|
@@ -21,9 +21,6 @@ import com.abi.qms.platform.service.QrPackageService;
|
|
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.tablestore.common.TableStoreEntity;
|
|
import com.abi.task.common.tablestore.common.TableStoreEntity;
|
|
-import com.abi.task.common.tablestore.entity.DemoEntity;
|
|
|
|
-import com.abi.task.common.utils.TableStoreUtils;
|
|
|
|
-import com.alicloud.openservices.tablestore.model.search.query.BoolQuery;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
import com.rabbitmq.client.Channel;
|
|
import com.rabbitmq.client.Channel;
|
|
@@ -39,7 +36,6 @@ import org.redisson.api.RedissonClient;
|
|
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
|
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
import org.springframework.amqp.support.AmqpHeaders;
|
|
import org.springframework.amqp.support.AmqpHeaders;
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.messaging.Message;
|
|
import org.springframework.messaging.Message;
|
|
@@ -48,7 +44,7 @@ import net.lingala.zip4j.core.ZipFile;
|
|
import net.lingala.zip4j.exception.ZipException;
|
|
import net.lingala.zip4j.exception.ZipException;
|
|
import net.lingala.zip4j.model.ZipParameters;
|
|
import net.lingala.zip4j.model.ZipParameters;
|
|
import net.lingala.zip4j.util.Zip4jConstants;
|
|
import net.lingala.zip4j.util.Zip4jConstants;
|
|
-import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
+import org.springframework.util.DigestUtils;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|
|
|
|
|
@@ -56,6 +52,7 @@ import java.io.File;
|
|
import java.io.FileInputStream;
|
|
import java.io.FileInputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.io.OutputStream;
|
|
import java.io.OutputStream;
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -119,7 +116,10 @@ public class GenerateCodeConsumer {
|
|
private File file = new File(this.getClass().getResource("/").getPath()+"/code");
|
|
private File file = new File(this.getClass().getResource("/").getPath()+"/code");
|
|
|
|
|
|
//批量添加文件
|
|
//批量添加文件
|
|
- private ArrayList<File> files = new ArrayList<>();
|
|
|
|
|
|
+ private ArrayList<File> fileList = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ //批量添加文件
|
|
|
|
+ private ArrayList<String> fileVerifyMd5List = new ArrayList<>();
|
|
|
|
|
|
/** 允许单个码生成重复的次数 */
|
|
/** 允许单个码生成重复的次数 */
|
|
private static final int REPEAT_BUILD_CODE_TIMES = 10;
|
|
private static final int REPEAT_BUILD_CODE_TIMES = 10;
|
|
@@ -130,10 +130,6 @@ public class GenerateCodeConsumer {
|
|
/** 声明码对应的值 */
|
|
/** 声明码对应的值 */
|
|
public Long codeIndex = 0L;
|
|
public Long codeIndex = 0L;
|
|
|
|
|
|
- /** 系统url */
|
|
|
|
- @Value("${system.url}")
|
|
|
|
- private String systemUrl;
|
|
|
|
-
|
|
|
|
@SneakyThrows
|
|
@SneakyThrows
|
|
@RabbitHandler
|
|
@RabbitHandler
|
|
@RabbitListener(queues = GenerateCodeConsumer.GENERATE_CODE_BY_REPERTORY_QUEUE)
|
|
@RabbitListener(queues = GenerateCodeConsumer.GENERATE_CODE_BY_REPERTORY_QUEUE)
|
|
@@ -257,7 +253,7 @@ public class GenerateCodeConsumer {
|
|
String pas = RandomCodeUtils.getStr(6);
|
|
String pas = RandomCodeUtils.getStr(6);
|
|
log.info("生成密码:"+pas);
|
|
log.info("生成密码:"+pas);
|
|
//压缩加密文件
|
|
//压缩加密文件
|
|
- zipEncryption(file,files,pas,zipName);
|
|
|
|
|
|
+ zipEncryption(file, fileList,pas,zipName);
|
|
//上传阿里云,并更新码包的下载路径 保存zip密码
|
|
//上传阿里云,并更新码包的下载路径 保存zip密码
|
|
try{
|
|
try{
|
|
MultipartFile multipartFile = toMultipartFile(file.getPath()+"\\"+zipName, zipName);
|
|
MultipartFile multipartFile = toMultipartFile(file.getPath()+"\\"+zipName, zipName);
|
|
@@ -277,6 +273,9 @@ public class GenerateCodeConsumer {
|
|
|
|
|
|
//3-更改生成状态为已生成
|
|
//3-更改生成状态为已生成
|
|
qrPackage.setGenerateStatus(QrPackageGenerateStatusEnum.GENERATE_SUCCESS.getCode());
|
|
qrPackage.setGenerateStatus(QrPackageGenerateStatusEnum.GENERATE_SUCCESS.getCode());
|
|
|
|
+ qrPackage.setGenerateTime(LocalDateTime.now());
|
|
|
|
+ //将MD5的字符换逗号拼接放入码包
|
|
|
|
+ qrPackage.setFileVerifyMd5(String.join(",",fileVerifyMd5List));
|
|
//根据包材厂获取包材厂负责人邮箱
|
|
//根据包材厂获取包材厂负责人邮箱
|
|
QueryWrapper<BaseFactory> baseQuery = new QueryWrapper<>();
|
|
QueryWrapper<BaseFactory> baseQuery = new QueryWrapper<>();
|
|
baseQuery.eq("id", qrPackage.getFactoryCoverId());
|
|
baseQuery.eq("id", qrPackage.getFactoryCoverId());
|
|
@@ -290,7 +289,7 @@ public class GenerateCodeConsumer {
|
|
index.setIndexCurrent(codeIndex);
|
|
index.setIndexCurrent(codeIndex);
|
|
qrIndexMapper.insert(index);
|
|
qrIndexMapper.insert(index);
|
|
redisClient.set("code_qr_index",codeIndex);
|
|
redisClient.set("code_qr_index",codeIndex);
|
|
- codeIndex = 0l;
|
|
|
|
|
|
+ codeIndex = 0L;
|
|
qrDataList.clear();
|
|
qrDataList.clear();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -333,19 +332,18 @@ public class GenerateCodeConsumer {
|
|
List<QrInnerData> innerDataList = qrData.getInnerDataList();
|
|
List<QrInnerData> innerDataList = qrData.getInnerDataList();
|
|
for (QrInnerData qrInnerData:innerDataList) {
|
|
for (QrInnerData qrInnerData:innerDataList) {
|
|
QrCode qrCode = new QrCode();
|
|
QrCode qrCode = new QrCode();
|
|
- qrCode.setId(String.valueOf(IdWorker.getId()));
|
|
|
|
//码
|
|
//码
|
|
qrCode.setCode(qrInnerData.getCode());
|
|
qrCode.setCode(qrInnerData.getCode());
|
|
//批次id
|
|
//批次id
|
|
qrCode.setBatchNumberId(qrPackageBatch.getId());
|
|
qrCode.setBatchNumberId(qrPackageBatch.getId());
|
|
//码包id
|
|
//码包id
|
|
qrCode.setPackageId(qrPackageBatch.getPackageId());
|
|
qrCode.setPackageId(qrPackageBatch.getPackageId());
|
|
- //要拼接的url
|
|
|
|
- qrCode.setUrl(qrInnerData.getUrl());
|
|
|
|
//创建时间
|
|
//创建时间
|
|
qrCode.setCreateTime(LocalDateTime.now());
|
|
qrCode.setCreateTime(LocalDateTime.now());
|
|
//已生成码包位置
|
|
//已生成码包位置
|
|
qrCode.setCodeIndex(qrInnerData.getCodeIndex());
|
|
qrCode.setCodeIndex(qrInnerData.getCodeIndex());
|
|
|
|
+ //生成码库列id
|
|
|
|
+ qrCode.setQrRepertoryColumnId(qrInnerData.getQrRepertoryColumnId());
|
|
codeSave.add(qrCode);
|
|
codeSave.add(qrCode);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -422,14 +420,14 @@ public class GenerateCodeConsumer {
|
|
List<char[]> codeStr = a(code, splitNum);
|
|
List<char[]> codeStr = a(code, splitNum);
|
|
for (char[] chars:codeStr) {
|
|
for (char[] chars:codeStr) {
|
|
QrInnerData qrInnerData = new QrInnerData();
|
|
QrInnerData qrInnerData = new QrInnerData();
|
|
- qrInnerData.setCode(String.valueOf(chars)).setUrl(url);
|
|
|
|
|
|
+ qrInnerData.setCode(String.valueOf(chars));
|
|
qrInnerData.setQrRepertoryColumnId(qrRepertoryColumnId).setSortNumber(qrRepertoryColumn.getSortNumber());
|
|
qrInnerData.setQrRepertoryColumnId(qrRepertoryColumnId).setSortNumber(qrRepertoryColumn.getSortNumber());
|
|
qrInnerData.setCodeIndex(codeIndex+=1);
|
|
qrInnerData.setCodeIndex(codeIndex+=1);
|
|
qrInnerDataList.add(qrInnerData);
|
|
qrInnerDataList.add(qrInnerData);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
QrInnerData qrInnerData = new QrInnerData();
|
|
QrInnerData qrInnerData = new QrInnerData();
|
|
- qrInnerData.setCode(code).setUrl(url);
|
|
|
|
|
|
+ qrInnerData.setCode(code);
|
|
qrInnerData.setQrRepertoryColumnId(qrRepertoryColumnId).setSortNumber(qrRepertoryColumn.getSortNumber());
|
|
qrInnerData.setQrRepertoryColumnId(qrRepertoryColumnId).setSortNumber(qrRepertoryColumn.getSortNumber());
|
|
qrInnerData.setCodeIndex(codeIndex+=1);
|
|
qrInnerData.setCodeIndex(codeIndex+=1);
|
|
qrInnerDataList.add(qrInnerData);
|
|
qrInnerDataList.add(qrInnerData);
|
|
@@ -462,16 +460,16 @@ public class GenerateCodeConsumer {
|
|
Long qrRepertoryColumnId = qrRepertoryColumn.getId();
|
|
Long qrRepertoryColumnId = qrRepertoryColumn.getId();
|
|
|
|
|
|
// 每列的url格式
|
|
// 每列的url格式
|
|
- Integer urlType = qrRepertoryColumn.getUrlType();
|
|
|
|
- String url = "";
|
|
|
|
- if (QrFormatUrlEnum.SYSTEM_URL.is(urlType)) {
|
|
|
|
- url = systemUrl;
|
|
|
|
- }
|
|
|
|
- // 如果url没有以/结尾,则加上/
|
|
|
|
- if (StringUtils.isNotBlank(url) && !url.endsWith("/")) {
|
|
|
|
- url += "/";
|
|
|
|
- }
|
|
|
|
- urlMap.put(qrRepertoryColumnId, url);
|
|
|
|
|
|
+// Integer urlType = qrRepertoryColumn.getUrlType();
|
|
|
|
+// String url = "";
|
|
|
|
+// if (QrFormatUrlEnum.SYSTEM_URL.is(urlType)) {
|
|
|
|
+// url = systemUrl;
|
|
|
|
+// }
|
|
|
|
+// // 如果url没有以/结尾,则加上/
|
|
|
|
+// if (StringUtils.isNotBlank(url) && !url.endsWith("/")) {
|
|
|
|
+// url += "/";
|
|
|
|
+// }
|
|
|
|
+ urlMap.put(qrRepertoryColumnId, "");
|
|
|
|
|
|
// 使用到流水号参数的列
|
|
// 使用到流水号参数的列
|
|
String[] buildClassArr = qrRepertoryColumn.getQrFormatVO().getCodeVariableBuildClass().split(",");
|
|
String[] buildClassArr = qrRepertoryColumn.getQrFormatVO().getCodeVariableBuildClass().split(",");
|
|
@@ -531,7 +529,7 @@ public class GenerateCodeConsumer {
|
|
String innerData;
|
|
String innerData;
|
|
for (QrData qrData : qrDataList) {
|
|
for (QrData qrData : qrDataList) {
|
|
innerDataList = qrData.getInnerDataList();
|
|
innerDataList = qrData.getInnerDataList();
|
|
- innerData = innerDataList.stream().map(qrInnerData -> qrInnerData.getUrl() + qrInnerData.getCode()).collect(Collectors.joining(","));
|
|
|
|
|
|
+ innerData = innerDataList.stream().map(qrInnerData -> qrInnerData.getCode()).collect(Collectors.joining(","));
|
|
content.append(innerData).append("\r\n");
|
|
content.append(innerData).append("\r\n");
|
|
}
|
|
}
|
|
//如果文件不存在,创建一个文件
|
|
//如果文件不存在,创建一个文件
|
|
@@ -546,7 +544,11 @@ public class GenerateCodeConsumer {
|
|
// 生成txt
|
|
// 生成txt
|
|
FileWriter fileWriter = new FileWriter(file.getPath()+"/"+ batchNumber + ".txt");
|
|
FileWriter fileWriter = new FileWriter(file.getPath()+"/"+ batchNumber + ".txt");
|
|
fileWriter.write(content.toString());
|
|
fileWriter.write(content.toString());
|
|
- files.add(new File(file.getPath()+"/"+ batchNumber + ".txt"));
|
|
|
|
|
|
+ fileList.add(new File(file.getPath()+"/"+ batchNumber + ".txt"));
|
|
|
|
+
|
|
|
|
+ //生成md5(用于前端校验是否被替换)
|
|
|
|
+ String fileVerifyMd5 = DigestUtils.md5DigestAsHex(content.toString().getBytes(StandardCharsets.UTF_8));
|
|
|
|
+ fileVerifyMd5List.add(fileVerifyMd5);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|