集成CID仿真评审流
This commit is contained in:
@@ -13,5 +13,4 @@ public class ApproveApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ApproveApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,9 @@ import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Base64;
|
||||
import java.util.Date;
|
||||
|
||||
@Slf4j
|
||||
public class SystemOperate {
|
||||
@@ -19,11 +21,10 @@ public class SystemOperate {
|
||||
String osName = System.getProperty("os.name");
|
||||
osName = osName.toLowerCase();
|
||||
String[] shCmd = null;
|
||||
if(osName.contains("linux")) {
|
||||
if (osName.contains("linux")) {
|
||||
String[] linuxCmd = {"/bin/sh", "-c", command};
|
||||
shCmd = linuxCmd;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
String[] winCmd = {"cmd", "/c", command};
|
||||
shCmd = winCmd;
|
||||
}
|
||||
@@ -110,41 +111,39 @@ public class SystemOperate {
|
||||
|
||||
/**
|
||||
* 向http response中输出文件流
|
||||
*
|
||||
* @param
|
||||
* @param inputFileName
|
||||
* @param outputFileName
|
||||
*/
|
||||
public static void outputHttpFileStream(HttpServletResponse httpServletResponse,String inputFileName,String outputFileName)
|
||||
{
|
||||
try {
|
||||
public static void outputHttpFileStream(HttpServletResponse httpServletResponse, String inputFileName, String outputFileName) {
|
||||
try {
|
||||
|
||||
File file = new File(inputFileName);
|
||||
if (!file.exists()) {
|
||||
return;
|
||||
} else {
|
||||
String encodeFileName = URLEncoder.encode(outputFileName, "UTF-8");
|
||||
encodeFileName = encodeFileName.replaceAll("\\+", "%20");
|
||||
httpServletResponse.reset();
|
||||
httpServletResponse.setCharacterEncoding("UTF-8");
|
||||
String contentType = Files.probeContentType(Paths.get(inputFileName));
|
||||
if (contentType == null) {
|
||||
contentType = MediaType.APPLICATION_OCTET_STREAM_VALUE;
|
||||
}
|
||||
httpServletResponse.addHeader("Content-Disposition", "attachment;filename=\"" + encodeFileName + "\";filename*=utf-8");
|
||||
httpServletResponse.addHeader("Content-Length", "" + file.length());
|
||||
httpServletResponse.addHeader("Content-Type", contentType);
|
||||
OutputStream outputStream = new BufferedOutputStream(httpServletResponse.getOutputStream());
|
||||
InputStream inputStream = new FileInputStream(file);
|
||||
outputStream.write(inputStream.readAllBytes());
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
inputStream.close();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
File file = new File(inputFileName);
|
||||
if (!file.exists()) {
|
||||
return;
|
||||
} else {
|
||||
String encodeFileName = URLEncoder.encode(outputFileName, "UTF-8");
|
||||
encodeFileName = encodeFileName.replaceAll("\\+", "%20");
|
||||
httpServletResponse.reset();
|
||||
httpServletResponse.setCharacterEncoding("UTF-8");
|
||||
String contentType = Files.probeContentType(Paths.get(inputFileName));
|
||||
if (contentType == null) {
|
||||
contentType = MediaType.APPLICATION_OCTET_STREAM_VALUE;
|
||||
}
|
||||
httpServletResponse.addHeader("Content-Disposition", "attachment;filename=\"" + encodeFileName + "\";filename*=utf-8");
|
||||
httpServletResponse.addHeader("Content-Length", "" + file.length());
|
||||
httpServletResponse.addHeader("Content-Type", contentType);
|
||||
OutputStream outputStream = new BufferedOutputStream(httpServletResponse.getOutputStream());
|
||||
InputStream inputStream = new FileInputStream(file);
|
||||
outputStream.write(inputStream.readAllBytes());
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
inputStream.close();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -152,4 +151,10 @@ public class SystemOperate {
|
||||
process.destroy();
|
||||
}
|
||||
|
||||
public static String getCurrentTime()
|
||||
{
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
return sdf.format(new Date());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
59
pbs/src/main/java/com/sdm/pbs/dao/SimulationFlowMapper.java
Normal file
59
pbs/src/main/java/com/sdm/pbs/dao/SimulationFlowMapper.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package com.sdm.pbs.dao;
|
||||
|
||||
|
||||
import com.sdm.pbs.model.entity.SimulationFlowInstance;
|
||||
import com.sdm.pbs.model.entity.SimulationFlowTemplate;
|
||||
import com.sdm.pbs.model.entity.SimulationFlowMember;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SimulationFlowMapper {
|
||||
|
||||
@Insert("INSERT INTO simulation_flow_template(uuid,templateName,version,template,templateStatus,templateType,approveStatus,comment,tenantId,creator) VALUES(#{template.uuid},#{template.templateName},#{template.version},#{template.template},#{template.templateStatus},#{template.templateType},#{template.approveStatus},#{template.comment},#{template.tenantId},#{template.creator})")
|
||||
int addSimulationFlowTemplate(@Param("template") SimulationFlowTemplate template);
|
||||
|
||||
@Update("UPDATE simulation_flow_template SET templateName=#{template.templateName},templateType=#{template.templateType},approveStatus=#{template.approveStatus},version=#{template.version},template=#{template.template},templateStatus=#{template.templateStatus},comment=#{template.comment},tenantId=#{template.tenantId} WHERE uuid=#{template.uuid}")
|
||||
int updateSimulationFlowTemplate(@Param("template") SimulationFlowTemplate template);
|
||||
|
||||
@Select("SELECT * FROM simulation_flow_template WHERE approveStatus=1")
|
||||
List<SimulationFlowTemplate> querySimulationAllFlowTemplate();
|
||||
|
||||
@Select("SELECT templateName FROM simulation_flow_template")
|
||||
List<String> querySimulateAllTemplateName();
|
||||
|
||||
@Select("SELECT DISTINCT(version) FROM simulation_flow_template WHERE uuid=#{templateId}")
|
||||
List<String> querySimulationFlowTemplateVersion(@Param("templateId") String templateId);
|
||||
|
||||
@Update("UPDATE simulation_flow_template SET approveStatus=#{approveStatus} WHERE uuid=#{templateId}")
|
||||
int updateSimulationFlowTemplateApproveStatus(@Param("approveStatus") int approveStatus, @Param("templateId") String templateId);
|
||||
|
||||
@Delete("DELETE FROM simulation_flow_template WHERE uuid=#{templateId}")
|
||||
int deleteSimulationFlowTemplate(@Param("templateId") String templateId);
|
||||
|
||||
@Insert("INSERT INTO simulation_flow_instance(uuid,flowName,templateName,templateId,nodeId,nodeName,taskId,taskName,runId,runName,flowStatus,workPath,currentPhase,planEndTime,beginTime,endTime,tenantId,creator) VALUES (#{instance.uuid},#{instance.flowName},#{instance.templateName},#{instance.templateId},#{instance.nodeId},#{instance.nodeName},#{instance.taskId},#{instance.taskName},#{instance.runId},#{instance.runName},#{instance.flowStatus},#{instance.workPath},#{instance.currentPhase},#{instance.planEndTime},#{instance.beginTime},#{instance.endTime},#{instance.tenantId},#{instance.creator})")
|
||||
int addSimulationFlowTemplateInstance(@Param("instance")SimulationFlowInstance instance);
|
||||
|
||||
@Update("UPDATE simulation_flow_instance SET nodeId=#{instance.nodeId},nodeName=#{instance.nodeName},taskId=#{instance.taskId},taskName=#{instance.taskName},runId=#{instance.runId},runName=#{instance.runName},flowStatus=#{instance.flowStatus},workPath=#{instance.workPath},currentPath=#{instance.currentPath},planEndTime=#{instance.planEndTime},beginTime=#{instance.beginTime},endTime=#{instance.endTime} WHERE uuid=#{instance.uuid}")
|
||||
int updateSimulationFlowInstance(@Param("instance")SimulationFlowInstance instance);
|
||||
|
||||
@Delete("DELETE FROM simulation_flow_instance WHERE uuid=#{instanceId}")
|
||||
int deleteSimulationFlowInstance(@Param("instanceId") int instanceId);
|
||||
|
||||
@Select("SELECT * FROM simulation_flow_instance WHERE ${condition}")
|
||||
List<SimulationFlowInstance> querySimulationFlowInstanceByCondition(@Param("condition") String condition);
|
||||
|
||||
@Insert("INSERT INTO simulation_flow_member(flowId,flowName,memberName,memberId,role,creator) VALUES (#{member.flowId},#{member.flowName},#{member.memberName},#{member.memberId},#{member.role},#{member.creator})")
|
||||
int addSimulationFlowInstanceMember(@Param("member") SimulationFlowMember member);
|
||||
|
||||
@Update("UPDATE simulation_flow_member SET memberName=#{member.memberName},memberId=#{member.memberId} role=#{member.role} WHERE id=#{member.id}")
|
||||
int updateSimulationFlowInstanceMember(@Param("member") SimulationFlowMember member);
|
||||
|
||||
@Delete("DELETE FROM simulation_flow_member WHERE id=#{id}")
|
||||
int deleteSimulationFlowInstanceMember(@Param("id") int id);
|
||||
|
||||
@Select("SELECT * FROM simulation_flow_member WHERE flowId=#{flowId}")
|
||||
List<SimulationFlowMember> querySimulationFlowMember(@Param("flowId") String flowId);
|
||||
|
||||
}
|
||||
118
pbs/src/main/java/com/sdm/pbs/flow/AbstractFlowNode.java
Normal file
118
pbs/src/main/java/com/sdm/pbs/flow/AbstractFlowNode.java
Normal file
@@ -0,0 +1,118 @@
|
||||
package com.sdm.pbs.flow;
|
||||
|
||||
import com.sdm.common.utils.SystemOperate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractFlowNode extends FlowNodeBean implements IFlowNode{
|
||||
|
||||
public AbstractFlowNode(FlowNodeBean nodeBean)
|
||||
{
|
||||
this.nodeName = nodeBean.nodeName;
|
||||
this.nodeId = nodeBean.nodeId;
|
||||
this.flowId = nodeBean.flowId;
|
||||
this.beginTime = nodeBean.beginTime;
|
||||
this.endTime = nodeBean.endTime;
|
||||
this.exeCmd = nodeBean.exeCmd;
|
||||
this.nodeParams = nodeBean.nodeParams;
|
||||
this.nodeStatus = nodeBean.nodeStatus;
|
||||
this.nodeType = nodeBean.nodeType;
|
||||
this.description = nodeBean.description;
|
||||
this.preProcessCmd = nodeBean.preProcessCmd;
|
||||
this.postProcessCmd = nodeBean.postProcessCmd;
|
||||
}
|
||||
protected List<AbstractFlowNode> children = new ArrayList<>();
|
||||
@Override
|
||||
public String getNodeName() {
|
||||
return nodeName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFlowId() {
|
||||
return flowId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNodeType() {
|
||||
return nodeType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNodeStatus() {
|
||||
return nodeStatus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setNodeStatus(int status) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeParams() {
|
||||
return nodeParams;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNodeParams(String params) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNodeExeCmd(String cmd) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeExeCmd() {
|
||||
return exeCmd;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBeginTime() {
|
||||
return beginTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeginTime(String beginTime) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEndTime(String endTime) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute()
|
||||
{
|
||||
setBeginTime(SystemOperate.getCurrentTime());
|
||||
//执行前处理
|
||||
preProcess();
|
||||
//执行节点命令或脚本
|
||||
handle();
|
||||
//执行后处理
|
||||
postProcess();
|
||||
//执行下一步节点
|
||||
setEndTime(SystemOperate.getCurrentTime());
|
||||
succeed();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
40
pbs/src/main/java/com/sdm/pbs/flow/CloudAppFlowNode.java
Normal file
40
pbs/src/main/java/com/sdm/pbs/flow/CloudAppFlowNode.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package com.sdm.pbs.flow;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class CloudAppFlowNode extends AbstractFlowNode{
|
||||
public CloudAppFlowNode(FlowNodeBean nodeBean)
|
||||
{
|
||||
super(nodeBean);
|
||||
nodeType = 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preProcess() {
|
||||
setNodeStatus(1);
|
||||
//为流程新建工作空间
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcess() {
|
||||
|
||||
setNodeStatus(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle() {
|
||||
log.info("流程开始");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void succeed() {
|
||||
if(nodeStatus == 2)
|
||||
{
|
||||
for(AbstractFlowNode flowNode : children)
|
||||
{
|
||||
flowNode.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
41
pbs/src/main/java/com/sdm/pbs/flow/ConditionFlowNode.java
Normal file
41
pbs/src/main/java/com/sdm/pbs/flow/ConditionFlowNode.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package com.sdm.pbs.flow;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class ConditionFlowNode extends AbstractFlowNode{
|
||||
public ConditionFlowNode(FlowNodeBean nodeBean)
|
||||
{
|
||||
super(nodeBean);
|
||||
nodeType = 8;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void preProcess() {
|
||||
setNodeStatus(1);
|
||||
//为流程新建工作空间
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcess() {
|
||||
|
||||
setNodeStatus(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle() {
|
||||
log.info("流程开始");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void succeed() {
|
||||
if(nodeStatus == 2)
|
||||
{
|
||||
for(AbstractFlowNode flowNode : children)
|
||||
{
|
||||
flowNode.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
44
pbs/src/main/java/com/sdm/pbs/flow/EndFlowNode.java
Normal file
44
pbs/src/main/java/com/sdm/pbs/flow/EndFlowNode.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package com.sdm.pbs.flow;
|
||||
|
||||
import com.sdm.common.utils.SystemOperate;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class EndFlowNode extends AbstractFlowNode{
|
||||
public EndFlowNode(FlowNodeBean nodeBean)
|
||||
{
|
||||
super(nodeBean);
|
||||
nodeType = 9;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void preProcess() {
|
||||
setNodeStatus(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcess() {
|
||||
setNodeStatus(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle() {
|
||||
log.info("流程结束");
|
||||
if(exeCmd != null && exeCmd.length() > 0)
|
||||
{
|
||||
try {
|
||||
SystemOperate.exeShellCmd(exeCmd);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void succeed() {
|
||||
|
||||
}
|
||||
}
|
||||
25
pbs/src/main/java/com/sdm/pbs/flow/FlowNodeBean.java
Normal file
25
pbs/src/main/java/com/sdm/pbs/flow/FlowNodeBean.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.sdm.pbs.flow;
|
||||
|
||||
import com.sdm.common.entity.bo.BaseBean;
|
||||
|
||||
|
||||
public class FlowNodeBean extends BaseBean {
|
||||
|
||||
public FlowNodeBean()
|
||||
{
|
||||
init();
|
||||
}
|
||||
protected String nodeId;
|
||||
protected String nodeName;//节点名称
|
||||
protected String workPath;//节点工作路径
|
||||
protected int nodeType;//节点类型 0:启动节点 1:配置节点 2:本地应用 3:云应用 4:执行节点 5:逻辑与 6:逻辑或 7:逻辑循环 8:条件节点 9:结束节点
|
||||
protected int nodeStatus;//节点状态 0:未执行 1:执行中 2:完成 3:失败 4:停止
|
||||
protected String flowId;//节点所属流程Id
|
||||
protected String nodeParams;//节点参数
|
||||
protected String exeCmd;//节点执行命令
|
||||
protected String preProcessCmd;//前处理
|
||||
protected String postProcessCmd;//后处理
|
||||
protected String beginTime;//节点开始时间
|
||||
protected String endTime;//节点结束时间
|
||||
protected String description;//节点描述
|
||||
}
|
||||
41
pbs/src/main/java/com/sdm/pbs/flow/HpcFlowNode.java
Normal file
41
pbs/src/main/java/com/sdm/pbs/flow/HpcFlowNode.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package com.sdm.pbs.flow;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class HpcFlowNode extends AbstractFlowNode{
|
||||
public HpcFlowNode(FlowNodeBean nodeBean)
|
||||
{
|
||||
super(nodeBean);
|
||||
nodeType = 4;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void preProcess() {
|
||||
setNodeStatus(1);
|
||||
//为流程新建工作空间
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcess() {
|
||||
|
||||
setNodeStatus(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle() {
|
||||
log.info("流程开始");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void succeed() {
|
||||
if(nodeStatus == 2)
|
||||
{
|
||||
for(AbstractFlowNode flowNode : children)
|
||||
{
|
||||
flowNode.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
44
pbs/src/main/java/com/sdm/pbs/flow/IFlowNode.java
Normal file
44
pbs/src/main/java/com/sdm/pbs/flow/IFlowNode.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package com.sdm.pbs.flow;
|
||||
|
||||
public interface IFlowNode {
|
||||
|
||||
String getNodeName();
|
||||
|
||||
String getFlowId();
|
||||
|
||||
int getNodeType();
|
||||
|
||||
int getNodeStatus();
|
||||
|
||||
int setNodeStatus(int status);
|
||||
|
||||
void stop();
|
||||
|
||||
void start();
|
||||
|
||||
String getNodeParams();
|
||||
|
||||
void setNodeParams(String params);
|
||||
|
||||
void setNodeExeCmd(String cmd);
|
||||
|
||||
String getNodeExeCmd();
|
||||
|
||||
void execute();
|
||||
|
||||
void preProcess();
|
||||
|
||||
void postProcess();
|
||||
|
||||
void handle();
|
||||
|
||||
void succeed();
|
||||
|
||||
String getBeginTime();
|
||||
|
||||
void setBeginTime(String beginTime);
|
||||
|
||||
String getEndTime();
|
||||
|
||||
void setEndTime(String endTime);
|
||||
}
|
||||
41
pbs/src/main/java/com/sdm/pbs/flow/LocalAppFlowNode.java
Normal file
41
pbs/src/main/java/com/sdm/pbs/flow/LocalAppFlowNode.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package com.sdm.pbs.flow;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class LocalAppFlowNode extends AbstractFlowNode{
|
||||
public LocalAppFlowNode(FlowNodeBean nodeBean)
|
||||
{
|
||||
super(nodeBean);
|
||||
nodeType = 2;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void preProcess() {
|
||||
setNodeStatus(1);
|
||||
//为流程新建工作空间
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcess() {
|
||||
|
||||
setNodeStatus(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle() {
|
||||
log.info("流程开始");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void succeed() {
|
||||
if(nodeStatus == 2)
|
||||
{
|
||||
for(AbstractFlowNode flowNode : children)
|
||||
{
|
||||
flowNode.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
41
pbs/src/main/java/com/sdm/pbs/flow/LogicAndFlowNode.java
Normal file
41
pbs/src/main/java/com/sdm/pbs/flow/LogicAndFlowNode.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package com.sdm.pbs.flow;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class LogicAndFlowNode extends AbstractFlowNode{
|
||||
public LogicAndFlowNode(FlowNodeBean nodeBean)
|
||||
{
|
||||
super(nodeBean);
|
||||
nodeType = 5;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void preProcess() {
|
||||
setNodeStatus(1);
|
||||
//为流程新建工作空间
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcess() {
|
||||
|
||||
setNodeStatus(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle() {
|
||||
log.info("流程开始");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void succeed() {
|
||||
if(nodeStatus == 2)
|
||||
{
|
||||
for(AbstractFlowNode flowNode : children)
|
||||
{
|
||||
flowNode.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
41
pbs/src/main/java/com/sdm/pbs/flow/LogicOrFlowNode.java
Normal file
41
pbs/src/main/java/com/sdm/pbs/flow/LogicOrFlowNode.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package com.sdm.pbs.flow;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class LogicOrFlowNode extends AbstractFlowNode{
|
||||
public LogicOrFlowNode(FlowNodeBean nodeBean)
|
||||
{
|
||||
super(nodeBean);
|
||||
nodeType = 6;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void preProcess() {
|
||||
setNodeStatus(1);
|
||||
//为流程新建工作空间
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcess() {
|
||||
|
||||
setNodeStatus(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle() {
|
||||
log.info("流程开始");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void succeed() {
|
||||
if(nodeStatus == 2)
|
||||
{
|
||||
for(AbstractFlowNode flowNode : children)
|
||||
{
|
||||
flowNode.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
42
pbs/src/main/java/com/sdm/pbs/flow/LoopFlowNode.java
Normal file
42
pbs/src/main/java/com/sdm/pbs/flow/LoopFlowNode.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package com.sdm.pbs.flow;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class LoopFlowNode extends AbstractFlowNode{
|
||||
|
||||
public LoopFlowNode(FlowNodeBean nodeBean)
|
||||
{
|
||||
super(nodeBean);
|
||||
nodeType = 7;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void preProcess() {
|
||||
setNodeStatus(1);
|
||||
//为流程新建工作空间
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcess() {
|
||||
|
||||
setNodeStatus(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void succeed() {
|
||||
if(nodeStatus == 2)
|
||||
{
|
||||
for(AbstractFlowNode flowNode : children)
|
||||
{
|
||||
flowNode.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
41
pbs/src/main/java/com/sdm/pbs/flow/StartFlowNode.java
Normal file
41
pbs/src/main/java/com/sdm/pbs/flow/StartFlowNode.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package com.sdm.pbs.flow;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class StartFlowNode extends AbstractFlowNode{
|
||||
public StartFlowNode(FlowNodeBean nodeBean)
|
||||
{
|
||||
super(nodeBean);
|
||||
nodeType = 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void preProcess() {
|
||||
setNodeStatus(1);
|
||||
//为流程新建工作空间
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcess() {
|
||||
|
||||
setNodeStatus(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle() {
|
||||
log.info("流程开始");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void succeed() {
|
||||
if(nodeStatus == 2)
|
||||
{
|
||||
for(AbstractFlowNode flowNode : children)
|
||||
{
|
||||
flowNode.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.sdm.pbs.model.entity;
|
||||
|
||||
import com.sdm.common.entity.bo.BaseBean;
|
||||
|
||||
public class SimulationFlowInstance extends BaseBean {
|
||||
|
||||
public SimulationFlowInstance(){
|
||||
init();
|
||||
}
|
||||
public int id;
|
||||
|
||||
public String uuid; //流程实例唯一ID
|
||||
|
||||
public String flowName; //流程实例名称
|
||||
|
||||
public String nodeId; //流程实例所属节点UUID
|
||||
|
||||
public String nodeName; //流程实例所属节点名称
|
||||
|
||||
public String taskId; //流程实例所属任务UUID
|
||||
|
||||
public String taskName; //流程实例所属任务名称
|
||||
|
||||
public String runId; //流程实例所属Run UUID
|
||||
|
||||
public String runName; //流程实例所属Run名称
|
||||
|
||||
public int flowStatus; //流程实例状态 0:未开始 1:进行中 2:已完成 3:失败 4:停止
|
||||
|
||||
public String workPath; //流程实例工作路径
|
||||
|
||||
public String currentPhase; //流程实例当前阶段
|
||||
|
||||
public String planEndTime; //路程实例计划完成时间
|
||||
|
||||
public String beginTime; //流程实例开始时间
|
||||
|
||||
public String endTime; //流程实例结束时间
|
||||
|
||||
public String tenantId; //租户ID
|
||||
|
||||
public String creator; //实例创建者
|
||||
|
||||
public String createTime; //实例创建时间
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.sdm.pbs.model.entity;
|
||||
|
||||
import com.sdm.common.entity.bo.BaseBean;
|
||||
|
||||
public class SimulationFlowMember extends BaseBean {
|
||||
|
||||
public SimulationFlowMember() {
|
||||
init();
|
||||
}
|
||||
|
||||
public int id;
|
||||
|
||||
public String flowId; //流程UUID
|
||||
|
||||
public String flowName; //流程名称
|
||||
|
||||
public String memberName; //成员名称
|
||||
|
||||
public String memberId; //成员ID
|
||||
|
||||
public int role; //成员在流程中的角色
|
||||
|
||||
public String creator; //创建者
|
||||
|
||||
public String createTime; //创建时间
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.sdm.pbs.model.entity;
|
||||
|
||||
import com.sdm.common.entity.bo.BaseBean;
|
||||
|
||||
public class SimulationFlowNode extends BaseBean {
|
||||
|
||||
public SimulationFlowNode(){
|
||||
init();
|
||||
}
|
||||
|
||||
public int id;
|
||||
|
||||
public String uuid; //节点唯一ID
|
||||
|
||||
public String nodeName; //节点名称
|
||||
|
||||
public String parentId; //所属父节点UUID
|
||||
|
||||
public String flowId; //所属流程UUID
|
||||
|
||||
public String flowName; //所属流程名称
|
||||
|
||||
public String templateId; //所属模版UUID
|
||||
|
||||
public String templateName; //所属模版名称
|
||||
|
||||
public int nodeType; //节点类型
|
||||
|
||||
public String workPath; //节点工作路径
|
||||
|
||||
public String exeCmd; //节点执行命令
|
||||
|
||||
public String preProcessCmd; //节点前处理命令
|
||||
|
||||
public String postProcessCmd; //节点后处理命令
|
||||
|
||||
public int nodeStatus; //节点状态 0:未开始 1:进行中 2:已完成 3:失败 4:停止
|
||||
|
||||
public String nodeParam; //节点参数
|
||||
|
||||
public String beginTime; //节点开始时间
|
||||
|
||||
public String endTime; //节点结束时间
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.sdm.pbs.model.entity;
|
||||
|
||||
import com.sdm.common.entity.bo.BaseBean;
|
||||
|
||||
public class SimulationFlowTemplate extends BaseBean {
|
||||
|
||||
public SimulationFlowTemplate() {
|
||||
init();
|
||||
}
|
||||
public int id;
|
||||
|
||||
public String uuid; //流程模版唯一ID
|
||||
|
||||
public String templateName; //流程模版名称
|
||||
|
||||
public String version; //流程模版版本号
|
||||
|
||||
public String template; //流程模版内容
|
||||
|
||||
public int templateStatus; //流程模版状态 0: 禁用 1:启用
|
||||
|
||||
public int approveStatus; //流程模版评审状态 0:未评审 1:已评审
|
||||
|
||||
public int templateType; //流程模版类型
|
||||
|
||||
public String comment; //流程模版描述信息
|
||||
|
||||
public String tenantId; //租户ID
|
||||
|
||||
public String creator; //模版创建者
|
||||
|
||||
public String createTime; //模版创建时间
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.sdm.grpc.server;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.grpc.lib.ApproveFlowReply;
|
||||
import com.sdm.grpc.lib.ApproveFlowRequest;
|
||||
import com.sdm.grpc.lib.ApproveFlowServiceGrpc;
|
||||
import com.sdm.system.service.ISimulatinoApprovalService;
|
||||
import com.sdm.system.service.impl.SimulationApproveServiceImpl;
|
||||
import io.grpc.stub.StreamObserver;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.devh.boot.grpc.server.service.GrpcService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
@Slf4j
|
||||
@GrpcService
|
||||
public class CidApproveFlowServer extends ApproveFlowServiceGrpc.ApproveFlowServiceImplBase{
|
||||
|
||||
public CidApproveFlowServer(){
|
||||
log.info("CidApproveFlowServer init");
|
||||
}
|
||||
@Autowired
|
||||
ISimulatinoApprovalService approvalService ;
|
||||
@Override
|
||||
public void launchApproveFlow(ApproveFlowRequest request, StreamObserver<ApproveFlowReply> responseObserver) {
|
||||
String approveTitle = request.getApproveTitle();
|
||||
int innerFlowId = request.getInnerFlowId();
|
||||
String comment = request.getComment();
|
||||
int approveType = request.getApproveType();
|
||||
String tenantId = request.getTenantId();
|
||||
String user = request.getUser();
|
||||
String replayUrl = request.getReplayUrl();
|
||||
|
||||
|
||||
|
||||
//responseObserver.onNext(reply.build());
|
||||
//responseObserver.onCompleted();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.sdm.grpc.server;
|
||||
|
||||
import com.sdm.grpc.lib.ApproveFlowServiceGrpc;
|
||||
import com.sdm.grpc.lib.ApproveNoticeReply;
|
||||
import com.sdm.grpc.lib.ApproveResultRequest;
|
||||
import io.grpc.stub.StreamObserver;
|
||||
import net.devh.boot.grpc.server.service.GrpcService;
|
||||
|
||||
public class ReceiveCidApproveFlowNoticeService{// extends ApproveFlowServiceGrpc.ApproveFlowServiceImplBase {
|
||||
//@Override
|
||||
public void approveFlowResultNotice(ApproveResultRequest request, StreamObserver<ApproveNoticeReply> responseObserver) {
|
||||
int approveStatus = request.getApproveStatus();
|
||||
int innerApproveId = request.getInnerFlowId();
|
||||
/******* ToDo ********/
|
||||
/*********************/
|
||||
ApproveNoticeReply.Builder reply = ApproveNoticeReply.newBuilder();
|
||||
reply.setInnerFlowId(innerApproveId);
|
||||
reply.setSuccess(true);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ 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.*;
|
||||
|
||||
@@ -26,7 +25,7 @@ public class SystemApproveController {
|
||||
|
||||
@PostMapping("/launchApprove")
|
||||
public SdmResponse launchApproval(@RequestBody ApproveFlowBean flowBean){
|
||||
return approveServer.launchApproval(flowBean.approveTitle,flowBean.approveType,flowBean.innerFlowId,flowBean.comment);
|
||||
return approveServer.launchApproval(flowBean.approveTitle,flowBean.templateName,flowBean.templateId,flowBean.approveType,flowBean.innerFlowId,flowBean.comment,flowBean.replyUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,11 +38,26 @@ public class SystemApproveController {
|
||||
return approveServer.receiveApprovalResult(flowBean.cidFlowId,flowBean.approveStatus);
|
||||
}
|
||||
|
||||
/*@PostMapping("/stopApprove")
|
||||
public SdmResponse stopApproval(@Param("flowId") String flowId, @Param("userId") String userId) {
|
||||
approveServer.stopCidApprovalFlow(flowId,userId);
|
||||
@GetMapping("queryApproveFlowStatus")
|
||||
public SdmResponse queryApproveFlowStatus(@RequestParam("flowId") String flowId) {
|
||||
return approveServer.queryApproveFlowStatus(flowId);
|
||||
}
|
||||
|
||||
@PostMapping("/stopApprove")
|
||||
public SdmResponse stopApproval(@RequestParam ("flowId") String flowId) {
|
||||
return approveServer.stopCidApprovalFlow(flowId);
|
||||
}
|
||||
|
||||
@PostMapping("/approveInnerNotice")
|
||||
public SdmResponse systemApproveInnerNotice(@RequestBody ApproveFlowBean flowBean) {
|
||||
return SdmResponse.success();
|
||||
}*/
|
||||
}
|
||||
|
||||
@GetMapping("/queryApproveFlowTempalte")
|
||||
public SdmResponse queryApproveFlowTemplate()
|
||||
{
|
||||
return approveServer.queryApprovalTemplates();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -13,12 +13,15 @@ import java.util.List;
|
||||
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})")
|
||||
@Insert("INSERT INTO simulation_approve_flow(innerFlowId,cidFlowId,templateName,templateId,approveTitle,approveStatus,approveType,comment,tenantId,userId,replyUrl,creator) VALUES (#{flowBean.innerFlowId},#{flowBean.cidFlowId},#{flowBean.templateName},#{flowBean.templateId},#{flowBean.approveTitle},#{flowBean.approveStatus},#{flowBean.approveType},#{flowBean.comment},#{flowBean.tenantId},#{flowBean.userId},#{flowBean.replyUrl},#{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);
|
||||
|
||||
@Update("UPDATE simulation_approve_flow SET replyStatus=#{replyStatus} WHERE cidFlowid=#{cidFlowId}")
|
||||
int updateSimulationApproveFlowReplyStatus(@Param("cidFlowId") String cidFlowId,@Param("replyStatus") int replyStatus);
|
||||
|
||||
@Select("SELECT * FROM simulation_approve_flow WHERE innerFlowId=#{flowId}")
|
||||
ApproveFlowBean querySimulationApproveFlowByInnerFlowId(@Param("flowId") int flowId);
|
||||
|
||||
|
||||
@@ -21,6 +21,18 @@ public class ApproveFlowBean extends BaseBean {
|
||||
|
||||
public String comment; //审批描述
|
||||
|
||||
public long tenantId; //租户ID
|
||||
|
||||
public String replyUrl; //审批回复URL
|
||||
|
||||
public String templateName; //模版名称
|
||||
|
||||
public String templateId; //评审流程模版ID
|
||||
|
||||
public int replyStatus; //审批回复状态 0:未回复 1:已回复
|
||||
|
||||
public long userId; //用户ID
|
||||
|
||||
public String creator; //审批创建者
|
||||
|
||||
public String createTime; //审批创建时间
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.sdm.system.model.entity;
|
||||
|
||||
public class ApproveTemplateBean {
|
||||
public String templateId;
|
||||
public String templateName;
|
||||
}
|
||||
@@ -2,9 +2,6 @@ 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;
|
||||
|
||||
/**
|
||||
@@ -18,14 +15,16 @@ import com.sdm.system.model.entity.ApproveFlowBean;
|
||||
public interface ISimulatinoApprovalService {
|
||||
|
||||
|
||||
SdmResponse queryApprovalTemplates(String group,String tenantId);
|
||||
SdmResponse queryApprovalTemplates();
|
||||
|
||||
boolean stopCidApprovalFlow(String flowId,String userId,String url);
|
||||
SdmResponse stopCidApprovalFlow(String flowId);
|
||||
|
||||
SdmResponse launchApproval(String approveTitle,int approveType,int innerFlowId,String comment);
|
||||
SdmResponse launchApproval(String approveTitle,String templateName,String templateId,int approveType,int innerFlowId,String comment,String replayUrl);
|
||||
|
||||
SdmResponse receiveApprovalResult(String cidFlowId,int status);
|
||||
|
||||
SdmResponse approvalResultNotice(ApproveFlowBean flowBean);
|
||||
|
||||
SdmResponse queryApproveFlowStatus(String flowId);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,17 +1,24 @@
|
||||
package com.sdm.system.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
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.model.entity.ApproveTemplateBean;
|
||||
import com.sdm.system.service.ISimulatinoApprovalService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@@ -20,12 +27,27 @@ public class SimulationApproveServiceImpl implements ISimulatinoApprovalService
|
||||
@Autowired
|
||||
private HttpClientUtil httpClientUtil;
|
||||
|
||||
|
||||
@Autowired
|
||||
private SimulationApproveMapper approveMapper;
|
||||
@Override
|
||||
public SdmResponse queryApprovalTemplates(String group, String tenantId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Value("${cid.url}")
|
||||
private String cidUrl;
|
||||
|
||||
@Value("${cid.flow.queryFlowTemplate}")
|
||||
private String queryFlowTemplatePath;
|
||||
|
||||
@Value("${cid.flow.launchApprove}")
|
||||
private String launchApprovePath;
|
||||
|
||||
@Value("${cid.flow.queryApproveDetail}")
|
||||
private String queryFlowDetailPath;
|
||||
|
||||
@Value("${cid.flow.stopApproveFlow}")
|
||||
private String stopFlowPath;
|
||||
|
||||
@Value("${cid.flow.group}")
|
||||
private String groupName;
|
||||
|
||||
/**
|
||||
* 向CID发起审批流程
|
||||
@@ -33,7 +55,7 @@ public class SimulationApproveServiceImpl implements ISimulatinoApprovalService
|
||||
* @param userId
|
||||
* @return string 返回审批流ID
|
||||
*/
|
||||
private String launchCidApprovalFlow(String flowId,String userId,String tenantId,String url)
|
||||
private String launchCidApprovalFlow(String flowId,long userId,long tenantId,String url)
|
||||
{
|
||||
JSONObject paramJson = new JSONObject();
|
||||
paramJson.put("flowId",flowId);
|
||||
@@ -41,7 +63,7 @@ public class SimulationApproveServiceImpl implements ISimulatinoApprovalService
|
||||
paramJson.put("tenantId",tenantId);
|
||||
String cidFlowId = "";
|
||||
try {
|
||||
String resultString = httpClientUtil.doPostJson(url+"/startFlow", paramJson.toJSONString());
|
||||
String resultString = httpClientUtil.doPostJson(url, paramJson.toJSONString());
|
||||
if (resultString != null && !resultString.isEmpty()) {
|
||||
JSONObject resultJson = JSONObject.parseObject(resultString);
|
||||
if (resultJson != null && resultJson.containsKey("success")) {
|
||||
@@ -60,22 +82,59 @@ public class SimulationApproveServiceImpl implements ISimulatinoApprovalService
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止cid评审流程
|
||||
* 获取Cid评审流程状态
|
||||
* @param flowId
|
||||
* @param userId
|
||||
* @param tenantId
|
||||
* @return
|
||||
*/
|
||||
public boolean stopCidApprovalFlow(String flowId,String userId,String url)
|
||||
private JSONArray queryCidApproveFlowStatus(String flowId, String templateId, long tenantId, String url)
|
||||
{
|
||||
JSONObject paramJson = new JSONObject();
|
||||
paramJson.put("flowId",templateId);
|
||||
paramJson.put("processInstanceId",flowId);
|
||||
paramJson.put("userId",userId);
|
||||
paramJson.put("tenantId",tenantId);
|
||||
JSONArray array = null;
|
||||
try {
|
||||
String resultString = httpClientUtil.doPostJson(url+"/stopFlow", paramJson.toJSONString());
|
||||
String resultString = httpClientUtil.doPostJson(url, paramJson.toJSONString());
|
||||
if (resultString != null && !resultString.isEmpty()) {
|
||||
JSONObject resultJson = JSONObject.parseObject(resultString);
|
||||
if (resultJson != null && resultJson.containsKey("success")) {
|
||||
return resultJson.getBoolean("success");
|
||||
boolean success = resultJson.getBoolean("success");
|
||||
if (success) {
|
||||
array = resultJson.getJSONArray("data");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止CID评审流程
|
||||
* @param cidFlowId
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
private boolean stopCidApprovalFlow(String cidFlowId,long userId)
|
||||
{
|
||||
JSONObject paramJson = new JSONObject();
|
||||
paramJson.put("processInstanceId", cidFlowId);
|
||||
paramJson.put("userId", userId);
|
||||
try
|
||||
{
|
||||
String url = cidUrl + stopFlowPath;
|
||||
String resultString = httpClientUtil.doPostJson(url, paramJson.toJSONString());
|
||||
if (resultString != null && !resultString.isEmpty()) {
|
||||
JSONObject resultJson = JSONObject.parseObject(resultString);
|
||||
if (resultJson != null && resultJson.containsKey("success")) {
|
||||
if(resultJson.getBoolean("success"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,6 +145,40 @@ public class SimulationApproveServiceImpl implements ISimulatinoApprovalService
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止cid评审流程
|
||||
* @param flowId
|
||||
* @return
|
||||
*/
|
||||
public SdmResponse stopCidApprovalFlow(String flowId)
|
||||
{
|
||||
SdmResponse response = SdmResponse.success();
|
||||
ApproveFlowBean flowBean = approveMapper.querySimulationApproveFlowByCidFlowId(flowId);
|
||||
if (flowBean == null) {
|
||||
response = SdmResponse.failed("评审流程不存在");
|
||||
}
|
||||
else {
|
||||
JSONObject paramJson = new JSONObject();
|
||||
paramJson.put("processInstanceId", flowBean.cidFlowId);
|
||||
paramJson.put("userId", flowBean.creator);
|
||||
try
|
||||
{
|
||||
String url = cidUrl+stopFlowPath;
|
||||
String resultString = httpClientUtil.doPostJson(url, paramJson.toJSONString());
|
||||
if (resultString != null && !resultString.isEmpty()) {
|
||||
JSONObject resultJson = JSONObject.parseObject(resultString);
|
||||
if (resultJson == null || !resultJson.containsKey("success")) {
|
||||
response = SdmResponse.failed("停止评审失败");
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发起审批流
|
||||
@@ -96,15 +189,16 @@ public class SimulationApproveServiceImpl implements ISimulatinoApprovalService
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public SdmResponse launchApproval(String approveTitle, int approveType, int approveId,String comment) {
|
||||
public SdmResponse launchApproval(String approveTitle,String templateName,String templateId, int approveType, int approveId,String comment,String replayUrl) {
|
||||
|
||||
|
||||
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);
|
||||
long userId = ThreadLocalContext.getUserId();
|
||||
long tenantId = ThreadLocalContext.getTenantId();
|
||||
String userName = ThreadLocalContext.getUserName();
|
||||
String url = cidUrl+launchApprovePath;
|
||||
|
||||
String cidFlowId = launchCidApprovalFlow(templateId, userId,tenantId,url);
|
||||
if (cidFlowId.isEmpty()) {
|
||||
sdmResponse = SdmResponse.failed("发起Cid审批流程失败");
|
||||
} else {
|
||||
@@ -114,9 +208,16 @@ public class SimulationApproveServiceImpl implements ISimulatinoApprovalService
|
||||
approveFlowBean.approveType = approveType;
|
||||
approveFlowBean.comment = comment;
|
||||
approveFlowBean.innerFlowId = approveId;
|
||||
approveFlowBean.creator = userName;
|
||||
approveFlowBean.tenantId = tenantId;
|
||||
approveFlowBean.replyUrl = replayUrl;
|
||||
approveFlowBean.userId = userId;
|
||||
approveFlowBean.creator = userName;
|
||||
approveFlowBean.templateId = templateId;
|
||||
approveFlowBean.templateName = templateName;
|
||||
if (approveMapper.addSimulationApproveFlow(approveFlowBean) <= 0) {
|
||||
sdmResponse = SdmResponse.failed("保存审批流程失败");
|
||||
if(!stopCidApprovalFlow(cidFlowId,"1979078323595476993",configBean.url))
|
||||
if(!stopCidApprovalFlow(cidFlowId,userId))
|
||||
{
|
||||
log.error("删除CID审批流["+cidFlowId+"]失败");
|
||||
}
|
||||
@@ -129,6 +230,33 @@ public class SimulationApproveServiceImpl implements ISimulatinoApprovalService
|
||||
return sdmResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前评审流程的状态详情
|
||||
* @param flowId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public SdmResponse queryApproveFlowStatus( String flowId)
|
||||
{
|
||||
SdmResponse sdmResponse = SdmResponse.success();
|
||||
ApproveFlowBean flowBean = approveMapper.querySimulationApproveFlowByCidFlowId(flowId);
|
||||
if(flowBean == null){
|
||||
sdmResponse = SdmResponse.failed("评审流程不存在");
|
||||
}
|
||||
else
|
||||
{
|
||||
String url = cidUrl+queryFlowDetailPath;
|
||||
JSONArray array = queryCidApproveFlowStatus(flowBean.cidFlowId, flowBean.templateId,flowBean.tenantId,url);
|
||||
if(array != null){
|
||||
sdmResponse.setData(array);
|
||||
}
|
||||
else{
|
||||
sdmResponse = SdmResponse.failed("获取评审流程状态信息失败");
|
||||
}
|
||||
}
|
||||
return sdmResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收CID审批流状态
|
||||
* @param cidFlowId
|
||||
@@ -153,7 +281,10 @@ public class SimulationApproveServiceImpl implements ISimulatinoApprovalService
|
||||
else
|
||||
{
|
||||
if(status > 1) { //评审结束后通知评审发起模块
|
||||
approvalResultNotice(flowBean);
|
||||
if(approvalResultNotice(flowBean).isSuccess())
|
||||
{
|
||||
approveMapper.updateSimulationApproveFlowReplyStatus(cidFlowId,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -167,8 +298,69 @@ public class SimulationApproveServiceImpl implements ISimulatinoApprovalService
|
||||
*/
|
||||
@Override
|
||||
public SdmResponse approvalResultNotice(ApproveFlowBean flowBean) {
|
||||
return null;
|
||||
SdmResponse sdmResponse = SdmResponse.success();
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("flowId", flowBean.innerFlowId);
|
||||
param.put("approveType", flowBean.approveType);
|
||||
try {
|
||||
String result = httpClientUtil.doPostJson(flowBean.replyUrl, param.toJSONString());
|
||||
if(result == null) {
|
||||
sdmResponse = SdmResponse.failed("发送评审状态通知失败");
|
||||
}
|
||||
else
|
||||
{
|
||||
JSONObject resultJson = JSONObject.parseObject(result);
|
||||
if(!resultJson.containsKey("success")) {
|
||||
sdmResponse = SdmResponse.failed();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return sdmResponse;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询评审流程模版
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public SdmResponse queryApprovalTemplates()
|
||||
{
|
||||
SdmResponse sdmResponse = SdmResponse.success();
|
||||
long tenantId = ThreadLocalContext.getTenantId();
|
||||
String url = cidUrl+queryFlowTemplatePath+"?groupName="+groupName+"&tenantId="+tenantId;
|
||||
try
|
||||
{
|
||||
String result = httpClientUtil.doGet(url);
|
||||
if(result == null) {
|
||||
sdmResponse = SdmResponse.failed("获取评审流程模版失败");
|
||||
}
|
||||
else {
|
||||
JSONObject resultJson = JSONObject.parseObject(result);
|
||||
if(!resultJson.containsKey("success")) {
|
||||
sdmResponse = SdmResponse.failed();
|
||||
}
|
||||
else
|
||||
{
|
||||
List<ApproveTemplateBean> templateBeanList = new ArrayList<>();
|
||||
JSONArray dataArray = resultJson.getJSONArray("data");
|
||||
for(int i=0;i<dataArray.size();i++)
|
||||
{
|
||||
JSONObject templateObj = dataArray.getJSONObject(i);
|
||||
ApproveTemplateBean templateBean = new ApproveTemplateBean();
|
||||
templateBean.templateName = templateObj.getString("name");
|
||||
templateBean.templateId = templateObj.getString("flowId");
|
||||
templateBeanList.add(templateBean);
|
||||
}
|
||||
sdmResponse.setData(templateBeanList);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return sdmResponse;
|
||||
}
|
||||
}
|
||||
|
||||
52
system/src/main/proto/approve.proto
Normal file
52
system/src/main/proto/approve.proto
Normal file
@@ -0,0 +1,52 @@
|
||||
syntax = "proto3";
|
||||
|
||||
//package com.sdm.grpc.server;
|
||||
|
||||
option java_multiple_files = true;
|
||||
option java_package = "com.sdm.grpc.lib";
|
||||
option java_outer_classname = "ApproveFlowProto";
|
||||
|
||||
// The greeting service definition.
|
||||
service ApproveFlowService {
|
||||
//发起评审流程
|
||||
rpc LaunchApproveFlow(ApproveFlowRequest) returns (ApproveFlowReply) {
|
||||
}
|
||||
|
||||
//通知评审结果
|
||||
rpc ApproveFlowResultNotice(ApproveResultRequest) returns(ApproveNoticeReply){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 发起评审请求
|
||||
message ApproveFlowRequest {
|
||||
string approveTitle = 1;
|
||||
int32 approveType = 2;
|
||||
int32 innerFlowId = 3;
|
||||
string comment = 4;
|
||||
string tenantId = 5;
|
||||
string user = 6;
|
||||
string replayUrl = 7;
|
||||
}
|
||||
|
||||
// 发起评审回复
|
||||
message ApproveFlowReply {
|
||||
bool success = 1;
|
||||
string cidFlowId = 2;
|
||||
}
|
||||
|
||||
// 评审状态通知结构
|
||||
message ApproveResultRequest {
|
||||
int32 approveStatus = 1;
|
||||
int32 innerFlowId = 2;
|
||||
}
|
||||
|
||||
// 发起评审回复
|
||||
message ApproveNoticeReply {
|
||||
bool success = 1;
|
||||
int32 innerFlowId = 2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -140,4 +140,11 @@ cid:
|
||||
listRoles: /spdm-role/listRoles
|
||||
tenant:
|
||||
getTenantDetailById: /spdm-tenant/getTenantDetailById
|
||||
listTenant: /spdm-tenant/listTenant
|
||||
listTenant: /spdm-tenant/listTenant
|
||||
flow:
|
||||
launchApprove: /spdm-flow/startFlow
|
||||
queryFlowTemplate: /spdm-flow/listProcessByGroup
|
||||
queryApproveDetail: /spdm-flow/queryFlowNodeDetail
|
||||
stopApproveFlow: /spdm-flow/stopFlow
|
||||
group: SPDM
|
||||
|
||||
|
||||
@@ -159,4 +159,11 @@ cid:
|
||||
listRoles: /spdm-role/listRoles
|
||||
tenant:
|
||||
getTenantDetailById: /spdm-tenant/getTenantDetailById
|
||||
listTenant: /spdm-tenant/listTenant
|
||||
listTenant: /spdm-tenant/listTenant
|
||||
|
||||
flow:
|
||||
launchApprove: /spdm-flow/startFlow
|
||||
queryFlowTemplate: /spdm-flow/listProcessByGroup
|
||||
queryApproveDetail: /spdm-flow/queryFlowNodeDetail
|
||||
stopApproveFlow: /spdm-flow/stopFlow
|
||||
group: SPDM
|
||||
Reference in New Issue
Block a user