diff --git a/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/entity/FactoryPackageEntity.java b/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/entity/FactoryPackageEntity.java index 3f157ce7e..bb7d27140 100644 --- a/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/entity/FactoryPackageEntity.java +++ b/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/entity/FactoryPackageEntity.java @@ -98,6 +98,8 @@ public class FactoryPackageEntity extends BaseEntity { /** 推送状态 1推送 0未推送 */ @ApiModelProperty(name = "推送状态 1推送 0未推送",notes = "") private Integer pushStatus ; + @ApiModelProperty(name = "老系统推送状态 1推送 0未推送 2 推送失败",notes = "") + private Integer oldPushStatus; /** 转发状态 1转送 0未转送 */ @ApiModelProperty(name = "转发状态 1转送 0未转送 2 转送失败",notes = "") private Integer turnStatus ; 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 deleted file mode 100644 index 7a09fa4f1..000000000 --- a/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/entity/OpPushPackageSystemEntity.java +++ /dev/null @@ -1,43 +0,0 @@ -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-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 deleted file mode 100644 index 595dfd5de..000000000 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/OpPushPackageSystemMapper.java +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index a9e3435fb..000000000 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/OpPushPackageSystemMapper.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - 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 index 06a9d8a59..273e8da32 100644 --- 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 @@ -3,12 +3,14 @@ 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.conditions.query.QueryWrapper; 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.oupai.entity.FactoryPackageEntity; +import com.logpm.factory.oupai.service.IFactoryPackageService; import com.logpm.factory.pan.service.IPanFactoryDataService; +import com.logpm.factory.props.OldSystemProperties; import com.logpm.oldproject.entity.WarehouseEntity; import com.logpm.oldproject.feign.IWarehouseClient; import com.rabbitmq.client.Channel; @@ -44,7 +46,10 @@ public class OpOldReceivingDataHandler { @Autowired private IWarehouseClient warehouseClient; @Autowired - private IOpPushPackageSystemService opPushPackageSystemService; + private OldSystemProperties oldSystemProperties; + + @Autowired + private IFactoryPackageService factoryPackageService; @RabbitHandler public void opOldReceivingDataHandler(Map map, Message message, Channel channel) throws IOException { @@ -55,11 +60,16 @@ public class OpOldReceivingDataHandler { 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); + + QueryWrapper warehouseQueryWrapper = new QueryWrapper(); + warehouseQueryWrapper.eq("code", orderPackageCode); + + log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 查询包件数据 start >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + FactoryPackageEntity packageEntity = factoryPackageService.getOne(warehouseQueryWrapper); + + log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 查询包件数据 end >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> packageEntity {}", packageEntity); + + //真正的处理需要的数据 try { // 保存数据 @@ -69,15 +79,15 @@ public class OpOldReceivingDataHandler { WarehouseEntity warehouseEntity = warehouseClient.findByCode(warehouse.getAssociationCode()); // 请求老系统的登录接口 - String authCode = oldLogin("账号", "密码", warehouseEntity.getId()); + String authCode = oldLogin(warehouseEntity.getId()); // 推送数据 if (StringUtil.isNotBlank(authCode)) { boolean isSuccess = sendPackageData(authCode, orderPackageCode, warehouseName); if (isSuccess) { // 请求成功 修改推送数据的状态 修改未1 - opPushPackageSystemEntity.setPushStatus(1); + packageEntity.setOldPushStatus(1); } else { - opPushPackageSystemEntity.setPushStatus(2); + packageEntity.setOldPushStatus(2); } } } @@ -86,11 +96,12 @@ public class OpOldReceivingDataHandler { log.error("##################opReceivingDataHandler: 处理欧派收货数据到新系统,orderPackageCode:{},warehouseName{}", orderPackageCode, warehouseName); log.error(e.getMessage()); - opPushPackageSystemEntity.setPushStatus(2); + packageEntity.setOldPushStatus(2); +// opPushPackageSystemEntity.setPushStatus(2); } + factoryPackageService.updateById(packageEntity); - opPushPackageSystemService.updateById(opPushPackageSystemEntity); } private boolean sendPackageData(String authCode, String orderPackageCode, String warehouseName) { @@ -105,29 +116,33 @@ public class OpOldReceivingDataHandler { map.put("origin", "按件入库"); + + return false; } /** * 登录老系统 * - * @param name 账号 - * @param pwd 密码 * @param warhouseId 仓库ID * @return 成功token */ - private String oldLogin(String name, String pwd, Integer warhouseId) { + private String oldLogin(Integer warhouseId) { - String url = ""; - String body = HttpRequest.post(url).execute().body(); + String url = oldSystemProperties.getUrl() + "api/fakeLogin"; + Map map = new HashMap<>(); + map.put("pwd", oldSystemProperties.getPwd()); + map.put("user_id", oldSystemProperties.getUserId()); + map.put("warehouse_id", warhouseId); + String body = HttpRequest.post(url).form(map).execute().body(); JSONObject authCode = JSON.parseObject(body); if ("200".equals(authCode.getString("code"))) { - return authCode.getJSONObject("data").getString("token"); + return authCode.getJSONObject("data").getJSONObject("token").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 3ae23ca1f..e010f268d 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 @@ -29,14 +29,14 @@ public class OpReceivingDataHandler { private IPanFactoryDataService panFactoryDataService; @RabbitHandler - public void opReceivingDataHandler(Map map, Message message, Channel channel) throws IOException { + public void opReceivingDataHandler(Map map, Message message, Channel channel) { // 如果手动ACK,消息会被监听消费,但是消息在队列中依旧存在,如果 未配置 acknowledge-mode 默认是会在消费完毕后自动ACK掉 log.info("##################opReceivingDataHandler: 处理欧派收货数据到新系统"); String jsonStr = (String) map.get("messageData"); JSONObject object = JSONObject.parseObject(jsonStr); String orderPackageCode = object.getString("orderPackageCode"); String receivingTime = object.getString("receivingTime"); - //真正的处理需要的数据 + //真正处理需要的数据 try { panFactoryDataService.handleDataToPlatform(orderPackageCode, receivingTime); 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 deleted file mode 100644 index ae7175ef4..000000000 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/IOpPushPackageSystemService.java +++ /dev/null @@ -1,8 +0,0 @@ -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/impl/OpPushPackageSystemService.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OpPushPackageSystemService.java deleted file mode 100644 index 43453e140..000000000 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OpPushPackageSystemService.java +++ /dev/null @@ -1,11 +0,0 @@ -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/OuPaiFactoryServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OuPaiFactoryServiceImpl.java index 24a4c999b..5d094f426 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 @@ -159,9 +159,6 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService { } - - - JSONObject jo = new JSONObject(); jo.put("orderPackageCode",code); jo.put("warehouse_name",warehouseName); diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/props/OldSystemProperties.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/props/OldSystemProperties.java new file mode 100644 index 000000000..f95298858 --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/props/OldSystemProperties.java @@ -0,0 +1,33 @@ +package com.logpm.factory.props; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +/** + * FactoryProperties + * + * @author pref + */ +@Data +@ConfigurationProperties(prefix = "old") +@Component +public class OldSystemProperties { + /** + * 请求地址 + */ + private String url; + + /** + * 默认账号 + */ + private String pwd; + + /** + * 默认用户 + */ + private String userId; + + + +} diff --git a/blade-service/logpm-factory/src/test/java/com/logpm/factory/TestService.java b/blade-service/logpm-factory/src/test/java/com/logpm/factory/TestService.java index 3285647ba..f5b5516b4 100644 --- a/blade-service/logpm-factory/src/test/java/com/logpm/factory/TestService.java +++ b/blade-service/logpm-factory/src/test/java/com/logpm/factory/TestService.java @@ -1,5 +1,6 @@ package com.logpm.factory; +import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpUtil; import com.alibaba.excel.EasyExcel; @@ -24,7 +25,9 @@ import com.logpm.factory.mt.service.IMtFactoryDataService; import com.logpm.factory.mt.service.IMtFactoryOrderMainService; import com.logpm.factory.mt.service.IMtPushDataService; import com.logpm.factory.mt.service.impl.MtFactoryDataServiceImpl; +import com.logpm.factory.oupai.entity.FactoryPackageEntity; import com.logpm.factory.oupai.entity.OpOrderStatusLogEntity; +import com.logpm.factory.oupai.service.IFactoryPackageService; import com.logpm.factory.oupai.service.IOuPaiFactoryService; import com.logpm.factory.pan.service.IPanFactoryDataService; import com.logpm.factory.snm.vo.MTOrderPackageRelationVO; @@ -70,6 +73,9 @@ public class TestService { @Autowired private IPanFactoryDataService panFactoryDataService; + @Autowired + private IFactoryPackageService factoryPackageService; + @Autowired private IOssClient ossClient; @@ -205,6 +211,46 @@ public class TestService { } + + @Test + public void test5(){ + +// String s = oldLogin("", 30); +// System.out.println(s); + + QueryWrapper warehouseQueryWrapper = new QueryWrapper(); + warehouseQueryWrapper.eq("code","P00842309083496137"); + + FactoryPackageEntity packageEntity = factoryPackageService.getOne(warehouseQueryWrapper); + + System.out.println(packageEntity); + + } + + private String oldLogin(String name, Integer warhouseId) { + Map map = new HashMap<>(); + map.put("pwd", "huitongys-2022"); + map.put("user_id", 1080); + map.put("warehouse_id", warhouseId); + + + String url = "http://twms.version1.huitongys.com/api/fakeLogin"; + String body = HttpRequest.post(url).form(map). + + execute().body(); + + + JSONObject authCode = JSON.parseObject(body); + + if ("200".equals(authCode.getString("code"))) { + + return authCode.getJSONObject("data").getJSONObject("token").getString("token"); + + } + return null; + } + + @NotNull private MultipartFile getMultipartFile(String logPath) throws FileNotFoundException { File file = new File(logPath);