diff --git a/src/main/java/com/glxp/api/http/ErpBasicClient.java b/src/main/java/com/glxp/api/http/ErpBasicClient.java index 899397936..b06b8a211 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 8989a265e..a3e2e14b9 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 00772815e..a3b533396 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 012c134ce..845fade20 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 ab6c58992..b32e30b7e 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 9377d0997..b2ec40905 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 a98b33a3e..ff921b2cb 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 cec12a306..80e18f1ee 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