|
|
|
@ -18,6 +18,7 @@ import cn.hutool.json.JSONUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.logpm.factorydata.enums.SaxStatusEnums; |
|
|
|
|
import com.logpm.factorydata.suofeiya.entity.DeliveryNoteEntity; |
|
|
|
|
import com.logpm.factorydata.suofeiya.entity.FactoryNodePushEntity; |
|
|
|
|
import com.logpm.factorydata.suofeiya.entity.FactoryOrderLogEntity; |
|
|
|
|
import com.logpm.factorydata.suofeiya.entity.OrderInfoEntity; |
|
|
|
|
import com.logpm.factorydata.suofeiya.entity.PackageInfoEntity; |
|
|
|
@ -28,6 +29,7 @@ import com.logpm.factorydata.suofeiya.pros.FactoryDataSuoFeiYaProperties;
|
|
|
|
|
import com.logpm.factorydata.suofeiya.pros.OldProperties; |
|
|
|
|
import com.logpm.factorydata.suofeiya.service.DeliveryNoteService; |
|
|
|
|
import com.logpm.factorydata.suofeiya.service.FactoryDataService; |
|
|
|
|
import com.logpm.factorydata.suofeiya.service.FactoryNodePushService; |
|
|
|
|
import com.logpm.factorydata.suofeiya.service.FactoryOrderLogService; |
|
|
|
|
import com.logpm.factorydata.suofeiya.service.OrderInfoService; |
|
|
|
|
import com.logpm.factorydata.suofeiya.service.PackageInfoService; |
|
|
|
@ -68,6 +70,7 @@ public class FactoryDataServiceImpl implements FactoryDataService {
|
|
|
|
|
private final FactoryOrderLogService logService; |
|
|
|
|
private final OldProperties oldProperties; |
|
|
|
|
private final FactoryDataSuoFeiYaProperties dataSuoFeiYaProperties; |
|
|
|
|
private final FactoryNodePushService factoryNodePushService; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@ -198,6 +201,7 @@ public class FactoryDataServiceImpl implements FactoryDataService {
|
|
|
|
|
// 按订单号和运单号进行分组
|
|
|
|
|
if (CollUtil.isNotEmpty(content)) { |
|
|
|
|
for (Map.Entry<String, Set<String>> entry : packageCodeMap.entrySet()) { |
|
|
|
|
FactoryNodePushEntity nodePushEntity = new FactoryNodePushEntity(); |
|
|
|
|
String key = entry.getKey(); |
|
|
|
|
Set<String> value = entry.getValue(); |
|
|
|
|
JSONObject jsons = new JSONObject(); |
|
|
|
@ -221,11 +225,23 @@ public class FactoryDataServiceImpl implements FactoryDataService {
|
|
|
|
|
packages.add(js); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (CollUtil.isNotEmpty(packages)) { |
|
|
|
|
String paNo = packages.stream().map(i -> i.getStr("paNo")).collect(Collectors.joining(",")); |
|
|
|
|
nodePushEntity.setPackageCode(paNo); |
|
|
|
|
} |
|
|
|
|
jsons.set("packageInfo", new JSONArray(packages)); |
|
|
|
|
if(StrUtil.equals(key, "Z")){ |
|
|
|
|
if (StrUtil.equals(key, "Z")) { |
|
|
|
|
jsons.set("orderType", key); |
|
|
|
|
nodePushEntity.setOrderType(key); |
|
|
|
|
} |
|
|
|
|
nodePushEntity.setLogisticsStatus(factoryNode.getText()); |
|
|
|
|
String jsonStr = JSONUtil.toJsonStr(jsons); |
|
|
|
|
nodePushEntity.setContent(jsonStr); |
|
|
|
|
nodePushEntity.setTenantCode(AuthUtil.getTenantId()); |
|
|
|
|
nodePushEntity.setAppKey(appKey); |
|
|
|
|
nodePushEntity.setCompanyCode(companyCode); |
|
|
|
|
nodePushEntity.setTimestamp(time); |
|
|
|
|
nodePushEntity.setWarehouse(entries.getStr("warehouse")); |
|
|
|
|
if (oldProperties.getEnable()) { |
|
|
|
|
try { |
|
|
|
|
log.info("推送节点数据:{}", jsonStr); |
|
|
|
@ -238,7 +254,7 @@ public class FactoryDataServiceImpl implements FactoryDataService {
|
|
|
|
|
} |
|
|
|
|
if (dataSuoFeiYaProperties.getPush().getPushEnable()) { |
|
|
|
|
String paStatusUrl = dataSuoFeiYaProperties.getPush().getPaStatusUrl(); |
|
|
|
|
sendFactory(companyCode, jsonStr, time, appKey, paStatusUrl); |
|
|
|
|
sendFactory(companyCode, jsonStr, time, appKey, paStatusUrl, nodePushEntity); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -246,6 +262,7 @@ public class FactoryDataServiceImpl implements FactoryDataService {
|
|
|
|
|
// 推送配送单计划
|
|
|
|
|
if (CollUtil.isNotEmpty(content)) { |
|
|
|
|
for (Map.Entry<String, Set<String>> entry : packageCodeMap.entrySet()) { |
|
|
|
|
FactoryNodePushEntity nodePushEntity = new FactoryNodePushEntity(); |
|
|
|
|
String key = entry.getKey(); |
|
|
|
|
Set<String> value = entry.getValue(); |
|
|
|
|
JSONObject jsons = new JSONObject(); |
|
|
|
@ -262,9 +279,14 @@ public class FactoryDataServiceImpl implements FactoryDataService {
|
|
|
|
|
packages.add(pushData.getPackageCode()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (CollUtil.isNotEmpty(packages)) { |
|
|
|
|
String paNo = packages.stream().collect(Collectors.joining(",")); |
|
|
|
|
nodePushEntity.setPackageCode(paNo); |
|
|
|
|
} |
|
|
|
|
if (StrUtil.isNotEmpty(main)) { |
|
|
|
|
JSONObject jsonObject = JSONUtil.parseObj(main); |
|
|
|
|
jsons.set("shipPlanNo", jsonObject.getStr("trainNumber")); |
|
|
|
|
nodePushEntity.setShipPlanNo(jsonObject.getStr("trainNumber")); |
|
|
|
|
jsons.set("receiver", jsonObject.getStr("receiver")); |
|
|
|
|
jsons.set("receiveAddr", jsonObject.getStr("receiveAddr")); |
|
|
|
|
jsons.set("receiveTel", jsonObject.getStr("receiveTel")); |
|
|
|
@ -273,10 +295,18 @@ public class FactoryDataServiceImpl implements FactoryDataService {
|
|
|
|
|
jsons.set("paNo", JSONUtil.toJsonStr(packages)); |
|
|
|
|
jsons.set("remark", ""); |
|
|
|
|
jsons.set("orderExtendFields", new JSONArray()); |
|
|
|
|
if(StrUtil.equals(key, "Z")){ |
|
|
|
|
if (StrUtil.equals(key, "Z")) { |
|
|
|
|
jsons.set("orderType", key); |
|
|
|
|
nodePushEntity.setOrderType(key); |
|
|
|
|
} |
|
|
|
|
nodePushEntity.setLogisticsStatus(factoryNode.getText()); |
|
|
|
|
String jsonStr = JSONUtil.toJsonStr(jsons); |
|
|
|
|
nodePushEntity.setContent(jsonStr); |
|
|
|
|
nodePushEntity.setTenantCode(AuthUtil.getTenantId()); |
|
|
|
|
nodePushEntity.setAppKey(appKey); |
|
|
|
|
nodePushEntity.setCompanyCode(companyCode); |
|
|
|
|
nodePushEntity.setTimestamp(time); |
|
|
|
|
nodePushEntity.setWarehouse(entries.getStr("warehouse")); |
|
|
|
|
if (oldProperties.getEnable()) { |
|
|
|
|
try { |
|
|
|
|
log.info("推送节点数据:{}", jsonStr); |
|
|
|
@ -289,14 +319,14 @@ public class FactoryDataServiceImpl implements FactoryDataService {
|
|
|
|
|
} |
|
|
|
|
if (dataSuoFeiYaProperties.getPush().getPushEnable()) { |
|
|
|
|
String paStatusUrl = dataSuoFeiYaProperties.getPush().getShipPlanUrl(); |
|
|
|
|
sendFactory(companyCode, jsonStr, time, appKey, paStatusUrl); |
|
|
|
|
sendFactory(companyCode, jsonStr, time, appKey, paStatusUrl, nodePushEntity); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void sendFactory(String companyCode, String jsonStr, Long time, String appKey, String paStatusUrl) { |
|
|
|
|
private void sendFactory(String companyCode, String jsonStr, Long time, String appKey, String paStatusUrl, FactoryNodePushEntity nodePushEntity) { |
|
|
|
|
try { |
|
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
|
|
param.put("companyCode", companyCode); |
|
|
|
@ -306,8 +336,18 @@ public class FactoryDataServiceImpl implements FactoryDataService {
|
|
|
|
|
String digest = MD5.create().digestHex(jsonStr + appKey + time); |
|
|
|
|
String encode = Base64.encode(digest); |
|
|
|
|
param.put("digest", encode); |
|
|
|
|
nodePushEntity.setDigest(digest); |
|
|
|
|
nodePushEntity.setSendUrl(dataSuoFeiYaProperties.getPush().getPushHost() + paStatusUrl); |
|
|
|
|
log.info("推送节点数据:{}", JSONUtil.toJsonStr(param)); |
|
|
|
|
String post = HttpUtil.post(dataSuoFeiYaProperties.getPush().getPushHost() + paStatusUrl, param); |
|
|
|
|
nodePushEntity.setResultContent(post); |
|
|
|
|
JSONObject entries = JSONUtil.parseObj(post); |
|
|
|
|
if (StrUtil.equals(entries.getStr("result_code"), "0000")) { |
|
|
|
|
nodePushEntity.setSendStatus("0"); |
|
|
|
|
} else { |
|
|
|
|
nodePushEntity.setSendStatus("-1"); |
|
|
|
|
} |
|
|
|
|
factoryNodePushService.save(nodePushEntity); |
|
|
|
|
log.info("推送结果:{}", post); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|