|
@@ -2,7 +2,6 @@ package com.management.platform.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.google.zxing.WriterException;
|
|
|
import com.management.platform.entity.ErpOrderInfo;
|
|
|
import com.management.platform.mapper.ErpOrderInfoMapper;
|
|
@@ -10,6 +9,7 @@ import com.management.platform.util.HttpRespMsg;
|
|
|
import com.management.platform.util.QRCodeUtil;
|
|
|
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
|
|
|
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
@@ -32,21 +32,29 @@ public class QRCodeController {
|
|
|
@Value("${upload.path}")
|
|
|
private String uploadPath;
|
|
|
|
|
|
+ private static final int specialCompanyId = 7536;
|
|
|
+
|
|
|
@RequestMapping("/generateQRCodeByErpIds")
|
|
|
public HttpRespMsg generateQRCodeByErpIds(@RequestParam("erpIds")String erpIds){
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
String[] split = erpIds.split(",");
|
|
|
List<String> list = Arrays.asList(split);
|
|
|
- List<ErpOrderInfo> erpList = erpOrderInfoMapper.selectList(new LambdaQueryWrapper<ErpOrderInfo>()
|
|
|
- .in(ErpOrderInfo::getId,list)
|
|
|
- );
|
|
|
+ if(StringUtils.isBlank(erpIds) || list.isEmpty()){
|
|
|
+ msg.setError("编号不能为空");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ List<ErpOrderInfo> erpList = erpOrderInfoMapper.getWithProject(list,specialCompanyId);
|
|
|
+// List<ErpOrderInfo> erpList = erpOrderInfoMapper.selectList(new LambdaQueryWrapper<ErpOrderInfo>()
|
|
|
+// .in(ErpOrderInfo::getId,list)
|
|
|
+// );
|
|
|
String[] filesToZip = new String[erpList.size()];
|
|
|
int index = 0;
|
|
|
for (ErpOrderInfo erpOrderInfo : erpList) {
|
|
|
String data = JSON.toJSONString(erpOrderInfo);
|
|
|
int width = 300; // 二维码宽度
|
|
|
int height = 300; // 二维码高度
|
|
|
- String fileName = "项目二维码_"+null!=erpOrderInfo.getMoDId()?erpOrderInfo.getMoDId():""+System.currentTimeMillis()+".png";
|
|
|
+ String s = null != erpOrderInfo.getMoDId() ? erpOrderInfo.getMoDId() : "";
|
|
|
+ String fileName = "项目二维码_"+s+System.currentTimeMillis()+".png";
|
|
|
try {
|
|
|
QRCodeUtil.generateQRCodeImage(data, width, height, uploadPath+fileName);
|
|
|
} catch (WriterException e) {
|
|
@@ -58,7 +66,7 @@ public class QRCodeController {
|
|
|
msg.setError("二维码生成失败,请联系管理员");
|
|
|
return msg;
|
|
|
}
|
|
|
- filesToZip[index] = fileName;
|
|
|
+ filesToZip[index] = uploadPath+fileName;
|
|
|
index++;
|
|
|
}
|
|
|
|