From 6ba21a3dd546603c0994064359cd268402bb9052 Mon Sep 17 00:00:00 2001 From: "pref_mail@163.com" <123456> Date: Wed, 26 Jul 2023 17:55:01 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E6=A2=A6=E5=A4=A9=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=8E=A8=E9=80=81=E4=BB=93=E5=BA=93Id=20=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/AsyncDataServiceImpl.java | 2 +- .../impl/MtFactoryDataServiceImpl.java | 137 ++++++++++++++---- .../factory/receiver/DealWithDataHandler.java | 6 +- .../factory/receiver/OrderStatusHandler.java | 6 + .../factory/receiver/ReceiveInfoHandler.java | 7 +- .../factory/receiver/UnloadCarComHandler.java | 3 - 6 files changed, 127 insertions(+), 34 deletions(-) diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/AsyncDataServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/AsyncDataServiceImpl.java index fccd920c2..8b42808ca 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/AsyncDataServiceImpl.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/AsyncDataServiceImpl.java @@ -311,7 +311,7 @@ public class AsyncDataServiceImpl implements IAsyncDataService { advanceEntity.setDeleteTime(0); // 删除时间 advanceEntity.setWaybillNo("");//运单号 可以为空 // Integer id = PanFactoryEnum.getId(panFactoryOrder.getPlantId()); - advanceEntity.setWarehouseId(0); //导入人仓库id TODO 需要提供映射 + advanceEntity.setWarehouseId(141); //导入人仓库id TODO 需要提供映射 advanceEntity.setWaybillStatus(Byte.parseByte("1"));//开单状态:1=未开单,2=已开单 advanceEntity.setOldId(0);// advanceEntity.setFreeze(Byte.parseByte("1"));//冻结状态:1=正常,2=冻结 diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/service/impl/MtFactoryDataServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/service/impl/MtFactoryDataServiceImpl.java index 05a189055..9c9399852 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/service/impl/MtFactoryDataServiceImpl.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/service/impl/MtFactoryDataServiceImpl.java @@ -6,16 +6,15 @@ import com.alibaba.fastjson.JSONObject; import com.alibaba.nacos.common.utils.MD5Utils; import com.alibaba.nacos.shaded.com.google.gson.Gson; import com.alibaba.nacos.shaded.com.google.gson.GsonBuilder; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.json.JsonMapper; import com.logpm.factory.comfac.dto.*; import com.logpm.factory.mt.dto.*; -import com.logpm.factory.mt.entity.MtFactoryOrder; -import com.logpm.factory.mt.entity.MtFactoryOrderMain; -import com.logpm.factory.mt.entity.MtOrderLogEntity; -import com.logpm.factory.mt.entity.MtPackageInfo; +import com.logpm.factory.mt.entity.*; import com.logpm.factory.mt.service.*; import com.logpm.factory.props.MtFactoryProperties; import com.logpm.factory.snm.bean.Resp; @@ -32,7 +31,9 @@ import org.slf4j.LoggerFactory; import org.springblade.common.exception.CustomerException; import org.springblade.core.redis.cache.BladeRedis; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.api.ResultCode; import org.springblade.core.tool.utils.StringUtil; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -62,6 +63,9 @@ public class MtFactoryDataServiceImpl implements IMtFactoryDataService { private final IMtOrderLogService mtOrderLogService; + private final IMtPushDataService mtPushDataService; + + @Transactional @Override public R dealWithData(MtFactoryDataDTO mtFactoryDataDTO) { @@ -293,29 +297,42 @@ public class MtFactoryDataServiceImpl implements IMtFactoryDataService { return Resp.fail(400,"当前数据的状态不推送"); } - if ("4".equals(status)){ - //继续判断是否到达目的仓 - String currentWarehouseId = orderStatusDTO.getCurrentWarehouse();//当前仓Id - //查询destinationWarehouse logiBillNo plantId数据 - logger.info("#############tag{}",1); - - Map supplyData = advanceDetailClient.getSupplyData(orderStatusDTO.getUnitNo()); - logger.info("#############tag{}",2); - String destinationWarehouseId = supplyData.get("destinationWarehouseId");//目的仓id - logger.info("#############tag{}",3); - if(StringUtil.isBlank(currentWarehouseId)||StringUtil.isBlank(destinationWarehouseId)){ - logger.info("#############tag{}",4); - log.warn("##############dealWithDataHandler: 仓库数据有问题currentWarehouseId={} destinationWarehouseId={}",currentWarehouseId,destinationWarehouseId); - throw new CustomerException(400,"仓库数据有误"); - }else{ - logger.info("#############tag{}",5); - if(!currentWarehouseId.equals(destinationWarehouseId)){ - logger.info("#############tag{}",6); - log.info("##############dealWithDataHandler: 不用处理的状态 currentWarehouseId={} destinationWarehouseId={}",currentWarehouseId,destinationWarehouseId); - throw new CustomerException(400,"仓库数据有误"); - } - } - } + + + logger.info("##################orderStatusHandler: 异常tag={}",0); + + + +// if("4".equals(status)){ +// +// // 需要推送数据 +// logger.info("#############handleStatusData: 推送 status={}",status); +// +// } + +// if ("4".equals(status)){ +// //继续判断是否到达目的仓 +// String currentWarehouseId = orderStatusDTO.getCurrentWarehouse();//当前仓Id +// //查询destinationWarehouse logiBillNo plantId数据 +// logger.info("#############tag{}",1); +// +// Map supplyData = advanceDetailClient.getSupplyData(orderStatusDTO.getUnitNo()); +// logger.info("#############tag{}",2); +// String destinationWarehouseId = supplyData.get("destinationWarehouseId");//目的仓id +// logger.info("#############tag{}",3); +// if(StringUtil.isBlank(currentWarehouseId)||StringUtil.isBlank(destinationWarehouseId)){ +// logger.info("#############tag{}",4); +// log.warn("##############dealWithDataHandler: 仓库数据有问题currentWarehouseId={} destinationWarehouseId={}",currentWarehouseId,destinationWarehouseId); +// throw new CustomerException(400,"仓库数据有误"); +// }else{ +// logger.info("#############tag{}",5); +// if(!currentWarehouseId.equals(destinationWarehouseId)){ +// logger.info("#############tag{}",6); +// log.info("##############dealWithDataHandler: 不用处理的状态 currentWarehouseId={} destinationWarehouseId={}",currentWarehouseId,destinationWarehouseId); +// throw new CustomerException(400,"仓库数据有误"); +// } +// } +// } //通过包件码查询是否是要推送的订单 String unitNo = orderStatusDTO.getUnitNo();//包件码 @@ -341,6 +358,30 @@ public class MtFactoryDataServiceImpl implements IMtFactoryDataService { return Resp.fail(400,"未找到对应订单"); } + + // 验证该数据是否推送过 + logger.info("##################orderStatusHandler: 异常tag={}",1); + LambdaQueryWrapper lambdaQueryChainWrapper = new LambdaQueryWrapper(MtPushData.class); + lambdaQueryChainWrapper.select(MtPushData::getId); + lambdaQueryChainWrapper.eq(MtPushData::getPushStatus,1); + lambdaQueryChainWrapper.eq(MtPushData::getRefCode,unitNo); + lambdaQueryChainWrapper.eq(MtPushData::getRefParentCode,orderNo); + lambdaQueryChainWrapper.eq(MtPushData::getRefType,2); + logger.info("##################orderStatusHandler: 异常tag={}",2); + + List tempIds =mtPushDataService.getBaseMapper().selectList(lambdaQueryChainWrapper); + logger.info("##################orderStatusHandler: 异常tag={}",3); + + logger.info("##################orderStatusHandler: tempIds={}",tempIds); + + if(tempIds!=null&& tempIds.size()>0){ + // 标识存在 该项数据已被推送 + return Resp.fail(400,"数据已被推送 ,无需再次重复"); + } + + + + //拼接参数 MtOrderStatusDTO mtOrderStatusDTO = new MtOrderStatusDTO(); mtOrderStatusDTO.setInvoiceOrderCode(mtFactoryOrderMain.getInvoiceOrderCode()); @@ -354,7 +395,23 @@ public class MtFactoryDataServiceImpl implements IMtFactoryDataService { String s = objectMapper.writeValueAsString(mtOrderStatusDTO); - return sendMtFactoryData(mtFactoryProperties.getUrl()+"/ZXCFaHuoDan/ShouHuoRuKu",s,1); + R rd = sendMtFactoryData(mtFactoryProperties.getUrl() + "/ZXCFaHuoDan/ShouHuoRuKu", s, 1); + + if(rd.getCode()==ResultCode.SUCCESS.getCode()){ + MtPushData mtPushData = new MtPushData(); + mtPushData.setPushTime(new Date()); + mtPushData.setPushStatus(1);// 推送状态 + mtPushData.setRefCode(unitNo); + mtPushData.setRefParentCode(orderNo); + mtPushData.setRefType(2);// 包件 + // 插入推送数据 + logger.info("#############handleStatusData:保存推送数据{}",mtPushData); + mtPushDataService.save(mtPushData); + + } + + + return rd; } @@ -364,11 +421,18 @@ public class MtFactoryDataServiceImpl implements IMtFactoryDataService { @Override public R sendReceiveInfo(ReceiveInfoDTO receiveInfoDTO) throws JsonProcessingException, NoSuchAlgorithmException { log.info("###########sendReceiveInfo: 处理签收图片数据开始"); + + logger.info("#############sendReceiveInfo:tag{}",1); + Integer newDistributionContactId = receiveInfoDTO.getNewDistributionContactId(); List receiveBodyList = receiveInfoDTO.getReceiveBodyList(); List receivePhotoList = receiveInfoDTO.getReceivePhotoList(); + logger.info("#############sendReceiveInfo:tag{}",2); + //查询签收人 NewDistributionContactEntity newDistributionContactEntity = newDistributionContactClient.fingByNewDistributionContactId(newDistributionContactId); + logger.info("#############sendReceiveInfo:tag{}",3); + String receiver = null; if (!Objects.isNull(newDistributionContactEntity)){ receiver = newDistributionContactEntity.getContact(); @@ -381,24 +445,35 @@ public class MtFactoryDataServiceImpl implements IMtFactoryDataService { //循环处理签收信息 List mtReceiveContentDTOList = new ArrayList<>(); + + logger.info("#############sendReceiveInfo:tag{}",4); + for(ReceiveBodyDTO receiveBodyDTO:receiveBodyList){ String unitNo = receiveBodyDTO.getUnitNo();//包条码 //通过订单编号查询总单信息 QueryWrapper packageInfoQueryWrapper = new QueryWrapper<>(); packageInfoQueryWrapper.eq("package_code",unitNo); MtPackageInfo one = mtPackageInfoService.getOne(packageInfoQueryWrapper); + logger.info("#############sendReceiveInfo:tag{}",5); + if(Objects.isNull(one)){ logger.info("#############sendReceiveInfo: 当前包条码未找到对应数据unitNo={}",unitNo); continue; } Long orderId = one.getOrderId(); MtFactoryOrder mtFactoryOrder = mtFactoryOrderService.getById(orderId); + logger.info("#############sendReceiveInfo:tag{}",6); + if(Objects.isNull(mtFactoryOrder)){ logger.info("#############sendReceiveInfo: 未找到对应订单orderId={}",orderId); continue; } Long mainId = mtFactoryOrder.getMainId(); + logger.info("#############sendReceiveInfo:tag{}",7); + MtFactoryOrderMain mtFactoryOrderMain = mtFactoryOrderMainService.getById(mainId); + logger.info("#############sendReceiveInfo:tag{}",8); + if(Objects.isNull(mtFactoryOrderMain)){ logger.info("#############sendReceiveInfo: 未找到对应订单mainId={}",mainId); continue; @@ -412,7 +487,11 @@ public class MtFactoryDataServiceImpl implements IMtFactoryDataService { mtReceiveContentDTO.setUnitNo(unitNo); mtReceiveContentDTO.setOperateDate(receiveBodyDTO.getOperateDate()); mtReceiveContentDTOList.add(mtReceiveContentDTO); + logger.info("#############sendReceiveInfo:tag{}",9); + } + logger.info("#############sendReceiveInfo:tag{}",10); + //签收信息数据存入头部数据 mtReceiveDTO.setReceiveContentList(mtReceiveContentDTOList); @@ -429,6 +508,8 @@ public class MtFactoryDataServiceImpl implements IMtFactoryDataService { ObjectMapper objectMapper = new ObjectMapper(); String s = objectMapper.writeValueAsString(mtReceiveDTO); + logger.info("#############sendReceiveInfo:tag{}",11); + return sendMtFactoryData(mtFactoryProperties.getUrl()+"/ZXCFaHuoDan/QianShouDan",s,5); diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DealWithDataHandler.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DealWithDataHandler.java index 382851234..3fe3897c3 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DealWithDataHandler.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DealWithDataHandler.java @@ -59,7 +59,11 @@ public class DealWithDataHandler { // channel.basicAck(deliveryTag,false); }else{ //真正的处理需要的数据 - panFactoryDataService.handleDataToPlatform(unitNo,operationTime); + try{ + panFactoryDataService.handleDataToPlatform(unitNo,operationTime); + }catch (Exception e){ + e.printStackTrace(); + } } } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/OrderStatusHandler.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/OrderStatusHandler.java index 7a39eaf34..4d6f11deb 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/OrderStatusHandler.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/OrderStatusHandler.java @@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j; import org.springblade.common.constant.RabbitConstant; import org.springblade.common.exception.CustomerException; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.api.ResultCode; import org.springframework.amqp.core.Message; import org.springframework.amqp.rabbit.annotation.RabbitHandler; import org.springframework.amqp.rabbit.annotation.RabbitListener; @@ -76,7 +77,12 @@ public class OrderStatusHandler { try{ r = mtFactoryDataService.handleStatusData(orderStatusDTO); + log.info("##################orderStatusHandler: 该条数据不用处理 orderNo={}",orderNo); + + + }catch (CustomerException rc){ + rc.printStackTrace(); if(200!=rc.code||400!=rc.code){ throw new CustomerException("程序异常,需要重试"); } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ReceiveInfoHandler.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ReceiveInfoHandler.java index d91bb8074..f2fcc815e 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ReceiveInfoHandler.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ReceiveInfoHandler.java @@ -70,7 +70,12 @@ public class ReceiveInfoHandler { // r = panFactoryDataService.handleData(orderInfoDTO); // break; case FactoryConstant.MENGT: - r = mtFactoryDataService.sendReceiveInfo(receiveInfoDTO); + try{ + r = mtFactoryDataService.sendReceiveInfo(receiveInfoDTO); + + }catch (Exception e){ + e.printStackTrace(); + } int code = r.getCode(); if(code == 400 || code == 200){ log.info("##################receiveInfoHandler: 该条数据不用处理 orderNo={}",orderCode); diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/UnloadCarComHandler.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/UnloadCarComHandler.java index d1bb865ce..ccc46ee1f 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/UnloadCarComHandler.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/UnloadCarComHandler.java @@ -139,13 +139,10 @@ public class UnloadCarComHandler { if(mtFactoryOrderMainList.size()>0){ mtFactoryOrderMainList.get(0); mtPushData.setRefId(mtFactoryOrderMainList.get(0).getId()); - } // 插入推送数据 mtPushDataService.save(mtPushData); - - } } catch (ParseException e) {