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
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.sdm.common.entity.enums;
|
||||
|
||||
/**
|
||||
* 审批状态枚举
|
||||
*/
|
||||
public enum ApproveStatusEnum {
|
||||
|
||||
NOT_START("未开始", 0),
|
||||
APPROVING("审批中", 1),
|
||||
PASSED("已通过", 2),
|
||||
REJECTED("已驳回", 3);
|
||||
|
||||
private final String name;
|
||||
|
||||
private final Integer code;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
ApproveStatusEnum(String name, Integer code) {
|
||||
this.name = name;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,8 @@ public enum ApproveTypeEnum {
|
||||
KNOWLEDGE_APPROVE(2, "仿真知识库评审"),
|
||||
FLOW_TEMPLATE_APPROVE(3, "流程模板评审"),
|
||||
DELIVERABLE_APPROVE(4, "交付物评审"),
|
||||
PARAM_APPROVE(5, "仿真参数库评审")
|
||||
PARAM_APPROVE(5, "仿真参数库评审"),
|
||||
REPORT_TEMPLATE_APPROVE(6, "报告模板评审")
|
||||
;
|
||||
|
||||
private final int code;
|
||||
|
||||
@@ -43,7 +43,13 @@ public enum DirTypeEnum {
|
||||
* 视频库
|
||||
*/
|
||||
@Schema(description = "视频库文件夹", example = "7")
|
||||
VIDEO_DIR("video", 7);
|
||||
VIDEO_DIR("video", 7),
|
||||
|
||||
/**
|
||||
* 报告模板库
|
||||
*/
|
||||
@Schema(description = "报告模板库文件夹", example = "8")
|
||||
REPORT_TEMPLATE_DIR("reportTemplate", 8);
|
||||
|
||||
|
||||
|
||||
@@ -76,7 +82,9 @@ public enum DirTypeEnum {
|
||||
// 初始化用户业务库目录
|
||||
private static final List<DirTypeEnum> INIT_SPMD_DIR = List.of(
|
||||
DirTypeEnum.KNOWLEDGE_BASE_DIR, DirTypeEnum.PROJECT_NODE_DIR,
|
||||
DirTypeEnum.AVATAR_DIR, DirTypeEnum.SIMULATION_PARAMETER_DIR, DirTypeEnum.TRAIN_MODEL_DIR,DirTypeEnum.SCRIPT_DIR, DirTypeEnum.VIDEO_DIR);
|
||||
DirTypeEnum.AVATAR_DIR, DirTypeEnum.SIMULATION_PARAMETER_DIR,
|
||||
DirTypeEnum.TRAIN_MODEL_DIR, DirTypeEnum.SCRIPT_DIR,
|
||||
DirTypeEnum.VIDEO_DIR, DirTypeEnum.REPORT_TEMPLATE_DIR);
|
||||
public static final List<DirTypeEnum> getInitSpmdDir() {
|
||||
return INIT_SPMD_DIR;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.sdm.common.entity.req.data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Data
|
||||
@Schema(description = "更新脚本或报告模板文件请求参数")
|
||||
public class UpdateScriptAndReportReq {
|
||||
@Schema(description = "需要更新的文件ID")
|
||||
private Long updateFileId;
|
||||
|
||||
@Schema(description = "文件名称")
|
||||
private String fileName;
|
||||
|
||||
@Schema(description = "需要更新的文件")
|
||||
private MultipartFile updateFile;
|
||||
|
||||
@Schema(description = "所属根目录文件夹名称")
|
||||
private String dirName;
|
||||
}
|
||||
@@ -18,8 +18,8 @@ public class LaunchApproveReq extends BaseBean {
|
||||
@Schema(description = "CID生成的流程ID",defaultValue = "")
|
||||
public String cidFlowId;
|
||||
|
||||
// 审批类型 0.http回调的,replyUrl必须传递,相当于是跨系统的,调用的时候可以不传,replyUrl必须传递 ;1:仿真地图审批(spdm内部feign) 2:知识库审批(spdm内部feign) 3:交付物审批(spdm内部feign)
|
||||
@Schema(description = "审批类型 1:仿真地图审批 2:知识库审批 3:流程模板审批 4:交付物审批",defaultValue = "0")
|
||||
// 审批类型 0.http回调的,replyUrl必须传递,相当于是跨系统的,调用的时候可以不传,replyUrl必须传递 ;1:仿真地图审批(spdm内部feign) 2:知识库审批(spdm内部feign) 4:交付物审批(spdm内部feign)
|
||||
@Schema(description = "审批类型 1:仿真地图审批 2:知识库审批 3:流程模板审批 4:交付物审批 5:仿真参数库审批 6:报告模板审批",defaultValue = "0")
|
||||
@Value("10")
|
||||
public int approveType;
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.sdm.common.feign.impl.capability;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
||||
import com.sdm.common.feign.inter.capability.ISimulationReportFeignClient;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SimulationReportFeignClientImpl implements ISimulationReportFeignClient {
|
||||
|
||||
@Autowired
|
||||
private ISimulationReportFeignClient reportFeignClient;
|
||||
|
||||
@Override
|
||||
public SdmResponse receiveApproveNotice(LaunchApproveReq req) {
|
||||
SdmResponse response;
|
||||
try {
|
||||
response = reportFeignClient.receiveApproveNotice(req);
|
||||
if (!response.isSuccess()) {
|
||||
return SdmResponse.failed("报告模板审批状态修改失败");
|
||||
}
|
||||
return response;
|
||||
} catch (Exception e) {
|
||||
log.error("报告模板审批状态修改异常", e);
|
||||
return SdmResponse.failed("报告模板审批状态修改异常");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import com.sdm.common.feign.inter.data.IDataFeignClient;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -177,8 +178,8 @@ public class DataClientFeignClientImpl implements IDataFeignClient {
|
||||
log.info("文件信息批量入库响应:"+ response);
|
||||
return response;
|
||||
} catch (Exception e) {
|
||||
log.error("文件信息批量入库响应", e);
|
||||
return SdmResponse.failed("文件信息批量入库响应");
|
||||
log.error("文件信息批量入库失败", e);
|
||||
return SdmResponse.failed("文件信息批量入库失败");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,4 +222,28 @@ public class DataClientFeignClientImpl implements IDataFeignClient {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse<Long> uploadReportTemplateFile(UploadFilesReq req) {
|
||||
SdmResponse<Long> response;
|
||||
try {
|
||||
response = dataClient.uploadReportTemplateFile(req);
|
||||
return response;
|
||||
} catch (Exception e) {
|
||||
log.error("上传报告模板文件失败:", e);
|
||||
return SdmResponse.failed("上传报告模板文件失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse<Long> updateReportTemplateFile(UpdateScriptAndReportReq req) {
|
||||
SdmResponse<Long> response;
|
||||
try {
|
||||
response = dataClient.updateReportTemplateFile(req);
|
||||
return response;
|
||||
} catch (Exception e) {
|
||||
log.error("编辑报告模板文件失败:", e);
|
||||
return SdmResponse.failed("编辑报告模板文件失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.sdm.common.feign.inter.capability;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
|
||||
@FeignClient(name = "capability",contextId = "reportTemplateFeignClient")
|
||||
public interface ISimulationReportFeignClient {
|
||||
|
||||
@PostMapping("/report/approveHandleNotice")
|
||||
SdmResponse receiveApproveNotice(@RequestBody LaunchApproveReq req);
|
||||
|
||||
}
|
||||
@@ -88,4 +88,10 @@ public interface IDataFeignClient {
|
||||
@PostMapping("/data/initNewTenant")
|
||||
SdmResponse initNewTenant(@RequestParam Long tenantId);
|
||||
|
||||
@PostMapping(value = "/data/uploadReportTemplateFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
SdmResponse<Long> uploadReportTemplateFile(UploadFilesReq req);
|
||||
|
||||
@PostMapping(value = "/data/updateReportTemplateFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
SdmResponse<Long> updateReportTemplateFile(UpdateScriptAndReportReq req);
|
||||
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class BaseService {
|
||||
* @param versionType
|
||||
* @return
|
||||
*/
|
||||
protected String generateVersion(String currentVersion,int versionType)
|
||||
public static String generateVersion(String currentVersion,int versionType)
|
||||
{
|
||||
currentVersion = currentVersion.substring(1);
|
||||
String[] versionSplits = currentVersion.split("\\.");
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.sdm.data.controller;
|
||||
|
||||
import com.sdm.common.annotation.IgnoreAuth;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.enums.DirTypeEnum;
|
||||
import com.sdm.common.entity.req.data.*;
|
||||
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
||||
import com.sdm.common.entity.resp.PageDataResp;
|
||||
@@ -370,14 +371,29 @@ public class DataFileController implements IDataFeignClient {
|
||||
@PostMapping(value = "/uploadScriptFile")
|
||||
@Operation(summary = "上传脚本文件", description = "上传脚本文件")
|
||||
public SdmResponse uploadScriptFile(@RequestParam("script") MultipartFile script) {
|
||||
return IDataFileService.uploadScriptFile(script);
|
||||
return IDataFileService.uploadScriptAndReportFile(script, DirTypeEnum.SCRIPT_DIR.getDirName());
|
||||
}
|
||||
|
||||
// 根基脚本文件ID更新当前脚本文件
|
||||
@PostMapping(value = "/updateScriptFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
@Operation(summary = "更新脚本文件", description = "更新脚本文件")
|
||||
public SdmResponse updateScriptFile(UpdateScriptReq req) {
|
||||
return IDataFileService.updateScriptFile(req);
|
||||
public SdmResponse updateScriptFile(UpdateScriptAndReportReq req) {
|
||||
req.setDirName(DirTypeEnum.SCRIPT_DIR.getDirName());
|
||||
return IDataFileService.updateScriptAndReportFile(req);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/uploadReportTemplateFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
@Operation(summary = "上传报告模板文件", description = "上传报告模板文件")
|
||||
public SdmResponse<Long> uploadReportTemplateFile(UploadFilesReq req) {
|
||||
return IDataFileService.uploadScriptAndReportFile(req.getFile(), DirTypeEnum.REPORT_TEMPLATE_DIR.getDirName());
|
||||
}
|
||||
|
||||
// 根基脚本文件ID更新当前脚本文件
|
||||
@PostMapping(value = "/updateReportTemplateFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
@Operation(summary = "更新报告模板文件", description = "更新报告模板文件")
|
||||
public SdmResponse<Long> updateReportTemplateFile(UpdateScriptAndReportReq req) {
|
||||
req.setDirName(DirTypeEnum.REPORT_TEMPLATE_DIR.getDirName());
|
||||
return IDataFileService.updateScriptAndReportFile(req);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.sdm.data.model.req;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.sdm.common.entity.enums.FileBizTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Schema(description = "更新脚本文件请求参数")
|
||||
public class UpdateScriptReq {
|
||||
@Schema(description = "需要更新的脚本文件ID")
|
||||
private Long scriptFileId;
|
||||
|
||||
@Schema(description = "脚本文件名称")
|
||||
private String fileName;
|
||||
|
||||
@Schema(description = "需要更新的脚本文件")
|
||||
private MultipartFile updateFile;
|
||||
}
|
||||
@@ -209,15 +209,15 @@ public interface IDataFileService {
|
||||
|
||||
/**
|
||||
* 上传脚本文件
|
||||
* @param scriptFile 脚本
|
||||
* @param file 文件
|
||||
* @return 上传文件id
|
||||
*/
|
||||
default SdmResponse<Long> uploadScriptFile(MultipartFile scriptFile){
|
||||
default SdmResponse<Long> uploadScriptAndReportFile(MultipartFile file, String dirName){
|
||||
return null;
|
||||
}
|
||||
|
||||
// 根基脚本文件ID更新当前脚本文件
|
||||
default SdmResponse updateScriptFile(UpdateScriptReq req) {
|
||||
default SdmResponse<Long> updateScriptAndReportFile(UpdateScriptAndReportReq req) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -2045,25 +2045,25 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse<Long> uploadScriptFile(MultipartFile scriptFile) {
|
||||
// 先创建 script 目录
|
||||
String dirMinioObjectKey = getDirMinioObjectKey(DirTypeEnum.SCRIPT_DIR.getDirName());
|
||||
public SdmResponse<Long> uploadScriptAndReportFile(MultipartFile file, String dirName) {
|
||||
// 先创建根目录
|
||||
String dirMinioObjectKey = getDirMinioObjectKey(dirName);
|
||||
Optional<FileMetadataInfo> fileMetadataInfoByObjectKey = getFileMetadataInfoByObjectKey(dirMinioObjectKey, ThreadLocalContext.getTenantId());
|
||||
// 检查目录是否已存在
|
||||
if (!fileMetadataInfoByObjectKey.isPresent()) {
|
||||
return SdmResponse.failed("script 目录不存在,等待initSystemDirectory 初始化完成");
|
||||
return SdmResponse.failed(dirMinioObjectKey + " 目录不存在,等待initSystemDirectory 初始化完成");
|
||||
}
|
||||
|
||||
// 检查文件是否为空
|
||||
if (scriptFile == null || scriptFile.isEmpty()) {
|
||||
return SdmResponse.failed("请选择要上传的脚本文件");
|
||||
if (file == null || file.isEmpty()) {
|
||||
return SdmResponse.failed("请选择要上传的文件");
|
||||
}
|
||||
|
||||
// 获取 script 目录的 id
|
||||
FileMetadataInfo scriptDirMetadataInfo = fileMetadataInfoByObjectKey.get();
|
||||
Long parScriptDirId = scriptDirMetadataInfo.getId();
|
||||
// 获取上级目录(也是根目录)的 id
|
||||
FileMetadataInfo dirMetadataInfo = fileMetadataInfoByObjectKey.get();
|
||||
Long parDirId = dirMetadataInfo.getId();
|
||||
|
||||
String originalFilename = scriptFile.getOriginalFilename();
|
||||
String originalFilename = file.getOriginalFilename();
|
||||
String suffix = originalFilename.substring(originalFilename.lastIndexOf(".") + 1);
|
||||
|
||||
// 生成带时间戳的文件名以避免冲突
|
||||
@@ -2071,43 +2071,42 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
String timestamp = String.valueOf(System.currentTimeMillis());
|
||||
String newFilename = filenameWithoutSuffix + "_" + timestamp + "." + suffix;
|
||||
|
||||
// 再上传脚本文件
|
||||
String scriptFileMinioObjectKey = getFileMinioObjectKey(scriptDirMetadataInfo.getObjectKey() + newFilename);
|
||||
// 再上传文件
|
||||
String fileMinioObjectKey = getFileMinioObjectKey(dirMetadataInfo.getObjectKey() + newFilename);
|
||||
|
||||
try {
|
||||
minioService.uploadFile(scriptFile, scriptFileMinioObjectKey, null,scriptDirMetadataInfo.getBucketName());
|
||||
minioService.uploadFile(file, fileMinioObjectKey, null,dirMetadataInfo.getBucketName());
|
||||
|
||||
// 创建目录元数据并保存到数据库
|
||||
FileMetadataInfo fileInfo = createFileMetadata(scriptFileMinioObjectKey, originalFilename, null,
|
||||
null, null, null, parScriptDirId, scriptFile.getSize());
|
||||
FileMetadataInfo fileInfo = createFileMetadata(fileMinioObjectKey, originalFilename, null,
|
||||
null, null, null, parDirId, file.getSize());
|
||||
fileMetadataInfoService.save(fileInfo);
|
||||
return SdmResponse.success(fileInfo.getId());
|
||||
} catch (Exception e) {
|
||||
minioService.deleteFile(scriptFileMinioObjectKey, scriptDirMetadataInfo.getBucketName() );
|
||||
log.error("上传传脚本文件", e);
|
||||
throw new RuntimeException("上传传脚本文件: " + e.getMessage(), e);
|
||||
minioService.deleteFile(fileMinioObjectKey, dirMetadataInfo.getBucketName());
|
||||
log.error("上传文件失败", e);
|
||||
throw new RuntimeException("上传文件失败: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse updateScriptFile(UpdateScriptReq req) {
|
||||
public SdmResponse<Long> updateScriptAndReportFile(UpdateScriptAndReportReq req) {
|
||||
// 先创建 script 目录
|
||||
String dirMinioObjectKey = getDirMinioObjectKey(DirTypeEnum.SCRIPT_DIR.getDirName());
|
||||
Optional<FileMetadataInfo> scriptDirInfo = getFileMetadataInfoByObjectKey(dirMinioObjectKey,ThreadLocalContext.getTenantId() );
|
||||
String dirMinioObjectKey = getDirMinioObjectKey(req.getDirName());
|
||||
Optional<FileMetadataInfo> dirInfo = getFileMetadataInfoByObjectKey(dirMinioObjectKey,ThreadLocalContext.getTenantId() );
|
||||
// 检查目录是否已存在
|
||||
if (!scriptDirInfo.isPresent()) {
|
||||
return SdmResponse.failed("script 目录不存在,等待initSystemDirectory 初始化完成");
|
||||
if (!dirInfo.isPresent()) {
|
||||
return SdmResponse.failed(req.getDirName() + " 目录不存在,等待initSystemDirectory 初始化完成");
|
||||
}
|
||||
|
||||
// 检查文件是否为空
|
||||
MultipartFile updateFile = req.getUpdateFile();
|
||||
if (ObjectUtils.isEmpty(updateFile)) {
|
||||
return SdmResponse.failed("请选择要更新的脚本文件");
|
||||
return SdmResponse.failed("请选择要更新的文件");
|
||||
}
|
||||
|
||||
// 获取 script 目录的 id
|
||||
FileMetadataInfo scriptDirMetadataInfo = scriptDirInfo.get();
|
||||
Long parScriptDirId = scriptDirMetadataInfo.getId();
|
||||
FileMetadataInfo dirMetadataInfo = dirInfo.get();
|
||||
|
||||
String originalFilename = req.getFileName();
|
||||
String suffix = originalFilename.substring(originalFilename.lastIndexOf(".") + 1);
|
||||
@@ -2118,23 +2117,23 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
String newFilename = filenameWithoutSuffix + "_" + timestamp + "." + suffix;
|
||||
|
||||
// 再上传脚本文件
|
||||
String scriptFileMinioObjectKey = getFileMinioObjectKey(scriptDirMetadataInfo.getObjectKey() + newFilename);
|
||||
String fileMinioObjectKey = getFileMinioObjectKey(dirMetadataInfo.getObjectKey() + newFilename);
|
||||
|
||||
try {
|
||||
minioService.uploadFile(updateFile, scriptFileMinioObjectKey, null,scriptDirMetadataInfo.getBucketName());
|
||||
minioService.uploadFile(updateFile, fileMinioObjectKey, null,dirMetadataInfo.getBucketName());
|
||||
|
||||
// 创建目录元数据并保存到数据库
|
||||
fileMetadataInfoService.lambdaUpdate()
|
||||
.set(FileMetadataInfo::getObjectKey,scriptFileMinioObjectKey)
|
||||
.set(FileMetadataInfo::getObjectKey,fileMinioObjectKey)
|
||||
.set(FileMetadataInfo::getOriginalName,originalFilename)
|
||||
.set(FileMetadataInfo::getFileSize,updateFile.getSize())
|
||||
.eq(FileMetadataInfo::getId,req.getScriptFileId())
|
||||
.eq(FileMetadataInfo::getId,req.getUpdateFileId())
|
||||
.update();
|
||||
return SdmResponse.success(req.getScriptFileId());
|
||||
return SdmResponse.success(req.getUpdateFileId());
|
||||
} catch (Exception e) {
|
||||
minioService.deleteFile(scriptFileMinioObjectKey, scriptDirMetadataInfo.getBucketName());
|
||||
log.error("更新传脚本文件", e);
|
||||
throw new RuntimeException("更新传脚本文件: " + e.getMessage(), e);
|
||||
minioService.deleteFile(fileMinioObjectKey, dirMetadataInfo.getBucketName());
|
||||
log.error("更新文件失败", e);
|
||||
throw new RuntimeException("更新文件失败: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ public class ISysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> implem
|
||||
wrapper.ge(SysLog::getCreateTime, sysLog.getCreateTimeArr()[0])
|
||||
.le(SysLog::getCreateTime, sysLog.getCreateTimeArr()[1]);
|
||||
}
|
||||
wrapper.orderByDesc(SysLog::getCreateTime);
|
||||
PageHelper.startPage(sysLog.getCurrent(), sysLog.getSize());
|
||||
List<SysLog> sysLogList = this.list(wrapper);
|
||||
PageInfo<SysLog> page = new PageInfo<>(sysLogList);
|
||||
|
||||
@@ -63,14 +63,14 @@ public class SimulationMessageServiceImpl implements ISimulationMessageService {
|
||||
userReq.setTenantId(ThreadLocalContext.getTenantId());
|
||||
SdmResponse<CIDUserResp> sdmResponse = sysUserFeignClient.queryUserDetail(userReq);
|
||||
if (sdmResponse.getData() != null) {
|
||||
param.setJobNo(sdmResponse.getData().getJobNumber());
|
||||
param.setJobNo(sdmResponse.getData().getUsername());
|
||||
}
|
||||
FreeLinkMsg freeLinkMsg = new FreeLinkMsg();
|
||||
if (switchFlag.equals("true")) {
|
||||
userReq.setUserId(Long.valueOf(req.getUserId()));
|
||||
SdmResponse<CIDUserResp> response = sysUserFeignClient.queryUserDetail(userReq);
|
||||
if (response.getData() != null) {
|
||||
freeLinkMsg.setId(response.getData().getJobNumber());
|
||||
freeLinkMsg.setId(response.getData().getUsername());
|
||||
}
|
||||
} else {
|
||||
freeLinkMsg.setId(sendUserId);
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.sdm.system.service.impl.approvalNotice;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.enums.ApproveTypeEnum;
|
||||
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
||||
import com.sdm.common.feign.impl.capability.SimulationReportFeignClientImpl;
|
||||
import com.sdm.common.feign.inter.capability.ISimulationFlowFeignClient;
|
||||
import com.sdm.common.feign.inter.capability.ISimulationReportFeignClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class SimulationReportTemplateNoticeStrategy extends ApproveAbstractNoticeStrategy {
|
||||
|
||||
@Autowired
|
||||
private SimulationReportFeignClientImpl reportFeignClient;
|
||||
// 这个回调场景值和 LaunchApproveReq 类里的 approveType 对应
|
||||
// 审批类型 0.http回调的,replyUrl必须传递,相当于是跨系统的,调用的时候可以不传,replyUrl必须传递 ;1:仿真地图审批(spdm内部feign) 2:知识库审批(spdm内部feign)
|
||||
@Override
|
||||
protected int getNoticeType() {
|
||||
return ApproveTypeEnum.REPORT_TEMPLATE_APPROVE.getCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse noticeResult(LaunchApproveReq req) {
|
||||
return reportFeignClient.receiveApproveNotice(req);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user