新增:CID审批电子流结果回调,增加知识库和仿真地图场景
This commit is contained in:
@@ -7,6 +7,7 @@ public class NumberConstants {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// int 类型常量
|
// int 类型常量
|
||||||
|
public static final int MINUS_ONE = -1;
|
||||||
public static final int ZERO = 0;
|
public static final int ZERO = 0;
|
||||||
public static final int ONE = 1;
|
public static final int ONE = 1;
|
||||||
public static final int TWO = 2;
|
public static final int TWO = 2;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public class LaunchApproveReq extends BaseBean {
|
|||||||
@Schema(description = "CID生成的流程ID",defaultValue = "")
|
@Schema(description = "CID生成的流程ID",defaultValue = "")
|
||||||
public String cidFlowId;
|
public String cidFlowId;
|
||||||
|
|
||||||
|
// 审批类型 0.http回调的,replyUrl必须传递,相当于是跨系统的,调用的时候可以不传,replyUrl必须传递 ;1:仿真地图审批(spdm内部feign) 2:知识库审批(spdm内部feign)
|
||||||
@Schema(description = "审批类型 1:仿真地图审批 2:知识库审批",defaultValue = "0")
|
@Schema(description = "审批类型 1:仿真地图审批 2:知识库审批",defaultValue = "0")
|
||||||
@Value("10")
|
@Value("10")
|
||||||
public int approveType;
|
public int approveType;
|
||||||
|
|||||||
@@ -83,12 +83,12 @@ public class DataClientFeignClientImpl implements IDataFeignClient {
|
|||||||
try {
|
try {
|
||||||
response = dataClient.approveDataFile(req);
|
response = dataClient.approveDataFile(req);
|
||||||
if (!response.isSuccess()) {
|
if (!response.isSuccess()) {
|
||||||
return SdmResponse.failed("知识库文件审批状态修改失败");
|
return SdmResponse.failed("仿真知识库文件审批状态修改失败");
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("知识库文件审批状态修改异常", e);
|
log.error("仿真知识库文件审批状态修改异常", e);
|
||||||
return SdmResponse.failed("知识库文件审批状态修改异常");
|
return SdmResponse.failed("仿真知识库文件审批状态修改异常");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -161,11 +161,11 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
|||||||
ApproveStrategy strategy = approveStrategyFactory.getStrategy(approveMetadataInfo.getApproveType());
|
ApproveStrategy strategy = approveStrategyFactory.getStrategy(approveMetadataInfo.getApproveType());
|
||||||
boolean result = strategy.handle(context);
|
boolean result = strategy.handle(context);
|
||||||
|
|
||||||
return result ? SdmResponse.success("审批状态修改成功") :
|
return result ? SdmResponse.success("仿真知识库审批状态修改成功") :
|
||||||
SdmResponse.failed("审批状态修改失败");
|
SdmResponse.failed("仿真知识库审批状态修改失败");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("approveDataFile handle error", e);
|
log.error("approveDataFile handle error", e);
|
||||||
return SdmResponse.failed("审批处理异常:" + e.getMessage());
|
return SdmResponse.failed("仿真知识库审批处理异常:" + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1499,8 +1499,9 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
|||||||
// 发起仿真知识库文件审核 true 成功 false失败
|
// 发起仿真知识库文件审核 true 成功 false失败
|
||||||
private boolean launchFileDataApprove(String templateId, String templateName,String approveContents,int approveAction)
|
private boolean launchFileDataApprove(String templateId, String templateName,String approveContents,int approveAction)
|
||||||
{
|
{
|
||||||
|
boolean result = false;
|
||||||
|
LaunchApproveReq req = new LaunchApproveReq();
|
||||||
try {
|
try {
|
||||||
LaunchApproveReq req = new LaunchApproveReq();
|
|
||||||
// 评审流程模版ID 前端传过来
|
// 评审流程模版ID 前端传过来
|
||||||
req.templateId = templateId;
|
req.templateId = templateId;
|
||||||
// req.templateId = "P202511041416483446SFON";
|
// req.templateId = "P202511041416483446SFON";
|
||||||
@@ -1523,11 +1524,17 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
|||||||
// req.userId = 1979078323595476993l;
|
// req.userId = 1979078323595476993l;
|
||||||
// 审批创建者
|
// 审批创建者
|
||||||
req.creator = ThreadLocalContext.getUserId();
|
req.creator = ThreadLocalContext.getUserId();
|
||||||
// req.creator = 1979078323595476993l;
|
|
||||||
SdmResponse response = approveFeignClient.launchApproval(req);
|
SdmResponse response = approveFeignClient.launchApproval(req);
|
||||||
|
if(response.isSuccess()){
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
return response.isSuccess();
|
return response.isSuccess();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("launchFileDataApprove error :{}",e);
|
log.error("launchFileDataApprove error :{}",e);
|
||||||
|
}finally {
|
||||||
|
if(!result){
|
||||||
|
log.warn("launchFileDataApprove fileData failed:{}",JSONObject.toJSONString(req));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public class ApproveFlowBean extends BaseBean {
|
|||||||
|
|
||||||
public String cidFlowId; //CID生成的流程ID
|
public String cidFlowId; //CID生成的流程ID
|
||||||
|
|
||||||
public int approveType; //审批类型 1:仿真地图审批 2:知识库审批
|
public int approveType; //审批类型 0.http回调的,replyUrl必须传递,相当于是跨系统的,调用的时候可以不传,replyUrl必须传递 ;1:仿真地图审批(spdm内部feign) 2:知识库审批(spdm内部feign)
|
||||||
|
|
||||||
public int approveAction; //评审动作 1:新增 2:修改 3:删除
|
public int approveAction; //评审动作 1:新增 2:修改 3:删除
|
||||||
|
|
||||||
|
|||||||
@@ -4,13 +4,17 @@ import com.alibaba.fastjson2.JSONArray;
|
|||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.sdm.common.common.SdmResponse;
|
import com.sdm.common.common.SdmResponse;
|
||||||
import com.sdm.common.common.ThreadLocalContext;
|
import com.sdm.common.common.ThreadLocalContext;
|
||||||
|
import com.sdm.common.entity.constants.NumberConstants;
|
||||||
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
||||||
import com.sdm.common.utils.HttpClientUtil;
|
import com.sdm.common.utils.HttpClientUtil;
|
||||||
import com.sdm.system.dao.SimulationApproveMapper;
|
import com.sdm.system.dao.SimulationApproveMapper;
|
||||||
import com.sdm.system.model.entity.ApproveFlowBean;
|
import com.sdm.system.model.entity.ApproveFlowBean;
|
||||||
import com.sdm.system.model.entity.ApproveTemplateBean;
|
import com.sdm.system.model.entity.ApproveTemplateBean;
|
||||||
import com.sdm.system.service.ISimulatinoApprovalService;
|
import com.sdm.system.service.ISimulatinoApprovalService;
|
||||||
|
import com.sdm.system.service.impl.approvalNotice.ApproveNoticeStrategy;
|
||||||
|
import com.sdm.system.service.impl.approvalNotice.ApproveNoticeStrategyFactory;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -48,6 +52,9 @@ public class SimulationApproveServiceImpl implements ISimulatinoApprovalService
|
|||||||
@Value("${cid.flow.group}")
|
@Value("${cid.flow.group}")
|
||||||
private String groupName;
|
private String groupName;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApproveNoticeStrategyFactory approveNoticeStrategyFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 向CID发起审批流程
|
* 向CID发起审批流程
|
||||||
* @param flowId
|
* @param flowId
|
||||||
@@ -278,24 +285,10 @@ public class SimulationApproveServiceImpl implements ISimulatinoApprovalService
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SdmResponse approvalResultNotice(ApproveFlowBean flowBean) {
|
public SdmResponse approvalResultNotice(ApproveFlowBean flowBean) {
|
||||||
SdmResponse sdmResponse = SdmResponse.success();
|
int approveResultType = getApproveResultType(flowBean);
|
||||||
JSONObject param = JSONObject.from(flowBean);
|
// 审批结果处理
|
||||||
try {
|
ApproveNoticeStrategy strategy = approveNoticeStrategyFactory.getStrategy(approveResultType);
|
||||||
String result = httpClientUtil.doPostJson(flowBean.replyUrl, param.toJSONString());
|
SdmResponse sdmResponse = strategy.noticeResult(flowBean);
|
||||||
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 sdmResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,4 +334,22 @@ public class SimulationApproveServiceImpl implements ISimulatinoApprovalService
|
|||||||
}
|
}
|
||||||
return sdmResponse;
|
return sdmResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取 审批流回调业务方的type :// 审批类型 0.http回调的,相当于是跨系统的;1:仿真地图审批(spdm内部feign) 2:知识库审批(spdm内部feign)
|
||||||
|
private int getApproveResultType(ApproveFlowBean flowBean){
|
||||||
|
try {
|
||||||
|
int approveType = flowBean.approveType;
|
||||||
|
// http 的 replyUrl 异常
|
||||||
|
if(approveType == NumberConstants.ZERO && StringUtils.isBlank(flowBean.replyUrl)){
|
||||||
|
log.error("getApproveResultType http replyUrl is null,flowBean:{}",JSONObject.toJSONString(flowBean));
|
||||||
|
return NumberConstants.MINUS_ONE;
|
||||||
|
}
|
||||||
|
return approveType;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("getApproveResultType error:{},flowBean:{}",e.getMessage(),JSONObject.toJSONString(flowBean));
|
||||||
|
return NumberConstants.MINUS_ONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.sdm.system.service.impl.approvalNotice;
|
||||||
|
|
||||||
|
import com.sdm.common.common.SdmResponse;
|
||||||
|
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
||||||
|
import com.sdm.system.model.entity.ApproveFlowBean;
|
||||||
|
|
||||||
|
public abstract class AbstractFeignApproveNoticeStrategy implements ApproveNoticeStrategy {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SdmResponse noticeResult(ApproveFlowBean flowBean) {
|
||||||
|
// 参数转换
|
||||||
|
LaunchApproveReq req = convertToLaunchApproveReq(flowBean);
|
||||||
|
// 调用Feign客户端
|
||||||
|
return callFeignClient(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 公共的参数转换方法
|
||||||
|
protected LaunchApproveReq convertToLaunchApproveReq(ApproveFlowBean approveFlowBean) {
|
||||||
|
// 创建LaunchApproveReq实例并复制属性
|
||||||
|
LaunchApproveReq launchApproveReq = new LaunchApproveReq();
|
||||||
|
// 复制属性(属性名和类型一致,直接赋值)
|
||||||
|
launchApproveReq.id = approveFlowBean.id;
|
||||||
|
launchApproveReq.cidFlowId = approveFlowBean.cidFlowId;
|
||||||
|
launchApproveReq.approveType = approveFlowBean.approveType;
|
||||||
|
launchApproveReq.approveAction = approveFlowBean.approveAction;
|
||||||
|
launchApproveReq.approveContents = approveFlowBean.approveContents;
|
||||||
|
launchApproveReq.approveTitle = approveFlowBean.approveTitle;
|
||||||
|
launchApproveReq.approveStatus = approveFlowBean.approveStatus;
|
||||||
|
launchApproveReq.comment = approveFlowBean.comment;
|
||||||
|
launchApproveReq.tenantId = approveFlowBean.tenantId;
|
||||||
|
launchApproveReq.replyUrl = approveFlowBean.replyUrl;
|
||||||
|
launchApproveReq.templateName = approveFlowBean.templateName;
|
||||||
|
launchApproveReq.templateId = approveFlowBean.templateId;
|
||||||
|
launchApproveReq.replyStatus = approveFlowBean.replyStatus;
|
||||||
|
launchApproveReq.userId = approveFlowBean.userId;
|
||||||
|
if (approveFlowBean.creator != null) {
|
||||||
|
try {
|
||||||
|
launchApproveReq.creator = Long.parseLong(approveFlowBean.creator);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
launchApproveReq.creator = 0L;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
launchApproveReq.createTime = approveFlowBean.createTime;
|
||||||
|
return launchApproveReq;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 抽象方法,由子类实现具体的Feign调用
|
||||||
|
protected abstract SdmResponse callFeignClient(LaunchApproveReq req);
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.sdm.system.service.impl.approvalNotice;
|
||||||
|
|
||||||
|
import com.sdm.common.common.SdmResponse;
|
||||||
|
import com.sdm.system.model.entity.ApproveFlowBean;
|
||||||
|
|
||||||
|
public interface ApproveNoticeStrategy {
|
||||||
|
SdmResponse noticeResult(ApproveFlowBean flowBean);
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.sdm.system.service.impl.approvalNotice;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class ApproveNoticeStrategyFactory {
|
||||||
|
private static final Map<Integer, ApproveNoticeStrategy> STRATEGY_MAP = new HashMap<>();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public ApproveNoticeStrategyFactory(HttpNoticeStrategy httpNoticeStrategy,
|
||||||
|
SimulationMapNoticeStrategy simulationMapNoticeStrategy,
|
||||||
|
FileDataNoticeStrategy fileDataNoticeStrategy) {
|
||||||
|
// 类型与策略的映射关系,后期可以扩展
|
||||||
|
STRATEGY_MAP.put(0, httpNoticeStrategy);
|
||||||
|
STRATEGY_MAP.put(1, simulationMapNoticeStrategy);
|
||||||
|
STRATEGY_MAP.put(2, fileDataNoticeStrategy);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApproveNoticeStrategy getStrategy(int noticeType) {
|
||||||
|
ApproveNoticeStrategy strategy = STRATEGY_MAP.get(noticeType);
|
||||||
|
if (strategy == null) {
|
||||||
|
throw new RuntimeException("审批通知类型非法:" + noticeType);
|
||||||
|
}
|
||||||
|
return strategy;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.sdm.system.service.impl.approvalNotice;
|
||||||
|
|
||||||
|
import com.sdm.common.common.SdmResponse;
|
||||||
|
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
||||||
|
import com.sdm.common.feign.inter.data.IDataFeignClient;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class FileDataNoticeStrategy extends AbstractFeignApproveNoticeStrategy {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IDataFeignClient dataFeignClient;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SdmResponse callFeignClient(LaunchApproveReq req) {
|
||||||
|
return dataFeignClient.approveDataFile(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package com.sdm.system.service.impl.approvalNotice;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.sdm.common.common.SdmResponse;
|
||||||
|
import com.sdm.common.utils.HttpClientUtil;
|
||||||
|
import com.sdm.system.model.entity.ApproveFlowBean;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class HttpNoticeStrategy implements ApproveNoticeStrategy {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private HttpClientUtil httpClientUtil;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SdmResponse noticeResult(ApproveFlowBean flowBean) {
|
||||||
|
// 初始化三方成功
|
||||||
|
SdmResponse sdmResponse = SdmResponse.success();
|
||||||
|
JSONObject param = JSONObject.from(flowBean);
|
||||||
|
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) {
|
||||||
|
log.error("http noticeResult error:{},flowBean:{}", e,JSONObject.toJSONString(flowBean));
|
||||||
|
sdmResponse = SdmResponse.failed("发送评审状态通知异常");
|
||||||
|
}
|
||||||
|
return sdmResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.sdm.system.service.impl.approvalNotice;
|
||||||
|
|
||||||
|
import com.sdm.common.common.SdmResponse;
|
||||||
|
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
||||||
|
import com.sdm.common.feign.inter.task.ISimuluationTaskPoolFeignClient;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class SimulationMapNoticeStrategy extends AbstractFeignApproveNoticeStrategy{
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISimuluationTaskPoolFeignClient simuluationTaskPoolFeignClient;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SdmResponse callFeignClient(LaunchApproveReq req) {
|
||||||
|
return simuluationTaskPoolFeignClient.receiveApproveNotice(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user