Professional Documents
Culture Documents
新建 文本文档
新建 文本文档
新建 文本文档
map.put("approvecontent",mOrder.getApprovecontent()==null?"":mOrder.getApproveconte
nt());
/*hmf 20210416 添加审核时间,添加按照规格统计重量*/
if (null != mOrder.getApprovedate()) {
map.put("approvedate", sdf.format(mOrder.getApprovedate()));//审核时
间
} else {
map.put("approvedate", "");//审核时间
}
List<HashMap<String, Object>> listKey =
mOrderDtlMapper.selectOrderDtlSumCusliweightByPkOrder(pkorder);
for (int i = 0; i < listKey.size(); i++) {
HashMap<String, Object> hashMap = listKey.get(i);
if (hashMap.containsKey("diaweightbypkorder")) {
hashMap.put("diaweightbypkorder", new
DataConverUtil().roundByScale(((BigDecimal)
hashMap.get("diaweightbypkorder")).doubleValue(),3));
}
hashMap.put("no", i + 1);
}
map.put("listKey", listKey);//【导出技术交底】根据订单主键按照规格直径统计重量
//填充子表
/*p--导出技术交底【长度】使用方式(默认 2 方式计算后的长度):1=zlong(总长),
2=mlong(计算后的长度)*/
//Integer longValue = getMlongMode(pkcompany);
List<Map<String, Object>> list = new ArrayList<>();
List<Map<String,Object>> list1 = new ArrayList<>();
for (int i = 0; i < mOrderDtlList.size(); i++) {
MOrderDtl mOrderDtl = mOrderDtlList.get(i);
MBasicProduct mBasicProduct =
mBasicProductMapper.selectByPrimaryKey(mOrderDtl.getPkproduct());
if (mBasicProduct == null) {
int intindexno = mOrderDtlList.get(i).getDef20().intValue();
throw new MyException(EMError.DOWNLOAD_ERROR, "第" + intindexno
+ "号数据没有查到成品信息,无法导出");
}
MBasicDiameter mBasicDiameter =
mBasicDiameterMapper.selectByPrimaryKey(mOrderDtl.getCusdiameter());
MBasicSpec mBasicSpec =
mBasicSpecMapper.selectByPrimaryKey(mOrderDtl.getCusspec());
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("id", mOrderDtl.getDef20());
String cusno = "";
if (mOrderDtl.getCusno() == null) {
cusno = "无";
} else {
cusno = mOrderDtl.getCusno();
}
dataMap.put("cusno", cusno);
String cusspecdiameter = "";
String spec = "";
if (mBasicSpec != null) {
spec = mBasicSpec.getSpec();
cusspecdiameter = cusspecdiameter + spec;
}
String diameter = "";
if (mBasicDiameter != null) {
diameter =
CommonTool.doubleRemoveZeros(mBasicDiameter.getDiameter());
cusspecdiameter = cusspecdiameter + "-" + diameter;
}
dataMap.put("cusdiameter", diameter);
/*hmf 20210416 添加*/
dataMap.put("orderno", mOrderDtl.getDef20());//订单序号
dataMap.put("cusspecdiameter", cusspecdiameter);//规格-直接
dataMap.put("proname", "(" +
(mBasicProduct.getTuhao()==null?"":mBasicProduct.getTuhao()) + ")" +
mBasicProduct.getProname());
Integer mlong = mBasicProduct.getMlong();
if (longType.intValue() == 1) {
//结算技术交底,使用 zlong
mlong = mBasicProduct.getZlong();
}
dataMap.put("cuslong", CommonTool.numberFormat(mlong));
dataMap.put("neednum",
CommonTool.numberFormat(mOrderDtl.getNeednum()));
dataMap.put("cusliweight", new
DataConverUtil().roundByScale(mOrderDtl.getCusliweight(),3));
String goujianname = "";
if (mOrderDtl.getGoujianname() == null) {
goujianname = "/";
} else {
goujianname = mOrderDtl.getGoujianname() + "/";
;
}
if (mOrderDtl.getGoujianplace() != null) {
if (mOrderDtl.getGoujianplace().length() > 0) {
goujianname = goujianname + mOrderDtl.getGoujianplace();
}
}
dataMap.put("goujianname", goujianname);
//备注:判断产品备注和订单备注是否相同,不相同的话合并显示
String remark;
String productRemark = mBasicProduct.getRemark();
String orderDtlRemark = mOrderDtl.getRemark();
if (null == productRemark || "".equals(productRemark)) {
remark = orderDtlRemark;
} else {
remark = productRemark + "" + orderDtlRemark;
}
dataMap.put("remark", remark);
/*//查询图形表
MBasicChart mBasicChart =
mBasicChartMapper.selectByPrimaryKey(Integer.valueOf(mOrderDtl.getPkchart()));
//得到图片 base64
String imageBase = DrawCommon.paint1(mBasicChart.getChartpar());*/
//产品中获取图片 base64
String imgBase = new String(mBasicProduct.getDef1());
if (imgBase == null || imgBase.equals("")) {
imgBase =
mBasicProductService.getpicbase64(mBasicProduct.getDef9(),
mBasicProduct.getDef10(), mBasicProduct.getPkchart());
}
String[] split = imgBase.split(",");
if (split.length > 1) {
imgBase = split[1];
}
dataMap.put("imageBase", imgBase);
dataMap.put("imageIndex", i + 1);
/*根据产品主键获取二维码 base64*/
String qrCodeImageBase = getQRCode("CP", mOrderDtl.getPkproduct() +
"");
dataMap.put("QRCodeImageBase", qrCodeImageBase);
list.add(dataMap);
}
map.put("newList", list);
for(MOrderAcessoriesTempPo
mOrderAcessoriesTempPo :mOrderAcessoriesList){
Map<String, Object> dataMap = new HashMap<>();
String rawcode = mOrderAcessoriesTempPo.getRawcode()
==null?"":mOrderAcessoriesTempPo.getRawcode();
dataMap.put("rawcode",rawcode);
String rawname = mOrderAcessoriesTempPo.getRawname()
==null?"":mOrderAcessoriesTempPo.getRawname();
dataMap.put("rawname",rawname);
String spec = mOrderAcessoriesTempPo.getSpec()
==null?"":mOrderAcessoriesTempPo.getSpec();
dataMap.put("spec",spec);
dataMap.put("acessoriesnum",mOrderAcessoriesTempPo.getAcessoriesnum());
dataMap.put("acessoriesliweight", new
DataConverUtil().roundByScale(mOrderAcessoriesTempPo.getAcessoriesliweight(),3));;
String remark = mOrderAcessoriesTempPo.getRemark()
==null?"":mOrderAcessoriesTempPo.getRemark();
dataMap.put("remark",remark);
list1.add(dataMap);
}
map.put("newList1", list1);
//2.调用生成工具 orderTechnical2 orderTechnical
// fileName = customer + "-"+mOrder.getCusbillno()+"-"+
mOrder.getBillno()+ ".doc";
if (fileName.contains(customer)){
//生成单个 新的文件名
fileName +=
GetCurUser.getCusBasicUser().getUsername().concat(DateUtil.getcurrDate()).concat(ff
HouZhui);
response.setHeader("Access-Control-Expose-Headers", "Content-
Disposition");
response.setCharacterEncoding("utf-8");
response.setHeader("content-type", "application/octet-stream");
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename="
.concat(String.valueOf(URLEncoder.encode(fileName, "UTF-
8"))));
File file1 = new File(jarpath);
bis = new FileInputStream(file1);
bs = new BufferedInputStream(bis);
os = response.getOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = bs.read(buffer)) != -1) {
os.write(buffer, 0, len);
}
}catch (Exception e) {
throw new MyException(EMError.DOWNLOAD_ERROR, "文件导出下载异常");
} finally {
try {
if (bis != null) {
bis.close();
}
if (bs != null) {
bs.close();
}
if (os != null) {
os.flush();
os.close();
}
}
catch (IOException e) {
e.printStackTrace();
}
}
// InputStream fin = new FileInputStream(file);
// ServletOutputStream out = null;
// response.setHeader("Access-Control-Expose-Headers", "Content-
Disposition");
// response.setCharacterEncoding("utf-8");
// response.setContentType("application/msword");
// // 设置浏览器以下载的方式处理该文件名
// String fileName = customer + "-"+mOrder.getCusbillno()+"-"+
mOrder.getBillno()+ ".doc";
// response.setHeader("Content-Disposition", "attachment;filename="
// .concat(String.valueOf(URLEncoder.encode(fileName, "UTF-
8"))));
// out = response.getOutputStream();
// byte[] buffer = new byte[512]; // 缓冲区
// int bytesToRead = -1;
// // 通过循环将读入的 Word 文件的内容输出到浏览器中
// while ((bytesToRead = fin.read(buffer)) != -1) {
// out.write(buffer, 0, bytesToRead);
// }
// out.close();
// } catch (IOException e) {
// e.printStackTrace();
// } catch (TemplateException e) {
// e.printStackTrace();
// } catch (Exception e) {
// e.printStackTrace();
// }
return "success";
}