集成CID仿真评审流
This commit is contained in:
@@ -8,6 +8,7 @@ import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Base64;
|
||||
|
||||
@Slf4j
|
||||
public class SystemOperate {
|
||||
@@ -51,6 +52,10 @@ public class SystemOperate {
|
||||
});
|
||||
}
|
||||
|
||||
public static String base64Encode(String str) {
|
||||
return Base64.getEncoder().encodeToString(str.getBytes());
|
||||
}
|
||||
|
||||
/**
|
||||
* <20><><EFBFBD>Ŀ¼<C4BF><C2BC><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>Ŀ¼
|
||||
*
|
||||
|
||||
@@ -352,8 +352,8 @@ public class Tools {
|
||||
/**
|
||||
* 清理路径下空的文件夹,返回路径下包含的文件数量
|
||||
*
|
||||
* @param path
|
||||
* @param filterFiles
|
||||
* @param
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public static int emptyDirCleanAndIncludeFilesCount(File topFile, List<String> ignoreFiles) {
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.sdm.system.controller;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.system.model.entity.ApproveFlowBean;
|
||||
import com.sdm.system.service.ISimulatinoApprovalService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统评审
|
||||
* </p>
|
||||
*
|
||||
* @author author
|
||||
* @since 2025-09-22
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/systemApprove")
|
||||
@Tag(name = "系统评审")
|
||||
public class SystemApproveController {
|
||||
|
||||
@Autowired
|
||||
private ISimulatinoApprovalService approveServer;
|
||||
|
||||
@PostMapping("/launchApprove")
|
||||
public SdmResponse launchApproval(@RequestBody ApproveFlowBean flowBean){
|
||||
return approveServer.launchApproval(flowBean.approveTitle,flowBean.approveType,flowBean.innerFlowId,flowBean.comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统评审状态通知
|
||||
* @param flowBean
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/approveStatusNotice")
|
||||
public SdmResponse systemApproveNotice(@RequestBody ApproveFlowBean flowBean) {
|
||||
return approveServer.receiveApprovalResult(flowBean.cidFlowId,flowBean.approveStatus);
|
||||
}
|
||||
|
||||
/*@PostMapping("/stopApprove")
|
||||
public SdmResponse stopApproval(@Param("flowId") String flowId, @Param("userId") String userId) {
|
||||
approveServer.stopCidApprovalFlow(flowId,userId);
|
||||
return SdmResponse.success();
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.sdm.system.dao;
|
||||
|
||||
import com.sdm.system.model.bo.DataDictionary;
|
||||
import com.sdm.system.model.bo.DictionaryClass;
|
||||
import com.sdm.system.model.bo.FormConfigure;
|
||||
import com.sdm.system.model.entity.ApproveConfigBean;
|
||||
import com.sdm.system.model.entity.ApproveFlowBean;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SimulationApproveMapper {
|
||||
|
||||
|
||||
@Insert("INSERT INTO simulation_approve_flow(innerFlowId,cidFlowId,approveTitle,approveStatus,approveType,comment,creator) VALUES (#{flowBean.innerFlowId},#{flowBean.cidFlowId},#{flowBean.approveTitle},#{flowBean.approveStatus},#{flowBean.approveType},#{flowBean.comment},#{flowBean.creator})")
|
||||
int addSimulationApproveFlow(@Param("flowBean") ApproveFlowBean flowBean);
|
||||
|
||||
@Update("UPDATE simulation_approve_flow SET approveStatus=#{status} WHERE cidFlowId=#{cidFlowId}")
|
||||
int updateSimulationApproveFlowStatus(@Param("cidFlowId") String cidFlowId,@Param("status") int status);
|
||||
|
||||
@Select("SELECT * FROM simulation_approve_flow WHERE innerFlowId=#{flowId}")
|
||||
ApproveFlowBean querySimulationApproveFlowByInnerFlowId(@Param("flowId") int flowId);
|
||||
|
||||
@Select("SELECT * FROM simulation_approve_flow WHERE cidFlowId=#{flowId} LIMIT 1")
|
||||
ApproveFlowBean querySimulationApproveFlowByCidFlowId(@Param("flowId") String flowId);
|
||||
|
||||
@Insert("INSERT INTO simulation_approve_config(approveType,cidFlowTemplate,url,creator) VALUES (#{config.approveType},#{config.cidFlowTemplate},#{config.url},#{config.creator})")
|
||||
int addSimulationApproveConfig(@Param("config")ApproveConfigBean config);
|
||||
|
||||
@Select("SELECT * FROM simulation_approve_config WHERE approveType=#{approveType} LIMIT 1")
|
||||
ApproveConfigBean querySimulationApproveConfig(@Param("approveType") int approveType);
|
||||
|
||||
@Delete("DELETE FROM simulation_approve_config WHERE id=#{id}")
|
||||
int deleteSimulationApproveConfig(@Param("id") int id);
|
||||
|
||||
@Update("UPDATE simulation_approve_config SET cidFlowTemplate=#{config.cidFlowTemplate},url=#{config.url}")
|
||||
int updateSimulationApproveConfig(@Param("config")ApproveConfigBean config);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.sdm.system.model.entity;
|
||||
|
||||
import com.sdm.common.entity.bo.BaseBean;
|
||||
|
||||
public class ApproveConfigBean extends BaseBean {
|
||||
|
||||
public ApproveConfigBean()
|
||||
{
|
||||
init();
|
||||
}
|
||||
public int id;
|
||||
|
||||
public int approveType; //评审类型
|
||||
|
||||
public String cidFlowTemplate; //cid评审模版
|
||||
|
||||
public String url; //cid评审URL
|
||||
|
||||
public String creator; //配置创建者
|
||||
|
||||
public String createTime; //配置创建时间
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.sdm.system.model.entity;
|
||||
|
||||
import com.sdm.common.entity.bo.BaseBean;
|
||||
|
||||
public class ApproveFlowBean extends BaseBean {
|
||||
public ApproveFlowBean() {
|
||||
init();
|
||||
approveStatus = 1;
|
||||
}
|
||||
public int id;
|
||||
|
||||
public int innerFlowId; //SPDM系统内部流程ID
|
||||
|
||||
public String cidFlowId; //CID生成的流程ID
|
||||
|
||||
public int approveType; //审批类型
|
||||
|
||||
public String approveTitle; //审批主题
|
||||
|
||||
public int approveStatus; //审批状态 1: 审批中 2:审批通过 3:审批不通过
|
||||
|
||||
public String comment; //审批描述
|
||||
|
||||
public String creator; //审批创建者
|
||||
|
||||
public String createTime; //审批创建时间
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.sdm.system.service;
|
||||
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.utils.SystemOperate;
|
||||
import com.sdm.system.model.entity.AppCenterItemBean;
|
||||
import com.sdm.system.model.entity.AppConfigureBean;
|
||||
import com.sdm.system.model.entity.ApproveFlowBean;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统提交评审服务
|
||||
* </p>
|
||||
*
|
||||
* @author author
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
public interface ISimulatinoApprovalService {
|
||||
|
||||
|
||||
SdmResponse queryApprovalTemplates(String group,String tenantId);
|
||||
|
||||
boolean stopCidApprovalFlow(String flowId,String userId,String url);
|
||||
|
||||
SdmResponse launchApproval(String approveTitle,int approveType,int innerFlowId,String comment);
|
||||
|
||||
SdmResponse receiveApprovalResult(String cidFlowId,int status);
|
||||
|
||||
SdmResponse approvalResultNotice(ApproveFlowBean flowBean);
|
||||
|
||||
}
|
||||
@@ -163,7 +163,6 @@ public class SimulationAppCenterServiceImpl extends BaseService implements ISimu
|
||||
{
|
||||
response = SdmResponse.failed("添加应用配置失败");
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
package com.sdm.system.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.utils.HttpClientUtil;
|
||||
import com.sdm.system.dao.SimulationApproveMapper;
|
||||
import com.sdm.system.model.entity.ApproveConfigBean;
|
||||
import com.sdm.system.model.entity.ApproveFlowBean;
|
||||
import com.sdm.system.service.ISimulatinoApprovalService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SimulationApproveServiceImpl implements ISimulatinoApprovalService {
|
||||
|
||||
@Autowired
|
||||
private HttpClientUtil httpClientUtil;
|
||||
|
||||
@Autowired
|
||||
private SimulationApproveMapper approveMapper;
|
||||
@Override
|
||||
public SdmResponse queryApprovalTemplates(String group, String tenantId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向CID发起审批流程
|
||||
* @param flowId
|
||||
* @param userId
|
||||
* @return string 返回审批流ID
|
||||
*/
|
||||
private String launchCidApprovalFlow(String flowId,String userId,String tenantId,String url)
|
||||
{
|
||||
JSONObject paramJson = new JSONObject();
|
||||
paramJson.put("flowId",flowId);
|
||||
paramJson.put("startUserId",userId);
|
||||
paramJson.put("tenantId",tenantId);
|
||||
String cidFlowId = "";
|
||||
try {
|
||||
String resultString = httpClientUtil.doPostJson(url+"/startFlow", paramJson.toJSONString());
|
||||
if (resultString != null && !resultString.isEmpty()) {
|
||||
JSONObject resultJson = JSONObject.parseObject(resultString);
|
||||
if (resultJson != null && resultJson.containsKey("success")) {
|
||||
boolean success = resultJson.getBoolean("success");
|
||||
if (success) {
|
||||
cidFlowId = resultJson.getString("data");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return cidFlowId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止cid评审流程
|
||||
* @param flowId
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
public boolean stopCidApprovalFlow(String flowId,String userId,String url)
|
||||
{
|
||||
JSONObject paramJson = new JSONObject();
|
||||
paramJson.put("processInstanceId",flowId);
|
||||
paramJson.put("userId",userId);
|
||||
try {
|
||||
String resultString = httpClientUtil.doPostJson(url+"/stopFlow", paramJson.toJSONString());
|
||||
if (resultString != null && !resultString.isEmpty()) {
|
||||
JSONObject resultJson = JSONObject.parseObject(resultString);
|
||||
if (resultJson != null && resultJson.containsKey("success")) {
|
||||
return resultJson.getBoolean("success");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发起审批流
|
||||
* @param approveTitle
|
||||
* @param approveType
|
||||
* @param approveId
|
||||
* @param comment
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public SdmResponse launchApproval(String approveTitle, int approveType, int approveId,String comment) {
|
||||
|
||||
SdmResponse sdmResponse = SdmResponse.success();
|
||||
ApproveConfigBean configBean = approveMapper.querySimulationApproveConfig(approveType);
|
||||
if(configBean == null){
|
||||
sdmResponse = SdmResponse.failed("评审配置信息不存在");
|
||||
return sdmResponse;
|
||||
}
|
||||
String cidFlowId = launchCidApprovalFlow(configBean.cidFlowTemplate, "1979078323595476993","1979091834410176514",configBean.url);
|
||||
if (cidFlowId.isEmpty()) {
|
||||
sdmResponse = SdmResponse.failed("发起Cid审批流程失败");
|
||||
} else {
|
||||
ApproveFlowBean approveFlowBean = new ApproveFlowBean();
|
||||
approveFlowBean.approveTitle = approveTitle;
|
||||
approveFlowBean.cidFlowId = cidFlowId;
|
||||
approveFlowBean.approveType = approveType;
|
||||
approveFlowBean.comment = comment;
|
||||
approveFlowBean.innerFlowId = approveId;
|
||||
if (approveMapper.addSimulationApproveFlow(approveFlowBean) <= 0) {
|
||||
sdmResponse = SdmResponse.failed("保存审批流程失败");
|
||||
if(!stopCidApprovalFlow(cidFlowId,"1979078323595476993",configBean.url))
|
||||
{
|
||||
log.error("删除CID审批流["+cidFlowId+"]失败");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sdmResponse.setData(cidFlowId);
|
||||
}
|
||||
}
|
||||
return sdmResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收CID审批流状态
|
||||
* @param cidFlowId
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public SdmResponse receiveApprovalResult(String cidFlowId,int status) {
|
||||
|
||||
SdmResponse sdmResponse = SdmResponse.success();
|
||||
if(approveMapper.updateSimulationApproveFlowStatus(cidFlowId,status) <= 0)
|
||||
{
|
||||
sdmResponse = SdmResponse.failed("更新审批流程状态失败");
|
||||
}
|
||||
else
|
||||
{
|
||||
ApproveFlowBean flowBean = approveMapper.querySimulationApproveFlowByCidFlowId(cidFlowId);
|
||||
if(flowBean == null)
|
||||
{
|
||||
sdmResponse = SdmResponse.failed("获取审批流程信息失败");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(status > 1) { //评审结束后通知评审发起模块
|
||||
approvalResultNotice(flowBean);
|
||||
}
|
||||
}
|
||||
}
|
||||
return sdmResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 审批状态通知到发起审批模块
|
||||
* @param flowBean
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public SdmResponse approvalResultNotice(ApproveFlowBean flowBean) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -21,7 +21,6 @@ public class SimulationTaskController {
|
||||
|
||||
@Autowired
|
||||
private ISimulationTaskService simulationTaskService;
|
||||
|
||||
/**
|
||||
* 分页查询工况数据
|
||||
* @param querySimulationTaskReq 查询条件
|
||||
|
||||
Reference in New Issue
Block a user