|
@@ -14,7 +14,6 @@ import com.abi.qms.platform.dao.tablestore.entity.QrCode;
|
|
|
import com.abi.qms.platform.dao.vo.result.QrRepertoryColumnVO;
|
|
|
import com.abi.qms.platform.dao.vo.result.QrRepertoryVO;
|
|
|
import com.abi.qms.platform.feign.BasicServiceClient;
|
|
|
-import com.abi.qms.platform.infrastructure.mq.GenerateCodeConsumer;
|
|
|
import com.abi.qms.platform.infrastructure.mq.TableStoreBatchInsertConsumer;
|
|
|
import com.abi.qms.platform.infrastructure.qr.build.parent.SerialBuildCode;
|
|
|
import com.abi.qms.platform.infrastructure.util.BuildCodeUtil;
|
|
@@ -25,7 +24,6 @@ import com.abi.qms.platform.service.QrPackageService;
|
|
|
import com.abi.task.common.api.exception.BusinessException;
|
|
|
import com.abi.task.common.utils.PojoConverterUtils;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import net.lingala.zip4j.core.ZipFile;
|
|
|
import net.lingala.zip4j.exception.ZipException;
|
|
@@ -34,12 +32,9 @@ import net.lingala.zip4j.util.Zip4jConstants;
|
|
|
import org.apache.commons.fileupload.FileItem;
|
|
|
import org.apache.commons.fileupload.FileItemFactory;
|
|
|
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
import org.redisson.api.RLock;
|
|
|
import org.redisson.api.RedissonClient;
|
|
|
import org.springframework.amqp.core.AmqpTemplate;
|
|
|
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
|
|
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.DigestUtils;
|
|
@@ -202,7 +197,7 @@ public class GenerateCodeServiceImpl implements GenerateCodeService {
|
|
|
log.info("7 loopGenerateCode save tablestore async -->"+System.currentTimeMillis());
|
|
|
|
|
|
|
|
|
- String md5 = createCodeFile(qrRepertory, batchNumber, qrBoxCodeFormat, fileList, codeList);
|
|
|
+ String md5 = createCodeFile(qrRepertory,splitCache, batchNumber, qrBoxCodeFormat, fileList, codeList);
|
|
|
fileVerifyMd5List.add(md5);
|
|
|
log.info("8 loopGenerateCode create file -->"+System.currentTimeMillis());
|
|
|
}catch(Exception e){
|
|
@@ -412,7 +407,6 @@ public class GenerateCodeServiceImpl implements GenerateCodeService {
|
|
|
StringBuilder codeSb = new StringBuilder();
|
|
|
|
|
|
for (int i = 0; i < needGenerateNumber; i++) {
|
|
|
- log.info("doLoopGenerateCode 的疑似死循环.2");
|
|
|
QrData qrData = new QrData()
|
|
|
.setQrRepertoryId(qrRepertoryId)
|
|
|
.setBatchNumber(batchNumber)
|
|
@@ -422,38 +416,25 @@ public class GenerateCodeServiceImpl implements GenerateCodeService {
|
|
|
List<QrInnerData> qrInnerDataList = new LinkedList<>();
|
|
|
|
|
|
for (int a = 0; a < boxCodeFormat.getFormatNumber(); a++) {
|
|
|
- log.info("doLoopGenerateCode 的疑似死循环.3");
|
|
|
for (int j = 0; j < qrRepertoryColumnList.size(); j++) {
|
|
|
- log.info("doLoopGenerateCode 的疑似死循环.4");
|
|
|
QrRepertoryColumnVO qrRepertoryColumn = qrRepertoryColumnList.get(j);
|
|
|
Long qrRepertoryColumnId = qrRepertoryColumn.getId();
|
|
|
-
|
|
|
- int splitNum = 0;
|
|
|
- if(splitCache.containsKey(qrRepertoryColumnId)){
|
|
|
- splitNum = splitCache.get(qrRepertoryColumnId).getSplitNum();
|
|
|
- }
|
|
|
|
|
|
String code = buildUniqueCode(uniqueSet, qrRepertoryColumn, codeSb, paramMap, qrRepertorySerialNumberMap, 0);
|
|
|
if (code == null) {
|
|
|
throw new RuntimeException("生成码失败,重复生成码次数超过" + REPEAT_BUILD_CODE_TIMES + "次");
|
|
|
}
|
|
|
|
|
|
- if( splitNum >0){
|
|
|
- List<char[]> codeStr = segmentation(code, splitNum);
|
|
|
- for (char[] chars:codeStr) {
|
|
|
- QrInnerData qrInnerData = new QrInnerData();
|
|
|
- qrInnerData.setCode(String.valueOf(chars));
|
|
|
- qrInnerData.setQrRepertoryColumnId(qrRepertoryColumnId).setSortNumber(qrRepertoryColumn.getSortNumber());
|
|
|
- qrInnerData.setCodeIndex(++qrIndex);
|
|
|
- qrInnerDataList.add(qrInnerData);
|
|
|
- }
|
|
|
- } else {
|
|
|
- QrInnerData qrInnerData = new QrInnerData();
|
|
|
- qrInnerData.setCode(code);
|
|
|
- qrInnerData.setQrRepertoryColumnId(qrRepertoryColumnId).setSortNumber(qrRepertoryColumn.getSortNumber());
|
|
|
- qrInnerData.setCodeIndex(++qrIndex);
|
|
|
- qrInnerDataList.add(qrInnerData);
|
|
|
+ int splitNum = 0;
|
|
|
+ if(splitCache.containsKey(qrRepertoryColumnId)){
|
|
|
+ splitNum = splitCache.get(qrRepertoryColumnId).getSplitNum();
|
|
|
}
|
|
|
+ QrInnerData qrInnerData = new QrInnerData();
|
|
|
+ qrInnerData.setCode(code);
|
|
|
+ qrInnerData.setQrRepertoryColumnId(qrRepertoryColumnId).setSortNumber(qrRepertoryColumn.getSortNumber());
|
|
|
+ qrInnerData.setCodeIndex(++qrIndex);
|
|
|
+ qrInnerData.setSplitNum(splitNum);
|
|
|
+ qrInnerDataList.add(qrInnerData);
|
|
|
}
|
|
|
}
|
|
|
qrData.setInnerDataList(qrInnerDataList);
|
|
@@ -520,13 +501,24 @@ public class GenerateCodeServiceImpl implements GenerateCodeService {
|
|
|
|
|
|
* 创建码文件
|
|
|
*/
|
|
|
- private String createCodeFile( QrRepertoryVO qrRepertory,String batchNumber,QrBoxCodeFormat boxCodeFormat,ArrayList<File> fileList,List<QrData> qrDataList) {
|
|
|
+ private String createCodeFile( QrRepertoryVO qrRepertory,Map<Long,QrBoxCodeFormatSplit> splitCache,String batchNumber,QrBoxCodeFormat boxCodeFormat,ArrayList<File> fileList,List<QrData> codeList) {
|
|
|
List<QrRepertoryColumnVO> qrRepertoryColumnList = qrRepertory.getQrRepertoryColumnList();
|
|
|
+ List<String> columnNameList = new ArrayList<>();
|
|
|
StringBuilder content = new StringBuilder();
|
|
|
|
|
|
- String dataComposition = qrRepertoryColumnList.stream().map(col -> col.getAlias()).collect(Collectors.joining(","));
|
|
|
+ for(QrRepertoryColumnVO colVO:qrRepertoryColumnList){
|
|
|
+ int splitNum = splitCache.containsKey(colVO.getId()) ? splitCache.get(colVO.getId()).getSplitNum() : 0;
|
|
|
+ if(splitNum>1){
|
|
|
+ for(int i=1;i<=splitNum;i++){
|
|
|
+ columnNameList.add(colVO.getAlias()+i);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ columnNameList.add(colVO.getAlias());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String dataComposition = String.join(",",columnNameList);
|
|
|
content.append(dataComposition);
|
|
|
-
|
|
|
+
|
|
|
if(boxCodeFormat.getFormatNumber() > 1){
|
|
|
for (int i = 1; i < boxCodeFormat.getFormatNumber(); i++) {
|
|
|
content.append(",").append(dataComposition);
|
|
@@ -534,11 +526,22 @@ public class GenerateCodeServiceImpl implements GenerateCodeService {
|
|
|
}
|
|
|
content.append("\r\n");
|
|
|
|
|
|
- List<QrInnerData> innerDataList;
|
|
|
- String innerData;
|
|
|
- for (QrData qrData : qrDataList) {
|
|
|
- innerDataList = qrData.getInnerDataList();
|
|
|
- innerData = innerDataList.stream().map(qrInnerData -> qrInnerData.getCode()).collect(Collectors.joining(","));
|
|
|
+ for (QrData qrData : codeList) {
|
|
|
+ List<String> codeTextList = new ArrayList<>();
|
|
|
+ for(QrInnerData qrInnerData:qrData.getInnerDataList()){
|
|
|
+ String code = qrInnerData.getCode();
|
|
|
+ int splitNum = qrInnerData.getSplitNum();
|
|
|
+
|
|
|
+ if(splitNum>1){
|
|
|
+ List<char[]> codeStr = segmentation(code, splitNum);
|
|
|
+ for (char[] chars:codeStr) {
|
|
|
+ codeTextList.add(String.valueOf(chars));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ codeTextList.add(code);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String innerData = String.join(",",codeTextList);
|
|
|
content.append(innerData).append("\r\n");
|
|
|
}
|
|
|
|