From 971b8e2b5191daa4da8a5a3a62113ef74a8fdd59 Mon Sep 17 00:00:00 2001 From: MrZhai Date: Wed, 16 Mar 2022 17:41:07 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=8C=BB=E7=96=97=E5=99=A8=E6=A2=B0=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E5=AF=BC=E5=87=BA=E5=85=B3=E8=81=94=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=96=B9=E4=BA=A7=E5=93=81=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basic/UdiInfoImportLogController.java | 2 +- .../api/admin/dao/thrsys/ThrProductsDao.java | 7 +++++ .../basic/UdiRelevanceExportJsonResponse.java | 5 ++++ .../impl/UdiInfoImportDetailServiceImpl.java | 7 +++++ .../api/admin/thread/BasicGenJsonService.java | 30 +++++++++++++++++++ .../api/admin/thread/IoTransInoutService.java | 7 +++-- .../mybatis/mapper/thrsys/ThrProductsDao.xml | 28 +++++++++++++++++ 7 files changed, 83 insertions(+), 3 deletions(-) diff --git a/api-admin/src/main/java/com/glxp/api/admin/controller/basic/UdiInfoImportLogController.java b/api-admin/src/main/java/com/glxp/api/admin/controller/basic/UdiInfoImportLogController.java index 5488b2f0..83d173be 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/controller/basic/UdiInfoImportLogController.java +++ b/api-admin/src/main/java/com/glxp/api/admin/controller/basic/UdiInfoImportLogController.java @@ -130,7 +130,7 @@ public class UdiInfoImportLogController { String fileName = file.getOriginalFilename(); try { String fileType = fileName.substring(fileName.lastIndexOf(".")); - if (!".udi".equals(fileType.toLowerCase())) { + if (!".udi".equalsIgnoreCase(fileType)) { return ResultVOUtils.error(500, "请上传udi文件"); } //导入数据 diff --git a/api-admin/src/main/java/com/glxp/api/admin/dao/thrsys/ThrProductsDao.java b/api-admin/src/main/java/com/glxp/api/admin/dao/thrsys/ThrProductsDao.java index f9e4fb4a..ab7659e1 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/dao/thrsys/ThrProductsDao.java +++ b/api-admin/src/main/java/com/glxp/api/admin/dao/thrsys/ThrProductsDao.java @@ -24,4 +24,11 @@ public interface ThrProductsDao { boolean deleteById(@Param("id") String id); boolean deleteAll(); + + /** + * 批量导入第三方产品信息 + * + * @param thrProductsEntities + */ + void importThrProductss(@Param("thrProductsEntities") List thrProductsEntities); } diff --git a/api-admin/src/main/java/com/glxp/api/admin/res/basic/UdiRelevanceExportJsonResponse.java b/api-admin/src/main/java/com/glxp/api/admin/res/basic/UdiRelevanceExportJsonResponse.java index b6063ef4..68d9bee9 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/res/basic/UdiRelevanceExportJsonResponse.java +++ b/api-admin/src/main/java/com/glxp/api/admin/res/basic/UdiRelevanceExportJsonResponse.java @@ -2,6 +2,7 @@ package com.glxp.api.admin.res.basic; import com.glxp.api.admin.entity.basic.UdiInfoEntity; import com.glxp.api.admin.entity.basic.UdiRelevanceEntity; +import com.glxp.api.admin.entity.thrsys.ThrProductsEntity; import lombok.Data; import java.util.ArrayList; @@ -17,8 +18,12 @@ public class UdiRelevanceExportJsonResponse { List udiRelevanceEntities; + //第三方产品信息 + List thrProductsEntities; + public UdiRelevanceExportJsonResponse() { this.udiInfoEntities = new ArrayList<>(); this.udiRelevanceEntities = new ArrayList<>(); + this.thrProductsEntities = new ArrayList<>(); } } diff --git a/api-admin/src/main/java/com/glxp/api/admin/service/basic/impl/UdiInfoImportDetailServiceImpl.java b/api-admin/src/main/java/com/glxp/api/admin/service/basic/impl/UdiInfoImportDetailServiceImpl.java index 9f681962..6ac6262c 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/service/basic/impl/UdiInfoImportDetailServiceImpl.java +++ b/api-admin/src/main/java/com/glxp/api/admin/service/basic/impl/UdiInfoImportDetailServiceImpl.java @@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper; import com.glxp.api.admin.dao.basic.UdiInfoDao; import com.glxp.api.admin.dao.basic.UdiInfoImportDetailDao; import com.glxp.api.admin.dao.basic.UdiRelevanceDao; +import com.glxp.api.admin.dao.thrsys.ThrProductsDao; import com.glxp.api.admin.entity.basic.UdiInfoImportDetailEntity; import com.glxp.api.admin.req.basic.FilterUdiIpLogRequest; import com.glxp.api.admin.res.basic.UdiRelevanceExportJsonResponse; @@ -25,6 +26,8 @@ public class UdiInfoImportDetailServiceImpl implements UdiInfoImportDetailServic UdiInfoDao udiInfoDao; @Resource UdiRelevanceDao udiRelevanceDao; + @Resource + ThrProductsDao thrProductsDao; @Override public List filterUdiInfoImport(FilterUdiIpLogRequest filterInCodeLogRequest) { @@ -76,5 +79,9 @@ public class UdiInfoImportDetailServiceImpl implements UdiInfoImportDetailServic if (CollUtil.isNotEmpty(udiRelevanceExportJsonResponse.getUdiRelevanceEntities())) { udiRelevanceDao.importUdiRelevance(udiRelevanceExportJsonResponse.getUdiRelevanceEntities()); } + + if (CollUtil.isNotEmpty(udiRelevanceExportJsonResponse.getThrProductsEntities())) { + thrProductsDao.importThrProductss(udiRelevanceExportJsonResponse.getThrProductsEntities()); + } } } diff --git a/api-admin/src/main/java/com/glxp/api/admin/thread/BasicGenJsonService.java b/api-admin/src/main/java/com/glxp/api/admin/thread/BasicGenJsonService.java index 8f252223..48d35f17 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/thread/BasicGenJsonService.java +++ b/api-admin/src/main/java/com/glxp/api/admin/thread/BasicGenJsonService.java @@ -3,15 +3,19 @@ package com.glxp.api.admin.thread; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.io.file.FileWriter; +import cn.hutool.core.util.ReflectUtil; import cn.hutool.json.JSONUtil; import com.glxp.api.admin.constant.BasicProcessStatus; import com.glxp.api.admin.dao.basic.UdiInfoDao; import com.glxp.api.admin.dao.basic.UdiRelevanceDao; +import com.glxp.api.admin.dao.thrsys.ThrProductsDao; import com.glxp.api.admin.entity.basic.*; +import com.glxp.api.admin.entity.thrsys.ThrProductsEntity; import com.glxp.api.admin.req.basic.BasicUnitMaintainFilterRequest; import com.glxp.api.admin.req.basic.CorpsExportRequest; import com.glxp.api.admin.req.basic.FilterUdiInfoRequest; import com.glxp.api.admin.req.basic.UdiInfoExportRequest; +import com.glxp.api.admin.req.thrsys.FilterThrProductsRequest; import com.glxp.api.admin.res.basic.UdiRelevanceExportJsonResponse; import com.glxp.api.admin.res.basic.UdiRelevanceResponse; import com.glxp.api.admin.service.basic.BasicUnitMaintainService; @@ -25,6 +29,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.io.File; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; @@ -44,6 +49,8 @@ public class BasicGenJsonService { UdiRelevanceDao udiRelevanceDao; @Resource UdiInfoDao udiInfoDao; + @Resource + ThrProductsDao thrProductsDao; public void exportCorp(String genKey, CorpsExportRequest corpsExportRequest) { @@ -135,6 +142,29 @@ public class BasicGenJsonService { }); List udiInfoEntities = udiInfoDao.batchSelectByUuid(uuids); List udiRelevanceEntities = udiRelevanceDao.batchSelectByUuid(uuids); + if (CollUtil.isNotEmpty(udiRelevanceEntities)) { + List thrProductsEntities = new ArrayList<>(udiRelevanceEntities.size()); + Field[] fields = ReflectUtil.getFields(UdiRelevanceEntity.class); + udiRelevanceEntities.forEach(udiRelevanceEntity -> { + for (Field field : fields) { + if (field.getName().contains("thirdId")) { + Object fieldValue = ReflectUtil.getFieldValue(udiRelevanceEntity, field); + if (null != fieldValue) { + FilterThrProductsRequest filter = new FilterThrProductsRequest(); + filter.setCode(String.valueOf(fieldValue)); + filter.setThirdSysFk("thirdId"); + List result = thrProductsDao.filterThrProductsRequest(filter); + if (CollUtil.isNotEmpty(result)) { + thrProductsEntities.addAll(result); + } + } + } + } + }); + if (CollUtil.isNotEmpty(thrProductsEntities)) { + exportData.setThrProductsEntities(thrProductsEntities); + } + } List udiInfo = exportData.getUdiInfoEntities(); List udiRelevance = exportData.getUdiRelevanceEntities(); udiInfo.addAll(udiInfoEntities); diff --git a/api-admin/src/main/java/com/glxp/api/admin/thread/IoTransInoutService.java b/api-admin/src/main/java/com/glxp/api/admin/thread/IoTransInoutService.java index 5061ab00..228b9f78 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/thread/IoTransInoutService.java +++ b/api-admin/src/main/java/com/glxp/api/admin/thread/IoTransInoutService.java @@ -10,7 +10,6 @@ import com.glxp.api.admin.controller.inout.utils.InoutUtils; import com.glxp.api.admin.entity.basic.*; import com.glxp.api.admin.entity.business.StockOrderDetailEntity; import com.glxp.api.admin.entity.business.StockOrderEntity; -import com.glxp.api.admin.entity.info.CompanyEntity; import com.glxp.api.admin.entity.inout.ErpOrderEntity; import com.glxp.api.admin.entity.inout.FilterErpOrderRequest; import com.glxp.api.admin.entity.inout.OrderEntity; @@ -160,7 +159,11 @@ public class IoTransInoutService { orderSaveRequest.setErpFk(docidStr); } } - orderService.insertOrder(orderSaveRequest); + try { + orderService.insertOrder(orderSaveRequest); + } catch (Exception e) { + logger.error("插入订单数据异常", e); + } for (int index = 0; index < warehouseEntityList.size(); index++) { warehouseEntityList.get(index).setOrderId(orderId); } diff --git a/api-admin/src/main/resources/mybatis/mapper/thrsys/ThrProductsDao.xml b/api-admin/src/main/resources/mybatis/mapper/thrsys/ThrProductsDao.xml index efc0b46c..fbad63dc 100644 --- a/api-admin/src/main/resources/mybatis/mapper/thrsys/ThrProductsDao.xml +++ b/api-admin/src/main/resources/mybatis/mapper/thrsys/ThrProductsDao.xml @@ -143,4 +143,32 @@ DELETE FROM thr_products + + + replace into thr_products (id, code, name, measname, spec, registerNo, manufactory, thirdSysFk, cplb, flbm, + qxlb, ybbm, sptm, tyshxydm, zczbhhzbapzbh, ylqxzcrbarmc, ylqxzcrbarywmc, cpms, + updateTime, supName) VALUES + + (#{item.id}, + #{item.code}, + #{item.name}, + #{item.measname}, + #{item.spec}, + #{item.registerNo}, + #{item.manufactory}, + #{item.thirdSysFk}, + #{item.cplb}, + #{item.flbm}, + #{item.qxlb}, + #{item.ybbm}, + #{item.sptm}, + #{item.tyshxydm}, + #{item.zczbhhzbapzbh}, + #{item.ylqxzcrbarmc}, + #{item.ylqxzcrbarywmc}, + #{item.cpms}, + #{item.updateTime}, + #{item.supName}) + + \ No newline at end of file