From 4fce3fda1aa95faa6b69a2d1343978ed09b13128 Mon Sep 17 00:00:00 2001 From: "pref_mail@163.com" Date: Sat, 30 Dec 2023 09:22:47 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=96=B9=E6=B3=95=20?= =?UTF-8?q?=E5=BE=85=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../oupai/entity/FactoryPackageEntity.java | 2 +- .../factory/jobhandler/FactoryXxlJob.java | 100 ++++++++++++++++-- .../service/impl/OuPaiFactoryServiceImpl.java | 64 ++++++++--- 3 files changed, 138 insertions(+), 28 deletions(-) diff --git a/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/entity/FactoryPackageEntity.java b/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/entity/FactoryPackageEntity.java index fa35f4046..55fc89e7c 100644 --- a/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/entity/FactoryPackageEntity.java +++ b/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/entity/FactoryPackageEntity.java @@ -98,7 +98,7 @@ public class FactoryPackageEntity extends BaseEntity { /** 入库单状态 0正常 1作废 */ @ApiModelProperty(name = "入库单状态 0正常 1作废",notes = "") private Integer receiptStatus ; - /** 推送状态 1推送 0未推送 */ + /** 推送欧派 推送状态 1推送 0未推送 3 收货推送完成 4 出库推送完成*/ @ApiModelProperty(name = "推送状态 1推送 0未推送",notes = "") private Integer pushStatus ; @ApiModelProperty(name = "老系统推送状态 1推送 0未推送 2 推送失败",notes = "") diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/jobhandler/FactoryXxlJob.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/jobhandler/FactoryXxlJob.java index 35f04ea1a..6a4efc013 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/jobhandler/FactoryXxlJob.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/jobhandler/FactoryXxlJob.java @@ -1,8 +1,13 @@ package com.logpm.factory.jobhandler; import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.logpm.factory.comfac.dto.OrderStatusDTO; +import com.logpm.factory.oupai.service.IOuPaiFactoryService; import com.logpm.factory.snm.dto.GroupByPackagesDTO; import com.logpm.factory.snm.entity.OrderLogEntity; import com.logpm.factory.snm.entity.StaorderPackagesEntity; @@ -23,6 +28,7 @@ import org.slf4j.LoggerFactory; import org.springblade.common.constant.LogpmDataStatusEnum; import org.springblade.common.constant.PackagesTypeEnum; import org.springblade.common.utils.CommonUtil; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.ObjectUtils; @@ -48,20 +54,22 @@ public class FactoryXxlJob { private static final Logger logger = LoggerFactory.getLogger(FactoryXxlJob.class); - private IStationlinenumService stationlinenumService; + private final IStationlinenumService stationlinenumService; - private IOrderService orderService; + private final IOrderService orderService; - private IOrderLogService orderLogService; + private final IOrderLogService orderLogService; - private IStationOrderService stationOrderService; + private final IStationOrderService stationOrderService; - private IStaorderPackagesService staorderPackagesService; - private IAdvanceClient iAdvanceClient; - private IAdvanceDetailClient advanceDetailClient; - private IDetailProductClient detailProductClient; - private IServiceNumClient serviceNumClient; - private IWarehouseClient warehouseClient; + private final IStaorderPackagesService staorderPackagesService; + private final IAdvanceClient iAdvanceClient; + private final IAdvanceDetailClient advanceDetailClient; + private final IDetailProductClient detailProductClient; + private final IServiceNumClient serviceNumClient; + private final IWarehouseClient warehouseClient; + + private final IOuPaiFactoryService ouPaiFactoryService; /** @@ -403,4 +411,76 @@ public class FactoryXxlJob { } + + // 还需要增加根据欧派收货单获取数据的方法 + + + /** + * 欧派工程数据回推 + * 启动参数格式 + * [{"codes":[包条码...],"type":4},{"codes":[包条码...],"type":7}] + */ + @XxlJob("factoryByOpOrderPackageCodeJobHandler") + public ReturnT factoryByOpOrderPackageCodeJobHandler(String param) throws Exception { + +// todo 需要拆分方法 + + + + // 获取执行参数的中参数 + JSONArray jsonArray; + try { + + jsonArray = JSON.parseArray(param); + + // 入库的数据请求 + JSONObject inArgs =null; + // 出库的数据请求 + JSONObject outArgs =null; + + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject t = jsonArray.getJSONObject(i); + if (t.get("type").equals(4)){ + inArgs= t; + } + if (t.get("type").equals(7)){ + outArgs= t; + } + } + + JSONArray codes = inArgs.getJSONArray("codes"); + extractedJsonArray(codes,"4"); + + + }catch (Exception e){ + + return ReturnT.FAIL; + } + + + + + return ReturnT.SUCCESS; + } + + private void extractedJsonArray(JSONArray codes,String status) { + if(codes !=null&& !codes.isEmpty()){ + for (int i = 0; i < codes.size(); i++) { + // 得到包件码 + String o = (String) codes.get(i); + // 还需要查询老系统的数据 得到这个包件的操作人 + + // 补充推送欧派的推送数据 + OrderStatusDTO orderStatusDTO = new OrderStatusDTO() ; + orderStatusDTO.setUnitNo(o); + orderStatusDTO.setStatus(status); + orderStatusDTO.setUsername();// 操作人 + + ouPaiFactoryService.handleStatusData(orderStatusDTO); + } + } + + } + + } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OuPaiFactoryServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OuPaiFactoryServiceImpl.java index c36854006..173e5f5b7 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OuPaiFactoryServiceImpl.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OuPaiFactoryServiceImpl.java @@ -372,20 +372,20 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService { String currentWarehouseId = orderStatusDTO.getCurrentWarehouse();//当前仓Id //查询destinationWarehouse logiBillNo plantId数据 log.info("oupai-handleStatusData >>> unitNo={}", unitNo); - Map 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 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 +451,50 @@ 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 lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(OpPackagePushLogEntity::getRefId, factoryPackageEntity.getId()); + lambdaQueryWrapper.eq(OpPackagePushLogEntity::getPushType,1);// 查询包件 + + List 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 +623,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); lambdaQueryWrapper.eq(OpPackagePushLogEntity::getRefId, refId); lambdaQueryWrapper.eq(OpPackagePushLogEntity::getPushOupaiNode, data.getString("Operate")); + lambdaQueryWrapper.eq(OpPackagePushLogEntity::getPushType,pushType);// 查询包件 List list = opPackagePushLogService.list(lambdaQueryWrapper); if (ObjectUtils.isNull(list) || list.isEmpty()) { OpPackagePushLogEntity opPackagePushLogEntity = new OpPackagePushLogEntity(); From a928e335e593d8b1090fe66bf98a2c4b402cd9cd Mon Sep 17 00:00:00 2001 From: "pref_mail@163.com" Date: Sun, 31 Dec 2023 01:59:42 +0800 Subject: [PATCH 2/4] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E5=AF=B9=E6=AC=A7?= =?UTF-8?q?=E6=B4=BE=E7=9A=84=E6=94=B6=E8=B4=A7=E5=8D=95=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E8=8E=B7=E5=8F=96=202.=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=AF=B9=E6=AC=A7=E6=B4=BE=E7=9A=84=E6=95=B0=E6=8D=AE=E9=87=8D?= =?UTF-8?q?=E6=96=B0=E6=8E=A8=E9=80=81=E5=85=A5=E5=BA=93=E5=92=8C=E5=87=BA?= =?UTF-8?q?=E5=BA=93=203.=E6=B5=8B=E8=AF=95=E9=80=9A=E8=BF=87=E6=A2=A6?= =?UTF-8?q?=E5=A4=A9=E7=9A=84=E7=AD=BE=E6=94=B6=E6=89=AB=E6=8F=8F=E5=92=8C?= =?UTF-8?q?=E6=96=87=E5=91=98=E5=A4=8D=E6=A0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../constant/OldSystemDataPushConfig.java | 2 + .../impl/DistributionAsyncServiceImpl.java | 4 + .../factory/jobhandler/FactoryXxlJob.java | 118 +++++++++++------- .../factory/mt/feign/MtOrderMainClinet.java | 4 + 4 files changed, 85 insertions(+), 43 deletions(-) diff --git a/blade-biz-common/src/main/java/org/springblade/common/constant/OldSystemDataPushConfig.java b/blade-biz-common/src/main/java/org/springblade/common/constant/OldSystemDataPushConfig.java index c6351e1ae..68ad6deec 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/constant/OldSystemDataPushConfig.java +++ b/blade-biz-common/src/main/java/org/springblade/common/constant/OldSystemDataPushConfig.java @@ -17,6 +17,8 @@ public class OldSystemDataPushConfig { warehourseIds.add("30"); warehourseIds.add("38"); warehourseIds.add("124"); + // 上海 + warehourseIds.add("149"); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAsyncServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAsyncServiceImpl.java index 6890a94bb..6766b4b00 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAsyncServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAsyncServiceImpl.java @@ -1500,6 +1500,10 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { } try { + + + log.info(">>>>>>>>>>>>>>> 文员复核推送 品牌 {} ",brand); + if (Func.isNotEmpty(brand.get("梦天"))){ mtReceiveDTO.setReceiveContentList(brand.get("梦天")); orderMainClinet.sendReceiveInfoByNewSystem(mtReceiveDTO); diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/jobhandler/FactoryXxlJob.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/jobhandler/FactoryXxlJob.java index 6a4efc013..b46716657 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/jobhandler/FactoryXxlJob.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/jobhandler/FactoryXxlJob.java @@ -54,9 +54,9 @@ public class FactoryXxlJob { private static final Logger logger = LoggerFactory.getLogger(FactoryXxlJob.class); - private final IStationlinenumService stationlinenumService; + private final IStationlinenumService stationlinenumService; - private final IOrderService orderService; + private final IOrderService orderService; private final IOrderLogService orderLogService; @@ -66,7 +66,7 @@ public class FactoryXxlJob { private final IAdvanceClient iAdvanceClient; private final IAdvanceDetailClient advanceDetailClient; private final IDetailProductClient detailProductClient; - private final IServiceNumClient serviceNumClient; + private final IServiceNumClient serviceNumClient; private final IWarehouseClient warehouseClient; private final IOuPaiFactoryService ouPaiFactoryService; @@ -177,7 +177,8 @@ public class FactoryXxlJob { resoveFactoryData(); return ReturnT.SUCCESS; } - private Timestamp initTimestamp(){ + + private Timestamp initTimestamp() { Calendar calendar = Calendar.getInstance(); return new Timestamp(calendar.get(Calendar.YEAR), @@ -185,8 +186,9 @@ public class FactoryXxlJob { calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.HOUR), calendar.get(Calendar.MINUTE), - calendar.get(Calendar.SECOND),calendar.get(Calendar.MILLISECOND)); + calendar.get(Calendar.SECOND), calendar.get(Calendar.MILLISECOND)); } + @Transactional(rollbackFor = Exception.class) public Boolean resoveFactoryData() { Map> map = new HashMap<>(); @@ -401,7 +403,7 @@ public class FactoryXxlJob { String tcWlb008 = stationOrderEntity.getTcWlb008();//Log中对应的客户单号 String tcWlb007 = stationOrderEntity.getTcWlb007();//Log中对应的系统单号 Integer tcWlb009 = stationOrderEntity.getTcWlb009();//Log中对应的包件数量 - if (otcWla001.equals(tcWla001)&&otcWla002.equals(tcWla002)&&otcWlb008.equals(tcWlb008)&&otcWlb007.equals(tcWlb007)&&otcWlb009.equals(tcWlb009)) { + if (otcWla001.equals(tcWla001) && otcWla002.equals(tcWla002) && otcWlb008.equals(tcWlb008) && otcWlb007.equals(tcWlb007) && otcWlb009.equals(tcWlb009)) { dataList.remove(i); break; } @@ -418,69 +420,99 @@ public class FactoryXxlJob { /** * 欧派工程数据回推 * 启动参数格式 - * [{"codes":[包条码...],"type":4},{"codes":[包条码...],"type":7}] + * "123,f12334,gt3545" */ - @XxlJob("factoryByOpOrderPackageCodeJobHandler") - public ReturnT factoryByOpOrderPackageCodeJobHandler(String param) throws Exception { - -// todo 需要拆分方法 + @XxlJob("factoryByOpOrderPackageCodeJobHandlerIn") + public ReturnT factoryByOpOrderPackageCodeJobHandlerIn(String param) throws Exception { + if (StringUtils.isBlank(param)) { + return ReturnT.FAIL; + } + String[] split = param.split(","); - // 获取执行参数的中参数 - JSONArray jsonArray; try { + for (String orderPackageCode : split) { - jsonArray = JSON.parseArray(param); + OrderStatusDTO orderStatusDTO = new OrderStatusDTO(); + orderStatusDTO.setUnitNo(orderPackageCode); + orderStatusDTO.setStatus("1"); - // 入库的数据请求 - JSONObject inArgs =null; - // 出库的数据请求 - JSONObject outArgs =null; + // 查询老系统的操作人 + orderStatusDTO.setUsername("zhangsna ");// 操作人 + ouPaiFactoryService.handleStatusData(orderStatusDTO); - for (int i = 0; i < jsonArray.size(); i++) { - JSONObject t = jsonArray.getJSONObject(i); - if (t.get("type").equals(4)){ - inArgs= t; - } - if (t.get("type").equals(7)){ - outArgs= t; - } } + return ReturnT.SUCCESS; + } catch (Exception e) { + XxlJobLogger.log(e); + logger.error(">>>> 执行失败"); + return ReturnT.FAIL; - JSONArray codes = inArgs.getJSONArray("codes"); - extractedJsonArray(codes,"4"); - + } - }catch (Exception e){ + } + @XxlJob("factoryByOpOrderPackageCodeJobHandlerOut") + public ReturnT factoryByOpOrderPackageCodeJobHandlerOut(String param) throws Exception { + if (StringUtils.isBlank(param)) { return ReturnT.FAIL; } + String[] split = param.split(","); + + try { + for (String orderPackageCode : split) { + OrderStatusDTO orderStatusDTO = new OrderStatusDTO(); + orderStatusDTO.setUnitNo(orderPackageCode); + orderStatusDTO.setStatus("7"); + // 查询老系统的操作人 + orderStatusDTO.setUsername("zhangsna");// 操作人 + ouPaiFactoryService.handleStatusData(orderStatusDTO); + + } + return ReturnT.SUCCESS; + } catch (Exception e) { + XxlJobLogger.log(e); + logger.error(">>>> 执行失败"); + return ReturnT.FAIL; + + } - return ReturnT.SUCCESS; } - private void extractedJsonArray(JSONArray codes,String status) { - if(codes !=null&& !codes.isEmpty()){ - for (int i = 0; i < codes.size(); i++) { - // 得到包件码 - String o = (String) codes.get(i); - // 还需要查询老系统的数据 得到这个包件的操作人 - // 补充推送欧派的推送数据 - OrderStatusDTO orderStatusDTO = new OrderStatusDTO() ; - orderStatusDTO.setUnitNo(o); - orderStatusDTO.setStatus(status); - orderStatusDTO.setUsername();// 操作人 + @XxlJob("factory2OpReplayGetOrderInforByReceivCode") + public ReturnT factory2OpReplayGetOrderInforByReceivCode(String param) throws Exception { + + // todo 需要拆分方法 + if (StringUtils.isBlank(param)) { + return ReturnT.FAIL; + } + String[] split = param.split(","); + + + try { + for (String receivCode : split) { + + XxlJobLogger.log(">>>>> 收货单执行单号 开始 {}",receivCode); + ouPaiFactoryService.saveOuPaiFactoryOrderDTOByCarCarNumber(receivCode); + XxlJobLogger.log(">>>>> 收货单执行单号 结束 {}",receivCode); + - ouPaiFactoryService.handleStatusData(orderStatusDTO); } + return ReturnT.SUCCESS; + } catch (Exception e) { + XxlJobLogger.log(e); + return ReturnT.FAIL; + } } + + } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/feign/MtOrderMainClinet.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/feign/MtOrderMainClinet.java index 8bdd1cb29..7902372c9 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/feign/MtOrderMainClinet.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/feign/MtOrderMainClinet.java @@ -5,6 +5,7 @@ import com.logpm.factory.mt.dto.MtReceiveDTO; import com.logpm.factory.mt.service.IMtFactoryDataService; import com.logpm.factory.mt.service.IMtFactoryOrderMainService; import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springblade.core.tenant.annotation.NonDS; import org.springblade.core.tool.api.R; import org.springframework.web.bind.annotation.GetMapping; @@ -18,6 +19,7 @@ import java.security.NoSuchAlgorithmException; @ApiIgnore @RestController @AllArgsConstructor +@Slf4j public class MtOrderMainClinet implements IMtOrderMainClinet { private final IMtFactoryOrderMainService mtFactoryOrderMainService; @@ -27,6 +29,7 @@ public class MtOrderMainClinet implements IMtOrderMainClinet { @Override @GetMapping(TOP) public R sendOrderPackageScan(String orderPackageCode, String operationTime, String distributionContactId, String distributionContactCode, String destinationWarehouse) throws NoSuchAlgorithmException, JsonProcessingException { + log.info(">>>>>>> 签收扫描 start"); // return mtFactoryDataService.qianshouScanForNewSystem(orderPackageCode,operationTime,distributionContactId,destinationWarehouse); return null; } @@ -35,6 +38,7 @@ public class MtOrderMainClinet implements IMtOrderMainClinet { @Override @PostMapping(SENDRECEIVEINFOBYNEWSYSTEM) public R sendReceiveInfoByNewSystem(MtReceiveDTO mtReceiveDTO) throws NoSuchAlgorithmException, JsonProcessingException { + log.info(">>>>>>> 文员复核 start"); // return mtFactoryDataService.sendReceiveInfoByNewSystem(mtReceiveDTO); return null; } From 8cab5009d57d898b1ea2093823abc6776ae7dd27 Mon Sep 17 00:00:00 2001 From: "pref_mail@163.com" Date: Sun, 31 Dec 2023 08:42:56 +0800 Subject: [PATCH 3/4] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E6=AC=A7=E6=B4=BE?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=90=8C=E6=AD=A5=202.=E5=A2=9E=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/utils/FileLogsUtil.java | 29 +- .../factory/jobhandler/FactoryXxlJob.java | 51 +- .../oupai/mapper/FactoryOrderMapper.java | 6 + .../oupai/mapper/FactoryOrderMapper.xml | 10 + .../oupai/mapper/ReceivingOrderMapper.java | 3 + .../oupai/mapper/ReceivingOrderMapper.xml | 6 +- .../oupai/service/IOuPaiFactoryService.java | 4 +- .../service/impl/FactoryOrderServiceImpl.java | 1 + .../service/impl/OuPaiFactoryServiceImpl.java | 542 ++++++++++-------- 9 files changed, 410 insertions(+), 242 deletions(-) diff --git a/blade-biz-common/src/main/java/org/springblade/common/utils/FileLogsUtil.java b/blade-biz-common/src/main/java/org/springblade/common/utils/FileLogsUtil.java index c7453f07e..36511603c 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/utils/FileLogsUtil.java +++ b/blade-biz-common/src/main/java/org/springblade/common/utils/FileLogsUtil.java @@ -5,10 +5,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springblade.common.constant.CommonConstant; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.Writer; +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URL; import java.util.Calendar; import java.util.Date; @@ -65,6 +64,28 @@ public class FileLogsUtil { return imgPath + fileName; } + + public static String loadFileContent(String urlString) { + try { + log.info(">>>> 开始下载 {}",urlString); + URL url = new URL(urlString); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.setRequestMethod("GET"); + BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String inputLine; + StringBuilder content = new StringBuilder(); + while ((inputLine = in.readLine()) != null) { + content.append(inputLine); + } + in.close(); + log.info(">>>> 结束下载 {}",urlString); + return content.toString(); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + private static String makeDateString(Date date) { StringBuilder stringBuffer = new StringBuilder(); diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/jobhandler/FactoryXxlJob.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/jobhandler/FactoryXxlJob.java index b46716657..06c6bb0ab 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/jobhandler/FactoryXxlJob.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/jobhandler/FactoryXxlJob.java @@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.logpm.factory.comfac.dto.OrderStatusDTO; +import com.logpm.factory.oupai.mapper.FactoryOrderMapper; import com.logpm.factory.oupai.service.IOuPaiFactoryService; import com.logpm.factory.snm.dto.GroupByPackagesDTO; import com.logpm.factory.snm.entity.OrderLogEntity; @@ -71,6 +72,8 @@ public class FactoryXxlJob { private final IOuPaiFactoryService ouPaiFactoryService; + private final FactoryOrderMapper factoryOrderMapper; + /** * snm工厂数据任务调度 @@ -498,7 +501,7 @@ public class FactoryXxlJob { for (String receivCode : split) { XxlJobLogger.log(">>>>> 收货单执行单号 开始 {}",receivCode); - ouPaiFactoryService.saveOuPaiFactoryOrderDTOByCarCarNumber(receivCode); + ouPaiFactoryService.saveOuPaiFactoryOrderDTOByCarCarNumberAgain(receivCode); XxlJobLogger.log(">>>>> 收货单执行单号 结束 {}",receivCode); @@ -513,6 +516,52 @@ public class FactoryXxlJob { } + /** + * 修复欧派工厂订单数据重复 + * @param param + * @return + * @throws Exception + */ + @XxlJob("factory2OpReplayOrderDataRepeat") + public ReturnT factory2OpReplayOrderDataRepeat(String param) throws Exception { + + // todo 需要拆分方法 + if (StringUtils.isBlank(param)) { + return ReturnT.FAIL; + } + String[] split = param.split(","); + + + try { + + List> dataRepeat = factoryOrderMapper.findDataRepeat(); + + for (Map stringObjectMap : dataRepeat) { + + Long receiving_id = (Long)stringObjectMap.get("receiving_id"); + String self_code = (String)stringObjectMap.get("self_code"); + + /** + * select id from op_factory_order where is_deleted = 0 and (self_code = 'OPLCZ绵阳市231200002CA1-1' and receiving_id = 1736591024500776962) ORDER BY create_time + */ + + List orderInforIdBySelfCodeAndReceivingid = factoryOrderMapper.findOrderInforIdBySelfCodeAndReceivingid(self_code, receiving_id); + + + + + + } + + + } catch (Exception e) { + XxlJobLogger.log(e); + + + } + return ReturnT.FAIL; + } + } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/FactoryOrderMapper.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/FactoryOrderMapper.java index 4a6ce58e6..e698c14be 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/FactoryOrderMapper.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/FactoryOrderMapper.java @@ -23,6 +23,7 @@ import com.logpm.factory.oupai.vo.FactoryOrderVO; import org.apache.ibatis.annotations.Param; import java.util.List; +import java.util.Map; /** * 欧派工厂订单 Mapper 接口 @@ -43,4 +44,9 @@ public interface FactoryOrderMapper extends BaseMapper { FactoryOrderEntity selectEntityByOrderPackageCode(@Param("unitNo") String unitNo); + + List> findDataRepeat(); + + + List findOrderInforIdBySelfCodeAndReceivingid(@Param("selfCode") String selfCode,@Param("receivingId") Long receivingId); } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/FactoryOrderMapper.xml b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/FactoryOrderMapper.xml index f6537489c..694c50f77 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/FactoryOrderMapper.xml +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/FactoryOrderMapper.xml @@ -21,5 +21,15 @@ ofp.CODE = #{unitNo} + + + + diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/ReceivingOrderMapper.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/ReceivingOrderMapper.java index 13dee3731..ce3342ad9 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/ReceivingOrderMapper.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/ReceivingOrderMapper.java @@ -44,6 +44,9 @@ public interface ReceivingOrderMapper extends BaseMapper { List selectReceivingOrderPage(IPage page, ReceivingOrderVO receivingOrder); + String selectReceivingOrderByOrderId (@Param("orderId") Long orderId); + + diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/ReceivingOrderMapper.xml b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/ReceivingOrderMapper.xml index 52faf74e7..8d4bf42d3 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/ReceivingOrderMapper.xml +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/ReceivingOrderMapper.xml @@ -11,7 +11,11 @@ select * from op_receiving_order where is_deleted = 0 - + diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/IOuPaiFactoryService.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/IOuPaiFactoryService.java index 5f0b50784..633a3ef44 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/IOuPaiFactoryService.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/IOuPaiFactoryService.java @@ -14,7 +14,9 @@ public interface IOuPaiFactoryService { String saveOuPaiFactoryOrderDTOByCarCarNumber(String carNumber); - String saveOuPaiPackageStatusByCode(String orderPackageCode,Integer event); + String saveOuPaiFactoryOrderDTOByCarCarNumberAgain(String code); + + String saveOuPaiPackageStatusByCode(String orderPackageCode, Integer event); Boolean checkReceivingOrder(String code); diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/FactoryOrderServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/FactoryOrderServiceImpl.java index cfafd5d1b..beed8b4bf 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/FactoryOrderServiceImpl.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/FactoryOrderServiceImpl.java @@ -45,6 +45,7 @@ public class FactoryOrderServiceImpl extends BaseServiceImpl>>> 欧派数据解析报错", e); + opOrderStatusLogEntity.setDataStatus(2); + + } + opOrderStatusLogService.saveOrUpdate(opOrderStatusLogEntity); + log.info("数据重新获取 end {}", code); + return code; + } + + private OpOrderStatusLogEntity findOurPaiDataByCarNumberByLoal(String code) { + + // 查询自己数据 判断这个收货单号是否存在 + + LambdaQueryWrapper 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) { // @@ -466,31 +511,32 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService { /** * 根据推送类型修改包件上的状态 + * * @param factoryPackageEntity */ - void checkOpFactoryPackagePushStatus(FactoryPackageEntity factoryPackageEntity){ + void checkOpFactoryPackagePushStatus(FactoryPackageEntity factoryPackageEntity) { // 查询推送记录 师傅包含 已收货 已出库 LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); lambdaQueryWrapper.eq(OpPackagePushLogEntity::getRefId, factoryPackageEntity.getId()); - lambdaQueryWrapper.eq(OpPackagePushLogEntity::getPushType,1);// 查询包件 + lambdaQueryWrapper.eq(OpPackagePushLogEntity::getPushType, 1);// 查询包件 List list = opPackagePushLogService.list(lambdaQueryWrapper); - if(list!=null&&!list.isEmpty()){ + if (list != null && !list.isEmpty()) { for (OpPackagePushLogEntity opPackagePushLogEntity : list) { - if("收货".equals(opPackagePushLogEntity.getPushOupaiNode())){ + if ("收货".equals(opPackagePushLogEntity.getPushOupaiNode())) { factoryPackageEntity.setPushStatus(3); } - if("发货".equals(opPackagePushLogEntity.getPushOupaiNode())){ + if ("发货".equals(opPackagePushLogEntity.getPushOupaiNode())) { factoryPackageEntity.setPushStatus(4); } } factoryPackageService.updateById(factoryPackageEntity); - }else{ - log.info("包件推送记录未null 包条码{}",factoryPackageEntity.getCode()); + } else { + log.info("包件推送记录未null 包条码{}", factoryPackageEntity.getCode()); } } @@ -623,7 +669,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); lambdaQueryWrapper.eq(OpPackagePushLogEntity::getRefId, refId); lambdaQueryWrapper.eq(OpPackagePushLogEntity::getPushOupaiNode, data.getString("Operate")); - lambdaQueryWrapper.eq(OpPackagePushLogEntity::getPushType,pushType);// 查询包件 + lambdaQueryWrapper.eq(OpPackagePushLogEntity::getPushType, pushType);// 查询包件 List list = opPackagePushLogService.list(lambdaQueryWrapper); if (ObjectUtils.isNull(list) || list.isEmpty()) { OpPackagePushLogEntity opPackagePushLogEntity = new OpPackagePushLogEntity(); @@ -699,7 +745,8 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService { lambdaQueryWrapper.eq(ReceivingOrderEntity::getCode, code); List receivingOrderEntities = receivingOrderMapper.selectList(lambdaQueryWrapper); if (ObjectUtils.isNotNull(receivingOrderEntities)) { - log.info(">>>>>>>>>>>>>>>>>>>>>>> 收货单已存在 {} ", code); + log.info(">>>>>>>>>>>>>>>>>>>>>>> 收货单已存在 收货单下面的订单是否存在 包件是否存在{} ", code); + extractedOuPaiOrderPackageInfor(valueObject, receivingOrderEntities.get(0).getId(), code); return; } @@ -759,246 +806,270 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService { if (row == 1) { log.info("############handleData: 保存发货单数据 成功成功成功成功 code={}", code); Long receivingId = receivingOrderEntity.getId();//发货单id - JSONArray packages = valueObject.getJSONArray("Packages"); - for (int j = 0; j < packages.size(); j++) { - JSONObject packageEntity = packages.getJSONObject(j);//包件信息 - JSONObject orderEntity = packageEntity.getJSONObject("Order");//订单信息 - if (orderEntity == null) { - log.info("包件数据没有订单信息 packageCode {}", packageEntity.getString("Code")); - continue; - } - String selfCode = orderEntity.getString("SelfCode");//订单自编码 - //先查询是否存在订单自编码 -// - FactoryOrderEntity factoryOrderEntity = factoryOrderService.selectEntityBySelfCode(selfCode, receivingId); - if(Objects.isNull(factoryOrderEntity)){ - factoryOrderEntity = new FactoryOrderEntity(); - factoryOrderEntity.setCode(orderEntity.getString("Code")); - factoryOrderEntity.setSelfCode(selfCode); - factoryOrderEntity.setContractNumber(orderEntity.getString("ContractNumber")); - factoryOrderEntity.setServiceNumber(orderEntity.getString("ServiceNumber")); - factoryOrderEntity.setOrderClass(orderEntity.getString("OrderClass")); - factoryOrderEntity.setOrderType(orderEntity.getString("OrderType")); - String factoryStatus = orderEntity.getString("Status"); - if ("待送货".equals(factoryStatus)) { - factoryOrderEntity.setFactoryStatus(0); - } else if ("已签收".equals(factoryStatus)) { - factoryOrderEntity.setFactoryStatus(2); - } else if ("已取消".equals(factoryStatus)) { - factoryOrderEntity.setFactoryStatus(3); - } else if ("部分签收".equals(factoryStatus)) { - factoryOrderEntity.setFactoryStatus(6); - } + 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); + } - String factoryShipStatus = orderEntity.getString("FactoryShipStatus"); - if ("工厂未发货".equals(factoryShipStatus)) { - factoryOrderEntity.setFactoryShipStatus(0); - } else if ("工厂部分发货".equals(factoryShipStatus)) { - factoryOrderEntity.setFactoryShipStatus(1); - } else if ("工厂齐套发货".equals(factoryShipStatus)) { - factoryOrderEntity.setFactoryShipStatus(2); - } - factoryOrderEntity.setFactorySendQty(orderEntity.getInteger("FactorySendQty")); - - String warehouseReceiveStatus = orderEntity.getString("WarehouseReceiveStatus"); - if ("仓库未收货".equals(warehouseReceiveStatus)) { - factoryOrderEntity.setWarehouseReceiveStatus(0); - } else if ("仓库部分收货".equals(warehouseReceiveStatus)) { - factoryOrderEntity.setWarehouseReceiveStatus(1); - } else if ("仓库全部收货".equals(warehouseReceiveStatus)) { - factoryOrderEntity.setWarehouseReceiveStatus(2); - } - factoryOrderEntity.setWarehouseReceiveQty(orderEntity.getInteger("WarehouseReceiveQty")); + } - String reservationStatus = orderEntity.getString("ReservationStatus"); - if ("不可预约".equals(reservationStatus)) { - factoryOrderEntity.setReservationStatus(0); - } else if ("可预约".equals(reservationStatus)) { - factoryOrderEntity.setReservationStatus(1); - } + /** + * 欧派入库方法 + * + * @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")); + continue; + } + String selfCode = orderEntity.getString("SelfCode");//订单自编码 + //先查询是否存在订单自编码 +// + 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); + factoryOrderEntity.setContractNumber(orderEntity.getString("ContractNumber")); + factoryOrderEntity.setServiceNumber(orderEntity.getString("ServiceNumber")); + factoryOrderEntity.setOrderClass(orderEntity.getString("OrderClass")); + factoryOrderEntity.setOrderType(orderEntity.getString("OrderType")); + String factoryStatus = orderEntity.getString("Status"); + if ("待送货".equals(factoryStatus)) { + factoryOrderEntity.setFactoryStatus(0); + } else if ("已签收".equals(factoryStatus)) { + factoryOrderEntity.setFactoryStatus(2); + } else if ("已取消".equals(factoryStatus)) { + factoryOrderEntity.setFactoryStatus(3); + } else if ("部分签收".equals(factoryStatus)) { + factoryOrderEntity.setFactoryStatus(6); + } - JSONObject store = orderEntity.getJSONObject("Store"); - if (!Objects.isNull(store)) { - factoryOrderEntity.setStoreCode(store.getString("Code")); - factoryOrderEntity.setStoreName(store.getString("Name")); - JSONObject shop = store.getJSONObject("Shop"); - if (!Objects.isNull(shop)) { - factoryOrderEntity.setShopCode(shop.getString("Code")); - factoryOrderEntity.setShopName(shop.getString("Name")); - factoryOrderEntity.setBusinessModel(shop.getString("BusinessModel")); - } + String factoryShipStatus = orderEntity.getString("FactoryShipStatus"); + if ("工厂未发货".equals(factoryShipStatus)) { + factoryOrderEntity.setFactoryShipStatus(0); + } else if ("工厂部分发货".equals(factoryShipStatus)) { + factoryOrderEntity.setFactoryShipStatus(1); + } else if ("工厂齐套发货".equals(factoryShipStatus)) { + factoryOrderEntity.setFactoryShipStatus(2); + } + factoryOrderEntity.setFactorySendQty(orderEntity.getInteger("FactorySendQty")); + + String warehouseReceiveStatus = orderEntity.getString("WarehouseReceiveStatus"); + if ("仓库未收货".equals(warehouseReceiveStatus)) { + factoryOrderEntity.setWarehouseReceiveStatus(0); + } else if ("仓库部分收货".equals(warehouseReceiveStatus)) { + factoryOrderEntity.setWarehouseReceiveStatus(1); + } else if ("仓库全部收货".equals(warehouseReceiveStatus)) { + factoryOrderEntity.setWarehouseReceiveStatus(2); + } + factoryOrderEntity.setWarehouseReceiveQty(orderEntity.getInteger("WarehouseReceiveQty")); - } + String reservationStatus = orderEntity.getString("ReservationStatus"); + if ("不可预约".equals(reservationStatus)) { + factoryOrderEntity.setReservationStatus(0); + } else if ("可预约".equals(reservationStatus)) { + factoryOrderEntity.setReservationStatus(1); + } - factoryOrderEntity.setMatingCode(orderEntity.getString("MatingCode")); - Boolean isMating = orderEntity.getBoolean("IsMating"); - if (isMating) { - factoryOrderEntity.setIsMating(1); - } else { - factoryOrderEntity.setIsMating(0); - } - factoryOrderEntity.setFirstClassCode(orderEntity.getString("FirstClassCode")); - Boolean leave = orderEntity.getBoolean("Leave"); - if (leave) { - factoryOrderEntity.setLeaveStatus(1); - } else { - factoryOrderEntity.setLeaveStatus(0); - } - factoryOrderEntity.setCustomer(orderEntity.getString("Customer")); - factoryOrderEntity.setProvince(orderEntity.getString("Province")); - factoryOrderEntity.setCity(orderEntity.getString("City")); - factoryOrderEntity.setCustomerAddress(orderEntity.getString("CustomerAddress")); - factoryOrderEntity.setCustomerPhone(orderEntity.getString("CustomerPhone")); - factoryOrderEntity.setShopReceiver(orderEntity.getString("ShopReceiver")); - factoryOrderEntity.setBrandCode(orderEntity.getString("BrandCode")); - factoryOrderEntity.setBrandName(orderEntity.getString("BrandName")); - factoryOrderEntity.setFirstShipTime(CommonUtil.StringToDateByT(orderEntity.getString("FirstShipTime"))); - factoryOrderEntity.setMatingShipTime(CommonUtil.StringToDateByT(orderEntity.getString("MatingShipTime"))); - factoryOrderEntity.setFirstReceiveTime(CommonUtil.StringToDateByT(orderEntity.getString("FirstReceiveTime"))); - factoryOrderEntity.setMatingReceiveTime(CommonUtil.StringToDateByT(orderEntity.getString("MatingReceiveTime"))); - Boolean freeze = orderEntity.getBoolean("Freeze"); - if (freeze) { - factoryOrderEntity.setFreeze(1); - } else { - factoryOrderEntity.setFreeze(0); - } - factoryOrderEntity.setOutGoingTime(CommonUtil.StringToDateByT(orderEntity.getString("OutGoingTime"))); - factoryOrderEntity.setStatus(0); - factoryOrderEntity.setReceivingId(receivingId); - factoryOrderEntity.setReceiptStatus(0); - factoryOrderEntity.setPushStatus(0); - factoryOrderEntity.setTurnStatus(0); - // - boolean save = factoryOrderService.save(factoryOrderEntity); - if (!save) { - log.error("############handleData: 保存订单失败 selfCode={}", selfCode); - throw new CustomerException(403, "保存订单失败"); - } + JSONObject store = orderEntity.getJSONObject("Store"); + if (!Objects.isNull(store)) { + factoryOrderEntity.setStoreCode(store.getString("Code")); + factoryOrderEntity.setStoreName(store.getString("Name")); + JSONObject shop = store.getJSONObject("Shop"); + if (!Objects.isNull(shop)) { + factoryOrderEntity.setShopCode(shop.getString("Code")); + factoryOrderEntity.setShopName(shop.getString("Name")); + factoryOrderEntity.setBusinessModel(shop.getString("BusinessModel")); } - //保存订单成功,继续保存包件 - Long orderId = factoryOrderEntity.getId(); - String packageCode = packageEntity.getString("Code"); - LambdaQueryWrapper packageEntityQueryWrapper = new LambdaQueryWrapper<>(); - packageEntityQueryWrapper.eq(FactoryPackageEntity::getCode, packageCode); - - FactoryPackageEntity factoryPackageEntity = factoryPackageService.getOne(packageEntityQueryWrapper); - - if (Objects.isNull(factoryPackageEntity)) { - factoryPackageEntity = new FactoryPackageEntity(); - factoryPackageEntity.setOrderId(orderId); - factoryPackageEntity.setCode(packageCode); - factoryPackageEntity.setOid(packageEntity.getString("Oid")); - factoryPackageEntity.setFirstClassCode(packageEntity.getString("FirstClassCode")); - factoryPackageEntity.setFirstClassName(packageEntity.getString("FirstClassName")); - factoryPackageEntity.setSecondClassCode(packageEntity.getString("SecondClassCode")); - factoryPackageEntity.setSecondClassName(packageEntity.getString("SecondClassName")); - factoryPackageEntity.setThirdClassCode(packageEntity.getString("ThirdClassCode")); - factoryPackageEntity.setThirdClassName(packageEntity.getString("ThirdClassName")); - factoryPackageEntity.setPackageDetailNames(packageEntity.getString("PackageDetailNames")); - factoryPackageEntity.setCarNumber(packageEntity.getString("CarNumber")); - factoryPackageEntity.setReserve1(factoryOrderEntity.getCode()); - Boolean buyIn = packageEntity.getBoolean("BuyIn"); - if (buyIn) { - factoryPackageEntity.setBuyin(1); - } else { - factoryPackageEntity.setBuyin(0); - } - factoryPackageEntity.setCosourcingCode(packageEntity.getString("CosourcingCode")); - factoryPackageEntity.setCosourcingUnit(packageEntity.getString("CosourcingUnit")); - String packageStatus = packageEntity.getString("PackageStatus"); - //未知:0 已调度:1 已装车:2 待收货:3 已收货:4 已在库:5 待理货:6 待上架:7 已上架:8 已下架:9 已发运:10 已签收:11 待返货:12 已提件:13 已拒收:14 异常:-1 - if ("已调度".equals(packageStatus)) { - factoryPackageEntity.setPackageStatus(1); - } else if ("已装车".equals(packageStatus)) { - factoryPackageEntity.setPackageStatus(2); - } else if ("待收货".equals(packageStatus)) { - factoryPackageEntity.setPackageStatus(3); - } else if ("已收货".equals(packageStatus)) { - factoryPackageEntity.setPackageStatus(4); - } else if ("已在库".equals(packageStatus)) { - factoryPackageEntity.setPackageStatus(5); - } else if ("待理货".equals(packageStatus)) { - factoryPackageEntity.setPackageStatus(6); - } else if ("待上架".equals(packageStatus)) { - factoryPackageEntity.setPackageStatus(7); - } else if ("已上架".equals(packageStatus)) { - factoryPackageEntity.setPackageStatus(8); - } else if ("已下架".equals(packageStatus)) { - factoryPackageEntity.setPackageStatus(9); - } else if ("已发运".equals(packageStatus)) { - factoryPackageEntity.setPackageStatus(10); - } else if ("已签收".equals(packageStatus)) { - factoryPackageEntity.setPackageStatus(11); - } else if ("待返货".equals(packageStatus)) { - factoryPackageEntity.setPackageStatus(12); - } else if ("已提件".equals(packageStatus)) { - factoryPackageEntity.setPackageStatus(13); - } else if ("已拒收".equals(packageStatus)) { - factoryPackageEntity.setPackageStatus(14); - } else if ("异常".equals(packageStatus)) { - factoryPackageEntity.setPackageStatus(-1); - } else { - factoryPackageEntity.setPackageStatus(0); - } - factoryPackageEntity.setLength(packageEntity.getBigDecimal("Length")); - factoryPackageEntity.setWidth(packageEntity.getBigDecimal("Width")); - factoryPackageEntity.setHeight(packageEntity.getBigDecimal("Height")); - factoryPackageEntity.setWeight(packageEntity.getBigDecimal("Weight")); - Boolean isInventory = packageEntity.getBoolean("IsInventory"); - if (isInventory) { - factoryPackageEntity.setIsInventory(1); - } else { - factoryPackageEntity.setIsInventory(0); - } - Boolean packageFreeze = packageEntity.getBoolean("Freeze"); - if (packageFreeze) { - factoryPackageEntity.setFreeze(1); - } else { - factoryPackageEntity.setFreeze(0); - } + } - //保存包件信息 - factoryPackageEntity.setReceiptStatus(0); - factoryPackageEntity.setPushStatus(0); - factoryPackageEntity.setTurnStatus(0); - boolean packageSave = factoryPackageService.save(factoryPackageEntity); - if (packageSave) { - Long packageId = factoryPackageEntity.getId(); - //保存物料信息 - JSONArray packageDetails = packageEntity.getJSONArray("PackageDetails"); - if (!Objects.isNull(packageDetails)) { - for (int k = 0; k < packageDetails.size(); k++) { - JSONObject packageDetailsJSONObject = packageDetails.getJSONObject(k); - FactoryPackageDetailEntity factoryPackageDetailEntity = new FactoryPackageDetailEntity(); - factoryPackageDetailEntity.setPackageId(packageId); - factoryPackageDetailEntity.setCode(packageDetailsJSONObject.getString("Code")); - factoryPackageDetailEntity.setName(packageDetailsJSONObject.getString("Name")); - factoryPackageDetailEntity.setType(packageDetailsJSONObject.getString("Type")); - factoryPackageDetailEntity.setUnit(packageDetailsJSONObject.getString("Unit")); - factoryPackageDetailEntity.setOrgCode(packageDetailsJSONObject.getString("OrgCode")); - factoryPackageDetailService.save(factoryPackageDetailEntity); - } - } - } - } else { + factoryOrderEntity.setMatingCode(orderEntity.getString("MatingCode")); + Boolean isMating = orderEntity.getBoolean("IsMating"); + if (isMating) { + factoryOrderEntity.setIsMating(1); + } else { + factoryOrderEntity.setIsMating(0); + } + factoryOrderEntity.setFirstClassCode(orderEntity.getString("FirstClassCode")); + Boolean leave = orderEntity.getBoolean("Leave"); + if (leave) { + factoryOrderEntity.setLeaveStatus(1); + } else { + factoryOrderEntity.setLeaveStatus(0); + } + factoryOrderEntity.setCustomer(orderEntity.getString("Customer")); + factoryOrderEntity.setProvince(orderEntity.getString("Province")); + factoryOrderEntity.setCity(orderEntity.getString("City")); + factoryOrderEntity.setCustomerAddress(orderEntity.getString("CustomerAddress")); + factoryOrderEntity.setCustomerPhone(orderEntity.getString("CustomerPhone")); + factoryOrderEntity.setShopReceiver(orderEntity.getString("ShopReceiver")); + factoryOrderEntity.setBrandCode(orderEntity.getString("BrandCode")); + factoryOrderEntity.setBrandName(orderEntity.getString("BrandName")); + factoryOrderEntity.setFirstShipTime(CommonUtil.StringToDateByT(orderEntity.getString("FirstShipTime"))); + factoryOrderEntity.setMatingShipTime(CommonUtil.StringToDateByT(orderEntity.getString("MatingShipTime"))); + factoryOrderEntity.setFirstReceiveTime(CommonUtil.StringToDateByT(orderEntity.getString("FirstReceiveTime"))); + factoryOrderEntity.setMatingReceiveTime(CommonUtil.StringToDateByT(orderEntity.getString("MatingReceiveTime"))); + Boolean freeze = orderEntity.getBoolean("Freeze"); + if (freeze) { + factoryOrderEntity.setFreeze(1); + } else { + factoryOrderEntity.setFreeze(0); + } + factoryOrderEntity.setOutGoingTime(CommonUtil.StringToDateByT(orderEntity.getString("OutGoingTime"))); + factoryOrderEntity.setStatus(0); + factoryOrderEntity.setReceivingId(receivingId); + factoryOrderEntity.setReceiptStatus(0); + factoryOrderEntity.setPushStatus(0); + factoryOrderEntity.setTurnStatus(0); + // + boolean save = factoryOrderService.save(factoryOrderEntity); + if (!save) { + log.error("############handleData: 保存订单失败 selfCode={}", selfCode); + throw new CustomerException(403, "保存订单失败"); + } + } - log.error("############handleData: 包件码已存在 packageCode={} 收货单号 {}", packageCode,code); + //保存订单成功,继续保存包件 + Long orderId = factoryOrderEntity.getId(); + String packageCode = packageEntity.getString("Code"); + LambdaQueryWrapper packageEntityQueryWrapper = new LambdaQueryWrapper<>(); + packageEntityQueryWrapper.eq(FactoryPackageEntity::getCode, packageCode); + + 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); + factoryPackageEntity.setOid(packageEntity.getString("Oid")); + factoryPackageEntity.setFirstClassCode(packageEntity.getString("FirstClassCode")); + factoryPackageEntity.setFirstClassName(packageEntity.getString("FirstClassName")); + factoryPackageEntity.setSecondClassCode(packageEntity.getString("SecondClassCode")); + factoryPackageEntity.setSecondClassName(packageEntity.getString("SecondClassName")); + factoryPackageEntity.setThirdClassCode(packageEntity.getString("ThirdClassCode")); + factoryPackageEntity.setThirdClassName(packageEntity.getString("ThirdClassName")); + factoryPackageEntity.setPackageDetailNames(packageEntity.getString("PackageDetailNames")); + factoryPackageEntity.setCarNumber(packageEntity.getString("CarNumber")); + factoryPackageEntity.setReserve1(factoryOrderEntity.getCode()); + Boolean buyIn = packageEntity.getBoolean("BuyIn"); + if (buyIn) { + factoryPackageEntity.setBuyin(1); + } else { + factoryPackageEntity.setBuyin(0); + } + factoryPackageEntity.setCosourcingCode(packageEntity.getString("CosourcingCode")); + factoryPackageEntity.setCosourcingUnit(packageEntity.getString("CosourcingUnit")); + String packageStatus = packageEntity.getString("PackageStatus"); + //未知:0 已调度:1 已装车:2 待收货:3 已收货:4 已在库:5 待理货:6 待上架:7 已上架:8 已下架:9 已发运:10 已签收:11 待返货:12 已提件:13 已拒收:14 异常:-1 + if ("已调度".equals(packageStatus)) { + factoryPackageEntity.setPackageStatus(1); + } else if ("已装车".equals(packageStatus)) { + factoryPackageEntity.setPackageStatus(2); + } else if ("待收货".equals(packageStatus)) { + factoryPackageEntity.setPackageStatus(3); + } else if ("已收货".equals(packageStatus)) { + factoryPackageEntity.setPackageStatus(4); + } else if ("已在库".equals(packageStatus)) { + factoryPackageEntity.setPackageStatus(5); + } else if ("待理货".equals(packageStatus)) { + factoryPackageEntity.setPackageStatus(6); + } else if ("待上架".equals(packageStatus)) { + factoryPackageEntity.setPackageStatus(7); + } else if ("已上架".equals(packageStatus)) { + factoryPackageEntity.setPackageStatus(8); + } else if ("已下架".equals(packageStatus)) { + factoryPackageEntity.setPackageStatus(9); + } else if ("已发运".equals(packageStatus)) { + factoryPackageEntity.setPackageStatus(10); + } else if ("已签收".equals(packageStatus)) { + factoryPackageEntity.setPackageStatus(11); + } else if ("待返货".equals(packageStatus)) { + factoryPackageEntity.setPackageStatus(12); + } else if ("已提件".equals(packageStatus)) { + factoryPackageEntity.setPackageStatus(13); + } else if ("已拒收".equals(packageStatus)) { + factoryPackageEntity.setPackageStatus(14); + } else if ("异常".equals(packageStatus)) { + factoryPackageEntity.setPackageStatus(-1); + } else { + factoryPackageEntity.setPackageStatus(0); + } + factoryPackageEntity.setLength(packageEntity.getBigDecimal("Length")); + factoryPackageEntity.setWidth(packageEntity.getBigDecimal("Width")); + factoryPackageEntity.setHeight(packageEntity.getBigDecimal("Height")); + factoryPackageEntity.setWeight(packageEntity.getBigDecimal("Weight")); + Boolean isInventory = packageEntity.getBoolean("IsInventory"); + if (isInventory) { + factoryPackageEntity.setIsInventory(1); + } else { + factoryPackageEntity.setIsInventory(0); + } + Boolean packageFreeze = packageEntity.getBoolean("Freeze"); + if (packageFreeze) { + factoryPackageEntity.setFreeze(1); + } else { + factoryPackageEntity.setFreeze(0); + } - //throw new CustomerException(403, "包件码已存在"); + //保存包件信息 + factoryPackageEntity.setReceiptStatus(0); + factoryPackageEntity.setPushStatus(0); + factoryPackageEntity.setTurnStatus(0); + boolean packageSave = factoryPackageService.save(factoryPackageEntity); + if (packageSave) { + Long packageId = factoryPackageEntity.getId(); + //保存物料信息 + JSONArray packageDetails = packageEntity.getJSONArray("PackageDetails"); + if (!Objects.isNull(packageDetails)) { + for (int k = 0; k < packageDetails.size(); k++) { + JSONObject packageDetailsJSONObject = packageDetails.getJSONObject(k); + FactoryPackageDetailEntity factoryPackageDetailEntity = new FactoryPackageDetailEntity(); + factoryPackageDetailEntity.setPackageId(packageId); + factoryPackageDetailEntity.setCode(packageDetailsJSONObject.getString("Code")); + factoryPackageDetailEntity.setName(packageDetailsJSONObject.getString("Name")); + factoryPackageDetailEntity.setType(packageDetailsJSONObject.getString("Type")); + factoryPackageDetailEntity.setUnit(packageDetailsJSONObject.getString("Unit")); + factoryPackageDetailEntity.setOrgCode(packageDetailsJSONObject.getString("OrgCode")); + factoryPackageDetailService.save(factoryPackageDetailEntity); + } } } } else { - log.error("############handleData: 保存发货单数据失败 code={}", code); - throw new CustomerException(403, "保存发货单数据失败"); + + String receiveCode = receivingOrderMapper.selectReceivingOrderByOrderId(factoryPackageEntity.getOrderId()); + + if(receiveCode.equals(code)){ + log.error("############handleData: 包件码已存在 packageCode={} ,订单 id {} 收货单号 {}", packageCode, factoryPackageEntity.getOrderId(), code); + + }else{ + log.error("############handleData: 该包件存在于其它收货单 packageCode={} 订单ID {} 收货单号 {}", packageCode,factoryPackageEntity.getOrderId(), receiveCode); + } + + //throw new CustomerException(403, "包件码已存在"); } - Date end = new Date(); - long startLong = start.getTime(); - long endLong = end.getTime(); - long l = endLong - startLong; - log.info("############handleData: 数据处理完成 耗时 {} 毫秒", l); } - } @@ -1010,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;" + From ea560a4d08087f25baf7223b8199dbd5ae5715e4 Mon Sep 17 00:00:00 2001 From: "pref_mail@163.com" Date: Tue, 2 Jan 2024 09:38:09 +0800 Subject: [PATCH 4/4] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E5=9C=A8=E5=BA=93?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../distribution/mapper/DistributionStockArticleMapper.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml index 0c6886280..9169113bb 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml @@ -678,6 +678,13 @@ and ldsa.consignee_unit like concat('%',#{par.consigneeUnit},'%') + + + and ldsa.total_number = #{par.totalNumber} + + + and ldsa.customer_address like concat('%',#{par.customerAddress},'%') +