From a0d6f3cc06117f789a86cfba3df84e70b816e1d4 Mon Sep 17 00:00:00 2001 From: x_z Date: Fri, 21 Apr 2023 11:20:20 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E5=A4=8D=E4=B8=B4=E6=97=B6=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=AD=98=E5=82=A8=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= =?UTF-8?q?=202.=E4=BF=AE=E6=94=B9=E4=B8=8B=E8=BD=BD=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E6=96=B9=E7=B3=BB=E7=BB=9F=E5=9F=BA=E7=A1=80=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=A0=A1=E9=AA=8C=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/glxp/api/http/ErpBasicClient.java | 19 +++++++------------ .../service/thrsys/ThrProductsService.java | 9 +++++++++ .../impl/ThrBusTypeOriginServiceImpl.java | 14 ++++++++++++++ .../thrsys/impl/ThrCorpServiceImpl.java | 7 +++++++ .../impl/ThrInvWarehouseServiceImpl.java | 2 ++ .../thrsys/impl/ThrProductsServiceImpl.java | 7 +++++++ .../glxp/api/task/ThirdSysInterfaceTask.java | 10 +++++++++- src/main/resources/application.yml | 1 + 8 files changed, 56 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/glxp/api/http/ErpBasicClient.java b/src/main/java/com/glxp/api/http/ErpBasicClient.java index 89939793..b06b8a21 100644 --- a/src/main/java/com/glxp/api/http/ErpBasicClient.java +++ b/src/main/java/com/glxp/api/http/ErpBasicClient.java @@ -174,18 +174,13 @@ public class ErpBasicClient { Request request = new Request.Builder().url(url).post(multipartBody).build(); - try { - Response response = okHttpClient.newCall(request).execute(); - response.close(); - - if (response.code() == 200) { - return ResultVOUtils.success("解析成功"); - } else { - log.info("解析接口响应信息失败,返回信息:{}", response); - return ResultVOUtils.error(500, "解析第三方产品信息失败"); - } - } catch (Exception e) { - log.error("解析第三方产品信息失败", e); + Response response = okHttpClient.newCall(request).execute(); + response.close(); + + if (response.code() == 200) { + return ResultVOUtils.success("解析成功"); + } else { + log.info("解析接口响应信息失败,返回信息:{}", response); return ResultVOUtils.error(500, "解析第三方产品信息失败"); } } catch (Exception e) { diff --git a/src/main/java/com/glxp/api/service/thrsys/ThrProductsService.java b/src/main/java/com/glxp/api/service/thrsys/ThrProductsService.java index 8989a265..a3e2e14b 100644 --- a/src/main/java/com/glxp/api/service/thrsys/ThrProductsService.java +++ b/src/main/java/com/glxp/api/service/thrsys/ThrProductsService.java @@ -3,6 +3,7 @@ package com.glxp.api.service.thrsys; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.entity.thrsys.ThrProductsEntity; +import com.glxp.api.entity.thrsys.ThrSystemDetailEntity; import com.glxp.api.req.thrsys.FilterThrProductsRequest; import com.glxp.api.req.thrsys.PostThrProductsRequest; import com.glxp.api.res.thrsys.ThrProductsResponse; @@ -55,4 +56,12 @@ public interface ThrProductsService { * @return */ BaseResponse importUploadPi(PostThrProductsRequest postThrProductsRequest); + + /** + * 下载第三方产品信息 + * + * @param thrSystemDetailEntity + * @return + */ + BaseResponse downloadThrPi(ThrSystemDetailEntity thrSystemDetailEntity); } diff --git a/src/main/java/com/glxp/api/service/thrsys/impl/ThrBusTypeOriginServiceImpl.java b/src/main/java/com/glxp/api/service/thrsys/impl/ThrBusTypeOriginServiceImpl.java index 00772815..a3b53339 100644 --- a/src/main/java/com/glxp/api/service/thrsys/impl/ThrBusTypeOriginServiceImpl.java +++ b/src/main/java/com/glxp/api/service/thrsys/impl/ThrBusTypeOriginServiceImpl.java @@ -28,6 +28,7 @@ import javax.annotation.Resource; import java.util.Collections; import java.util.Date; import java.util.List; +import java.util.Objects; @Slf4j @Service @@ -187,6 +188,7 @@ public class ThrBusTypeOriginServiceImpl implements IThrBusTypeOriginService { } else { boolean isChange = verifyDataChange(thrBusTypeOriginEntity, item); if (isChange) { + thrBusTypeOriginEntity.setUpdateTime(new Date()); thrBusTypeOriginDao.updateById(thrBusTypeOriginEntity); } } @@ -213,6 +215,18 @@ public class ThrBusTypeOriginServiceImpl implements IThrBusTypeOriginService { * @return */ private boolean verifyDataChange(ThrBusTypeOriginEntity thrBusTypeOriginEntity, ThrSystemBusApiEntity thrSystemBusApi) { + if (!StrUtil.equals(thrBusTypeOriginEntity.getName(), thrSystemBusApi.getName())) { + thrBusTypeOriginEntity.setName(thrSystemBusApi.getName()); + return true; + } + if (!Objects.equals(thrBusTypeOriginEntity.getInoutType(), thrSystemBusApi.getInoutType())) { + thrBusTypeOriginEntity.setInoutType(thrSystemBusApi.getInoutType()); + return true; + } + if (!StrUtil.equals(thrBusTypeOriginEntity.getRemark(), thrSystemBusApi.getRemark())) { + thrBusTypeOriginEntity.setRemark(thrSystemBusApi.getRemark()); + return true; + } return false; } } diff --git a/src/main/java/com/glxp/api/service/thrsys/impl/ThrCorpServiceImpl.java b/src/main/java/com/glxp/api/service/thrsys/impl/ThrCorpServiceImpl.java index 012c134c..845fade2 100644 --- a/src/main/java/com/glxp/api/service/thrsys/impl/ThrCorpServiceImpl.java +++ b/src/main/java/com/glxp/api/service/thrsys/impl/ThrCorpServiceImpl.java @@ -158,24 +158,31 @@ public class ThrCorpServiceImpl implements ThrCorpService { */ private boolean verifyDataChange(ThrCorpEntity thrCorpEntity, ThrCorpsResponse thrCorpsResponse) { if (!StrUtil.equals(thrCorpEntity.getSpell(), thrCorpsResponse.getSpell())) { + thrCorpEntity.setSpell(thrCorpsResponse.getSpell()); return true; } if (!StrUtil.equals(thrCorpEntity.getAddr(), thrCorpsResponse.getAddr())) { + thrCorpEntity.setAddr(thrCorpsResponse.getAddr()); return true; } if (!StrUtil.equals(thrCorpEntity.getCreditNo(), thrCorpsResponse.getCreditNo())) { + thrCorpEntity.setContact(thrCorpsResponse.getCreditNo()); return true; } if (!StrUtil.equals(thrCorpEntity.getContact(), thrCorpsResponse.getContact())) { + thrCorpEntity.setContact(thrCorpsResponse.getContact()); return true; } if (!StrUtil.equals(thrCorpEntity.getMobile(), thrCorpsResponse.getMobile())) { + thrCorpEntity.setMobile(thrCorpsResponse.getMobile()); return true; } if (!StrUtil.equals(thrCorpEntity.getName(), thrCorpsResponse.getName())) { + thrCorpEntity.setName(thrCorpsResponse.getName()); return true; } if (!StrUtil.equals(thrCorpEntity.getRemark(), thrCorpsResponse.getRemark())) { + thrCorpEntity.setRemark(thrCorpsResponse.getRemark()); return true; } return false; diff --git a/src/main/java/com/glxp/api/service/thrsys/impl/ThrInvWarehouseServiceImpl.java b/src/main/java/com/glxp/api/service/thrsys/impl/ThrInvWarehouseServiceImpl.java index ab6c5899..b32e30b7 100644 --- a/src/main/java/com/glxp/api/service/thrsys/impl/ThrInvWarehouseServiceImpl.java +++ b/src/main/java/com/glxp/api/service/thrsys/impl/ThrInvWarehouseServiceImpl.java @@ -185,9 +185,11 @@ public class ThrInvWarehouseServiceImpl implements ThrInvWarehouseService { */ private boolean verifyDataChange(ThrInvWarehouseEntity thrInvWarehouseEntity, UdiwmsWarehouseDetail udiwmsWarehouseDetail) { if (!StrUtil.equals(thrInvWarehouseEntity.getName(), udiwmsWarehouseDetail.getName())) { + thrInvWarehouseEntity.setName(udiwmsWarehouseDetail.getName()); return true; } if (!StrUtil.equals(thrInvWarehouseEntity.getRemark(), udiwmsWarehouseDetail.getRemark())) { + thrInvWarehouseEntity.setRemark(udiwmsWarehouseDetail.getRemark()); return true; } return false; diff --git a/src/main/java/com/glxp/api/service/thrsys/impl/ThrProductsServiceImpl.java b/src/main/java/com/glxp/api/service/thrsys/impl/ThrProductsServiceImpl.java index 9377d099..b2ec4090 100644 --- a/src/main/java/com/glxp/api/service/thrsys/impl/ThrProductsServiceImpl.java +++ b/src/main/java/com/glxp/api/service/thrsys/impl/ThrProductsServiceImpl.java @@ -9,6 +9,7 @@ import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.util.ResultVOUtils; import com.glxp.api.dao.thrsys.ThrProductsDao; import com.glxp.api.entity.thrsys.ThrProductsEntity; +import com.glxp.api.entity.thrsys.ThrSystemDetailEntity; import com.glxp.api.http.ErpBasicClient; import com.glxp.api.req.thrsys.FilterThrProductsRequest; import com.glxp.api.req.thrsys.PostThrProductsRequest; @@ -157,4 +158,10 @@ public class ThrProductsServiceImpl implements ThrProductsService { return ResultVOUtils.success("第三方系统产品数据已插入到数据库"); } + @Override + public BaseResponse downloadThrPi(ThrSystemDetailEntity thrSystemDetailEntity) { + + return null; + } + } diff --git a/src/main/java/com/glxp/api/task/ThirdSysInterfaceTask.java b/src/main/java/com/glxp/api/task/ThirdSysInterfaceTask.java index a98b33a3..ff921b2c 100644 --- a/src/main/java/com/glxp/api/task/ThirdSysInterfaceTask.java +++ b/src/main/java/com/glxp/api/task/ThirdSysInterfaceTask.java @@ -140,7 +140,15 @@ public class ThirdSysInterfaceTask { * @param thrSystemDetailEntity */ private void downloadThrPi(ThrSystemDetailEntity thrSystemDetailEntity) { - + //校验任务并更新redis数据执行标识 + if (verifyTask(thrSystemDetailEntity)) { + getExecutor().submit(() -> { + log.info("开始下载第三方产品信息"); + thrProductsService.downloadThrPi(thrSystemDetailEntity); + updateTask(getTaskKey(thrSystemDetailEntity)); + log.info("第三方产品信息下载完成"); + }); + } } /** diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index cec12a30..80e18f1e 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -5,6 +5,7 @@ spring: enabled: false servlet: multipart: + enabled: true max-file-size: 200MB max-request-size: 200MB location: D:/tmp