|
|
|
@ -9,7 +9,6 @@ import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import cn.hutool.json.JSONObject; |
|
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
|
import com.logpm.factorydata.enums.BrandEnums; |
|
|
|
|
import org.springblade.common.constant.WorkNodeEnums; |
|
|
|
|
import com.logpm.factorydata.feign.IFactoryDataClient; |
|
|
|
|
import com.logpm.factorydata.vo.NodePushMsg; |
|
|
|
|
import com.logpm.factorydata.vo.SendMsg; |
|
|
|
@ -33,6 +32,7 @@ import lombok.AllArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.jetbrains.annotations.NotNull; |
|
|
|
|
import org.jetbrains.annotations.Nullable; |
|
|
|
|
import org.springblade.common.constant.WorkNodeEnums; |
|
|
|
|
import org.springblade.common.constant.factorydata.FactoryDataConstants; |
|
|
|
|
import org.springblade.common.utils.HutoolConfigUtil; |
|
|
|
|
import org.springframework.amqp.core.ExchangeTypes; |
|
|
|
@ -145,7 +145,16 @@ public class ZbomNodeDataPushListener {
|
|
|
|
|
} |
|
|
|
|
log.info("zb节点推送数据:参数{},返回值{}。", body, result); |
|
|
|
|
if (StrUtil.isNotBlank(result)) { |
|
|
|
|
ZbFactoryNodePushFailEntity build = ZbFactoryNodePushFailEntity.builder().content(body).resultContent(result).build(); |
|
|
|
|
NodeDataDTO nodeDataDTO = nodeDataMap.get(key); |
|
|
|
|
String packageCode = nodeDataDTO.getPackageCode(); |
|
|
|
|
ZbFactoryNodePushFailEntity build = ZbFactoryNodePushFailEntity.builder() |
|
|
|
|
.content(body) |
|
|
|
|
.resultContent(result) |
|
|
|
|
.departCode(nodeConfirmParam.getDepartCode()) |
|
|
|
|
.platformOrderCode(nodeConfirmParam.getPlatformOrderCode()) |
|
|
|
|
.node(nodeConfirmParam.getNode()) |
|
|
|
|
.packageCode(packageCode) |
|
|
|
|
.build(); |
|
|
|
|
if (!StrUtil.contains(result, "code")) { |
|
|
|
|
// 推送失败
|
|
|
|
|
nodePushFailService.save(build); |
|
|
|
@ -156,8 +165,6 @@ public class ZbomNodeDataPushListener {
|
|
|
|
|
// 推送失败
|
|
|
|
|
nodePushFailService.save(build); |
|
|
|
|
} |
|
|
|
|
NodeDataDTO nodeDataDTO = nodeDataMap.get(key); |
|
|
|
|
String packageCode = nodeDataDTO.getPackageCode(); |
|
|
|
|
if (ObjectUtil.isEmpty(packageCode)) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
@ -228,42 +235,21 @@ public class ZbomNodeDataPushListener {
|
|
|
|
|
log.info("key:{},签收数量:{}", departCode + "_" + platformOrderCode, signNumber); |
|
|
|
|
|
|
|
|
|
// 签收环节上一个节点是在途,说明缺少一个送货抵达,需要补一个节点
|
|
|
|
|
if (ObjectUtil.isEmpty(nodeOrderEntity) || ObjectUtil.equal(nodeOrderEntity.getCurrentNode(), ZbomNodeEnums.INTRANSIT.getIndex())) { |
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(nodeOrderEntity.getPushNode()) || !StrUtil.contains(nodeOrderEntity.getPushNode(), ZbomNodeEnums.DELIVERY_ARRIVAL.getCode())) { |
|
|
|
|
// 第一次签收,节点改为送货抵达
|
|
|
|
|
paramDTO.setNode(ZbomNodeEnums.DELIVERY_ARRIVAL.getCode()); |
|
|
|
|
currentNode = ZbomNodeEnums.DELIVERY_ARRIVAL; |
|
|
|
|
List<Object> js = new ArrayList<>(); |
|
|
|
|
for (String s : nodeData.getPackageCode().split(",")) { |
|
|
|
|
JSONObject entries1 = new JSONObject(); |
|
|
|
|
entries1.set("packageCode", s); |
|
|
|
|
js.add(entries1); |
|
|
|
|
} |
|
|
|
|
NodePushMsg nodePushMsg = NodePushMsg.builder() |
|
|
|
|
.node(WorkNodeEnums.CLERK_REVIEW) |
|
|
|
|
.operator(paramDTO.getOperator()) |
|
|
|
|
.operatorTime(DateUtil.parseDateTime(paramDTO.getOperatorTime())) |
|
|
|
|
.address(paramDTO.getAddress()) |
|
|
|
|
.brand(BrandEnums.ZB) |
|
|
|
|
.content(js) |
|
|
|
|
.build(); |
|
|
|
|
SendMsg message = SendMsg.builder() |
|
|
|
|
.delay(30 * 60 * 1000) |
|
|
|
|
.exchange(FactoryDataConstants.Mq.Exchanges.NODE_DATA_PUSH_DELAYED) |
|
|
|
|
.routingKey(FactoryDataConstants.Mq.RoutingKeys.ZBOM_NODE_DATA_PUSH) |
|
|
|
|
.message(JSONUtil.toJsonStr(nodePushMsg, HutoolConfigUtil.jsonConfigByDataTimeFormat())) |
|
|
|
|
.build(); |
|
|
|
|
sendMsgMap.put(key, message); |
|
|
|
|
Integer nodeDelay = 15 * 60 * 1000; |
|
|
|
|
buildSendMag(sendMsgMap, nodeData, key, paramDTO, node, nodeDelay); |
|
|
|
|
} else { |
|
|
|
|
// 查询当前未签收的数量与当前签收数量比较,如果未签收数较大,则是部分签收
|
|
|
|
|
paramDTO.setNode(ZbomNodeMappingEnums.getZbomByNodeAndStatus(workNodeEnums, ZbomConstants.Status.SIGN_FOR_SECTION_STATUS).getCode()); |
|
|
|
|
currentNode = ZbomNodeEnums.PARTIAL_RECEIPT; |
|
|
|
|
paramDTO.setSignQty(nodeData.getSignQty()); |
|
|
|
|
if (ObjectUtil.isNotEmpty(noSignNumberMap) && noSignNumberMap.containsKey(key)) { |
|
|
|
|
Integer noSignNum = noSignNumberMap.get(key); |
|
|
|
|
if (noSignNum <= signNumber) { |
|
|
|
|
// 全部签收
|
|
|
|
|
log.info("{} 全部签收", platformOrderCode); |
|
|
|
|
paramDTO.setNode(ZbomNodeMappingEnums.getZbomByNodeAndStatus(workNodeEnums, ZbomConstants.Status.SIGN_FOR_ALL_STATUS).getCode()); |
|
|
|
|
currentNode = ZbomNodeEnums.SIGN_FOR; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
continue; |
|
|
|
@ -272,21 +258,61 @@ public class ZbomNodeDataPushListener {
|
|
|
|
|
// 如果之前发送的是部分签收,则之后的所有签收节点都发部分签收
|
|
|
|
|
if (StrUtil.isNotEmpty(pushNode) && pushNode.contains(ZbomNodeEnums.PARTIAL_RECEIPT.getIndex().toString())) { |
|
|
|
|
log.info("{} 部分签收", platformOrderCode); |
|
|
|
|
paramDTO.setNode(ZbomNodeMappingEnums.getZbomByNodeAndStatus(workNodeEnums, ZbomConstants.Status.SIGN_FOR_SECTION_STATUS).getCode()); |
|
|
|
|
currentNode = ZbomNodeEnums.PARTIAL_RECEIPT; |
|
|
|
|
} |
|
|
|
|
currentNode = ZbomNodeEnums.getByCode(paramDTO.getNode()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Integer index = currentNode.getIndex(); |
|
|
|
|
Integer startNodeDelay = 15 * 60 * 1000; |
|
|
|
|
// 历史必须节点需要补发
|
|
|
|
|
if (ObjectUtil.isEmpty(nodeOrderEntity.getPushNode())) { |
|
|
|
|
// 历史不存在,当前节点不是第一个节点,则需要补发第一个节点
|
|
|
|
|
if (!ObjectUtil.equal(index, ZbomNodeEnums.STATION_DEPART.getIndex())) { |
|
|
|
|
currentNode = ZbomNodeEnums.STATION_DEPART; |
|
|
|
|
buildSendMag(sendMsgMap, nodeData, key, paramDTO, node, startNodeDelay); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
// 历史节点存在,但是历史节点中不包含第一个节点,且当前节点不是第一个节点,则需要补发第一个节点
|
|
|
|
|
if (!ObjectUtil.equal(index, ZbomNodeEnums.STATION_DEPART.getIndex()) |
|
|
|
|
&& !StrUtil.contains(nodeOrderEntity.getPushNode(), ZbomNodeEnums.STATION_DEPART.getIndex().toString())) { |
|
|
|
|
currentNode = ZbomNodeEnums.STATION_DEPART; |
|
|
|
|
buildSendMag(sendMsgMap, nodeData, key, paramDTO, node, startNodeDelay); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 组装历史节点数据
|
|
|
|
|
if (buildNodeOrder(nodeOrderEntity, currentNode, departCode, platformOrderCode, index, nodeOrderMap)) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
paramDTO.setNode(currentNode.getCode()); |
|
|
|
|
nodeConfirmLsit.add(paramDTO); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void buildSendMag(Map<String, SendMsg> sendMsgMap, NodeDataDTO nodeData, String key, NodeConfirmParamDTO paramDTO, String node, Integer delay) { |
|
|
|
|
List<Object> js = new ArrayList<>(); |
|
|
|
|
for (String s : nodeData.getPackageCode().split(",")) { |
|
|
|
|
JSONObject entries1 = new JSONObject(); |
|
|
|
|
entries1.set("packageCode", s); |
|
|
|
|
js.add(entries1); |
|
|
|
|
} |
|
|
|
|
NodePushMsg nodePushMsg = NodePushMsg.builder() |
|
|
|
|
.node(EnumUtil.fromString(WorkNodeEnums.class, node)) |
|
|
|
|
.operator(paramDTO.getOperator()) |
|
|
|
|
.operatorTime(DateUtil.parseDateTime(paramDTO.getOperatorTime())) |
|
|
|
|
.address(paramDTO.getAddress()) |
|
|
|
|
.brand(BrandEnums.ZB) |
|
|
|
|
.content(js) |
|
|
|
|
.build(); |
|
|
|
|
SendMsg message = SendMsg.builder() |
|
|
|
|
.delay(delay) |
|
|
|
|
.exchange(FactoryDataConstants.Mq.Exchanges.NODE_DATA_PUSH_DELAYED) |
|
|
|
|
.routingKey(FactoryDataConstants.Mq.RoutingKeys.ZBOM_NODE_DATA_PUSH) |
|
|
|
|
.message(JSONUtil.toJsonStr(nodePushMsg, HutoolConfigUtil.jsonConfigByDataTimeFormat())) |
|
|
|
|
.build(); |
|
|
|
|
sendMsgMap.put(key, message); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean buildNodeOrder(ZbFactoryNodeOrderEntity nodeOrderEntity, ZbomNodeEnums zbNode, String departCode, String platformOrderCode, Integer index, Map<String, ZbFactoryNodeOrderEntity> nodeOrderEntityMap) { |
|
|
|
|
if (ObjectUtil.isNotEmpty(nodeOrderEntity)) { |
|
|
|
|
Integer currentNode = nodeOrderEntity.getCurrentNode(); |
|
|
|
|