|
@@ -5,10 +5,7 @@ import cn.hutool.core.io.file.FileWriter;
|
|
|
import com.abi.base.foundation.util.RedisClient;
|
|
|
import com.abi.ootb.core.utils.JsonUtils;
|
|
|
import com.abi.qms.platform.dao.entity.*;
|
|
|
-import com.abi.qms.platform.dao.enums.CodePackageOrderTypeEnum;
|
|
|
-import com.abi.qms.platform.dao.enums.InvalidEnum;
|
|
|
-import com.abi.qms.platform.dao.enums.QrPackageGenerateStatusEnum;
|
|
|
-import com.abi.qms.platform.dao.enums.QrRepertoryTypeEnum;
|
|
|
+import com.abi.qms.platform.dao.enums.*;
|
|
|
import com.abi.qms.platform.dao.mapper.*;
|
|
|
import com.abi.qms.platform.dao.tablestore.entity.QrCode;
|
|
|
import com.abi.qms.platform.dao.vo.result.QrRepertoryColumnVO;
|
|
@@ -16,6 +13,7 @@ import com.abi.qms.platform.dao.vo.result.QrRepertoryVO;
|
|
|
import com.abi.qms.platform.feign.BasicServiceClient;
|
|
|
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.AesEncodeUtil;
|
|
|
import com.abi.qms.platform.infrastructure.util.BuildCodeUtil;
|
|
|
import com.abi.qms.platform.infrastructure.util.RandomCodeUtils;
|
|
|
import com.abi.qms.platform.service.GenerateCodeService;
|
|
@@ -36,6 +34,7 @@ import org.redisson.api.RLock;
|
|
|
import org.redisson.api.RedissonClient;
|
|
|
import org.springframework.amqp.core.AmqpTemplate;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.DigestUtils;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
@@ -101,6 +100,9 @@ public class GenerateCodeServiceImpl implements GenerateCodeService {
|
|
|
@Autowired
|
|
|
private QrPackageBookingOrderService qrPackageBookingOrderService;
|
|
|
|
|
|
+ @Value("${qms.encode.key}")
|
|
|
+ private String encodeKey;
|
|
|
+
|
|
|
/** 允许单个码生成重复的次数 */
|
|
|
private static final int REPEAT_BUILD_CODE_TIMES = 10;
|
|
|
|
|
@@ -132,6 +134,8 @@ public class GenerateCodeServiceImpl implements GenerateCodeService {
|
|
|
log.info("2 loopGenerateCode update status -->"+System.currentTimeMillis());
|
|
|
|
|
|
//1-准备参数
|
|
|
+ //包材厂信息(取二级包材厂id,如果是非一级的包材厂,保存的时候FactoryCoverLevelTwoId这个字段就会填写他自己的id)
|
|
|
+ BaseFactory coverFactory = baseFactoryMapper.selectById(qrPackage.getFactoryCoverLevelTwoId());
|
|
|
//查询幅面
|
|
|
QrBoxCodeFormat qrBoxCodeFormat = qrBoxCodeFormatMapper.selectById(qrPackage.getBoxCodeFormatId());
|
|
|
//查询拆分数量
|
|
@@ -197,7 +201,7 @@ public class GenerateCodeServiceImpl implements GenerateCodeService {
|
|
|
log.info("7 loopGenerateCode save tablestore async -->"+System.currentTimeMillis());
|
|
|
|
|
|
// 创建码文件
|
|
|
- String md5 = createCodeFile(qrRepertory,splitCache, batchNumber, qrBoxCodeFormat, fileList, codeList);
|
|
|
+ String md5 = createCodeFile(coverFactory,qrRepertory,splitCache, batchNumber, qrBoxCodeFormat, fileList, codeList);
|
|
|
fileVerifyMd5List.add(md5);
|
|
|
log.info("8 loopGenerateCode create file -->"+System.currentTimeMillis());
|
|
|
}catch(Exception e){
|
|
@@ -253,13 +257,9 @@ public class GenerateCodeServiceImpl implements GenerateCodeService {
|
|
|
qrPackage.setGenerateTime(LocalDateTime.now());
|
|
|
//将MD5的字符换逗号拼接放入码包
|
|
|
qrPackage.setFileVerifyMd5(String.join(",",fileVerifyMd5List));
|
|
|
- //根据包材厂获取包材厂负责人邮箱
|
|
|
- QueryWrapper<BaseFactory> baseQuery = new QueryWrapper<>();
|
|
|
- baseQuery.eq("id", qrPackage.getFactoryCoverId());
|
|
|
- BaseFactory baseFactory = baseFactoryMapper.selectOne(baseQuery);
|
|
|
//发送邮件
|
|
|
String aliPath = qrPackage.getDownloadPath().substring(qrPackage.getDownloadPath().lastIndexOf("/") + 1);
|
|
|
- qrPackageService.sendEmailForQrPackageCreated(baseFactory.getEmail(),qrPackage,aliPath,qrPackage.getZipPassword());
|
|
|
+ qrPackageService.sendEmailForQrPackageCreated(coverFactory.getEmail(),qrPackage,aliPath,qrPackage.getZipPassword());
|
|
|
//邮件发送后修改状态
|
|
|
qrPackageMapper.updateById(qrPackage);
|
|
|
log.info("12 loopGenerateCode send email -->"+System.currentTimeMillis());
|
|
@@ -501,7 +501,7 @@ public class GenerateCodeServiceImpl implements GenerateCodeService {
|
|
|
/**
|
|
|
* 创建码文件
|
|
|
*/
|
|
|
- private String createCodeFile( QrRepertoryVO qrRepertory,Map<Long,QrBoxCodeFormatSplit> splitCache,String batchNumber,QrBoxCodeFormat boxCodeFormat,ArrayList<File> fileList,List<QrData> codeList) {
|
|
|
+ private String createCodeFile(BaseFactory coverFactory, 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();
|
|
@@ -554,9 +554,15 @@ public class GenerateCodeServiceImpl implements GenerateCodeService {
|
|
|
log.error("创建文件异常",e);
|
|
|
}
|
|
|
|
|
|
+ // 如果包材厂是接受加密的包材厂 则对这个text的内容加密
|
|
|
+ String contentText = content.toString();
|
|
|
+ if(TrueFalseEnum.TRUE.is(coverFactory.getIsQrCodeEncode())){
|
|
|
+ contentText = AesEncodeUtil.aesEncode(contentText, encodeKey);
|
|
|
+ }
|
|
|
+
|
|
|
// 生成txt
|
|
|
FileWriter fileWriter = new FileWriter(file.getPath()+"/"+ batchNumber + ".txt");
|
|
|
- fileWriter.write(content.toString());
|
|
|
+ fileWriter.write(contentText);
|
|
|
fileList.add(new File(file.getPath()+"/"+ batchNumber + ".txt"));
|
|
|
|
|
|
//生成md5(用于前端校验是否被替换)
|