Commit a26d1289 authored by tianbo's avatar tianbo

登记类修改并发问题

parent e32392c0
package com.yeejoin.amos.boot.module.jg.api.service; package com.yeejoin.amos.boot.module.jg.api.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jg.api.dto.JgChangeRegistrationReformDto; import com.yeejoin.amos.boot.module.jg.api.dto.JgChangeRegistrationReformDto;
...@@ -50,14 +49,15 @@ public interface IJgChangeRegistrationReformService { ...@@ -50,14 +49,15 @@ public interface IJgChangeRegistrationReformService {
* @param instanceId * @param instanceId
* @param operate * @param operate
* @param comment * @param comment
* @param nextTaskId 页面上送下一任务id
*/ */
void flowExecute(Long id, String instanceId, String operate, String comment); void flowExecute(Long id, String instanceId, String operate, String comment, String nextTaskId);
/** /**
* @deprecated 根据流程id执行撤回操作 * @deprecated 根据流程id执行撤回操作
* @param instanceId * @param instanceId
*/ */
void withdraw(String instanceId); void withdraw(String instanceId, String nextTaskId);
/** /**
* @deprecated 根据id批量删除数据 * @deprecated 根据id批量删除数据
......
...@@ -30,9 +30,9 @@ public interface IJgChangeRegistrationTransferService extends IService<JgChangeR ...@@ -30,9 +30,9 @@ public interface IJgChangeRegistrationTransferService extends IService<JgChangeR
Page<Map<String, Object>> queryListForPage(Page<Map<String, Object>> page, JgChangeRegistrationTransferDto params, String companyTypeCode, String companyType); Page<Map<String, Object>> queryListForPage(Page<Map<String, Object>> page, JgChangeRegistrationTransferDto params, String companyTypeCode, String companyType);
void flowExecute(Long sequenceNbr, String instanceId, String operate, String comment); void flowExecute(Long sequenceNbr, String instanceId, String operate, String comment, String nextTaskId);
void revocation(String instanceId); void revocation(String instanceId, String nextTaskId);
void exportUseRegistrationCertificate(String sequenceNbr, HttpServletResponse response, String printType); void exportUseRegistrationCertificate(String sequenceNbr, HttpServletResponse response, String printType);
......
package com.yeejoin.amos.boot.module.jg.biz.controller; package com.yeejoin.amos.boot.module.jg.biz.controller;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.module.jg.api.dto.JgScrapCancelDto;
import com.yeejoin.amos.boot.module.jg.api.enums.WorkFlowStatusEnum;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jg.api.dto.JgChangeRegistrationNameDto;
import java.util.*; import com.yeejoin.amos.boot.module.jg.api.enums.WorkFlowStatusEnum;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgChangeRegistrationNameServiceImpl; import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgChangeRegistrationNameServiceImpl;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import io.swagger.annotations.Api;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jg.api.dto.JgChangeRegistrationNameDto;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.*;
/** /**
* 更名变更登记 * 更名变更登记
...@@ -100,7 +92,11 @@ public class JgChangeRegistrationNameController extends BaseController { ...@@ -100,7 +92,11 @@ public class JgChangeRegistrationNameController extends BaseController {
LinkedHashMap jgRegistrationInfoMap = (LinkedHashMap) model1.get("jgRegistrationInfo"); LinkedHashMap jgRegistrationInfoMap = (LinkedHashMap) model1.get("jgRegistrationInfo");
JgChangeRegistrationNameDto jgScrapCancelDto = JSON.parseObject(JSON.toJSONString(jgRegistrationInfoMap), JgChangeRegistrationNameDto.class); JgChangeRegistrationNameDto jgScrapCancelDto = JSON.parseObject(JSON.toJSONString(jgRegistrationInfoMap), JgChangeRegistrationNameDto.class);
jgChangeRegistrationNameService.flowExecute(Long.valueOf(String.valueOf(jgScrapCancelDto.getSequenceNbr())), jgScrapCancelDto.getInstanceId(), String.valueOf(map.get("operate")), String.valueOf(map.get("opinion"))); jgChangeRegistrationNameService.flowExecute(Long.valueOf(String.valueOf(jgScrapCancelDto.getSequenceNbr())),
jgScrapCancelDto.getInstanceId(),
String.valueOf(map.get("operate")),
String.valueOf(map.get("operate")),
String.valueOf(map.get("nextTaskId")));
return ResponseHelper.buildResponse("ok"); return ResponseHelper.buildResponse("ok");
} }
......
...@@ -49,14 +49,18 @@ public class JgChangeRegistrationReformController extends BaseController { ...@@ -49,14 +49,18 @@ public class JgChangeRegistrationReformController extends BaseController {
@PostMapping(value = "/flowExecute") @PostMapping(value = "/flowExecute")
@ApiOperation(httpMethod = "POST", value = "执行流程", notes = "执行流程") @ApiOperation(httpMethod = "POST", value = "执行流程", notes = "执行流程")
public ResponseModel<Object> flowExecute(@RequestBody JSONObject map) { public ResponseModel<Object> flowExecute(@RequestBody JSONObject map) {
jgChangeRegistrationReformServiceImpl.flowExecute(Long.valueOf(String.valueOf(map.get("sequenceNbr"))),String.valueOf(map.get("instanceId")), String.valueOf(map.get("operate")), String.valueOf(map.get("comment"))); jgChangeRegistrationReformServiceImpl.flowExecute(Long.valueOf(String.valueOf(map.get("sequenceNbr"))),
String.valueOf(map.get("instanceId")),
String.valueOf(map.get("operate")),
String.valueOf(map.get("comment")),
String.valueOf(map.get("nextTaskId")));
return ResponseHelper.buildResponse("ok"); return ResponseHelper.buildResponse("ok");
} }
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/withdraw") @PostMapping(value = "/withdraw")
@ApiOperation(httpMethod = "POST", value = "撤回", notes = "撤回") @ApiOperation(httpMethod = "POST", value = "撤回", notes = "撤回")
public ResponseModel<Object> withdraw(@RequestBody JSONObject map) { public ResponseModel<Object> withdraw(@RequestBody JSONObject map) {
jgChangeRegistrationReformServiceImpl.withdraw(String.valueOf(map.get("instanceId"))); jgChangeRegistrationReformServiceImpl.withdraw(String.valueOf(map.get("instanceId")), String.valueOf(map.get("nextTaskId")));
return ResponseHelper.buildResponse("ok"); return ResponseHelper.buildResponse("ok");
} }
......
package com.yeejoin.amos.boot.module.jg.biz.controller; package com.yeejoin.amos.boot.module.jg.biz.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.netflix.ribbon.proxy.annotation.Http; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jg.api.dto.JgChangeRegistrationTransferDto;
import com.yeejoin.amos.boot.module.jg.api.service.IJgChangeRegistrationTransferService; import com.yeejoin.amos.boot.module.jg.api.service.IJgChangeRegistrationTransferService;
import com.yeejoin.amos.boot.module.jg.api.service.IJgInstallationNoticeService; import com.yeejoin.amos.boot.module.jg.api.service.IJgInstallationNoticeService;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgRegisterInfoServiceImpl;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController; import io.swagger.annotations.ApiOperation;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.BufferedOutputStream; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.Map;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.Map;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jg.api.dto.JgChangeRegistrationTransferDto;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
/** /**
* 移装变更登记登记 * 移装变更登记登记
...@@ -100,7 +88,11 @@ public class JgChangeRegistrationTransferController extends BaseController { ...@@ -100,7 +88,11 @@ public class JgChangeRegistrationTransferController extends BaseController {
@PostMapping(value = "/flowExecute") @PostMapping(value = "/flowExecute")
@ApiOperation(httpMethod = "POST", value = "执行流程", notes = "执行流程") @ApiOperation(httpMethod = "POST", value = "执行流程", notes = "执行流程")
public ResponseModel<Object> flowExecute(@RequestBody JSONObject map) { public ResponseModel<Object> flowExecute(@RequestBody JSONObject map) {
jgChangeRegistrationTransferService.flowExecute(Long.valueOf(String.valueOf(map.get("sequenceNbr"))),String.valueOf(map.get("instanceId")), String.valueOf(map.get("operate")), String.valueOf(map.get("opinion"))); jgChangeRegistrationTransferService.flowExecute(Long.valueOf(String.valueOf(map.get("sequenceNbr"))),
String.valueOf(map.get("instanceId")),
String.valueOf(map.get("operate")),
String.valueOf(map.get("operate")),
String.valueOf(map.get("nextTaskId")));
return ResponseHelper.buildResponse("ok"); return ResponseHelper.buildResponse("ok");
} }
...@@ -108,7 +100,8 @@ public class JgChangeRegistrationTransferController extends BaseController { ...@@ -108,7 +100,8 @@ public class JgChangeRegistrationTransferController extends BaseController {
@PostMapping(value = "/revocation") @PostMapping(value = "/revocation")
@ApiOperation(httpMethod = "POST", value = "撤回", notes = "撤回") @ApiOperation(httpMethod = "POST", value = "撤回", notes = "撤回")
public ResponseModel<Object> revocation(@RequestBody JSONObject map) { public ResponseModel<Object> revocation(@RequestBody JSONObject map) {
jgChangeRegistrationTransferService.revocation(String.valueOf(map.get("instanceId"))); jgChangeRegistrationTransferService.revocation(String.valueOf(map.get("instanceId")),
String.valueOf(map.get("nextTaskId")));
return ResponseHelper.buildResponse("ok"); return ResponseHelper.buildResponse("ok");
} }
......
package com.yeejoin.amos.boot.module.jg.biz.controller; package com.yeejoin.amos.boot.module.jg.biz.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey; import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import org.springframework.web.bind.annotation.RequestMapping; import com.yeejoin.amos.boot.module.jg.api.dto.JgEnableDisableDto;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.util.Map;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgEnableDisableServiceImpl; import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgEnableDisableServiceImpl;
import org.typroject.tyboot.core.foundation.context.RequestContext; import io.swagger.annotations.Api;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import io.swagger.annotations.ApiOperation;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.typroject.tyboot.core.foundation.context.RequestContext;
import com.yeejoin.amos.boot.module.jg.api.dto.JgEnableDisableDto;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.Map;
/** /**
* @author system_generator * @author system_generator
...@@ -74,7 +73,7 @@ public class JgEnableDisableController extends BaseController { ...@@ -74,7 +73,7 @@ public class JgEnableDisableController extends BaseController {
@PostMapping(value = "/withdraw") @PostMapping(value = "/withdraw")
@ApiOperation(httpMethod = "POST", value = "撤回", notes = "撤回") @ApiOperation(httpMethod = "POST", value = "撤回", notes = "撤回")
public ResponseModel<Object> withdraw(@RequestBody JSONObject map) { public ResponseModel<Object> withdraw(@RequestBody JSONObject map) {
jgEnableDisableServiceImpl.withdraw(String.valueOf(map.get("instanceId"))); jgEnableDisableServiceImpl.withdraw(String.valueOf(map.get("instanceId")), String.valueOf(map.get("nextTaskId")));
return ResponseHelper.buildResponse("ok"); return ResponseHelper.buildResponse("ok");
} }
......
...@@ -65,7 +65,7 @@ public class JgMaintenanceContractController extends BaseController { ...@@ -65,7 +65,7 @@ public class JgMaintenanceContractController extends BaseController {
@PostMapping(value = "/revocation") @PostMapping(value = "/revocation")
@ApiOperation(httpMethod = "POST", value = "维保合同撤回", notes = "维保合同撤回") @ApiOperation(httpMethod = "POST", value = "维保合同撤回", notes = "维保合同撤回")
public ResponseModel<Object> revocation(@RequestBody JSONObject map) { public ResponseModel<Object> revocation(@RequestBody JSONObject map) {
jgMaintenanceContractServiceImpl.revocation(String.valueOf(map.get("instanceId"))); jgMaintenanceContractServiceImpl.revocation(String.valueOf(map.get("instanceId")), String.valueOf(map.get("nextTaskId")));
return ResponseHelper.buildResponse("ok"); return ResponseHelper.buildResponse("ok");
} }
...@@ -129,7 +129,12 @@ public class JgMaintenanceContractController extends BaseController { ...@@ -129,7 +129,12 @@ public class JgMaintenanceContractController extends BaseController {
@PostMapping(value = "/flowExecute") @PostMapping(value = "/flowExecute")
@ApiOperation(httpMethod = "POST", value = "执行流程", notes = "执行流程") @ApiOperation(httpMethod = "POST", value = "执行流程", notes = "执行流程")
public ResponseModel<Object> flowExecute(@RequestBody JSONObject map) { public ResponseModel<Object> flowExecute(@RequestBody JSONObject map) {
jgMaintenanceContractServiceImpl.flowExecute(Long.valueOf(String.valueOf(map.get("sequenceNbr"))),String.valueOf(map.get("instanceId")), String.valueOf(map.get("operate")), String.valueOf(map.get("comment")), true); jgMaintenanceContractServiceImpl.flowExecute(Long.valueOf(String.valueOf(map.get("sequenceNbr"))),
String.valueOf(map.get("instanceId")),
String.valueOf(map.get("operate")),
String.valueOf(map.get("comment")),
true,
String.valueOf(map.get("nextTaskId")));
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class); ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
if (map.containsKey("formData") && !ObjectUtils.isEmpty(map.get("formData"))){ if (map.containsKey("formData") && !ObjectUtils.isEmpty(map.get("formData"))){
JgMaintenanceContract dto = new JgMaintenanceContract(); JgMaintenanceContract dto = new JgMaintenanceContract();
......
...@@ -78,7 +78,12 @@ public class JgScrapCancelController extends BaseController { ...@@ -78,7 +78,12 @@ public class JgScrapCancelController extends BaseController {
jgScrapCancelInfo.remove("SEQUENCE_NBR"); jgScrapCancelInfo.remove("SEQUENCE_NBR");
JgScrapCancelDto jgScrapCancelDto = JSON.parseObject(JSON.toJSONString(jgScrapCancelInfo), JgScrapCancelDto.class); JgScrapCancelDto jgScrapCancelDto = JSON.parseObject(JSON.toJSONString(jgScrapCancelInfo), JgScrapCancelDto.class);
jgScrapCancelService.flowExecute(jgScrapCancelDto.getEquList(), Long.valueOf(String.valueOf(jgScrapCancelDto.getSequenceNbr())), jgScrapCancelDto.getInstanceId(), String.valueOf(map.get("operate")), String.valueOf(map.get("opinion"))); jgScrapCancelService.flowExecute(jgScrapCancelDto.getEquList(),
Long.valueOf(String.valueOf(jgScrapCancelDto.getSequenceNbr())),
jgScrapCancelDto.getInstanceId(),
String.valueOf(map.get("operate")),
String.valueOf(map.get("operate")),
String.valueOf(map.get("nextTaskId")));
return ResponseHelper.buildResponse("ok"); return ResponseHelper.buildResponse("ok");
} }
...@@ -135,7 +140,7 @@ public class JgScrapCancelController extends BaseController { ...@@ -135,7 +140,7 @@ public class JgScrapCancelController extends BaseController {
@PostMapping(value = "/withdraw") @PostMapping(value = "/withdraw")
@ApiOperation(httpMethod = "POST", value = "撤回", notes = "撤回") @ApiOperation(httpMethod = "POST", value = "撤回", notes = "撤回")
public ResponseModel<Object> revocation(@RequestBody JSONObject map) { public ResponseModel<Object> revocation(@RequestBody JSONObject map) {
jgScrapCancelService.revocation(String.valueOf(map.get("instanceId"))); jgScrapCancelService.revocation(String.valueOf(map.get("instanceId")), String.valueOf(map.get("nextTaskId")));
return ResponseHelper.buildResponse("ok"); return ResponseHelper.buildResponse("ok");
} }
......
...@@ -494,6 +494,9 @@ public class JgChangeRegistrationNameServiceImpl extends BaseService<JgChangeReg ...@@ -494,6 +494,9 @@ public class JgChangeRegistrationNameServiceImpl extends BaseService<JgChangeReg
// 判断撤回后当前的节点,如果当前节点为提交节点则页面可编辑 // 判断撤回后当前的节点,如果当前节点为提交节点则页面可编辑
jsonObject.put("pageType", this.getPageTypeByCurrentNode(jgChangeRegistrationName.getAuditStatus())); jsonObject.put("pageType", this.getPageTypeByCurrentNode(jgChangeRegistrationName.getAuditStatus()));
commonService.rollbackTask(instanceId, jsonObject); commonService.rollbackTask(instanceId, jsonObject);
// 保存redis最新流程数据
commonService.saveExecuteFlowData2Redis(jgChangeRegistrationName.getInstanceId(), this.buildInstanceRuntimeData(jgChangeRegistrationName));
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
...@@ -518,19 +521,20 @@ public class JgChangeRegistrationNameServiceImpl extends BaseService<JgChangeReg ...@@ -518,19 +521,20 @@ public class JgChangeRegistrationNameServiceImpl extends BaseService<JgChangeReg
} }
public void flowExecute(Long id, String instanceId, String operate, String comment) { public void flowExecute(Long id, String instanceId, String operate, String comment, String nextTaskId) {
String lockKey = CommonServiceImpl.buildJgExecuteLockKey(instanceId); String lockKey = CommonServiceImpl.buildJgExecuteLockKey(instanceId);
RLock lock = redissonClient.getLock(lockKey); RLock lock = redissonClient.getLock(lockKey);
try { try {
boolean isLocked = lock.tryLock(); boolean isLocked = lock.tryLock(0, 180, TimeUnit.SECONDS);
// 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回) // 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回)
if(!isLocked){ if(!isLocked){
throw new BadRequest("当前流程已经被执行!"); throw new BadRequest("当前流程已经被执行!");
} }
// 流程执行时,状态及权限校验
commonService.checkForExecuteFlow(nextTaskId, instanceId);
JgChangeRegistrationName jgChangeRegistrationName = this.getBaseMapper().selectById(id); JgChangeRegistrationName jgChangeRegistrationName = this.getBaseMapper().selectById(id);
String taskId = jgChangeRegistrationName.getNextTaskId(); String taskId = jgChangeRegistrationName.getNextTaskId();
// 流程执行时,状态及权限校验
commonService.checkForExecuteFlow(taskId, instanceId);
// 组装信息 // 组装信息
TaskResultDTO dto = new TaskResultDTO(); TaskResultDTO dto = new TaskResultDTO();
dto.setResultCode("approvalStatus"); dto.setResultCode("approvalStatus");
...@@ -549,6 +553,8 @@ public class JgChangeRegistrationNameServiceImpl extends BaseService<JgChangeReg ...@@ -549,6 +553,8 @@ public class JgChangeRegistrationNameServiceImpl extends BaseService<JgChangeReg
ProcessTaskDTO processTaskDTO = cmWorkflowService.completeOrReject(taskId, dto, operate); ProcessTaskDTO processTaskDTO = cmWorkflowService.completeOrReject(taskId, dto, operate);
// 更新下一步执行人、创建待办 // 更新下一步执行人、创建待办
updateExecuteIds(instanceId, id, operate, processTaskDTO); updateExecuteIds(instanceId, id, operate, processTaskDTO);
} catch (InterruptedException e) {
e.printStackTrace();
} finally { } finally {
if(lock.isHeldByCurrentThread()){ if(lock.isHeldByCurrentThread()){
lock.unlock(); lock.unlock();
......
...@@ -7,16 +7,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; ...@@ -7,16 +7,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey; import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jg.api.dto.TaskMessageDto; import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.api.dto.TaskModelDto;
import com.yeejoin.amos.boot.module.jg.api.dto.WorkflowResultDto;
import com.yeejoin.amos.boot.module.jg.api.entity.*; import com.yeejoin.amos.boot.module.jg.api.entity.*;
import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum; import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.EquipTypeEnum; import com.yeejoin.amos.boot.module.jg.api.enums.EquipTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.WorkFlowStatusEnum; import com.yeejoin.amos.boot.module.jg.api.enums.WorkFlowStatusEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.*; import com.yeejoin.amos.boot.module.jg.api.mapper.*;
import com.yeejoin.amos.boot.module.jg.api.service.IJgChangeRegistrationReformService; import com.yeejoin.amos.boot.module.jg.api.service.IJgChangeRegistrationReformService;
import com.yeejoin.amos.boot.module.jg.api.dto.JgChangeRegistrationReformDto;
import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient; import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient;
import com.yeejoin.amos.boot.module.jg.biz.service.*; import com.yeejoin.amos.boot.module.jg.biz.service.*;
import com.yeejoin.amos.boot.module.ymt.api.entity.*; import com.yeejoin.amos.boot.module.ymt.api.entity.*;
...@@ -27,6 +24,8 @@ import com.yeejoin.amos.boot.module.ymt.api.mapper.*; ...@@ -27,6 +24,8 @@ import com.yeejoin.amos.boot.module.ymt.api.mapper.*;
import com.yeejoin.amos.feign.systemctl.model.TaskV2Model; import com.yeejoin.amos.feign.systemctl.model.TaskV2Model;
import com.yeejoin.amos.feign.workflow.model.*; import com.yeejoin.amos.feign.workflow.model.*;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -42,6 +41,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel; ...@@ -42,6 +41,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -108,6 +108,9 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR ...@@ -108,6 +108,9 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR
@Autowired @Autowired
private JgChangeRegistrationNameEqMapper jgChangeRegistrationNameEqMapper; private JgChangeRegistrationNameEqMapper jgChangeRegistrationNameEqMapper;
@Autowired
private RedissonClient redissonClient;
/*** /***
* @deprecated 根据查询调教获取分页对象 * @deprecated 根据查询调教获取分页对象
* @param dto 查询的dto对象 * @param dto 查询的dto对象
...@@ -227,7 +230,7 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR ...@@ -227,7 +230,7 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR
String instanceId = ""; String instanceId = "";
if (!ObjectUtils.isEmpty(jgChangeRegistrationReform.getSequenceNbr()) && !ObjectUtils.isEmpty(jgChangeRegistrationReform.getInstanceId())) { if (!ObjectUtils.isEmpty(jgChangeRegistrationReform.getSequenceNbr()) && !ObjectUtils.isEmpty(jgChangeRegistrationReform.getInstanceId())) {
// 如果是旧流程则执行一步 // 如果是旧流程则执行一步
flowExecute(jgChangeRegistrationReform.getSequenceNbr(), jgChangeRegistrationReform.getInstanceId(), "0", ""); flowExecute(jgChangeRegistrationReform.getSequenceNbr(), jgChangeRegistrationReform.getInstanceId(), "0", "", jgChangeRegistrationReform.getNextTaskId());
// updateExecuteIds(instanceId, jgChangeRegistrationReform.getSequenceNbr(), "0"); // updateExecuteIds(instanceId, jgChangeRegistrationReform.getSequenceNbr(), "0");
} else { } else {
// 如果是新启动的流程开启自动访问 // 如果是新启动的流程开启自动访问
...@@ -277,7 +280,7 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR ...@@ -277,7 +280,7 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR
WorkflowResultDto workflowResultDto = conveterProcessTaskDTO2WorkflowResultDto(processTaskDTO); WorkflowResultDto workflowResultDto = conveterProcessTaskDTO2WorkflowResultDto(processTaskDTO);
jgChangeRegistrationReform.setNextExecutorIds(workflowResultDto.getNextExecutorRoleIds()); jgChangeRegistrationReform.setNextExecutorIds(workflowResultDto.getNextExecutorRoleIds());
jgChangeRegistrationReform.setNextExecuteUserIds(workflowResultDto.getNextExecutorUserIds()); jgChangeRegistrationReform.setNextExecuteUserIds(workflowResultDto.getNextExecutorUserIds());
String nextTaskid = Optional.ofNullable(workflowResultDto.getNextTaskId()).orElse(""); String nextTaskId = Optional.ofNullable(workflowResultDto.getNextTaskId()).orElse("");
String taskCode = FlowStatusEnum.TO_BE_FINISHED.getName(); String taskCode = FlowStatusEnum.TO_BE_FINISHED.getName();
if (!ObjectUtils.isEmpty(workflowResultDto.getNextTaskCode())) { if (!ObjectUtils.isEmpty(workflowResultDto.getNextTaskCode())) {
taskCode = Optional.ofNullable(workflowResultDto.getNextTaskCode()).orElse(""); taskCode = Optional.ofNullable(workflowResultDto.getNextTaskCode()).orElse("");
...@@ -290,7 +293,7 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR ...@@ -290,7 +293,7 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR
updateTodoAndCreate = Boolean.FALSE; updateTodoAndCreate = Boolean.FALSE;
} }
if (!FlowStatusEnum.TO_BE_FINISHED.getName().equals(taskCode)) { if (!FlowStatusEnum.TO_BE_FINISHED.getName().equals(taskCode)) {
jgChangeRegistrationReform.setNextTaskId(nextTaskid); jgChangeRegistrationReform.setNextTaskId(nextTaskId);
jgChangeRegistrationReform.setNextExecutorIds(role); jgChangeRegistrationReform.setNextExecutorIds(role);
jgChangeRegistrationReform.setPromoter(reginParams.getUserModel().getUserId()); jgChangeRegistrationReform.setPromoter(reginParams.getUserModel().getUserId());
jgChangeRegistrationReform.setInstanceId(instanceId); jgChangeRegistrationReform.setInstanceId(instanceId);
...@@ -356,63 +359,111 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR ...@@ -356,63 +359,111 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR
map.put("model", conveterTaskMessageDTO(jgChangeRegistrationReform)); map.put("model", conveterTaskMessageDTO(jgChangeRegistrationReform));
commonServiceImpl.updateTaskModel(map); commonServiceImpl.updateTaskModel(map);
} }
// redis流程实时数据更新
commonServiceImpl.saveExecuteFlowData2Redis(instanceId, this.buildInstanceRuntimeData(jgChangeRegistrationReform));
this.getBaseMapper().updateById(jgChangeRegistrationReform); this.getBaseMapper().updateById(jgChangeRegistrationReform);
} }
public void flowExecute(Long id, String instanceId, String operate, String comment) { private InstanceRuntimeData buildInstanceRuntimeData(JgChangeRegistrationReform jgChangeRegistrationReform) {
ProcessTaskDTO processTaskDTO = new ProcessTaskDTO(); return InstanceRuntimeData.builder()
JgChangeRegistrationReform jgChangeRegistrationReform = this.getBaseMapper().selectById(id); .nextExecuteUserIds(jgChangeRegistrationReform.getNextExecuteUserIds())
String taskId = jgChangeRegistrationReform.getNextTaskId(); .promoter(jgChangeRegistrationReform.getPromoter())
//组装信息 .nextTaskId(jgChangeRegistrationReform.getNextTaskId())
TaskResultDTO dto = new TaskResultDTO(); .build();
dto.setResultCode("approvalStatus"); }
dto.setTaskId(taskId);
dto.setComment(comment); public void flowExecute(Long id, String instanceId, String operate, String comment, String nextTaskId) {
HashMap<String, Object> map = new HashMap<>(); String lockKey = CommonServiceImpl.buildJgExecuteLockKey(instanceId);
map.put("approvalStatus", operate); RLock lock = redissonClient.getLock(lockKey);
//2023年12月27日16点33分 流程状态为起草人撤回或者一级审批驳回时需要将提交时的已同意修改为已提交 try {
if (!ObjectUtils.isEmpty(jgChangeRegistrationReform) && (jgChangeRegistrationReform.getStatus().equals(WorkFlowStatusEnum.CHANGE_SUBMIT.getRollBack()) || jgChangeRegistrationReform.getStatus().equals(WorkFlowStatusEnum.CHANGE_SUBMIT.getReject()))) { boolean isLocked = lock.tryLock(0, 180, TimeUnit.SECONDS);
map.put("approvalStatus", "提交"); // 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回)
} if (!isLocked) {
dto.setVariable(map); throw new BadRequest("当前流程已经被执行!");
dto.setNextExecuteUserCompanyCode(getNextUserOrgCode(operate, jgChangeRegistrationReform)); }
//执行流程 // 流程执行时,状态及权限校验
processTaskDTO = iCmWorkflowService.completeOrReject(taskId, dto, operate); commonServiceImpl.checkForExecuteFlow(nextTaskId, instanceId);
// 更新下一步执行人
updateExecuteIds(instanceId, jgChangeRegistrationReform, operate, processTaskDTO); ProcessTaskDTO processTaskDTO;
JgChangeRegistrationReform jgChangeRegistrationReform = this.getBaseMapper().selectById(id);
String taskId = jgChangeRegistrationReform.getNextTaskId();
//组装信息
TaskResultDTO dto = new TaskResultDTO();
dto.setResultCode("approvalStatus");
dto.setTaskId(taskId);
dto.setComment(comment);
HashMap<String, Object> map = new HashMap<>();
map.put("approvalStatus", operate);
//2023年12月27日16点33分 流程状态为起草人撤回或者一级审批驳回时需要将提交时的已同意修改为已提交
if (!ObjectUtils.isEmpty(jgChangeRegistrationReform) && (jgChangeRegistrationReform.getStatus().equals(WorkFlowStatusEnum.CHANGE_SUBMIT.getRollBack()) || jgChangeRegistrationReform.getStatus().equals(WorkFlowStatusEnum.CHANGE_SUBMIT.getReject()))) {
map.put("approvalStatus", "提交");
}
dto.setVariable(map);
dto.setNextExecuteUserCompanyCode(getNextUserOrgCode(operate, jgChangeRegistrationReform));
//执行流程
processTaskDTO = iCmWorkflowService.completeOrReject(taskId, dto, operate);
// 更新下一步执行人
updateExecuteIds(instanceId, jgChangeRegistrationReform, operate, processTaskDTO);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
if (lock.isHeldByCurrentThread()) {
lock.unlock();
}
}
} }
public void withdraw(String instanceId) { public void withdraw(String instanceId, String nextTaskId) {
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class); String lockKey = CommonServiceImpl.buildJgExecuteLockKey(instanceId);
JgChangeRegistrationReform jgChangeRegistrationReform = this.getBaseMapper().selectOne(new QueryWrapper<JgChangeRegistrationReform>().eq("instance_id", instanceId)); RLock lock = redissonClient.getLock(lockKey);
ProcessTaskDTO processTaskDTO = iCmWorkflowService.rollBack(instanceId); try {
WorkflowResultDto workflowResultDto = conveterProcessTaskDTO2WorkflowResultDto(processTaskDTO); boolean isLocked = lock.tryLock(0, 180, TimeUnit.SECONDS);
String taskCode = Optional.ofNullable(workflowResultDto.getNextTaskCode()).orElse(""); // 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回)
String role = Optional.ofNullable(workflowResultDto.getNextExecutorRoleIds()).orElse(""); if (!isLocked) {
if (!ObjectUtils.isEmpty(taskCode)) { throw new BadRequest("当前流程已经被执行!");
jgChangeRegistrationReform.setAuditStatus(WorkFlowStatusEnum.getMessage(taskCode).getRollBack()); }
jgChangeRegistrationReform.setStatus(WorkFlowStatusEnum.getMessage(taskCode).getRollBack()); // 流程执行时,状态及权限校验
commonServiceImpl.checkForRevocationFlow(nextTaskId, instanceId);
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
JgChangeRegistrationReform jgChangeRegistrationReform = this.getBaseMapper().selectOne(new QueryWrapper<JgChangeRegistrationReform>().eq("instance_id", instanceId));
ProcessTaskDTO processTaskDTO = iCmWorkflowService.rollBack(instanceId);
WorkflowResultDto workflowResultDto = conveterProcessTaskDTO2WorkflowResultDto(processTaskDTO);
String taskCode = Optional.ofNullable(workflowResultDto.getNextTaskCode()).orElse("");
String role = Optional.ofNullable(workflowResultDto.getNextExecutorRoleIds()).orElse("");
if (!ObjectUtils.isEmpty(taskCode)) {
jgChangeRegistrationReform.setAuditStatus(WorkFlowStatusEnum.getMessage(taskCode).getRollBack());
jgChangeRegistrationReform.setStatus(WorkFlowStatusEnum.getMessage(taskCode).getRollBack());
}
jgChangeRegistrationReform.setPromoter(reginParams.getUserModel().getUserId());
jgChangeRegistrationReform.setNextTaskId(workflowResultDto.getNextTaskId());
jgChangeRegistrationReform.setNextExecuteUserIds(workflowResultDto.getNextExecutorUserIds());
jgChangeRegistrationReform.setNextExecutorIds(role);
this.getBaseMapper().updateById(jgChangeRegistrationReform);
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(jgChangeRegistrationReform));
jsonObject.put("flowStatus", commonServiceImpl.getDictionaryCodeByName(jgChangeRegistrationReform.getAuditStatus()));
jsonObject.put("flowStatusLabel", jgChangeRegistrationReform.getAuditStatus());
jsonObject.put("nextTaskId", jgChangeRegistrationReform.getNextTaskId());
jsonObject.put("nextExecuteUser", jgChangeRegistrationReform.getNextExecutorIds());
jsonObject.put("taskType", BusinessTypeEnum.JG_RENOVATION_REGISTRATION.getCode());
jsonObject.put("pageType", "look");
//如果创建人等于当前人则打开编辑页面
if (taskCode.equals(WorkFlowStatusEnum.CHANGE_SUBMIT.getCode())) {
jsonObject.put("pageType", "edit");
}
jsonObject.put("model", conveterTaskMessageDTO(jgChangeRegistrationReform));
commonServiceImpl.rollbackTask(instanceId, jsonObject);
// redis流程实时数据更新
commonServiceImpl.saveExecuteFlowData2Redis(instanceId, this.buildInstanceRuntimeData(jgChangeRegistrationReform));
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
if(lock.isHeldByCurrentThread()){
lock.unlock();
}
} }
jgChangeRegistrationReform.setPromoter(reginParams.getUserModel().getUserId());
jgChangeRegistrationReform.setNextTaskId(workflowResultDto.getNextTaskId());
jgChangeRegistrationReform.setNextExecuteUserIds(workflowResultDto.getNextExecutorUserIds());
jgChangeRegistrationReform.setNextExecutorIds(role);
this.getBaseMapper().updateById(jgChangeRegistrationReform);
// commonServiceImpl.deleteTaskModel(instanceId);
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(jgChangeRegistrationReform));
jsonObject.put("flowStatus", commonServiceImpl.getDictionaryCodeByName(jgChangeRegistrationReform.getAuditStatus()));
jsonObject.put("flowStatusLabel", jgChangeRegistrationReform.getAuditStatus());
jsonObject.put("nextTaskId", jgChangeRegistrationReform.getNextTaskId());
jsonObject.put("nextExecuteUser", jgChangeRegistrationReform.getNextExecutorIds());
jsonObject.put("taskType", BusinessTypeEnum.JG_RENOVATION_REGISTRATION.getCode());
jsonObject.put("pageType", "look");
//如果创建人等于当前人则打开编辑页面
if (taskCode.equals(WorkFlowStatusEnum.CHANGE_SUBMIT.getCode())) {
jsonObject.put("pageType", "edit");
}
jsonObject.put("model", conveterTaskMessageDTO(jgChangeRegistrationReform));
commonServiceImpl.rollbackTask(instanceId, jsonObject);
} }
public void deleteBatch(List<Long> ids) { public void deleteBatch(List<Long> ids) {
......
...@@ -10,10 +10,7 @@ import com.yeejoin.amos.boot.biz.common.bo.CompanyBo; ...@@ -10,10 +10,7 @@ import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey; import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jg.api.dto.JgChangeRegistrationTransferDto; import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.api.dto.TaskMessageDto;
import com.yeejoin.amos.boot.module.jg.api.dto.TaskModelDto;
import com.yeejoin.amos.boot.module.jg.api.dto.WorkflowResultDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgChangeRegistrationTransfer; import com.yeejoin.amos.boot.module.jg.api.entity.JgChangeRegistrationTransfer;
import com.yeejoin.amos.boot.module.jg.api.entity.JgChangeRegistrationTransferEq; import com.yeejoin.amos.boot.module.jg.api.entity.JgChangeRegistrationTransferEq;
import com.yeejoin.amos.boot.module.jg.api.entity.JgRegistrationHistory; import com.yeejoin.amos.boot.module.jg.api.entity.JgRegistrationHistory;
...@@ -48,6 +45,8 @@ import org.elasticsearch.client.RestHighLevelClient; ...@@ -48,6 +45,8 @@ import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -63,6 +62,7 @@ import javax.servlet.http.HttpServletResponse; ...@@ -63,6 +62,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -125,6 +125,9 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -125,6 +125,9 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
@Autowired @Autowired
CommonServiceImpl commonServiceImpl; CommonServiceImpl commonServiceImpl;
@Autowired
private RedissonClient redissonClient;
/** /**
* 新增移装变更登记 * 新增移装变更登记
* *
...@@ -325,7 +328,7 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -325,7 +328,7 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
String instanceId = ""; String instanceId = "";
if (!ValidationUtil.isEmpty(oldTransfer.getSequenceNbr()) && !ValidationUtil.isEmpty(oldTransfer.getInstanceId())) { if (!ValidationUtil.isEmpty(oldTransfer.getSequenceNbr()) && !ValidationUtil.isEmpty(oldTransfer.getInstanceId())) {
this.flowExecute(oldTransfer.getSequenceNbr(), oldTransfer.getInstanceId(), "0", ""); this.flowExecute(oldTransfer.getSequenceNbr(), oldTransfer.getInstanceId(), "0", "", String.valueOf(map.get("nextTaskId")));
} else { } else {
// 如果是新启动的流程开启自动访问 // 如果是新启动的流程开启自动访问
String equipListName = Optional.ofNullable(tableData.get("equListDesc")).orElse("无").toString(); String equipListName = Optional.ofNullable(tableData.get("equListDesc")).orElse("无").toString();
...@@ -385,30 +388,47 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -385,30 +388,47 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
* @param operate * @param operate
* @param comment * @param comment
*/ */
public void flowExecute(Long id, String instanceId, String operate, String comment) { public void flowExecute(Long id, String instanceId, String operate, String comment, String nextTaskId) {
WorkflowResultDto workflowResult = new WorkflowResultDto(); String lockKey = CommonServiceImpl.buildJgExecuteLockKey(instanceId);
JgChangeRegistrationTransfer transfer = this.getById(id); RLock lock = redissonClient.getLock(lockKey);
try {
String taskId = transfer.getNextTaskId(); boolean isLocked = lock.tryLock(0, 180, TimeUnit.SECONDS);
//组装信息 // 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回)
TaskResultDTO dto = new TaskResultDTO(); if(!isLocked){
dto.setResultCode("approvalStatus"); throw new BadRequest("当前流程已经被执行!");
dto.setTaskId(taskId); }
dto.setComment(comment); // 流程执行时,状态及权限校验
HashMap<String, Object> map = new HashMap<>(); commonService.checkForExecuteFlow(nextTaskId, instanceId);
map.put("approvalStatus", operate);
dto.setVariable(map); WorkflowResultDto workflowResult;
//下一节点执行人单位(下节点接收机构code) JgChangeRegistrationTransfer transfer = this.getById(id);
dto.setNextExecuteUserCompanyCode(this.getNextUserOrgCode(operate, transfer));
if (!ObjectUtils.isEmpty(transfer) && (transfer.getStatus().equals(WorkFlowStatusEnum.TRANSFER_SUBMIT.getRollBack()) || transfer.getStatus().equals(WorkFlowStatusEnum.TRANSFER_SUBMIT.getReject()))) { String taskId = transfer.getNextTaskId();
map.put("approvalStatus", "提交"); //组装信息
TaskResultDTO dto = new TaskResultDTO();
dto.setResultCode("approvalStatus");
dto.setTaskId(taskId);
dto.setComment(comment);
HashMap<String, Object> map = new HashMap<>();
map.put("approvalStatus", operate);
dto.setVariable(map);
//下一节点执行人单位(下节点接收机构code)
dto.setNextExecuteUserCompanyCode(this.getNextUserOrgCode(operate, transfer));
if (!ObjectUtils.isEmpty(transfer) && (transfer.getStatus().equals(WorkFlowStatusEnum.TRANSFER_SUBMIT.getRollBack()) || transfer.getStatus().equals(WorkFlowStatusEnum.TRANSFER_SUBMIT.getReject()))) {
map.put("approvalStatus", "提交");
}
//执行流程
ProcessTaskDTO complete = icmWorkflowService.completeOrReject(taskId, dto, operate);
workflowResult = commonService.buildWorkFlowInfo(Collections.singletonList(complete)).get(0);
// 更新下一步执行人
this.updateExecuteIds(instanceId, transfer, operate, workflowResult);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
if(lock.isHeldByCurrentThread()){
lock.unlock();
}
} }
//执行流程
ProcessTaskDTO complete = icmWorkflowService.completeOrReject(taskId, dto, operate);
workflowResult = commonService.buildWorkFlowInfo(Collections.singletonList(complete)).get(0);
// 更新下一步执行人
this.updateExecuteIds(instanceId, transfer, operate, workflowResult);
} }
/** /**
...@@ -416,43 +436,71 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -416,43 +436,71 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
* *
* @param instanceId * @param instanceId
*/ */
public void revocation(String instanceId) { public void revocation(String instanceId, String nextTaskId) {
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class); String lockKey = CommonServiceImpl.buildJgExecuteLockKey(instanceId);
RLock lock = redissonClient.getLock(lockKey);
JgChangeRegistrationTransfer jgTransfer = new JgChangeRegistrationTransfer(); try {
LambdaQueryWrapper<JgChangeRegistrationTransfer> lambda = new QueryWrapper<JgChangeRegistrationTransfer>().lambda(); boolean isLocked = lock.tryLock(0, 180, TimeUnit.SECONDS);
lambda.eq(JgChangeRegistrationTransfer::getInstanceId, instanceId); // 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回)
jgTransfer = this.getOne(lambda); if(!isLocked){
ProcessTaskDTO processTask = icmWorkflowService.rollBack(instanceId); throw new BadRequest("当前流程已经被执行!");
WorkflowResultDto workflowResult = commonService.buildWorkFlowInfo(Collections.singletonList(processTask)).get(0); }
String taskCode = ""; // 撤回校验
String role = ""; commonServiceImpl.checkForRevocationFlow(nextTaskId, instanceId);
if (!ValidationUtil.isEmpty(workflowResult)) {
taskCode = Optional.ofNullable(workflowResult.getNextTaskCode()).orElse(""); ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
role = Optional.ofNullable(workflowResult.getNextExecutorRoleIds()).orElse("");
jgTransfer.setNextTaskId(workflowResult.getNextTaskId()); JgChangeRegistrationTransfer jgTransfer;
// 更新下一步可执行人 LambdaQueryWrapper<JgChangeRegistrationTransfer> lambda = new QueryWrapper<JgChangeRegistrationTransfer>().lambda();
jgTransfer.setNextExecuteUserIds(workflowResult.getNextExecutorUserIds()); lambda.eq(JgChangeRegistrationTransfer::getInstanceId, instanceId);
} jgTransfer = this.getOne(lambda);
if (!ObjectUtils.isEmpty(taskCode)) { ProcessTaskDTO processTask = icmWorkflowService.rollBack(instanceId);
jgTransfer.setAuditStatus(WorkFlowStatusEnum.getMessage(taskCode).getRollBack()); WorkflowResultDto workflowResult = commonService.buildWorkFlowInfo(Collections.singletonList(processTask)).get(0);
jgTransfer.setStatus(WorkFlowStatusEnum.getMessage(taskCode).getRollBack()); String taskCode = "";
String role = "";
if (!ValidationUtil.isEmpty(workflowResult)) {
taskCode = Optional.ofNullable(workflowResult.getNextTaskCode()).orElse("");
role = Optional.ofNullable(workflowResult.getNextExecutorRoleIds()).orElse("");
jgTransfer.setNextTaskId(workflowResult.getNextTaskId());
// 更新下一步可执行人
jgTransfer.setNextExecuteUserIds(workflowResult.getNextExecutorUserIds());
}
if (!ObjectUtils.isEmpty(taskCode)) {
jgTransfer.setAuditStatus(WorkFlowStatusEnum.getMessage(taskCode).getRollBack());
jgTransfer.setStatus(WorkFlowStatusEnum.getMessage(taskCode).getRollBack());
}
jgTransfer.setPromoter(reginParams.getUserModel().getUserId());
jgTransfer.setNextExecutorIds(role);
this.updateById(jgTransfer);
//待办 撤回
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(jgTransfer));
jsonObject.put("flowStatus", commonService.getDictionaryCodeByName(jgTransfer.getAuditStatus()));
jsonObject.put("flowStatusLabel", jgTransfer.getAuditStatus());
jsonObject.put("nextTaskId", jgTransfer.getNextTaskId());
jsonObject.put("nextExecuteUser", jgTransfer.getNextExecutorIds());
jsonObject.put("taskType", BusinessTypeEnum.JG_CHANGE_REGISTRATION.getCode());
// 判断撤回后当前的节点,如果当前节点为提交节点则页面可编辑
jsonObject.put("pageType", this.getPageTypeByCurrentNode(jgTransfer.getAuditStatus()));
commonService.rollbackTask(instanceId, jsonObject);
// redis流程实时数据更新
commonServiceImpl.saveExecuteFlowData2Redis(instanceId, this.buildInstanceRuntimeData(jgTransfer));
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
if(lock.isHeldByCurrentThread()){
lock.unlock();
}
} }
jgTransfer.setPromoter(reginParams.getUserModel().getUserId());
jgTransfer.setNextExecutorIds(role);
this.updateById(jgTransfer);
//待办 撤回
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(jgTransfer));
jsonObject.put("flowStatus", commonService.getDictionaryCodeByName(jgTransfer.getAuditStatus()));
jsonObject.put("flowStatusLabel", jgTransfer.getAuditStatus());
jsonObject.put("nextTaskId", jgTransfer.getNextTaskId());
jsonObject.put("nextExecuteUser", jgTransfer.getNextExecutorIds());
jsonObject.put("taskType", BusinessTypeEnum.JG_CHANGE_REGISTRATION.getCode());
// 判断撤回后当前的节点,如果当前节点为提交节点则页面可编辑
jsonObject.put("pageType", this.getPageTypeByCurrentNode(jgTransfer.getAuditStatus()));
commonService.rollbackTask(instanceId, jsonObject);
} }
public InstanceRuntimeData buildInstanceRuntimeData(JgChangeRegistrationTransfer jgTransfer) {
return InstanceRuntimeData.builder()
.nextExecuteUserIds(jgTransfer.getNextExecuteUserIds())
.promoter(jgTransfer.getPromoter())
.nextTaskId(jgTransfer.getNextTaskId())
.build();
}
/** /**
* 批量删除 * 批量删除
...@@ -711,7 +759,6 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -711,7 +759,6 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
commonService.buildTaskModel(Collections.singletonList(taskModelDto)); commonService.buildTaskModel(Collections.singletonList(taskModelDto));
} }
} }
} else { } else {
jgChangeRegistrationTransfer.setAuditPassDate(new Date()); jgChangeRegistrationTransfer.setAuditPassDate(new Date());
jgChangeRegistrationTransfer.setAuditStatus(FlowStatusEnum.TO_BE_FINISHED.getName()); jgChangeRegistrationTransfer.setAuditStatus(FlowStatusEnum.TO_BE_FINISHED.getName());
...@@ -727,11 +774,10 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -727,11 +774,10 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
map.put("flowStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName()); map.put("flowStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName());
map.put("relationId", jgChangeRegistrationTransfer.getInstanceId()); map.put("relationId", jgChangeRegistrationTransfer.getInstanceId());
map.put("model", jgChangeRegistrationTransfer); map.put("model", jgChangeRegistrationTransfer);
TaskV2Model taskV2Model = commonService.updateTaskModel(map);
} }
// redis流程实时数据更新
commonServiceImpl.saveExecuteFlowData2Redis(instanceId, this.buildInstanceRuntimeData(jgChangeRegistrationTransfer));
this.getBaseMapper().updateById(jgChangeRegistrationTransfer); this.getBaseMapper().updateById(jgChangeRegistrationTransfer);
} }
/** /**
......
...@@ -28,6 +28,8 @@ import com.yeejoin.amos.component.feign.model.FeignClientResult; ...@@ -28,6 +28,8 @@ import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.systemctl.model.TaskV2Model; import com.yeejoin.amos.feign.systemctl.model.TaskV2Model;
import com.yeejoin.amos.feign.workflow.Workflow; import com.yeejoin.amos.feign.workflow.Workflow;
import com.yeejoin.amos.feign.workflow.model.*; import com.yeejoin.amos.feign.workflow.model.*;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -47,6 +49,7 @@ import java.io.File; ...@@ -47,6 +49,7 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -123,6 +126,8 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg ...@@ -123,6 +126,8 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg
@Autowired ICommonService commonService; @Autowired ICommonService commonService;
@Autowired
private RedissonClient redissonClient;
public static byte[] file2byte(File file) { public static byte[] file2byte(File file) {
try { try {
...@@ -713,79 +718,117 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg ...@@ -713,79 +718,117 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg
} }
public void cancel(JgChangeRegistrationUnitDto noticeDto) { public void cancel(JgChangeRegistrationUnitDto noticeDto) {
String taskCode = FlowStatusEnum.TO_BE_FINISHED.getName(); String lockKey = CommonServiceImpl.buildJgExecuteLockKey(noticeDto.getInstanceId());
String[] taskName = new String[]{"流程结束"}; RLock lock = redissonClient.getLock(lockKey);
// FeignClientResult ajaxResult = Workflow.taskV2Client.rollBack(noticeDto.getInstanceId()); try {
List<String> roleListNext = new ArrayList<>(); boolean isLocked = lock.tryLock(0, 180, TimeUnit.SECONDS);
List<String> roleListAll = new ArrayList<>(); // 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回)
ProcessTaskDTO processTaskDTO = cmWorkflowService.rollBack(noticeDto.getInstanceId()); if(!isLocked){
String nextTaskId = processTaskDTO.getNextTask().get(0).getId(); throw new BadRequest("当前流程已经被执行!");
this.buildRoleList(Collections.singletonList(processTaskDTO), roleListNext, roleListAll); }
List<WorkflowResultDto> workflowResultDtos = commonServiceImpl.buildWorkFlowInfo(Collections.singletonList(processTaskDTO)); // 撤回校验
commonServiceImpl.checkForRevocationFlow(noticeDto.getNextTaskId(), noticeDto.getInstanceId());
// 待调整
taskCode = processTaskDTO.getNextTask().get(0).getKey(); String taskCode;
JgChangeRegistrationUnit JgChangeRegistrationUnit = this.baseMapper.selectById(noticeDto.getSequenceNbr()); List<String> roleListNext = new ArrayList<>();
JgChangeRegistrationUnit.setStatus(WorkFlowStatusEnum.getMessage(taskCode).getRollBack()); List<String> roleListAll = new ArrayList<>();
JgChangeRegistrationUnit.setPromoter(""); ProcessTaskDTO processTaskDTO = cmWorkflowService.rollBack(noticeDto.getInstanceId());
JgChangeRegistrationUnit.setNextTaskId(nextTaskId); String nextTaskId = processTaskDTO.getNextTask().get(0).getId();
JgChangeRegistrationUnit.setNextExecuteUserIds(workflowResultDtos.get(0).getNextExecutorUserIds()); this.buildRoleList(Collections.singletonList(processTaskDTO), roleListNext, roleListAll);
JgChangeRegistrationUnit.setNextExecutorIds(String.join(",", roleListNext)); List<WorkflowResultDto> workflowResultDtos = commonServiceImpl.buildWorkFlowInfo(Collections.singletonList(processTaskDTO));
JgChangeRegistrationUnitMapper.updateById(JgChangeRegistrationUnit);
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(JgChangeRegistrationUnit)); // 待调整
jsonObject.put("nextTaskId", JgChangeRegistrationUnit.getNextTaskId()); taskCode = processTaskDTO.getNextTask().get(0).getKey();
jsonObject.put("nextExecuteUser", JgChangeRegistrationUnit.getNextExecutorIds()); JgChangeRegistrationUnit jgChangeRegistrationUnit = this.baseMapper.selectById(noticeDto.getSequenceNbr());
jsonObject.put("taskType", BusinessTypeEnum.JG_COMPANY_CHANGE_REGISTRATION.getCode()); jgChangeRegistrationUnit.setStatus(WorkFlowStatusEnum.getMessage(taskCode).getRollBack());
jsonObject.put("flowStatus", this.getTaskCodeByName(JgChangeRegistrationUnit.getStatus())); jgChangeRegistrationUnit.setPromoter("");
jsonObject.put("flowStatusLabel", JgChangeRegistrationUnit.getStatus()); jgChangeRegistrationUnit.setNextTaskId(nextTaskId);
jgChangeRegistrationUnit.setNextExecuteUserIds(workflowResultDtos.get(0).getNextExecutorUserIds());
commonServiceImpl.rollbackTask(noticeDto.getInstanceId(), jsonObject); jgChangeRegistrationUnit.setNextExecutorIds(String.join(",", roleListNext));
JgChangeRegistrationUnitMapper.updateById(jgChangeRegistrationUnit);
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(jgChangeRegistrationUnit));
jsonObject.put("nextTaskId", jgChangeRegistrationUnit.getNextTaskId());
jsonObject.put("nextExecuteUser", jgChangeRegistrationUnit.getNextExecutorIds());
jsonObject.put("taskType", BusinessTypeEnum.JG_COMPANY_CHANGE_REGISTRATION.getCode());
jsonObject.put("flowStatus", this.getTaskCodeByName(jgChangeRegistrationUnit.getStatus()));
jsonObject.put("flowStatusLabel", jgChangeRegistrationUnit.getStatus());
commonServiceImpl.rollbackTask(noticeDto.getInstanceId(), jsonObject);
// redis流程实时数据更新
commonServiceImpl.saveExecuteFlowData2Redis(noticeDto.getInstanceId(), this.buildInstanceRuntimeData(jgChangeRegistrationUnit));
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
if(lock.isHeldByCurrentThread()){
lock.unlock();
}
}
}
public InstanceRuntimeData buildInstanceRuntimeData(JgChangeRegistrationUnit jgChangeRegistrationUnit) {
return InstanceRuntimeData.builder()
.nextExecuteUserIds(jgChangeRegistrationUnit.getNextExecuteUserIds())
.promoter(jgChangeRegistrationUnit.getPromoter())
.nextTaskId(jgChangeRegistrationUnit.getNextTaskId())
.build();
} }
@Transactional @Transactional
public void accept(JgChangeRegistrationUnitDto dto, String op) { public void accept(JgChangeRegistrationUnitDto dto, String op) {
String[] taskName = new String[]{"已完成"}; String lockKey = CommonServiceImpl.buildJgExecuteLockKey(dto.getInstanceId());
String userId = RequestContext.getExeUserId(); RLock lock = redissonClient.getLock(lockKey);
String taskId = dto.getNextTaskId(); try {
JgChangeRegistrationUnit jgChangeRegistrationUnit = this.JgChangeRegistrationUnitMapper.selectById(dto.getSequenceNbr()); boolean isLocked = lock.tryLock(0, 180, TimeUnit.SECONDS);
jgChangeRegistrationUnit.setProcessAdvice(dto.getProcessAdvice()); // 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回)
List<String> roleListNext = new ArrayList<>(); if(!isLocked){
List<String> roleListAll = new ArrayList<>(); throw new BadRequest("当前流程已经被执行!");
ArrayList<String> roleList = new ArrayList<>(); }
// 流程执行时,状态及权限校验
commonServiceImpl.checkForExecuteFlow(dto.getNextTaskId(), dto.getInstanceId());
String[] taskName = new String[]{"已完成"};
String userId = RequestContext.getExeUserId();
String taskId = dto.getNextTaskId();
JgChangeRegistrationUnit jgChangeRegistrationUnit = this.JgChangeRegistrationUnitMapper.selectById(dto.getSequenceNbr());
jgChangeRegistrationUnit.setProcessAdvice(dto.getProcessAdvice());
List<String> roleListNext = new ArrayList<>();
List<String> roleListAll = new ArrayList<>();
ArrayList<String> roleList = new ArrayList<>();
// boolean submit = submit(jgChangeRegistrationUnit, op); // boolean submit = submit(jgChangeRegistrationUnit, op);
// if (submit) { // if (submit) {
// getNext(roleList, dto.getInstanceId(), taskName); // getNext(roleList, dto.getInstanceId(), taskName);
//组装信息 //组装信息
TaskResultDTO task = new TaskResultDTO(); TaskResultDTO task = new TaskResultDTO();
task.setResultCode("approvalStatus"); task.setResultCode("approvalStatus");
task.setTaskId(taskId); task.setTaskId(taskId);
task.setComment(StringUtils.isEmpty(dto.getProcessAdvice())?"":dto.getProcessAdvice()); task.setComment(StringUtils.isEmpty(dto.getProcessAdvice())?"":dto.getProcessAdvice());
task.setNextExecuteUserCompanyCode(this.getNextUserOrgCode(op,jgChangeRegistrationUnit)); task.setNextExecuteUserCompanyCode(this.getNextUserOrgCode(op,jgChangeRegistrationUnit));
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
map.put("approvalStatus", op); map.put("approvalStatus", op);
if (!ObjectUtils.isEmpty(jgChangeRegistrationUnit.getInstanceStatus()) && if (!ObjectUtils.isEmpty(jgChangeRegistrationUnit.getInstanceStatus()) &&
(jgChangeRegistrationUnit.getStatus().equals(WorkFlowStatusEnum.UNIT_RENAME_SUBMIT.getReject()) || (jgChangeRegistrationUnit.getStatus().equals(WorkFlowStatusEnum.UNIT_RENAME_SUBMIT.getReject()) ||
jgChangeRegistrationUnit.getStatus().equals(WorkFlowStatusEnum.UNIT_RENAME_SUBMIT.getRollBack()))) { jgChangeRegistrationUnit.getStatus().equals(WorkFlowStatusEnum.UNIT_RENAME_SUBMIT.getRollBack()))) {
map.put("approvalStatus", "提交"); map.put("approvalStatus", "提交");
} }
task.setVariable(map); task.setVariable(map);
//执行流程 //执行流程
ProcessTaskDTO processTaskDTO = cmWorkflowService.completeOrReject(taskId, task, op); ProcessTaskDTO processTaskDTO = cmWorkflowService.completeOrReject(taskId, task, op);
String taskCode = FlowStatusEnum.TO_BE_FINISHED.getName(); String taskCode = FlowStatusEnum.TO_BE_FINISHED.getName();
String taskName1 = ""; String taskName1 = "";
String nextTaskId = ""; String nextTaskId = "";
this.buildRoleList(Collections.singletonList(processTaskDTO), roleList, roleListAll); this.buildRoleList(Collections.singletonList(processTaskDTO), roleList, roleListAll);
List<WorkflowResultDto> workflowResultDtos = commonServiceImpl.buildWorkFlowInfo(Collections.singletonList(processTaskDTO)); List<WorkflowResultDto> workflowResultDtos = commonServiceImpl.buildWorkFlowInfo(Collections.singletonList(processTaskDTO));
String nextUserIds = workflowResultDtos.get(0).getNextExecutorUserIds(); String nextUserIds = workflowResultDtos.get(0).getNextExecutorUserIds();
if(processTaskDTO != null && processTaskDTO.getNextTask() != null && processTaskDTO.getNextTask().size() >0){ if(processTaskDTO != null && processTaskDTO.getNextTask() != null && processTaskDTO.getNextTask().size() >0){
taskCode = processTaskDTO.getNextTask().get(0).getKey(); taskCode = processTaskDTO.getNextTask().get(0).getKey();
taskName1 = processTaskDTO.getNextTask().get(0).getName(); taskName1 = processTaskDTO.getNextTask().get(0).getName();
nextTaskId = processTaskDTO.getNextTask().get(0).getId(); nextTaskId = processTaskDTO.getNextTask().get(0).getId();
} }
jgChangeRegistrationUnit.setStatus(taskName[0]); jgChangeRegistrationUnit.setStatus(taskName[0]);
if ("0".equals(op)) { if ("0".equals(op)) {
if (roleList.size() == 0) { if (roleList.size() == 0) {
jgChangeRegistrationUnit.setStatus(taskName[0]); jgChangeRegistrationUnit.setStatus(taskName[0]);
...@@ -857,7 +900,16 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg ...@@ -857,7 +900,16 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg
executeOneStep(jgChangeRegistrationUnit, taskName1, nextUserIds, op); executeOneStep(jgChangeRegistrationUnit, taskName1, nextUserIds, op);
} }
JgChangeRegistrationUnitMapper.updateById(jgChangeRegistrationUnit); JgChangeRegistrationUnitMapper.updateById(jgChangeRegistrationUnit);
// }
// redis流程实时数据更新
commonServiceImpl.saveExecuteFlowData2Redis(dto.getInstanceId(), this.buildInstanceRuntimeData(jgChangeRegistrationUnit));
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
if(lock.isHeldByCurrentThread()){
lock.unlock();
}
}
} }
private Integer getTaskCodeByName(String auditStatus) { private Integer getTaskCodeByName(String auditStatus) {
......
...@@ -8,9 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; ...@@ -8,9 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey; import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jg.api.dto.TaskMessageDto; import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.api.dto.TaskModelDto;
import com.yeejoin.amos.boot.module.jg.api.dto.WorkflowResultDto;
import com.yeejoin.amos.boot.module.jg.api.entity.*; import com.yeejoin.amos.boot.module.jg.api.entity.*;
import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum; import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.WorkFlowStatusEnum; import com.yeejoin.amos.boot.module.jg.api.enums.WorkFlowStatusEnum;
...@@ -18,7 +16,6 @@ import com.yeejoin.amos.boot.module.jg.api.mapper.JgEnableDisableEqMapper; ...@@ -18,7 +16,6 @@ import com.yeejoin.amos.boot.module.jg.api.mapper.JgEnableDisableEqMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgEnableDisableMapper; import com.yeejoin.amos.boot.module.jg.api.mapper.JgEnableDisableMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgMaintainNoticeMapper; import com.yeejoin.amos.boot.module.jg.api.mapper.JgMaintainNoticeMapper;
import com.yeejoin.amos.boot.module.jg.api.service.IJgEnableDisableService; import com.yeejoin.amos.boot.module.jg.api.service.IJgEnableDisableService;
import com.yeejoin.amos.boot.module.jg.api.dto.JgEnableDisableDto;
import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient; import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient;
import com.yeejoin.amos.boot.module.jg.biz.service.ICmWorkflowService; import com.yeejoin.amos.boot.module.jg.biz.service.ICmWorkflowService;
import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgRegisterInfoService; import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgRegisterInfoService;
...@@ -30,6 +27,8 @@ import com.yeejoin.amos.component.feign.model.FeignClientResult; ...@@ -30,6 +27,8 @@ import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.systemctl.model.TaskV2Model; import com.yeejoin.amos.feign.systemctl.model.TaskV2Model;
import com.yeejoin.amos.feign.workflow.Workflow; import com.yeejoin.amos.feign.workflow.Workflow;
import com.yeejoin.amos.feign.workflow.model.*; import com.yeejoin.amos.feign.workflow.model.*;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -40,9 +39,11 @@ import org.typroject.tyboot.core.foundation.context.RequestContext; ...@@ -40,9 +39,11 @@ import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit;
/** /**
* 服务实现类 * 服务实现类
...@@ -85,6 +86,9 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto, ...@@ -85,6 +86,9 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto,
@Autowired @Autowired
ICmWorkflowService iCmWorkflowService; ICmWorkflowService iCmWorkflowService;
@Autowired
private RedissonClient redissonClient;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public List<JgEnableDisable> saveOrUpdate(JSONObject map, ReginParams reginParams) { public List<JgEnableDisable> saveOrUpdate(JSONObject map, ReginParams reginParams) {
JgEnableDisable jgEnableDisable = new JgEnableDisable(); JgEnableDisable jgEnableDisable = new JgEnableDisable();
...@@ -389,46 +393,84 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto, ...@@ -389,46 +393,84 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto,
@Autowired @Autowired
RegistrationInfoMapper tzsJgRegistrationInfoMapper; RegistrationInfoMapper tzsJgRegistrationInfoMapper;
public void flowExecute(Long id, String instanceId, String operate, String comment) { public void flowExecute(Long id, String instanceId, String operate, String comment, String nextTaskId) {
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class); String lockKey = CommonServiceImpl.buildJgExecuteLockKey(instanceId);
JgEnableDisable jgEnableDisable = this.baseMapper.selectById(id); RLock lock = redissonClient.getLock(lockKey);
try {
boolean isLocked = lock.tryLock(0, 180, TimeUnit.SECONDS);
// 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回)
if(!isLocked){
throw new BadRequest("当前流程已经被执行!");
}
// 流程执行时,状态及权限校验
commonService.checkForExecuteFlow(nextTaskId, instanceId);
// 执行工作流并返回组装好的工作流信息 ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
WorkflowResultDto workflowResultDto = getWorkflowResultDto(operate, comment, jgEnableDisable); JgEnableDisable jgEnableDisable = this.baseMapper.selectById(id);
jgEnableDisable.setPromoter(reginParams.getUserModel().getUserId()); // 执行工作流并返回组装好的工作流信息
TaskV2Model taskV2Model = new TaskV2Model(); WorkflowResultDto workflowResultDto = getWorkflowResultDto(operate, comment, jgEnableDisable);
if ("0".equals(operate)) {
if (StringUtils.isEmpty(workflowResultDto.getNextExecutorRoleIds())) { jgEnableDisable.setPromoter(reginParams.getUserModel().getUserId());
jgEnableDisable.setPromoter(""); TaskV2Model taskV2Model = new TaskV2Model();
jgEnableDisable.setAuditPassDate(new Date()); if ("0".equals(operate)) {
jgEnableDisable.setAuditStatus(String.valueOf(FlowStatusEnum.TO_BE_FINISHED.getName())); if (StringUtils.isEmpty(workflowResultDto.getNextExecutorRoleIds())) {
// 上个代办改为已办 jgEnableDisable.setPromoter("");
HashMap<String, Object> taskMap = new HashMap<>(); jgEnableDisable.setAuditPassDate(new Date());
taskMap.put("taskStatus", FlowStatusEnum.TO_BE_FINISHED.getCode()); jgEnableDisable.setAuditStatus(String.valueOf(FlowStatusEnum.TO_BE_FINISHED.getName()));
taskMap.put("taskStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName()); // 上个代办改为已办
taskMap.put("relationId", jgEnableDisable.getInstanceId()); HashMap<String, Object> taskMap = new HashMap<>();
taskMap.put("flowStatus", FlowStatusEnum.TO_BE_FINISHED.getCode()); taskMap.put("taskStatus", FlowStatusEnum.TO_BE_FINISHED.getCode());
taskMap.put("flowStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName()); taskMap.put("taskStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName());
TaskMessageDto taskMessageDto = new TaskMessageDto(); taskMap.put("relationId", jgEnableDisable.getInstanceId());
BeanUtils.copyProperties(jgEnableDisable, taskMessageDto); taskMap.put("flowStatus", FlowStatusEnum.TO_BE_FINISHED.getCode());
taskMap.put("model", jgEnableDisable); taskMap.put("flowStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName());
commonService.updateTaskModel(taskMap); TaskMessageDto taskMessageDto = new TaskMessageDto();
} else { BeanUtils.copyProperties(jgEnableDisable, taskMessageDto);
jgEnableDisable.setNextExecutorIds(workflowResultDto.getNextExecutorRoleIds()); taskMap.put("model", jgEnableDisable);
if (!ObjectUtils.isEmpty(jgEnableDisable.getExecuteSequence())) { commonService.updateTaskModel(taskMap);
jgEnableDisable.setExecuteSequence(jgEnableDisable.getExecuteSequence() + "," + workflowResultDto.getNextExecutorRoleIds());
} else { } else {
jgEnableDisable.setExecuteSequence(workflowResultDto.getNextExecutorRoleIds()); jgEnableDisable.setNextExecutorIds(workflowResultDto.getNextExecutorRoleIds());
if (!ObjectUtils.isEmpty(jgEnableDisable.getExecuteSequence())) {
jgEnableDisable.setExecuteSequence(jgEnableDisable.getExecuteSequence() + "," + workflowResultDto.getNextExecutorRoleIds());
} else {
jgEnableDisable.setExecuteSequence(workflowResultDto.getNextExecutorRoleIds());
}
jgEnableDisable.setAuditStatus(String.valueOf(FlowStatusEnum.TO_BE_PROCESSED.getName()));
// 上个代办改为已办
HashMap<String, Object> taskMap = new HashMap<>();
taskMap.put("taskStatus", FlowStatusEnum.TO_BE_PROCESSED.getCode());
taskMap.put("taskStatusLabel", FlowStatusEnum.TO_BE_PROCESSED.getName());
taskMap.put("flowStatus", FlowStatusEnum.TO_BE_PROCESSED.getCode());
taskMap.put("flowStatusLabel", FlowStatusEnum.TO_BE_PROCESSED.getName());
taskMap.put("relationId", jgEnableDisable.getInstanceId());
taskV2Model = commonService.updateTaskModel(taskMap);
TaskModelDto taskModelDto = new TaskModelDto();
BeanUtils.copyProperties(taskV2Model, taskModelDto);
// 创建新的代办
TaskMessageDto taskMessageDto = new TaskMessageDto();
BeanUtils.copyProperties(jgEnableDisable, taskMessageDto);
taskModelDto.setModel(taskMessageDto);
taskModelDto.setTaskName(workflowResultDto.getNextTaskName());
taskModelDto.setExecuteUserIds(workflowResultDto.getNextExecutorUserIds());
taskModelDto.setFlowStatus(FlowStatusEnum.TO_BE_PROCESSED.getCode());
taskModelDto.setFlowStatusLabel(FlowStatusEnum.TO_BE_PROCESSED.getName());
taskModelDto.setFlowCode(workflowResultDto.getNextTaskId());
taskModelDto.setTaskStatusLabel(FlowStatusEnum.TO_BE_PROCESSED.getName());
taskModelDto.setNextExecuteUser(workflowResultDto.getNextExecutorRoleIds());
commonService.buildTaskModel(Collections.singletonList(taskModelDto));
} }
jgEnableDisable.setAuditStatus(String.valueOf(FlowStatusEnum.TO_BE_PROCESSED.getName())); } else {
jgEnableDisable.setPromoter("");
jgEnableDisable.setAuditStatus(String.valueOf(FlowStatusEnum.REJECTED.getName()));
jgEnableDisable.setNextExecutorIds(workflowResultDto.getNextExecutorRoleIds());
// 上个代办改为已办 // 上个代办改为已办
HashMap<String, Object> taskMap = new HashMap<>(); HashMap<String, Object> taskMap = new HashMap<>();
taskMap.put("taskStatus", FlowStatusEnum.TO_BE_PROCESSED.getCode()); taskMap.put("taskStatus", FlowStatusEnum.REJECTED.getCode());
taskMap.put("taskStatusLabel", FlowStatusEnum.TO_BE_PROCESSED.getName()); taskMap.put("taskStatusLabel", FlowStatusEnum.REJECTED.getName());
taskMap.put("flowStatus", FlowStatusEnum.TO_BE_PROCESSED.getCode());
taskMap.put("flowStatusLabel", FlowStatusEnum.TO_BE_PROCESSED.getName());
taskMap.put("relationId", jgEnableDisable.getInstanceId()); taskMap.put("relationId", jgEnableDisable.getInstanceId());
taskMap.put("flowStatus", FlowStatusEnum.REJECTED.getCode());
taskMap.put("flowStatusLabel", FlowStatusEnum.REJECTED.getName());
taskV2Model = commonService.updateTaskModel(taskMap); taskV2Model = commonService.updateTaskModel(taskMap);
TaskModelDto taskModelDto = new TaskModelDto(); TaskModelDto taskModelDto = new TaskModelDto();
BeanUtils.copyProperties(taskV2Model, taskModelDto); BeanUtils.copyProperties(taskV2Model, taskModelDto);
...@@ -438,44 +480,26 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto, ...@@ -438,44 +480,26 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto,
taskModelDto.setModel(taskMessageDto); taskModelDto.setModel(taskMessageDto);
taskModelDto.setTaskName(workflowResultDto.getNextTaskName()); taskModelDto.setTaskName(workflowResultDto.getNextTaskName());
taskModelDto.setExecuteUserIds(workflowResultDto.getNextExecutorUserIds()); taskModelDto.setExecuteUserIds(workflowResultDto.getNextExecutorUserIds());
taskModelDto.setFlowStatus(FlowStatusEnum.TO_BE_PROCESSED.getCode()); taskModelDto.setFlowStatus(FlowStatusEnum.REJECTED.getCode());
taskModelDto.setFlowStatusLabel(FlowStatusEnum.TO_BE_PROCESSED.getName()); taskModelDto.setFlowStatusLabel(FlowStatusEnum.REJECTED.getName());
taskModelDto.setFlowCode(workflowResultDto.getNextTaskId()); taskModelDto.setFlowCode(workflowResultDto.getNextTaskId());
taskModelDto.setTaskStatusLabel(FlowStatusEnum.TO_BE_PROCESSED.getName());
taskModelDto.setNextExecuteUser(workflowResultDto.getNextExecutorRoleIds()); taskModelDto.setNextExecuteUser(workflowResultDto.getNextExecutorRoleIds());
taskModelDto.setPageType("edit");
commonService.buildTaskModel(Collections.singletonList(taskModelDto)); commonService.buildTaskModel(Collections.singletonList(taskModelDto));
} }
} else { jgEnableDisable.setNextExecuteUserIds(workflowResultDto.getNextExecutorUserIds());
jgEnableDisable.setPromoter(""); jgEnableDisable.setNextTaskId(workflowResultDto.getNextTaskId());
jgEnableDisable.setAuditStatus(String.valueOf(FlowStatusEnum.REJECTED.getName())); this.baseMapper.updateById(jgEnableDisable);
jgEnableDisable.setNextExecutorIds(workflowResultDto.getNextExecutorRoleIds());
// 上个代办改为已办
HashMap<String, Object> taskMap = new HashMap<>();
taskMap.put("taskStatus", FlowStatusEnum.REJECTED.getCode());
taskMap.put("taskStatusLabel", FlowStatusEnum.REJECTED.getName());
taskMap.put("relationId", jgEnableDisable.getInstanceId());
taskMap.put("flowStatus", FlowStatusEnum.REJECTED.getCode());
taskMap.put("flowStatusLabel", FlowStatusEnum.REJECTED.getName());
taskV2Model = commonService.updateTaskModel(taskMap);
TaskModelDto taskModelDto = new TaskModelDto();
BeanUtils.copyProperties(taskV2Model, taskModelDto);
// 创建新的代办
TaskMessageDto taskMessageDto = new TaskMessageDto();
BeanUtils.copyProperties(jgEnableDisable, taskMessageDto);
taskModelDto.setModel(taskMessageDto);
taskModelDto.setTaskName(workflowResultDto.getNextTaskName());
taskModelDto.setExecuteUserIds(workflowResultDto.getNextExecutorUserIds());
taskModelDto.setFlowStatus(FlowStatusEnum.REJECTED.getCode());
taskModelDto.setFlowStatusLabel(FlowStatusEnum.REJECTED.getName());
taskModelDto.setFlowCode(workflowResultDto.getNextTaskId());
taskModelDto.setNextExecuteUser(workflowResultDto.getNextExecutorRoleIds());
taskModelDto.setPageType("edit");
commonService.buildTaskModel(Collections.singletonList(taskModelDto));
}
jgEnableDisable.setNextExecuteUserIds(workflowResultDto.getNextExecutorUserIds());
jgEnableDisable.setNextTaskId(workflowResultDto.getNextTaskId());
this.baseMapper.updateById(jgEnableDisable);
// redis流程实时数据更新
commonService.saveExecuteFlowData2Redis(instanceId, this.buildInstanceRuntimeData(jgEnableDisable));
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
if(lock.isHeldByCurrentThread()){
lock.unlock();
}
}
} }
...@@ -508,27 +532,55 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto, ...@@ -508,27 +532,55 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto,
} }
public void withdraw(String instanceId) { public void withdraw(String instanceId, String nextTaskId) {
JgEnableDisable jgEnableDisable = this.baseMapper.selectOne(new QueryWrapper<JgEnableDisable>().lambda().eq(JgEnableDisable::getInstanceId, instanceId)); String lockKey = CommonServiceImpl.buildJgExecuteLockKey(instanceId);
ProcessTaskDTO processTaskDTO = iCmWorkflowService.rollBack(instanceId); RLock lock = redissonClient.getLock(lockKey);
// 提取节点等信息 try {
WorkflowResultDto workflowResultDto = commonService.buildWorkFlowInfo(Collections.singletonList(processTaskDTO)).get(0); boolean isLocked = lock.tryLock(0, 180, TimeUnit.SECONDS);
jgEnableDisable.setPromoter(""); // 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回)
jgEnableDisable.setExecuteSequence(workflowResultDto.getNextExecutorRoleIds()); if(!isLocked){
jgEnableDisable.setAuditStatus(String.valueOf(FlowStatusEnum.ROLLBACK.getName())); throw new BadRequest("当前流程已经被执行!");
jgEnableDisable.setNextTaskId(workflowResultDto.getNextTaskId()); }
jgEnableDisable.setNextExecuteUserIds(workflowResultDto.getNextExecutorUserIds()); // 流程执行时,状态及权限校验
updateById(jgEnableDisable); commonService.checkForRevocationFlow(nextTaskId, instanceId);
// 删除待办 JgEnableDisable jgEnableDisable = this.baseMapper.selectOne(new QueryWrapper<JgEnableDisable>().lambda().eq(JgEnableDisable::getInstanceId, instanceId));
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(jgEnableDisable)); ProcessTaskDTO processTaskDTO = iCmWorkflowService.rollBack(instanceId);
jsonObject.put("nextExecuteUser", jgEnableDisable.getNextExecutorIds()); // 提取节点等信息
jsonObject.put("taskType", BusinessTypeEnum.JG_MAINTENANCE_NOTIFICATION.getCode()); WorkflowResultDto workflowResultDto = commonService.buildWorkFlowInfo(Collections.singletonList(processTaskDTO)).get(0);
jsonObject.put("flowStatusLabel", FlowStatusEnum.ROLLBACK.getName()); jgEnableDisable.setPromoter("");
jsonObject.put("flowStatus", FlowStatusEnum.ROLLBACK.getCode()); jgEnableDisable.setExecuteSequence(workflowResultDto.getNextExecutorRoleIds());
commonService.rollbackTask(jgEnableDisable.getInstanceId(), jsonObject); jgEnableDisable.setAuditStatus(String.valueOf(FlowStatusEnum.ROLLBACK.getName()));
jgEnableDisable.setNextTaskId(workflowResultDto.getNextTaskId());
jgEnableDisable.setNextExecuteUserIds(workflowResultDto.getNextExecutorUserIds());
updateById(jgEnableDisable);
// 删除待办
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(jgEnableDisable));
jsonObject.put("nextExecuteUser", jgEnableDisable.getNextExecutorIds());
jsonObject.put("taskType", BusinessTypeEnum.JG_MAINTENANCE_NOTIFICATION.getCode());
jsonObject.put("flowStatusLabel", FlowStatusEnum.ROLLBACK.getName());
jsonObject.put("flowStatus", FlowStatusEnum.ROLLBACK.getCode());
commonService.rollbackTask(jgEnableDisable.getInstanceId(), jsonObject);
// redis流程实时数据更新
commonService.saveExecuteFlowData2Redis(instanceId, this.buildInstanceRuntimeData(jgEnableDisable));
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
if(lock.isHeldByCurrentThread()){
lock.unlock();
}
}
} }
public InstanceRuntimeData buildInstanceRuntimeData(JgEnableDisable jgEnableDisable) {
return InstanceRuntimeData.builder()
.nextExecuteUserIds(jgEnableDisable.getNextExecuteUserIds())
.promoter(jgEnableDisable.getPromoter())
.nextTaskId(jgEnableDisable.getNextTaskId())
.build();
}
public void updateExecuteIds(String instanceId, Long sequenceNbr, String operate) { public void updateExecuteIds(String instanceId, Long sequenceNbr, String operate) {
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class); ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
......
...@@ -9,10 +9,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -9,10 +9,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo; import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jg.api.dto.JgMaintenanceContractDto; import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.api.dto.TaskMessageDto;
import com.yeejoin.amos.boot.module.jg.api.dto.TaskModelDto;
import com.yeejoin.amos.boot.module.jg.api.dto.WorkflowResultDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgMaintenanceContract; import com.yeejoin.amos.boot.module.jg.api.entity.JgMaintenanceContract;
import com.yeejoin.amos.boot.module.jg.api.entity.JgMaintenanceContractEq; import com.yeejoin.amos.boot.module.jg.api.entity.JgMaintenanceContractEq;
import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum; import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum;
...@@ -33,6 +30,8 @@ import com.yeejoin.amos.feign.workflow.model.ActWorkflowStartDTO; ...@@ -33,6 +30,8 @@ import com.yeejoin.amos.feign.workflow.model.ActWorkflowStartDTO;
import com.yeejoin.amos.feign.workflow.model.ProcessTaskDTO; import com.yeejoin.amos.feign.workflow.model.ProcessTaskDTO;
import com.yeejoin.amos.feign.workflow.model.TaskResultDTO; import com.yeejoin.amos.feign.workflow.model.TaskResultDTO;
import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.client.RestHighLevelClient;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
...@@ -47,6 +46,7 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest; ...@@ -47,6 +46,7 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -83,6 +83,9 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC ...@@ -83,6 +83,9 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC
@Autowired @Autowired
private IdxBizJgMaintenanceRecordInfoServiceImpl idxBizJgMaintenanceRecordInfoService; private IdxBizJgMaintenanceRecordInfoServiceImpl idxBizJgMaintenanceRecordInfoService;
@Autowired
private RedissonClient redissonClient;
/** /**
* 分页查询 * 分页查询
*/ */
...@@ -162,25 +165,51 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC ...@@ -162,25 +165,51 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC
return maintenanceContractMapper.updateBySequenceNbr(dto); return maintenanceContractMapper.updateBySequenceNbr(dto);
} }
public void flowExecute(Long id, String instanceId, String operate, String comment, Boolean update) { public void flowExecute(Long id, String instanceId, String operate, String comment, Boolean update, String nextTaskId) {
JgMaintenanceContract contract = this.getBaseMapper().selectById(id); String lockKey = CommonServiceImpl.buildJgExecuteLockKey(instanceId);
String taskId = contract.getNextTaskId(); RLock lock = redissonClient.getLock(lockKey);
// 组装信息 try {
TaskResultDTO dto = new TaskResultDTO(); boolean isLocked = lock.tryLock(0, 180, TimeUnit.SECONDS);
dto.setResultCode("approvalStatus"); // 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回)
dto.setTaskId(taskId); if(!isLocked){
dto.setComment(comment); throw new BadRequest("当前流程已经被执行!");
HashMap<String, Object> map = new HashMap<>(); }
map.put("approvalStatus", operate); // 流程执行时,状态及权限校验
if (WorkFlowStatusEnum.MAIN_SUBMIT.getReject().equals(contract.getStatus()) || WorkFlowStatusEnum.MAIN_SUBMIT.getRollBack().equals(contract.getStatus())) { commonService.checkForExecuteFlow(nextTaskId, instanceId);
map.put("approvalStatus", "提交");
JgMaintenanceContract contract = this.getBaseMapper().selectById(id);
String taskId = contract.getNextTaskId();
// 组装信息
TaskResultDTO dto = new TaskResultDTO();
dto.setResultCode("approvalStatus");
dto.setTaskId(taskId);
dto.setComment(comment);
HashMap<String, Object> map = new HashMap<>();
map.put("approvalStatus", operate);
if (WorkFlowStatusEnum.MAIN_SUBMIT.getReject().equals(contract.getStatus()) || WorkFlowStatusEnum.MAIN_SUBMIT.getRollBack().equals(contract.getStatus())) {
map.put("approvalStatus", "提交");
}
dto.setVariable(map);
// 下一节点执行人单位(下节点接收机构code)
dto.setNextExecuteUserCompanyCode(getNextUserOrgCode(operate, contract));
ProcessTaskDTO complete = workflowService.completeOrReject(taskId, dto, operate);
// 更新下一步执行人、创建待办
updateExecuteIds(instanceId, id, operate, complete);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
if(lock.isHeldByCurrentThread()){
lock.unlock();
}
} }
dto.setVariable(map); }
// 下一节点执行人单位(下节点接收机构code)
dto.setNextExecuteUserCompanyCode(getNextUserOrgCode(operate, contract)); public InstanceRuntimeData buildInstanceRuntimeData(JgMaintenanceContract jgMaintenanceContract) {
ProcessTaskDTO complete = workflowService.completeOrReject(taskId, dto, operate); return InstanceRuntimeData.builder()
// 更新下一步执行人、创建待办 .nextExecuteUserIds(jgMaintenanceContract.getNextExecuteUserIds())
updateExecuteIds(instanceId, id, operate, complete); .promoter(jgMaintenanceContract.getPromoter())
.nextTaskId(jgMaintenanceContract.getNextTaskId())
.build();
} }
public String getNextUserOrgCode(String operate, JgMaintenanceContract contract) { public String getNextUserOrgCode(String operate, JgMaintenanceContract contract) {
...@@ -258,37 +287,58 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC ...@@ -258,37 +287,58 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC
* 维保合同撤回 * 维保合同撤回
*/ */
@Transactional @Transactional
public void revocation(String instanceId) { public void revocation(String instanceId, String _nextTaskId) {
LambdaQueryWrapper<JgMaintenanceContract> lambda = new QueryWrapper<JgMaintenanceContract>().lambda(); String lockKey = CommonServiceImpl.buildJgExecuteLockKey(instanceId);
lambda.eq(JgMaintenanceContract::getInstanceId, instanceId); RLock lock = redissonClient.getLock(lockKey);
List<String> roleListNext = new ArrayList<>(); try {
List<String> roleListAll = new ArrayList<>(); boolean isLocked = lock.tryLock(0, 180, TimeUnit.SECONDS);
JgMaintenanceContract contract = this.getOne(lambda); // 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回)
ProcessTaskDTO processTaskDTO = workflowService.rollBack(instanceId); if(!isLocked){
String nextTaskId = processTaskDTO.getNextTask().get(0).getId(); throw new BadRequest("当前流程已经被执行!");
this.buildRoleList(Collections.singletonList(processTaskDTO), roleListNext, roleListAll); }
// 待调整 // 流程执行时,状态及权限校验
String taskCode = processTaskDTO.getNextTask().get(0).getKey(); commonService.checkForRevocationFlow(_nextTaskId, instanceId);
if (!FlowStatusEnum.TO_BE_FINISHED.getName().equals(taskCode)) {
contract.setStatus(WorkFlowStatusEnum.getMessage(taskCode).getRollBack()); LambdaQueryWrapper<JgMaintenanceContract> lambda = new QueryWrapper<JgMaintenanceContract>().lambda();
lambda.eq(JgMaintenanceContract::getInstanceId, instanceId);
List<String> roleListNext = new ArrayList<>();
List<String> roleListAll = new ArrayList<>();
JgMaintenanceContract contract = this.getOne(lambda);
ProcessTaskDTO processTaskDTO = workflowService.rollBack(instanceId);
String nextTaskId = processTaskDTO.getNextTask().get(0).getId();
this.buildRoleList(Collections.singletonList(processTaskDTO), roleListNext, roleListAll);
// 待调整
String taskCode = processTaskDTO.getNextTask().get(0).getKey();
if (!FlowStatusEnum.TO_BE_FINISHED.getName().equals(taskCode)) {
contract.setStatus(WorkFlowStatusEnum.getMessage(taskCode).getRollBack());
}
contract.setPromoter(RequestContext.getExeUserId());
contract.setNextExecuteIds(String.join(",", roleListNext));
contract.setNextTaskId(nextTaskId);
List<WorkflowResultDto> workflowResultDtos = commonService.buildWorkFlowInfo(Collections.singletonList(processTaskDTO));
// 更新下一步可执行人
String nextUserIds = workflowResultDtos.get(0).getNextExecutorUserIds();
contract.setNextExecuteUserIds(nextUserIds);
this.updateById(contract);
// 删除待办
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(contract));
jsonObject.put("nextTaskId", contract.getNextTaskId());
jsonObject.put("nextExecuteUser", contract.getNextExecuteIds());
jsonObject.put("taskType", BusinessTypeEnum.JG_MAINTENANCE_RECORD.getCode());
jsonObject.put("flowStatus", this.getTaskCodeByName(contract.getStatus()));
jsonObject.put("flowStatusLabel", contract.getStatus());
jsonObject.put("maintenanceContract", null);// 不传合同照片附件信息
commonService.rollbackTask(instanceId, jsonObject);
// redis流程实时数据更新
commonService.saveExecuteFlowData2Redis(instanceId, this.buildInstanceRuntimeData(contract));
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
if(lock.isHeldByCurrentThread()){
lock.unlock();
}
} }
contract.setPromoter(RequestContext.getExeUserId());
contract.setNextExecuteIds(String.join(",", roleListNext));
contract.setNextTaskId(nextTaskId);
List<WorkflowResultDto> workflowResultDtos = commonService.buildWorkFlowInfo(Collections.singletonList(processTaskDTO));
// 更新下一步可执行人
String nextUserIds = workflowResultDtos.get(0).getNextExecutorUserIds();
contract.setNextExecuteUserIds(nextUserIds);
this.updateById(contract);
// 删除待办
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(contract));
jsonObject.put("nextTaskId", contract.getNextTaskId());
jsonObject.put("nextExecuteUser", contract.getNextExecuteIds());
jsonObject.put("taskType", BusinessTypeEnum.JG_MAINTENANCE_RECORD.getCode());
jsonObject.put("flowStatus", this.getTaskCodeByName(contract.getStatus()));
jsonObject.put("flowStatusLabel", contract.getStatus());
jsonObject.put("maintenanceContract", null);// 不传合同照片附件信息
commonService.rollbackTask(instanceId, jsonObject);
} }
/** /**
...@@ -505,6 +555,9 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC ...@@ -505,6 +555,9 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC
updateEquipMessage(contract.getSequenceNbr()); updateEquipMessage(contract.getSequenceNbr());
} }
this.getBaseMapper().updateById(contract); this.getBaseMapper().updateById(contract);
// redis流程实时数据更新
commonService.saveExecuteFlowData2Redis(instanceId, this.buildInstanceRuntimeData(contract));
} }
/** /**
......
...@@ -10,10 +10,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -10,10 +10,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey; import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jg.api.dto.JgScrapCancelDto; import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.api.dto.TaskMessageDto;
import com.yeejoin.amos.boot.module.jg.api.dto.TaskModelDto;
import com.yeejoin.amos.boot.module.jg.api.dto.WorkflowResultDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgScrapCancel; import com.yeejoin.amos.boot.module.jg.api.entity.JgScrapCancel;
import com.yeejoin.amos.boot.module.jg.api.entity.JgScrapCancelEq; import com.yeejoin.amos.boot.module.jg.api.entity.JgScrapCancelEq;
import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum; import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum;
...@@ -39,6 +36,8 @@ import com.yeejoin.amos.feign.workflow.model.ActWorkflowBatchDTO; ...@@ -39,6 +36,8 @@ import com.yeejoin.amos.feign.workflow.model.ActWorkflowBatchDTO;
import com.yeejoin.amos.feign.workflow.model.ActWorkflowStartDTO; import com.yeejoin.amos.feign.workflow.model.ActWorkflowStartDTO;
import com.yeejoin.amos.feign.workflow.model.ProcessTaskDTO; import com.yeejoin.amos.feign.workflow.model.ProcessTaskDTO;
import com.yeejoin.amos.feign.workflow.model.TaskResultDTO; import com.yeejoin.amos.feign.workflow.model.TaskResultDTO;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
...@@ -50,9 +49,11 @@ import org.springframework.util.StringUtils; ...@@ -50,9 +49,11 @@ import org.springframework.util.StringUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
...@@ -96,6 +97,9 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc ...@@ -96,6 +97,9 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
@Autowired @Autowired
private IdxBizJgUseInfoMapper idxBizJgUseInfoMapper; private IdxBizJgUseInfoMapper idxBizJgUseInfoMapper;
@Autowired
private RedissonClient redissonClient;
/** /**
* 移装移装注销/报废注销判断 * 移装移装注销/报废注销判断
* *
...@@ -555,35 +559,56 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc ...@@ -555,35 +559,56 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
@Transactional @Transactional
public void revocation(String instanceId) { public void revocation(String instanceId, String nextTaskId) {
ReginParams reginParams = this.getSelectedOrgInfo(); String lockKey = CommonServiceImpl.buildJgExecuteLockKey(instanceId);
LambdaQueryWrapper<JgScrapCancel> lambda = new QueryWrapper<JgScrapCancel>().lambda(); RLock lock = redissonClient.getLock(lockKey);
lambda.eq(JgScrapCancel::getInstanceId, instanceId); try {
JgScrapCancel jgScrapCancel = this.baseMapper.selectOne(lambda); boolean isLocked = lock.tryLock(0, 180, TimeUnit.SECONDS);
ProcessTaskDTO processTaskDTO = cmWorkflowService.rollBack(instanceId); // 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回)
WorkflowResultDto workflowResultDto = commonService.buildWorkFlowInfo(Collections.singletonList(processTaskDTO)).get(0); if(!isLocked){
if (!FlowStatusEnum.TO_BE_FINISHED.getName().equals(workflowResultDto.getNextTaskName())) { throw new BadRequest("当前流程已经被执行!");
jgScrapCancel.setAuditStatus(Objects.requireNonNull(WorkFlowStatusEnum.getMessage(workflowResultDto.getNextTaskCode())).getRollBack()); }
// 流程执行时,状态及权限校验
commonService.checkForRevocationFlow(nextTaskId, instanceId);
ReginParams reginParams = this.getSelectedOrgInfo();
LambdaQueryWrapper<JgScrapCancel> lambda = new QueryWrapper<JgScrapCancel>().lambda();
lambda.eq(JgScrapCancel::getInstanceId, instanceId);
JgScrapCancel jgScrapCancel = this.baseMapper.selectOne(lambda);
ProcessTaskDTO processTaskDTO = cmWorkflowService.rollBack(instanceId);
WorkflowResultDto workflowResultDto = commonService.buildWorkFlowInfo(Collections.singletonList(processTaskDTO)).get(0);
if (!FlowStatusEnum.TO_BE_FINISHED.getName().equals(workflowResultDto.getNextTaskName())) {
jgScrapCancel.setAuditStatus(Objects.requireNonNull(WorkFlowStatusEnum.getMessage(workflowResultDto.getNextTaskCode())).getRollBack());
}
jgScrapCancel.setNextTaskId(workflowResultDto.getNextTaskId());
List<WorkflowResultDto> workflowResultDtos = commonService.buildWorkFlowInfo(Collections.singletonList(processTaskDTO));
// 更新下一步可执行人
String nextUserIds = workflowResultDtos.get(0).getNextExecutorUserIds();
jgScrapCancel.setNextExecuteUserIds(nextUserIds);
jgScrapCancel.setPromoter(reginParams.getUserModel().getUserId());
jgScrapCancel.setNextExecuteIds(workflowResultDto.getNextExecutorRoleIds());
this.updateById(jgScrapCancel);
// 删除待办
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(jgScrapCancel));
jsonObject.put("nextTaskId", jgScrapCancel.getNextTaskId());
jsonObject.put("nextExecuteUser", jgScrapCancel.getNextExecuteIds());
jsonObject.put("taskType", businessTypeJudgment(jgScrapCancel.getCancelType()).getCode());
jsonObject.put("flowStatus", this.getTaskCodeByName(jgScrapCancel.getAuditStatus()));
jsonObject.put("flowStatusLabel", jgScrapCancel.getAuditStatus());
// 判断撤回后当前的节点,如果当前节点为提交节点则页面可编辑
jsonObject.put("pageType", this.getPageTypeByCurrentNode(jgScrapCancel.getAuditStatus()));
commonService.rollbackTask(instanceId, jsonObject);
// redis流程实时数据更新
commonService.saveExecuteFlowData2Redis(instanceId, this.buildInstanceRuntimeData(jgScrapCancel));
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
if(lock.isHeldByCurrentThread()){
lock.unlock();
}
} }
jgScrapCancel.setNextTaskId(workflowResultDto.getNextTaskId());
List<WorkflowResultDto> workflowResultDtos = commonService.buildWorkFlowInfo(Collections.singletonList(processTaskDTO));
// 更新下一步可执行人
String nextUserIds = workflowResultDtos.get(0).getNextExecutorUserIds();
jgScrapCancel.setNextExecuteUserIds(nextUserIds);
jgScrapCancel.setPromoter(reginParams.getUserModel().getUserId());
jgScrapCancel.setNextExecuteIds(workflowResultDto.getNextExecutorRoleIds());
this.updateById(jgScrapCancel);
// 删除待办
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(jgScrapCancel));
jsonObject.put("nextTaskId", jgScrapCancel.getNextTaskId());
jsonObject.put("nextExecuteUser", jgScrapCancel.getNextExecuteIds());
jsonObject.put("taskType", businessTypeJudgment(jgScrapCancel.getCancelType()).getCode());
jsonObject.put("flowStatus", this.getTaskCodeByName(jgScrapCancel.getAuditStatus()));
jsonObject.put("flowStatusLabel", jgScrapCancel.getAuditStatus());
// 判断撤回后当前的节点,如果当前节点为提交节点则页面可编辑
jsonObject.put("pageType", this.getPageTypeByCurrentNode(jgScrapCancel.getAuditStatus()));
commonService.rollbackTask(instanceId, jsonObject);
} }
private Integer getTaskCodeByName(String auditStatus) { private Integer getTaskCodeByName(String auditStatus) {
...@@ -599,28 +624,56 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc ...@@ -599,28 +624,56 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
} }
@Transactional @Transactional
public void flowExecute(String equList, Long id, String instanceId, String operate, String comment) { public void flowExecute(String equList, Long id, String instanceId, String operate, String comment, String nextTaskId) {
JgScrapCancel jgScrapCancel = this.getBaseMapper().selectById(id); String lockKey = CommonServiceImpl.buildJgExecuteLockKey(instanceId);
String taskId = jgScrapCancel.getNextTaskId(); RLock lock = redissonClient.getLock(lockKey);
// 组装信息 try {
TaskResultDTO dto = new TaskResultDTO(); boolean isLocked = lock.tryLock(0, 180, TimeUnit.SECONDS);
dto.setResultCode("approvalStatus"); // 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回)
dto.setTaskId(taskId); if(!isLocked){
dto.setComment(comment); throw new BadRequest("当前流程已经被执行!");
HashMap<String, Object> map = new HashMap<>(); }
map.put("approvalStatus", operate); // 流程执行时,状态及权限校验
if (!ObjectUtils.isEmpty(jgScrapCancel.getInstanceStatus()) && (jgScrapCancel.getInstanceStatus().equals(WorkFlowStatusEnum.CANCEL_SUBMIT.getReject()) || jgScrapCancel.getInstanceStatus().equals(WorkFlowStatusEnum.CANCEL_SUBMIT.getRollBack()))) { commonService.checkForExecuteFlow(nextTaskId, instanceId);
map.put("approvalStatus", "提交");
JgScrapCancel jgScrapCancel = this.getBaseMapper().selectById(id);
String taskId = jgScrapCancel.getNextTaskId();
// 组装信息
TaskResultDTO dto = new TaskResultDTO();
dto.setResultCode("approvalStatus");
dto.setTaskId(taskId);
dto.setComment(comment);
HashMap<String, Object> map = new HashMap<>();
map.put("approvalStatus", operate);
if (!ObjectUtils.isEmpty(jgScrapCancel.getInstanceStatus()) && (jgScrapCancel.getInstanceStatus().equals(WorkFlowStatusEnum.CANCEL_SUBMIT.getReject()) || jgScrapCancel.getInstanceStatus().equals(WorkFlowStatusEnum.CANCEL_SUBMIT.getRollBack()))) {
map.put("approvalStatus", "提交");
}
dto.setVariable(map);
// 下一节点执行人单位(下节点接收机构code)
dto.setNextExecuteUserCompanyCode(this.getNextUserOrgCode(operate, jgScrapCancel));
// 执行流程
ProcessTaskDTO processTaskDTO = cmWorkflowService.completeOrReject(taskId, dto, operate);
// 更新下一步执行人、创建待办
updateExecuteIds(equList, instanceId, id, operate, processTaskDTO);
// redis流程实时数据更新
commonService.saveExecuteFlowData2Redis(instanceId, this.buildInstanceRuntimeData(jgScrapCancel));
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
if(lock.isHeldByCurrentThread()){
lock.unlock();
}
} }
dto.setVariable(map);
// 下一节点执行人单位(下节点接收机构code)
dto.setNextExecuteUserCompanyCode(this.getNextUserOrgCode(operate, jgScrapCancel));
// 执行流程
ProcessTaskDTO processTaskDTO = cmWorkflowService.completeOrReject(taskId, dto, operate);
// 更新下一步执行人、创建待办
updateExecuteIds(equList, instanceId, id, operate, processTaskDTO);
} }
public InstanceRuntimeData buildInstanceRuntimeData(JgScrapCancel jgScrapCancel) {
return InstanceRuntimeData.builder()
.nextExecuteUserIds(jgScrapCancel.getNextExecuteUserIds())
.promoter(jgScrapCancel.getPromoter())
.nextTaskId(jgScrapCancel.getNextTaskId())
.build();
}
public void updateExecuteIds(String equList, String instanceId, Long sequenceNbr, String operate, ProcessTaskDTO processTaskDTO) { public void updateExecuteIds(String equList, String instanceId, Long sequenceNbr, String operate, ProcessTaskDTO processTaskDTO) {
List<String> roleListNext = new ArrayList<>(); List<String> roleListNext = new ArrayList<>();
......
...@@ -641,6 +641,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -641,6 +641,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
} }
// 流程执行时,状态及权限校验 // 流程执行时,状态及权限校验
commonService.checkForExecuteFlow(nextTaskId, instanceId); commonService.checkForExecuteFlow(nextTaskId, instanceId);
JgUseRegistration jgUseRegistration = this.getBaseMapper().selectById(id); JgUseRegistration jgUseRegistration = this.getBaseMapper().selectById(id);
// 组装信息 // 组装信息
TaskResultDTO dto = new TaskResultDTO(); TaskResultDTO dto = new TaskResultDTO();
...@@ -682,13 +683,14 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -682,13 +683,14 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
String lockKey = CommonServiceImpl.buildJgExecuteLockKey(instanceId); String lockKey = CommonServiceImpl.buildJgExecuteLockKey(instanceId);
RLock lock = redissonClient.getLock(lockKey); RLock lock = redissonClient.getLock(lockKey);
try { try {
boolean isLocked = lock.tryLock(); boolean isLocked = lock.tryLock(0, 180, TimeUnit.SECONDS);
// 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回) // 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回)
if(!isLocked){ if(!isLocked){
throw new BadRequest("当前流程已经被执行!"); throw new BadRequest("当前流程已经被执行!");
} }
// 撤回校验 // 撤回校验
commonServiceImpl.checkForRevocationFlow(nextTaskId, instanceId); commonServiceImpl.checkForRevocationFlow(nextTaskId, instanceId);
JgUseRegistration jgUseRegistration = new JgUseRegistration(); JgUseRegistration jgUseRegistration = new JgUseRegistration();
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class); ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
ProcessTaskDTO processTaskDTO = cmWorkflowService.rollBack(instanceId); ProcessTaskDTO processTaskDTO = cmWorkflowService.rollBack(instanceId);
...@@ -732,6 +734,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -732,6 +734,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
commonServiceImpl.rollbackTask(instanceId, jsonObject); commonServiceImpl.rollbackTask(instanceId, jsonObject);
// redis流程实时数据更新 // redis流程实时数据更新
commonServiceImpl.saveExecuteFlowData2Redis(instanceId, this.buildInstanceRuntimeData(data)); commonServiceImpl.saveExecuteFlowData2Redis(instanceId, this.buildInstanceRuntimeData(data));
} catch (InterruptedException e) {
e.printStackTrace();
} finally { } finally {
if(lock.isHeldByCurrentThread()){ if(lock.isHeldByCurrentThread()){
lock.unlock(); lock.unlock();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment