Merge remote-tracking branch 'origin/dev_third_stage' into dev_third_stage

This commit is contained in:
wangzhijiang
2022-08-03 18:15:29 +08:00
33 changed files with 3278 additions and 166 deletions
@@ -22,10 +22,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -197,4 +194,23 @@ public class ParamsReportDetailEOController extends JeroController<ParamsReportD
return Result.OK(paramsReportConfigEO);
}
/**
* 暂存
*
* @param paramsReportDetailVO
* @return
*/
@AutoLog(value = "上报库参数项-保存")
@ApiOperation(value="参数项收集清单-保存", notes="参数项收集清单-保存")
@PostMapping(value = "/save")
@RequiresPermissions("report:detail:export:save")
public Result<?> save(@RequestBody ParamsReportDetailVO paramsReportDetailVO) {
boolean isSuccess = paramsReportDetailEOService.save(paramsReportDetailVO.getConfigDataList(), paramsReportDetailVO.getParamsManifestId());
if (isSuccess) {
return Result.OK("保存成功!");
} else {
return Result.error("保存失败!");
}
}
}
@@ -23,4 +23,11 @@ public interface IParamsReportConfigDataEOService extends IService<ParamsReportC
ParamsReportConfigDataEO queryByConfigIdAndCollectManifestId(String paramsConfigId, String paramsCollectManifestId);
List<ParamsReportConfigDataEO> queryByConfigIdListAndCollectManifestId(List<String> paramsConfigIdList, String paramsCollectManifestId);
/**
* 查询清单的所有配置数据
* @param configIdList
* @return
*/
List<ParamsReportConfigDataEO> queryListByConfigIdList(List<String> configIdList);
}
@@ -1,7 +1,8 @@
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;
/**
@@ -12,5 +13,10 @@ import java.util.List;
*/
public interface IParamsReportConfigEOService extends IService<ParamsReportConfigEO> {
/**
* 列表查询
* @param paramsManifestId
* @return
*/
List<ParamsReportConfigEO> queryList(String paramsManifestId);
}
@@ -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);
}
@@ -1,5 +1,6 @@
package com.jero.modules.cert.report.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.modules.cert.report.entity.ParamsReportConfigDataEO;
@@ -38,4 +39,20 @@ public class ParamsReportConfigDataEOServiceImpl extends ServiceImpl<ParamsRepor
public List<ParamsReportConfigDataEO> queryByConfigIdListAndCollectManifestId(List<String> paramsConfigIdList, String paramsCollectManifestId) {
return baseMapper.selectByConfigIdListAndCollectManifestId(paramsConfigIdList, paramsCollectManifestId);
}
/**
* 查询清单的所有配置数据
* @param configIdList
* @return
*/
@Override
public List<ParamsReportConfigDataEO> queryListByConfigIdList(List<String> configIdList) {
if (CollectionUtil.isNotEmpty(configIdList)) {
LambdaQueryWrapper<ParamsReportConfigDataEO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(ParamsReportConfigDataEO::getParamsConfigId, configIdList);
return list(queryWrapper);
}
return null;
}
}
@@ -20,6 +20,7 @@ import com.jero.modules.cert.collect.enums.CollectManifestStateEnum;
import com.jero.modules.cert.collect.enums.ConfigDataTypeEnum;
import com.jero.modules.cert.collect.vo.ParamsConfigDataVO;
import com.jero.modules.cert.report.entity.*;
import com.jero.modules.cert.report.enums.ExportTemplateStateEnum;
import com.jero.modules.cert.report.enums.ExportTypeEnum;
import com.jero.modules.cert.report.mapper.ParamsReportDetailEOMapper;
import com.jero.modules.cert.report.service.*;
@@ -674,7 +675,8 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
public List<Map<String, String>> getTemplateLabelList() {
// 查询所有导出模板
LambdaQueryWrapper<ParamsExportTemplateEO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.orderByDesc(ParamsExportTemplateEO::getCreateTime);
queryWrapper.eq(ParamsExportTemplateEO::getState, ExportTemplateStateEnum.ENABLE.getValue())
.orderByDesc(ParamsExportTemplateEO::getCreateTime);
List<ParamsExportTemplateEO> paramsExportTemplateEOList = paramsExportTemplateEOService.list(queryWrapper);
List<Map<String, String>> templateLabelList = new ArrayList<>();
@@ -1366,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 实体对象
@@ -3,6 +3,9 @@ package com.jero.modules.cert.report.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
import java.util.Map;
@Data
public class ParamsReportDetailVO {
@@ -37,6 +40,9 @@ public class ParamsReportDetailVO {
@ApiModelProperty(value = "对应参数模板发布版本")
private Integer paramsTemplatePublishVersion;
@ApiModelProperty(value = "保存专用")
private List<Map<String, Object>> configDataList; // 保存专用
// 导出通用
private String cut;
private String exportName;
@@ -98,12 +98,12 @@ public class ParamsInfoEOServiceImpl extends ServiceImpl<ParamsInfoEOMapper, Par
String nioNumber = paramsInfoEO.getNioNumber();
String paramsTemplateId = paramsInfoEO.getParamsTemplateId();
// 校验nio编号 格式:字母数字横杠(-)
String nioNumberRegex = "^[A-Za-z0-9-/. ]+$";
String nioNumberRegex = "^[A-Za-z0-9-/ ]+$";
if (!nioNumber.matches(nioNumberRegex)) {
if (CutEnum.CN.getValue().equals(paramsInfoEO.getCut())) {
throw new JeroBootException("NIO编号格式错误,仅能为字母,数字,横杠(-),小数点(.),左斜杠,空格!");
throw new JeroBootException("NIO编号格式错误,仅能为字母,数字,横杠(-),左斜杠,空格!");
} else {
throw new JeroBootException("NIO number formatting errors, can only letters,numbers,dash (-),dot (.),left slash,spaces!");
throw new JeroBootException("NIO number formatting errors, can only letters,numbers,dash (-),left slash,spaces!");
}
}
@@ -176,12 +176,12 @@ public class ParamsInfoEOServiceImpl extends ServiceImpl<ParamsInfoEOMapper, Par
String paramsTemplateId = paramsInfoEO.getParamsTemplateId();
// 校验nio编号 格式:字母数字横杠(-)
String nioNumberRegex = "^[A-Za-z0-9-/. ]+$";
String nioNumberRegex = "^[A-Za-z0-9-/ ]+$";
if (!nioNumber.matches(nioNumberRegex)) {
if (CutEnum.CN.getValue().equals(paramsInfoEO.getCut())) {
throw new JeroBootException("NIO编号格式错误,仅能为字母,数字,横杠(-),小数点(.),左斜杠,空格!");
throw new JeroBootException("NIO编号格式错误,仅能为字母,数字,横杠(-),左斜杠,空格!");
} else {
throw new JeroBootException("NIO number formatting errors, can only letters,numbers,dash (-),dot (.),left slash,spaces!");
throw new JeroBootException("NIO number formatting errors, can only letters,numbers,dash (-),left slash,spaces!");
}
}
@@ -1134,12 +1134,12 @@ public class ParamsInfoEOServiceImpl extends ServiceImpl<ParamsInfoEOMapper, Par
countError += (int)resultMap.get("countError");
if (StringUtils.isNotEmpty(dto.getNioNumber())) {
// 校验nio编号 格式:字母数字横杠(-)
String nioNumberRegex = "^[A-Za-z0-9-/. ]+$";
String nioNumberRegex = "^[A-Za-z0-9-/ ]+$";
if (!nioNumber.matches(nioNumberRegex)) {
if(CutEnum.CN.getValue().equals(cut)) {
errorMsg += "NIO编号格式错误,仅能为字母,数字,横杠(-),小数点(.),左斜杠,空格;";
errorMsg += "NIO编号格式错误,仅能为字母,数字,横杠(-),左斜杠,空格;";
} else {
errorMsg += "NIO number formatting errors, can only letters, numbers, dash (-),dot (.),left slash,spaces;";
errorMsg += "NIO number formatting errors, can only letters, numbers, dash (-),left slash,spaces;";
}
countError++;
}
@@ -1389,12 +1389,12 @@ public class ParamsInfoEOServiceImpl extends ServiceImpl<ParamsInfoEOMapper, Par
countError += (int)resultMap.get("countError");
if (StringUtils.isNotEmpty(ccDto.getNioNumber())) {
// 校验nio编号 格式:字母数字横杠(-)
String nioNumberRegex = "^[A-Za-z0-9-/. ]+$";
String nioNumberRegex = "^[A-Za-z0-9-/ ]+$";
if (!nioNumber.matches(nioNumberRegex)) {
if(CutEnum.CN.getValue().equals(cut)) {
errorMsg += "nio编号格式错误,仅能为字母,数字,横杠(-),小数点(.),左斜杠,空格;";
errorMsg += "nio编号格式错误,仅能为字母,数字,横杠(-),左斜杠,空格;";
} else {
errorMsg += "NIO number formatting errors, can only letters, numbers, dash (-),dot (.),left slash,spaces;";
errorMsg += "NIO number formatting errors, can only letters, numbers, dash (-),left slash,spaces;";
}
countError++;
}
@@ -534,7 +534,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
sysUser.setUsername(ppEmployee.getWorker_user_id());
sysUser.setRealname(ppEmployee.getFormatted_name());
sysUser.setStatus("Active".equals(ppEmployee.getEmployee_status())? CommonConstant.USER_UNFREEZE : CommonConstant.USER_FREEZE);
sysUser.setDelFlag("1".equals(ppEmployee.getDelete_flag())? CommonConstant.DEL_FLAG_0 : CommonConstant.DEL_FLAG_1);
// sysUser.setDelFlag("1".equals(ppEmployee.getDelete_flag())? CommonConstant.DEL_FLAG_0 : CommonConstant.DEL_FLAG_1);
sysUser.setThirdId(ppEmployee.getWorker_user_id());
sysUser.setWorkNo(ppEmployee.getEmployee_id());
sysUser.setWorkerType("Employee".equals(ppEmployee.getWorker_type())? CommonConstant.WORKER_TYPE_1 : CommonConstant.WORKER_TYPE_2);