Browse Source

1.修复工厂数据模块bug

2.优化工厂数据逻辑
training
zhenghaoyu 1 year ago
parent
commit
24531e5611
  1. 5
      blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/controller/FactoryCommonController.java
  2. 16
      blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OuPaiFactoryServiceImpl.java
  3. 55
      blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ErrorQueueHandler.java
  4. 11
      blade-service/logpm-factory/src/main/java/com/logpm/factory/zb/controller/ZbFactoryDataController.java

5
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("logId", orderStatusLog.getId());
map.put("messageData", orderInfoDTO); map.put("messageData", orderInfoDTO);
map.put("createTime", new Date().getTime()); 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()))); 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("type", "Push");
map.put("messageData", orderStatusDTO); map.put("messageData", orderStatusDTO);
map.put("createTime", new Date().getTime()); map.put("createTime", new Date().getTime());
map.put("flagType", "OrderStatusLog");
//将消息携带绑定键值 //将消息携带绑定键值
rabbitTemplate.convertAndSend(RabbitConstant.ORDER_STATUS_EXCHANGE, RabbitConstant.ORDER_STATUS_ROUTING, map); rabbitTemplate.convertAndSend(RabbitConstant.ORDER_STATUS_EXCHANGE, RabbitConstant.ORDER_STATUS_ROUTING, map);
map.put("type", "DealWith"); map.put("type", "DealWith");
@ -132,6 +134,7 @@ public class FactoryCommonController {
map.put("logId", orderStatusLog.getId()); map.put("logId", orderStatusLog.getId());
map.put("messageData", receiveInfoDTO); map.put("messageData", receiveInfoDTO);
map.put("createTime", new Date().getTime()); map.put("createTime", new Date().getTime());
map.put("flagType", "OrderStatusLog");
//将消息携带绑定键值 //将消息携带绑定键值
rabbitTemplate.convertAndSend(RabbitConstant.RECEIVE_INFO_EXCHANGE, RabbitConstant.RECEIVE_INFO_ROUTING, map); 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("logId", orderStatusLog.getId());
map.put("messageData", receiveInfoDTO); map.put("messageData", receiveInfoDTO);
map.put("createTime", new Date().getTime()); 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); 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("logId", orderStatusLog.getId());
map.put("messageData", messageDTO); map.put("messageData", messageDTO);
map.put("createTime", new Date().getTime()); map.put("createTime", new Date().getTime());
map.put("flagType", "OrderStatusLog");
//将消息携带绑定键值 //将消息携带绑定键值
rabbitTemplate.convertAndSend(RabbitConstant.SYNC_OLD_DATA_EXCHANGE, RabbitConstant.SYNC_OLD_DATA_ROUTING, map); rabbitTemplate.convertAndSend(RabbitConstant.SYNC_OLD_DATA_EXCHANGE, RabbitConstant.SYNC_OLD_DATA_ROUTING, map);

16
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.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils; 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.comfac.service.IAsyncDataService;
import com.logpm.factory.oupai.entity.*; import com.logpm.factory.oupai.entity.*;
import com.logpm.factory.oupai.mapper.ReceivingOrderMapper; import com.logpm.factory.oupai.mapper.ReceivingOrderMapper;
@ -106,7 +103,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
queryWrapper.eq("oid", orderPackageCode); queryWrapper.eq("oid", orderPackageCode);
FactoryPackageEntity packageEntity = factoryPackageService.getOne(queryWrapper); FactoryPackageEntity packageEntity = factoryPackageService.getOne(queryWrapper);
if (Objects.isNull(packageEntity)) { if (Objects.isNull(packageEntity)) {
log.error("############oid 查询数据失败: {}", orderPackageCode); log.warn("############oid 查询数据失败: {}", orderPackageCode);
return orderPackageCode; return orderPackageCode;
} }
packageEntity.setPackageStatus(5); packageEntity.setPackageStatus(5);
@ -148,9 +145,10 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
String packageDetailNames = null; String packageDetailNames = null;
String firstPackName,secondPackName,thirdPackName = null; String firstPackName,secondPackName,thirdPackName = null;
if (Objects.isNull(packageEntity)) { 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()); JSONObject jsonObject = JSONObject.parseObject(opOrderStatusLogEntity.getResponseBody());
@ -163,7 +161,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
thirdPackName = jsonObject.getString("ThirdPackName"); thirdPackName = jsonObject.getString("ThirdPackName");
if(isInventory){ if(isInventory){
log.error("############库存品数据 不进行推送: {}", code); log.warn("############库存品数据 不进行推送: {}", code);
return key; return key;
} }
@ -178,14 +176,16 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
if(t!=null){ if(t!=null){
opShipNo = t.getString("Code"); opShipNo = t.getString("Code");
JSONObject endWarehouse = t.getJSONObject("EndWarehouse"); JSONObject endWarehouse = t.getJSONObject("EndWarehouse");
log.info("############仓库对象: endWarehouse={}",endWarehouse);
endWarehouseName = endWarehouse.getString("Name"); endWarehouseName = endWarehouse.getString("Name");
JSONObject fromWarehouse = t.getJSONObject("FromWarehouse"); JSONObject fromWarehouse = t.getJSONObject("FromWarehouse");
log.info("############基地对象: fromWarehouse={}",fromWarehouse);
siteName = fromWarehouse.getString("Name"); siteName = fromWarehouse.getString("Name");
} }
}else{ }else{
log.error("############没有收货单oid:{}", key); log.warn("############没有收货单oid:{}", key);
return key; return key;
} }

55
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 com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.common.constant.RabbitConstant; import org.springblade.common.constant.RabbitConstant;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.amqp.core.Message; import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler; import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.Map; import java.util.Map;
import java.util.Objects;
/** /**
@ -35,24 +36,42 @@ public class ErrorQueueHandler {
log.error(message.toString()); log.error(message.toString());
final long deliveryTag = message.getMessageProperties().getDeliveryTag(); final long deliveryTag = message.getMessageProperties().getDeliveryTag();
try { Object logIdObject = map.get("logId");
Long logId = (Long) map.get("logId"); Object flagTypeObject = map.get("flagType");
UpdateWrapper<OrderStatusLog> updateWrapper = new UpdateWrapper<>(); if(!Objects.isNull(logIdObject) && !Objects.isNull(flagTypeObject)){
updateWrapper.set("status",2) Long logId = (Long)logIdObject;
.eq("id",logId); String flagType = (String) flagTypeObject;
boolean updateFlag = orderStatusLogService.update(updateWrapper); if(!StringUtil.isBlank(flagType)){
if(updateFlag){ if("OrderStatusLog".equals(flagType)){
channel.basicAck(deliveryTag, false); UpdateWrapper<OrderStatusLog> updateWrapper = new UpdateWrapper<>();
}else{ updateWrapper.set("status",2)
channel.basicReject(deliveryTag,true); .eq("id",logId);
} orderStatusLogService.update(updateWrapper);
} catch (IOException e) { }
try {
// 处理失败,重新压入MQ
channel.basicReject(deliveryTag,true);
} catch (IOException e1) {
e1.printStackTrace();
} }
} }
// try {
// Long logId = (Long) map.get("logId");
// UpdateWrapper<OrderStatusLog> 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();
// }
// }
} }
} }

11
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.alibaba.fastjson.JSONObject;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.logpm.factory.comfac.service.IAsyncDataService; 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.bean.ZbResp;
import com.logpm.factory.zb.dto.ZBReceiptDTO; import com.logpm.factory.zb.dto.ZBReceiptDTO;
import com.logpm.factory.zb.entity.ZbFactoryLogEntity; 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.IZbFactoryDataService;
import com.logpm.factory.zb.service.IZbFactoryLogService; import com.logpm.factory.zb.service.IZbFactoryLogService;
import io.swagger.annotations.Api; 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.oss.model.BladeFile;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.resource.feign.IOssClient; 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.http.MediaType;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -72,6 +67,12 @@ public class ZbFactoryDataController {
String corpId = request.getHeader("corpId"); String corpId = request.getHeader("corpId");
zbReceiptDTO.setCorpId(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 orderStatusLog = new OrderStatusLog();
// orderStatusLog.setArgs(JSONObject.toJSONString(zbReceiptDTO)); // orderStatusLog.setArgs(JSONObject.toJSONString(zbReceiptDTO));

Loading…
Cancel
Save