|
@@ -2,7 +2,6 @@ package com.abi.qms.platform.infrastructure.mq;
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.io.file.FileWriter;
|
|
|
-import cn.hutool.core.util.ZipUtil;
|
|
|
import com.abi.qms.platform.dao.entity.*;
|
|
|
import com.abi.qms.platform.dao.enums.QrFormatUrlEnum;
|
|
|
import com.abi.qms.platform.dao.enums.QrPackageGenerateStatusEnum;
|
|
@@ -25,8 +24,6 @@ import com.abi.task.common.tablestore.TableStorePlusUtils;
|
|
|
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.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alicloud.openservices.tablestore.model.search.query.BoolQuery;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
@@ -42,6 +39,7 @@ import org.redisson.api.RedissonClient;
|
|
|
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
|
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
|
import org.springframework.amqp.support.AmqpHeaders;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.messaging.Message;
|
|
@@ -70,7 +68,6 @@ import java.util.stream.Collectors;
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@Component
|
|
|
-@RabbitListener(queues = GenerateCodeConsumer.GENERATE_CODE_BY_REPERTORY_QUEUE)
|
|
|
public class GenerateCodeConsumer {
|
|
|
|
|
|
public static final String GENERATE_CODE_BY_REPERTORY_QUEUE = "generate_code_queue";
|
|
@@ -120,14 +117,26 @@ public class GenerateCodeConsumer {
|
|
|
|
|
|
@SneakyThrows
|
|
|
@RabbitHandler
|
|
|
- public void onMessage(String objeQrPackage, Message message, Channel channel) {
|
|
|
- QrPackage qrPackage = JSONObject.parseObject(objeQrPackage,QrPackage.class);
|
|
|
+ @RabbitListener(queues = GenerateCodeConsumer.GENERATE_CODE_BY_REPERTORY_QUEUE)
|
|
|
+ public void onMessage(String id, Message message, Channel channel) {
|
|
|
+ if (id.startsWith("\"")) {
|
|
|
+ id = id.substring(1);
|
|
|
+ }
|
|
|
+ if (id.endsWith("\"")) {
|
|
|
+ id = id.substring(0,id.length() - 1);
|
|
|
+ }
|
|
|
+ String str = id;
|
|
|
+ long l = Long.parseLong(str);
|
|
|
+ QrPackageVO qrPackageVO = qrPackageMapper.selectQrPackageDetailById(l);
|
|
|
try {
|
|
|
// 生成码
|
|
|
- loopGenerateCode(qrPackage);
|
|
|
+ loopGenerateCode(qrPackageVO);
|
|
|
} catch (Exception e) {
|
|
|
log.error("生成码失败", e);
|
|
|
// 回滚
|
|
|
+ QrPackage qrPackage = new QrPackage();
|
|
|
+ qrPackage.setId(qrPackageVO.getId());
|
|
|
+ qrPackage.setGenerateStatus(qrPackageVO.getGenerateStatus());
|
|
|
qrPackageService.failedRollback(qrPackage);
|
|
|
} finally {
|
|
|
// 手工ack
|
|
@@ -139,9 +148,9 @@ public class GenerateCodeConsumer {
|
|
|
/**
|
|
|
* 生成码
|
|
|
*/
|
|
|
- private void loopGenerateCode(QrPackage qrPackage) {
|
|
|
+ private void loopGenerateCode(QrPackageVO qrPackageVO) {
|
|
|
//刷新码包信息
|
|
|
- qrPackage = qrPackageMapper.selectById(qrPackage.getId());
|
|
|
+ QrPackage qrPackage = qrPackageMapper.selectById(qrPackageVO.getId());
|
|
|
|
|
|
// 查询码包关联的幅面关联的码库的信息
|
|
|
QrPackageVO qrPackageVo = qrPackageMapper.selectQrPackageDetailById(qrPackage.getId());
|
|
@@ -215,10 +224,17 @@ public class GenerateCodeConsumer {
|
|
|
zipEncryption(file,files,pas,zipName);
|
|
|
//上传阿里云,并更新码包的下载路径 保存zip密码
|
|
|
try{
|
|
|
- MultipartFile multipartFile = toMultipartFile(file.getCanonicalPath(), file.getName());
|
|
|
- Object result = basicServiceClient.uploadFileOss(multipartFile);
|
|
|
- String ossUrl = JSONObject.parseObject(JSONObject.toJSONString(result)).getString("data");
|
|
|
- //放入oss地址和密码
|
|
|
+ MultipartFile multipartFile = toMultipartFile(file.getPath()+"\\"+zipName, zipName);
|
|
|
+ Object returDat = basicServiceClient.uploadFileOss(multipartFile);
|
|
|
+ String ossUrl = null;
|
|
|
+ if(null != returDat){
|
|
|
+ Map<String,Object> result =(Map<String, Object>)returDat;
|
|
|
+ ossUrl = (String) result.get("data");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+// String ossUrl = JSONObject.parseObject(JSONObject.toJSONString(result)).getString("data");
|
|
|
+// //放入oss地址和密码
|
|
|
qrPackage.setDownloadPath(ossUrl);
|
|
|
qrPackage.setZipPassword(pas);
|
|
|
//删除生成文件
|