Browse Source

feat(all): 修改梦天回传逻辑

dist.1.3.0
zhaoqiaobo 8 months ago
parent
commit
1ffe687c47
  1. 9
      blade-service/logpm-factory-data/logpm-factory-data-base/src/main/java/com/logpm/factorydata/base/service/impl/MqServiceImpl.java
  2. 31
      blade-service/logpm-factory-data/logpm-factory-data-mengtian/src/main/java/com/logpm/factorydata/mengtian/entity/FactoryNodePushEntity.java
  3. 77
      blade-service/logpm-factory-data/logpm-factory-data-mengtian/src/main/java/com/logpm/factorydata/mengtian/mq/NodeDataPushListener.java

9
blade-service/logpm-factory-data/logpm-factory-data-base/src/main/java/com/logpm/factorydata/base/service/impl/MqServiceImpl.java

@ -14,21 +14,16 @@ import lombok.extern.slf4j.Slf4j;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.ThreadLocalUtil;
import org.springblade.core.tool.utils.WebUtil;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageBuilder;
import org.springframework.amqp.core.MessageDeliveryMode;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.http.HttpHeaders;
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Recover;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestContextHolder;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
/**
* @author zhaoqiaobo
@ -51,14 +46,14 @@ public class MqServiceImpl implements MqService {
* @param msg 消息对象会将对象序列化成json字符串发出
* @return 是否发送成功
*/
@Retryable(value = MsgException.class, maxAttempts = 3, backoff = @Backoff(value = 3000, multiplier = 1.5))
// @Retryable(value = MsgException.class, maxAttempts = 3, backoff = @Backoff(value = 3000, multiplier = 1.5))
@Override
public Boolean sendMsg(String exchange, String routingKey, Object msg) {
// 实时发送
return this.sendMsg(exchange, routingKey, msg, MqConstants.DEFAULT_DELAY);
}
@Retryable(value = MsgException.class, maxAttempts = 3, backoff = @Backoff(value = 3000, multiplier = 1.5))
// @Retryable(value = MsgException.class, maxAttempts = 3, backoff = @Backoff(value = 3000, multiplier = 1.5))
@Override
public Boolean sendMsg(String exchange, String routingKey, Object msg, int delay) {
// 1.获取消息内容,如果非字符串将其序列化

31
blade-service/logpm-factory-data/logpm-factory-data-mengtian/src/main/java/com/logpm/factorydata/mengtian/entity/FactoryNodePushEntity.java

@ -60,21 +60,36 @@ public class FactoryNodePushEntity extends BaseEntity {
*/
@ApiModelProperty(name = "订单号", notes = "")
private String orderCode;
/**
* 节点
*/
@ApiModelProperty(name = "节点", notes = "")
private String node;
/**
* 包条码
*/
@ApiModelProperty(name = "包条码", notes = "")
private String packageCode;
/**
* 节点名称
* 类型
*/
@ApiModelProperty(name = "类型(收货,确认收货,签收,确认签收)", notes = "")
private String type;
/**
* 送货任务ID
*/
@ApiModelProperty(name = "送货任务ID", notes = "")
private String sendTaskId;
/**
* 发送状态
*/
@ApiModelProperty(name = "发送状态", notes = "")
private String sendStatus;
/**
* 操作码
*/
@ApiModelProperty(name = "操作码", notes = "")
private String operationCode;
/**
* url
*/
@ApiModelProperty(name = "节点名称", notes = "")
private String nodeName;
@ApiModelProperty(name = "url", notes = "")
private String sendUrl;
/**
* 内容
*/

77
blade-service/logpm-factory-data/logpm-factory-data-mengtian/src/main/java/com/logpm/factorydata/mengtian/mq/NodeDataPushListener.java

@ -16,10 +16,12 @@ import com.fasterxml.jackson.databind.json.JsonMapper;
import com.logpm.factory.mt.dto.MtPushDataDTO;
import com.logpm.factory.mt.feign.MtFactoryDataClient;
import com.logpm.factorydata.feign.IFactoryDataClient;
import com.logpm.factorydata.mengtian.entity.FactoryNodePushEntity;
import com.logpm.factorydata.mengtian.enums.FactoryNodeEnums;
import com.logpm.factorydata.mengtian.enums.NodeMappingEnums;
import com.logpm.factorydata.mengtian.enums.NodeNeedEnums;
import com.logpm.factorydata.mengtian.pros.MengTianProperties;
import com.logpm.factorydata.mengtian.service.FactoryNodePushService;
import com.logpm.factorydata.mengtian.vo.CentralStkInConfirmOrderVO;
import com.logpm.factorydata.mengtian.vo.CentralStkInConfirmPackageVO;
import com.logpm.factorydata.mengtian.vo.CentralStkInConfirmVO;
@ -59,6 +61,7 @@ public class NodeDataPushListener {
private final IFactoryDataClient factoryDataClient;
private final MtFactoryDataClient mtFactoryDataClient;
private final MengTianProperties mengTianProperties;
private final FactoryNodePushService factoryNodePushService;
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FactoryDataConstants.Mq.Queues.MENGTIAN_NODE_DATA_PUSH, durable = "true"),
@ -127,7 +130,13 @@ public class NodeDataPushListener {
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
sendFactory(s, "mt.poc.ht_yc_noms.CentralStkIn", mengTianProperties.getCentralStkInUrl());
FactoryNodePushEntity entity = FactoryNodePushEntity.builder()
.senderCode(centralStkInVO.getSenderCode())
.orderCode(centralStkInVO.getOrderCode())
.packageCode(centralStkInVO.getPackageCode())
.type("收货")
.build();
sendFactory(s, "mt.poc.ht_yc_noms.CentralStkIn", mengTianProperties.getCentralStkInUrl(), entity);
}
}
}
@ -170,7 +179,21 @@ public class NodeDataPushListener {
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
sendFactory(s, "mt.poc.ht_yc_noms.CentralStkInConfirm", mengTianProperties.getCentralStkInConfirmUrl());
String orderCodes = CollUtil.join(mtPushDataDTOS1.stream().map(pushData -> {
return pushData.getOrderCode();
}).collect(Collectors.toSet()), ",");
String packageCodes = CollUtil.join(content.stream()
.filter(pushData -> orderCodes.contains(pushData.getOrderCode()))
.map(pushData -> {
return pushData.getPackageCode();
}).collect(Collectors.toSet()), ",");
FactoryNodePushEntity entity = FactoryNodePushEntity.builder()
.senderCode(senderCode)
.orderCode(orderCodes)
.packageCode(packageCodes)
.type("确认收货")
.build();
sendFactory(s, "mt.poc.ht_yc_noms.CentralStkInConfirm", mengTianProperties.getCentralStkInConfirmUrl(), entity);
}
}
}
@ -204,7 +227,23 @@ public class NodeDataPushListener {
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
sendFactory(s, "mt.poc.ht_yc_noms.SignFor", mengTianProperties.getSignForUrl());
String orderCodes = CollUtil.join(content.stream().map(pushData -> {
return pushData.getOrderCode();
}).collect(Collectors.toSet()), ",");
String packageCodes = CollUtil.join(content.stream().map(pushData -> {
return pushData.getPackageCode();
}).collect(Collectors.toSet()), ",");
String senderCodes = CollUtil.join(mtPushDataDTOS.stream().map(pushData -> {
return pushData.getSenderCode();
}).collect(Collectors.toSet()), ",");
FactoryNodePushEntity entity = FactoryNodePushEntity.builder()
.senderCode(signForVO.getSenderCode())
.orderCode(signForVO.getOrderCode())
.packageCode(signForVO.getPackageCode())
.type("签收")
.sendTaskId(signForVO.getSendTaskId())
.build();
sendFactory(s, "mt.poc.ht_yc_noms.SignFor", mengTianProperties.getSignForUrl(), entity);
}
}
}
@ -216,9 +255,9 @@ public class NodeDataPushListener {
JSONArray objects = new JSONArray(images);
List<SignForConfirmImageVO> imageVOS = objects.stream()
.filter(m -> !m.toString().contains("blob"))
.map(m ->{
return SignForConfirmImageVO.builder().image(m.toString()).build();
}).collect(Collectors.toList());
.map(m -> {
return SignForConfirmImageVO.builder().image(m.toString()).build();
}).collect(Collectors.toList());
Map<String, MtPushDataDTO> mtPushDataDTOMap = mtPushDataDTOS.stream().collect(Collectors.toMap(MtPushDataDTO::getOrderCode, mtPushDataDTO -> mtPushDataDTO));
SignForConfirmVO confirmVO = SignForConfirmVO.builder()
.sendTaskId(entries1.getStr("boId"))
@ -245,11 +284,27 @@ public class NodeDataPushListener {
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
sendFactory(s, "mt.poc.ht_yc_noms.SignForConfirm", mengTianProperties.getSignForConfirmUrl());
String orderCodes = CollUtil.join(content.stream().map(pushData -> {
return pushData.getOrderCode();
}).collect(Collectors.toSet()), ",");
String packageCodes = CollUtil.join(content.stream().map(pushData -> {
return pushData.getPackageCode();
}).collect(Collectors.toSet()), ",");
String senderCodes = CollUtil.join(mtPushDataDTOS.stream().map(pushData -> {
return pushData.getSenderCode();
}).collect(Collectors.toSet()), ",");
FactoryNodePushEntity entity = FactoryNodePushEntity.builder()
.senderCode(senderCodes)
.orderCode(orderCodes)
.packageCode(packageCodes)
.type("确认签收")
.sendTaskId(confirmVO.getSendTaskId())
.build();
sendFactory(s, "mt.poc.ht_yc_noms.SignForConfirm", mengTianProperties.getSignForConfirmUrl(), entity);
}
}
private void sendFactory(String body, String operationCode, String url) {
private void sendFactory(String body, String operationCode, String url, FactoryNodePushEntity entity) {
log.info("推送工厂:{}", body);
HttpRequest post = HttpUtil.createPost(mengTianProperties.getHost() + url);
post.header("ClientId", "mt.ht");
@ -258,6 +313,12 @@ public class NodeDataPushListener {
HttpResponse execute = post.execute();
String resBody = execute.body();
log.info("推送工厂结果:{}", resBody);
// 存入日志表
entity.setContent(body);
entity.setOperationCode(operationCode);
entity.setSendUrl(mengTianProperties.getHost() + url);
entity.setResultContent(resBody);
factoryNodePushService.save(entity);
}
private boolean checkData(String msg) {

Loading…
Cancel
Save