|
@@ -12,6 +12,7 @@ import com.abi.qms.platform.dao.vo.result.*;
|
|
|
import com.abi.qms.platform.dto.req.*;
|
|
|
import com.abi.qms.platform.dto.res.*;
|
|
|
import com.abi.qms.platform.infrastructure.util.AssertUtil;
|
|
|
+import com.abi.qms.platform.infrastructure.util.AsyncTableStoreUtil;
|
|
|
import com.abi.qms.platform.infrastructure.util.PageUtil;
|
|
|
import com.abi.qms.platform.infrastructure.util.UserUtil;
|
|
|
import com.abi.qms.platform.service.QrBoxMappingService;
|
|
@@ -25,6 +26,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.google.common.collect.Maps;
|
|
|
+import com.sun.org.apache.bcel.internal.generic.NEW;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -39,8 +41,6 @@ import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
-import java.util.regex.Matcher;
|
|
|
-import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
|
* @author: fangxinjian
|
|
@@ -63,12 +63,20 @@ public class QrBoxMappingServiceImpl implements QrBoxMappingService {
|
|
|
@Autowired
|
|
|
private BaseFactoryMapper baseFactoryMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private AsyncTableStoreUtil asyncTableStoreUtil;
|
|
|
+
|
|
|
private static final String SUCCESS = "success";
|
|
|
|
|
|
private static final String FAIL = "fail";
|
|
|
|
|
|
+ /**
|
|
|
+ * 生成箱码合一文件,罐码使用这个逻辑(用首位码段生成)
|
|
|
+ * @param req
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Override
|
|
|
- public String generateBarCode(GenerateBarCodeReq req) {
|
|
|
+ public String addQrBoxMappingByFirstAndLast(GenerateBarCodeReq req) {
|
|
|
|
|
|
//获取登录用户信息
|
|
|
UserInfo user = userUtil.getUser();
|
|
@@ -115,6 +123,55 @@ public class QrBoxMappingServiceImpl implements QrBoxMappingService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 生成箱码合一文件,盖码使用这个逻辑(每一个码都再tablestore记录箱码合一信息)
|
|
|
+ * @param codeList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String addQrBoxMappingByFileUpload(List<String> codeList,Long packageId) {
|
|
|
+ //如果入参有问题则短路
|
|
|
+ if(CollectionUtils.isEmpty(codeList)){
|
|
|
+ throw new BusinessException("箱码合一的码数量为0");
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取登录用户信息
|
|
|
+ UserInfo user = userUtil.getUser();
|
|
|
+
|
|
|
+ //1-构造持久化对象
|
|
|
+ QrBoxMapping qrBoxMapping = new QrBoxMapping();
|
|
|
+ qrBoxMapping.setBoxCode(String.valueOf(IdWorker.getId()));
|
|
|
+ qrBoxMapping.setIndexBegin(0L);
|
|
|
+ qrBoxMapping.setIndexEnd(0L);
|
|
|
+ qrBoxMapping.setBeginQrCode(codeList.get(0));
|
|
|
+ qrBoxMapping.setEndQrCode(codeList.get(codeList.size()-1));
|
|
|
+ qrBoxMapping.setQrCodeCount(Long.valueOf(codeList.size()));
|
|
|
+ qrBoxMapping.setActiveStatus(BoxMappingActiveStatusEnum.NOT_ACTIVE.getCode());
|
|
|
+ qrBoxMapping.setCreateUserName(user.getUserName());
|
|
|
+ qrBoxMapping.setCreateBy(user.getId());
|
|
|
+ qrBoxMapping.setPackageId(packageId);
|
|
|
+ qrBoxMapping.setInvalid(InvalidEnum.NOT_INVALID.getCode());
|
|
|
+ qrBoxMappingMapper.insert(qrBoxMapping);
|
|
|
+
|
|
|
+ //2-修改tablestore里面的码的箱码合一文件id
|
|
|
+ Integer max = 10000;
|
|
|
+ List<QrCode> qrCodeList = new ArrayList<>();
|
|
|
+ for(int i=0;i<codeList.size();i++){
|
|
|
+ QrCode qrCode = new QrCode();
|
|
|
+ qrCode.setCode(codeList.get(i));
|
|
|
+ qrCode.setQrBoxMappingId(qrBoxMapping.getId());
|
|
|
+ qrCodeList.add(qrCode);
|
|
|
+ //每一批满了 or 最后一批 就保存一下
|
|
|
+ if((i+1)%max==0 || i==codeList.size()-1){
|
|
|
+ asyncTableStoreUtil.mqUpdateRow(qrCodeList,"qrBoxMappingId");
|
|
|
+ qrCodeList.clear();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return qrBoxMapping.getBoxCode();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public ListQrBoxCodeMappingRes listQrBoxCodeMapping(ListQrBoxCodeMappingReq req) {
|
|
|
|
|
@@ -332,13 +389,12 @@ public class QrBoxMappingServiceImpl implements QrBoxMappingService {
|
|
|
String filename = file.getName();
|
|
|
String encryptCodeStr;
|
|
|
|
|
|
- String first = null;
|
|
|
- String last = null;
|
|
|
-
|
|
|
try {
|
|
|
inputStream = file.getInputStream();
|
|
|
//解决服务器上乱码
|
|
|
reader = new LineNumberReader(new InputStreamReader(inputStream, "UTF-8"));
|
|
|
+ //待修改的tablestore对象列表
|
|
|
+ List<String> codeList = new ArrayList<>();
|
|
|
|
|
|
//1-逐行读取文件的码
|
|
|
while ((encryptCodeStr = reader.readLine()) != null) {
|
|
@@ -346,30 +402,17 @@ public class QrBoxMappingServiceImpl implements QrBoxMappingService {
|
|
|
if (StringUtils.isBlank(encryptCodeStr)) {
|
|
|
continue;
|
|
|
}
|
|
|
-// //判断有没有中文标题
|
|
|
-// Pattern p = Pattern.compile("[\u4e00-\u9fa5]");
|
|
|
-// Matcher m = p.matcher(encryptCodeStr);
|
|
|
- if (reader.getLineNumber()>2) {
|
|
|
- if (encryptCodeStr.contains(",")) {
|
|
|
- throw new BusinessException("码包文件格式错误,建议每行一个码!");
|
|
|
- }
|
|
|
- //截取 去掉uri
|
|
|
- encryptCodeStr = encryptCodeStr.substring(encryptCodeStr.lastIndexOf("/") + 1);
|
|
|
-
|
|
|
- if (StringUtils.isBlank(first)) {
|
|
|
- first = encryptCodeStr;
|
|
|
- }
|
|
|
- last = encryptCodeStr;
|
|
|
+ if (encryptCodeStr.contains(",")) {
|
|
|
+ throw new BusinessException("码包文件格式错误,建议每行一个码!");
|
|
|
}
|
|
|
-
|
|
|
+ //截取 去掉uri
|
|
|
+ encryptCodeStr = encryptCodeStr.substring(encryptCodeStr.lastIndexOf("/") + 1);
|
|
|
+ //放入tablestore entity的主键code
|
|
|
+ codeList.add(encryptCodeStr);
|
|
|
}
|
|
|
|
|
|
//生成条形码
|
|
|
- GenerateBarCodeReq req = new GenerateBarCodeReq();
|
|
|
- req.setBeginQrCode(first);
|
|
|
- req.setEndQrCode(last);
|
|
|
- req.setPackageId(packageId);
|
|
|
- generateBarCode(req);
|
|
|
+ addQrBoxMappingByFileUpload(codeList,packageId);
|
|
|
|
|
|
} catch (BusinessException e) {
|
|
|
throw e;
|