认证-上报库-参数项查看-保存
This commit is contained in:
+3
-3
@@ -205,11 +205,11 @@ public class ParamsReportDetailEOController extends JeroController<ParamsReportD
|
||||
@PostMapping(value = "/save")
|
||||
@RequiresPermissions("report:detail:export:save")
|
||||
public Result<?> 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("保存失败!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-11
@@ -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<ParamsReportConfi
|
||||
* @return
|
||||
*/
|
||||
List<ParamsReportConfigEO> queryList(String paramsManifestId);
|
||||
|
||||
/**
|
||||
* 保存
|
||||
* @param configDataList
|
||||
* @param paramsManifestId
|
||||
* @return
|
||||
*/
|
||||
boolean save(List<Map<String, Object>> configDataList, String paramsManifestId);
|
||||
|
||||
}
|
||||
|
||||
+3
@@ -56,4 +56,7 @@ public interface IParamsReportDetailEOService extends IService<ParamsReportDetai
|
||||
// 自定义导出-excel模板
|
||||
void exportCustomExcel(ParamsReportDetailVO paramsReportDetailVO, HttpServletResponse response, HttpServletRequest request);
|
||||
|
||||
// 保存
|
||||
boolean save(List<Map<String, Object>> configDataList, String paramsManifestId);
|
||||
|
||||
}
|
||||
|
||||
-122
@@ -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<ParamsReportConfigEOMapper, ParamsReportConfigEO> implements IParamsReportConfigEOService {
|
||||
|
||||
@Autowired
|
||||
private IOSSFileService ossFileService;
|
||||
|
||||
@Autowired
|
||||
private IParamsReportConfigEOService paramsReportConfigEOService;
|
||||
|
||||
@Autowired
|
||||
private IParamsReportConfigDataEOService paramsReportConfigDataEOService;
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
@@ -55,102 +31,4 @@ public class ParamsReportConfigEOServiceImpl extends ServiceImpl<ParamsReportCon
|
||||
List<ParamsReportConfigEO> list = list(queryWrapper);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean save(List<Map<String, Object>> configDataList, String paramsManifestId) {
|
||||
List<ParamsReportConfigDataEO> newConfigDataEOList = new ArrayList<>();
|
||||
List<ParamsReportConfigEO> paramsReportConfigEOList = paramsReportConfigEOService.queryList(paramsManifestId); // 查询配置列
|
||||
List<String> paramsReportConfigIdList = paramsReportConfigEOList.stream().map(ParamsConfigEO::getId).collect(Collectors.toList());
|
||||
List<ParamsReportConfigDataEO> paramsReportConfigDataEOList = paramsReportConfigDataEOService.queryListByConfigIdList(paramsReportConfigIdList); // 查询所有配置数据
|
||||
|
||||
// 处理数据
|
||||
for (Map<String, Object> map : configDataList) {
|
||||
String paramsCollectManifestId = (String) map.get("id");
|
||||
|
||||
// 添加配置数据
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
ParamsReportConfigDataEO paramsReportConfigDataEO = new ParamsReportConfigDataEO();
|
||||
if ("id".equals(entry.getKey())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 取值
|
||||
String paramsReportConfigEOId = entry.getKey();
|
||||
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");
|
||||
|
||||
// 判断是新增还是修改
|
||||
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<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);
|
||||
|
||||
} 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<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;
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
paramsReportConfigDataEO.setFileConnectId(dataValue);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
newConfigDataEOList.add(paramsReportConfigDataEO);
|
||||
}
|
||||
}
|
||||
|
||||
// 批量更新
|
||||
return paramsReportConfigDataEOService.saveOrUpdateBatch(newConfigDataEOList);
|
||||
}
|
||||
|
||||
private ParamsReportConfigDataEO getConfigDataEOByConfigIdAndCollectManifestId(String configId, String collectManifestId, List<ParamsReportConfigDataEO> paramsReportConfigDataEOList) {
|
||||
List<ParamsReportConfigDataEO> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+97
@@ -1368,6 +1368,103 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean save(List<Map<String, Object>> configDataList, String paramsManifestId) {
|
||||
List<ParamsReportConfigDataEO> newConfigDataEOList = new ArrayList<>();
|
||||
List<ParamsReportConfigEO> paramsReportConfigEOList = paramsReportConfigEOService.queryList(paramsManifestId); // 查询配置列
|
||||
List<String> paramsReportConfigIdList = paramsReportConfigEOList.stream().map(ParamsConfigEO::getId).collect(Collectors.toList());
|
||||
List<ParamsReportConfigDataEO> paramsReportConfigDataEOList = paramsReportConfigDataEOService.queryListByConfigIdList(paramsReportConfigIdList); // 查询所有配置数据
|
||||
|
||||
// 处理数据
|
||||
for (Map<String, Object> map : configDataList) {
|
||||
String paramsCollectManifestId = (String) map.get("id");
|
||||
|
||||
// 添加配置数据
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
ParamsReportConfigDataEO paramsReportConfigDataEO = new ParamsReportConfigDataEO();
|
||||
if ("id".equals(entry.getKey())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 取值
|
||||
String paramsReportConfigEOId = entry.getKey();
|
||||
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");
|
||||
|
||||
// 判断是新增还是修改
|
||||
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<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);
|
||||
|
||||
} 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<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;
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
paramsReportConfigDataEO.setFileConnectId(dataValue);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
newConfigDataEOList.add(paramsReportConfigDataEO);
|
||||
}
|
||||
}
|
||||
|
||||
// 批量更新
|
||||
return paramsReportConfigDataEOService.saveOrUpdateBatch(newConfigDataEOList);
|
||||
}
|
||||
|
||||
private ParamsReportConfigDataEO getConfigDataEOByConfigIdAndCollectManifestId(String configId, String collectManifestId, List<ParamsReportConfigDataEO> paramsReportConfigDataEOList) {
|
||||
List<ParamsReportConfigDataEO> 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 实体对象
|
||||
|
||||
Reference in New Issue
Block a user