|
@@ -55,6 +55,7 @@ import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.OutputStream;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
@@ -156,6 +157,7 @@ public class GenerateCodeConsumer {
|
|
|
}
|
|
|
// 生成码
|
|
|
loopGenerateCode(qrPackageVO);
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
log.error("生成码失败", e);
|
|
|
// 回滚
|
|
@@ -231,9 +233,10 @@ public class GenerateCodeConsumer {
|
|
|
* localDateTime 创建时间
|
|
|
* boxCodeFormat 箱码幅面
|
|
|
*/
|
|
|
+ System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())+"+++...");
|
|
|
// 循环生成码
|
|
|
List<QrData> codeList = loopGenerateCode(qrRepertoryColumnList, qrRepertoryId, urlMap, qrRepertorySerialNumberMap, qrNumber, batchNumber, repeatTimes,boxCodeFormat);
|
|
|
-
|
|
|
+ System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())+"+++...");
|
|
|
// 更新码库流水号
|
|
|
if (!qrRepertorySerialNumberMap.isEmpty()) {
|
|
|
for (Map.Entry<String, QrRepertorySerialNumber> entry : qrRepertorySerialNumberMap.entrySet()) {
|
|
@@ -246,7 +249,7 @@ public class GenerateCodeConsumer {
|
|
|
}
|
|
|
|
|
|
// table数据库 批量插入
|
|
|
- saveTableStore(qrPackageBatch, codeList);
|
|
|
+// saveTableStore(qrPackageBatch, codeList);
|
|
|
|
|
|
// 创建码文件
|
|
|
createCodeFile(qrRepertory,batchNumber,boxCodeFormat);
|
|
@@ -288,8 +291,8 @@ public class GenerateCodeConsumer {
|
|
|
baseQuery.eq("id", qrPackage.getFactoryCoverId());
|
|
|
BaseFactory baseFactory = baseFactoryMapper.selectOne(baseQuery);
|
|
|
//发送邮件
|
|
|
- String aliPath = qrPackage.getDownloadPath().substring(qrPackage.getDownloadPath().lastIndexOf("/") + 1);
|
|
|
- qrPackageService.sendEmailForQrPackageCreated(baseFactory.getEmail(),qrPackage.getSapOrderNo(),aliPath,qrPackage.getZipPassword());
|
|
|
+// String aliPath = qrPackage.getDownloadPath().substring(qrPackage.getDownloadPath().lastIndexOf("/") + 1);
|
|
|
+// qrPackageService.sendEmailForQrPackageCreated(baseFactory.getEmail(),qrPackage.getSapOrderNo(),aliPath,qrPackage.getZipPassword());
|
|
|
//邮件发送后修改状态
|
|
|
qrPackageMapper.updateById(qrPackage);
|
|
|
QrIndex index = new QrIndex();
|
|
@@ -390,19 +393,25 @@ public class GenerateCodeConsumer {
|
|
|
for (int j = 0; j < qrRepertoryColumnList.size(); j++) {
|
|
|
QrRepertoryColumnVO qrRepertoryColumn = qrRepertoryColumnList.get(j);
|
|
|
Long qrRepertoryColumnId = qrRepertoryColumn.getId();
|
|
|
- //判断是否有拆分数量 0 或者空不拆分 ,根据箱码幅面id,码库id,码库列id 查询拆分数量
|
|
|
- QueryWrapper<QrBoxCodeFormatSplit> boxCodeFormatSplit = new QueryWrapper<>();
|
|
|
- boxCodeFormatSplit.eq("box_code_format_id",boxCodeFormat.getId() );
|
|
|
- boxCodeFormatSplit.eq("qr_repertory_id", boxCodeFormat.getQrRepertoryId());
|
|
|
- boxCodeFormatSplit.eq("qr_repertory_column_id",qrRepertoryColumnId );
|
|
|
- QrBoxCodeFormatSplit qrBoxCodeFormatSplits = qrBoxCodeFormatSplitMapper.selectOne(boxCodeFormatSplit);
|
|
|
- //声明拆分数量
|
|
|
- int splitNum = 0;
|
|
|
- //判断是否为空
|
|
|
- if(ObjectUtils.isNotEmpty(qrBoxCodeFormatSplits)){
|
|
|
- //查分数量
|
|
|
- splitNum = qrBoxCodeFormatSplits.getSplitNum();
|
|
|
+ //缓存中获取拆分列
|
|
|
+ Integer split = redisClient.get("box_code_format_split");
|
|
|
+ if(null == split){
|
|
|
+ //判断是否有拆分数量 0 或者空不拆分 ,根据箱码幅面id,码库id,码库列id 查询拆分数量
|
|
|
+ QueryWrapper<QrBoxCodeFormatSplit> boxCodeFormatSplit = new QueryWrapper<>();
|
|
|
+ boxCodeFormatSplit.eq("box_code_format_id",boxCodeFormat.getId() );
|
|
|
+ boxCodeFormatSplit.eq("qr_repertory_id", boxCodeFormat.getQrRepertoryId());
|
|
|
+ boxCodeFormatSplit.eq("qr_repertory_column_id",qrRepertoryColumnId );
|
|
|
+ QrBoxCodeFormatSplit qrBoxCodeFormatSplits = qrBoxCodeFormatSplitMapper.selectOne(boxCodeFormatSplit);
|
|
|
+ if(!ObjectUtils.isEmpty(qrBoxCodeFormatSplits)){
|
|
|
+ split = qrBoxCodeFormatSplits.getSplitNum();
|
|
|
+ redisClient.set("box_code_format_split",qrBoxCodeFormatSplits.getSplitNum());
|
|
|
+ }else {
|
|
|
+ split = 0;
|
|
|
+ redisClient.set("box_code_format_split",0);
|
|
|
+ }
|
|
|
}
|
|
|
+ //声明拆分数量
|
|
|
+ int splitNum = split;
|
|
|
// 非clone列,设置code和url
|
|
|
String code = buildUniqueCode(uniqueSet, qrRepertoryColumn, codeSb, paramMap, qrRepertorySerialNumberMap, 0);
|
|
|
if (code == null) {
|
|
@@ -433,8 +442,10 @@ public class GenerateCodeConsumer {
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
+ redisClient.delete("box_code_format_split");
|
|
|
return qrDataList;
|
|
|
} catch (Exception e) {
|
|
|
+ redisClient.delete("box_code_format_split");
|
|
|
log.error("封装码失败", e);
|
|
|
if (++repeatTimes >= REPEAT_BUILD_CODE_TIMES) {
|
|
|
throw new RuntimeException("生成码失败,重复生成码次数超过" + REPEAT_BUILD_CODE_TIMES + "次");
|
|
@@ -543,7 +554,7 @@ public class GenerateCodeConsumer {
|
|
|
}
|
|
|
|
|
|
// 单个码重复次数大于上限
|
|
|
- if (buildTimes >= REPEAT_BUILD_CODE_TIMES) {
|
|
|
+ if (buildTimes > REPEAT_BUILD_CODE_TIMES) {
|
|
|
return null;
|
|
|
}
|
|
|
|