|
@@ -35,6 +35,7 @@ import org.apache.commons.lang3.ObjectUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.redisson.api.RLock;
|
|
import org.redisson.api.RLock;
|
|
import org.redisson.api.RedissonClient;
|
|
import org.redisson.api.RedissonClient;
|
|
|
|
+import org.springframework.amqp.core.AmqpTemplate;
|
|
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;
|
|
@@ -111,6 +112,9 @@ public class GenerateCodeConsumer {
|
|
@Autowired
|
|
@Autowired
|
|
private BaseMaterialMapper baseMaterialMapper;
|
|
private BaseMaterialMapper baseMaterialMapper;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private AmqpTemplate amqpTemplate;
|
|
|
|
+
|
|
//生成码数据
|
|
//生成码数据
|
|
final List<QrData> qrDataList = new LinkedList<>();
|
|
final List<QrData> qrDataList = new LinkedList<>();
|
|
|
|
|
|
@@ -260,7 +264,7 @@ public class GenerateCodeConsumer {
|
|
log.info("6 loopGenerateCode transform tableStoreEntityList -->"+System.currentTimeMillis());
|
|
log.info("6 loopGenerateCode transform tableStoreEntityList -->"+System.currentTimeMillis());
|
|
|
|
|
|
// table数据库 批量插入
|
|
// table数据库 批量插入
|
|
- saveTableStore(tableStoreEntityList);
|
|
|
|
|
|
+ saveTableStore(qrPackageBatch, codeList);
|
|
log.info("7 loopGenerateCode save tablestore async -->"+System.currentTimeMillis());
|
|
log.info("7 loopGenerateCode save tablestore async -->"+System.currentTimeMillis());
|
|
|
|
|
|
// 创建码文件
|
|
// 创建码文件
|
|
@@ -308,7 +312,7 @@ public class GenerateCodeConsumer {
|
|
BaseFactory baseFactory = baseFactoryMapper.selectOne(baseQuery);
|
|
BaseFactory baseFactory = baseFactoryMapper.selectOne(baseQuery);
|
|
//发送邮件
|
|
//发送邮件
|
|
String aliPath = qrPackage.getDownloadPath().substring(qrPackage.getDownloadPath().lastIndexOf("/") + 1);
|
|
String aliPath = qrPackage.getDownloadPath().substring(qrPackage.getDownloadPath().lastIndexOf("/") + 1);
|
|
- qrPackageService.sendEmailForQrPackageCreated(baseFactory.getEmail(),qrPackage.getSapOrderNo(),aliPath,qrPackage.getZipPassword());
|
|
|
|
|
|
+// qrPackageService.sendEmailForQrPackageCreated(baseFactory.getEmail(),qrPackage.getSapOrderNo(),aliPath,qrPackage.getZipPassword());
|
|
//邮件发送后修改状态
|
|
//邮件发送后修改状态
|
|
qrPackageMapper.updateById(qrPackage);
|
|
qrPackageMapper.updateById(qrPackage);
|
|
QrIndex index = new QrIndex();
|
|
QrIndex index = new QrIndex();
|
|
@@ -371,13 +375,34 @@ public class GenerateCodeConsumer {
|
|
/**
|
|
/**
|
|
* 批量新增tableStore,码表
|
|
* 批量新增tableStore,码表
|
|
*/
|
|
*/
|
|
- private void saveTableStore(List<TableStoreEntity> tableStoreEntityList) {
|
|
|
|
- //保存tablestore
|
|
|
|
- tableStorePlusUtils.putRow(tableStoreEntityList);
|
|
|
|
-
|
|
|
|
- sum+=tableStoreEntityList.size();
|
|
|
|
|
|
+ private void saveTableStore(QrPackageBatch qrPackageBatch, List<QrData> codeList) {
|
|
|
|
+ List<QrCode> qrCodes = new ArrayList<>();
|
|
|
|
+ for (QrData sout : codeList) {
|
|
|
|
+ List<QrInnerData> innerDataList = sout.getInnerDataList();
|
|
|
|
+ List<QrCode> qrCodeCope = PojoConverterUtils.copyList(innerDataList, QrCode.class);
|
|
|
|
+ // 批次号 码包
|
|
|
|
+ qrCodeCope.forEach(stable -> {
|
|
|
|
+ stable.setBatchNumberId(qrPackageBatch.getId());
|
|
|
|
+ stable.setPackageId(qrPackageBatch.getPackageId());
|
|
|
|
+ stable.setCreateTime(LocalDateTime.now());
|
|
|
|
+ stable.setInvalid(InvalidEnum.NOT_INVALID.getCode());
|
|
|
|
+ });
|
|
|
|
+ qrCodes.addAll(qrCodeCope);
|
|
|
|
+ }
|
|
|
|
+ // 开始多线程写tableStore
|
|
|
|
+ int repeatTimes = qrCodes.size() / 200;
|
|
|
|
+ int leftover = qrCodes.size() % 200;
|
|
|
|
+ for (int i = 0; i < repeatTimes+1; i++) {
|
|
|
|
+ if (i == repeatTimes){
|
|
|
|
+ amqpTemplate.convertAndSend(TableStoreBatchInsertConsumer.TABLE_STORE_BATCH_INSERT_QUEUE, qrCodes.subList(i*200,i*200+leftover));
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ amqpTemplate.convertAndSend(TableStoreBatchInsertConsumer.TABLE_STORE_BATCH_INSERT_QUEUE, qrCodes.subList(i*200,i*200+200));
|
|
|
|
+ }
|
|
|
|
+ sum+=qrCodes.size();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* qrRepertoryColumnList 码库的列
|
|
* qrRepertoryColumnList 码库的列
|
|
* qrRepertoryId 码库id
|
|
* qrRepertoryId 码库id
|