搬家调试

20230922-ljl-fixBug
qiushengjie 1 year ago
parent a5403200de
commit 8f4f50825e

@ -117,8 +117,8 @@ public class MoveMaterialAuditBufferTaskService extends TaskBaseService {
queueList.add(queue);
});
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
TransactionStatus status = transactionManager.getTransaction(def);
// DefaultTransactionDefinition def = new DefaultTransactionDefinition();
// TransactionStatus status = transactionManager.getTransaction(def);
try {
int aff = materialAuditStatusQueueService.insertBatch(queueList);
int delAff = 0;
@ -129,10 +129,10 @@ public class MoveMaterialAuditBufferTaskService extends TaskBaseService {
if (bufferIds.size() < limit) {
break;
}
transactionManager.commit(status);
// transactionManager.commit(status);
} catch (Exception e) {
e.printStackTrace();
transactionManager.rollback(status);
// transactionManager.rollback(status);
log.error("任务执行失败 数据回滚: moveMaterialAuditBuffer", e);
if (e.getMessage().contains("udx_material_id")) {
List<String> materialIdList = bufferList.stream().map(MaterialAuditStatusBuffer::getMaterialId).collect(Collectors.toList());

@ -98,6 +98,7 @@ public class MoveMaterialAuditProcessTaskService extends TaskBaseService {
*/
@Override
public Object getTask() {
log.info("start moveMaterialAuditProcess");
while (true) {
List<Long> queueIds = materialAuditStatusQueueService.getMaterialAuditStatusQueueIds();
if (queueIds.isEmpty()) {
@ -121,6 +122,7 @@ public class MoveMaterialAuditProcessTaskService extends TaskBaseService {
materialAuditStatusQueue.setGmtModified(new Date());
int affectRows = materialAuditStatusQueueService.updateByPrimaryKeyWithUnlock(materialAuditStatusQueue);
if (affectRows == 1) {
log.info("locked task");
return queueMsg;
}
}
@ -228,7 +230,6 @@ public class MoveMaterialAuditProcessTaskService extends TaskBaseService {
materialAuditStatusQueueService.deleteByPrimaryKey(queueMsg.getMaterialAuditStatusQueueId());
transactionManager.commit(status);
} catch (Throwable e) {
e.printStackTrace();
transactionManager.rollback(status);
log.info("任务执行失败 数据回滚: ", e);
}

@ -2,6 +2,7 @@ package com.ms.api.task;
import cn.hutool.core.util.ObjectUtil;
import com.ms.api.bo.MovePublishBufferRandShopIdAndPriorityBO;
import com.ms.api.common.E;
import com.ms.api.common.StrObjMap;
import com.ms.api.common.TaskBaseService;
import com.ms.api.consts.RedisKeyConst;
@ -104,8 +105,7 @@ public class MovePublishBufferTaskService extends TaskBaseService {
log.info("start moveProductPublishBufferToQueue");
Map<Long, Integer> shopBufferCountMap = moveProductPublishBufferToQueue(selectedShopMap);
if (ObjectUtil.isEmpty(shopBufferCountMap)) {
log.info("end moveProductPublishBufferToQueue for empty bufferRows cost times");
return null;
E.throwMSException("end moveProductPublishBufferToQueue for empty bufferRows cost times");
}
log.info("end moveProductPublishBufferToQueue ret: " + shopBufferCountMap.toString());
return shopBufferCountMap;
@ -119,8 +119,7 @@ public class MovePublishBufferTaskService extends TaskBaseService {
log.info("handle getMoveProductPublishBufferShopMap");
int queueCount = moveProductPublishQueueService.count();
if (queueCount >= maxQueueCount) {
log.info("queueCount " + queueCount + ", maxQueueCount " + maxQueueCount + ", end.");
return null;
E.throwMSException("queueCount " + queueCount + ", maxQueueCount " + maxQueueCount + ", end.");
}
int leftCount = maxQueueCount - queueCount;
@ -174,8 +173,7 @@ public class MovePublishBufferTaskService extends TaskBaseService {
log.info("start getShopMonthQuotaMap");
Map<Long, MoveShopConfig> shopMoveQuotaMap = getShopMonthQuotaMap(shopIds);
if(ObjectUtil.isEmpty(shopMoveQuotaMap)){
log.info("getShopMonthQuotaMap is empty");
return null;
E.throwMSException("getShopMonthQuotaMap is empty");
}
log.info("end getShopMonthQuotaMap");
@ -195,21 +193,19 @@ public class MovePublishBufferTaskService extends TaskBaseService {
*/
private Map<Long, MoveShopConfig> getShopMonthQuotaMap(List<Long> shopIds) {
if (ObjectUtil.isEmpty(shopIds)) {
return null;
E.throwMSException("shopIds is empty");
}
// 获取店铺的配置
String curMonth = CommonTool.getCurMonthLastTime();
List<MoveShopConfig> moveConfigList = moveShopConfigService.selectByShopIds(shopIds,curMonth);
if (ObjectUtil.isEmpty(moveConfigList)) {
log.info("getShopMonthQuotaMap moveConfigList is empty");
return null;
E.throwMSException("getShopMonthQuotaMap moveConfigList is empty");
}
Map<Long, MoveShopConfig> moveConfigMap = CommonTool.convertListToMap(moveConfigList, MoveShopConfig::getShopId);
if (ObjectUtil.isEmpty(moveConfigMap)) {
log.info("getShopMonthQuotaMap moveConfigMap is empty");
return null;
E.throwMSException("getShopMonthQuotaMap moveConfigMap is empty");
}
return moveConfigMap;
}
@ -360,8 +356,7 @@ public class MovePublishBufferTaskService extends TaskBaseService {
}
log.info("end process selectedShopMap");
if (allBufferRowList.isEmpty()) {
log.info("end moveShopBufferToQueue for empty bufferRows cost times");
return null;
E.throwMSException("end moveShopBufferToQueue for empty bufferRows cost times");
}
// 分批把删除buffer中的数据放入到queue中同时放入到redis中
List<Map<Integer, MoveProductPublishBuffer>> chunkBufferRowList = CommonTool.chunkMap(allBufferRowList, 50);

@ -233,15 +233,13 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
MoveProductPublishQueueBO queueMsg = lockProductPublishQueue();
log.info("MoveProductPublishQueueBO taskDetailId" + queueMsg.getMoveProductPublishQueueId());
if (Objects.isNull(queueMsg)) {
log.info("locked empty, wait");
return null;
E.throwMSException("locked empty, wait");
}
// 更新move_task_detail
MoveCollectTaskDetail moveCollectTaskDetail = moveCollectTaskDetailService.selectByPrimaryKey(queueMsg.getMoveCollectTaskDetailId());
if(ObjectUtil.isEmpty(moveCollectTaskDetail)){
log.info("moveCollectTaskDetail is null");
return null;
E.throwMSException("moveCollectTaskDetail is null");
}
log.info("来源商品id:" + moveCollectTaskDetail.getSourceItemId(), " 标题: "+ moveCollectTaskDetail.getSourceItemId());
long publishWaitSeconds = startTime - queueMsg.getGmtCreate().getTime();
@ -263,13 +261,11 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
@Override
public Object processTask(Object params) {
if (ObjectUtil.isEmpty(params)) {
log.info("processTask accept null params");
return null;
E.throwMSException("processTask accept null params");
}
Ret getTaskRet = (Ret) params;
if (CommonTool.isFailRet(getTaskRet)) {
log.info("processTask accept null params");
return null;
E.throwMSException("processTask accept null params");
}
MoveProductPublishQueueBO queueMsg = (MoveProductPublishQueueBO) getTaskRet.getQueueMsg();
long startTime = System.currentTimeMillis();

@ -9,7 +9,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication(scanBasePackages = {"com.ms","com.jinritemai"})
@MapperScan("com.ms.dal.mapper")
@EnableAsync
//@EnableScheduling
@EnableScheduling
public class MsApplication {
public static void main(String[] args) {

Loading…
Cancel
Save