|
|
|
@ -8,7 +8,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
|
|
import com.logpm.factory.comfac.constant.FactoryConstant; |
|
|
|
|
import com.logpm.factory.comfac.dto.OrderStatusDTO; |
|
|
|
|
import com.logpm.factory.comfac.service.IAsyncDataService; |
|
|
|
|
import com.logpm.factory.oupai.entity.*; |
|
|
|
@ -111,6 +110,52 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String saveOuPaiFactoryOrderDTOByCarCarNumberAgain(String code) { |
|
|
|
|
log.info("数据重新获取 start {}", code); |
|
|
|
|
OpOrderStatusLogEntity opOrderStatusLogEntity = findOurPaiDataByCarNumberByLoal(code); |
|
|
|
|
|
|
|
|
|
// 保存需要解析的数据
|
|
|
|
|
// 获取返回内容
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
// 需要下载 数据中的内容
|
|
|
|
|
String responseUrl = opOrderStatusLogEntity.getResponseUrl(); |
|
|
|
|
|
|
|
|
|
// 下载这个数据
|
|
|
|
|
opOrderStatusLogEntity.setResponseBody(FileLogsUtil.loadFileContent(responseUrl)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(opOrderStatusLogEntity.getResponseBody()); |
|
|
|
|
JSONArray resultArray = jsonObject.getJSONArray("value"); |
|
|
|
|
log.info("############handleData: 数据处理开始"); |
|
|
|
|
analyzeData(resultArray); |
|
|
|
|
opOrderStatusLogEntity.setDataStatus(1); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error(">>>> 欧派数据解析报错", e); |
|
|
|
|
opOrderStatusLogEntity.setDataStatus(2); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
opOrderStatusLogService.saveOrUpdate(opOrderStatusLogEntity); |
|
|
|
|
log.info("数据重新获取 end {}", code); |
|
|
|
|
return code; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private OpOrderStatusLogEntity findOurPaiDataByCarNumberByLoal(String code) { |
|
|
|
|
|
|
|
|
|
// 查询自己数据 判断这个收货单号是否存在
|
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<OpOrderStatusLogEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
lambdaQueryWrapper.eq(OpOrderStatusLogEntity::getType, 3); |
|
|
|
|
lambdaQueryWrapper.like(OpOrderStatusLogEntity::getArgs, code); |
|
|
|
|
lambdaQueryWrapper.orderByAsc(OpOrderStatusLogEntity::getCreateTime); |
|
|
|
|
lambdaQueryWrapper.last("limit 1"); |
|
|
|
|
return opOrderStatusLogService.getOne(lambdaQueryWrapper); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String saveOuPaiPackageStatusByCode(String orderPackageCode, Integer event) { |
|
|
|
|
//
|
|
|
|
@ -372,20 +417,20 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
String currentWarehouseId = orderStatusDTO.getCurrentWarehouse();//当前仓Id
|
|
|
|
|
//查询destinationWarehouse logiBillNo plantId数据
|
|
|
|
|
log.info("oupai-handleStatusData >>> unitNo={}", unitNo); |
|
|
|
|
Map<String, String> supplyData = advanceDetailClient.getSupplyData(unitNo); |
|
|
|
|
if (ObjectUtils.isEmpty(supplyData)) { |
|
|
|
|
return Resp.fail(400, "未查询到该单据信息"); |
|
|
|
|
} |
|
|
|
|
String destinationWarehouseId = supplyData.get("destinationWarehouseId");//目的仓id
|
|
|
|
|
if (StringUtil.isBlank(currentWarehouseId) || StringUtil.isBlank(destinationWarehouseId)) { |
|
|
|
|
log.warn("##############oupai-handleStatusData: 仓库数据有问题currentWarehouseId={} destinationWarehouseId={}", currentWarehouseId, destinationWarehouseId); |
|
|
|
|
return Resp.fail(400, "仓库数据有误"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!currentWarehouseId.equals(destinationWarehouseId)) { |
|
|
|
|
log.info("##############oupai-handleStatusData: 不用处理的状态 currentWarehouseId={} destinationWarehouseId={}", currentWarehouseId, destinationWarehouseId); |
|
|
|
|
return Resp.fail(400, "不是目的仓"); |
|
|
|
|
} |
|
|
|
|
// Map<String, String> supplyData = advanceDetailClient.getSupplyData(unitNo);
|
|
|
|
|
// if (ObjectUtils.isEmpty(supplyData)) {
|
|
|
|
|
// return Resp.fail(400, "未查询到该单据信息");
|
|
|
|
|
// }
|
|
|
|
|
// String destinationWarehouseId = supplyData.get("destinationWarehouseId");//目的仓id
|
|
|
|
|
// if (StringUtil.isBlank(currentWarehouseId) || StringUtil.isBlank(destinationWarehouseId)) {
|
|
|
|
|
// log.warn("##############oupai-handleStatusData: 仓库数据有问题currentWarehouseId={} destinationWarehouseId={}", currentWarehouseId, destinationWarehouseId);
|
|
|
|
|
// return Resp.fail(400, "仓库数据有误");
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (!currentWarehouseId.equals(destinationWarehouseId)) {
|
|
|
|
|
// log.info("##############oupai-handleStatusData: 不用处理的状态 currentWarehouseId={} destinationWarehouseId={}", currentWarehouseId, destinationWarehouseId);
|
|
|
|
|
// return Resp.fail(400, "不是目的仓");
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// 查询这个包件对应到新系统的订单
|
|
|
|
|
FactoryOrderEntity factoryOrder = factoryOrderService.selectEntityByOrderPackageCode(unitNo); |
|
|
|
@ -451,21 +496,51 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
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); |
|
|
|
|
checkOpFactoryPackagePushStatus(factoryPackageEntity); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return Resp.success("物流状态传递成功"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 根据推送类型修改包件上的状态 |
|
|
|
|
* |
|
|
|
|
* @param factoryPackageEntity |
|
|
|
|
*/ |
|
|
|
|
void checkOpFactoryPackagePushStatus(FactoryPackageEntity factoryPackageEntity) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询推送记录 师傅包含 已收货 已出库
|
|
|
|
|
LambdaQueryWrapper<OpPackagePushLogEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
lambdaQueryWrapper.eq(OpPackagePushLogEntity::getRefId, factoryPackageEntity.getId()); |
|
|
|
|
lambdaQueryWrapper.eq(OpPackagePushLogEntity::getPushType, 1);// 查询包件
|
|
|
|
|
|
|
|
|
|
List<OpPackagePushLogEntity> list = opPackagePushLogService.list(lambdaQueryWrapper); |
|
|
|
|
|
|
|
|
|
if (list != null && !list.isEmpty()) { |
|
|
|
|
for (OpPackagePushLogEntity opPackagePushLogEntity : list) { |
|
|
|
|
if ("收货".equals(opPackagePushLogEntity.getPushOupaiNode())) { |
|
|
|
|
factoryPackageEntity.setPushStatus(3); |
|
|
|
|
} |
|
|
|
|
if ("发货".equals(opPackagePushLogEntity.getPushOupaiNode())) { |
|
|
|
|
factoryPackageEntity.setPushStatus(4); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
factoryPackageService.updateById(factoryPackageEntity); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
log.info("包件推送记录未null 包条码{}", factoryPackageEntity.getCode()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 根据汇通业务提供是否操作欧派系统的商场 来决定是否会推数据 |
|
|
|
|
* 如果需要使用欧派系统 这里就需要不进行回传 |
|
|
|
@ -594,6 +669,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
LambdaQueryWrapper<OpPackagePushLogEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
lambdaQueryWrapper.eq(OpPackagePushLogEntity::getRefId, refId); |
|
|
|
|
lambdaQueryWrapper.eq(OpPackagePushLogEntity::getPushOupaiNode, data.getString("Operate")); |
|
|
|
|
lambdaQueryWrapper.eq(OpPackagePushLogEntity::getPushType, pushType);// 查询包件
|
|
|
|
|
List<OpPackagePushLogEntity> list = opPackagePushLogService.list(lambdaQueryWrapper); |
|
|
|
|
if (ObjectUtils.isNull(list) || list.isEmpty()) { |
|
|
|
|
OpPackagePushLogEntity opPackagePushLogEntity = new OpPackagePushLogEntity(); |
|
|
|
@ -669,7 +745,8 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
lambdaQueryWrapper.eq(ReceivingOrderEntity::getCode, code); |
|
|
|
|
List<ReceivingOrderEntity> receivingOrderEntities = receivingOrderMapper.selectList(lambdaQueryWrapper); |
|
|
|
|
if (ObjectUtils.isNotNull(receivingOrderEntities)) { |
|
|
|
|
log.info(">>>>>>>>>>>>>>>>>>>>>>> 收货单已存在 {} ", code); |
|
|
|
|
log.info(">>>>>>>>>>>>>>>>>>>>>>> 收货单已存在 收货单下面的订单是否存在 包件是否存在{} ", code); |
|
|
|
|
extractedOuPaiOrderPackageInfor(valueObject, receivingOrderEntities.get(0).getId(), code); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -729,9 +806,34 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
if (row == 1) { |
|
|
|
|
log.info("############handleData: 保存发货单数据 成功成功成功成功 code={}", code); |
|
|
|
|
Long receivingId = receivingOrderEntity.getId();//发货单id
|
|
|
|
|
extractedOuPaiOrderPackageInfor(valueObject, receivingId, code); |
|
|
|
|
} else { |
|
|
|
|
log.error("############handleData: 保存发货单数据失败 code={}", code); |
|
|
|
|
throw new CustomerException(403, "保存发货单数据失败"); |
|
|
|
|
} |
|
|
|
|
Date end = new Date(); |
|
|
|
|
long startLong = start.getTime(); |
|
|
|
|
long endLong = end.getTime(); |
|
|
|
|
long l = endLong - startLong; |
|
|
|
|
log.info("############handleData: 数据处理完成 耗时 {} 毫秒", l); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 欧派入库方法 |
|
|
|
|
* |
|
|
|
|
* @param valueObject |
|
|
|
|
* @param receivingId |
|
|
|
|
* @param code |
|
|
|
|
*/ |
|
|
|
|
private void extractedOuPaiOrderPackageInfor(JSONObject valueObject, Long receivingId, String code) { |
|
|
|
|
JSONArray packages = valueObject.getJSONArray("Packages"); |
|
|
|
|
|
|
|
|
|
log.info(">>> 获取的包件长度 {}", packages.size()); |
|
|
|
|
for (int j = 0; j < packages.size(); j++) { |
|
|
|
|
JSONObject packageEntity = packages.getJSONObject(j);//包件信息
|
|
|
|
|
log.info(">>>>> 解析出欧派的包件信息 {}", packageEntity.getString("Code")); |
|
|
|
|
JSONObject orderEntity = packageEntity.getJSONObject("Order");//订单信息
|
|
|
|
|
if (orderEntity == null) { |
|
|
|
|
log.info("包件数据没有订单信息 packageCode {}", packageEntity.getString("Code")); |
|
|
|
@ -742,6 +844,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
//
|
|
|
|
|
FactoryOrderEntity factoryOrderEntity = factoryOrderService.selectEntityBySelfCode(selfCode, receivingId); |
|
|
|
|
if (Objects.isNull(factoryOrderEntity)) { |
|
|
|
|
log.info(" oupai 收货单ID{} 收货单下面的订单不存在 进行新增订单 {}", receivingId, selfCode); |
|
|
|
|
factoryOrderEntity = new FactoryOrderEntity(); |
|
|
|
|
factoryOrderEntity.setCode(orderEntity.getString("Code")); |
|
|
|
|
factoryOrderEntity.setSelfCode(selfCode); |
|
|
|
@ -855,6 +958,8 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
FactoryPackageEntity factoryPackageEntity = factoryPackageService.getOne(packageEntityQueryWrapper); |
|
|
|
|
|
|
|
|
|
if (Objects.isNull(factoryPackageEntity)) { |
|
|
|
|
log.info(" oupai 收货单ID{} 收货单下面的包件不存在 进行新增订单 {} 关联包件 {}", receivingId, selfCode, packageCode); |
|
|
|
|
|
|
|
|
|
factoryPackageEntity = new FactoryPackageEntity(); |
|
|
|
|
factoryPackageEntity.setOrderId(orderId); |
|
|
|
|
factoryPackageEntity.setCode(packageCode); |
|
|
|
@ -953,22 +1058,18 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
log.error("############handleData: 包件码已存在 packageCode={} 收货单号 {}", packageCode,code); |
|
|
|
|
String receiveCode = receivingOrderMapper.selectReceivingOrderByOrderId(factoryPackageEntity.getOrderId()); |
|
|
|
|
|
|
|
|
|
if(receiveCode.equals(code)){ |
|
|
|
|
log.error("############handleData: 包件码已存在 packageCode={} ,订单 id {} 收货单号 {}", packageCode, factoryPackageEntity.getOrderId(), code); |
|
|
|
|
|
|
|
|
|
//throw new CustomerException(403, "包件码已存在");
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
log.error("############handleData: 保存发货单数据失败 code={}", code); |
|
|
|
|
throw new CustomerException(403, "保存发货单数据失败"); |
|
|
|
|
} |
|
|
|
|
Date end = new Date(); |
|
|
|
|
long startLong = start.getTime(); |
|
|
|
|
long endLong = end.getTime(); |
|
|
|
|
long l = endLong - startLong; |
|
|
|
|
log.info("############handleData: 数据处理完成 耗时 {} 毫秒", l); |
|
|
|
|
log.error("############handleData: 该包件存在于其它收货单 packageCode={} 订单ID {} 收货单号 {}", packageCode,factoryPackageEntity.getOrderId(), receiveCode); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//throw new CustomerException(403, "包件码已存在");
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -980,6 +1081,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
*/ |
|
|
|
|
private OpOrderStatusLogEntity findOurPaiDataByCarNumber(String code) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String url = ouPaiProperties.getUri() + "tims_odata_api/api/odata/ReceivingOrder?$filter=Code eq '" + code + "'&select=Code,Type,Status,Plate,PackagesCount,ReceivePackageCount,PlateNum,CarNumber,CarrierCode,SendTime,ArrivalTime,ReceiveTime,CreateTime,ReturnNumber\n" + |
|
|
|
|
"&$expand=" + |
|
|
|
|
"Packages($select=Oid,Code,PdaNumber,FirstClassCode,FirstClassName,SecondClassCode,SecondClassName,ThirdClassCode,ThirdClassName,BuyIn,CosourcingCode,CosourcingUnit,SortingCenter,DistributionCenter,Length,Width,Height,Weight,OrderDetail,Order,PathIndex,PathDetail,DeliveryOrders,ReceivingOrders,LPN,LpnSerialNum,IsEntruck,ReservationOrder,OutGoingOrderDetail,SignBill,IsInventory,Inventories,InventoryInDetails,Freeze,OutGoingOrderDetailInventoryDetail,From,Creator,CreateTime,ShipTime,CarNumber,DeliveryMethod,DeliveryReceiver,DeliveryReceiverPhone,ReturnNumber,GroupType,CarrierCode,CarrierName,PackageDetailNames,ReceivingTime,SendTime,ExceptionSignRemark,Descript,SignTime,OutOrder,IsReceiveByHand,PackageStatus,PackageDetailNames;" + |
|
|
|
|