fix: 年度制修订-各部门上报 流程发起BUG

This commit is contained in:
2023-10-31 11:07:28 +08:00
parent f337cd962a
commit 9b2096ff3b
9 changed files with 621 additions and 15 deletions
@@ -27,10 +27,7 @@ import org.activiti.bpmn.model.*;
import org.activiti.bpmn.model.Process;
import org.activiti.editor.constants.ModelDataJsonConstants;
import org.activiti.editor.language.json.converter.BpmnJsonConverter;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.*;
import org.activiti.engine.delegate.BaseExecutionListener;
import org.activiti.engine.delegate.TaskListener;
import org.activiti.engine.repository.*;
@@ -135,6 +132,75 @@ public class ModelerController {
return Result.OK(modelId);
}
@ApiOperation(value = "导入model文件")
@ApiImplicitParams({
@ApiImplicitParam(name = "name", value = "模型名称")
})
@PostMapping("/importModelFileRecursion")
public Result<String> importModelFileRecursion(@RequestPart(value = "file", required = false) MultipartFile file,
@RequestParam(value = "name", required = false) String name) throws Exception {
InputStream fileInputStream = file.getInputStream();
XMLInputFactory xif = XMLInputFactory.newInstance();
InputStreamReader in = new InputStreamReader(fileInputStream, "UTF-8");
XMLStreamReader xtr = xif.createXMLStreamReader(in);
// 转为bpmnModel
BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr);
Model model = repositoryService.newModel();
String modelKey = "m_" + CreatedTools.getCreated();
ObjectNode modelNode = objectMapper.createObjectNode();
modelNode.put(ModelDataJsonConstants.MODEL_NAME, modelKey);
modelNode.put(ModelDataJsonConstants.MODEL_REVISION, 1);
model.setName(name);
model.setKey(modelKey);
model.setMetaInfo(modelNode.toString());
repositoryService.saveModel(model);
String modelId = model.getId();
Process mainProcess = bpmnModel.getMainProcess();
List<ActivitiListener> executionListeners = mainProcess.getExecutionListeners();
ActivitiListener startListener = new ActivitiListener();
startListener.setEvent(BaseExecutionListener.EVENTNAME_START);
startListener.setImplementationType("class");
startListener.setImplementation(StartListener.class.getName());
executionListeners.add(startListener);
ActivitiListener endListener = new ActivitiListener();
endListener.setEvent(BaseExecutionListener.EVENTNAME_END);
endListener.setImplementationType("class");
endListener.setImplementation(EndListener.class.getName());
executionListeners.add(endListener);
mainProcess.setExecutionListeners(executionListeners);
//向所有userTask节点增加创建和完成时任务监听器工作
processFlowElements(mainProcess.getFlowElements());
ObjectNode objectNode = new BpmnJsonConverter().convertToJson(bpmnModel);
repositoryService.addModelEditorSource(modelId, objectNode.toString().getBytes(StandardCharsets.UTF_8));
//生成节点
processModelNodeService.generateNode(modelId);
return Result.OK(modelId);
}
public void processFlowElements(Collection<FlowElement> flowElements) {
for (FlowElement flowElement : flowElements) {
if (flowElement instanceof UserTask) {
UserTask userTask = (UserTask) flowElement;
List<ActivitiListener> taskListeners = userTask.getTaskListeners();
ActivitiListener createListener = new ActivitiListener();
createListener.setEvent(TaskListener.EVENTNAME_CREATE);
createListener.setImplementationType("class");
createListener.setImplementation(CreateListener.class.getName());
taskListeners.add(createListener);
ActivitiListener completeListener = new ActivitiListener();
completeListener.setEvent(TaskListener.EVENTNAME_COMPLETE);
completeListener.setImplementationType("class");
completeListener.setImplementation(CompleteListener.class.getName());
taskListeners.add(completeListener);
userTask.setTaskListeners(taskListeners);
} else if (flowElement instanceof SubProcess) {
SubProcess subProcess = (SubProcess) flowElement;
processFlowElements(subProcess.getFlowElements());
}
}
}
@ApiOperation(value = "模板列表")
@ApiImplicitParams({ @ApiImplicitParam(name = "name", value = "名称"),
@ApiImplicitParam(name = "category", value = "类型") })
@@ -0,0 +1,110 @@
package com.jero.modules.activiti.process.esAbolish.listener;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jero.modules.activiti.process.esInitChange.entity.ProcessEsInitChange;
import com.jero.modules.activiti.process.esInitChange.entity.enums.ESPApplicationCategoryEnum;
import com.jero.modules.activiti.process.esInitChange.entity.enums.ESPChangeType;
import com.jero.modules.activiti.process.esInitChange.entity.enums.ESPProjectType;
import com.jero.modules.activiti.process.esInitChange.service.ProcessEsInitChangeService;
import com.jero.modules.laws.enterprise.entity.EnterpriseStandardPlan;
import com.jero.modules.laws.enterprise.service.EnterpriseStandardPlanService;
import com.jero.modules.laws.enterprise.util.BeanCopyUtils;
import lombok.extern.slf4j.Slf4j;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
* @author: Mzaxd
* @Date: 2023/10/10 14:14
*/
@Slf4j
@Component
public class ProcessESAbolishEndListener implements ExecutionListener {
@Resource
private EnterpriseStandardPlanService espService;
@Resource
private ProcessEsInitChangeService esInitChangeService;
/**
* 企标立项变更流程结束之后需要把数据存入企标计划数据库 然后自动发起企标制修订流程
* @param delegateExecution
*/
@Override
public void notify(DelegateExecution delegateExecution) {
log.info("企标立项变更流程结束 监听执行器开始执行");
// 获取流程实例ID
String processInstanceId = delegateExecution.getProcessInstanceId();
// 根据流程实例Id找到所有流程业务数据
LambdaQueryWrapper<ProcessEsInitChange> esInitChangeWrapper = new LambdaQueryWrapper<>();
esInitChangeWrapper.eq(ProcessEsInitChange::getProcessInstanceId, processInstanceId);
List<ProcessEsInitChange> processEsInitChanges = esInitChangeService.list(esInitChangeWrapper);
String applicationCategory = processEsInitChanges.get(0).getApplicationCategory();
String projectType = processEsInitChanges.get(0).getProjectType();
List<EnterpriseStandardPlan> enterpriseStandardPlans;
if (ESPApplicationCategoryEnum.INITIATION.getValue().equals(applicationCategory)) {
// 立项新增-Id置空
for (ProcessEsInitChange processEsInitChange : processEsInitChanges) {
processEsInitChange.setId(null);
}
// 转换为企标计划数据并入库
enterpriseStandardPlans = BeanCopyUtils.copyBeanList(processEsInitChanges, EnterpriseStandardPlan.class);
espService.saveBatch(enterpriseStandardPlans);
} else {
// 将Id设为企标计划的Id
for (ProcessEsInitChange processEsInitChange : processEsInitChanges) {
processEsInitChange.setId(processEsInitChange.getEspId());
}
// 完成时间变更
if (ESPProjectType.COMPLETE_TIME_CHANGE.getValue().equals(projectType)) {
enterpriseStandardPlans = BeanCopyUtils.copyBeanList(processEsInitChanges, EnterpriseStandardPlan.class);
espService.saveOrUpdateBatch(enterpriseStandardPlans);
}
// 工作中止
if (ESPProjectType.WORK_TERMINATE.getValue().equals(projectType)) {
// 将企标计划变更状态设为取消
for (ProcessEsInitChange processEsInitChange : processEsInitChanges) {
processEsInitChange.setProjectStatus(ESPChangeType.CANCEL.getValue());
}
enterpriseStandardPlans = BeanCopyUtils.copyBeanList(processEsInitChanges, EnterpriseStandardPlan.class);
espService.saveOrUpdateBatch(enterpriseStandardPlans);
}
// 责任部门变更
if (ESPProjectType.RESPONSIBLE_DEPT_CHANGE.getValue().equals(projectType)) {
// 将企标计划变更状态设为变更
for (ProcessEsInitChange processEsInitChange : processEsInitChanges) {
processEsInitChange.setProjectStatus(ESPChangeType.CHANGE.getValue());
}
enterpriseStandardPlans = BeanCopyUtils.copyBeanList(processEsInitChanges, EnterpriseStandardPlan.class);
espService.saveOrUpdateBatch(enterpriseStandardPlans);
}
// 合并
if (ESPProjectType.MERGE.getValue().equals(projectType)) {
for (ProcessEsInitChange processEsInitChange : processEsInitChanges) {
processEsInitChange.setId(null);
}
// 删除两个老企标计划
espService.deleteById(processEsInitChanges.get(0).getStandardIdOne());
espService.deleteById(processEsInitChanges.get(0).getStandardIdTwo());
// 生成新企标计划
enterpriseStandardPlans = BeanCopyUtils.copyBeanList(processEsInitChanges, EnterpriseStandardPlan.class);
espService.saveOrUpdateBatch(enterpriseStandardPlans);
}
}
log.info("数据存入企标计划数据库");
// 软删除流程数据
esInitChangeService.removeByProcessInstanceId(processInstanceId);
log.info("软删除流程数据");
//TODO 发起制修订流程
log.info("自动发起企标制修订流程");
}
}
@@ -276,12 +276,6 @@ public class ProcessEsAnnualReport implements Serializable {
@ApiModelProperty(value = "提交草稿日期")
private Date draftSubmissionDate;
/**
* 是否征求意见
*/
@ApiModelProperty(value = "是否征求意见")
private String solicitationOpinionEnabled;
/**
* 征求意见稿完成日期
*/
@@ -85,8 +85,6 @@ public class ProcessEsAnnualReportServiceImpl extends ServiceImpl<ProcessEsAnnua
public void startProcess(AnnualReportDataVO annualReportData) {
// 流程Key
String processDefinitionKey = ProcessType.ES_ANNUAL_REPORT.getProcessKey();
// 业务数据
List<ProcessEsAnnualReport> annualReportList = annualReportData.getDataList();
// 通用数据
CommonVO commonVO = annualReportData.getCommonVO();
// 当前用户Id
@@ -102,8 +100,6 @@ public class ProcessEsAnnualReportServiceImpl extends ServiceImpl<ProcessEsAnnua
actFlowCommonService.setProcessVariables(processInstanceId, variables);
// 自动完成第一个任务
actFlowCommonService.autoCompleteFirstTask(userId, processInstanceId, processDefinitionId, commonVO);
// 设置流程实例Id
annualReportList.forEach(annualReport -> annualReport.setProcessInstanceId(processInstanceId));
// 保存选人信息
processNodeLinkService.saveNodeUserLink(processDefinitionId, processInstanceId, this.getUserMap(variables));
// 根据流程实例id更新流程总表
@@ -0,0 +1,110 @@
package com.jero.modules.activiti.process.esArchive.listener;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jero.modules.activiti.process.esInitChange.entity.ProcessEsInitChange;
import com.jero.modules.activiti.process.esInitChange.entity.enums.ESPApplicationCategoryEnum;
import com.jero.modules.activiti.process.esInitChange.entity.enums.ESPChangeType;
import com.jero.modules.activiti.process.esInitChange.entity.enums.ESPProjectType;
import com.jero.modules.activiti.process.esInitChange.service.ProcessEsInitChangeService;
import com.jero.modules.laws.enterprise.entity.EnterpriseStandardPlan;
import com.jero.modules.laws.enterprise.service.EnterpriseStandardPlanService;
import com.jero.modules.laws.enterprise.util.BeanCopyUtils;
import lombok.extern.slf4j.Slf4j;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
* @author: Mzaxd
* @Date: 2023/10/10 14:14
*/
@Slf4j
@Component
public class ProcessESArchiveEndListener implements ExecutionListener {
@Resource
private EnterpriseStandardPlanService espService;
@Resource
private ProcessEsInitChangeService esInitChangeService;
/**
* 企标立项变更流程结束之后需要把数据存入企标计划数据库 然后自动发起企标制修订流程
* @param delegateExecution
*/
@Override
public void notify(DelegateExecution delegateExecution) {
log.info("企标立项变更流程结束 监听执行器开始执行");
// 获取流程实例ID
String processInstanceId = delegateExecution.getProcessInstanceId();
// 根据流程实例Id找到所有流程业务数据
LambdaQueryWrapper<ProcessEsInitChange> esInitChangeWrapper = new LambdaQueryWrapper<>();
esInitChangeWrapper.eq(ProcessEsInitChange::getProcessInstanceId, processInstanceId);
List<ProcessEsInitChange> processEsInitChanges = esInitChangeService.list(esInitChangeWrapper);
String applicationCategory = processEsInitChanges.get(0).getApplicationCategory();
String projectType = processEsInitChanges.get(0).getProjectType();
List<EnterpriseStandardPlan> enterpriseStandardPlans;
if (ESPApplicationCategoryEnum.INITIATION.getValue().equals(applicationCategory)) {
// 立项新增-Id置空
for (ProcessEsInitChange processEsInitChange : processEsInitChanges) {
processEsInitChange.setId(null);
}
// 转换为企标计划数据并入库
enterpriseStandardPlans = BeanCopyUtils.copyBeanList(processEsInitChanges, EnterpriseStandardPlan.class);
espService.saveBatch(enterpriseStandardPlans);
} else {
// 将Id设为企标计划的Id
for (ProcessEsInitChange processEsInitChange : processEsInitChanges) {
processEsInitChange.setId(processEsInitChange.getEspId());
}
// 完成时间变更
if (ESPProjectType.COMPLETE_TIME_CHANGE.getValue().equals(projectType)) {
enterpriseStandardPlans = BeanCopyUtils.copyBeanList(processEsInitChanges, EnterpriseStandardPlan.class);
espService.saveOrUpdateBatch(enterpriseStandardPlans);
}
// 工作中止
if (ESPProjectType.WORK_TERMINATE.getValue().equals(projectType)) {
// 将企标计划变更状态设为取消
for (ProcessEsInitChange processEsInitChange : processEsInitChanges) {
processEsInitChange.setProjectStatus(ESPChangeType.CANCEL.getValue());
}
enterpriseStandardPlans = BeanCopyUtils.copyBeanList(processEsInitChanges, EnterpriseStandardPlan.class);
espService.saveOrUpdateBatch(enterpriseStandardPlans);
}
// 责任部门变更
if (ESPProjectType.RESPONSIBLE_DEPT_CHANGE.getValue().equals(projectType)) {
// 将企标计划变更状态设为变更
for (ProcessEsInitChange processEsInitChange : processEsInitChanges) {
processEsInitChange.setProjectStatus(ESPChangeType.CHANGE.getValue());
}
enterpriseStandardPlans = BeanCopyUtils.copyBeanList(processEsInitChanges, EnterpriseStandardPlan.class);
espService.saveOrUpdateBatch(enterpriseStandardPlans);
}
// 合并
if (ESPProjectType.MERGE.getValue().equals(projectType)) {
for (ProcessEsInitChange processEsInitChange : processEsInitChanges) {
processEsInitChange.setId(null);
}
// 删除两个老企标计划
espService.deleteById(processEsInitChanges.get(0).getStandardIdOne());
espService.deleteById(processEsInitChanges.get(0).getStandardIdTwo());
// 生成新企标计划
enterpriseStandardPlans = BeanCopyUtils.copyBeanList(processEsInitChanges, EnterpriseStandardPlan.class);
espService.saveOrUpdateBatch(enterpriseStandardPlans);
}
}
log.info("数据存入企标计划数据库");
// 软删除流程数据
esInitChangeService.removeByProcessInstanceId(processInstanceId);
log.info("软删除流程数据");
//TODO 发起制修订流程
log.info("自动发起企标制修订流程");
}
}
@@ -0,0 +1,110 @@
package com.jero.modules.activiti.process.esChange.listener;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jero.modules.activiti.process.esInitChange.entity.ProcessEsInitChange;
import com.jero.modules.activiti.process.esInitChange.entity.enums.ESPApplicationCategoryEnum;
import com.jero.modules.activiti.process.esInitChange.entity.enums.ESPChangeType;
import com.jero.modules.activiti.process.esInitChange.entity.enums.ESPProjectType;
import com.jero.modules.activiti.process.esInitChange.service.ProcessEsInitChangeService;
import com.jero.modules.laws.enterprise.entity.EnterpriseStandardPlan;
import com.jero.modules.laws.enterprise.service.EnterpriseStandardPlanService;
import com.jero.modules.laws.enterprise.util.BeanCopyUtils;
import lombok.extern.slf4j.Slf4j;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
* @author: Mzaxd
* @Date: 2023/10/10 14:14
*/
@Slf4j
@Component
public class ProcessESChangeEndListener implements ExecutionListener {
@Resource
private EnterpriseStandardPlanService espService;
@Resource
private ProcessEsInitChangeService esInitChangeService;
/**
* 企标立项变更流程结束之后需要把数据存入企标计划数据库 然后自动发起企标制修订流程
* @param delegateExecution
*/
@Override
public void notify(DelegateExecution delegateExecution) {
log.info("企标立项变更流程结束 监听执行器开始执行");
// 获取流程实例ID
String processInstanceId = delegateExecution.getProcessInstanceId();
// 根据流程实例Id找到所有流程业务数据
LambdaQueryWrapper<ProcessEsInitChange> esInitChangeWrapper = new LambdaQueryWrapper<>();
esInitChangeWrapper.eq(ProcessEsInitChange::getProcessInstanceId, processInstanceId);
List<ProcessEsInitChange> processEsInitChanges = esInitChangeService.list(esInitChangeWrapper);
String applicationCategory = processEsInitChanges.get(0).getApplicationCategory();
String projectType = processEsInitChanges.get(0).getProjectType();
List<EnterpriseStandardPlan> enterpriseStandardPlans;
if (ESPApplicationCategoryEnum.INITIATION.getValue().equals(applicationCategory)) {
// 立项新增-Id置空
for (ProcessEsInitChange processEsInitChange : processEsInitChanges) {
processEsInitChange.setId(null);
}
// 转换为企标计划数据并入库
enterpriseStandardPlans = BeanCopyUtils.copyBeanList(processEsInitChanges, EnterpriseStandardPlan.class);
espService.saveBatch(enterpriseStandardPlans);
} else {
// 将Id设为企标计划的Id
for (ProcessEsInitChange processEsInitChange : processEsInitChanges) {
processEsInitChange.setId(processEsInitChange.getEspId());
}
// 完成时间变更
if (ESPProjectType.COMPLETE_TIME_CHANGE.getValue().equals(projectType)) {
enterpriseStandardPlans = BeanCopyUtils.copyBeanList(processEsInitChanges, EnterpriseStandardPlan.class);
espService.saveOrUpdateBatch(enterpriseStandardPlans);
}
// 工作中止
if (ESPProjectType.WORK_TERMINATE.getValue().equals(projectType)) {
// 将企标计划变更状态设为取消
for (ProcessEsInitChange processEsInitChange : processEsInitChanges) {
processEsInitChange.setProjectStatus(ESPChangeType.CANCEL.getValue());
}
enterpriseStandardPlans = BeanCopyUtils.copyBeanList(processEsInitChanges, EnterpriseStandardPlan.class);
espService.saveOrUpdateBatch(enterpriseStandardPlans);
}
// 责任部门变更
if (ESPProjectType.RESPONSIBLE_DEPT_CHANGE.getValue().equals(projectType)) {
// 将企标计划变更状态设为变更
for (ProcessEsInitChange processEsInitChange : processEsInitChanges) {
processEsInitChange.setProjectStatus(ESPChangeType.CHANGE.getValue());
}
enterpriseStandardPlans = BeanCopyUtils.copyBeanList(processEsInitChanges, EnterpriseStandardPlan.class);
espService.saveOrUpdateBatch(enterpriseStandardPlans);
}
// 合并
if (ESPProjectType.MERGE.getValue().equals(projectType)) {
for (ProcessEsInitChange processEsInitChange : processEsInitChanges) {
processEsInitChange.setId(null);
}
// 删除两个老企标计划
espService.deleteById(processEsInitChanges.get(0).getStandardIdOne());
espService.deleteById(processEsInitChanges.get(0).getStandardIdTwo());
// 生成新企标计划
enterpriseStandardPlans = BeanCopyUtils.copyBeanList(processEsInitChanges, EnterpriseStandardPlan.class);
espService.saveOrUpdateBatch(enterpriseStandardPlans);
}
}
log.info("数据存入企标计划数据库");
// 软删除流程数据
esInitChangeService.removeByProcessInstanceId(processInstanceId);
log.info("软删除流程数据");
//TODO 发起制修订流程
log.info("自动发起企标制修订流程");
}
}
@@ -0,0 +1,110 @@
package com.jero.modules.activiti.process.esEnable.listener;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jero.modules.activiti.process.esInitChange.entity.ProcessEsInitChange;
import com.jero.modules.activiti.process.esInitChange.entity.enums.ESPApplicationCategoryEnum;
import com.jero.modules.activiti.process.esInitChange.entity.enums.ESPChangeType;
import com.jero.modules.activiti.process.esInitChange.entity.enums.ESPProjectType;
import com.jero.modules.activiti.process.esInitChange.service.ProcessEsInitChangeService;
import com.jero.modules.laws.enterprise.entity.EnterpriseStandardPlan;
import com.jero.modules.laws.enterprise.service.EnterpriseStandardPlanService;
import com.jero.modules.laws.enterprise.util.BeanCopyUtils;
import lombok.extern.slf4j.Slf4j;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
* @author: Mzaxd
* @Date: 2023/10/10 14:14
*/
@Slf4j
@Component
public class ProcessESEnableEndListener implements ExecutionListener {
@Resource
private EnterpriseStandardPlanService espService;
@Resource
private ProcessEsInitChangeService esInitChangeService;
/**
* 企标立项变更流程结束之后需要把数据存入企标计划数据库 然后自动发起企标制修订流程
* @param delegateExecution
*/
@Override
public void notify(DelegateExecution delegateExecution) {
log.info("企标立项变更流程结束 监听执行器开始执行");
// 获取流程实例ID
String processInstanceId = delegateExecution.getProcessInstanceId();
// 根据流程实例Id找到所有流程业务数据
LambdaQueryWrapper<ProcessEsInitChange> esInitChangeWrapper = new LambdaQueryWrapper<>();
esInitChangeWrapper.eq(ProcessEsInitChange::getProcessInstanceId, processInstanceId);
List<ProcessEsInitChange> processEsInitChanges = esInitChangeService.list(esInitChangeWrapper);
String applicationCategory = processEsInitChanges.get(0).getApplicationCategory();
String projectType = processEsInitChanges.get(0).getProjectType();
List<EnterpriseStandardPlan> enterpriseStandardPlans;
if (ESPApplicationCategoryEnum.INITIATION.getValue().equals(applicationCategory)) {
// 立项新增-Id置空
for (ProcessEsInitChange processEsInitChange : processEsInitChanges) {
processEsInitChange.setId(null);
}
// 转换为企标计划数据并入库
enterpriseStandardPlans = BeanCopyUtils.copyBeanList(processEsInitChanges, EnterpriseStandardPlan.class);
espService.saveBatch(enterpriseStandardPlans);
} else {
// 将Id设为企标计划的Id
for (ProcessEsInitChange processEsInitChange : processEsInitChanges) {
processEsInitChange.setId(processEsInitChange.getEspId());
}
// 完成时间变更
if (ESPProjectType.COMPLETE_TIME_CHANGE.getValue().equals(projectType)) {
enterpriseStandardPlans = BeanCopyUtils.copyBeanList(processEsInitChanges, EnterpriseStandardPlan.class);
espService.saveOrUpdateBatch(enterpriseStandardPlans);
}
// 工作中止
if (ESPProjectType.WORK_TERMINATE.getValue().equals(projectType)) {
// 将企标计划变更状态设为取消
for (ProcessEsInitChange processEsInitChange : processEsInitChanges) {
processEsInitChange.setProjectStatus(ESPChangeType.CANCEL.getValue());
}
enterpriseStandardPlans = BeanCopyUtils.copyBeanList(processEsInitChanges, EnterpriseStandardPlan.class);
espService.saveOrUpdateBatch(enterpriseStandardPlans);
}
// 责任部门变更
if (ESPProjectType.RESPONSIBLE_DEPT_CHANGE.getValue().equals(projectType)) {
// 将企标计划变更状态设为变更
for (ProcessEsInitChange processEsInitChange : processEsInitChanges) {
processEsInitChange.setProjectStatus(ESPChangeType.CHANGE.getValue());
}
enterpriseStandardPlans = BeanCopyUtils.copyBeanList(processEsInitChanges, EnterpriseStandardPlan.class);
espService.saveOrUpdateBatch(enterpriseStandardPlans);
}
// 合并
if (ESPProjectType.MERGE.getValue().equals(projectType)) {
for (ProcessEsInitChange processEsInitChange : processEsInitChanges) {
processEsInitChange.setId(null);
}
// 删除两个老企标计划
espService.deleteById(processEsInitChanges.get(0).getStandardIdOne());
espService.deleteById(processEsInitChanges.get(0).getStandardIdTwo());
// 生成新企标计划
enterpriseStandardPlans = BeanCopyUtils.copyBeanList(processEsInitChanges, EnterpriseStandardPlan.class);
espService.saveOrUpdateBatch(enterpriseStandardPlans);
}
}
log.info("数据存入企标计划数据库");
// 软删除流程数据
esInitChangeService.removeByProcessInstanceId(processInstanceId);
log.info("软删除流程数据");
//TODO 发起制修订流程
log.info("自动发起企标制修订流程");
}
}
@@ -214,7 +214,7 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl<ProcessEsInitCha
}
// 更新审批表为完成,填充数据
actFlowCommonService.updateApprovalInfo(commonVO, taskId, pass);
//审批节点
// 审批节点
actFlowCommonService.completeTask(taskId, userId);
}
@@ -0,0 +1,110 @@
package com.jero.modules.activiti.process.esRecheck.listener;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jero.modules.activiti.process.esInitChange.entity.ProcessEsInitChange;
import com.jero.modules.activiti.process.esInitChange.entity.enums.ESPApplicationCategoryEnum;
import com.jero.modules.activiti.process.esInitChange.entity.enums.ESPChangeType;
import com.jero.modules.activiti.process.esInitChange.entity.enums.ESPProjectType;
import com.jero.modules.activiti.process.esInitChange.service.ProcessEsInitChangeService;
import com.jero.modules.laws.enterprise.entity.EnterpriseStandardPlan;
import com.jero.modules.laws.enterprise.service.EnterpriseStandardPlanService;
import com.jero.modules.laws.enterprise.util.BeanCopyUtils;
import lombok.extern.slf4j.Slf4j;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
* @author: Mzaxd
* @Date: 2023/10/10 14:14
*/
@Slf4j
@Component
public class ProcessESRecheckEndListener implements ExecutionListener {
@Resource
private EnterpriseStandardPlanService espService;
@Resource
private ProcessEsInitChangeService esInitChangeService;
/**
* 企标立项变更流程结束之后需要把数据存入企标计划数据库 然后自动发起企标制修订流程
* @param delegateExecution
*/
@Override
public void notify(DelegateExecution delegateExecution) {
log.info("企标立项变更流程结束 监听执行器开始执行");
// 获取流程实例ID
String processInstanceId = delegateExecution.getProcessInstanceId();
// 根据流程实例Id找到所有流程业务数据
LambdaQueryWrapper<ProcessEsInitChange> esInitChangeWrapper = new LambdaQueryWrapper<>();
esInitChangeWrapper.eq(ProcessEsInitChange::getProcessInstanceId, processInstanceId);
List<ProcessEsInitChange> processEsInitChanges = esInitChangeService.list(esInitChangeWrapper);
String applicationCategory = processEsInitChanges.get(0).getApplicationCategory();
String projectType = processEsInitChanges.get(0).getProjectType();
List<EnterpriseStandardPlan> enterpriseStandardPlans;
if (ESPApplicationCategoryEnum.INITIATION.getValue().equals(applicationCategory)) {
// 立项新增-Id置空
for (ProcessEsInitChange processEsInitChange : processEsInitChanges) {
processEsInitChange.setId(null);
}
// 转换为企标计划数据并入库
enterpriseStandardPlans = BeanCopyUtils.copyBeanList(processEsInitChanges, EnterpriseStandardPlan.class);
espService.saveBatch(enterpriseStandardPlans);
} else {
// 将Id设为企标计划的Id
for (ProcessEsInitChange processEsInitChange : processEsInitChanges) {
processEsInitChange.setId(processEsInitChange.getEspId());
}
// 完成时间变更
if (ESPProjectType.COMPLETE_TIME_CHANGE.getValue().equals(projectType)) {
enterpriseStandardPlans = BeanCopyUtils.copyBeanList(processEsInitChanges, EnterpriseStandardPlan.class);
espService.saveOrUpdateBatch(enterpriseStandardPlans);
}
// 工作中止
if (ESPProjectType.WORK_TERMINATE.getValue().equals(projectType)) {
// 将企标计划变更状态设为取消
for (ProcessEsInitChange processEsInitChange : processEsInitChanges) {
processEsInitChange.setProjectStatus(ESPChangeType.CANCEL.getValue());
}
enterpriseStandardPlans = BeanCopyUtils.copyBeanList(processEsInitChanges, EnterpriseStandardPlan.class);
espService.saveOrUpdateBatch(enterpriseStandardPlans);
}
// 责任部门变更
if (ESPProjectType.RESPONSIBLE_DEPT_CHANGE.getValue().equals(projectType)) {
// 将企标计划变更状态设为变更
for (ProcessEsInitChange processEsInitChange : processEsInitChanges) {
processEsInitChange.setProjectStatus(ESPChangeType.CHANGE.getValue());
}
enterpriseStandardPlans = BeanCopyUtils.copyBeanList(processEsInitChanges, EnterpriseStandardPlan.class);
espService.saveOrUpdateBatch(enterpriseStandardPlans);
}
// 合并
if (ESPProjectType.MERGE.getValue().equals(projectType)) {
for (ProcessEsInitChange processEsInitChange : processEsInitChanges) {
processEsInitChange.setId(null);
}
// 删除两个老企标计划
espService.deleteById(processEsInitChanges.get(0).getStandardIdOne());
espService.deleteById(processEsInitChanges.get(0).getStandardIdTwo());
// 生成新企标计划
enterpriseStandardPlans = BeanCopyUtils.copyBeanList(processEsInitChanges, EnterpriseStandardPlan.class);
espService.saveOrUpdateBatch(enterpriseStandardPlans);
}
}
log.info("数据存入企标计划数据库");
// 软删除流程数据
esInitChangeService.removeByProcessInstanceId(processInstanceId);
log.info("软删除流程数据");
//TODO 发起制修订流程
log.info("自动发起企标制修订流程");
}
}