From a58340e2e02f60190f23a4b133bc9cf6f2e01909 Mon Sep 17 00:00:00 2001 From: MrZhai Date: Wed, 16 Mar 2022 17:41:54 +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 | 3 +- .../sale/admin/dao/thrsys/ThrProductsDao.java | 7 ++++ .../basic/UdiRelevanceExportJsonResponse.java | 5 +++ .../impl/UdiInfoImportDetailServiceImpl.java | 7 ++++ .../admin/thread/BasicGenExcelService.java | 32 +++++++++++++++++-- .../mybatis/mapper/thrsys/ThrProductsDao.xml | 28 ++++++++++++++++ 6 files changed, 78 insertions(+), 4 deletions(-) diff --git a/api-admin/src/main/java/com/glxp/sale/admin/controller/basic/UdiInfoImportLogController.java b/api-admin/src/main/java/com/glxp/sale/admin/controller/basic/UdiInfoImportLogController.java index 1e29e1d..b021f57 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/controller/basic/UdiInfoImportLogController.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/controller/basic/UdiInfoImportLogController.java @@ -1,7 +1,6 @@ package com.glxp.sale.admin.controller.basic; import cn.hutool.core.io.IoUtil; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.github.pagehelper.PageInfo; @@ -136,7 +135,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/sale/admin/dao/thrsys/ThrProductsDao.java b/api-admin/src/main/java/com/glxp/sale/admin/dao/thrsys/ThrProductsDao.java index e4db410..e5918fd 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/dao/thrsys/ThrProductsDao.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/dao/thrsys/ThrProductsDao.java @@ -31,4 +31,11 @@ public interface ThrProductsDao { * @param thrProductsEntities */ void importThrProducts(@Param("thrProductsEntities") List thrProductsEntities); + + /** + * 批量导入第三方产品信息 + * + * @param thrProductsEntities + */ + void importThrProductss(@Param("thrProductsEntities") List thrProductsEntities); } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/res/basic/UdiRelevanceExportJsonResponse.java b/api-admin/src/main/java/com/glxp/sale/admin/res/basic/UdiRelevanceExportJsonResponse.java index 71cee04..ec526f3 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/res/basic/UdiRelevanceExportJsonResponse.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/res/basic/UdiRelevanceExportJsonResponse.java @@ -3,6 +3,7 @@ package com.glxp.sale.admin.res.basic; import com.glxp.sale.admin.entity.basic.UdiInfoEntity; import com.glxp.sale.admin.entity.basic.UdiRelevanceEntity; import com.glxp.sale.admin.entity.info.CompanyProductRelevanceEntity; +import com.glxp.sale.admin.entity.thrsys.ThrProductsEntity; import lombok.Data; import java.util.ArrayList; @@ -18,10 +19,14 @@ public class UdiRelevanceExportJsonResponse { List udiRelevanceEntities; + //第三方产品信息 + List thrProductsEntities; + public UdiRelevanceExportJsonResponse() { this.udiInfoEntities = new ArrayList<>(); this.udiRelevanceEntities = new ArrayList<>(); this.companyProductRelevanceEntities = new ArrayList<>(); + this.thrProductsEntities = new ArrayList<>(); } private List companyProductRelevanceEntities; diff --git a/api-admin/src/main/java/com/glxp/sale/admin/service/basic/impl/UdiInfoImportDetailServiceImpl.java b/api-admin/src/main/java/com/glxp/sale/admin/service/basic/impl/UdiInfoImportDetailServiceImpl.java index a594ba1..0904dc0 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/service/basic/impl/UdiInfoImportDetailServiceImpl.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/service/basic/impl/UdiInfoImportDetailServiceImpl.java @@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper; import com.glxp.sale.admin.dao.basic.UdiInfoDao; import com.glxp.sale.admin.dao.basic.UdiInfoImportDetailDao; import com.glxp.sale.admin.dao.basic.UdiRelevanceDao; +import com.glxp.sale.admin.dao.thrsys.ThrProductsDao; import com.glxp.sale.admin.entity.basic.UdiInfoImportDetailEntity; import com.glxp.sale.admin.req.basic.FilterUdiIpLogRequest; import com.glxp.sale.admin.res.basic.UdiRelevanceExportJsonResponse; @@ -24,6 +25,8 @@ public class UdiInfoImportDetailServiceImpl implements UdiInfoImportDetailServic UdiInfoDao udiInfoDao; @Resource UdiRelevanceDao udiRelevanceDao; + @Resource + ThrProductsDao thrProductsDao; @Override public List filterUdiInfoImport(FilterUdiIpLogRequest filterInCodeLogRequest) { @@ -74,5 +77,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/sale/admin/thread/BasicGenExcelService.java b/api-admin/src/main/java/com/glxp/sale/admin/thread/BasicGenExcelService.java index 15d4192..bd52e3b 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/thread/BasicGenExcelService.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/thread/BasicGenExcelService.java @@ -3,16 +3,19 @@ package com.glxp.sale.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.sale.admin.constant.BasicProcessStatus; import com.glxp.sale.admin.constant.ConstantStatus; -import com.glxp.sale.admin.constant.UdiInfoImportStatus; import com.glxp.sale.admin.dao.basic.UdiInfoDao; import com.glxp.sale.admin.dao.basic.UdiRelevanceDao; +import com.glxp.sale.admin.dao.thrsys.ThrProductsDao; import com.glxp.sale.admin.entity.basic.*; import com.glxp.sale.admin.entity.info.CompanyProductRelevanceEntity; +import com.glxp.sale.admin.entity.thrsys.ThrProductsEntity; import com.glxp.sale.admin.req.basic.*; import com.glxp.sale.admin.req.info.FilterCompanyProductRelevanceRequest; +import com.glxp.sale.admin.req.thrsys.FilterThrProductsRequest; import com.glxp.sale.admin.res.basic.UdiExportJsonResponse; import com.glxp.sale.admin.res.basic.UdiRelevanceExportJsonResponse; import com.glxp.sale.admin.res.basic.UdiRelevanceResponse; @@ -21,13 +24,13 @@ import com.glxp.sale.admin.service.info.CompanyProductRelevanceService; import com.glxp.sale.admin.util.ExcelUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; -import org.springframework.context.annotation.Bean; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.io.File; import java.io.IOException; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -52,6 +55,8 @@ public class BasicGenExcelService { UdiInfoDao udiInfoDao; @Resource private CompanyProductRelevanceService companyProductRelevanceService; + @Resource + ThrProductsDao thrProductsDao; //往来单位 @Async @@ -364,6 +369,29 @@ public class BasicGenExcelService { }); 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/resources/mybatis/mapper/thrsys/ThrProductsDao.xml b/api-admin/src/main/resources/mybatis/mapper/thrsys/ThrProductsDao.xml index 4fc5f96..e2ece23 100644 --- a/api-admin/src/main/resources/mybatis/mapper/thrsys/ThrProductsDao.xml +++ b/api-admin/src/main/resources/mybatis/mapper/thrsys/ThrProductsDao.xml @@ -138,4 +138,32 @@ #{item.thirdSysFk}, #{item.updateTime}, #{item.supName}) + + + 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