From 16003b73d0da2913dbb082e76a45546e1a83dd5b Mon Sep 17 00:00:00 2001 From: anthonyywj2 <353682448@qq.com> Date: Thu, 5 May 2022 17:22:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8D=95=E6=8D=AE=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E6=8E=A5=E5=8F=A3=EF=BC=8C=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=88=B0udiwms=EF=BC=8C=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mipsdl/admin/client/http/TestClient.java | 29 ++++++++++++-- .../admin/controller/UdiWmsController.java | 12 ++++++ .../glxp/mipsdl/admin/http/UdiwmsClient.java | 40 ++++++++++++++----- .../admin/req/UdiwmsBusTypeRequest.java | 14 +++++++ .../res/system/UdiwmsBusTypeResponse.java | 12 ++++++ .../thread/system/UdiInfoUploadService.java | 15 +++---- .../glxp/mipsdl/admin/util/HttpClient.java | 17 +++++++- .../main/resources/application-pro.properties | 8 ++-- .../mybatis/mapper/system/ScheduleDao.xml | 21 +++++----- 9 files changed, 130 insertions(+), 38 deletions(-) create mode 100644 api-sync/src/main/java/com/glxp/mipsdl/admin/req/UdiwmsBusTypeRequest.java create mode 100644 api-sync/src/main/java/com/glxp/mipsdl/admin/res/system/UdiwmsBusTypeResponse.java diff --git a/api-sync/src/main/java/com/glxp/mipsdl/admin/client/http/TestClient.java b/api-sync/src/main/java/com/glxp/mipsdl/admin/client/http/TestClient.java index 3352f8d..79ac1e1 100644 --- a/api-sync/src/main/java/com/glxp/mipsdl/admin/client/http/TestClient.java +++ b/api-sync/src/main/java/com/glxp/mipsdl/admin/client/http/TestClient.java @@ -4,10 +4,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; import com.glxp.mipsdl.admin.req.*; -import com.glxp.mipsdl.admin.res.system.UdiwmsInvProductResponse; -import com.glxp.mipsdl.admin.res.system.UdiwmsOrderResponse; -import com.glxp.mipsdl.admin.res.system.UdiwmsProductInfoResponse; -import com.glxp.mipsdl.admin.res.system.UdiwmsUnitResponse; +import com.glxp.mipsdl.admin.res.system.*; import com.glxp.mipsdl.admin.util.CustomUtil; import com.glxp.mipsdl.common.res.BaseResponse; import com.glxp.mipsdl.common.util.ResultVOUtils; @@ -135,6 +132,30 @@ public class TestClient { return ResultVOUtils.success(udiwmsOrderResponse); } + + public BaseResponse getBusType(UdiwmsBusTypeRequest udiwmsBusTypeRequest) { + if (null == udiwmsBusTypeRequest) { + return ResultVOUtils.error(500, "参数不能未空"); + } + List udiwmsBusTypeResponses = new ArrayList<>(); + UdiwmsBusTypeResponse udiwmsBusTypeResponse = new UdiwmsBusTypeResponse(); + udiwmsBusTypeResponse.setId("1"); + udiwmsBusTypeResponse.setCode("cgrk"); + udiwmsBusTypeResponse.setName("采购入库单"); + udiwmsBusTypeResponse.setRemark("测试"); + udiwmsBusTypeResponses.add(udiwmsBusTypeResponse); + UdiwmsBusTypeResponse udiwmsBusTypeResponse2 = new UdiwmsBusTypeResponse(); + udiwmsBusTypeResponse2.setId("2"); + udiwmsBusTypeResponse2.setCode("syck"); + udiwmsBusTypeResponse2.setName("使用出库单"); + udiwmsBusTypeResponse2.setRemark("测试"); + udiwmsBusTypeResponses.add(udiwmsBusTypeResponse2); + udiwmsBusTypeResponses.add(udiwmsBusTypeResponse); + udiwmsBusTypeResponses.add(udiwmsBusTypeResponse2); + + return ResultVOUtils.success(udiwmsBusTypeResponses); + } + /** * 新增订单 * diff --git a/api-sync/src/main/java/com/glxp/mipsdl/admin/controller/UdiWmsController.java b/api-sync/src/main/java/com/glxp/mipsdl/admin/controller/UdiWmsController.java index cbfc4b5..ab43186 100644 --- a/api-sync/src/main/java/com/glxp/mipsdl/admin/controller/UdiWmsController.java +++ b/api-sync/src/main/java/com/glxp/mipsdl/admin/controller/UdiWmsController.java @@ -76,6 +76,18 @@ public class UdiWmsController { } + + //获取ERP单据类型接口 + @AuthRuleAnnotation("") + @PostMapping("/udiwms/erp/getOrderType") + public BaseResponse getOrderTypes(@RequestBody UdiwmsBusTypeRequest udiwmsBusTypeRequest) { + if (curFlag.equals("TEST")) { + return testClient.getBusType(udiwmsBusTypeRequest); + } else + return ResultVOUtils.error(500, "未设置系统版本!"); + + } + //新增单据 @AuthRuleAnnotation("") @PostMapping("/udiwms/erp/addOrders") diff --git a/api-sync/src/main/java/com/glxp/mipsdl/admin/http/UdiwmsClient.java b/api-sync/src/main/java/com/glxp/mipsdl/admin/http/UdiwmsClient.java index f7f9529..5a68bc6 100644 --- a/api-sync/src/main/java/com/glxp/mipsdl/admin/http/UdiwmsClient.java +++ b/api-sync/src/main/java/com/glxp/mipsdl/admin/http/UdiwmsClient.java @@ -8,41 +8,59 @@ import com.glxp.mipsdl.admin.req.system.PostThrInvProductsRequest; import com.glxp.mipsdl.admin.req.system.PostThrProductsRequest; import com.glxp.mipsdl.admin.util.HttpClient; import com.glxp.mipsdl.common.res.BaseResponse; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpHeaders; +import org.springframework.stereotype.Service; +@Service public class UdiwmsClient { - String udiWmsUrl; + @Value("${UDIWMS_IP}") + private String udiWmsUrl; - public UdiwmsClient(String udiWmsUrl) { - this.udiWmsUrl = udiWmsUrl; + + @Value("${API_KEY}") + private String apiKey; + @Value("${API_SECRET}") + private String apiSecret; + + + public HttpHeaders getHeaders() { + HttpHeaders headers = new HttpHeaders(); + headers.add("Content-Type", "application/json"); + headers.add("api_key", apiKey); + headers.add("secret_key", apiSecret); + return headers; } - public BaseResponse postProducts( PostThrProductsRequest postThrProductsRequest) { - String response = HttpClient.postJson(udiWmsUrl+"/udiwms/thrsys/postThrProducts", postThrProductsRequest); + + + public BaseResponse postProducts(PostThrProductsRequest postThrProductsRequest) { + String response = HttpClient.postJson(udiWmsUrl + "/udiwms/thrsys/postThrProducts", postThrProductsRequest, getHeaders()); BaseResponse baseResponse = JSONObject.parseObject(response, new TypeReference() { }); return baseResponse; } - public BaseResponse postCorps( PostThrCorpRequest postThrCorpRequest) { + public BaseResponse postCorps(PostThrCorpRequest postThrCorpRequest) { postThrCorpRequest.setUploadType("文件导入"); - String response = HttpClient.postJson(udiWmsUrl+"/udiwms/thrsys/postCorps", postThrCorpRequest); + String response = HttpClient.postJson(udiWmsUrl + "/udiwms/thrsys/postCorps", postThrCorpRequest, getHeaders()); BaseResponse baseResponse = JSONObject.parseObject(response, new TypeReference() { }); return baseResponse; } - public BaseResponse postOrderDetail( PostFileThrOrderRequest postFileThrOrderRequest) { - String response = HttpClient.postJson(udiWmsUrl+"/udiwms/thrsys/postFileOrder", postFileThrOrderRequest); + public BaseResponse postOrderDetail(PostFileThrOrderRequest postFileThrOrderRequest) { + String response = HttpClient.postJson(udiWmsUrl + "/udiwms/thrsys/postFileOrder", postFileThrOrderRequest, getHeaders()); BaseResponse baseResponse = JSONObject.parseObject(response, new TypeReference() { }); return baseResponse; } - public BaseResponse postInvProducts( PostThrInvProductsRequest postThrInvProductsRequest) { - String response = HttpClient.postJson(udiWmsUrl+"/udiwms/thrsys/postInvProducts", postThrInvProductsRequest); + public BaseResponse postInvProducts(PostThrInvProductsRequest postThrInvProductsRequest) { + String response = HttpClient.postJson(udiWmsUrl + "/udiwms/thrsys/postInvProducts", postThrInvProductsRequest, getHeaders()); BaseResponse baseResponse = JSONObject.parseObject(response, new TypeReference() { }); diff --git a/api-sync/src/main/java/com/glxp/mipsdl/admin/req/UdiwmsBusTypeRequest.java b/api-sync/src/main/java/com/glxp/mipsdl/admin/req/UdiwmsBusTypeRequest.java new file mode 100644 index 0000000..4dd5e31 --- /dev/null +++ b/api-sync/src/main/java/com/glxp/mipsdl/admin/req/UdiwmsBusTypeRequest.java @@ -0,0 +1,14 @@ +package com.glxp.mipsdl.admin.req; + +import lombok.Data; + +@Data +public class UdiwmsBusTypeRequest { + + private String id; + private String code; + private String name; + private Integer limit; + private Integer page; + private String thirdSys; +} diff --git a/api-sync/src/main/java/com/glxp/mipsdl/admin/res/system/UdiwmsBusTypeResponse.java b/api-sync/src/main/java/com/glxp/mipsdl/admin/res/system/UdiwmsBusTypeResponse.java new file mode 100644 index 0000000..a1cad88 --- /dev/null +++ b/api-sync/src/main/java/com/glxp/mipsdl/admin/res/system/UdiwmsBusTypeResponse.java @@ -0,0 +1,12 @@ +package com.glxp.mipsdl.admin.res.system; + +import lombok.Data; + +@Data +public class UdiwmsBusTypeResponse { + + private String id; + private String code; + private String name; + private String remark; +} diff --git a/api-sync/src/main/java/com/glxp/mipsdl/admin/thread/system/UdiInfoUploadService.java b/api-sync/src/main/java/com/glxp/mipsdl/admin/thread/system/UdiInfoUploadService.java index dc8f7b3..416c880 100644 --- a/api-sync/src/main/java/com/glxp/mipsdl/admin/thread/system/UdiInfoUploadService.java +++ b/api-sync/src/main/java/com/glxp/mipsdl/admin/thread/system/UdiInfoUploadService.java @@ -5,36 +5,37 @@ import com.glxp.mipsdl.admin.req.system.PostFileThrOrderRequest; import com.glxp.mipsdl.admin.req.system.PostThrCorpRequest; import com.glxp.mipsdl.admin.req.system.PostThrInvProductsRequest; import com.glxp.mipsdl.admin.req.system.PostThrProductsRequest; -import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; +import javax.annotation.Resource; + @Service public class UdiInfoUploadService { - @Value("${UDIWMS_IP}") - private String udiwmsIp; + @Resource + UdiwmsClient udiwmsClient; @Async public void postProducts(PostThrProductsRequest postThrProductsRequest) { - new UdiwmsClient(udiwmsIp).postProducts(postThrProductsRequest); + udiwmsClient.postProducts(postThrProductsRequest); } @Async public void postCorps(PostThrCorpRequest postThrCorpRequest) { - new UdiwmsClient(udiwmsIp).postCorps(postThrCorpRequest); + udiwmsClient.postCorps(postThrCorpRequest); } @Async public void postInvPi(PostThrInvProductsRequest postThrInvProductsRequest) { - new UdiwmsClient(udiwmsIp).postInvProducts(postThrInvProductsRequest); + udiwmsClient.postInvProducts(postThrInvProductsRequest); } @Async public void postOrders(PostFileThrOrderRequest postFileThrOrderRequest) { - new UdiwmsClient(udiwmsIp).postOrderDetail(postFileThrOrderRequest); + udiwmsClient.postOrderDetail(postFileThrOrderRequest); } } diff --git a/api-sync/src/main/java/com/glxp/mipsdl/admin/util/HttpClient.java b/api-sync/src/main/java/com/glxp/mipsdl/admin/util/HttpClient.java index 348389b..9d9ea4c 100644 --- a/api-sync/src/main/java/com/glxp/mipsdl/admin/util/HttpClient.java +++ b/api-sync/src/main/java/com/glxp/mipsdl/admin/util/HttpClient.java @@ -30,10 +30,9 @@ public class HttpClient { public static String postJson(String url, Object object) { SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); factory.setConnectTimeout(600000); - factory.setReadTimeout(20000); + factory.setReadTimeout(600000); RestTemplate restTemplate = new RestTemplate(factory); String json = JSONObject.toJSON(object).toString(); -// logger.info(url + "\n" + json); HttpHeaders headers = new HttpHeaders(); headers.add("Content-Type", "application/json"); HttpEntity httpEntity = new HttpEntity<>(json, headers); @@ -42,4 +41,18 @@ public class HttpClient { return response; } + + public static String postJson(String url, Object object, HttpHeaders headers) { + SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); + factory.setConnectTimeout(600000); + factory.setReadTimeout(600000); + RestTemplate restTemplate = new RestTemplate(factory); + String json = JSONObject.toJSON(object).toString(); + logger.info(url + "\n" + json); + HttpEntity httpEntity = new HttpEntity<>(json, headers); + String response = restTemplate.postForObject(url, httpEntity, String.class); + logger.info(response); + return response; + } + } diff --git a/api-sync/src/main/resources/application-pro.properties b/api-sync/src/main/resources/application-pro.properties index ea8fa01..e2240fa 100644 --- a/api-sync/src/main/resources/application-pro.properties +++ b/api-sync/src/main/resources/application-pro.properties @@ -1,10 +1,10 @@ # 本地环境 server.port=9997 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver -spring.datasource.jdbc-url=jdbc:mysql://192.168.235.137:33306/udiwms_erp?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true -#spring.datasource.jdbc-url=jdbc:mysql://127.0.0.1:3306/udiwms_new?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true +#spring.datasource.jdbc-url=jdbc:mysql://192.168.235.137:33306/udiwms_erp?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true +spring.datasource.jdbc-url=jdbc:mysql://127.0.0.1:3306/udiwms?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true spring.datasource.username=root -spring.datasource.password=root +spring.datasource.password=123456 #spring.datasource.password=89083fb2fc145533 logging.level.com.glxp.mipsdl.admin.dao=debug #logging.level.com.glxp.mipsdl.admin.barcode=debug @@ -24,6 +24,8 @@ server.connectionTimeout=180000 #udi管理系统IP地址(上传文件解析后回传) UDIWMS_IP=http://192.168.0.109:9991 #UDIWMS_IP=http://139.159.187.130/UDI_WMS_MC +API_KEY=1102 +API_SECRET=4dc07484afd34e8083ba96e8fe564224 #文件导入 #0.NULL(空,未配置),1.GLXP(自定义规范标准),2.ZHIYE_V1(智业V1,诏安医院),3.YG_UDPLAT_V1(阳光采购平台) FILE_VERSION_FLAG=ZHIYE_V1 diff --git a/api-sync/src/main/resources/mybatis/mapper/system/ScheduleDao.xml b/api-sync/src/main/resources/mybatis/mapper/system/ScheduleDao.xml index 05451e7..fc40236 100644 --- a/api-sync/src/main/resources/mybatis/mapper/system/ScheduleDao.xml +++ b/api-sync/src/main/resources/mybatis/mapper/system/ScheduleDao.xml @@ -6,25 +6,24 @@ - insert INTO scheduled - (cronName,cron,customerId) - values - ( - #{cronName}, - #{cron}, - #{customerId} - ) + insert INTO sys_scheduled + (cronName, cron, customerId) + values (#{cronName}, + #{cron}, + #{customerId}) - delete from scheduled where id = #{id} + delete + from sys_scheduled + where id = #{id}