1 changed files with 52 additions and 71 deletions
@ -1,87 +1,68 @@
|
||||
package com.logpm.factory.receiver; |
||||
|
||||
import cn.hutool.json.JSONObject; |
||||
import cn.hutool.json.JSONUtil; |
||||
import com.fasterxml.jackson.core.JsonProcessingException; |
||||
import com.logpm.factory.mt.service.IMtFactoryDataService; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.common.constant.broadcast.FanoutConstants; |
||||
import org.springblade.common.enums.BizOperationEnums; |
||||
import org.springblade.common.enums.PackageTypeEnums; |
||||
import org.springblade.common.exception.CustomerException; |
||||
import org.springblade.common.model.DistributionSignforVO; |
||||
import org.springblade.common.model.NodeFanoutMsg; |
||||
import org.springblade.common.model.PackageData; |
||||
import org.springblade.core.tool.utils.DateUtil; |
||||
import org.springframework.amqp.core.ExchangeTypes; |
||||
import org.springframework.amqp.rabbit.annotation.Exchange; |
||||
import org.springframework.amqp.rabbit.annotation.Queue; |
||||
import org.springframework.amqp.rabbit.annotation.QueueBinding; |
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.security.NoSuchAlgorithmException; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 作业节点数据监听 |
||||
*/ |
||||
@Slf4j |
||||
@AllArgsConstructor |
||||
@Component |
||||
// @Component
|
||||
public class NodeWorkHandler { |
||||
|
||||
private final IMtFactoryDataService mtFactoryDataService; |
||||
@RabbitListener(bindings = @QueueBinding( |
||||
value = @Queue(name = FanoutConstants.distribution.DeliveryAndSignfor.QUEUE.FACTORY_NODE_WORK_DISTRIBUTION_SIGNFOR_QUERY), |
||||
exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndSignfor.EXCHANGE, type = ExchangeTypes.FANOUT) |
||||
)) |
||||
public void distributionSignforQuery(String message) { |
||||
|
||||
try { |
||||
NodeFanoutMsg bean = JSONUtil.toBean(message, NodeFanoutMsg.class); |
||||
Object main = bean.getMain(); |
||||
JSONObject entries = JSONUtil.parseObj(main); |
||||
DistributionSignforVO vo = JSONUtil.toBean(entries, DistributionSignforVO.class); |
||||
List<PackageData> details = vo.getPackageDataList(); |
||||
details.forEach(t->{ |
||||
if(t.getPackageType().equals(PackageTypeEnums.CMP)){ |
||||
String orderPackageCode = t.getPackageCode(); |
||||
String operationTime = DateUtil.format(bean.getOperatorTime(),"yyyy-MM-dd hh:mm:ss"); |
||||
Long distributionContactId = vo.getReservationId(); |
||||
String destinationWarehouse = bean.getWarehouse(); |
||||
|
||||
// 获取品牌BrandEnums.MTMM.getValue()
|
||||
String o = t.getBrand(); |
||||
switch (o) { |
||||
case "梦天" : |
||||
log.info("工厂节点数据监听:1"); |
||||
try { |
||||
mtFactoryDataService.qianshouScanForNewSystem(orderPackageCode, operationTime, distributionContactId+"", destinationWarehouse); |
||||
} catch (Exception e) { |
||||
throw new CustomerException("服务器异常"+e.getMessage()); |
||||
} |
||||
break; |
||||
default: |
||||
log.info("签收扫描没有找到品牌: {}",o); |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}); |
||||
|
||||
// JSONObject jsonObject = JSONUtil.parseObj(message);
|
||||
|
||||
}catch (Exception e){ |
||||
log.error("工厂节点数据监听异常", e); |
||||
} |
||||
|
||||
|
||||
} |
||||
// 梦天签收回推走总线了,这里不需要了
|
||||
// @RabbitListener(bindings = @QueueBinding(
|
||||
// value = @Queue(name = FanoutConstants.distribution.DeliveryAndSignfor.QUEUE.FACTORY_NODE_WORK_DISTRIBUTION_SIGNFOR_QUERY),
|
||||
// exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndSignfor.EXCHANGE, type = ExchangeTypes.FANOUT)
|
||||
// ))
|
||||
// public void distributionSignforQuery(String message) {
|
||||
//
|
||||
// try {
|
||||
// NodeFanoutMsg bean = JSONUtil.toBean(message, NodeFanoutMsg.class);
|
||||
// Object main = bean.getMain();
|
||||
// JSONObject entries = JSONUtil.parseObj(main);
|
||||
// DistributionSignforVO vo = JSONUtil.toBean(entries, DistributionSignforVO.class);
|
||||
// List<PackageData> details = vo.getPackageDataList();
|
||||
// details.forEach(t->{
|
||||
// if(t.getPackageType().equals(PackageTypeEnums.CMP)){
|
||||
// String orderPackageCode = t.getPackageCode();
|
||||
// String operationTime = DateUtil.format(bean.getOperatorTime(),"yyyy-MM-dd hh:mm:ss");
|
||||
// Long distributionContactId = vo.getReservationId();
|
||||
// String destinationWarehouse = bean.getWarehouse();
|
||||
//
|
||||
// // 获取品牌BrandEnums.MTMM.getValue()
|
||||
// String o = t.getBrand();
|
||||
// switch (o) {
|
||||
// case "梦天" :
|
||||
// log.info("工厂节点数据监听:1");
|
||||
// try {
|
||||
// mtFactoryDataService.qianshouScanForNewSystem(orderPackageCode, operationTime, distributionContactId+"", destinationWarehouse);
|
||||
// } catch (Exception e) {
|
||||
// throw new CustomerException("服务器异常"+e.getMessage());
|
||||
// }
|
||||
// break;
|
||||
// default:
|
||||
// log.info("签收扫描没有找到品牌: {}",o);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// });
|
||||
//
|
||||
// // JSONObject jsonObject = JSONUtil.parseObj(message);
|
||||
//
|
||||
// }catch (Exception e){
|
||||
// log.error("工厂节点数据监听异常", e);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
} |
||||
|
Loading…
Reference in new issue