diff --git a/blade-biz-common/src/main/java/org/springblade/common/constant/RabbitConstant.java b/blade-biz-common/src/main/java/org/springblade/common/constant/RabbitConstant.java index d147e98f7..752dd14ec 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/constant/RabbitConstant.java +++ b/blade-biz-common/src/main/java/org/springblade/common/constant/RabbitConstant.java @@ -35,7 +35,7 @@ public interface RabbitConstant { */ String UNLOAD_CAR_COM_INFO_QUEUE = "unload_car_com_info_quere"; String UNLOAD_CAR_COM_INFO_EXCHANGE = "unload_car_com_info_exchange"; - String UNLOAD_CAR_COM_INFO_ROUTING = "unload_car_com_info_routing "; + String UNLOAD_CAR_COM_INFO_ROUTING = "unload_car_com_info_routing "; String WAYBILL_DATA_QUEUE = "waybill_data_queue"; @@ -54,11 +54,18 @@ public interface RabbitConstant { String OUPAI_RECEIVING_QUEUE = "oupai_receiving_queue"; String OUPAI_RECEIVING_EXCHANGE = "oupai_receiving_exchange"; - String OUPAI_RECEIVING_ROUTING = "oupai_receiving_routing"; + String OUPAI_RECEIVING_ROUTING = "oupai_receiving_routing"; + + /****************************收货入库 老系统 start ************************************************/ + String OUPAI_OLD_RECEIVING_QUEUE = "oupai_old_receiving_queue"; + String OUPAI_OLD_RECEIVING_EXCHANGE = "oupai_old_receiving_exchange"; + String OUPAI_OLD_RECEIVING_ROUTING = "oupai_old_receiving_routing"; + + /****************************收货入库 老系统 end ************************************************/ String OUPAI_SIGN_QUEUE = "oupai_sign_queue"; String OUPAI_SIGN_EXCHANGE = "oupai_sign_exchange"; - String OUPAI_SIGN_ROUTING = "oupai_sign_routing"; + String OUPAI_SIGN_ROUTING = "oupai_sign_routing"; String SYNC_OLD_DATA_QUEUE = "sync_old_data_queue"; String SYNC_OLD_DATA_EXCHANGE = "sync_old_data_exchange"; diff --git a/blade-service-api/logpm-basicdata-api/pom.xml b/blade-service-api/logpm-basicdata-api/pom.xml index 826a81507..9ae7563f0 100644 --- a/blade-service-api/logpm-basicdata-api/pom.xml +++ b/blade-service-api/logpm-basicdata-api/pom.xml @@ -13,6 +13,12 @@ org.springblade logpm-basicdata-api 3.1.0.RELEASE + + + cn.hutool + hutool-all + + + - diff --git a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/entity/BasicdataTripartiteWarehouseEntity.java b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/entity/BasicdataTripartiteWarehouseEntity.java new file mode 100644 index 000000000..ec896ea05 --- /dev/null +++ b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/entity/BasicdataTripartiteWarehouseEntity.java @@ -0,0 +1,47 @@ +package com.logpm.basicdata.entity; + +import cn.hutool.db.meta.Table; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.tenant.mp.TenantEntity; +@Data +@TableName("logpm_basicdata_tripartite_warehouse") +@ApiModel(value = "三方仓库", description = "三方仓库") +@EqualsAndHashCode(callSuper = true) +public class BasicdataTripartiteWarehouseEntity extends TenantEntity { + + /** 预留1 */ + @ApiModelProperty(name = "预留1",notes = "") + private String reserve1 ; + /** 预留2 */ + @ApiModelProperty(name = "预留2",notes = "") + private String reserve2 ; + /** 预留3 */ + @ApiModelProperty(name = "预留3",notes = "") + private String reserve3 ; + /** 预留4 */ + @ApiModelProperty(name = "预留4",notes = "") + private String reserve4 ; + /** 预留5 */ + @ApiModelProperty(name = "预留5",notes = "") + private String reserve5 ; + /** 三方仓库编码 */ + @ApiModelProperty(name = "三方仓库编码",notes = "") + private String warehouseCode ; + /** 三方仓库名称 */ + @ApiModelProperty(name = "三方仓库名称",notes = "") + private String warehouseName ; + /** 关联仓库编码 */ + @ApiModelProperty(name = "关联仓库编码",notes = "") + private String associationCode ; + /** 地址 */ + @ApiModelProperty(name = "地址",notes = "") + private String address ; + /** 品牌 */ + @ApiModelProperty(name = "品牌",notes = "") + private String brand ; + +} diff --git a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataTripartiteWarehouseClient.java b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataTripartiteWarehouseClient.java new file mode 100644 index 000000000..f4ed3a22b --- /dev/null +++ b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataTripartiteWarehouseClient.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package com.logpm.basicdata.feign; + + +import com.logpm.basicdata.entity.BasicdataTripartiteWarehouseEntity; +import com.logpm.basicdata.entity.BasicdataWarehouseEntity; +import org.springblade.common.constant.ModuleNameConstant; +import org.springblade.core.mp.support.BladePage; +import org.springblade.core.tool.api.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +/** + * 三方 + * + * @author pref + * @since 2023-09-25 + */ +@FeignClient( + value = ModuleNameConstant.APPLICATION_BASICDATA_NAME +) +public interface IBasicdataTripartiteWarehouseClient { + + String API_PREFIX = "tripartiteWarehouse/client"; + String GETWAREHOUSE = API_PREFIX + "/warehouse"; + + + /** + * 通过三方仓库名称 查询 汇通仓库的编码 + * @param warehouseName 三方仓库名称 + * @param warehouseCode 三方仓库编码 + * @return BasicdataTripartiteWarehouseEntity + */ + @GetMapping(GETWAREHOUSE) + BasicdataTripartiteWarehouseEntity getWarehouse(@RequestParam("warehouseName") String warehouseName, @RequestParam("warehouseCode") String warehouseCode); + + +} + diff --git a/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/entity/OpPushPackageSystemEntity.java b/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/entity/OpPushPackageSystemEntity.java new file mode 100644 index 000000000..7a09fa4f1 --- /dev/null +++ b/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/entity/OpPushPackageSystemEntity.java @@ -0,0 +1,43 @@ +package com.logpm.factory.oupai.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.mp.base.BaseEntity; +@Data +@TableName("op_push_package_system") +@ApiModel(value = "欧派包件推送老系统", description = "欧派包件推送老系统") +@EqualsAndHashCode(callSuper = true) +public class OpPushPackageSystemEntity extends BaseEntity { + + /** 预留1 */ + @ApiModelProperty(name = "预留1",notes = "") + private String reserve1 ; + /** 预留2 */ + @ApiModelProperty(name = "预留2",notes = "") + private String reserve2 ; + /** 预留3 */ + @ApiModelProperty(name = "预留3",notes = "") + private String reserve3 ; + /** 预留4 */ + @ApiModelProperty(name = "预留4",notes = "") + private String reserve4 ; + /** 预留5 */ + @ApiModelProperty(name = "预留5",notes = "") + private String reserve5 ; + /** 包条码 */ + @ApiModelProperty(name = "包条码",notes = "") + private String code ; + /** 仓库名称 */ + @ApiModelProperty(name = "仓库名称",notes = "") + private String warehouseName ; + /** 仓库编码 */ + @ApiModelProperty(name = "仓库编码",notes = "") + private String warehouseCode ; + /** 推送状态 0 未推送 1 已推送 */ + @ApiModelProperty(name = "推送状态 0 未推送 1 已推送",notes = "") + private Integer pushStatus ; + +} diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataTripartiteWarehouseClient.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataTripartiteWarehouseClient.java new file mode 100644 index 000000000..5d4adebc3 --- /dev/null +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataTripartiteWarehouseClient.java @@ -0,0 +1,31 @@ +package com.logpm.basicdata.feign; + +import com.logpm.basicdata.entity.BasicdataTripartiteWarehouseEntity; +import com.logpm.basicdata.service.IBasicdataTripartiteWarehouseService; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.RestController; +import springfox.documentation.annotations.ApiIgnore; + +import java.util.List; + +/** + * 三方仓库查询 + */ +@ApiIgnore() +@RestController +@AllArgsConstructor +public class BasicdataTripartiteWarehouseClient implements IBasicdataTripartiteWarehouseClient { + + private final IBasicdataTripartiteWarehouseService basicdataTripartiteWarehouseService; + + @Override + public BasicdataTripartiteWarehouseEntity getWarehouse(String warehouseName, String warehouseCode) { + + // 暂时 先用名称进行匹配 + List list = basicdataTripartiteWarehouseService.lambdaQuery().eq(BasicdataTripartiteWarehouseEntity::getWarehouseName, warehouseName).list(); + if (list.isEmpty()) { + return null; + } + return list.get(0); + } +} diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataTripartiteWarehouseMapper.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataTripartiteWarehouseMapper.java new file mode 100644 index 000000000..ccb0268d6 --- /dev/null +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataTripartiteWarehouseMapper.java @@ -0,0 +1,10 @@ +package com.logpm.basicdata.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.logpm.basicdata.entity.BasicdataTripartiteMallEntity; +import com.logpm.basicdata.entity.BasicdataTripartiteWarehouseEntity; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface BasicdataTripartiteWarehouseMapper extends BaseMapper { +} diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataTripartiteWarehouseMapper.xml b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataTripartiteWarehouseMapper.xml new file mode 100644 index 000000000..fdec73410 --- /dev/null +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataTripartiteWarehouseMapper.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataTripartiteWarehouseService.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataTripartiteWarehouseService.java new file mode 100644 index 000000000..d0c573357 --- /dev/null +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataTripartiteWarehouseService.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package com.logpm.basicdata.service; + + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.logpm.basicdata.entity.BasicdataTripartiteWarehouseEntity; +import com.logpm.basicdata.entity.BasicdataWarehouseEntity; +import com.logpm.basicdata.excel.BasicdataWarehouseExcel; +import com.logpm.basicdata.vo.BasicdataWarehouseVO; +import org.springblade.core.mp.base.BaseService; +import org.springblade.core.tool.api.R; + +import java.util.List; + +/** + * 三方仓库服务类 + * + * @author pref + * @since 2023-09-25 + */ +public interface IBasicdataTripartiteWarehouseService extends BaseService { + +} diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataTripartiteWarehouseServiceImpl.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataTripartiteWarehouseServiceImpl.java new file mode 100644 index 000000000..75bbc0416 --- /dev/null +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataTripartiteWarehouseServiceImpl.java @@ -0,0 +1,13 @@ +package com.logpm.basicdata.service.impl; + +import com.logpm.basicdata.entity.BasicdataTripartiteWarehouseEntity; +import com.logpm.basicdata.mapper.BasicdataTripartiteWarehouseMapper; +import com.logpm.basicdata.service.IBasicdataTripartiteWarehouseService; +import lombok.AllArgsConstructor; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +@Service +@AllArgsConstructor +public class BasicdataTripartiteWarehouseServiceImpl extends BaseServiceImpl implements IBasicdataTripartiteWarehouseService { +} diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java index 260afe78e..304d5bc5f 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java @@ -558,7 +558,6 @@ public class DistributionStockArticleServiceImpl extends BaseServiceImpl handlePackage(IPage pageVO) { pageVO.getRecords().forEach(s->{ - HashSet str = new HashSet<>(); // List parcelListEntityList = distributionParcelListService.getBaseMapper().selectList(Wrappers.query().lambda() // .eq(DistributionParcelListEntity::getStockArticleId, s.getId()) // .ne(DistributionParcelListEntity::getOrderPackageReservationStatus, OrderPackageReservationStatusConstant.yiyueyue.getValue())); diff --git a/blade-service/logpm-distribution/src/main/resources/application-prod.yml b/blade-service/logpm-distribution/src/main/resources/application-prod.yml index 1406c5b7a..3da290a43 100644 --- a/blade-service/logpm-distribution/src/main/resources/application-prod.yml +++ b/blade-service/logpm-distribution/src/main/resources/application-prod.yml @@ -55,3 +55,29 @@ spring: acknowledge-mode: manual template: mandatory: true + #rabbitmq配置 + rabbitmq: + host: 172.16.128.145 + port: 5672 + username: admin + password: Slwk@123654 + #虚拟host 可以不设置,使用server默认host + virtual-host: / + #确认消息已发送到队列(Queue) + publisher-returns: true + publisher-confirm-type: correlated + # 手动提交消息 + listener: + simple: + acknowledge-mode: auto + default-requeue-rejected: false + retry: + enabled: true # 开启消费者失败重试 + initial-interval: 1000 # 初识的失败等待时长为1秒 + multiplier: 1 # 失败的等待时长倍数,下次等待时长 = multiplier * last-interval + max-attempts: 3 # 最大重试次数 + stateless: true # true无状态;false有状态。如果业务中包含事务,这里改为false + direct: + acknowledge-mode: manual + template: + mandatory: true diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java index cf270a020..def968e3b 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java @@ -212,6 +212,29 @@ public class RabbitMqConfiguration { return BindingBuilder.bind(oupaiReceivingQueue).to(oupaiReceivingExchange).with(RabbitConstant.OUPAI_RECEIVING_ROUTING).noargs(); } + + @Bean + public Queue oupaiOldReceivingQueue() { + return new Queue(RabbitConstant.OUPAI_OLD_RECEIVING_QUEUE, true); + } + + @Bean + public CustomExchange oupaiOldReceivingExchange() { + Map args = Maps.newHashMap(); + args.put("x-delayed-type", "direct"); + return new CustomExchange(RabbitConstant.OUPAI_OLD_RECEIVING_EXCHANGE, "x-delayed-message", true, false, args); + } + + @Bean + public Binding oupaiOldReceivingBinding(Queue oupaiOldReceivingQueue, CustomExchange oupaiOldReceivingExchange) { + return BindingBuilder.bind(oupaiOldReceivingQueue).to(oupaiOldReceivingExchange).with(RabbitConstant.OUPAI_OLD_RECEIVING_ROUTING).noargs(); + } + + + + + + @Bean public Queue oupaiTestReceivingQueue() { return new Queue(RabbitConstant.TEST_RECEIVE_INFO_QUEUE, true); diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/OpPushPackageSystemMapper.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/OpPushPackageSystemMapper.java new file mode 100644 index 000000000..595dfd5de --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/OpPushPackageSystemMapper.java @@ -0,0 +1,10 @@ +package com.logpm.factory.oupai.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.logpm.factory.oupai.entity.FactoryLogEntity; +import com.logpm.factory.oupai.entity.OpPushPackageSystemEntity; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface OpPushPackageSystemMapper extends BaseMapper { +} diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/OpPushPackageSystemMapper.xml b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/OpPushPackageSystemMapper.xml new file mode 100644 index 000000000..a9e3435fb --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/OpPushPackageSystemMapper.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/receiver/OpOldReceivingDataHandler.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/receiver/OpOldReceivingDataHandler.java new file mode 100644 index 000000000..06a9d8a59 --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/receiver/OpOldReceivingDataHandler.java @@ -0,0 +1,135 @@ +package com.logpm.factory.oupai.receiver; + +import cn.hutool.http.HttpRequest; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.logpm.basicdata.entity.BasicdataTripartiteWarehouseEntity; +import com.logpm.basicdata.feign.IBasicdataTripartiteWarehouseClient; +import com.logpm.factory.oupai.entity.OpPushPackageSystemEntity; +import com.logpm.factory.oupai.service.IOpPushPackageSystemService; +import com.logpm.factory.pan.service.IPanFactoryDataService; +import com.logpm.oldproject.entity.WarehouseEntity; +import com.logpm.oldproject.feign.IWarehouseClient; +import com.rabbitmq.client.Channel; +import jodd.util.StringUtil; +import lombok.extern.slf4j.Slf4j; +import org.springblade.common.constant.RabbitConstant; +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.HashMap; +import java.util.Map; + + +/** + * 推送老系统 + * + * @author pref + */ +@Slf4j +@RabbitListener(queues = RabbitConstant.OUPAI_OLD_RECEIVING_QUEUE) +@Component +public class OpOldReceivingDataHandler { + + @Autowired + private IPanFactoryDataService panFactoryDataService; + + @Autowired + private IBasicdataTripartiteWarehouseClient basicdataTripartiteWarehouseClient; + @Autowired + private IWarehouseClient warehouseClient; + @Autowired + private IOpPushPackageSystemService opPushPackageSystemService; + + @RabbitHandler + public void opOldReceivingDataHandler(Map map, Message message, Channel channel) throws IOException { + // 如果手动ACK,消息会被监听消费,但是消息在队列中依旧存在,如果 未配置 acknowledge-mode 默认是会在消费完毕后自动ACK掉 + log.info("##################opReceivingDataHandler: 处理欧派收货数据到新系统"); + String jsonStr = (String) map.get("messageData"); + JSONObject object = JSONObject.parseObject(jsonStr); + String orderPackageCode = object.getString("orderPackageCode"); + String warehouseName = object.getString("warehouse_name"); + + OpPushPackageSystemEntity opPushPackageSystemEntity = new OpPushPackageSystemEntity(); + opPushPackageSystemEntity.setWarehouseName(warehouseName); + opPushPackageSystemEntity.setCode(orderPackageCode); + opPushPackageSystemEntity.setPushStatus(0); + opPushPackageSystemService.save(opPushPackageSystemEntity); + //真正的处理需要的数据 + try { + // 保存数据 + // 需要查询映射表 如果映射表没有值 这个字段为null + BasicdataTripartiteWarehouseEntity warehouse = basicdataTripartiteWarehouseClient.getWarehouse(warehouseName, null); + if (ObjectUtils.isNotNull(warehouse)) { + WarehouseEntity warehouseEntity = warehouseClient.findByCode(warehouse.getAssociationCode()); + // 请求老系统的登录接口 + + String authCode = oldLogin("账号", "密码", warehouseEntity.getId()); + // 推送数据 + if (StringUtil.isNotBlank(authCode)) { + boolean isSuccess = sendPackageData(authCode, orderPackageCode, warehouseName); + if (isSuccess) { + // 请求成功 修改推送数据的状态 修改未1 + opPushPackageSystemEntity.setPushStatus(1); + } else { + opPushPackageSystemEntity.setPushStatus(2); + } + } + } + + } catch (Exception e) { + log.error("##################opReceivingDataHandler: 处理欧派收货数据到新系统,orderPackageCode:{},warehouseName{}", + orderPackageCode, warehouseName); + log.error(e.getMessage()); + opPushPackageSystemEntity.setPushStatus(2); + + } + + opPushPackageSystemService.updateById(opPushPackageSystemEntity); + } + + private boolean sendPackageData(String authCode, String orderPackageCode, String warehouseName) { + // 构建请求头 + Map map = new HashMap<>(); + map.put("type", "1"); + map.put("unitNo", orderPackageCode); + map.put("mctsTruckNo", ""); + map.put("area", ""); + map.put("user_id", ""); + map.put("pick_up_id", ""); + map.put("origin", "按件入库"); + + + return false; + } + + /** + * 登录老系统 + * + * @param name 账号 + * @param pwd 密码 + * @param warhouseId 仓库ID + * @return 成功token + */ + private String oldLogin(String name, String pwd, Integer warhouseId) { + + + String url = ""; + String body = HttpRequest.post(url).execute().body(); + + + JSONObject authCode = JSON.parseObject(body); + + if ("200".equals(authCode.getString("code"))) { + + return authCode.getJSONObject("data").getString("token"); + + } + return null; + } +} diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/receiver/OpReceivingDataHandler.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/receiver/OpReceivingDataHandler.java index 059e54e4c..3ae23ca1f 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/receiver/OpReceivingDataHandler.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/receiver/OpReceivingDataHandler.java @@ -39,36 +39,12 @@ public class OpReceivingDataHandler { //真正的处理需要的数据 try { panFactoryDataService.handleDataToPlatform(orderPackageCode, receivingTime); + } catch (Exception e) { log.error("##################opReceivingDataHandler: 处理欧派收货数据到新系统,orderPackageCode:{},receivingTime{}", orderPackageCode,receivingTime); log.error(e.getMessage()); } - -// String args = opOrderStatusLogEntity.getResponseBody(); -// JSONObject jsonObject = JSONObject.parseObject(args); -// JSONArray jsonArray = jsonObject.getJSONArray("value"); -// for (int i = 0; i < jsonArray.size(); i++) { -// JSONObject valueObject = jsonArray.getJSONObject(i); -// JSONArray packages = valueObject.getJSONArray("Packages"); -// for (int j = 0; j < packages.size(); j++) { -// JSONObject packageJSON = packages.getJSONObject(j); -// String packageStatus = packageJSON.getString("PackageStatus"); -// String orderPackageCode = packageJSON.getString("Code"); -// String receivingTime=null; -// try{ -// receivingTime = packageJSON.getString("CreateTime"); -// }catch (Exception e){ -// log.error(e.getMessage()); -// } -// log.info("##################opReceivingDataHandler: 处理欧派收货数据到新系统,packageStatus:{},orderPackageCode:{},receivingTime{}", -// packageStatus,orderPackageCode,receivingTime); -// //判断是否是已入库 -// if("已在库".equals(packageStatus)){ -// -// } -// } -// } } } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/IOpPushPackageSystemService.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/IOpPushPackageSystemService.java new file mode 100644 index 000000000..ae7175ef4 --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/IOpPushPackageSystemService.java @@ -0,0 +1,8 @@ +package com.logpm.factory.oupai.service; + +import com.logpm.factory.oupai.entity.OpPushPackageSystemEntity; +import com.logpm.factory.oupai.entity.OpSignPackageEntity; +import org.springblade.core.mp.base.BaseService; + +public interface IOpPushPackageSystemService extends BaseService { +} diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/IOuPaiFactoryService.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/IOuPaiFactoryService.java index e7fced789..03fdaa0ae 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/IOuPaiFactoryService.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/IOuPaiFactoryService.java @@ -17,4 +17,5 @@ public interface IOuPaiFactoryService { String savaOuPaiSignBillByCode(String orderCode, Integer event); + String saveOuPaiPackageStatusByCodeByOld(String key, Integer event, String warehouseName); } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OpPushPackageSystemService.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OpPushPackageSystemService.java new file mode 100644 index 000000000..43453e140 --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OpPushPackageSystemService.java @@ -0,0 +1,11 @@ +package com.logpm.factory.oupai.service.impl; + +import com.logpm.factory.oupai.entity.OpOrderStatusLogEntity; +import com.logpm.factory.oupai.entity.OpPushPackageSystemEntity; +import com.logpm.factory.oupai.mapper.OpOrderStatusLogMapper; +import com.logpm.factory.oupai.mapper.OpPushPackageSystemMapper; +import com.logpm.factory.oupai.service.IOpPushPackageSystemService; +import org.springblade.core.mp.base.BaseServiceImpl; + +public class OpPushPackageSystemService extends BaseServiceImpl implements IOpPushPackageSystemService { +} diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OuPaiFactoryDataServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OuPaiFactoryDataServiceImpl.java index 56cab1033..ed5814c57 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OuPaiFactoryDataServiceImpl.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OuPaiFactoryDataServiceImpl.java @@ -26,6 +26,7 @@ public class OuPaiFactoryDataServiceImpl implements IOuPaiFactoryDataService { String typeName = ouPaiDataPushVO.getTypeName(); String orderCode = ouPaiDataPushVO.getOrderCode(); String key = ouPaiDataPushVO.getKey(); + String warehouseName = ouPaiDataPushVO.getWarehouseName(); String code = null; if(StringUtil.isBlank(typeName)){ log.info("#############saveData: 事件类型为空 typeName={}",typeName); @@ -38,6 +39,8 @@ public class OuPaiFactoryDataServiceImpl implements IOuPaiFactoryDataService { }else if(event == 2){ //包件收货 code = ouPaiFactoryService.saveOuPaiPackageStatusByCode(key,event); + // 老系统的 + code = ouPaiFactoryService.saveOuPaiPackageStatusByCodeByOld(key,event,warehouseName); }else if(event == 3){ // 收货单创建 // 获取需要处理的数据并存入数据库 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 31798547c..24a4c999b 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,7 +5,10 @@ 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; @@ -69,6 +72,8 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService { @Autowired private IOssClient ossClient; + + @Override public String saveOuPaiFactoryOrderDTOByCarCarNumber(String code) { @@ -119,16 +124,70 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService { map.put("messageData", jo.toJSONString()); map.put("createTime", new Date().getTime()); try { + log.info(">>>############ 处理到新系统"); rabbitTemplate.convertAndSend(RabbitConstant.OUPAI_RECEIVING_EXCHANGE, RabbitConstant.OUPAI_RECEIVING_ROUTING, map); } catch (Exception e) { log.error("############saveOuPaiPackageStatusByCode: {}", e.getMessage()); } log.info("############saveOuPaiPackageStatusByCode: 数据处理结束"); - return orderPackageCode; } + + + @Override + public String saveOuPaiPackageStatusByCodeByOld(String key, Integer event, String warehouseName) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("oid",key); + FactoryPackageEntity packageEntity = factoryPackageService.getOne(queryWrapper); + String code; + if(Objects.isNull(packageEntity)) { + log.error("############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)"; + OpOrderStatusLogEntity opOrderStatusLogEntity = sendRequestData(url, event); + + JSONObject jsonObject = JSONObject.parseObject(opOrderStatusLogEntity.getResponseBody()); + + code= jsonObject.getString("Code"); + + }else{ + packageEntity.setPackageStatus(5); + factoryPackageService.updateById(packageEntity); + code =packageEntity.getCode(); + } + + + + + + JSONObject jo = new JSONObject(); + jo.put("orderPackageCode",code); + jo.put("warehouse_name",warehouseName); + + //真正的处理需要的数据 + Map map = new HashMap<>(); + map.put("messageId", CommonUtil.getUUID()); + map.put("type", "Push"); + map.put("messageData", jo.toJSONString()); + map.put("createTime", new Date().getTime()); + try { + log.info(">>>############ 处理到老系统"); + rabbitTemplate.convertAndSend(RabbitConstant.OUPAI_OLD_RECEIVING_EXCHANGE, RabbitConstant.OUPAI_OLD_RECEIVING_ROUTING, map); + } catch (Exception e) { + log.error("############saveOuPaiPackageStatusByCodeByOld: {}", e.getMessage()); + } + + log.info("############saveOuPaiPackageStatusByCodeByOld: 数据处理结束"); + return key; + } + + + + + + @Override public String saveOuPaiOutGoingOrderByCode(String orderCode, Integer event) { //