上报库管理-参数项查看-保存接口修改。

This commit is contained in:
wangzhijiang
2023-02-03 13:47:40 +08:00
parent c6fcaaf773
commit 137c94fc1e
@@ -1766,133 +1766,201 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
continue;
}
ParamsReportConfigDataEO paramsReportConfigDataEO = new ParamsReportConfigDataEO();
// 取值
String paramsReportConfigEOId = entry.getKey();
ParamsReportConfigEO paramsReportConfigEO = paramsReportConfigEOService.getById(paramsReportConfigEOId);
Map<String, Object> paramsReportConfigDataMap = (Map<String, Object>) entry.getValue();
// 无法转ParamsConfigDataVO(遍历会出现该异常 LinkedHashMap cannot be cast to ParamsConfigDataVO
List<Map<String, Object>> configDataVOList = (List<Map<String, Object>>) paramsReportConfigDataMap.get("list");
// List<Map<String, Object>> configDataVOList = (List<Map<String, Object>>) paramsReportConfigDataMap.get("list");
Map<String, Object> paramsConfigDataVOMap = (Map<String, Object>) paramsReportConfigDataMap.get("paramsConfigData");
for (Map.Entry<String, Object> paramsConfigDataMap : paramsConfigDataVOMap.entrySet()) {
String configDataId = paramsConfigDataMap.getKey();
List<Map<String, Object>> configDataVOList = (List<Map<String, Object>>) paramsConfigDataMap.getValue();
if (CollectionUtil.isNotEmpty(configDataVOList)) {
Integer orderNum = (Integer) configDataVOList.get(0).get("orderNum");
ParamsReportConfigDataEO paramsReportConfigDataEO = new ParamsReportConfigDataEO();
paramsReportConfigDataEO.setOrderNum(orderNum);
for (Map<String, Object> 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<OSSFile> ossFiles = ossFileService.getFileInfosByConnectId(fileIdList[0]);
if(CollectionUtil.isEmpty(ossFiles)) { // 新加了一个文件
String connectId = UUID.randomUUID().toString().replace("-", "");
List<OSSFile> 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<OSSFile> ossFiles = ossFileService.getFileInfosByConnectId(dataValue);
if(CollectionUtil.isEmpty(ossFiles)){ // 新加了一个文件
String connectId = UUID.randomUUID().toString().replace("-", "");
//修改文件表关联信息connect_id
List<OSSFile> 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<OSSFile> ossFiles = ossFileService.getFileInfosByConnectId(fileIdList[0]);
if(CollectionUtil.isEmpty(ossFiles)) { // 新加了一个文件
String connectId = UUID.randomUUID().toString().replace("-", "");
List<OSSFile> 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<OSSFile> ossFiles = ossFileService.getFileInfosByConnectId(dataValue);
if(CollectionUtil.isEmpty(ossFiles)){ // 新加了一个文件
String connectId = UUID.randomUUID().toString().replace("-", "");
//修改文件表关联信息connect_id
List<OSSFile> 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<ParamsReportConfigDataEO> 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<String, Object> 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<OSSFile> ossFiles = ossFileService.getFileInfosByConnectId(fileIdList[0]);
if(CollectionUtil.isEmpty(ossFiles)) { // 新加了一个文件
String connectId = UUID.randomUUID().toString().replace("-", "");
List<OSSFile> 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<OSSFile> ossFiles = ossFileService.getFileInfosByConnectId(dataValue);
if(CollectionUtil.isEmpty(ossFiles)){ // 新加了一个文件
String connectId = UUID.randomUUID().toString().replace("-", "");
//修改文件表关联信息connect_id
List<OSSFile> 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<ParamsReportDet
if (CollectionUtil.isNotEmpty(insertLogEOList)) {
paramsReportDetailLogEOService.saveBatch(insertLogEOList);
}
return paramsReportConfigDataEOService.saveOrUpdateBatch(newConfigDataEOList);
return paramsReportConfigDataEOService.saveBatch(newConfigDataEOList);
}
private ParamsReportConfigDataEO getConfigDataEOByConfigIdAndCollectManifestId(String configId, String collectManifestId, List<ParamsReportConfigDataEO> paramsReportConfigDataEOList) {
private ParamsReportConfigDataEO getConfigDataEOByConfigIdAndCollectManifestId(String configId, String collectManifestId, List<ParamsReportConfigDataEO> paramsReportConfigDataEOList,String configDataId) {
List<ParamsReportConfigDataEO> 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);