15 changed files with 350 additions and 18 deletions
@ -0,0 +1,28 @@
|
||||
package com.logpm.factory.feign; |
||||
|
||||
|
||||
import org.springblade.common.constant.ModuleNameConstant; |
||||
import org.springframework.cloud.openfeign.FeignClient; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
||||
@FeignClient( |
||||
value = ModuleNameConstant.APPLICATION_FACTORY_NAME |
||||
) |
||||
public interface IOldSystemWaybillClient { |
||||
|
||||
String API_PREFIX = "/client"; |
||||
String HANDLEDATATOPLATFORM = API_PREFIX + "/handleDataToPlatform"; |
||||
|
||||
/** |
||||
* 处理订单入库数据 |
||||
* @param unitNo |
||||
* @param operationTime |
||||
*/ |
||||
@GetMapping(HANDLEDATATOPLATFORM) |
||||
void handleDataToPlatform(@RequestParam("unitNo") String unitNo, @RequestParam("operationTime") String operationTime); |
||||
|
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,38 @@
|
||||
package com.logpm.oldproject.feign; |
||||
|
||||
import com.logpm.oldproject.dto.SignPushDataDTO; |
||||
import org.checkerframework.checker.units.qual.A; |
||||
import org.springblade.common.constant.ModuleNameConstant; |
||||
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.Map; |
||||
|
||||
/** |
||||
* 老系统的开单的运单推送入库接口 |
||||
*/ |
||||
@FeignClient( |
||||
value = ModuleNameConstant.APPLICATION_OLDPROJECT_NAME |
||||
) |
||||
public interface IOldWaybillClient { |
||||
|
||||
|
||||
String API_PREFIX = "/client"; |
||||
|
||||
|
||||
/** |
||||
* 查询处理系统运单信息 |
||||
* @param waybillId |
||||
* @param waybillNo |
||||
* @return |
||||
*/ |
||||
@GetMapping(API_PREFIX+"/waybillDataHandler") |
||||
R waybillDataHandler(@RequestParam String waybillId, @RequestParam String waybillNo); |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,27 @@
|
||||
package com.logpm.factory.feign; |
||||
|
||||
import com.logpm.factory.pan.service.IPanFactoryDataService; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
import springfox.documentation.annotations.ApiIgnore; |
||||
|
||||
@Slf4j |
||||
@ApiIgnore() |
||||
@RestController |
||||
@AllArgsConstructor |
||||
public class OldSystemWaybillClient implements IOldSystemWaybillClient{ |
||||
|
||||
|
||||
|
||||
private final IPanFactoryDataService panFactoryDataService; |
||||
|
||||
@GetMapping(HANDLEDATATOPLATFORM) |
||||
@Override |
||||
public void handleDataToPlatform(String unitNo, String operationTime) { |
||||
log.info(">>>>>>>>> 运单开单 保存包件数据 {}",unitNo); |
||||
panFactoryDataService.handleDataToPlatform(unitNo,operationTime); |
||||
} |
||||
} |
@ -0,0 +1,111 @@
|
||||
package com.logpm.oldproject.feign; |
||||
|
||||
import cn.hutool.core.date.DateUtil; |
||||
import cn.hutool.http.HttpRequest; |
||||
import com.alibaba.fastjson.JSON; |
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.logpm.factory.feign.IOldSystemWaybillClient; |
||||
import com.logpm.oldproject.entity.WayBillEntity; |
||||
import com.logpm.oldproject.props.OldSystemProperties; |
||||
import com.logpm.oldproject.service.IWayBillService; |
||||
import jodd.util.StringUtil; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.core.redis.cache.BladeRedis; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
import springfox.documentation.annotations.ApiIgnore; |
||||
|
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
@ApiIgnore() |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@Slf4j |
||||
public class OldWaybillClient implements IOldWaybillClient { |
||||
@Autowired |
||||
private IOldSystemWaybillClient oldSystemWaybillClient; |
||||
@Autowired |
||||
private BladeRedis bladeRedis; |
||||
@Autowired |
||||
private OldSystemProperties oldSystemProperties; |
||||
@Autowired |
||||
private IWayBillService wayBillService; |
||||
|
||||
@Override |
||||
public R waybillDataHandler(String waybillId, String waybillNo) { |
||||
|
||||
// 更加运单ID查询系统数据
|
||||
log.info("##################pushOldSystemSignInfo: 请求老系统接口 start waybillId {},waybillNo {}", waybillId, waybillNo); |
||||
|
||||
WayBillEntity byWaybillId = wayBillService.getByWaybillId(Integer.parseInt(waybillId)); |
||||
|
||||
String authCode = oldLogin(byWaybillId.getArriveSiteId() + ""); |
||||
|
||||
String url = oldSystemProperties.getUrl() + "openApi/newSystem.WaybillQuery/index?waybillId=" + waybillId; |
||||
|
||||
String body = HttpRequest.get(url).header("token", authCode).execute().body(); |
||||
JSONObject jsonObject = JSONObject.parseObject(body); |
||||
if (200 == Integer.parseInt(jsonObject.get("code").toString())) { |
||||
// 请求成功
|
||||
JSONArray jsonArray = jsonObject.getJSONArray("data"); |
||||
// 循环结果
|
||||
for (int i = 0; i < jsonArray.size(); i++) { |
||||
JSONObject temp = jsonArray.getJSONObject(i); |
||||
// 订单编号
|
||||
String orderSelfNum = temp.getString("orderSelfNum"); |
||||
JSONArray unitNos = temp.getJSONArray("unitNo"); |
||||
|
||||
for (int i1 = 0; i1 < unitNos.size(); i1++) { |
||||
String unitNo = unitNos.getString(i1); |
||||
log.info(">>>>>>>> 保存开单推送的已入库包件 {} 保存到新系统",unitNo); |
||||
|
||||
String operationTime = DateUtil.format(new Date(),"yyyy-MM-dd hh:mm:ss"); |
||||
oldSystemWaybillClient.handleDataToPlatform(unitNo,operationTime); |
||||
} |
||||
|
||||
|
||||
} |
||||
} else { |
||||
// 请求失败
|
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* 登录老系统 |
||||
* |
||||
* @param warhouseId 仓库ID |
||||
* @return 成功token |
||||
*/ |
||||
private String oldLogin(String warhouseId) { |
||||
String o = bladeRedis.get(oldSystemProperties.getUserId() + "_" + warhouseId); |
||||
if (StringUtil.isBlank(o)) { |
||||
String url = oldSystemProperties.getUrl() + "api/fakeLogin"; |
||||
|
||||
Map<String, Object> 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(); |
||||
log.info("##################opReceivingDataHandler: 请求老系统接口,url:{},body:{}", url, body); |
||||
|
||||
|
||||
JSONObject authCode = JSON.parseObject(body); |
||||
|
||||
if ("200".equals(authCode.getString("code"))) { |
||||
|
||||
o = authCode.getJSONObject("data").getJSONObject("token").getString("token"); |
||||
bladeRedis.setEx(oldSystemProperties.getUserId() + "_" + warhouseId, o, 30 * 60L); |
||||
|
||||
} |
||||
} |
||||
|
||||
return o; |
||||
} |
||||
} |
@ -0,0 +1,24 @@
|
||||
package com.logpm.oldproject; |
||||
|
||||
import com.logpm.oldproject.feign.IOldWaybillClient; |
||||
import org.junit.jupiter.api.Test; |
||||
import org.junit.jupiter.api.extension.ExtendWith; |
||||
import org.springblade.core.test.BladeBootTest; |
||||
import org.springblade.core.test.BladeSpringExtension; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
||||
@ExtendWith(BladeSpringExtension.class) |
||||
@BladeBootTest(appName = "logpm-old-project-pref", enableLoader = true) |
||||
public class CodeTest { |
||||
|
||||
@Autowired |
||||
private IOldWaybillClient oldWaybillClient; |
||||
|
||||
|
||||
@Test |
||||
public void test1(){ |
||||
|
||||
oldWaybillClient.waybillDataHandler("100001","编号"); |
||||
|
||||
} |
||||
} |
@ -0,0 +1,60 @@
|
||||
/* |
||||
* 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.oldproject.launch; |
||||
|
||||
import org.springblade.core.auto.service.AutoService; |
||||
import org.springblade.core.launch.constant.NacosConstant; |
||||
import org.springblade.core.launch.service.LauncherService; |
||||
import org.springblade.core.launch.utils.PropsUtil; |
||||
import org.springframework.boot.builder.SpringApplicationBuilder; |
||||
|
||||
import java.util.Properties; |
||||
|
||||
/** |
||||
* 启动参数拓展 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@AutoService(LauncherService.class) |
||||
public class OldProjectLauncherServiceImpl implements LauncherService { |
||||
|
||||
@Override |
||||
public void launcher(SpringApplicationBuilder builder, String appName, String profile, boolean isLocalDev) { |
||||
Properties props = System.getProperties(); |
||||
// 开启多数据源
|
||||
PropsUtil.setProperty(props, "spring.datasource.dynamic.enabled", "true"); |
||||
// 指定注册配置信息
|
||||
PropsUtil.setProperty(props, "spring.cloud.nacos.config.extension-configs[0].data-id", NacosConstant.dataId("factory", profile)); |
||||
PropsUtil.setProperty(props, "spring.cloud.nacos.config.extension-configs[0].group", NacosConstant.NACOS_CONFIG_GROUP); |
||||
PropsUtil.setProperty(props, "spring.cloud.nacos.config.extension-configs[0].refresh", NacosConstant.NACOS_CONFIG_REFRESH); |
||||
// 指定注册IP
|
||||
// PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.ip", "127.0.0.1");
|
||||
// 指定注册端口
|
||||
// PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.port", "8200");
|
||||
// 自定义命名空间
|
||||
// PropsUtil.setProperty(props, "spring.cloud.nacos.config.namespace", LauncherConstant.NACOS_NAMESPACE);
|
||||
// PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.namespace", LauncherConstant.NACOS_NAMESPACE);
|
||||
// 自定义分组
|
||||
// PropsUtil.setProperty(props, "spring.cloud.nacos.config.group", NacosConstant.NACOS_CONFIG_GROUP);
|
||||
// PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.group", NacosConstant.NACOS_CONFIG_GROUP);
|
||||
} |
||||
|
||||
@Override |
||||
public int getOrder() { |
||||
return 20; |
||||
} |
||||
} |
Loading…
Reference in new issue