feat:报告模板库
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
package com.sdm.capability.controller;
|
||||
|
||||
import com.sdm.capability.model.dto.ReportTemplateDto;
|
||||
import com.sdm.capability.model.entity.SimulationFlowTemplate;
|
||||
import com.sdm.capability.model.entity.SimulationReportTemplate;
|
||||
import com.sdm.capability.model.req.flow.GetFlowTemplateReq;
|
||||
import com.sdm.capability.model.req.flow.ReleaseFlowTemplateReq;
|
||||
import com.sdm.capability.service.IFlowService;
|
||||
import com.sdm.capability.service.ISimulationFlowNodeService;
|
||||
import com.sdm.capability.service.ISimulationReportTemplateService;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.req.capability.FlowNodeDto;
|
||||
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
||||
import com.sdm.common.entity.resp.capability.FlowTemplateResp;
|
||||
import com.sdm.common.feign.inter.capability.ISimulationFlowFeignClient;
|
||||
import com.sdm.common.feign.inter.capability.ISimulationReportFeignClient;
|
||||
import com.sdm.common.log.annotation.SysLog;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/report")
|
||||
public class ReportTemplateController implements ISimulationReportFeignClient {
|
||||
|
||||
@Resource
|
||||
private ISimulationReportTemplateService reportTemplateService;
|
||||
|
||||
/**
|
||||
* 新增报告模板
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/createReportTemplate", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public SdmResponse createReportTemplate(ReportTemplateDto templateDto) {
|
||||
return reportTemplateService.createReportTemplate(templateDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 报告模板升级
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/upgradeReportTemplate", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public SdmResponse upgradeReportTemplate(ReportTemplateDto templateDto) {
|
||||
return reportTemplateService.upgradeReportTemplate(templateDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑报告模板
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/updateReportTemplate", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public SdmResponse updateReportTemplate(ReportTemplateDto templateDto) {
|
||||
return reportTemplateService.updateReportTemplate(templateDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除报告模版
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/deleteReportTemplate")
|
||||
public SdmResponse deleteReportTemplate(@RequestBody ReportTemplateDto templateDto) {
|
||||
return reportTemplateService.deleteReportTemplate(templateDto);
|
||||
}
|
||||
|
||||
@PostMapping("/releaseReportTemplate")
|
||||
public SdmResponse releaseReportTemplate(@RequestBody ReportTemplateDto templateDto) {
|
||||
return reportTemplateService.releaseReportTemplate(templateDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询报告模版
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/queryReportTemplate")
|
||||
public SdmResponse queryReportTemplate(@RequestBody ReportTemplateDto req) {
|
||||
return reportTemplateService.queryReportTemplate(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询报告模版版本信息
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryReportTemplateVersion")
|
||||
public SdmResponse queryReportTemplateVersion(@RequestParam("uuid") String uuid) {
|
||||
return reportTemplateService.queryReportTemplateVersion(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置流程模版启用状态
|
||||
* @param uuid
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/setReportTemplateStatus")
|
||||
public SdmResponse turnOnOffFlowTemplate(@RequestParam("uuid") String uuid,@RequestParam("status") int status) {
|
||||
return reportTemplateService.turnOnOffReportTemplate(uuid, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过UUID获取流程模版详情
|
||||
* @param uuid
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryReportTemplateInfo")
|
||||
public SdmResponse queryReportTemplateInfo(@RequestParam("uuid") String uuid) {
|
||||
return reportTemplateService.queryReportTemplateInfo(uuid);
|
||||
}
|
||||
|
||||
@PostMapping("/approveHandleNotice")
|
||||
public SdmResponse receiveApproveNotice(LaunchApproveReq req) {
|
||||
return reportTemplateService.handleApproveResult(req);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.sdm.capability.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sdm.capability.model.entity.SimulationReportTemplate;
|
||||
|
||||
public interface SimulationReportTemplateMapper extends BaseMapper<SimulationReportTemplate> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.sdm.capability.model.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ReportTemplateDto {
|
||||
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "报告模版唯一ID")
|
||||
private String uuid;
|
||||
|
||||
@Schema(description = "报告模版名称")
|
||||
private String templateName;
|
||||
|
||||
@Schema(description = "报告模版版本")
|
||||
private String templateVersion;
|
||||
|
||||
@Schema(description = "报告模板绑定文件ID")
|
||||
private Long fileId;
|
||||
|
||||
@Schema(description = "报告模版状态 -1:草稿 0:禁用 1:启用")
|
||||
private Integer templateStatus;
|
||||
|
||||
@Schema(description = "报告模版类型(分析方向)")
|
||||
private String templateType;
|
||||
|
||||
@Schema(description = "报告模版审批状态 0:未审批 1:审批中 2:审批通过 3:审批未通过")
|
||||
private Integer approveType;
|
||||
|
||||
@Schema(description = "报告模版评审流ID")
|
||||
private String approveFlowId;
|
||||
|
||||
@Schema(description = "报告模版描述信息")
|
||||
private String comment;
|
||||
|
||||
@Schema(description = "租户ID")
|
||||
private Long tenantId;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@Schema(description = "模版创建者ID")
|
||||
private Long creator;
|
||||
|
||||
@Schema(description = "模版创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "模版更新人ID")
|
||||
private Long updater;
|
||||
|
||||
@Schema(description = "文件")
|
||||
private MultipartFile file;
|
||||
|
||||
@Schema(description = "创建时间范围")
|
||||
private String[] createTimeArr;
|
||||
|
||||
@Schema(description = "是否为个人模板")
|
||||
private boolean personal;
|
||||
|
||||
@Schema(description = "报告审批模板名称")
|
||||
public String approveTemplateName;
|
||||
|
||||
@Schema(description = "报告审批模板ID")
|
||||
public String approveTemplateId;
|
||||
|
||||
@Schema(description = "升版类型 0:小版本 1:大版本")
|
||||
public int versionType;
|
||||
|
||||
@Schema(description = "分页参数,当前第几页")
|
||||
private int current;
|
||||
|
||||
@Schema(description = "分页参数,一页几条")
|
||||
private int size;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.sdm.capability.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("simulation_report_template")
|
||||
@ApiModel(value="SimulationReportTemplate对象", description="报告模板实体类")
|
||||
public class SimulationReportTemplate implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "报告模版唯一ID")
|
||||
@TableField("uuid")
|
||||
private String uuid;
|
||||
|
||||
@ApiModelProperty(value = "报告模版名称")
|
||||
@TableField("templateName")
|
||||
private String templateName;
|
||||
|
||||
@ApiModelProperty(value = "报告模版版本")
|
||||
@TableField("templateVersion")
|
||||
private String templateVersion;
|
||||
|
||||
@ApiModelProperty(value = "报告模板绑定文件ID")
|
||||
@TableField("fileId")
|
||||
private Long fileId;
|
||||
|
||||
@ApiModelProperty(value = "报告模版状态 -1:草稿 0:禁用 1:启用")
|
||||
@TableField("templateStatus")
|
||||
private Integer templateStatus;
|
||||
|
||||
@ApiModelProperty(value = "报告模版类型(分析方向)")
|
||||
@TableField("templateType")
|
||||
private String templateType;
|
||||
|
||||
@ApiModelProperty(value = "报告模版审批状态 0:未审批 1:审批中 2:审批通过 3:审批未通过")
|
||||
@TableField("approveType")
|
||||
private Integer approveType;
|
||||
|
||||
@ApiModelProperty(value = "报告模版评审流ID")
|
||||
@TableField("approveFlowId")
|
||||
private String approveFlowId;
|
||||
|
||||
@ApiModelProperty(value = "报告模版描述信息")
|
||||
@TableField("comment")
|
||||
private String comment;
|
||||
|
||||
@ApiModelProperty(value = "租户ID")
|
||||
@TableField("tenantId")
|
||||
private Long tenantId;
|
||||
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
@TableField("updateTime")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@ApiModelProperty(value = "模版创建者ID")
|
||||
@TableField("creator")
|
||||
private Long creator;
|
||||
|
||||
@ApiModelProperty(value = "模版创建时间")
|
||||
@TableField("createTime")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@ApiModelProperty(value = "模版更新人ID")
|
||||
@TableField("updater")
|
||||
private Long updater;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.sdm.capability.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.sdm.capability.model.dto.ReportTemplateDto;
|
||||
import com.sdm.capability.model.entity.SimulationReportTemplate;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
||||
|
||||
public interface ISimulationReportTemplateService extends IService<SimulationReportTemplate> {
|
||||
|
||||
SdmResponse createReportTemplate(ReportTemplateDto reportTemplate);
|
||||
|
||||
SdmResponse upgradeReportTemplate(ReportTemplateDto reportTemplate);
|
||||
|
||||
SdmResponse updateReportTemplate(ReportTemplateDto reportTemplate);
|
||||
|
||||
SdmResponse deleteReportTemplate(ReportTemplateDto reportTemplate);
|
||||
|
||||
SdmResponse releaseReportTemplate(ReportTemplateDto reportTemplate);
|
||||
|
||||
SdmResponse queryReportTemplate(ReportTemplateDto req);
|
||||
|
||||
SdmResponse queryReportTemplateVersion(String uuid);
|
||||
|
||||
SdmResponse turnOnOffReportTemplate(String uuid, int status);
|
||||
|
||||
SdmResponse queryReportTemplateInfo(String uuid);
|
||||
|
||||
SdmResponse handleApproveResult(LaunchApproveReq req);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,279 @@
|
||||
package com.sdm.capability.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.sdm.capability.dao.SimulationReportTemplateMapper;
|
||||
import com.sdm.capability.model.dto.ReportTemplateDto;
|
||||
import com.sdm.capability.model.entity.SimulationReportTemplate;
|
||||
import com.sdm.capability.service.ISimulationReportTemplateService;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
import com.sdm.common.entity.bo.DataPageInfo;
|
||||
import com.sdm.common.entity.constants.NumberConstants;
|
||||
import com.sdm.common.entity.enums.ApproveStatusEnum;
|
||||
import com.sdm.common.entity.enums.ApproveTypeEnum;
|
||||
import com.sdm.common.entity.req.data.DelFileReq;
|
||||
import com.sdm.common.entity.req.data.UpdateScriptAndReportReq;
|
||||
import com.sdm.common.entity.req.data.UploadFilesReq;
|
||||
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
||||
import com.sdm.common.feign.impl.data.DataClientFeignClientImpl;
|
||||
import com.sdm.common.feign.impl.system.ApproveFeignClientImpl;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.sdm.common.service.BaseService.generateUuid;
|
||||
import static com.sdm.common.service.BaseService.generateVersion;
|
||||
|
||||
|
||||
@Service
|
||||
public class SimulationReportTemplateServiceImpl extends ServiceImpl<SimulationReportTemplateMapper, SimulationReportTemplate> implements ISimulationReportTemplateService {
|
||||
|
||||
@Autowired
|
||||
private DataClientFeignClientImpl dataFeignClient;
|
||||
|
||||
@Autowired
|
||||
private ApproveFeignClientImpl approveFeignClient;
|
||||
|
||||
@Override
|
||||
public SdmResponse createReportTemplate(ReportTemplateDto templateDto) {
|
||||
SimulationReportTemplate reportTemplate = new SimulationReportTemplate();
|
||||
BeanUtils.copyProperties(templateDto, reportTemplate);
|
||||
reportTemplate.setUuid(generateUuid("report_template_"));
|
||||
reportTemplate.setCreator(ThreadLocalContext.getUserId());
|
||||
reportTemplate.setTenantId(ThreadLocalContext.getTenantId());
|
||||
UploadFilesReq req = new UploadFilesReq();
|
||||
req.setFile(templateDto.getFile());
|
||||
SdmResponse<Long> response = dataFeignClient.uploadReportTemplateFile(req);
|
||||
if (!response.isSuccess()) {
|
||||
return response;
|
||||
}
|
||||
reportTemplate.setFileId(response.getData());
|
||||
this.save(reportTemplate);
|
||||
return SdmResponse.success(reportTemplate.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse upgradeReportTemplate(ReportTemplateDto templateDto) {
|
||||
Long tenantId = ThreadLocalContext.getTenantId();
|
||||
Long creator = ThreadLocalContext.getUserId();
|
||||
|
||||
SimulationReportTemplate reportTemplate = this.lambdaQuery().eq(SimulationReportTemplate::getUuid, templateDto.getUuid()).one();
|
||||
SimulationReportTemplate upgradeTemplate = new SimulationReportTemplate();
|
||||
BeanUtils.copyProperties(templateDto, upgradeTemplate);
|
||||
|
||||
upgradeTemplate.setTemplateVersion(generateVersion(reportTemplate.getTemplateVersion(),templateDto.getVersionType()));
|
||||
upgradeTemplate.setUuid(generateUuid("report_template_"));
|
||||
upgradeTemplate.setCreator(creator);
|
||||
upgradeTemplate.setTenantId(tenantId);
|
||||
|
||||
UploadFilesReq req = new UploadFilesReq();
|
||||
req.setFile(templateDto.getFile());
|
||||
SdmResponse<Long> response = dataFeignClient.uploadReportTemplateFile(req);
|
||||
if (!response.isSuccess()) {
|
||||
return response;
|
||||
}
|
||||
upgradeTemplate.setFileId(response.getData());
|
||||
this.save(upgradeTemplate);
|
||||
return SdmResponse.success(upgradeTemplate.getUuid());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse updateReportTemplate(ReportTemplateDto templateDto) {
|
||||
UpdateScriptAndReportReq req = new UpdateScriptAndReportReq();
|
||||
req.setUpdateFile(templateDto.getFile());
|
||||
req.setUpdateFileId(templateDto.getFileId());
|
||||
req.setFileName(templateDto.getFile().getOriginalFilename());
|
||||
SdmResponse<Long> response = dataFeignClient.updateReportTemplateFile(req);
|
||||
if (!response.isSuccess()) {
|
||||
return response;
|
||||
}
|
||||
templateDto.setFileId(response.getData());
|
||||
SimulationReportTemplate reportTemplate = new SimulationReportTemplate();
|
||||
BeanUtils.copyProperties(templateDto, reportTemplate);
|
||||
this.updateById(reportTemplate);
|
||||
return SdmResponse.success(reportTemplate.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse deleteReportTemplate(ReportTemplateDto reportTemplate) {
|
||||
SimulationReportTemplate reportTemplateEntity = this.getById(reportTemplate.getId());
|
||||
if (reportTemplateEntity == null) {
|
||||
return SdmResponse.failed("报告模板不存在");
|
||||
}
|
||||
DelFileReq delFileReq = new DelFileReq();
|
||||
delFileReq.setDelFileId(reportTemplateEntity.getFileId());
|
||||
SdmResponse response = dataFeignClient.delFile(delFileReq);
|
||||
if (!response.isSuccess()) {
|
||||
return response;
|
||||
}
|
||||
return SdmResponse.success(this.removeById(reportTemplate.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse releaseReportTemplate(ReportTemplateDto templateDto) {
|
||||
SimulationReportTemplate reportTemplate = this.lambdaQuery().eq(SimulationReportTemplate::getUuid, templateDto.getUuid())
|
||||
.eq(SimulationReportTemplate::getTenantId, ThreadLocalContext.getTenantId())
|
||||
.one();
|
||||
if (ObjectUtils.isEmpty(reportTemplate)) {
|
||||
return SdmResponse.failed("报告模版草稿不存在");
|
||||
} else {
|
||||
// 发起评审
|
||||
SdmResponse approveRespond = launchApprove(templateDto);
|
||||
if (!approveRespond.isSuccess()) {
|
||||
return SdmResponse.failed("发起评审失败");
|
||||
} else {
|
||||
String approveFlowId = (String) approveRespond.getData();
|
||||
reportTemplate.setApproveFlowId(approveFlowId);
|
||||
reportTemplate.setApproveType(ApproveStatusEnum.APPROVING.getCode());
|
||||
this.updateById(reportTemplate);
|
||||
return SdmResponse.success(approveFlowId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发起评审
|
||||
*/
|
||||
private SdmResponse launchApprove(ReportTemplateDto templateDto) {
|
||||
LaunchApproveReq approveReq = new LaunchApproveReq();
|
||||
approveReq.approveTitle = "报告模板评审";
|
||||
approveReq.approveStatus = ApproveStatusEnum.APPROVING.getCode();
|
||||
approveReq.userId = ThreadLocalContext.getUserId();
|
||||
approveReq.approveType = ApproveTypeEnum.REPORT_TEMPLATE_APPROVE.getCode();
|
||||
approveReq.approveAction = 1;
|
||||
approveReq.templateName = templateDto.getApproveTemplateName();
|
||||
approveReq.templateId = templateDto.getApproveTemplateId();
|
||||
approveReq.tenantId = ThreadLocalContext.getTenantId();
|
||||
approveReq.creator = approveReq.userId;
|
||||
JSONObject reportTemplateJson = new JSONObject();
|
||||
reportTemplateJson.put("reportUuid", templateDto.getUuid());
|
||||
reportTemplateJson.put("reportTemplate", JSON.toJSONString(templateDto));
|
||||
approveReq.approveContents = reportTemplateJson.toJSONString();
|
||||
return approveFeignClient.launchApproval(approveReq);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse queryReportTemplate(ReportTemplateDto req) {
|
||||
Long tenantId = ThreadLocalContext.getTenantId();
|
||||
LambdaQueryWrapper<SimulationReportTemplate> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SimulationReportTemplate::getTenantId, tenantId);
|
||||
|
||||
if (StringUtils.isNotBlank(req.getTemplateType())) {
|
||||
queryWrapper.eq(SimulationReportTemplate::getTemplateType, req.getTemplateType());
|
||||
}
|
||||
if (StringUtils.isNotBlank(req.getTemplateName())) {
|
||||
queryWrapper.like(SimulationReportTemplate::getTemplateName, req.getTemplateName());
|
||||
}
|
||||
if (ObjectUtils.isNotEmpty(req.getTemplateStatus())) {
|
||||
queryWrapper.eq(SimulationReportTemplate::getTemplateStatus, req.getTemplateStatus());
|
||||
}
|
||||
if (req.isPersonal()) {
|
||||
queryWrapper.eq(SimulationReportTemplate::getCreator, ThreadLocalContext.getUserId());
|
||||
if (ObjectUtils.isNotEmpty(req.getApproveType())) {
|
||||
queryWrapper.eq(SimulationReportTemplate::getApproveType, req.getApproveType());
|
||||
}
|
||||
} else {
|
||||
if (ObjectUtils.isNotEmpty(req.getCreator())) {
|
||||
queryWrapper.eq(SimulationReportTemplate::getCreator, req.getCreator());
|
||||
}
|
||||
queryWrapper.eq(SimulationReportTemplate::getApproveType, ApproveStatusEnum.PASSED.getCode());
|
||||
}
|
||||
if (ArrayUtil.isNotEmpty(req.getCreateTimeArr())) {
|
||||
queryWrapper.ge(SimulationReportTemplate::getCreateTime, req.getCreateTimeArr()[0])
|
||||
.le(SimulationReportTemplate::getCreateTime, req.getCreateTimeArr()[1]);
|
||||
}
|
||||
queryWrapper.orderByDesc(SimulationReportTemplate::getCreateTime);
|
||||
List<SimulationReportTemplate> templates = this.list(queryWrapper);
|
||||
|
||||
List<SimulationReportTemplate> latestVersions = filterLatestVersion(templates);
|
||||
|
||||
int total = latestVersions.size();
|
||||
int beginPos = (req.getCurrent() - 1) * req.getSize();
|
||||
int endPos = beginPos + req.getSize();
|
||||
List<SimulationReportTemplate> queryTemplate = new ArrayList<>();
|
||||
if(latestVersions.size() > beginPos) {
|
||||
if(latestVersions.size() > endPos) {
|
||||
queryTemplate = latestVersions.subList(beginPos,endPos);
|
||||
} else {
|
||||
queryTemplate = latestVersions.subList(beginPos,latestVersions.size());
|
||||
}
|
||||
}
|
||||
DataPageInfo<List<SimulationReportTemplate>> pageInfo = new DataPageInfo<>();
|
||||
pageInfo.data = queryTemplate;
|
||||
pageInfo.total = total;
|
||||
return SdmResponse.success(pageInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse queryReportTemplateVersion(String uuid) {
|
||||
SimulationReportTemplate reportTemplate = this.lambdaQuery().eq(SimulationReportTemplate::getUuid, uuid).one();
|
||||
List<SimulationReportTemplate> templates = this.lambdaQuery().eq(SimulationReportTemplate::getTemplateName, reportTemplate.getTemplateName())
|
||||
.eq(SimulationReportTemplate::getTenantId, ThreadLocalContext.getTenantId())
|
||||
.list();
|
||||
return SdmResponse.success(templates);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse turnOnOffReportTemplate(String uuid, int status) {
|
||||
SimulationReportTemplate reportTemplate = this.lambdaQuery().eq(SimulationReportTemplate::getUuid, uuid).one();
|
||||
if (reportTemplate == null) {
|
||||
return SdmResponse.failed("报告模板不存在");
|
||||
}
|
||||
reportTemplate.setTemplateStatus(status);
|
||||
return SdmResponse.success(this.updateById(reportTemplate));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse queryReportTemplateInfo(String uuid) {
|
||||
SimulationReportTemplate reportTemplate = this.lambdaQuery().eq(SimulationReportTemplate::getUuid, uuid).one();
|
||||
return SdmResponse.success(reportTemplate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse handleApproveResult(LaunchApproveReq req) {
|
||||
SdmResponse response = SdmResponse.success();
|
||||
int approveStatus = req.approveStatus;
|
||||
String approveContent = req.approveContents;
|
||||
JSONObject contentObj = JSONObject.parseObject(approveContent);
|
||||
if (contentObj != null && contentObj.containsKey("reportUuid")) {
|
||||
String reportTemplateUuid = contentObj.getString("reportUuid");
|
||||
SimulationReportTemplate reportTemplate = (SimulationReportTemplate) this.queryReportTemplateInfo(reportTemplateUuid).getData();
|
||||
if (reportTemplate != null) {
|
||||
// 审批通过
|
||||
if (NumberConstants.TWO == approveStatus) {
|
||||
reportTemplate.setTemplateStatus(1);
|
||||
}
|
||||
reportTemplate.setApproveType(approveStatus);
|
||||
this.updateById(reportTemplate);
|
||||
}
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤出最新的版本模版
|
||||
* @param templates
|
||||
* @return
|
||||
*/
|
||||
private List<SimulationReportTemplate> filterLatestVersion(List<SimulationReportTemplate> templates) {
|
||||
List<SimulationReportTemplate> latestVersions = new ArrayList<>();
|
||||
Set<String> nameSet = new HashSet<>();
|
||||
|
||||
for (SimulationReportTemplate obj : templates) {
|
||||
if (!nameSet.contains(obj.getTemplateName())) {
|
||||
nameSet.add(obj.getTemplateName());
|
||||
latestVersions.add(obj);
|
||||
}
|
||||
}
|
||||
return latestVersions;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -109,6 +109,7 @@ security:
|
||||
paths:
|
||||
- /pbs/jobFileCallback
|
||||
- /flow/approveHandleNotice
|
||||
- /report/approveHandleNotice
|
||||
|
||||
#logging:
|
||||
# config: ./config/logback.xml
|
||||
@@ -109,6 +109,7 @@ security:
|
||||
paths:
|
||||
- /pbs/jobFileCallback
|
||||
- /flow/approveHandleNotice
|
||||
- /report/approveHandleNotice
|
||||
|
||||
#logging:
|
||||
# config: ./config/logback.xml
|
||||
@@ -29,8 +29,8 @@ spring:
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 192.168.65.161:8848
|
||||
group: DAI_GROUP
|
||||
server-addr: 127.0.0.1:8848
|
||||
group: LOCAL_GROUP
|
||||
# server-addr: 127.0.0.1:8848
|
||||
enabled: true
|
||||
# username: nacos
|
||||
@@ -95,5 +95,12 @@ lombok:
|
||||
file:
|
||||
rootPath: /data/home/sdm
|
||||
|
||||
security:
|
||||
whitelist:
|
||||
paths:
|
||||
- /pbs/jobFileCallback
|
||||
- /flow/approveHandleNotice
|
||||
- /report/approveHandleNotice
|
||||
|
||||
#logging:
|
||||
# config: ./config/logback.xml
|
||||
@@ -109,6 +109,7 @@ security:
|
||||
paths:
|
||||
- /pbs/jobFileCallback
|
||||
- /flow/approveHandleNotice
|
||||
- /report/approveHandleNotice
|
||||
|
||||
#logging:
|
||||
# config: ./config/logback.xml
|
||||
@@ -109,6 +109,7 @@ security:
|
||||
paths:
|
||||
- /pbs/jobFileCallback
|
||||
- /flow/approveHandleNotice
|
||||
- /report/approveHandleNotice
|
||||
|
||||
#logging:
|
||||
# config: ./config/logback.xml
|
||||
Reference in New Issue
Block a user