新流程开发
parent
969b044daa
commit
48aecf5235
|
@ -85,4 +85,19 @@ public class ActConstant {
|
|||
|
||||
public static final String KEY_PROJECT_ID = "projectId";
|
||||
public static final String KEY_PROJECT_TYPE = "projectType";
|
||||
|
||||
public static final String PROCESS_DEFKEY_SALE_CONTRACT = "saleContract";
|
||||
public static final String PROCESS_DEFKEY_BUSINESS_PURCHASE = "businessPurchase";
|
||||
|
||||
|
||||
//发起人部门主管
|
||||
public static final int CANDIDATE_TYPE_START_USER_LEADER = 1;
|
||||
|
||||
|
||||
//四算项目
|
||||
public static final int PROJECT_TYPE_FOURCAL = 0;
|
||||
//销售合同
|
||||
public static final int PROJECT_TYPE_SALE_CONTRACT = 1;
|
||||
//业务采购
|
||||
public static final int PROJECT_TYPE_BUSINESS_PURCHASE = 2;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ package cn.palmte.work.controller.backend;
|
|||
import cn.palmte.work.bean.ResponseMsg;
|
||||
import cn.palmte.work.service.ActModelService;
|
||||
|
||||
import cn.palmte.work.utils.ActUtil;
|
||||
import cn.palmte.work.utils.InterfaceUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -24,6 +25,9 @@ public class ActModelController extends BaseController {
|
|||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ActModelController.class);
|
||||
|
||||
@Autowired
|
||||
ActUtil actUtil;
|
||||
|
||||
@Autowired
|
||||
private ActModelService activitiModelService;
|
||||
|
||||
|
@ -45,9 +49,14 @@ public class ActModelController extends BaseController {
|
|||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
public String save(HttpServletRequest request) {
|
||||
public String save(HttpServletRequest request, Map<String, Object> model) {
|
||||
String procDefKey = request.getParameter("procDefKey");
|
||||
if (activitiModelService.findByProcDefKey(procDefKey) != null) {
|
||||
model.put("errorMessage", "流程标识已经存在!");
|
||||
return "/common/error";
|
||||
}
|
||||
try {
|
||||
activitiModelService.createModel(request.getParameter("procDefKey"), request.getParameter("modelName"));
|
||||
activitiModelService.createModel(procDefKey, request.getParameter("modelName"));
|
||||
} catch (Exception e) {
|
||||
logger.error("", e);
|
||||
}
|
||||
|
|
|
@ -69,16 +69,11 @@ public class ActTaskDef {
|
|||
|
||||
|
||||
/**
|
||||
* 审批通过执行的脚本 act_script(弃用)表id 弃用
|
||||
* 按类型查询
|
||||
*/
|
||||
@Column(name = "end_script")
|
||||
private int endScript;
|
||||
@Column(name = "candidate_types")
|
||||
private String candidateTypes;
|
||||
|
||||
/**
|
||||
* 审批驳回执行的脚本 act_script(弃用)表id 弃用
|
||||
*/
|
||||
@Column(name = "rollback_script")
|
||||
private int rollbackScript;
|
||||
|
||||
@Column(name = "created_time")
|
||||
private Date createdTime;
|
||||
|
@ -94,4 +89,7 @@ public class ActTaskDef {
|
|||
@Transient
|
||||
private List<String> candidateRoleList;
|
||||
|
||||
@Transient
|
||||
private List<String> candidateTypeList;
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,12 @@ public class ProjectInstanceRelation {
|
|||
@Column(name = "project_id")
|
||||
private int projectId;
|
||||
|
||||
/**
|
||||
* 项目类型 0-四算项目 1-销售合同流程 2-业务采购流程
|
||||
*/
|
||||
@Column(name = "project_type")
|
||||
private int projectType = 0;
|
||||
|
||||
/**
|
||||
* 流程类型:estimate、budget、settle、final
|
||||
*/
|
||||
|
@ -77,4 +83,12 @@ public class ProjectInstanceRelation {
|
|||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public int getProjectType() {
|
||||
return projectType;
|
||||
}
|
||||
|
||||
public void setProjectType(int projectType) {
|
||||
this.projectType = projectType;
|
||||
}
|
||||
}
|
|
@ -1,14 +1,15 @@
|
|||
package cn.palmte.work.model;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ProjectInstanceRelationRepository extends JpaRepository<ProjectInstanceRelation,Integer> {
|
||||
/**
|
||||
* 根据项目id和类型找到流程实例id
|
||||
*/
|
||||
List<ProjectInstanceRelation> findAllByProjectIdEqualsAndProcessTypeEqualsOrderByCreateTimeDesc(int projectId, String processType);
|
||||
|
||||
@Query(value = "select * from project_instance_relation where project_id = ? and project_type=0 order by create_time desc", nativeQuery = true)
|
||||
List<ProjectInstanceRelation> findByProjectIdOrderByCreateTimeDesc(int projectId);
|
||||
|
||||
@Query(value = "select * from project_instance_relation where project_id = ? and project_type=? order by create_time desc limit 1", nativeQuery = true)
|
||||
ProjectInstanceRelation findByProjectIdAndProjectType(int projectId, int projectType);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,12 @@ public class ProjectTaskRecord {
|
|||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* 项目类型 0-四算项目 1-销售合同流程 2-业务采购流程
|
||||
*/
|
||||
@Column(name = "project_type")
|
||||
private int projectType = 0;
|
||||
|
||||
@Column(name = "project_id")
|
||||
private int projectId;
|
||||
|
||||
|
|
|
@ -472,4 +472,31 @@ public class AccountService {
|
|||
}
|
||||
return userIds;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询部门主管(一级部门领导)
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
public int getOneLevelDeptManagerId(int userId) {
|
||||
Admin admin = adminRepository.findOne(userId);
|
||||
Record record = getDept(admin.getDeptId());
|
||||
if (record == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (1 != record.getInt("level")) {
|
||||
//不是一级 往上找
|
||||
record = getDept(record.getInt("parnter_id"));
|
||||
}
|
||||
|
||||
return record.getInt("manager_id");
|
||||
}
|
||||
|
||||
private Record getDept(int deptId) {
|
||||
String sql = "SELECT level, manager_id, parnter_id from dept where id=?";
|
||||
return pagination.findFirst(sql, deptId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -47,7 +48,7 @@ public class ActListenerService {
|
|||
* @param delegateTask
|
||||
* @throws Exception
|
||||
*/
|
||||
public void create(DelegateTask delegateTask) throws Exception {
|
||||
public void create(DelegateTask delegateTask) {
|
||||
String procInsId = delegateTask.getProcessInstanceId();
|
||||
logger.info("--节点创建后监听-- procInsId:{}, {}", procInsId, delegateTask);
|
||||
logger.info("**** rwcjjt【{}】任务创建监听 procInsId:{} **** ", delegateTask, procInsId);
|
||||
|
@ -58,44 +59,69 @@ public class ActListenerService {
|
|||
logger.info("**** rwcjjt 任务创建监听 查询候选人 procInsId:{},任务名称:{},候选人:{} **** ", procInsId, delegateTask.getName(), candidateUsers);
|
||||
|
||||
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(procInsId).singleResult();
|
||||
updateProjectApprover(candidateUsers, processInstance, procDefId, taskDefKey);
|
||||
if (processInstance != null) {
|
||||
try {
|
||||
updateProjectApprover(candidateUsers, processInstance, procDefId, taskDefKey);
|
||||
} catch (Exception e) {
|
||||
logger.error("updateProjectApproverError", e);
|
||||
}
|
||||
}
|
||||
|
||||
delegateTask.addCandidateUsers(candidateUsers);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新项目审批人 四算业务需要
|
||||
* 流程结束监听 更新项目状态为审批通过
|
||||
*
|
||||
* @param delegateExecution
|
||||
*/
|
||||
public void end(DelegateExecution delegateExecution) {
|
||||
String procInsId = delegateExecution.getProcessInstanceId();
|
||||
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(procInsId).singleResult();
|
||||
int projectId = Integer.parseInt(processInstance.getBusinessKey());
|
||||
|
||||
String procDefId = processInstance.getProcessDefinitionId();
|
||||
if (actUtil.isNewProcess(procDefId)) {
|
||||
logger.info("**** lcjsjt 流程结束监听 更新项目状态为审批通过 **** procInsId:{}, procDefId:{}, projectId:{}", procInsId, procDefId, projectId);
|
||||
//todo updateNewProcess 更新项目状态为审批通过
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新项目审批人
|
||||
*
|
||||
* @param candidateUsers
|
||||
* @param processInstance
|
||||
*/
|
||||
private void updateProjectApprover(List<String> candidateUsers, ProcessInstance processInstance, String procDefId, String taskDefKey) {
|
||||
if (processInstance == null) {
|
||||
return;
|
||||
}
|
||||
private void updateProjectApprover(List<String> candidateUsers, ProcessInstance processInstance,
|
||||
String procDefId, String taskDefKey) {
|
||||
String businessKey = processInstance.getBusinessKey();
|
||||
ActTaskDef actTaskDef = actTaskDefService.findFirstByProcDefIdAndTaskKey(procDefId, taskDefKey);
|
||||
//找到当前有效的用户
|
||||
List<Integer> enableUsers = currentEnableUsers(candidateUsers);
|
||||
boolean isFirstUserTask = actTaskDef != null && actTaskDef.getTaskIndex() != ActConstant.TASK_INDEX_FIRST_USER_TASK;
|
||||
|
||||
try {
|
||||
String businessKey = processInstance.getBusinessKey();
|
||||
ActTaskDef actTaskDef = actTaskDefService.findFirstByProcDefIdAndTaskKey(procDefId, taskDefKey);
|
||||
int adminId = 0;
|
||||
if (!candidateUsers.isEmpty() && actTaskDef!=null && actTaskDef.getTaskIndex() != ActConstant.TASK_INDEX_FIRST_USER_TASK) {
|
||||
//回退到发起节点 审批人设置为空
|
||||
for (String id : candidateUsers) {
|
||||
Admin one = adminRepository.findOne(Integer.parseInt(id));
|
||||
if (!one.isDeleted() && one.getEnabled() == 1) {
|
||||
//找到有效账号 发送任务
|
||||
adminId = one.getId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (actUtil.isFourcalProcess(procDefId)) {
|
||||
int adminId = 0;//默认审批人设置为空
|
||||
if (!isFirstUserTask && !enableUsers.isEmpty()) {
|
||||
adminId = enableUsers.get(0);//四算项目只支持一个审批人
|
||||
}
|
||||
logger.info("**** rwcjjt 任务创建监听 更新审批人 procInsId:{}, projectId:{}, adminId:{} **** ",
|
||||
logger.info("**** rwcjjt 任务创建监听 更新审批人1 procInsId:{}, projectId:{}, adminId:{} **** ",
|
||||
processInstance.getProcessInstanceId(), businessKey, adminId);
|
||||
projectInstanceService.updateApprover(Integer.parseInt(businessKey), adminId);
|
||||
} catch (Exception e) {
|
||||
logger.error("", e);
|
||||
} else if (actUtil.isNewProcess(procDefId)) {
|
||||
//todo updateNewProcess 更新流程审批人
|
||||
logger.info("**** rwcjjt 任务创建监听 更新审批2 procInsId:{}, projectId:{}, enableUsers:{} **** ",
|
||||
processInstance.getProcessInstanceId(), businessKey, enableUsers);
|
||||
}
|
||||
}
|
||||
|
||||
private List<Integer> currentEnableUsers(List<String> candidateUsers) {
|
||||
return candidateUsers.stream().map(ele -> adminRepository.findOne(Integer.parseInt(ele)))
|
||||
.filter(ele -> !ele.isDeleted() && ele.getEnabled() == 1)
|
||||
.map(Admin::getId)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.activiti.bpmn.model.*;
|
|||
import org.activiti.bpmn.model.Process;
|
||||
import org.activiti.editor.language.json.converter.BpmnJsonConverter;
|
||||
import org.activiti.engine.RepositoryService;
|
||||
import org.activiti.engine.delegate.BaseExecutionListener;
|
||||
import org.activiti.engine.delegate.TaskListener;
|
||||
import org.activiti.engine.repository.Deployment;
|
||||
import org.activiti.engine.repository.DeploymentBuilder;
|
||||
|
@ -55,6 +56,10 @@ public class ActModelService {
|
|||
return pagination.paginate(queryHelper.getSql(), ActModel.class, pageNumber, pageSize);
|
||||
}
|
||||
|
||||
public ActModel findByProcDefKey(String procDefKey) {
|
||||
return pagination.findFirst("select * from act_re_model where KEY_=? ", ActModel.class, procDefKey);
|
||||
}
|
||||
|
||||
public void createModel(String processId, String modelName) throws Exception {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
ObjectNode editorNode = objectMapper.createObjectNode();
|
||||
|
@ -114,18 +119,13 @@ public class ActModelService {
|
|||
BpmnJsonConverter jsonConverter = new BpmnJsonConverter();
|
||||
BpmnModel model = jsonConverter.convertToBpmnModel(modelNode);
|
||||
|
||||
//任务创建后监听器
|
||||
ActivitiListener activitiListener = new ActivitiListener();
|
||||
activitiListener.setEvent(TaskListener.EVENTNAME_CREATE);
|
||||
activitiListener.setImplementation("${actListenerService.create(task)}");
|
||||
activitiListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
|
||||
List<ActivitiListener> activitiListenerList = new ArrayList<>(1);
|
||||
activitiListenerList.add(activitiListener);
|
||||
|
||||
List<ActTaskDef> taskList = new ArrayList<>();
|
||||
Process process = model.getMainProcess();
|
||||
Collection<FlowElement> flowElements = process.getFlowElements();
|
||||
|
||||
//设置流程监听器
|
||||
setExecutionListener(process);
|
||||
|
||||
int i = 0;
|
||||
ActTaskDef taskDef;
|
||||
ActTaskDef first = null;
|
||||
|
@ -139,16 +139,12 @@ public class ActModelService {
|
|||
|
||||
MultiInstanceLoopCharacteristics loopCharacteristics = userTaskElement.getLoopCharacteristics();
|
||||
if (loopCharacteristics != null) { //多实列
|
||||
loopCharacteristics.setInputDataItem("${actListenerService.getMultiCandidateUsers(execution)}");
|
||||
loopCharacteristics.setElementVariable("assignee");
|
||||
userTaskElement.setAssignee("${assignee}");
|
||||
|
||||
taskDef.setTaskType(ActConstant.TASK_TYPE_MULTI);
|
||||
}else {
|
||||
userTaskElement.setTaskListeners(activitiListenerList);
|
||||
|
||||
taskDef.setTaskType(ActConstant.TASK_TYPE_SINGE);
|
||||
}
|
||||
//任务监听器
|
||||
setTaskListener(userTaskElement);
|
||||
|
||||
if (i == 1) {//画流程图时,要保证第一个用户任务一定要先画
|
||||
taskDef.setTaskIndex(ActConstant.TASK_INDEX_FIRST_USER_TASK);
|
||||
|
@ -183,4 +179,24 @@ public class ActModelService {
|
|||
logger.info("deploy success: deploymentId:{}, procDefName:{}, procDefKey:{}", deployment.getId(), processDefinition.getName(), processDefinition.getKey());
|
||||
}
|
||||
|
||||
|
||||
private void setTaskListener(UserTask userTaskElement) {
|
||||
ActivitiListener taskListener = new ActivitiListener();
|
||||
taskListener.setEvent(TaskListener.EVENTNAME_CREATE);
|
||||
taskListener.setImplementation("${actListenerService.create(task)}");
|
||||
taskListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
|
||||
List<ActivitiListener> taskListenerList = new ArrayList<>(1);
|
||||
taskListenerList.add(taskListener);
|
||||
userTaskElement.setTaskListeners(taskListenerList);
|
||||
}
|
||||
|
||||
private void setExecutionListener(Process process) {
|
||||
ActivitiListener executionListener = new ActivitiListener();
|
||||
executionListener.setEvent(BaseExecutionListener.EVENTNAME_END);
|
||||
executionListener.setImplementation("${actListenerService.end(execution)}");
|
||||
executionListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
|
||||
List<ActivitiListener> executionListenerList = new ArrayList<>(1);
|
||||
executionListenerList.add(executionListener);
|
||||
process.setExecutionListeners(executionListenerList);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public class ActProcDefService {
|
|||
QueryHelper queryHelper = new QueryHelper(select, " act_re_procdef p LEFT JOIN act_re_deployment d on p.DEPLOYMENT_ID_ = d.ID_");
|
||||
String name = searchInfo.get("name");
|
||||
queryHelper.addCondition(StringUtils.isNotEmpty(name), "(p.NAME_=? or p.KEY_=?)", name, name);
|
||||
queryHelper.addOrderProperty("p.VERSION_", false);
|
||||
queryHelper.addOrderProperty("d.DEPLOY_TIME_", false);
|
||||
return pagination.paginate(queryHelper.getSql(), ActProcDef.class, pageNumber, pageSize);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ import cn.palmte.work.utils.InterfaceUtil;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.activiti.engine.*;
|
||||
import org.activiti.engine.impl.identity.Authentication;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntity;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
@ -99,6 +98,7 @@ public class ActTaskDefService {
|
|||
|
||||
/**
|
||||
* 预算跳过剩下审批任务直接到执行董事节点
|
||||
*
|
||||
* @param procInsId
|
||||
*/
|
||||
public ResponseMsg skipTaskByProcInsId(String procInsId, String fileUrl, String comment) {
|
||||
|
@ -176,8 +176,10 @@ public class ActTaskDefService {
|
|||
//审批通过
|
||||
taskService.complete(taskId);
|
||||
|
||||
//最后一个任务完成后 更新项目状态为审批通过
|
||||
updateProjectPassed(processInstance, actTaskDef, procDefKey);
|
||||
if (actUtil.isFourcalProcess(processInstance.getProcessDefinitionId())) {
|
||||
//四算项目 最后一个任务完成后 更新项目状态为审批通过 其他项目通过监听器更新
|
||||
updateProjectPassed(processInstance, actTaskDef, procDefKey);
|
||||
}
|
||||
} else if (ApproveStatusEnum.APPROVAL_UNPASS.getApproveStatus() == type) {
|
||||
//驳回
|
||||
String rollbackTaskKey = actTaskDef.getRollbackTaskKey();
|
||||
|
@ -185,7 +187,11 @@ public class ActTaskDefService {
|
|||
|
||||
//驳回后 更新项目状态为审批不通过
|
||||
int projectId = Integer.parseInt(processInstance.getBusinessKey());
|
||||
projectInstanceService.updateApproveStatus(projectId, procDefKey, ApproveStatusEnum.APPROVAL_UNPASS);
|
||||
if (actUtil.isFourcalProcess(processInstance.getProcessDefinitionId())) {
|
||||
projectInstanceService.updateApproveStatus(projectId, procDefKey, ApproveStatusEnum.APPROVAL_UNPASS);
|
||||
} else if (actUtil.isNewProcess(processInstance.getProcessDefinitionId())) {
|
||||
//todo updateNewProcess 更新流程状态为不通过
|
||||
}
|
||||
logger.info("updateProjectUnPassed projectId:{}, proDefKey:{}", projectId, procDefKey);
|
||||
|
||||
}
|
||||
|
@ -295,7 +301,8 @@ public class ActTaskDefService {
|
|||
ActTaskDef one = actTaskDefRepository.findOne(taskDef.getId());
|
||||
one.setCandidateUsers(taskDef.getCandidateUsers());
|
||||
one.setCandidateRoles(taskDef.getCandidateRoles());
|
||||
one.setRollbackTaskKey(taskDef.getRollbackTaskKey());
|
||||
one.setCandidateTypes(taskDef.getCandidateTypes());
|
||||
//one.setRollbackTaskKey(taskDef.getRollbackTaskKey());
|
||||
one.setLastUpdatedTime(new Date());
|
||||
|
||||
actTaskDefRepository.save(one);
|
||||
|
@ -341,11 +348,40 @@ public class ActTaskDefService {
|
|||
res.addAll(list);
|
||||
}
|
||||
|
||||
//通过特殊类型查询
|
||||
List<String> candidateTypeList = taskDef.getCandidateTypeList();
|
||||
logger.info("findCandidateUsers-type-task:{}, typeList:{}", taskDef.getTaskName(), candidateTypeList);
|
||||
List<String> userListByType = queryCandidatesByTypes(candidateRoleList, procInsId);
|
||||
logger.info("findCandidateUsers-type-task:{}, userListByType:{}", taskDef.getTaskName(), userListByType);
|
||||
if (!userListByType.isEmpty()) {
|
||||
res.addAll(userListByType);
|
||||
}
|
||||
|
||||
List<String> resList = new ArrayList<>(res);
|
||||
logger.info("findCandidateUsers-4-task:{}, resIds:{}", taskDef.getTaskName(), resList);
|
||||
return resList;
|
||||
}
|
||||
|
||||
private List<String> queryCandidatesByTypes(List<String> types, String procInsId) {
|
||||
if (types == null || types.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<String> userIdList = new ArrayList<>();
|
||||
for (String typeStr : types) {
|
||||
if (ActConstant.CANDIDATE_TYPE_START_USER_LEADER == Integer.parseInt(typeStr)) {
|
||||
//查找发起人部门主管
|
||||
String startUserId = actUtil.getStartUserId(procInsId);
|
||||
int leaderId = accountService.getOneLevelDeptManagerId(Integer.parseInt(startUserId));
|
||||
if (leaderId != 0) {
|
||||
userIdList.add(String.valueOf(leaderId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return userIdList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 任务审批人列表从sring转成list
|
||||
|
@ -366,6 +402,13 @@ public class ActTaskDefService {
|
|||
roleIdList = Arrays.asList(candidateRoles.split("#"));
|
||||
}
|
||||
actTaskDef.setCandidateRoleList(roleIdList);
|
||||
|
||||
String candidateTypes = actTaskDef.getCandidateTypes();
|
||||
List<String> typeIdList = new ArrayList<>();
|
||||
if (StringUtils.isNotBlank(candidateTypes)) {
|
||||
typeIdList = Arrays.asList(candidateTypes.split("#"));
|
||||
}
|
||||
actTaskDef.setCandidateTypeList(typeIdList);
|
||||
}
|
||||
|
||||
|
||||
|
@ -409,7 +452,7 @@ public class ActTaskDefService {
|
|||
//保存一条指定承接人记录
|
||||
projectTaskRecordService.saveTaskRecord(projectId, currentTask, ProjectTaskRecord.STATUS_RE_ASSIGNEE, ActConstant.TASK_INDEX_OTHER,
|
||||
"指定承接人【" + targetAdmin.getRealName() + "]");
|
||||
}else{
|
||||
} else {
|
||||
logger.error("setTaskAssignAndSaveRecordError task is null, projectId:{}", projectId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,15 @@
|
|||
package cn.palmte.work.service;
|
||||
|
||||
import cn.palmte.work.bean.ApproveStatusEnum;
|
||||
import cn.palmte.work.bean.StatusEnum;
|
||||
import cn.palmte.work.config.activiti.ActConstant;
|
||||
import cn.palmte.work.model.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import top.jfunc.common.utils.CollectionUtil;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author xiongshiyan at 2021/10/29 , contact me with email yanshixiong@126.com or phone 15208384257
|
||||
|
@ -30,6 +25,8 @@ public class ProjectInstanceService {
|
|||
private ActProcInsService actProcInsService;
|
||||
@Autowired
|
||||
private ProjectInstanceRelationRepository projectInstanceRelationRepository;
|
||||
@Autowired
|
||||
private ActTaskDefService actTaskDefService;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -39,25 +36,12 @@ public class ProjectInstanceService {
|
|||
startProcess(project, admin, ActConstant.PROCESS_DEFKEY_ESTIMATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回概算的所有的实例id,没有则空集合
|
||||
*/
|
||||
public List<String> getEstimateProcessInsIds(Project project){
|
||||
return getApproveInstanceIds(project, ActConstant.PROCESS_DEFKEY_ESTIMATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启一个预算流程实例
|
||||
*/
|
||||
public void startBudgetProcessInstance(Project project, Admin admin) throws Exception {
|
||||
startProcess(project, admin, ActConstant.PROCESS_DEFKEY_BUDGET);
|
||||
}
|
||||
/**
|
||||
* 返回预算的所有的实例id,没有则空集合
|
||||
*/
|
||||
public List<String> getBudgetProcessInsIds(Project project){
|
||||
return getApproveInstanceIds(project, ActConstant.PROCESS_DEFKEY_BUDGET);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启一个结算流程实例
|
||||
|
@ -65,12 +49,6 @@ public class ProjectInstanceService {
|
|||
public void startSettleProcessInstance(Project project, Admin admin) throws Exception {
|
||||
startProcess(project, admin, ActConstant.PROCESS_DEFKEY_SETTLE);
|
||||
}
|
||||
/**
|
||||
* 返回结算的所有的实例id,没有则空集合
|
||||
*/
|
||||
public List<String> getSettleProcessInsIds(Project project){
|
||||
return getApproveInstanceIds(project, ActConstant.PROCESS_DEFKEY_SETTLE);
|
||||
}
|
||||
/**
|
||||
* 开启一个决算流程实例
|
||||
*/
|
||||
|
@ -78,18 +56,87 @@ public class ProjectInstanceService {
|
|||
Project project = projectRepository.findOne(projectId);
|
||||
startProcess(project, admin, ActConstant.PROCESS_DEFKEY_FINAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回决算的所有的实例id,没有则空集合
|
||||
* 发起销售合同流程实例
|
||||
*
|
||||
* @param projectId 项目唯一id
|
||||
* @param map 流程变量
|
||||
* @throws Exception
|
||||
*/
|
||||
public List<String> getFinalProcessInsIds(Project project){
|
||||
return getApproveInstanceIds(project, ActConstant.PROCESS_DEFKEY_FINAL);
|
||||
public void startSaleContractProcess(int projectId, Map<String, Object> map) throws Exception {
|
||||
String processDefkey = ActConstant.PROCESS_DEFKEY_SALE_CONTRACT;
|
||||
String businessKey = String.valueOf(projectId);
|
||||
logger.info("startSaleContractProcess processDefkey:{}, businessKey:{}", processDefkey, businessKey);
|
||||
String processInstanceId = actProcInsService.startProcessInstance(processDefkey, businessKey, map);
|
||||
saveRelation(projectId, processDefkey, processInstanceId);
|
||||
|
||||
}
|
||||
private List<String> getApproveInstanceIds(Project project, String processDefkey) {
|
||||
List<ProjectInstanceRelation> all = projectInstanceRelationRepository.findAllByProjectIdEqualsAndProcessTypeEqualsOrderByCreateTimeDesc(project.getId(), processDefkey);
|
||||
if (CollectionUtil.isEmpty(all)) {
|
||||
return Collections.emptyList();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 发起业务采购流程实例
|
||||
*
|
||||
* @param projectId 项目唯一id
|
||||
* @param map 流程变量
|
||||
* @throws Exception
|
||||
*/
|
||||
public void startBusinessPurchaseProcess(int projectId, Map<String, Object> map) throws Exception {
|
||||
String processDefkey = ActConstant.PROCESS_DEFKEY_BUSINESS_PURCHASE;
|
||||
String businessKey = String.valueOf(projectId);
|
||||
logger.info("startBusinessPurchaseProcess processDefkey:{}, businessKey:{}", processDefkey, businessKey);
|
||||
String processInstanceId = actProcInsService.startProcessInstance(processDefkey, businessKey, map);
|
||||
|
||||
//保存流程实例id与项目的关联关系
|
||||
saveRelation(projectId, processDefkey, processInstanceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 销售合同流程 审批(通过或者不通过)
|
||||
*
|
||||
* @param projectId 项目唯一id
|
||||
* @param approveType 2-通过 3-不通过
|
||||
* @param message 审批意见
|
||||
* @return
|
||||
*/
|
||||
public boolean completeSaleContractTask(int projectId, int approveType, String message) {
|
||||
ProjectInstanceRelation projectInstance = projectInstanceRelationRepository.findByProjectIdAndProjectType(projectId, ActConstant.PROJECT_TYPE_SALE_CONTRACT);
|
||||
if (projectInstance == null) {
|
||||
return false;
|
||||
}
|
||||
return all.stream().map(ProjectInstanceRelation::getProcessInsId).collect(Collectors.toList());
|
||||
actTaskDefService.completeTaskByProcInsId(projectInstance.getProcessInsId(), approveType, message);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 业务采购流程 审批(通过或者不通过)
|
||||
*
|
||||
* @param projectId 项目唯一id
|
||||
* @param approveType 2-通过 3-不通过
|
||||
* @param message 审批意见
|
||||
* @return
|
||||
*/
|
||||
public boolean completeBusinessPurchaseTask(int projectId, int approveType, String message) {
|
||||
ProjectInstanceRelation projectInstance = projectInstanceRelationRepository.findByProjectIdAndProjectType(projectId, ActConstant.PROJECT_TYPE_SALE_CONTRACT);
|
||||
if (projectInstance == null) {
|
||||
return false;
|
||||
}
|
||||
actTaskDefService.completeTaskByProcInsId(projectInstance.getProcessInsId(), approveType, message);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void saveRelation(int projectId, String processDefkey, String processInstanceId) {
|
||||
//保存流程实例id与项目的关联关系
|
||||
ProjectInstanceRelation relation = new ProjectInstanceRelation();
|
||||
relation.setProjectId(projectId);
|
||||
relation.setProjectType(ActConstant.PROJECT_TYPE_SALE_CONTRACT);
|
||||
relation.setProcessType(processDefkey);
|
||||
relation.setProcessInsId(processInstanceId);
|
||||
relation.setCreateTime(new Date());
|
||||
projectInstanceRelationRepository.saveAndFlush(relation);
|
||||
}
|
||||
|
||||
private void startProcess(Project project, Admin admin, String processDefkey) throws Exception {
|
||||
|
|
|
@ -80,8 +80,17 @@ public class ProjectTaskRecordService {
|
|||
private ProjectTaskRecord getProjectTaskRecord(int projectId, Task task, int status, int taskIndex, String comment) {
|
||||
ProjectTaskRecord record = new ProjectTaskRecord();
|
||||
record.setProjectId(projectId);
|
||||
record.setProcDefId(task.getProcessDefinitionId());
|
||||
String procDefId = task.getProcessDefinitionId();
|
||||
record.setProcDefId(procDefId);
|
||||
record.setProcInsId(task.getProcessInstanceId());
|
||||
|
||||
int projectType = ActConstant.PROJECT_TYPE_FOURCAL;
|
||||
if (procDefId.startsWith(ActConstant.PROCESS_DEFKEY_SALE_CONTRACT)) {
|
||||
projectType = ActConstant.PROJECT_TYPE_SALE_CONTRACT;
|
||||
} else if (procDefId.startsWith(ActConstant.PROCESS_DEFKEY_BUSINESS_PURCHASE)) {
|
||||
projectType = ActConstant.PROJECT_TYPE_BUSINESS_PURCHASE;
|
||||
}
|
||||
record.setProjectType(projectType);
|
||||
record.setTaskDefKey(task.getTaskDefinitionKey());
|
||||
record.setTaskName(task.getName());
|
||||
record.setTaskComment(comment);
|
||||
|
|
|
@ -52,6 +52,19 @@ public class ActUtil {
|
|||
@Autowired
|
||||
private ProjectInstanceRelationRepository projectInstanceRelationRepository;
|
||||
|
||||
|
||||
public boolean isFourcalProcess(String procDefId) {
|
||||
return procDefId.startsWith(ActConstant.PROCESS_DEFKEY_ESTIMATE)
|
||||
|| procDefId.startsWith(ActConstant.PROCESS_DEFKEY_BUDGET)
|
||||
|| procDefId.startsWith(ActConstant.PROCESS_DEFKEY_SETTLE)
|
||||
|| procDefId.startsWith(ActConstant.PROCESS_DEFKEY_FINAL);
|
||||
}
|
||||
|
||||
public boolean isNewProcess(String procDefId) {
|
||||
return procDefId.startsWith(ActConstant.PROCESS_DEFKEY_SALE_CONTRACT)
|
||||
|| procDefId.startsWith(ActConstant.PROCESS_DEFKEY_BUSINESS_PURCHASE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断两个节点间顺序
|
||||
*
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
<div class="pull-right">
|
||||
<button type="button" class="btn" ng-click="close()" ng-disabled="status.loading" translate>ACTION.CANCEL</button>
|
||||
<button class="btn btn-primary" ng-click="saveAndClose()" ng-disabled="status.loading" ng-show="!error" translate>ACTION.SAVE-AND-CLOSE</button>
|
||||
<!--<button class="btn btn-primary" ng-click="saveAndClose()" ng-disabled="status.loading" ng-show="!error" translate>ACTION.SAVE-AND-CLOSE</button>-->
|
||||
<button class="btn btn-primary" ng-click="save()" ng-disabled="status.loading" ng-show="!error" translate>ACTION.SAVE</button>
|
||||
</div>
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -74,7 +74,9 @@
|
|||
<td>
|
||||
<div class="am-btn-toolbar">
|
||||
<div class="am-btn-group am-btn-group-xs">
|
||||
<#if userName! == 'admin'>
|
||||
<#if list.procDefKey == 'saleContract'
|
||||
|| list.procDefKey == 'businessPurchase'
|
||||
>
|
||||
<button type="button"
|
||||
class="am-btn am-btn-default am-btn-xs am-text-secondary"
|
||||
onclick="design(${list.id?c})" >
|
||||
|
|
|
@ -18,9 +18,10 @@
|
|||
<tr class="am-text-nowrap">
|
||||
<th class="table-title">序号</th>
|
||||
<th class="table-title">任务节点名称</th>
|
||||
<th class="table-date">回退任务节点</th>
|
||||
<#-- <th class="table-date">回退任务节点</th>-->
|
||||
<th class="table-set ">按人员设置审批人</th>
|
||||
<th class="table-set ">按角色设置审批人</th>
|
||||
<th class="table-set ">按类型设置审批人</th>
|
||||
<th class="table-set am-text-center">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -31,7 +32,7 @@
|
|||
<td>${list_index+1}</td>
|
||||
<td>${list.taskName!}</td>
|
||||
|
||||
<td>
|
||||
<#-- <td>
|
||||
|
||||
<select data-am-selected="{btnSize: 'sm',btnWidth: '150px', maxHeight: 500}"
|
||||
id="rollbackTask_${list.id}">
|
||||
|
@ -41,7 +42,7 @@
|
|||
</#list>
|
||||
</select>
|
||||
|
||||
</td>
|
||||
</td>-->
|
||||
|
||||
<td>
|
||||
|
||||
|
@ -70,6 +71,16 @@
|
|||
|
||||
</td>
|
||||
|
||||
<td>
|
||||
|
||||
<select multiple
|
||||
data-am-selected="{btnSize: 'sm',btnWidth: '150px',maxHeight: 500,searchBox: 1}"
|
||||
id="typeSelect_${list.id}">
|
||||
<option value="1" <#if list.candidateTypeList?seq_contains('1')>selected</#if> >发起人部门主管</option>
|
||||
</select>
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
|
||||
|
@ -137,6 +148,16 @@
|
|||
}
|
||||
});
|
||||
|
||||
var $typeSelected = $("#typeSelect_" + taskId + " option:selected");
|
||||
var typeIds = '';
|
||||
$typeSelected.each(function () {
|
||||
if (typeIds == '') {
|
||||
typeIds = $(this).val();
|
||||
} else {
|
||||
typeIds = typeIds + "#" + $(this).val();
|
||||
}
|
||||
});
|
||||
|
||||
var params = {
|
||||
id: taskId,
|
||||
procDefId: $("#procDefId").val(),
|
||||
|
@ -144,7 +165,8 @@
|
|||
endScript: endScript,
|
||||
rollbackScript: rollbackScript,
|
||||
candidateUsers: userIds,
|
||||
candidateRoles: roleIds
|
||||
candidateRoles: roleIds,
|
||||
candidateTypes: typeIds
|
||||
};
|
||||
$.ajax({
|
||||
url: '${base}/actTaskDef/saveConfig',
|
||||
|
|
Loading…
Reference in New Issue