From 9d029392da8579337918b330ccdd0b86af49c4ca Mon Sep 17 00:00:00 2001 From: liyawei Date: Wed, 3 Aug 2022 16:13:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A4=E8=AF=81-=E4=B8=8A=E6=8A=A5=E5=BA=93-?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=A1=B9=E6=9F=A5=E7=9C=8B-=E4=BF=9D?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ParamsReportDetailEOController.java | 6 +- .../service/IParamsReportConfigEOService.java | 13 +- .../service/IParamsReportDetailEOService.java | 3 + .../impl/ParamsReportConfigEOServiceImpl.java | 122 ------------------ .../impl/ParamsReportDetailEOServiceImpl.java | 97 ++++++++++++++ 5 files changed, 105 insertions(+), 136 deletions(-) diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/controller/ParamsReportDetailEOController.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/controller/ParamsReportDetailEOController.java index ce59f6900..0a0b444a8 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/controller/ParamsReportDetailEOController.java +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/controller/ParamsReportDetailEOController.java @@ -205,11 +205,11 @@ public class ParamsReportDetailEOController extends JeroController save(@RequestBody ParamsReportDetailVO paramsReportDetailVO) { - boolean isSuccess = paramsReportConfigEOService.save(paramsReportDetailVO.getConfigDataList(), paramsReportDetailVO.getParamsManifestId()); + boolean isSuccess = paramsReportDetailEOService.save(paramsReportDetailVO.getConfigDataList(), paramsReportDetailVO.getParamsManifestId()); if (isSuccess) { - return Result.OK("暂存成功!"); + return Result.OK("保存成功!"); } else { - return Result.error("暂存失败!"); + return Result.error("保存失败!"); } } diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/service/IParamsReportConfigEOService.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/service/IParamsReportConfigEOService.java index 649b427d0..076a08978 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/service/IParamsReportConfigEOService.java +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/service/IParamsReportConfigEOService.java @@ -1,9 +1,9 @@ package com.jero.modules.cert.report.service; -import com.jero.modules.cert.report.entity.ParamsReportConfigEO; import com.baomidou.mybatisplus.extension.service.IService; +import com.jero.modules.cert.report.entity.ParamsReportConfigEO; + import java.util.List; -import java.util.Map; /** * @Description: 上报库参数配置 @@ -19,13 +19,4 @@ public interface IParamsReportConfigEOService extends IService queryList(String paramsManifestId); - - /** - * 保存 - * @param configDataList - * @param paramsManifestId - * @return - */ - boolean save(List> configDataList, String paramsManifestId); - } diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/service/IParamsReportDetailEOService.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/service/IParamsReportDetailEOService.java index 551b001b1..9f377b597 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/service/IParamsReportDetailEOService.java +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/service/IParamsReportDetailEOService.java @@ -56,4 +56,7 @@ public interface IParamsReportDetailEOService extends IService> configDataList, String paramsManifestId); + } diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/service/impl/ParamsReportConfigEOServiceImpl.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/service/impl/ParamsReportConfigEOServiceImpl.java index edb2fe3d2..23af1d970 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/service/impl/ParamsReportConfigEOServiceImpl.java +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/service/impl/ParamsReportConfigEOServiceImpl.java @@ -1,28 +1,13 @@ package com.jero.modules.cert.report.service.impl; -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.jero.modules.cert.collect.entity.ParamsConfigDataEO; -import com.jero.modules.cert.collect.entity.ParamsConfigEO; -import com.jero.modules.cert.collect.enums.ConfigDataTypeEnum; -import com.jero.modules.cert.report.entity.ParamsReportConfigDataEO; import com.jero.modules.cert.report.entity.ParamsReportConfigEO; import com.jero.modules.cert.report.mapper.ParamsReportConfigEOMapper; -import com.jero.modules.cert.report.service.IParamsReportConfigDataEOService; import com.jero.modules.cert.report.service.IParamsReportConfigEOService; -import com.jero.modules.oss.entity.OSSFile; -import com.jero.modules.oss.service.IOSSFileService; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.ArrayList; import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.stream.Collectors; /** * @Description: 上报库参数配置 @@ -33,15 +18,6 @@ import java.util.stream.Collectors; @Service public class ParamsReportConfigEOServiceImpl extends ServiceImpl implements IParamsReportConfigEOService { - @Autowired - private IOSSFileService ossFileService; - - @Autowired - private IParamsReportConfigEOService paramsReportConfigEOService; - - @Autowired - private IParamsReportConfigDataEOService paramsReportConfigDataEOService; - /** * 列表查询 * @@ -55,102 +31,4 @@ public class ParamsReportConfigEOServiceImpl extends ServiceImpl list = list(queryWrapper); return list; } - - @Override - public boolean save(List> configDataList, String paramsManifestId) { - List newConfigDataEOList = new ArrayList<>(); - List paramsReportConfigEOList = paramsReportConfigEOService.queryList(paramsManifestId); // 查询配置列 - List paramsReportConfigIdList = paramsReportConfigEOList.stream().map(ParamsConfigEO::getId).collect(Collectors.toList()); - List paramsReportConfigDataEOList = paramsReportConfigDataEOService.queryListByConfigIdList(paramsReportConfigIdList); // 查询所有配置数据 - - // 处理数据 - for (Map map : configDataList) { - String paramsCollectManifestId = (String) map.get("id"); - - // 添加配置数据 - for (Map.Entry entry : map.entrySet()) { - ParamsReportConfigDataEO paramsReportConfigDataEO = new ParamsReportConfigDataEO(); - if ("id".equals(entry.getKey())) { - continue; - } - - // 取值 - String paramsReportConfigEOId = entry.getKey(); - Map paramsReportConfigDataMap = (Map) entry.getValue(); - // 无法转ParamsConfigDataVO(遍历会出现该异常 : LinkedHashMap cannot be cast to ParamsConfigDataVO) - List> configDataVOList = (List>) paramsReportConfigDataMap.get("list"); - - // 判断是新增还是修改 - ParamsConfigDataEO oldConfigDataEO = getConfigDataEOByConfigIdAndCollectManifestId(paramsReportConfigEOId, paramsCollectManifestId, paramsReportConfigDataEOList); - if (ObjectUtil.isNotEmpty(oldConfigDataEO)) { - paramsReportConfigDataEO.setId(oldConfigDataEO.getId()); - - } - paramsReportConfigDataEO.setParamsCollectManifestId(paramsCollectManifestId); - paramsReportConfigDataEO.setParamsConfigId(paramsReportConfigEOId); - if (CollectionUtil.isNotEmpty(configDataVOList)) { - for (Map paramsConfigDataVO : configDataVOList) { - String type = (String) paramsConfigDataVO.get("type"); - String dataValue = (String) paramsConfigDataVO.get("dataValue"); - - if (type.equals(ConfigDataTypeEnum.TEXT.getValue())) { - paramsReportConfigDataEO.setTextData(dataValue); - - } else if (type.equals(ConfigDataTypeEnum.PULL.getValue()) - || type.equals(ConfigDataTypeEnum.PULL_MORE.getValue())) { - paramsReportConfigDataEO.setPullData(dataValue); - - } else if (type.equals(ConfigDataTypeEnum.FILE.getValue())) { - if (StringUtils.isNotEmpty(dataValue) && dataValue.contains(",")) { // 新加多个文件 - // 处理文件connectId - String[] fileIdList = dataValue.split(","); - String connectId = UUID.randomUUID().toString().replace("-", ""); - List updateFileList = new ArrayList<>(); - for (int i = 0; i < fileIdList.length; i++) { - OSSFile ossFile = new OSSFile(); - ossFile.setId(fileIdList[i]); - ossFile.setConnectId(connectId); - updateFileList.add(ossFile); - } - ossFileService.updateBatchById(updateFileList); - dataValue = connectId; - } else if (StringUtils.isNotEmpty(dataValue) && !dataValue.contains(",")) { - List ossFiles = ossFileService.getFileInfosByConnectId(dataValue); - if(CollectionUtil.isEmpty(ossFiles)){ // 新加了一个文件 - String connectId = UUID.randomUUID().toString().replace("-", ""); - //修改文件表关联信息connect_id - List oSSFileList = new ArrayList<>(); - for (String fileId : dataValue.split(",")) { - OSSFile ossFile = new OSSFile(); - ossFile.setId(fileId); - ossFile.setConnectId(connectId); - oSSFileList.add(ossFile); - } - ossFileService.updateFileInfo(oSSFileList); - dataValue = connectId; - } - } - paramsReportConfigDataEO.setFileConnectId(dataValue); - - } - } - } - newConfigDataEOList.add(paramsReportConfigDataEO); - } - } - - // 批量更新 - return paramsReportConfigDataEOService.saveOrUpdateBatch(newConfigDataEOList); - } - - private ParamsReportConfigDataEO getConfigDataEOByConfigIdAndCollectManifestId(String configId, String collectManifestId, List paramsReportConfigDataEOList) { - List configDataEOList = paramsReportConfigDataEOList.stream() - .filter(e-> configId.equals(e.getParamsConfigId()) && collectManifestId.equals(e.getParamsCollectManifestId())) - .collect(Collectors.toList()); - if (CollectionUtil.isNotEmpty(configDataEOList)) { - return configDataEOList.get(0); - } - return null; - } - } diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/service/impl/ParamsReportDetailEOServiceImpl.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/service/impl/ParamsReportDetailEOServiceImpl.java index 2ca1a4003..0330b1067 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/service/impl/ParamsReportDetailEOServiceImpl.java +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/service/impl/ParamsReportDetailEOServiceImpl.java @@ -1368,6 +1368,103 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl> configDataList, String paramsManifestId) { + List newConfigDataEOList = new ArrayList<>(); + List paramsReportConfigEOList = paramsReportConfigEOService.queryList(paramsManifestId); // 查询配置列 + List paramsReportConfigIdList = paramsReportConfigEOList.stream().map(ParamsConfigEO::getId).collect(Collectors.toList()); + List paramsReportConfigDataEOList = paramsReportConfigDataEOService.queryListByConfigIdList(paramsReportConfigIdList); // 查询所有配置数据 + + // 处理数据 + for (Map map : configDataList) { + String paramsCollectManifestId = (String) map.get("id"); + + // 添加配置数据 + for (Map.Entry entry : map.entrySet()) { + ParamsReportConfigDataEO paramsReportConfigDataEO = new ParamsReportConfigDataEO(); + if ("id".equals(entry.getKey())) { + continue; + } + + // 取值 + String paramsReportConfigEOId = entry.getKey(); + Map paramsReportConfigDataMap = (Map) entry.getValue(); + // 无法转ParamsConfigDataVO(遍历会出现该异常 : LinkedHashMap cannot be cast to ParamsConfigDataVO) + List> configDataVOList = (List>) paramsReportConfigDataMap.get("list"); + + // 判断是新增还是修改 + ParamsConfigDataEO oldConfigDataEO = getConfigDataEOByConfigIdAndCollectManifestId(paramsReportConfigEOId, paramsCollectManifestId, paramsReportConfigDataEOList); + if (ObjectUtil.isNotEmpty(oldConfigDataEO)) { + paramsReportConfigDataEO.setId(oldConfigDataEO.getId()); + + } + paramsReportConfigDataEO.setParamsCollectManifestId(paramsCollectManifestId); + paramsReportConfigDataEO.setParamsConfigId(paramsReportConfigEOId); + if (CollectionUtil.isNotEmpty(configDataVOList)) { + for (Map paramsConfigDataVO : configDataVOList) { + String type = (String) paramsConfigDataVO.get("type"); + String dataValue = (String) paramsConfigDataVO.get("dataValue"); + + if (type.equals(ConfigDataTypeEnum.TEXT.getValue())) { + paramsReportConfigDataEO.setTextData(dataValue); + + } else if (type.equals(ConfigDataTypeEnum.PULL.getValue()) + || type.equals(ConfigDataTypeEnum.PULL_MORE.getValue())) { + paramsReportConfigDataEO.setPullData(dataValue); + + } else if (type.equals(ConfigDataTypeEnum.FILE.getValue())) { + if (StringUtils.isNotEmpty(dataValue) && dataValue.contains(",")) { // 新加多个文件 + // 处理文件connectId + String[] fileIdList = dataValue.split(","); + String connectId = UUID.randomUUID().toString().replace("-", ""); + List updateFileList = new ArrayList<>(); + for (int i = 0; i < fileIdList.length; i++) { + OSSFile ossFile = new OSSFile(); + ossFile.setId(fileIdList[i]); + ossFile.setConnectId(connectId); + updateFileList.add(ossFile); + } + ossFileService.updateBatchById(updateFileList); + dataValue = connectId; + } else if (StringUtils.isNotEmpty(dataValue) && !dataValue.contains(",")) { + List ossFiles = ossFileService.getFileInfosByConnectId(dataValue); + if(CollectionUtil.isEmpty(ossFiles)){ // 新加了一个文件 + String connectId = UUID.randomUUID().toString().replace("-", ""); + //修改文件表关联信息connect_id + List oSSFileList = new ArrayList<>(); + for (String fileId : dataValue.split(",")) { + OSSFile ossFile = new OSSFile(); + ossFile.setId(fileId); + ossFile.setConnectId(connectId); + oSSFileList.add(ossFile); + } + ossFileService.updateFileInfo(oSSFileList); + dataValue = connectId; + } + } + paramsReportConfigDataEO.setFileConnectId(dataValue); + + } + } + } + newConfigDataEOList.add(paramsReportConfigDataEO); + } + } + + // 批量更新 + return paramsReportConfigDataEOService.saveOrUpdateBatch(newConfigDataEOList); + } + + private ParamsReportConfigDataEO getConfigDataEOByConfigIdAndCollectManifestId(String configId, String collectManifestId, List paramsReportConfigDataEOList) { + List configDataEOList = paramsReportConfigDataEOList.stream() + .filter(e-> configId.equals(e.getParamsConfigId()) && collectManifestId.equals(e.getParamsCollectManifestId())) + .collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(configDataEOList)) { + return configDataEOList.get(0); + } + return null; + } + /** * 实体对象转成Map * @param obj 实体对象