dev_xd
parent
ac0c401534
commit
4db7c1f325
|
@ -53,6 +53,13 @@ public interface FlowBusinessKeyMapper {
|
||||||
*/
|
*/
|
||||||
public List<Map<String, Object>> selectMyAwaitFlowTask(FlowTaskEntity flowTaskEntity);
|
public List<Map<String, Object>> selectMyAwaitFlowTask(FlowTaskEntity flowTaskEntity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询我的驳回任务
|
||||||
|
* @param flowTaskEntity
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<Map<String, Object>> selectMyRejectedFlowTask(FlowTaskEntity flowTaskEntity);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据条件查询我的代办分组数量统计
|
* 根据条件查询我的代办分组数量统计
|
||||||
* @param flowTaskEntity
|
* @param flowTaskEntity
|
||||||
|
|
|
@ -95,6 +95,16 @@
|
||||||
order by fa.createTime desc
|
order by fa.createTime desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!--查询我的驳回任务-->
|
||||||
|
<select id="selectMyRejectedFlowTask" parameterType="FlowTaskEntity" resultType="Map">
|
||||||
|
select fa.* from vw_flow_await fa
|
||||||
|
<where>
|
||||||
|
<if test="businessKey != null and businessKey != ''"> and fa.businessKey = #{businessKey}</if>
|
||||||
|
<if test="startProId != null and startProId != ''"> and fa.startProId = #{startProId}</if>
|
||||||
|
AND fa.ASSIGNEE_ = #{assigneeId}
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
<!--根据条件查询我的代办分组数量统计-->
|
<!--根据条件查询我的代办分组数量统计-->
|
||||||
<select id="findAwaitCountGroupByCategory" parameterType="FlowTaskEntity" resultType="Map">
|
<select id="findAwaitCountGroupByCategory" parameterType="FlowTaskEntity" resultType="Map">
|
||||||
select fa.category, count(1) as total from vw_flow_await fa where 1=1
|
select fa.category, count(1) as total from vw_flow_await fa where 1=1
|
||||||
|
|
|
@ -10,7 +10,9 @@ import com.yanzhu.flowable.common.enums.FlowComment;
|
||||||
import com.yanzhu.flowable.domain.SysForm;
|
import com.yanzhu.flowable.domain.SysForm;
|
||||||
import com.yanzhu.flowable.domain.dto.FlowProcDefDto;
|
import com.yanzhu.flowable.domain.dto.FlowProcDefDto;
|
||||||
import com.yanzhu.flowable.domain.my.FlowDeptVo;
|
import com.yanzhu.flowable.domain.my.FlowDeptVo;
|
||||||
|
import com.yanzhu.flowable.domain.my.FlowTaskEntity;
|
||||||
import com.yanzhu.flowable.factory.FlowServiceFactory;
|
import com.yanzhu.flowable.factory.FlowServiceFactory;
|
||||||
|
import com.yanzhu.flowable.mapper.FlowBusinessKeyMapper;
|
||||||
import com.yanzhu.flowable.mapper.FlowDeployMapper;
|
import com.yanzhu.flowable.mapper.FlowDeployMapper;
|
||||||
import com.yanzhu.flowable.service.IFlowDefinitionService;
|
import com.yanzhu.flowable.service.IFlowDefinitionService;
|
||||||
import com.yanzhu.flowable.service.ISysDeployFormService;
|
import com.yanzhu.flowable.service.ISysDeployFormService;
|
||||||
|
@ -18,6 +20,7 @@ import com.yanzhu.manage.domain.ProProjectInfo;
|
||||||
import com.yanzhu.system.api.domain.SysUser;
|
import com.yanzhu.system.api.domain.SysUser;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.flowable.bpmn.model.BpmnModel;
|
import org.flowable.bpmn.model.BpmnModel;
|
||||||
import org.flowable.bpmn.model.UserTask;
|
import org.flowable.bpmn.model.UserTask;
|
||||||
import org.flowable.engine.repository.Deployment;
|
import org.flowable.engine.repository.Deployment;
|
||||||
|
@ -25,6 +28,7 @@ import org.flowable.engine.repository.ProcessDefinition;
|
||||||
import org.flowable.engine.repository.ProcessDefinitionQuery;
|
import org.flowable.engine.repository.ProcessDefinitionQuery;
|
||||||
import org.flowable.engine.runtime.ProcessInstance;
|
import org.flowable.engine.runtime.ProcessInstance;
|
||||||
import org.flowable.image.impl.DefaultProcessDiagramGenerator;
|
import org.flowable.image.impl.DefaultProcessDiagramGenerator;
|
||||||
|
import org.flowable.task.api.DelegationState;
|
||||||
import org.flowable.task.api.Task;
|
import org.flowable.task.api.Task;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -57,6 +61,9 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
|
||||||
@Resource
|
@Resource
|
||||||
private ISysDeployFormService sysDeployFormService;
|
private ISysDeployFormService sysDeployFormService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FlowBusinessKeyMapper flowBusinessKeyMapper;
|
||||||
|
|
||||||
private static final String BPMN_FILE_SUFFIX = ".bpmn";
|
private static final String BPMN_FILE_SUFFIX = ".bpmn";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -139,7 +146,6 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
|
||||||
Deployment deploy = repositoryService.createDeployment().addInputStream(name + BPMN_FILE_SUFFIX, in).name(name).category(category).deploy();
|
Deployment deploy = repositoryService.createDeployment().addInputStream(name + BPMN_FILE_SUFFIX, in).name(name).category(category).deploy();
|
||||||
ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().deploymentId(deploy.getId()).singleResult();
|
ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().deploymentId(deploy.getId()).singleResult();
|
||||||
repositoryService.setProcessDefinitionCategory(definition.getId(), category);
|
repositoryService.setProcessDefinitionCategory(definition.getId(), category);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -260,33 +266,63 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult startProcessInstanceByParams(String procDefId, Map<String, Object> variables) {
|
public AjaxResult startProcessInstanceByParams(String procDefId, Map<String, Object> variables) {
|
||||||
try {
|
try {
|
||||||
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId)
|
boolean isModify = Convert.toBool(variables.get("isModify"),false);
|
||||||
.latestVersion().singleResult();
|
if(isModify){
|
||||||
if (Objects.nonNull(processDefinition) && processDefinition.isSuspended()) {
|
FlowTaskEntity flowQuery = new FlowTaskEntity();
|
||||||
return AjaxResult.error("流程已被挂起,请先激活流程");
|
flowQuery.setBusinessKey(Convert.toStr(variables.get("businessKey")));
|
||||||
|
flowQuery.setStartProId(Convert.toStr(variables.get("proId")));
|
||||||
|
flowQuery.setAssigneeId(Convert.toLong(variables.get("INITIATOR")));
|
||||||
|
List<Map<String, Object>> rejecteds = flowBusinessKeyMapper.selectMyRejectedFlowTask(flowQuery);
|
||||||
|
if(rejecteds.size()==0){
|
||||||
|
return startProcessInstance(procDefId,variables);
|
||||||
|
}else{
|
||||||
|
String userName = Convert.toStr(variables.get("userName"));
|
||||||
|
String taskId = Convert.toStr(rejecteds.get(0).get("taskId"));
|
||||||
|
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
||||||
|
if (Objects.isNull(task)) {
|
||||||
|
return startProcessInstance(procDefId,variables);
|
||||||
|
}
|
||||||
|
taskService.addComment(taskId, task.getProcessInstanceId(), FlowComment.NORMAL.getType(), userName+"提交流程申请!!");
|
||||||
|
taskService.complete(task.getId(), variables);
|
||||||
|
return AjaxResult.success("流程重启成功");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return startProcessInstance(procDefId,variables);
|
||||||
}
|
}
|
||||||
// 设置流程发起人Id到流程中
|
|
||||||
String userId = Convert.toStr(variables.get(ProcessConstants.PROCESS_INITIATOR));
|
|
||||||
String userName = Convert.toStr(variables.get("userName"));
|
|
||||||
String businessKey = Convert.toStr(variables.get("businessKey"));
|
|
||||||
identityService.setAuthenticatedUserId(userId);
|
|
||||||
ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDefId, businessKey, variables);
|
|
||||||
|
|
||||||
// 给第一步申请人节点设置任务执行人和意见
|
|
||||||
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).singleResult();
|
|
||||||
if (Objects.nonNull(task)) {
|
|
||||||
taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), userName + "发起流程申请");
|
|
||||||
taskService.setAssignee(task.getId(), userId);
|
|
||||||
taskService.complete(task.getId(), variables);
|
|
||||||
}
|
|
||||||
return AjaxResult.success("流程启动成功");
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return AjaxResult.error("流程启动错误");
|
return AjaxResult.error("流程启动错误");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据参数启动流程
|
||||||
|
* @param procDefId
|
||||||
|
* @param variables
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private AjaxResult startProcessInstance(String procDefId, Map<String, Object> variables){
|
||||||
|
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId)
|
||||||
|
.latestVersion().singleResult();
|
||||||
|
if (Objects.nonNull(processDefinition) && processDefinition.isSuspended()) {
|
||||||
|
return AjaxResult.error("流程已被挂起,请先激活流程");
|
||||||
|
}
|
||||||
|
// 设置流程发起人Id到流程中
|
||||||
|
String userId = Convert.toStr(variables.get(ProcessConstants.PROCESS_INITIATOR));
|
||||||
|
String userName = Convert.toStr(variables.get("userName"));
|
||||||
|
String businessKey = Convert.toStr(variables.get("businessKey"));
|
||||||
|
identityService.setAuthenticatedUserId(userId);
|
||||||
|
ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDefId, businessKey, variables);
|
||||||
|
|
||||||
|
// 给第一步申请人节点设置任务执行人和意见
|
||||||
|
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).singleResult();
|
||||||
|
if (Objects.nonNull(task)) {
|
||||||
|
taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), userName + "发起流程申请");
|
||||||
|
taskService.setAssignee(task.getId(), userId);
|
||||||
|
taskService.complete(task.getId(), variables);
|
||||||
|
}
|
||||||
|
return AjaxResult.success("流程启动成功");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 激活或挂起流程定义
|
* 激活或挂起流程定义
|
||||||
|
|
|
@ -970,10 +970,18 @@ public class ProProjectInfoSubdeptsUsersServiceImpl implements IProProjectInfoSu
|
||||||
throw new ServiceException("承诺书生成失败...服务器异常!!!");
|
throw new ServiceException("承诺书生成失败...服务器异常!!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isModify = false;
|
||||||
// 判断是否需要审批...
|
// 判断是否需要审批...
|
||||||
if(Objects.nonNull(proSubdeptsUser.getApproveStatus()) && proSubdeptsUser.getApproveStatus()<ApproveStatus.check.getCode()){
|
if(Objects.nonNull(proSubdeptsUser.getApproveStatus())){
|
||||||
proSubdeptsUser.setApproveStatus(ApproveStatus.check.getCode());
|
if(proSubdeptsUser.getApproveStatus()<ApproveStatus.check.getCode()){
|
||||||
|
proSubdeptsUser.setApproveStatus(ApproveStatus.check.getCode());
|
||||||
|
}else if(proSubdeptsUser.getApproveStatus()==ApproveStatus.refuse.getCode()){
|
||||||
|
isModify = true;
|
||||||
|
//查询流程...
|
||||||
|
proSubdeptsUser.setApproveStatus(ApproveStatus.check.getCode());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int res = proProjectInfoSubdeptsUsersMapper.updateProProjectInfoSubdeptsUsers(proSubdeptsUser);
|
int res = proProjectInfoSubdeptsUsersMapper.updateProProjectInfoSubdeptsUsers(proSubdeptsUser);
|
||||||
|
|
||||||
// 保存业务签名
|
// 保存业务签名
|
||||||
|
@ -998,6 +1006,7 @@ public class ProProjectInfoSubdeptsUsersServiceImpl implements IProProjectInfoSu
|
||||||
String procDefId = Convert.toStr(procdefDatas.get(0).get("PROCDEF_ID_"));
|
String procDefId = Convert.toStr(procdefDatas.get(0).get("PROCDEF_ID_"));
|
||||||
// 启动工作流审批节点...
|
// 启动工作流审批节点...
|
||||||
Map<String, Object> variables = new HashMap<>();
|
Map<String, Object> variables = new HashMap<>();
|
||||||
|
variables.put("isModify",isModify);
|
||||||
variables.put("INITIATOR",proSubdeptsUser.getUserId());
|
variables.put("INITIATOR",proSubdeptsUser.getUserId());
|
||||||
variables.put("userName",proSubdeptsUser.getUserName());
|
variables.put("userName",proSubdeptsUser.getUserName());
|
||||||
variables.put("userDeptName",proSubdeptsUser.getSubDeptName());
|
variables.put("userDeptName",proSubdeptsUser.getSubDeptName());
|
||||||
|
|
Loading…
Reference in New Issue