feat: 企标立项变更流程 功能细化
This commit is contained in:
+13
-7
@@ -12,6 +12,7 @@ import org.activiti.engine.RepositoryService;
|
||||
import org.activiti.engine.RuntimeService;
|
||||
import org.activiti.engine.TaskService;
|
||||
import org.activiti.engine.impl.identity.Authentication;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.activiti.engine.task.TaskQuery;
|
||||
@@ -38,22 +39,27 @@ public class ActFlowCommonService {
|
||||
@Resource
|
||||
private TaskService taskService;
|
||||
|
||||
@Resource
|
||||
private ProcessEsInitChangeService processEsInitChangeService;
|
||||
|
||||
@Resource
|
||||
private ISysBaseAPI sysBaseAPI;
|
||||
|
||||
/**
|
||||
* 启动流程实例
|
||||
*/
|
||||
public ProcessInstance startProcess(String formKey, String beanName, String id) {
|
||||
public ProcessInstance startProcess(String processDefinitionKey, String beanName, String businessId) {
|
||||
ProcessDefinition latestProcessDefinition = repositoryService.createProcessDefinitionQuery()
|
||||
.processDefinitionKey(processDefinitionKey)
|
||||
.orderByProcessDefinitionVersion().desc()
|
||||
.list()
|
||||
.get(0); // 获取最新版本的流程定义
|
||||
|
||||
IActFlowCustomService customService = (IActFlowCustomService) SpringContextUtil.getBean(beanName);
|
||||
// 修改业务的状态
|
||||
customService.startRunTask(id);
|
||||
Map<String, Object> variables = customService.setVariables(id);
|
||||
customService.startRunTask(businessId);
|
||||
Map<String, Object> variables = customService.setVariables(businessId);
|
||||
// 第一个节点默认通过
|
||||
variables.put("pass", true);
|
||||
// 启动流程
|
||||
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(formKey, variables);
|
||||
ProcessInstance processInstance = runtimeService.startProcessInstanceById(latestProcessDefinition.getId(), variables);
|
||||
// 流程实例ID
|
||||
String processDefinitionId = processInstance.getProcessDefinitionId();
|
||||
log.info("【启动流程】- 成功,processDefinitionId:{}", processDefinitionId);
|
||||
|
||||
+5
-6
@@ -80,11 +80,11 @@ public class ProcessESInitChangeController {
|
||||
*
|
||||
* @param esInitChangeList
|
||||
*/
|
||||
@AutoLog(value = "企标立项变更流程-新增立项变更申请")
|
||||
@ApiOperation(value="企标立项变更流程-新增立项变更申请", notes="企标立项变更流程-新增立项变更申请")
|
||||
@PostMapping("/add")
|
||||
public Result<?> addInitChange(@RequestBody List<ProcessEsInitChange> esInitChangeList) {
|
||||
initChangeService.addInitChange(esInitChangeList);
|
||||
@AutoLog(value = "企标立项变更流程-发起立项变更申请")
|
||||
@ApiOperation(value="企标立项变更流程-发起立项变更申请", notes="企标立项变更流程-发起立项变更申请")
|
||||
@PostMapping("/start")
|
||||
public Result<?> startInitChange(@RequestBody List<ProcessEsInitChange> esInitChangeList) {
|
||||
initChangeService.startInitChange(esInitChangeList);
|
||||
return Result.OK();
|
||||
}
|
||||
|
||||
@@ -99,7 +99,6 @@ public class ProcessESInitChangeController {
|
||||
@ApiOperation(value="企标立项变更流程-审批(同意/驳回)", notes="企标立项变更流程-审批(同意/驳回)")
|
||||
@PostMapping("/approval")
|
||||
public Result<?> approval(@RequestParam("taskId") String taskId, @RequestBody List<ProcessEsInitChange> esInitChangeList) {
|
||||
//审批
|
||||
initChangeService.approvalInitChange(taskId, esInitChangeList);
|
||||
return Result.OK();
|
||||
}
|
||||
|
||||
+5
@@ -13,6 +13,8 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* 企标计划
|
||||
* @TableName process_es_init_change
|
||||
@@ -127,16 +129,19 @@ public class ProcessEsInitChange implements Serializable {
|
||||
/**
|
||||
* 企业名称代号
|
||||
*/
|
||||
@NotBlank
|
||||
private String enNameCode;
|
||||
|
||||
/**
|
||||
* 标准类别代号
|
||||
*/
|
||||
@NotBlank
|
||||
private String standardCategoryCode;
|
||||
|
||||
/**
|
||||
* 年代号
|
||||
*/
|
||||
@NotBlank
|
||||
private String decadeCode;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public interface ProcessEsInitChangeService extends IService<ProcessEsInitChange
|
||||
* @param esInitChange
|
||||
* @return
|
||||
*/
|
||||
void addInitChange(List<ProcessEsInitChange> esInitChange);
|
||||
void startInitChange(List<ProcessEsInitChange> esInitChange);
|
||||
|
||||
/**
|
||||
* 转办
|
||||
|
||||
+25
-27
@@ -34,9 +34,14 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl<ProcessEsInitCha
|
||||
|
||||
@Override
|
||||
public Map<String, Object> setVariables(String id) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
ProcessEsInitChange initChange = getById(id);
|
||||
// 设置流程中各个节点的人
|
||||
return this.setVariables(initChange);
|
||||
}
|
||||
|
||||
private Map<String, Object> setVariables(ProcessEsInitChange initChange) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
// 设置流程中各个节点的人
|
||||
map.put("createUser", initChange.getCreateBy());
|
||||
map.put("contactUser", initChange.getContactUser());
|
||||
map.put("standardExpertList", Optional.ofNullable(initChange.getStandardExpert()).map(s -> Arrays.asList(s.split(","))).orElse(Collections.emptyList()));
|
||||
@@ -46,7 +51,10 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl<ProcessEsInitCha
|
||||
map.put("newMainDraftUserLeaderLeader", initChange.getNewMainDraftUserLeaderLeader());
|
||||
map.put("newMainDraftUserLeader", initChange.getNewMainDraftUserLeader());
|
||||
map.put("relatedUserList", Optional.ofNullable(initChange.getRelatedUser()).map(s -> Arrays.asList(s.split(","))).orElse(Collections.emptyList()));
|
||||
map.put("copyUser", initChange.getCreateBy());
|
||||
map.put("copyUser", initChange.getCopyUser());
|
||||
// 设置流程分支判断变量
|
||||
map.put("applicationCategory", initChange.getApplicationCategory());
|
||||
map.put("projectType", initChange.getProjectType());
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -61,30 +69,17 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl<ProcessEsInitCha
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInitChange(List<ProcessEsInitChange> esInitChangeList) {
|
||||
public void startInitChange(List<ProcessEsInitChange> esInitChangeList) {
|
||||
String processDefinitionKey = "es-init-change";
|
||||
String userId = UserUtils.getUserId();
|
||||
// 保存到业务流程表
|
||||
saveOrUpdateBatch(esInitChangeList);
|
||||
String id;
|
||||
// 完成时间变更/工作中止
|
||||
if (isListApproval(esInitChangeList)) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (ProcessEsInitChange ic : esInitChangeList) {
|
||||
stringBuilder.append(ic.getId()).append(",");
|
||||
}
|
||||
// 去掉最后的逗号
|
||||
stringBuilder.deleteCharAt(stringBuilder.length() - 1);
|
||||
id = stringBuilder.toString();
|
||||
} else {
|
||||
id = esInitChangeList.get(0).getId();
|
||||
}
|
||||
|
||||
saveBatch(esInitChangeList);
|
||||
ProcessEsInitChange initChange = esInitChangeList.get(0);
|
||||
// TODO 根据业务需求设置流程状态
|
||||
// 对数据进行其他操作
|
||||
String formKey = "initChange";
|
||||
String beanName = formKey + "Service";
|
||||
String beanName = "initChange";
|
||||
|
||||
ProcessInstance processInstance = actFlowCommonService.startProcess(formKey, beanName, id);
|
||||
ProcessInstance processInstance = actFlowCommonService.startProcess(processDefinitionKey, beanName, initChange.getId());
|
||||
|
||||
// 获取流程实例ID
|
||||
String processDefinitionId = processInstance.getProcessDefinitionId();
|
||||
@@ -103,6 +98,12 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl<ProcessEsInitCha
|
||||
}
|
||||
}
|
||||
}
|
||||
// 设置流程实例Id
|
||||
for (ProcessEsInitChange esInitChange : esInitChangeList) {
|
||||
esInitChange.setProcessInstanceId(processInstance.getId());
|
||||
}
|
||||
// 更新流程实例Id
|
||||
saveOrUpdateBatch(esInitChangeList);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -110,16 +111,13 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl<ProcessEsInitCha
|
||||
actFlowCommonService.transfer(taskId, userId);
|
||||
}
|
||||
|
||||
private boolean isListApproval(List<ProcessEsInitChange> esInitChangeList) {
|
||||
ProcessEsInitChange initChange = esInitChangeList.get(0);
|
||||
return ESProjectType.COMPLETE_TIME_CHANGE.getValue().equals(initChange.getProjectType()) ||
|
||||
ESProjectType.WORK_TERMINATE.getValue().equals(initChange.getProjectType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void approvalInitChange(String taskId, List<ProcessEsInitChange> esInitChangeList) {
|
||||
String userId = UserUtils.getUserId();
|
||||
// 更新业务流程数据
|
||||
saveOrUpdateBatch(esInitChangeList);
|
||||
// 设置流程变量
|
||||
setVariables(esInitChangeList.get(0));
|
||||
// TODO 保存流程审批信息
|
||||
actFlowCommonService.completeTask(esInitChangeList.get(0).getRemarks(), taskId, userId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user