From 24531e5611f2a7896ebf52207bc14d515248722c Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Sun, 8 Oct 2023 18:49:32 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E5=A4=8D=E5=B7=A5=E5=8E=82=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=A8=A1=E5=9D=97bug=202.=E4=BC=98=E5=8C=96=E5=B7=A5?= =?UTF-8?q?=E5=8E=82=E6=95=B0=E6=8D=AE=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FactoryCommonController.java | 5 ++ .../service/impl/OuPaiFactoryServiceImpl.java | 16 +++--- .../factory/receiver/ErrorQueueHandler.java | 55 +++++++++++++------ .../controller/ZbFactoryDataController.java | 11 ++-- 4 files changed, 56 insertions(+), 31 deletions(-) diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/controller/FactoryCommonController.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/controller/FactoryCommonController.java index d082b4e2f..43927134f 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/controller/FactoryCommonController.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/controller/FactoryCommonController.java @@ -56,6 +56,7 @@ public class FactoryCommonController { map.put("logId", orderStatusLog.getId()); map.put("messageData", orderInfoDTO); map.put("createTime", new Date().getTime()); + map.put("flagType", "OrderStatusLog"); //将消息携带绑定键值 rabbitTemplate.convertAndSend(RabbitConstant.OPEN_ORDER_EXCHANGE, RabbitConstant.OPEN_ORDER_ROUTING, map, new CorrelationData(String.valueOf(orderStatusLog.getId()))); @@ -92,6 +93,7 @@ public class FactoryCommonController { map.put("type", "Push"); map.put("messageData", orderStatusDTO); map.put("createTime", new Date().getTime()); + map.put("flagType", "OrderStatusLog"); //将消息携带绑定键值 rabbitTemplate.convertAndSend(RabbitConstant.ORDER_STATUS_EXCHANGE, RabbitConstant.ORDER_STATUS_ROUTING, map); map.put("type", "DealWith"); @@ -132,6 +134,7 @@ public class FactoryCommonController { map.put("logId", orderStatusLog.getId()); map.put("messageData", receiveInfoDTO); map.put("createTime", new Date().getTime()); + map.put("flagType", "OrderStatusLog"); //将消息携带绑定键值 rabbitTemplate.convertAndSend(RabbitConstant.RECEIVE_INFO_EXCHANGE, RabbitConstant.RECEIVE_INFO_ROUTING, map); @@ -173,6 +176,7 @@ public class FactoryCommonController { map.put("logId", orderStatusLog.getId()); map.put("messageData", receiveInfoDTO); map.put("createTime", new Date().getTime()); + map.put("flagType", "OrderStatusLog"); //将消息携带绑定键值 rabbitTemplate.convertAndSend(RabbitConstant.UNLOAD_CAR_COM_INFO_EXCHANGE, RabbitConstant.UNLOAD_CAR_COM_INFO_ROUTING, map); @@ -207,6 +211,7 @@ public class FactoryCommonController { map.put("logId", orderStatusLog.getId()); map.put("messageData", messageDTO); map.put("createTime", new Date().getTime()); + map.put("flagType", "OrderStatusLog"); //将消息携带绑定键值 rabbitTemplate.convertAndSend(RabbitConstant.SYNC_OLD_DATA_EXCHANGE, RabbitConstant.SYNC_OLD_DATA_ROUTING, map); 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 0613d601d..a62e56a99 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 @@ -5,10 +5,7 @@ import cn.hutool.http.HttpResponse; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; 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.basicdata.entity.BasicdataTripartiteWarehouseEntity; -import com.logpm.basicdata.feign.IBasicdataTripartiteWarehouseClient; import com.logpm.factory.comfac.service.IAsyncDataService; import com.logpm.factory.oupai.entity.*; import com.logpm.factory.oupai.mapper.ReceivingOrderMapper; @@ -106,7 +103,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService { queryWrapper.eq("oid", orderPackageCode); FactoryPackageEntity packageEntity = factoryPackageService.getOne(queryWrapper); if (Objects.isNull(packageEntity)) { - log.error("############oid 查询数据失败: {}", orderPackageCode); + log.warn("############oid 查询数据失败: {}", orderPackageCode); return orderPackageCode; } packageEntity.setPackageStatus(5); @@ -148,9 +145,10 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService { String packageDetailNames = null; String firstPackName,secondPackName,thirdPackName = null; if (Objects.isNull(packageEntity)) { - log.error("############oid 查询数据失败: {}", key); + log.warn("############oid 查询数据失败: {}", key); // 查询欧派系统的的数据 - String url = ouPaiProperties.getUri() + "tims_odata_api/api/odata/Package(" + key + ")?select=Code,PackageStatus,FirstClassCode,FirstClassName,SecondClassCode,SecondClassName,ThirdClassCode,ThirdClassName,BuyIn,CosourcingCode,CosourcingUnit,Length,Width,Height,Weight,IsInventory,SendTime,ReceivingTime,CreateTime,ShipTime,CarNumber,DeliveryMethod&$expand=ReceivingOrders($select=Code,Type,Status,Plate,PackagesCount,ReceivePackageCount,PlateNum,CarNumber,CarrierCode,SendTime,ArrivalTime,ReceiveTime,CreateTime,ReturnNumber;$expand=EndWarehouse($select=Name,Code))&$expand=Order($select=SelfCode,Code)"; OpOrderStatusLogEntity opOrderStatusLogEntity = sendRequestData(url, event); + String url = ouPaiProperties.getUri() + "tims_odata_api/api/odata/Package(" + key + ")?select=Code,PackageStatus,FirstClassCode,FirstClassName,SecondClassCode,SecondClassName,ThirdClassCode,ThirdClassName,BuyIn,CosourcingCode,CosourcingUnit,Length,Width,Height,Weight,IsInventory,SendTime,ReceivingTime,CreateTime,ShipTime,CarNumber,DeliveryMethod&$expand=ReceivingOrders($select=Code,Type,Status,Plate,PackagesCount,ReceivePackageCount,PlateNum,CarNumber,CarrierCode,SendTime,ArrivalTime,ReceiveTime,CreateTime,ReturnNumber;$expand=EndWarehouse($select=Name,Code))&$expand=Order($select=SelfCode,Code)"; + OpOrderStatusLogEntity opOrderStatusLogEntity = sendRequestData(url, event); JSONObject jsonObject = JSONObject.parseObject(opOrderStatusLogEntity.getResponseBody()); @@ -163,7 +161,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService { thirdPackName = jsonObject.getString("ThirdPackName"); if(isInventory){ - log.error("############库存品数据 不进行推送: {}", code); + log.warn("############库存品数据 不进行推送: {}", code); return key; } @@ -178,14 +176,16 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService { if(t!=null){ opShipNo = t.getString("Code"); JSONObject endWarehouse = t.getJSONObject("EndWarehouse"); + log.info("############仓库对象: endWarehouse={}",endWarehouse); endWarehouseName = endWarehouse.getString("Name"); JSONObject fromWarehouse = t.getJSONObject("FromWarehouse"); + log.info("############基地对象: fromWarehouse={}",fromWarehouse); siteName = fromWarehouse.getString("Name"); } }else{ - log.error("############没有收货单oid:{}", key); + log.warn("############没有收货单oid:{}", key); return key; } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ErrorQueueHandler.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ErrorQueueHandler.java index 1e4cfce36..6518f60c2 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ErrorQueueHandler.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ErrorQueueHandler.java @@ -6,14 +6,15 @@ import com.logpm.factory.snm.entity.OrderStatusLog; import com.rabbitmq.client.Channel; import lombok.extern.slf4j.Slf4j; import org.springblade.common.constant.RabbitConstant; +import org.springblade.core.tool.utils.StringUtil; import org.springframework.amqp.core.Message; import org.springframework.amqp.rabbit.annotation.RabbitHandler; import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.io.IOException; import java.util.Map; +import java.util.Objects; /** @@ -35,24 +36,42 @@ public class ErrorQueueHandler { log.error(message.toString()); final long deliveryTag = message.getMessageProperties().getDeliveryTag(); - try { - Long logId = (Long) map.get("logId"); - UpdateWrapper updateWrapper = new UpdateWrapper<>(); - updateWrapper.set("status",2) - .eq("id",logId); - boolean updateFlag = orderStatusLogService.update(updateWrapper); - if(updateFlag){ - channel.basicAck(deliveryTag, false); - }else{ - channel.basicReject(deliveryTag,true); - } - } catch (IOException e) { - try { - // 处理失败,重新压入MQ - channel.basicReject(deliveryTag,true); - } catch (IOException e1) { - e1.printStackTrace(); + Object logIdObject = map.get("logId"); + Object flagTypeObject = map.get("flagType"); + if(!Objects.isNull(logIdObject) && !Objects.isNull(flagTypeObject)){ + Long logId = (Long)logIdObject; + String flagType = (String) flagTypeObject; + if(!StringUtil.isBlank(flagType)){ + if("OrderStatusLog".equals(flagType)){ + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.set("status",2) + .eq("id",logId); + orderStatusLogService.update(updateWrapper); + } } } + + + + +// try { +// Long logId = (Long) map.get("logId"); +// UpdateWrapper updateWrapper = new UpdateWrapper<>(); +// updateWrapper.set("status",2) +// .eq("id",logId); +// boolean updateFlag = orderStatusLogService.update(updateWrapper); +// if(updateFlag){ +// channel.basicAck(deliveryTag, false); +// }else{ +// channel.basicReject(deliveryTag,true); +// } +// } catch (IOException e) { +// try { +// // 处理失败,重新压入MQ +// channel.basicReject(deliveryTag,true); +// } catch (IOException e1) { +// e1.printStackTrace(); +// } +// } } } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/zb/controller/ZbFactoryDataController.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/zb/controller/ZbFactoryDataController.java index 16e7e43f9..b2026adf1 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/zb/controller/ZbFactoryDataController.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/zb/controller/ZbFactoryDataController.java @@ -3,12 +3,9 @@ package com.logpm.factory.zb.controller; import com.alibaba.fastjson.JSONObject; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.logpm.factory.comfac.service.IAsyncDataService; -import com.logpm.factory.comfac.service.IOrderStatusLogService; -import com.logpm.factory.snm.entity.OrderStatusLog; import com.logpm.factory.zb.bean.ZbResp; import com.logpm.factory.zb.dto.ZBReceiptDTO; import com.logpm.factory.zb.entity.ZbFactoryLogEntity; -import com.logpm.factory.zb.entity.ZbOrderLogEntity; import com.logpm.factory.zb.service.IZbFactoryDataService; import com.logpm.factory.zb.service.IZbFactoryLogService; import io.swagger.annotations.Api; @@ -23,8 +20,6 @@ import org.springblade.common.utils.FileLogsUtil; import org.springblade.core.oss.model.BladeFile; import org.springblade.core.tool.api.R; import org.springblade.resource.feign.IOssClient; -import org.springframework.amqp.rabbit.core.RabbitTemplate; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -72,6 +67,12 @@ public class ZbFactoryDataController { String corpId = request.getHeader("corpId"); zbReceiptDTO.setCorpId(corpId); + String method = request.getParameter("method"); + if(!"entry.order.create".equals(method)){ + log.warn("############data: 暂不支持该功能 method={}",method); + return ZbResp.fail("暂不支持该功能"); + } + // 先保存原始请求数据 // OrderStatusLog orderStatusLog = new OrderStatusLog(); // orderStatusLog.setArgs(JSONObject.toJSONString(zbReceiptDTO));