From 137c94fc1e8601a5d953da2a7ae945aa1930f676 Mon Sep 17 00:00:00 2001 From: wangzhijiang <12345678> Date: Fri, 3 Feb 2023 13:47:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E6=8A=A5=E5=BA=93=E7=AE=A1=E7=90=86-?= =?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=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/ParamsReportDetailEOServiceImpl.java | 308 +++++++++++------- 1 file changed, 188 insertions(+), 120 deletions(-) diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/report/service/impl/ParamsReportDetailEOServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/report/service/impl/ParamsReportDetailEOServiceImpl.java index 858d70b32..8f3f5b766 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/report/service/impl/ParamsReportDetailEOServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/report/service/impl/ParamsReportDetailEOServiceImpl.java @@ -1766,133 +1766,201 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl paramsReportConfigDataMap = (Map) entry.getValue(); // 无法转ParamsConfigDataVO(遍历会出现该异常 : LinkedHashMap cannot be cast to ParamsConfigDataVO) - List> configDataVOList = (List>) paramsReportConfigDataMap.get("list"); + // List> configDataVOList = (List>) paramsReportConfigDataMap.get("list"); + + Map paramsConfigDataVOMap = (Map) paramsReportConfigDataMap.get("paramsConfigData"); + + for (Map.Entry paramsConfigDataMap : paramsConfigDataVOMap.entrySet()) { + String configDataId = paramsConfigDataMap.getKey(); + List> configDataVOList = (List>) paramsConfigDataMap.getValue(); + + if (CollectionUtil.isNotEmpty(configDataVOList)) { + Integer orderNum = (Integer) configDataVOList.get(0).get("orderNum"); + + ParamsReportConfigDataEO paramsReportConfigDataEO = new ParamsReportConfigDataEO(); + paramsReportConfigDataEO.setOrderNum(orderNum); + for (Map paramsConfigDataVO : configDataVOList) { + String type = (String) paramsConfigDataVO.get("type"); + String dataValue = (String) paramsConfigDataVO.get("dataValue"); + + // 判断是新增还是修改 + ParamsConfigDataEO oldConfigDataEO = getConfigDataEOByConfigIdAndCollectManifestId(paramsReportConfigEOId, paramsCollectManifestId, paramsReportConfigDataEOList,configDataId); + if (ObjectUtil.isNotEmpty(oldConfigDataEO)) { + paramsReportConfigDataEO.setId(oldConfigDataEO.getId()); + + if (type.equals(ConfigDataTypeEnum.TEXT.getValue())) { + // paramsReportConfigDataEO.setTextData(dataValue); + if (StringUtils.isEmpty(oldConfigDataEO.getTextData()) && StringUtils.isNotEmpty(dataValue)) { + logCnContent.append("\"").append("空").append("\"").append("改为").append("\"").append(dataValue).append("\"").append(","); + logEnContent.append(" from ").append("\"").append("Null").append("\"").append(" to ").append("\"").append(dataValue).append("\"").append(", "); + + changeFlag = true; + } else if (StringUtils.isNotEmpty(oldConfigDataEO.getTextData()) && StringUtils.isEmpty(dataValue)) { + logCnContent.append("\"").append(oldConfigDataEO.getTextData()).append("\"").append("改为").append("\"").append("空").append("\"").append(","); + logEnContent.append(" from ").append("\"").append(oldConfigDataEO.getTextData()).append("\"").append(" to ").append("\"").append("Null").append("\"").append(", "); + + changeFlag = true; + } else if (StringUtils.isNotEmpty(oldConfigDataEO.getTextData()) && StringUtils.isNotEmpty(dataValue) && !oldConfigDataEO.getTextData().equals(dataValue)) { + logCnContent.append("\"").append(oldConfigDataEO.getTextData()).append("\"").append("改为").append("\"").append(dataValue).append("\"").append(","); + logEnContent.append(" from ").append("\"").append(oldConfigDataEO.getTextData()).append("\"").append(" to ").append("\"").append(dataValue).append("\"").append(", "); + + changeFlag = true; + } + + } else if (type.equals(ConfigDataTypeEnum.PULL.getValue()) + || type.equals(ConfigDataTypeEnum.PULL_MORE.getValue())) { + // paramsReportConfigDataEO.setPullData(dataValue); + + if (StringUtils.isEmpty(oldConfigDataEO.getPullData()) && StringUtils.isNotEmpty(dataValue)) { + logCnContent.append("\"").append("空").append("\"").append("改为").append("\"").append(dataValue).append("\"").append(","); + logEnContent.append(" from ").append("\"").append("Null").append("\"").append(" to ").append("\"").append(dataValue).append("\"").append(", "); + + changeFlag = true; + } else if (StringUtils.isNotEmpty(oldConfigDataEO.getPullData()) && StringUtils.isEmpty(dataValue)) { + logCnContent.append("\"").append(oldConfigDataEO.getPullData()).append("\"").append("改为").append("\"").append("空").append("\"").append(","); + logEnContent.append(" from ").append("\"").append(oldConfigDataEO.getPullData()).append("\"").append(" to ").append("\"").append("Null").append("\"").append(", "); + + changeFlag = true; + } else if (StringUtils.isNotEmpty(oldConfigDataEO.getPullData()) && StringUtils.isNotEmpty(dataValue) && !oldConfigDataEO.getPullData().equals(dataValue)) { + logCnContent.append("\"").append(oldConfigDataEO.getPullData()).append("\"").append("改为").append("\"").append(dataValue).append("\"").append(","); + logEnContent.append(" from ").append("\"").append(oldConfigDataEO.getPullData()).append("\"").append(" to ").append("\"").append(dataValue).append("\"").append(", "); + + changeFlag = true; + } + + } else if (type.equals(ConfigDataTypeEnum.FILE.getValue())) { + String newFileNames = ""; + if (StringUtils.isNotEmpty(dataValue) && dataValue.contains(",")) { // 新加多个文件. 目前没用到这段代码 + // 处理文件connectId + String[] fileIdList = dataValue.split(","); + List ossFiles = ossFileService.getFileInfosByConnectId(fileIdList[0]); + if(CollectionUtil.isEmpty(ossFiles)) { // 新加了一个文件 + 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; + newFileNames = ossFileService.getFileInfosByConnectId(connectId).stream().map(OSSFile::getFileName).collect(Collectors.joining(",")); + } + } 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; + newFileNames = ossFileService.getFileInfosByConnectId(connectId).stream().map(OSSFile::getFileName).collect(Collectors.joining(",")); + } + } + // paramsReportConfigDataEO.setFileConnectId(dataValue); + if (StringUtils.isEmpty(oldConfigDataEO.getFileConnectId()) && StringUtils.isNotEmpty(dataValue)) { + logCnContent.append("\"").append("空").append("\"").append("改为").append("\"").append(newFileNames).append("\"").append(","); + logEnContent.append(" from ").append("\"").append("Null").append("\"").append(" to ").append("\"").append(newFileNames).append("\"").append(", "); + + changeFlag = true; + } else if (StringUtils.isNotEmpty(oldConfigDataEO.getFileConnectId()) && StringUtils.isEmpty(dataValue)) { + String oldFileNames = ossFileService.getFileInfosByConnectId(oldConfigDataEO.getFileConnectId()).stream().map(OSSFile::getFileName).collect(Collectors.joining(",")); + logCnContent.append("\"").append(oldFileNames).append("\"").append("改为").append("\"").append("空").append("\"").append(","); + logEnContent.append(" from ").append("\"").append(oldFileNames).append("\"").append(" to ").append("\"").append("Null").append("\"").append(", "); + + changeFlag = true; + } else if (StringUtils.isNotEmpty(oldConfigDataEO.getFileConnectId()) && StringUtils.isNotEmpty(dataValue)) { + String oldFileNames = ossFileService.getFileInfosByConnectId(oldConfigDataEO.getFileConnectId()).stream().map(OSSFile::getFileName).collect(Collectors.joining(",")); + if (!oldConfigDataEO.getFileConnectId().equals(dataValue)) { + logCnContent.append("\"").append(oldFileNames).append("\"").append("改为").append("\"").append(newFileNames).append("\"").append(","); + logEnContent.append(" from ").append("\"").append(oldFileNames).append("\"").append(" to ").append("\"").append(newFileNames).append("\"").append(", "); + + changeFlag = true; + } + + } + + } + } + + + + 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())) { + String newFileNames = ""; + if (StringUtils.isNotEmpty(dataValue) && dataValue.contains(",")) { // 新加多个文件. 目前没用到这段代码 + // 处理文件connectId + String[] fileIdList = dataValue.split(","); + List ossFiles = ossFileService.getFileInfosByConnectId(fileIdList[0]); + if(CollectionUtil.isEmpty(ossFiles)) { // 新加了一个文件 + 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; + newFileNames = ossFileService.getFileInfosByConnectId(connectId).stream().map(OSSFile::getFileName).collect(Collectors.joining(",")); + } + } 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; + newFileNames = ossFileService.getFileInfosByConnectId(connectId).stream().map(OSSFile::getFileName).collect(Collectors.joining(",")); + } + } + paramsReportConfigDataEO.setFileConnectId(dataValue); + } + } + + QueryWrapper removeConfigDataWrap = new QueryWrapper<>(); + removeConfigDataWrap.lambda().eq(ParamsReportConfigDataEO::getParamsConfigId,paramsReportConfigEOId); + removeConfigDataWrap.lambda().eq(ParamsReportConfigDataEO::getParamsCollectManifestId,paramsCollectManifestId); + this.paramsReportConfigDataEOService.remove(removeConfigDataWrap); + + paramsReportConfigDataEO.setParamsCollectManifestId(paramsCollectManifestId); + paramsReportConfigDataEO.setParamsConfigId(paramsReportConfigEOId); + + newConfigDataEOList.add(paramsReportConfigDataEO); + } - // 判断是新增还是修改 - ParamsConfigDataEO oldConfigDataEO = getConfigDataEOByConfigIdAndCollectManifestId(paramsReportConfigEOId, paramsCollectManifestId, paramsReportConfigDataEOList); - if (ObjectUtil.isNotEmpty(oldConfigDataEO)) { - paramsReportConfigDataEO.setId(oldConfigDataEO.getId()); } + + logCnContent.append(paramsReportConfigEO.getConfigName()).append("的"); logEnContent.append(paramsReportConfigEO.getConfigName()); - 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); - if (StringUtils.isEmpty(oldConfigDataEO.getTextData()) && StringUtils.isNotEmpty(dataValue)) { - logCnContent.append("\"").append("空").append("\"").append("改为").append("\"").append(dataValue).append("\"").append(","); - logEnContent.append(" from ").append("\"").append("Null").append("\"").append(" to ").append("\"").append(dataValue).append("\"").append(", "); - - changeFlag = true; - } else if (StringUtils.isNotEmpty(oldConfigDataEO.getTextData()) && StringUtils.isEmpty(dataValue)) { - logCnContent.append("\"").append(oldConfigDataEO.getTextData()).append("\"").append("改为").append("\"").append("空").append("\"").append(","); - logEnContent.append(" from ").append("\"").append(oldConfigDataEO.getTextData()).append("\"").append(" to ").append("\"").append("Null").append("\"").append(", "); - - changeFlag = true; - } else if (StringUtils.isNotEmpty(oldConfigDataEO.getTextData()) && StringUtils.isNotEmpty(dataValue) && !oldConfigDataEO.getTextData().equals(dataValue)) { - logCnContent.append("\"").append(oldConfigDataEO.getTextData()).append("\"").append("改为").append("\"").append(dataValue).append("\"").append(","); - logEnContent.append(" from ").append("\"").append(oldConfigDataEO.getTextData()).append("\"").append(" to ").append("\"").append(dataValue).append("\"").append(", "); - - changeFlag = true; - } - - } else if (type.equals(ConfigDataTypeEnum.PULL.getValue()) - || type.equals(ConfigDataTypeEnum.PULL_MORE.getValue())) { - paramsReportConfigDataEO.setPullData(dataValue); - - if (StringUtils.isEmpty(oldConfigDataEO.getPullData()) && StringUtils.isNotEmpty(dataValue)) { - logCnContent.append("\"").append("空").append("\"").append("改为").append("\"").append(dataValue).append("\"").append(","); - logEnContent.append(" from ").append("\"").append("Null").append("\"").append(" to ").append("\"").append(dataValue).append("\"").append(", "); - - changeFlag = true; - } else if (StringUtils.isNotEmpty(oldConfigDataEO.getPullData()) && StringUtils.isEmpty(dataValue)) { - logCnContent.append("\"").append(oldConfigDataEO.getPullData()).append("\"").append("改为").append("\"").append("空").append("\"").append(","); - logEnContent.append(" from ").append("\"").append(oldConfigDataEO.getPullData()).append("\"").append(" to ").append("\"").append("Null").append("\"").append(", "); - - changeFlag = true; - } else if (StringUtils.isNotEmpty(oldConfigDataEO.getPullData()) && StringUtils.isNotEmpty(dataValue) && !oldConfigDataEO.getPullData().equals(dataValue)) { - logCnContent.append("\"").append(oldConfigDataEO.getPullData()).append("\"").append("改为").append("\"").append(dataValue).append("\"").append(","); - logEnContent.append(" from ").append("\"").append(oldConfigDataEO.getPullData()).append("\"").append(" to ").append("\"").append(dataValue).append("\"").append(", "); - - changeFlag = true; - } - - } else if (type.equals(ConfigDataTypeEnum.FILE.getValue())) { - String newFileNames = ""; - if (StringUtils.isNotEmpty(dataValue) && dataValue.contains(",")) { // 新加多个文件. 目前没用到这段代码 - // 处理文件connectId - String[] fileIdList = dataValue.split(","); - List ossFiles = ossFileService.getFileInfosByConnectId(fileIdList[0]); - if(CollectionUtil.isEmpty(ossFiles)) { // 新加了一个文件 - 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; - newFileNames = ossFileService.getFileInfosByConnectId(connectId).stream().map(OSSFile::getFileName).collect(Collectors.joining(",")); - } - } 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; - newFileNames = ossFileService.getFileInfosByConnectId(connectId).stream().map(OSSFile::getFileName).collect(Collectors.joining(",")); - } - } - paramsReportConfigDataEO.setFileConnectId(dataValue); - if (StringUtils.isEmpty(oldConfigDataEO.getFileConnectId()) && StringUtils.isNotEmpty(dataValue)) { - logCnContent.append("\"").append("空").append("\"").append("改为").append("\"").append(newFileNames).append("\"").append(","); - logEnContent.append(" from ").append("\"").append("Null").append("\"").append(" to ").append("\"").append(newFileNames).append("\"").append(", "); - - changeFlag = true; - } else if (StringUtils.isNotEmpty(oldConfigDataEO.getFileConnectId()) && StringUtils.isEmpty(dataValue)) { - String oldFileNames = ossFileService.getFileInfosByConnectId(oldConfigDataEO.getFileConnectId()).stream().map(OSSFile::getFileName).collect(Collectors.joining(",")); - logCnContent.append("\"").append(oldFileNames).append("\"").append("改为").append("\"").append("空").append("\"").append(","); - logEnContent.append(" from ").append("\"").append(oldFileNames).append("\"").append(" to ").append("\"").append("Null").append("\"").append(", "); - - changeFlag = true; - } else if (StringUtils.isNotEmpty(oldConfigDataEO.getFileConnectId()) && StringUtils.isNotEmpty(dataValue)) { - String oldFileNames = ossFileService.getFileInfosByConnectId(oldConfigDataEO.getFileConnectId()).stream().map(OSSFile::getFileName).collect(Collectors.joining(",")); - if (!oldConfigDataEO.getFileConnectId().equals(dataValue)) { - logCnContent.append("\"").append(oldFileNames).append("\"").append("改为").append("\"").append(newFileNames).append("\"").append(","); - logEnContent.append(" from ").append("\"").append(oldFileNames).append("\"").append(" to ").append("\"").append(newFileNames).append("\"").append(", "); - - changeFlag = true; - } - - } - - } - } - } - newConfigDataEOList.add(paramsReportConfigDataEO); - } ParamsReportDetailLogEO insertLogEO = new ParamsReportDetailLogEO(); /*if (logCnContent.toString().endsWith(",")) { @@ -1928,13 +1996,13 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl paramsReportConfigDataEOList) { + private ParamsReportConfigDataEO getConfigDataEOByConfigIdAndCollectManifestId(String configId, String collectManifestId, List paramsReportConfigDataEOList,String configDataId) { List configDataEOList = paramsReportConfigDataEOList.stream() - .filter(e-> configId.equals(e.getParamsConfigId()) && collectManifestId.equals(e.getParamsCollectManifestId())) + .filter(e-> configId.equals(e.getParamsConfigId()) && collectManifestId.equals(e.getParamsCollectManifestId()) && StringUtils.equals(configDataId,e.getId())) .collect(Collectors.toList()); if (CollectionUtil.isNotEmpty(configDataEOList)) { return configDataEOList.get(0);