搬家调试

20230922-ljl-fixBug
qiushengjie 1 year ago
parent e2d009971f
commit 8679346d0f

@ -53,7 +53,7 @@ public class TestRedisService extends SPIBaseService implements ExtensionService
redisService.pop(RedisKeyConst.MOVE_PRODUCT_PUBLISH_TO_PIC_QUEUE);
}
for (long i = 115; i < 180; i++) {
for (long i = 190; i < 250; i++) {
MoveProductPublishToPicQueue data = moveProductPublishToPicQueueService.selectByPrimaryKey(i);
if (data != null && data.getLocked() == 0) {
redisService.push(RedisKeyConst.MOVE_PRODUCT_PUBLISH_TO_PIC_QUEUE, String.valueOf(data.getMoveProductPublishToPicQueueId()));

@ -1182,12 +1182,23 @@ public class MoveService {
}
public Ret saveMaterialAuditStatusBuffer(long shopId, List<String> materialIds, StrStrMap materialIdAndOriginUrlMap) {
StrObjMap filter = new StrObjMap();
filter.put("materialIds", materialIds);
Map<String, MaterialBizAuditStatusLog> materialIdMap = materialBizAuditStatusLogService.getShopMaterialBizAuditStatusLogMap(shopId, filter);
materialIds.stream().filter(materialId -> materialIdMap.containsKey(materialId)).forEach(materialIds::remove);
addMaterialAuditStatusBuffer(shopId, materialIds);
addMaterialBizAuditStatusLog(shopId, materialIds, materialIdAndOriginUrlMap);
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
TransactionStatus status = transactionManager.getTransaction(def);
try{
StrObjMap filter = new StrObjMap();
filter.put("materialIds", materialIds);
Map<String, MaterialBizAuditStatusLog> materialIdMap = materialBizAuditStatusLogService.getShopMaterialBizAuditStatusLogMap(shopId, filter);
materialIds.stream().filter(materialId -> materialIdMap.containsKey(materialId)).forEach(materialIds::remove);
addMaterialAuditStatusBuffer(shopId, materialIds);
addMaterialBizAuditStatusLog(shopId, materialIds, materialIdAndOriginUrlMap);
transactionManager.commit(status);
}catch (Throwable e){
e.printStackTrace();
transactionManager.rollback(status);
log.info("任务执行失败 数据回滚: ", e);
return CommonTool.failResult("任务执行失败");
}
return CommonTool.successResult();
}

@ -84,6 +84,9 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;
/**
*
@ -93,6 +96,9 @@ import org.springframework.stereotype.Component;
@Slf4j
public class ProcessMovePublishToPicTaskService extends TaskBaseService {
@Autowired
private PlatformTransactionManager transactionManager;
@Autowired
MoveProductPublishQueueService moveProductPublishQueueService;
@ -144,6 +150,7 @@ public class ProcessMovePublishToPicTaskService extends TaskBaseService {
@Autowired
private ProductService productService;
private static Map<String, Boolean> isProcessed = new HashMap<>();
private static Map<String, Integer> tryTimes = new HashMap<>();
@ -179,7 +186,7 @@ public class ProcessMovePublishToPicTaskService extends TaskBaseService {
@Scheduled(fixedRate = 10000)
@Override
public void runTask() {
super.runTaskWithTransaction();
super.runTask();
}
/**
@ -397,42 +404,42 @@ public class ProcessMovePublishToPicTaskService extends TaskBaseService {
// TODO
private Ret rebuildAddRetReason(Ret addRet, JSONArray brandList, MoveShopSettingBO condition, String cid, AccessToken accessToken) {
if (addRet.getReason().contains("请重新选择品牌") || addRet.getReason().contains("该类目下无品牌") || addRet.getReason().contains("品牌不属于该类目")) {
if (StringUtils.isNumeric(condition.getBrandId())) {
Map<String, JSONObject> brandMap = brandList.stream().filter(x -> ((JSONObject) x).containsKey("id")).collect(Collectors.toMap(x -> ((JSONObject) x).getString("id"), x -> (JSONObject) x, (v1, v2) -> v1));
JSONObject brand = brandMap.get(condition.getBrandId());
String brandName = brand.getString("brand_chinese_name") != null ? brand.getString("brand_chinese_name") : brand.getString("brand_english_name");
addRet.setReason("当前类目无 " + brandName + " 品牌权限,请前往店铺后台申请品牌,<a href=\"https://fxg.jinritemai.com/ffa/grs/qualification/list?type=2\" target=\"_blank\">立即申请</a>");
return addRet;
} else if (Objects.equals(condition.getBrandId(), MoveConst.brandEmpty)) {
addRet.setReason("当前类目品牌必填,请前往店铺后台申请品牌,<a href=\"https://fxg.jinritemai.com/ffa/grs/qualification/list?type=2\" target=\"_blank\">立即申请</a><br>您在搬家配置设置“品牌留空”。若您已经申请品牌,请修改搬家配置,若没有申请品牌,请前往店铺后台申请品牌");
return addRet;
} else if (brandList.isEmpty()) {
addRet.setReason("当前类目品牌必填,请前往店铺后台申请品牌,<a href=\"https://fxg.jinritemai.com/ffa/grs/qualification/list?type=2\" target=\"_blank\">立即申请</a>");
return addRet;
} else if (brandList.size() != 0) {
List<String> brandNames = brandList.stream().map(x -> {
JSONObject temp = (JSONObject) x;
return temp.containsKey("brand_chinese_name") ? temp.getString("brand_chinese_name") : temp.getString("brand_english_name");
}).collect(Collectors.toList());
addRet.setReason("当前类目无\"" + String.join(",", brandNames) + "\"品牌权限,请前往店铺后台申请品牌,<a href=\"https://fxg.jinritemai.com/ffa/grs/qualification/list?type=2\" target=\"_blank\">立即申请</a>");
return addRet;
}
}
if (addRet.getReason().contains("没有品牌资质,非普通店商品请使用有资质的品牌")) {
return rebuildAddRetBrandQualificationReason(addRet, brandList, cid, accessToken);
}
if (addRet.getReason().contains("颜色对应的规格值不能重复,请核对")) {
addRet.setReason(addRet.getReason() + ",请检查是否包含特殊符号或违禁词(" + String.join("", MoveConst.getSpecialBanWordList()) + "");
}
// if (addRet.getReason().contains("请重新选择品牌") || addRet.getReason().contains("该类目下无品牌") || addRet.getReason().contains("品牌不属于该类目")) {
// if (StringUtils.isNumeric(condition.getBrandId())) {
// Map<String, JSONObject> brandMap = brandList.stream().filter(x -> ((JSONObject) x).containsKey("id")).collect(Collectors.toMap(x -> ((JSONObject) x).getString("id"), x -> (JSONObject) x, (v1, v2) -> v1));
// JSONObject brand = brandMap.get(condition.getBrandId());
// String brandName = brand.getString("brand_chinese_name") != null ? brand.getString("brand_chinese_name") : brand.getString("brand_english_name");
// addRet.setReason("当前类目无 " + brandName + " 品牌权限,请前往店铺后台申请品牌,<a href=\"https://fxg.jinritemai.com/ffa/grs/qualification/list?type=2\" target=\"_blank\">立即申请</a>");
// return addRet;
// } else if (Objects.equals(condition.getBrandId(), MoveConst.brandEmpty)) {
// addRet.setReason("当前类目品牌必填,请前往店铺后台申请品牌,<a href=\"https://fxg.jinritemai.com/ffa/grs/qualification/list?type=2\" target=\"_blank\">立即申请</a><br>您在搬家配置设置“品牌留空”。若您已经申请品牌,请修改搬家配置,若没有申请品牌,请前往店铺后台申请品牌");
// return addRet;
// } else if (brandList.isEmpty()) {
// addRet.setReason("当前类目品牌必填,请前往店铺后台申请品牌,<a href=\"https://fxg.jinritemai.com/ffa/grs/qualification/list?type=2\" target=\"_blank\">立即申请</a>");
// return addRet;
// } else if (brandList.size() != 0) {
// List<String> brandNames = brandList.stream().map(x -> {
// JSONObject temp = (JSONObject) x;
// return temp.containsKey("brand_chinese_name") ? temp.getString("brand_chinese_name") : temp.getString("brand_english_name");
// }).collect(Collectors.toList());
// addRet.setReason("当前类目无\"" + String.join(",", brandNames) + "\"品牌权限,请前往店铺后台申请品牌,<a href=\"https://fxg.jinritemai.com/ffa/grs/qualification/list?type=2\" target=\"_blank\">立即申请</a>");
// return addRet;
// }
// }
Matcher matcherBanWord = Pattern.compile("规格值含有敏感词(?::|)\\[([^\\]]+)\\]").matcher(addRet.getReason());
Matcher matcherBanWordDescription = Pattern.compile("商品规格值描述“(.*)”不符合平台要求").matcher(addRet.getReason());
if (matcherBanWord.matches() || matcherBanWordDescription.matches()) {
addRet.setReason(addRet.getReason() + ",并且过滤后会导致sku规格值重复请检查并手动修改");
}
// if (addRet.getReason().contains("没有品牌资质,非普通店商品请使用有资质的品牌")) {
// return rebuildAddRetBrandQualificationReason(addRet, brandList, cid, accessToken);
// }
//
// if (addRet.getReason().contains("颜色对应的规格值不能重复,请核对")) {
// addRet.setReason(addRet.getReason() + ",请检查是否包含特殊符号或违禁词(" + String.join("", MoveConst.getSpecialBanWordList()) + "");
// }
//
// Matcher matcherBanWord = Pattern.compile("规格值含有敏感词(?::|)\\[([^\\]]+)\\]").matcher(addRet.getReason());
// Matcher matcherBanWordDescription = Pattern.compile("商品规格值描述“(.*)”不符合平台要求").matcher(addRet.getReason());
// if (matcherBanWord.matches() || matcherBanWordDescription.matches()) {
// addRet.setReason(addRet.getReason() + ",并且过滤后会导致sku规格值重复请检查并手动修改");
// }
return addRet;
}
@ -1592,10 +1599,20 @@ public class ProcessMovePublishToPicTaskService extends TaskBaseService {
}
}
int queueId = createMoveProductPublishToPicQueue(queueMsg);
List<String> materialIds = Arrays.asList(urlAndMaterialIdMap.values().toArray(new String[0]));
saveMaterialBiz(queueMsg.getShopId(), CommonConst.BIZ_MOVE, queueId, materialIds, urlAndMaterialIdMap);
deleteQueueMsg(queueMsg);
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
TransactionStatus status = transactionManager.getTransaction(def);
try{
int queueId = createMoveProductPublishToPicQueue(queueMsg);
List<String> materialIds = Arrays.asList(urlAndMaterialIdMap.values().toArray(new String[0]));
saveMaterialBiz(queueMsg.getShopId(), CommonConst.BIZ_MOVE, queueId, materialIds, urlAndMaterialIdMap);
deleteQueueMsg(queueMsg);
transactionManager.commit(status);
}catch (Throwable e){
e.printStackTrace();
transactionManager.rollback(status);
log.info("任务执行失败 数据回滚: ", e);
}
return;
}

@ -113,6 +113,9 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;
/**
* move_product_publish_queue
@ -122,6 +125,9 @@ import org.springframework.stereotype.Component;
@Slf4j
public class ProcessProductPublishTaskService extends TaskBaseService {
@Autowired
private PlatformTransactionManager transactionManager;
@Autowired
MoveProductPublishQueueService moveProductPublishQueueService;
@ -214,7 +220,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
@Scheduled(fixedRate = 10000)
@Override
public void runTask() {
super.runTaskWithTransaction();
super.runTask();
}
/**
@ -2562,11 +2568,18 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
}
Ret processRet = (Ret) params;
MoveProductPublishQueueBO queueMsg = (MoveProductPublishQueueBO) processRet.getQueueMsg();
Ret ret = processMovePublishQueueRet(processRet);
log.info("processMovePublishQueueRet ret:{}", ret);
// 前面已经挂起这边删除que
//TODO 测试强行停掉
deleteQueueMsg(queueMsg);
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
TransactionStatus status = transactionManager.getTransaction(def);
try{
processMovePublishQueueRet(processRet);
deleteQueueMsg(queueMsg);
transactionManager.commit(status);
}catch (Throwable e){
e.printStackTrace();
transactionManager.rollback(status);
log.info("任务执行失败 数据回滚: ", e);
}
}
private Ret processMovePublishQueueRet(Ret processRet) {

Loading…
Cancel
Save