Browse Source

feat(all): 修改梦天回推时重复推送老系统问题

dist.1.3.0
zhaoqiaobo 6 months ago
parent
commit
d0ae92c012
  1. 21
      blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/service/impl/MtFactoryDataServiceImpl.java
  2. 35
      blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/service/impl/MtOrderLogFailRetryServiceImpl.java

21
blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/service/impl/MtFactoryDataServiceImpl.java

@ -286,7 +286,9 @@ public class MtFactoryDataServiceImpl implements IMtFactoryDataService {
@Override @Override
public R handleStatusData(OrderStatusDTO orderStatusDTO) throws CustomerException, JsonProcessingException, NoSuchAlgorithmException { public R handleStatusData(OrderStatusDTO orderStatusDTO) throws CustomerException, JsonProcessingException, NoSuchAlgorithmException {
logger.info("TAG {} #############handleStatusData: orderStatusDTO={}", FactoryConstant.MENGT,orderStatusDTO); logger.info("TAG {} #############handleStatusData: orderStatusDTO={}", FactoryConstant.MENGT,orderStatusDTO);
if(!mtFactoryProperties.getSendEnable()){
return R.fail(400, "当前数据不推送");
}
String status = orderStatusDTO.getStatus(); String status = orderStatusDTO.getStatus();
R rd = null; R rd = null;
@ -324,6 +326,9 @@ public class MtFactoryDataServiceImpl implements IMtFactoryDataService {
String distributionContactId, String distributionContactId,
String destinationWarehouse String destinationWarehouse
) throws JsonProcessingException, NoSuchAlgorithmException { ) throws JsonProcessingException, NoSuchAlgorithmException {
if(!mtFactoryProperties.getSendEnable()){
return R.fail(400, "当前数据不推送");
}
QueryWrapper<MtPackageInfo> packageInfoQueryWrapper = new QueryWrapper<>(); QueryWrapper<MtPackageInfo> packageInfoQueryWrapper = new QueryWrapper<>();
packageInfoQueryWrapper.eq("package_code", orderPackageCode); packageInfoQueryWrapper.eq("package_code", orderPackageCode);
MtPackageInfo one = mtPackageInfoService.getOne(packageInfoQueryWrapper); MtPackageInfo one = mtPackageInfoService.getOne(packageInfoQueryWrapper);
@ -474,7 +479,9 @@ public class MtFactoryDataServiceImpl implements IMtFactoryDataService {
@Override @Override
public R sendReceiveInfoByNewSystem(MtReceiveDTO mtReceiveDTO) throws JsonProcessingException, NoSuchAlgorithmException { public R sendReceiveInfoByNewSystem(MtReceiveDTO mtReceiveDTO) throws JsonProcessingException, NoSuchAlgorithmException {
if(!mtFactoryProperties.getSendEnable()){
return R.fail("发送数据已关闭");
}
List<MtReceiveContentDTO> receiveContentList = mtReceiveDTO.getReceiveContentList(); List<MtReceiveContentDTO> receiveContentList = mtReceiveDTO.getReceiveContentList();
@ -685,6 +692,9 @@ public class MtFactoryDataServiceImpl implements IMtFactoryDataService {
* @throws NoSuchAlgorithmException * @throws NoSuchAlgorithmException
*/ */
public String retryPushMtFactoryData(String url, String data) throws NoSuchAlgorithmException { public String retryPushMtFactoryData(String url, String data) throws NoSuchAlgorithmException {
if(!mtFactoryProperties.getSendEnable()){
return "";
}
return sendMtFactoryDataRequest(url, data); return sendMtFactoryDataRequest(url, data);
} }
@ -698,7 +708,9 @@ public class MtFactoryDataServiceImpl implements IMtFactoryDataService {
* @throws NoSuchAlgorithmException * @throws NoSuchAlgorithmException
*/ */
private R sendMtFactoryData(String url, String data, Integer type,String refCode) throws NoSuchAlgorithmException { private R sendMtFactoryData(String url, String data, Integer type,String refCode) throws NoSuchAlgorithmException {
if(!mtFactoryProperties.getSendEnable()){
return R.fail(400, "当前数据不推送");
}
logger.info("##############sendMtFactoryData 发送数据: {}", data); logger.info("##############sendMtFactoryData 发送数据: {}", data);
String result = sendMtFactoryDataRequest(url, data); String result = sendMtFactoryDataRequest(url, data);
@ -747,6 +759,9 @@ public class MtFactoryDataServiceImpl implements IMtFactoryDataService {
* @throws NoSuchAlgorithmException * @throws NoSuchAlgorithmException
*/ */
private String sendMtFactoryDataRequest(String url, String data) throws NoSuchAlgorithmException { private String sendMtFactoryDataRequest(String url, String data) throws NoSuchAlgorithmException {
if(!mtFactoryProperties.getSendEnable()){
return "";
}
//先获取token //先获取token
String token = getMtToken(); String token = getMtToken();

35
blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/service/impl/MtOrderLogFailRetryServiceImpl.java

@ -12,7 +12,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -81,28 +80,30 @@ public class MtOrderLogFailRetryServiceImpl implements MtOrderLogFailRetryServic
*/ */
protected void executeRetry(MtOrderLogEntity mtOrderLogEntity) { protected void executeRetry(MtOrderLogEntity mtOrderLogEntity) {
try { try {
String requestUrl = getRequestUrl(mtOrderLogEntity); if(mtFactoryProperties.getSendEnable()){
String result = mtFactoryDataService.retryPushMtFactoryData(requestUrl, mtOrderLogEntity.getReqArgs()); String requestUrl = getRequestUrl(mtOrderLogEntity);
mtOrderLogEntity.setResBody(result); String result = mtFactoryDataService.retryPushMtFactoryData(requestUrl, mtOrderLogEntity.getReqArgs());
Integer PUSH_STATUS_FAIL = 1; mtOrderLogEntity.setResBody(result);
Integer PUSH_STATUS_SUCCESS = 2;
Integer PUSH_STATUS_EXPIRE = 3;
JSONObject jsonObject = JSONObject.parseObject(result);
if (jsonObject == null || jsonObject.isEmpty() || 0 != jsonObject.getInteger("Result")) { Integer PUSH_STATUS_FAIL = 1;
mtOrderLogEntity.setPushStatus( Integer PUSH_STATUS_SUCCESS = 2;
isExpire(mtOrderLogEntity.getCreateTime()) ? PUSH_STATUS_EXPIRE : PUSH_STATUS_FAIL Integer PUSH_STATUS_EXPIRE = 3;
); JSONObject jsonObject = JSONObject.parseObject(result);
} else {
mtOrderLogEntity.setPushStatus(PUSH_STATUS_SUCCESS);
}
// 由于要存储每次的响应结果,所以每次请求后都立即保存 if (jsonObject == null || jsonObject.isEmpty() || 0 != jsonObject.getInteger("Result")) {
mtOrderLogService.updateById(mtOrderLogEntity); mtOrderLogEntity.setPushStatus(
isExpire(mtOrderLogEntity.getCreateTime()) ? PUSH_STATUS_EXPIRE : PUSH_STATUS_FAIL
);
} else {
mtOrderLogEntity.setPushStatus(PUSH_STATUS_SUCCESS);
}
// 由于要存储每次的响应结果,所以每次请求后都立即保存
mtOrderLogService.updateById(mtOrderLogEntity);
}
} catch (Exception e) { } catch (Exception e) {
log.error("梦天重推 error", e); log.error("梦天重推 error", e);
} }

Loading…
Cancel
Save