3 changed files with 168 additions and 0 deletions
@ -0,0 +1,126 @@ |
|||||||
|
package com.logpm.factory.receiver; |
||||||
|
|
||||||
|
import com.logpm.basicdata.feign.IBasicdataTrayClient; |
||||||
|
import com.logpm.basicdata.feign.IBasicdataWarehouseClient; |
||||||
|
import com.logpm.factory.comfac.constant.FactoryConstant; |
||||||
|
import com.logpm.factory.comfac.dto.OrderStatusDTO; |
||||||
|
import com.logpm.factory.mt.service.IMtFactoryDataService; |
||||||
|
import com.logpm.factory.oupai.service.IOuPaiFactoryService; |
||||||
|
import com.logpm.factory.pan.service.IPanFactoryDataService; |
||||||
|
import com.logpm.factory.zb.service.IZbFactoryDataService; |
||||||
|
import com.logpm.oldproject.entity.AdvanceEntity; |
||||||
|
import com.logpm.oldproject.feign.IAdvanceClient; |
||||||
|
import com.logpm.oldproject.feign.ITrayClient; |
||||||
|
import com.logpm.oldproject.feign.ITrayScanClient; |
||||||
|
import com.logpm.oldproject.feign.ITrayScanDesClient; |
||||||
|
import com.logpm.trunkline.entity.TrunklineAdvanceEntity; |
||||||
|
import com.logpm.trunkline.feign.ITrunklineAdvanceClient; |
||||||
|
import com.logpm.warehouse.feign.*; |
||||||
|
import com.rabbitmq.client.Channel; |
||||||
|
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.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.security.NoSuchAlgorithmException; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.Objects; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 梦天工厂数据 处理器 |
||||||
|
* |
||||||
|
* @author yangkai.shen |
||||||
|
*/ |
||||||
|
@Slf4j |
||||||
|
@RabbitListener(queues = RabbitConstant.HWY_ORDER_STATUS_QUEUE) |
||||||
|
@Component |
||||||
|
public class HwyOrderStatusHandler { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private IAdvanceClient advanceClient; |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private IPanFactoryDataService panFactoryDataService; |
||||||
|
@Autowired |
||||||
|
private IMtFactoryDataService mtFactoryDataService; |
||||||
|
@Autowired |
||||||
|
private IZbFactoryDataService zbFactoryDataService; |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private IOuPaiFactoryService ouPaiFactoryService; |
||||||
|
@Autowired |
||||||
|
private IWarehouseTrayTypeClient warehouseTrayTypeClient; |
||||||
|
@Autowired |
||||||
|
private IWarehouseUpdownTypeClient updownTypeClient; |
||||||
|
@Autowired |
||||||
|
private IWarehouseTaryAllocationClient taryAllocationClient; |
||||||
|
@Autowired |
||||||
|
private IBasicdataWarehouseClient basicdataWarehouseClient; |
||||||
|
@Autowired |
||||||
|
private IBasicdataTrayClient basicdataTrayClient; |
||||||
|
@Autowired |
||||||
|
private ITrayClient trayClient; |
||||||
|
@Autowired |
||||||
|
private ITrayScanDesClient trayScanDesClient; |
||||||
|
@Autowired |
||||||
|
private ITrayScanClient trayScanClient; |
||||||
|
@Autowired |
||||||
|
private IWarehouseTrayGoodsClient warehouseTrayGoodsClient; |
||||||
|
@Autowired |
||||||
|
private IWarehouseUpdownGoodsClient warehouseUpdownGoodsClient; |
||||||
|
|
||||||
|
private ITrunklineAdvanceClient trunklineAdvanceClient; |
||||||
|
|
||||||
|
|
||||||
|
@RabbitHandler |
||||||
|
public void hwyOrderStatusHandler(Map map, Message message, Channel channel) throws IOException, NoSuchAlgorithmException { |
||||||
|
// 如果手动ACK,消息会被监听消费,但是消息在队列中依旧存在,如果 未配置 acknowledge-mode 默认是会在消费完毕后自动ACK掉
|
||||||
|
final long deliveryTag = message.getMessageProperties().getDeliveryTag(); |
||||||
|
String msg = new String(message.getBody()); |
||||||
|
log.info("##################hwyOrderStatusHandler: 处理扫码作业数据"); |
||||||
|
OrderStatusDTO orderStatusDTO = (OrderStatusDTO) map.get("messageData"); |
||||||
|
String orderSelfNum = orderStatusDTO.getOrderNo();//订单自编号
|
||||||
|
String unitNo = orderStatusDTO.getUnitNo(); |
||||||
|
//通过订单自编号去查询该条订单是属于哪个工厂
|
||||||
|
TrunklineAdvanceEntity advanceLimitOneByOrderCode = trunklineAdvanceClient.findAdvanceLimitOneByOrderCode(orderSelfNum); |
||||||
|
if (Objects.isNull(advanceLimitOneByOrderCode)) { |
||||||
|
log.info("##################hwyOrderStatusHandler: 未找到对应订单 orderNo={}", orderSelfNum); |
||||||
|
// channel.basicAck(deliveryTag,true);
|
||||||
|
return; |
||||||
|
} |
||||||
|
String type = advanceLimitOneByOrderCode.getBrand();//品牌
|
||||||
|
|
||||||
|
R r = null; |
||||||
|
switch (type) { |
||||||
|
case FactoryConstant.PIANO: |
||||||
|
r = panFactoryDataService.handleStatusData(orderStatusDTO); |
||||||
|
if (r.getCode() == 400 || r.getCode() == 200) { |
||||||
|
log.info("TAG {} ##################hwyOrderStatusHandler: 该条数据不用处理 orderNo={}", FactoryConstant.PIANO, orderSelfNum); |
||||||
|
// channel.basicAck(deliveryTag,true);
|
||||||
|
} else { |
||||||
|
throw new CustomerException(r.getCode(), r.getMsg()); |
||||||
|
} |
||||||
|
break; |
||||||
|
case FactoryConstant.MENGT: |
||||||
|
r = mtFactoryDataService.handleStatusData(orderStatusDTO); |
||||||
|
if (r.getCode() == 400 || r.getCode() == 200) { |
||||||
|
log.info("TAG {} ##################hwyOrderStatusHandler: 该条数据不用处理 orderNo={}", FactoryConstant.MENGT, orderSelfNum); |
||||||
|
} else { |
||||||
|
throw new CustomerException(r.getCode(), r.getMsg()); |
||||||
|
} |
||||||
|
break; |
||||||
|
|
||||||
|
default: |
||||||
|
log.info("##################hwyOrderStatusHandler: 新系统推送未知品牌 type={}", type); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue