|
@@ -1,15 +1,20 @@
|
|
package com.abi.qms.platform.service.impl;
|
|
package com.abi.qms.platform.service.impl;
|
|
|
|
|
|
|
|
+import com.abi.qms.platform.dao.entity.BaseFactory;
|
|
import com.abi.qms.platform.dao.entity.QrBoxMapping;
|
|
import com.abi.qms.platform.dao.entity.QrBoxMapping;
|
|
import com.abi.qms.platform.dao.entity.UserInfo;
|
|
import com.abi.qms.platform.dao.entity.UserInfo;
|
|
import com.abi.qms.platform.dao.enums.BoxMappingActiveStatusEnum;
|
|
import com.abi.qms.platform.dao.enums.BoxMappingActiveStatusEnum;
|
|
|
|
+import com.abi.qms.platform.dao.mapper.BaseFactoryMapper;
|
|
import com.abi.qms.platform.dao.mapper.QrBoxMappingMapper;
|
|
import com.abi.qms.platform.dao.mapper.QrBoxMappingMapper;
|
|
import com.abi.qms.platform.dao.tablestore.entity.QrCode;
|
|
import com.abi.qms.platform.dao.tablestore.entity.QrCode;
|
|
|
|
+import com.abi.qms.platform.dao.vo.result.PrintingDetailVO;
|
|
import com.abi.qms.platform.dao.vo.result.QrBoxMappingVO;
|
|
import com.abi.qms.platform.dao.vo.result.QrBoxMappingVO;
|
|
import com.abi.qms.platform.dto.req.ActiveBoxCodeReq;
|
|
import com.abi.qms.platform.dto.req.ActiveBoxCodeReq;
|
|
import com.abi.qms.platform.dto.req.GenerateBarCodeReq;
|
|
import com.abi.qms.platform.dto.req.GenerateBarCodeReq;
|
|
import com.abi.qms.platform.dto.req.ListQrBoxCodeMappingReq;
|
|
import com.abi.qms.platform.dto.req.ListQrBoxCodeMappingReq;
|
|
|
|
+import com.abi.qms.platform.dto.req.PrintingDetailReq;
|
|
import com.abi.qms.platform.dto.res.ListQrBoxCodeMappingRes;
|
|
import com.abi.qms.platform.dto.res.ListQrBoxCodeMappingRes;
|
|
|
|
+import com.abi.qms.platform.dto.res.PrintingDetailRes;
|
|
import com.abi.qms.platform.dto.res.QrBoxCodeUploadRes;
|
|
import com.abi.qms.platform.dto.res.QrBoxCodeUploadRes;
|
|
import com.abi.qms.platform.dto.res.UploadFileRes;
|
|
import com.abi.qms.platform.dto.res.UploadFileRes;
|
|
import com.abi.qms.platform.infrastructure.util.AssertUtil;
|
|
import com.abi.qms.platform.infrastructure.util.AssertUtil;
|
|
@@ -19,6 +24,7 @@ import com.abi.qms.platform.service.QrBoxMappingService;
|
|
import com.abi.task.common.api.exception.BusinessException;
|
|
import com.abi.task.common.api.exception.BusinessException;
|
|
import com.abi.task.common.tablestore.TableStorePlusUtils;
|
|
import com.abi.task.common.tablestore.TableStorePlusUtils;
|
|
import com.abi.task.common.utils.PojoConverterUtils;
|
|
import com.abi.task.common.utils.PojoConverterUtils;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Maps;
|
|
@@ -34,6 +40,8 @@ import java.io.InputStreamReader;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.regex.Matcher;
|
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author: fangxinjian
|
|
* @author: fangxinjian
|
|
@@ -53,6 +61,9 @@ public class QrBoxMappingServiceImpl implements QrBoxMappingService {
|
|
@Autowired
|
|
@Autowired
|
|
private UserUtil userUtil;
|
|
private UserUtil userUtil;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private BaseFactoryMapper baseFactoryMapper;
|
|
|
|
+
|
|
private static final String SUCCESS = "success";
|
|
private static final String SUCCESS = "success";
|
|
|
|
|
|
private static final String FAIL = "fail";
|
|
private static final String FAIL = "fail";
|
|
@@ -85,6 +96,7 @@ public class QrBoxMappingServiceImpl implements QrBoxMappingService {
|
|
qbm.setRemark(req.getRemark());
|
|
qbm.setRemark(req.getRemark());
|
|
qbm.setCreateUserName(user.getUserName());
|
|
qbm.setCreateUserName(user.getUserName());
|
|
qbm.setCreateBy(user.getId());
|
|
qbm.setCreateBy(user.getId());
|
|
|
|
+ qbm.setPackageId(req.getPackageId());
|
|
qrBoxMappingMapper.insert(qbm);
|
|
qrBoxMappingMapper.insert(qbm);
|
|
|
|
|
|
}
|
|
}
|
|
@@ -106,7 +118,7 @@ public class QrBoxMappingServiceImpl implements QrBoxMappingService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public QrBoxCodeUploadRes uploadCodeFiles(Map<String, MultipartFile> map) {
|
|
|
|
|
|
+ public QrBoxCodeUploadRes uploadCodeFiles(Map<String, MultipartFile> map, Long packageId) {
|
|
|
|
|
|
QrBoxCodeUploadRes res = new QrBoxCodeUploadRes();
|
|
QrBoxCodeUploadRes res = new QrBoxCodeUploadRes();
|
|
Map<String, UploadFileRes> resultMap = Maps.newHashMap();
|
|
Map<String, UploadFileRes> resultMap = Maps.newHashMap();
|
|
@@ -115,14 +127,14 @@ public class QrBoxMappingServiceImpl implements QrBoxMappingService {
|
|
//核心!!!上传文件
|
|
//核心!!!上传文件
|
|
try {
|
|
try {
|
|
//上传箱码文件
|
|
//上传箱码文件
|
|
- doUpload(file);
|
|
|
|
- resultMap.put(o.getKey(), new UploadFileRes(SUCCESS, ""));
|
|
|
|
|
|
+ doUpload(file, packageId);
|
|
|
|
+ resultMap.put(o.getKey(), new UploadFileRes(SUCCESS, "上传箱码合一文件成功!"));
|
|
} catch (BusinessException e) {
|
|
} catch (BusinessException e) {
|
|
log.info("文件上传失败");
|
|
log.info("文件上传失败");
|
|
resultMap.put(o.getKey(), new UploadFileRes(FAIL, e.getMessage()));
|
|
resultMap.put(o.getKey(), new UploadFileRes(FAIL, e.getMessage()));
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.info("文件上传异常", e);
|
|
log.info("文件上传异常", e);
|
|
- resultMap.put(o.getKey(), new UploadFileRes(FAIL, ""));
|
|
|
|
|
|
+ resultMap.put(o.getKey(), new UploadFileRes(FAIL, e.getMessage()));
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
@@ -151,6 +163,20 @@ public class QrBoxMappingServiceImpl implements QrBoxMappingService {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public PrintingDetailRes getPrintingDetail(PrintingDetailReq req) {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ PrintingDetailVO printingDetail = qrBoxMappingMapper.getPrintingDetail(req.getPackageId());
|
|
|
|
+ PrintingDetailRes res = PojoConverterUtils.copy(printingDetail, PrintingDetailRes.class);
|
|
|
|
+ Long factoryCoverLevelTwoId = printingDetail.getFactoryCoverLevelTwoId();
|
|
|
|
+ Long factoryBeerId = printingDetail.getFactoryBeerId();
|
|
|
|
+ res.setFactoryCoverName(getFactoryName(factoryCoverLevelTwoId));
|
|
|
|
+ res.setFactoryBeerName(getFactoryName(factoryBeerId));
|
|
|
|
+
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 根据主键查询已生成码包位置
|
|
* 根据主键查询已生成码包位置
|
|
@@ -163,7 +189,7 @@ public class QrBoxMappingServiceImpl implements QrBoxMappingService {
|
|
return qrCode.getCodeIndex();
|
|
return qrCode.getCodeIndex();
|
|
}
|
|
}
|
|
|
|
|
|
- public void doUpload(MultipartFile file) {
|
|
|
|
|
|
+ public void doUpload(MultipartFile file, Long packageId) {
|
|
if (file.isEmpty()) {
|
|
if (file.isEmpty()) {
|
|
throw new BusinessException("文件为空,请重新选择文件");
|
|
throw new BusinessException("文件为空,请重新选择文件");
|
|
}
|
|
}
|
|
@@ -186,19 +212,29 @@ public class QrBoxMappingServiceImpl implements QrBoxMappingService {
|
|
if (StringUtils.isBlank(encryptCodeStr)) {
|
|
if (StringUtils.isBlank(encryptCodeStr)) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- //截取 去掉uri
|
|
|
|
- encryptCodeStr = encryptCodeStr.substring(encryptCodeStr.lastIndexOf("/") + 1);
|
|
|
|
-
|
|
|
|
- if (StringUtils.isBlank(first)) {
|
|
|
|
- first = encryptCodeStr;
|
|
|
|
|
|
+ //判断有没有中文标题
|
|
|
|
+ Pattern p = Pattern.compile("[\u4e00-\u9fa5]");
|
|
|
|
+ Matcher m = p.matcher(encryptCodeStr);
|
|
|
|
+ if (!m.find()) {
|
|
|
|
+ if (encryptCodeStr.contains(",")) {
|
|
|
|
+ throw new BusinessException("码包文件格式错误,建议每行一个码!");
|
|
|
|
+ }
|
|
|
|
+ //截取 去掉uri
|
|
|
|
+ encryptCodeStr = encryptCodeStr.substring(encryptCodeStr.lastIndexOf("/") + 1);
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isBlank(first)) {
|
|
|
|
+ first = encryptCodeStr;
|
|
|
|
+ }
|
|
|
|
+ last = encryptCodeStr;
|
|
}
|
|
}
|
|
- last = encryptCodeStr;
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
//生成条形码
|
|
//生成条形码
|
|
GenerateBarCodeReq req = new GenerateBarCodeReq();
|
|
GenerateBarCodeReq req = new GenerateBarCodeReq();
|
|
req.setBeginQrCode(first);
|
|
req.setBeginQrCode(first);
|
|
req.setEndQrCode(last);
|
|
req.setEndQrCode(last);
|
|
|
|
+ req.setPackageId(packageId);
|
|
generateBarCode(req);
|
|
generateBarCode(req);
|
|
|
|
|
|
} catch (BusinessException e) {
|
|
} catch (BusinessException e) {
|
|
@@ -229,5 +265,12 @@ public class QrBoxMappingServiceImpl implements QrBoxMappingService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private String getFactoryName(Long id) {
|
|
|
|
+ QueryWrapper<BaseFactory> qw = new QueryWrapper<>();
|
|
|
|
+ qw.eq("id", id);
|
|
|
|
+ qw.eq("is_delete", 0);
|
|
|
|
+ BaseFactory baseFactory = baseFactoryMapper.selectOne(qw);
|
|
|
|
+ return baseFactory.getFactoryName();
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|