|
|
|
@ -94,6 +94,13 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
@Override |
|
|
|
|
public String saveOuPaiFactoryOrderDTOByCarCarNumber(String code) { |
|
|
|
|
|
|
|
|
|
String key = bladeRedis.get(RedisKeyConstant.cache_oupai_key + code); |
|
|
|
|
if (ObjectUtils.isNull(key)) { |
|
|
|
|
bladeRedis.setEx(RedisKeyConstant.cache_oupai_key + key, key, 60 * 60L); |
|
|
|
|
} else { |
|
|
|
|
log.info(">>>>>> 收货单 已存在 {}", code); |
|
|
|
|
return code; |
|
|
|
|
} |
|
|
|
|
// 对返回i的数据进行处理 按照 发车单-->订单-->包件 完成保存
|
|
|
|
|
handleData(code); |
|
|
|
|
if (ObjectUtils.isNotNull(code)) { |
|
|
|
@ -162,9 +169,10 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
// saveOuPaiFactoryOrderDTOByCarCarNumber(orderCode);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
QueryWrapper<FactoryPackageEntity> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
queryWrapper.eq("oid", key); |
|
|
|
|
FactoryPackageEntity packageEntity = factoryPackageService.getOne(queryWrapper); |
|
|
|
|
LambdaQueryWrapper<FactoryPackageEntity> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
queryWrapper.eq(FactoryPackageEntity::getOid, key); |
|
|
|
|
List<FactoryPackageEntity> list = factoryPackageService.list(queryWrapper); |
|
|
|
|
|
|
|
|
|
String code = null; |
|
|
|
|
String endWarehouseName = null; |
|
|
|
|
String opShipNo = null; |
|
|
|
@ -173,7 +181,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
String siteName = null; |
|
|
|
|
String packageDetailNames = null; |
|
|
|
|
String firstPackName, secondPackName, thirdPackName = null; |
|
|
|
|
if (Objects.isNull(packageEntity)) { |
|
|
|
|
if (Objects.isNull(list) || list.isEmpty()) { |
|
|
|
|
|
|
|
|
|
// 需要对
|
|
|
|
|
log.warn("############oid 查询数据失败: {}", key); |
|
|
|
@ -221,6 +229,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
FactoryPackageEntity packageEntity = list.get(0); |
|
|
|
|
packageEntity.setPackageStatus(5); |
|
|
|
|
factoryPackageService.updateById(packageEntity); |
|
|
|
|
code = packageEntity.getCode(); |
|
|
|
@ -294,19 +303,11 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
|
|
|
|
|
Boolean isUpdate = false; |
|
|
|
|
|
|
|
|
|
String o = bladeRedis.get(RedisKeyConstant.cache_oupai_key + code); |
|
|
|
|
if(code.equals(o)){ |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<ReceivingOrderEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
lambdaQueryWrapper.eq(ReceivingOrderEntity::getCode, code); |
|
|
|
|
List<ReceivingOrderEntity> receivingOrderEntities = receivingOrderMapper.selectList(lambdaQueryWrapper); |
|
|
|
|
if (ObjectUtils.isNotNull(receivingOrderEntities)) { |
|
|
|
|
isUpdate = true; |
|
|
|
|
// 加入缓存
|
|
|
|
|
bladeRedis.setEx(RedisKeyConstant.cache_oupai_key+code,code,60*60*60L); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
return isUpdate; |
|
|
|
|
} |
|
|
|
@ -361,7 +362,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
String unitNo = orderStatusDTO.getUnitNo(); |
|
|
|
|
String operationTime = orderStatusDTO.getOperationTime(); |
|
|
|
|
// || "7".equals(status) 增加签收状态推送
|
|
|
|
|
if ("1".equals(status) || "2".equals(status) || "3".equals(status) || "5".equals(status) || "6".equals(status) || "8".equals(status) || "9".equals(status)) { |
|
|
|
|
if ("2".equals(status) || "3".equals(status) || "5".equals(status) || "6".equals(status) || "8".equals(status) || "9".equals(status)) { |
|
|
|
|
log.warn("#############oupai-handleStatusData: 当前数据的状态不推送 status={}", status); |
|
|
|
|
return Resp.fail(400, "当前数据的状态不推送"); |
|
|
|
|
} |
|
|
|
@ -427,7 +428,8 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
detailObject.put("WarehouseBelong", "oppein"); |
|
|
|
|
detailObject.put("Creator", orderStatusDTO.getUsername()); |
|
|
|
|
detailObject.put("PackageCode", unitNo); |
|
|
|
|
if ("4".equals(status)) { |
|
|
|
|
// 增加当仓直接入库的 就没有卸车收货的状态 直接 进行入库 入库就表示货物进入当前仓库
|
|
|
|
|
if ("4".equals(status) || "1".equals(status)) { |
|
|
|
|
detailObject.put("Operate", "收货"); |
|
|
|
|
} else if ("7".equals(status)) { |
|
|
|
|
detailObject.put("Operate", "发货"); |
|
|
|
@ -444,17 +446,20 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
// 推送数据
|
|
|
|
|
String url = ouPaiProperties.getUri() + "tims_odata_api/api/odata/PackageFeedbackRecord"; |
|
|
|
|
OpPackagePushLogEntity opPackagePushLogEntity = sendPushOuPaiData(factoryPackageEntity.getId(), url, 1, detailObject); |
|
|
|
|
// 需要盘点这个对象的
|
|
|
|
|
String resp = opPackagePushLogEntity.getResp(); |
|
|
|
|
|
|
|
|
|
// 转换为json
|
|
|
|
|
// JSONObject respJson = JSONObject.parseObject(resp);
|
|
|
|
|
log.info(" >>>>>>>>>>>>>>>>>>>>>>> 推送欧派返回数据 {}", resp); |
|
|
|
|
// TODO: 2023/10/25 不知道返回成功的状态是多少
|
|
|
|
|
|
|
|
|
|
// 需要修改包件对应的状态
|
|
|
|
|
factoryPackageEntity.setPushStatus(1); |
|
|
|
|
factoryPackageService.updateById(factoryPackageEntity); |
|
|
|
|
if (opPackagePushLogEntity == null) { |
|
|
|
|
log.info(" >>>>>>>>>>>>>>>>>>>>>>> 包件 {} 已推送欧派 状态 {}", unitNo, detailObject.get("Operate")); |
|
|
|
|
} else { |
|
|
|
|
// 需要盘点这个对象的
|
|
|
|
|
String resp = opPackagePushLogEntity.getResp(); |
|
|
|
|
// 转换为json
|
|
|
|
|
// JSONObject respJson = JSONObject.parseObject(resp);
|
|
|
|
|
log.info(" >>>>>>>>>>>>>>>>>>>>>>> 推送欧派返回数据 {}", resp); |
|
|
|
|
// TODO: 2023/10/25 不知道返回成功的状态是多少
|
|
|
|
|
// 需要修改包件对应的状态
|
|
|
|
|
factoryPackageEntity.setPushStatus(1); |
|
|
|
|
factoryPackageService.updateById(factoryPackageEntity); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return Resp.success("物流状态传递成功"); |
|
|
|
@ -583,20 +588,32 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private OpPackagePushLogEntity sendPushOuPaiData(Long refId, String url, Integer pushType, JSONObject data) { |
|
|
|
|
OpPackagePushLogEntity opPackagePushLogEntity = new OpPackagePushLogEntity(); |
|
|
|
|
opPackagePushLogEntity.setArgs(data.toJSONString()); |
|
|
|
|
opPackagePushLogEntity.setPushType(pushType); |
|
|
|
|
opPackagePushLogEntity.setUrl(url); |
|
|
|
|
opPackagePushLogEntity.setRefId(refId); |
|
|
|
|
opPackagePushLogEntity.setPushOupaiNode(data.getString("Operate")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String token = buildToken(); |
|
|
|
|
HttpResponse httpResponse = HttpRequest.post(url).header("Authorization", token).body(data.toJSONString()).execute(); |
|
|
|
|
String result = httpResponse.body(); |
|
|
|
|
opPackagePushLogEntity.setResp(result); |
|
|
|
|
opPackagePushLogService.save(opPackagePushLogEntity); |
|
|
|
|
return opPackagePushLogEntity; |
|
|
|
|
LambdaQueryWrapper<OpPackagePushLogEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
lambdaQueryWrapper.eq(OpPackagePushLogEntity::getRefId, refId); |
|
|
|
|
lambdaQueryWrapper.eq(OpPackagePushLogEntity::getPushOupaiNode, data.getString("Operate")); |
|
|
|
|
List<OpPackagePushLogEntity> list = opPackagePushLogService.list(lambdaQueryWrapper); |
|
|
|
|
if (ObjectUtils.isNull(list) || list.isEmpty()) { |
|
|
|
|
OpPackagePushLogEntity opPackagePushLogEntity = new OpPackagePushLogEntity(); |
|
|
|
|
opPackagePushLogEntity.setArgs(data.toJSONString()); |
|
|
|
|
opPackagePushLogEntity.setPushType(pushType); |
|
|
|
|
opPackagePushLogEntity.setUrl(url); |
|
|
|
|
opPackagePushLogEntity.setRefId(refId); |
|
|
|
|
opPackagePushLogEntity.setPushOupaiNode(data.getString("Operate")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String token = buildToken(); |
|
|
|
|
HttpResponse httpResponse = HttpRequest.post(url).header("Authorization", token).body(data.toJSONString()).execute(); |
|
|
|
|
String result = httpResponse.body(); |
|
|
|
|
opPackagePushLogEntity.setResp(result); |
|
|
|
|
opPackagePushLogService.save(opPackagePushLogEntity); |
|
|
|
|
return opPackagePushLogEntity; |
|
|
|
|
} else { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -607,6 +624,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
*/ |
|
|
|
|
private void handleData(String code) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OpOrderStatusLogEntity opOrderStatusLogEntity = findOurPaiDataByCarNumber(code); |
|
|
|
|
|
|
|
|
|
// 保存需要解析的数据
|
|
|
|
@ -618,6 +636,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
analyzeData(resultArray); |
|
|
|
|
opOrderStatusLogEntity.setDataStatus(1); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
log.error(">>>> TAG {} error {}", FactoryConstant.OUPAI, e.getMessage()); |
|
|
|
|
opOrderStatusLogEntity.setDataStatus(2); |
|
|
|
|
|
|
|
|
@ -647,13 +666,11 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
receivingOrderEntity.setCode(code); |
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<ReceivingOrderEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
lambdaQueryWrapper.eq(ReceivingOrderEntity::getCode,code); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lambdaQueryWrapper.eq(ReceivingOrderEntity::getCode, code); |
|
|
|
|
List<ReceivingOrderEntity> receivingOrderEntities = receivingOrderMapper.selectList(lambdaQueryWrapper); |
|
|
|
|
if(ObjectUtils.isNotNull(receivingOrderEntities)){ |
|
|
|
|
log.info(">>>>>>>>>>>>>>>>>>>>>>> 收货单已存在 {} ",code); |
|
|
|
|
return ; |
|
|
|
|
if (ObjectUtils.isNotNull(receivingOrderEntities)) { |
|
|
|
|
log.info(">>>>>>>>>>>>>>>>>>>>>>> 收货单已存在 {} ", code); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String type = valueObject.getString("Type"); |
|
|
|
@ -823,7 +840,6 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
factoryOrderEntity.setTurnStatus(0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -836,9 +852,8 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
//保存订单成功,继续保存包件
|
|
|
|
|
Long orderId = factoryOrderEntity.getId(); |
|
|
|
|
String packageCode = packageEntity.getString("Code"); |
|
|
|
|
QueryWrapper<FactoryPackageEntity> packageEntityQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
packageEntityQueryWrapper.eq("code", packageCode); |
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<FactoryPackageEntity> packageEntityQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
packageEntityQueryWrapper.eq(FactoryPackageEntity::getCode, packageCode); |
|
|
|
|
|
|
|
|
|
FactoryPackageEntity factoryPackageEntity = factoryPackageService.getOne(packageEntityQueryWrapper); |
|
|
|
|
|
|
|
|
|