fix(稽查整改流程): 强制撤销

This commit is contained in:
yjz
2024-01-31 13:50:30 +08:00
parent c60d4b512d
commit fd715f45ec
4 changed files with 98 additions and 7 deletions
@@ -35,6 +35,19 @@ public class EsInspectRectifyFlowController {
this.esInspectReportFlowService = esInspectReportFlowService;
}
/**
* 企标稽查整改-流程发起
* @param esInspectReportFlowVO 企标稽查整改VO对象
* @return 结果对象
*/
@AutoLog(value = "企标稽查整改-流程发起")
@ApiOperation(value="企标稽查整改-流程发起", notes="企标稽查整改-流程发起")
@PostMapping(value = "/flowStart")
public Result<T> flowStart(@RequestBody EsInspectRectifyFlowVO esInspectReportFlowVO) {
esInspectReportFlowService.flowStart(esInspectReportFlowVO);
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
}
/**
* 企标稽查整改-流程保存
* @param esInspectReportFlowVO 企标稽查整改VO对象
@@ -12,6 +12,13 @@ import java.text.ParseException;
* @Version: 1.0
**/
public interface IEsInspectRectifyFlowService {
/**
* 企标稽查流程-流程发起
* @param esInspectReportFlowVO
*/
void flowStart(EsInspectRectifyFlowVO esInspectReportFlowVO);
/**
* 生成企标稽查整改
* @param esInspectReportFlowVO
@@ -1,7 +1,11 @@
package com.jero.modules.activiti.process.esinspectrectify.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jero.modules.activiti.entity.ProcessAll;
import com.jero.modules.activiti.process.esinspectrectify.entity.ProcessEsInspectRectify;
import com.jero.modules.activiti.process.esinspectrectify.service.IProcessEsInspectRectifyService;
import com.jero.modules.activiti.service.WorkCenterService;
import com.jero.modules.activiti.util.SpringContextUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -24,10 +28,11 @@ public class EsInspectRectifyFlow implements WorkCenterService {
@Override
public void changeToDraft(ProcessAll processAll) {
// 删除业务表数据
/** IProcessEsInspectRectifyService processEsInspectRectifyService = SpringContextUtil.getBean(IProcessEsInspectRectifyService.class);
* processEsInspectRectifyService.remove(
* new LambdaQueryWrapper<ProcessEsInspectRectify>()
* .eq(ProcessEsInspectRectify::getProjectId, processAll.getProjectId()));
*/
IProcessEsInspectRectifyService processEsInspectRectifyService =
SpringContextUtil.getBean(IProcessEsInspectRectifyService.class);
processEsInspectRectifyService.remove(
new LambdaQueryWrapper<ProcessEsInspectRectify>()
.eq(ProcessEsInspectRectify::getProjectId, processAll.getProjectId()));
}
}
@@ -3,6 +3,7 @@ package com.jero.modules.activiti.process.esinspectrectify.service.impl;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
@@ -30,6 +31,7 @@ import com.jero.modules.activiti.service.ProcessApprovalRecordService;
import com.jero.modules.activiti.service.ProcessNodeLinkService;
import com.jero.modules.laws.enterprise.entity.EnterpriseStandardInspectRectifyPlan;
import com.jero.modules.laws.enterprise.service.EnterpriseStandardInspectRectifyPlanService;
import com.jero.modules.system.service.ISysUserService;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RuntimeService;
@@ -63,19 +65,22 @@ public class EsInspectRectifyFlowServiceImpl implements IEsInspectRectifyFlowSer
private final ProcessNodeLinkService processNodeLinkService;
private final IProcessEsInspectRectifyService processEsInspectRectifyService;
private final EnterpriseStandardInspectRectifyPlanService enterpriseStandardInspectRectifyPlanService;
private final ISysUserService sysUserService;
public EsInspectRectifyFlowServiceImpl(ProcessAllService processAllService,
ProcessApprovalRecordService processApprovalRecordService,
ProcessDraftService processDraftService,
ProcessNodeLinkService processNodeLinkService,
IProcessEsInspectRectifyService processEsInspectReportService,
EnterpriseStandardInspectRectifyPlanService enterpriseStandardInspectRectifyPlanService) {
EnterpriseStandardInspectRectifyPlanService enterpriseStandardInspectRectifyPlanService,
ISysUserService sysUserService) {
this.processAllService = processAllService;
this.processApprovalRecordService = processApprovalRecordService;
this.processDraftService = processDraftService;
this.processNodeLinkService = processNodeLinkService;
this.processEsInspectRectifyService = processEsInspectReportService;
this.enterpriseStandardInspectRectifyPlanService = enterpriseStandardInspectRectifyPlanService;
this.sysUserService = sysUserService;
}
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
@@ -83,6 +88,57 @@ public class EsInspectRectifyFlowServiceImpl implements IEsInspectRectifyFlowSer
@Resource
private TaskService taskService;
@Override
public void flowStart(EsInspectRectifyFlowVO esInspectReportFlowVO) {
// 流程信息
ProcessAll processAll = esInspectReportFlowVO.getProcessAll();
// 流程审批信息
ProcessApprovalRecord processApprovalRecord = esInspectReportFlowVO.getProcessApprovalRecord();
// map(参数)
Map<String, Object> map = esInspectReportFlowVO.getMap();
// 根据流程key启动流程 同时 设置审批人员参数
ProcessInstance processInstance = runtimeService
.startProcessInstanceByKey(EsInspectRectifyCommon.KEY, map);
// 再次设置map
runtimeService.setVariables(processInstance.getId(), map);
// 更新流程总表信息
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
processAll.setPrcType(Integer.valueOf(ProcessType.ES_INSPECT_REPORT.getValue()));
DateTime date = DateUtil.date();
processAll.setPrcNum(DateUtil.format(date, DatePattern.PURE_DATETIME_MS_PATTERN));
processAll.setPrcStatus(ProcessStatusEnum.INCOMPLETE.getValue());
processAll.setCreateUserId(loginUser.getId());
processAllService.update(processAll,
new LambdaUpdateWrapper<ProcessAll>()
.eq(ProcessAll::getProcessInstanceId, processInstance.getId()));
// 根据流程实例id查询
Task task = taskService.createTaskQuery()
.processInstanceId(processInstance.getId())
.singleResult();
// 更新流程审批信息、
processApprovalRecord.setUserId(loginUser.getId());
processApprovalRecord.setProjectId(processAll.getProjectId());
processApprovalRecord.setFinishFlag(FinishFlagEnum.COMPLETE.getValue());
processApprovalRecord.setEndTime(new Date());
processApprovalRecordService.update(processApprovalRecord,
new LambdaUpdateWrapper<ProcessApprovalRecord>()
.eq(ProcessApprovalRecord::getTaskId, task.getId()));
// 处理业务表数据
handleBusinessData(esInspectReportFlowVO);
// 新增流程实例节点关联用户表
processNodeLinkService.saveNodeUserLink(processInstance.getProcessDefinitionId(), processInstance.getId(), listToString(map));
// 自动完成第一个节点
taskService.complete(task.getId());
}
@Override
public void createReportFlow(EsInspectRectifyFlowVO esInspectReportFlowVO) {
// 流程信息
@@ -156,8 +212,18 @@ public class EsInspectRectifyFlowServiceImpl implements IEsInspectRectifyFlowSer
processDraft.setInfoJsonStr(esInspectReportFlowVO.getInfoJsonStr());
}
processDraft.setUserId(processApprovalRecord.getUserId());
processDraft.setId(String.valueOf(SnowflakeUtils.snowflake()).replaceFirst("\\{", "{\"revocation\": true,"));
processDraft.setId(String.valueOf(SnowflakeUtils.snowflake()));
processDraft.setSaveSource("3");
// 保存infoJsonStr信息
Map<String, Object> map = esInspectReportFlowVO.getMap();
map.put("responsible_dictText", sysUserService.dictByIdsOrUserNames(String.valueOf(map.get("responsible")), ""));
ProcessEsInspectRectify processEsInspectRectify = esInspectReportFlowVO.getProcessEsInspectRectify();
JSONObject jsonObject = new JSONObject();
jsonObject.put("revocation", true);
jsonObject.put("personInfo", map);
jsonObject.put("draftData", processEsInspectRectify);
processDraft.setInfoJsonStr(jsonObject.toJSONString());
processDraftService.save(processDraft);
}