bug liucheng

This commit is contained in:
Timer
2026-04-04 01:17:13 +08:00
parent 9cc4d4a988
commit 785654a510
11 changed files with 597 additions and 519 deletions

View File

@ -483,6 +483,7 @@ public class ActivitiController {
String passFlag = request.getParameter("passFlag"); String passFlag = request.getParameter("passFlag");
if (passFlag != null && !passFlag.isEmpty()) { if (passFlag != null && !passFlag.isEmpty()) {
boolean pFlag = Boolean.parseBoolean(passFlag); boolean pFlag = Boolean.parseBoolean(passFlag);
int totalCount = list.size();
Iterator<WorkTask> iterator = list.iterator(); Iterator<WorkTask> iterator = list.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
WorkTask workTask = (WorkTask) iterator.next(); WorkTask workTask = (WorkTask) iterator.next();
@ -491,6 +492,10 @@ public class ActivitiController {
} }
} }
// 当 passFlag=false 过滤后返回空列表(即未识别到退回路径),则作为备用方案返回全部路径
if (list.isEmpty() && !pFlag && totalCount > 0) {
list = workflowProcessDefinitionService.getNextWorkTasks(task.getProcessDefinitionId(), task.getTaskDefinitionKey());
}
JSONArray jsonArray = new JSONArray(); JSONArray jsonArray = new JSONArray();
if (list != null && list.size() > 0) { if (list != null && list.size() > 0) {
for (WorkTask workTask : list) { for (WorkTask workTask : list) {

View File

@ -37,6 +37,7 @@ import org.activiti.engine.history.HistoricTaskInstance;
import org.activiti.engine.impl.pvm.process.ActivityImpl; import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.runtime.ProcessInstance; import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task; import org.activiti.engine.task.Task;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model; import org.springframework.ui.Model;
@ -356,7 +357,9 @@ public class MaintenancePlanController {
model.addAttribute("nowDate", CommUtil.nowDate()); model.addAttribute("nowDate", CommUtil.nowDate());
String maintenancePlanId = pInstance.getBusinessKey(); String maintenancePlanId = pInstance.getBusinessKey();
List<BusinessUnitAudit> list = this.businessUnitAuditService.selectListByWhere("where businessId = '" + maintenancePlanId + "' order by insdt desc "); List<BusinessUnitAudit> list = this.businessUnitAuditService.selectListByWhere("where businessId = '" + maintenancePlanId + "' order by insdt desc ");
if (CollectionUtils.isNotEmpty(list)){
model.addAttribute("businessUnitAudit", list.get(0)); model.addAttribute("businessUnitAudit", list.get(0));
}
MaintenancePlan maintenancePlan = this.maintenancePlanService.selectById(maintenancePlanId); MaintenancePlan maintenancePlan = this.maintenancePlanService.selectById(maintenancePlanId);
model.addAttribute("maintenancePlan", maintenancePlan); model.addAttribute("maintenancePlan", maintenancePlan);
EquipmentPlan equipmentPlan = this.equipmentPlanService.selectById(maintenancePlanId); EquipmentPlan equipmentPlan = this.equipmentPlanService.selectById(maintenancePlanId);

View File

@ -181,8 +181,8 @@ public class SafetyCheckComprehensiveController {
SafetyCheckStatusEnum.RESPONSE.getTaskTitle(), SafetyCheckStatusEnum.RESPONSE.getTaskTitle(),
bean.getDutyUserId(), // 当前节点审批人 bean.getDutyUserId(), // 当前节点审批人
bean.getDutyUserName(), // 当前节点审批人 bean.getDutyUserName(), // 当前节点审批人
null, // 抄送人 bean.getCopyUserId(), // 抄送人
null,// 抄送人 bean.getCopyUserName(),// 抄送人
null); null);
} }
return Result.success(); return Result.success();

View File

@ -236,8 +236,8 @@ public class SafetyCheckDaylyController {
SafetyCheckStatusEnum.RESPONSE.getTaskTitle(), SafetyCheckStatusEnum.RESPONSE.getTaskTitle(),
bean.getDutyUserId(), // 当前节点审批人 bean.getDutyUserId(), // 当前节点审批人
bean.getDutyUserName(), // 当前节点审批人 bean.getDutyUserName(), // 当前节点审批人
null, // 抄送人 bean.getCopyUserId(), // 抄送人
null,// 抄送人 bean.getCopyUserName(),// 抄送人
null); null);
} }

View File

@ -197,8 +197,8 @@ public class SafetyCheckSpecialController {
SafetyCheckStatusEnum.RESPONSE.getTaskTitle(), SafetyCheckStatusEnum.RESPONSE.getTaskTitle(),
bean.getDutyUserId(), // 当前节点审批人 bean.getDutyUserId(), // 当前节点审批人
bean.getDutyUserName(), // 当前节点审批人 bean.getDutyUserName(), // 当前节点审批人
null, // 抄送人 bean.getCopyUserId(), // 抄送人
null,// 抄送人 bean.getCopyUserName(),// 抄送人
null); null);
} }
return Result.success(); return Result.success();

View File

@ -362,9 +362,22 @@ public class WorkflowProcessDefinitionService {
String pvmTransitionId = ""; String pvmTransitionId = "";
for (WorkTask workTask : list) { for (WorkTask workTask : list) {
PvmTransition item=this.getTransition(processDefId, taskDefId,workTask.getId(),pvmTransitionId); PvmTransition item=this.getTransition(processDefId, taskDefId,workTask.getId(),pvmTransitionId);
if (item == null) {
// 未找到对应路径时默认标记为通过路径,继续处理其他任务
workTask.setPassFlag(true);
continue;
}
pvmTransitionId = item.getId(); pvmTransitionId = item.getId();
String conditionText=String.valueOf(item.getProperty("conditionText")); String conditionText=String.valueOf(item.getProperty("conditionText"));
if (conditionText!=null && conditionText.contains("!"+CommString.ACTI_KEK_Condition)) { // 检测退回路径:支持多种条件表达式格式
// ${!pass} / ${pass == false} / ${pass==false} / ${pass != true} / ${pass!=true}
boolean isRejectPath = conditionText != null && (
conditionText.contains("!"+CommString.ACTI_KEK_Condition) ||
conditionText.contains(CommString.ACTI_KEK_Condition+" == false") ||
conditionText.contains(CommString.ACTI_KEK_Condition+"==false") ||
conditionText.contains(CommString.ACTI_KEK_Condition+" != true") ||
conditionText.contains(CommString.ACTI_KEK_Condition+"!=true"));
if (isRejectPath) {
workTask.setPassFlag(false); workTask.setPassFlag(false);
}else{ }else{
workTask.setPassFlag(true); workTask.setPassFlag(true);

View File

@ -62,10 +62,9 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
@Component @Component
public class WorkflowService { public class WorkflowService {
@ -174,14 +173,21 @@ public class WorkflowService {
} }
return processInstance; return processInstance;
} }
/**删除运行中流程*/
/**
* 删除运行中流程
*/
public void delProcessInstance(String processInstanceId) { public void delProcessInstance(String processInstanceId) {
runtimeService.deleteProcessInstance(processInstanceId, ""); runtimeService.deleteProcessInstance(processInstanceId, "");
} }
/**删除历史流程*/
/**
* 删除历史流程
*/
public void delHistoryInstance(String processInstanceId) { public void delHistoryInstance(String processInstanceId) {
historyService.deleteHistoricProcessInstance(processInstanceId); historyService.deleteHistoricProcessInstance(processInstanceId);
} }
/** /**
* 读取运行中的流程 * 读取运行中的流程
* *
@ -227,7 +233,8 @@ public class WorkflowService {
results.add(todoTask); results.add(todoTask);
} }
page.setTotalCount(query.count());; page.setTotalCount(query.count());
;
page.setResult(results); page.setResult(results);
return results; return results;
} }
@ -278,6 +285,7 @@ public class WorkflowService {
return taskInstance; return taskInstance;
} }
/** /**
* 查询待办任务 * 查询待办任务
* *
@ -570,8 +578,7 @@ public class WorkflowService {
} }
maintenance.setStatus(todoTask.getTask().getDescription()); maintenance.setStatus(todoTask.getTask().getDescription());
todoTask.setBusiness(maintenance); todoTask.setBusiness(maintenance);
} } else if (todoTask.getType().contains(ProcessType.Repair_Plan.getId())) {
else if(todoTask.getType().contains(ProcessType.Repair_Plan.getId())){
//之前老的单条计划 //之前老的单条计划
/*EquipmentRepairPlan maintenancePlan = this.equipmentRepairPlanService.selectById(businessKey); /*EquipmentRepairPlan maintenancePlan = this.equipmentRepairPlanService.selectById(businessKey);
maintenance=new Maintenance(); maintenance=new Maintenance();
@ -596,8 +603,7 @@ public class WorkflowService {
} }
maintenance.setStatus(todoTask.getTask().getDescription()); maintenance.setStatus(todoTask.getTask().getDescription());
todoTask.setBusiness(maintenance); todoTask.setBusiness(maintenance);
} } else if (todoTask.getType().contains(ProcessType.Lose_Apply.getId())) {
else if(todoTask.getType().contains(ProcessType.Lose_Apply.getId())){
EquipmentLoseApply loseApply = this.equipmentLoseApplyService.selectById(businessKey); EquipmentLoseApply loseApply = this.equipmentLoseApplyService.selectById(businessKey);
maintenance = new Maintenance(); maintenance = new Maintenance();
Company company = unitService.getCompById(loseApply.getBizId()); Company company = unitService.getCompById(loseApply.getBizId());
@ -719,8 +725,7 @@ public class WorkflowService {
maintenance.setProblem(overhaul.getProjectDescribe()); maintenance.setProblem(overhaul.getProjectDescribe());
maintenance.setStatus(todoTask.getTask().getDescription()); maintenance.setStatus(todoTask.getTask().getDescription());
todoTask.setBusiness(maintenance); todoTask.setBusiness(maintenance);
} } else if (todoTask.getType().contains(ProcessType.Report_Check.getId())) {
else if(todoTask.getType().contains(ProcessType.Report_Check.getId())){
RptCreate rptCreate = rptCreateService.selectById(businessKey); RptCreate rptCreate = rptCreateService.selectById(businessKey);
maintenance = new Maintenance(); maintenance = new Maintenance();
if (rptCreate != null) { if (rptCreate != null) {
@ -915,6 +920,7 @@ public class WorkflowService {
results.put("rows", json); results.put("rows", json);
return results; return results;
} }
/** /**
* 查询待办任务 * 查询待办任务
* *
@ -1055,9 +1061,10 @@ public class WorkflowService {
} }
return (TodoTask) todoTask.clone(); return (TodoTask) todoTask.clone();
} }
/** /**
*
* 根据运维单获取流程任务 * 根据运维单获取流程任务
*
* @param * @param
* @param * @param
* @return * @return
@ -1111,9 +1118,10 @@ public class WorkflowService {
return todoTask; return todoTask;
} }
/** /**
*
* 根据运维详情获取流程任务 * 根据运维详情获取流程任务
*
* @param * @param
* @param * @param
* @return * @return
@ -1224,6 +1232,7 @@ public class WorkflowService {
return todoTask; return todoTask;
} }
/** /**
* 查询任务comment * 查询任务comment
* *
@ -1260,6 +1269,7 @@ public class WorkflowService {
return list; return list;
} }
/** /**
* 查询已处理任务列表。 * 查询已处理任务列表。
* *
@ -1320,6 +1330,7 @@ public class WorkflowService {
} }
return leaveTasks; return leaveTasks;
} }
public JSONArray todoTasklistToJsonArray(List list) { public JSONArray todoTasklistToJsonArray(List list) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
JSONArray json = new JSONArray(); JSONArray json = new JSONArray();
@ -1388,6 +1399,7 @@ public class WorkflowService {
sdf = null; sdf = null;
return json; return json;
} }
public JSONArray doneTasklistToJsonArray(List list) { public JSONArray doneTasklistToJsonArray(List list) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
JSONArray json = new JSONArray(); JSONArray json = new JSONArray();
@ -1465,6 +1477,7 @@ public class WorkflowService {
sdf = null; sdf = null;
return json; return json;
} }
/** /**
* 查询已完成流程。 * 查询已完成流程。
* *
@ -1500,6 +1513,7 @@ public class WorkflowService {
} }
return result; return result;
} }
/** /**
* 查询流程定义对象 * 查询流程定义对象
* *
@ -1531,21 +1545,27 @@ public class WorkflowService {
public void setRepositoryService(RepositoryService repositoryService) { public void setRepositoryService(RepositoryService repositoryService) {
this.repositoryService = repositoryService; this.repositoryService = repositoryService;
} }
public IdentityService getIdentityService() { public IdentityService getIdentityService() {
return identityService; return identityService;
} }
public void setIdentityService(IdentityService identityService) { public void setIdentityService(IdentityService identityService) {
this.identityService = identityService; this.identityService = identityService;
} }
public RuntimeService getRuntimeService() { public RuntimeService getRuntimeService() {
return runtimeService; return runtimeService;
} }
public TaskService getTaskService() { public TaskService getTaskService() {
return taskService; return taskService;
} }
public HistoryService getHistoryService() { public HistoryService getHistoryService() {
return historyService; return historyService;
} }
public RepositoryService getRepositoryService() { public RepositoryService getRepositoryService() {
return repositoryService; return repositoryService;
} }

View File

@ -112,17 +112,24 @@ public class BusinessUnitAuditService implements CommService<BusinessUnitAudit>{
} }
List<HistoricActivityInstance> list=historyService.createHistoricActivityInstanceQuery().processInstanceId(entity.getProcessid()).activityId(wortTaskId) List<HistoricActivityInstance> list=historyService.createHistoricActivityInstanceQuery().processInstanceId(entity.getProcessid()).activityId(wortTaskId)
.orderByHistoricActivityInstanceStartTime().desc().list(); .orderByHistoricActivityInstanceStartTime().desc().list();
// 优先取历史记录中的 assignee若 assignee 为空(候选人任务未签收),则查 BusinessUnitAudit 记录获取实际提交人
String targetAssignee = null;
if (list != null && list.size() > 0) { if (list != null && list.size() > 0) {
variables.put(CommString.ACTI_KEK_Assignee, list.get(0).getAssignee()); targetAssignee = list.get(0).getAssignee();
}
if (targetAssignee == null && !wortTaskId.isEmpty()) {
// 历史 assignee 为空时,从 BusinessUnitAudit 记录中查找该步骤的实际提交人
List<BusinessUnitAudit> previousAuditList = this.selectListByWhere(
"where businessid='" + entity.getBusinessid() + "' and taskdefinitionkey='" + wortTaskId + "' order by insdt desc");
if (previousAuditList != null && previousAuditList.size() > 0) {
targetAssignee = previousAuditList.get(0).getInsuser();
}
}
// 设置退回目标处理人(若仍为空则由流程变量 userIds 确定候选人,不再回退到工单创建人)
variables.put(CommString.ACTI_KEK_Assignee, targetAssignee);
if(entity.getAuditopinion()!=null && !entity.getAuditopinion().isEmpty()){ if(entity.getAuditopinion()!=null && !entity.getAuditopinion().isEmpty()){
taskService.addComment(entity.getTaskid(), entity.getProcessid(), entity.getAuditopinion()); taskService.addComment(entity.getTaskid(), entity.getProcessid(), entity.getAuditopinion());
} }
}else {
variables.put(CommString.ACTI_KEK_Assignee, businessUnitAdapter.getInsuser());
if(entity.getAuditopinion()!=null && !entity.getAuditopinion().isEmpty()){
taskService.addComment(entity.getTaskid(), entity.getProcessid(), entity.getAuditopinion());
}
}
} }
//int res=0; //int res=0;
taskService.complete(entity.getTaskid(), variables); taskService.complete(entity.getTaskid(), variables);
@ -141,15 +148,22 @@ public class BusinessUnitAuditService implements CommService<BusinessUnitAudit>{
BusinessUnitRecord businessUnitRecord = new BusinessUnitRecord(entity); BusinessUnitRecord businessUnitRecord = new BusinessUnitRecord(entity);
if(entity.getPassstatus()){ if(entity.getPassstatus()){
//通过 //通过
if(variables.get(CommString.ACTI_KEK_Candidate_Users)!=null){ String candidateUsers = variables.get(CommString.ACTI_KEK_Candidate_Users) != null
businessUnitRecord.sendMessage(variables.get(CommString.ACTI_KEK_Candidate_Users).toString(),""); ? variables.get(CommString.ACTI_KEK_Candidate_Users).toString() : null;
}else{ if(candidateUsers != null && !candidateUsers.isEmpty()){
// 有下一步接收人,通知下一步处理人
businessUnitRecord.sendMessage(candidateUsers, "");
}else if(variables.get(CommString.ACTI_KEK_AssigneeList) != null){
// 会签 // 会签
if(variables.get(CommString.ACTI_KEK_AssigneeList)!=null){
businessUnitRecord.sendMessage(entity.getTargetusers(), ""); businessUnitRecord.sendMessage(entity.getTargetusers(), "");
}else{
// 最后一步,无下一步处理人,通知当前提交人(完成确认)
if(entity.getInsuser() != null && !entity.getInsuser().isEmpty()){
businessUnitRecord.sendMessage(entity.getInsuser(), "");
} }
} }
}else{ }else{
// 退回:通知目标处理人(排除空值,避免错误发送)
if(variables.get(CommString.ACTI_KEK_Assignee) != null){ if(variables.get(CommString.ACTI_KEK_Assignee) != null){
businessUnitRecord.sendMessage(variables.get(CommString.ACTI_KEK_Assignee).toString(), ""); businessUnitRecord.sendMessage(variables.get(CommString.ACTI_KEK_Assignee).toString(), "");
} }

View File

@ -47,11 +47,22 @@ public class SafetyCheckActivityService {
if (processDefinitions == null || processDefinitions.size() == 0) { if (processDefinitions == null || processDefinitions.size() == 0) {
return Result.failed(company.getName() + "缺少该流程定义。"); return Result.failed(company.getName() + "缺少该流程定义。");
} }
// 防止重复发起:若该业务已有运行中的流程实例,则跳过,避免创建双倍待办任务
List<org.activiti.engine.runtime.ProcessInstance> existingInstances = workflowService.getRuntimeService()
.createProcessInstanceQuery()
.processDefinitionKey(processKey)
.processInstanceBusinessKey(bizId)
.active()
.list();
if (existingInstances != null && !existingInstances.isEmpty()) {
return Result.success();
}
// 启动流程实例 // 启动流程实例
// 设置网关条件 // 设置网关条件
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put(CommString.ACTI_KEK_Condition, 1); map.put(CommString.ACTI_KEK_Condition, 1);
map.put(CommString.ACTI_KEK_Assignee, applyUserId); map.put(CommString.ACTI_KEK_Assignee, applyUserId);
map.put(CommString.ACTI_KEK_Candidate_Users, "");
// 启动流程 // 启动流程
ProcessInstance processInstance = workflowService.startWorkflow( ProcessInstance processInstance = workflowService.startWorkflow(
@ -70,6 +81,7 @@ public class SafetyCheckActivityService {
Map<String, Object> map2 = new HashMap<>(); Map<String, Object> map2 = new HashMap<>();
map2.put(CommString.ACTI_KEK_Condition, 1); map2.put(CommString.ACTI_KEK_Condition, 1);
map2.put(CommString.ACTI_KEK_Assignee, nextUserId); map2.put(CommString.ACTI_KEK_Assignee, nextUserId);
map2.put(CommString.ACTI_KEK_Candidate_Users, "");
workflowService.getTaskService().complete(task.getId(), map2); workflowService.getTaskService().complete(task.getId(), map2);
return Result.success(); return Result.success();
@ -89,9 +101,9 @@ public class SafetyCheckActivityService {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put(CommString.ACTI_KEK_Condition, pass); map.put(CommString.ACTI_KEK_Condition, pass);
map.put(CommString.ACTI_KEK_Assignee, nextUserId); map.put(CommString.ACTI_KEK_Assignee, nextUserId);
for (Task task : tasks) { map.put(CommString.ACTI_KEK_Candidate_Users, "");
workflowService.getTaskService().complete(task.getId(), map); // 只完成第一个任务,防止多任务场景下指数级创建待办(如因重复发起导致有多个并发任务时)
} workflowService.getTaskService().complete(tasks.get(0).getId(), map);
return Result.success(); return Result.success();
} }

View File

@ -101,6 +101,9 @@ public class SafetyFilesService implements CommService<SafetyFiles> {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
List<MultipartFile> files = multipartRequest.getFiles("file"); List<MultipartFile> files = multipartRequest.getFiles("file");
for (MultipartFile mfile : files) { for (MultipartFile mfile : files) {
if (mfile == null || mfile.getSize() == 0) {
continue;
}
String suffix = mfile.getOriginalFilename().substring(mfile.getOriginalFilename().lastIndexOf(".")); String suffix = mfile.getOriginalFilename().substring(mfile.getOriginalFilename().lastIndexOf("."));
//判断保存文件的路径是否存在 //判断保存文件的路径是否存在

View File

@ -346,6 +346,10 @@ var processSelectNodeForHandle = function(taskId){
//选择下一节点,先选择审核结果,再选择节点 //选择下一节点,先选择审核结果,再选择节点
$.post(ext.contextPath + "/activiti/workflow/getRoutesForSelect2.do", {taskId:taskId,passFlag:passFlag}, function(data) { $.post(ext.contextPath + "/activiti/workflow/getRoutesForSelect2.do", {taskId:taskId,passFlag:passFlag}, function(data) {
$("#routeNum").empty(); $("#routeNum").empty();
if (!data || data.length === 0) {
console.warn('getRoutesForSelect2: no routes found for passFlag=' + passFlag);
return;
}
var selelct = $("#routeNum").select2({ var selelct = $("#routeNum").select2({
data: data, data: data,
placeholder:'请先选择审核结果',//默认文字提示 placeholder:'请先选择审核结果',//默认文字提示
@ -374,6 +378,10 @@ var processSelectNodeForHandle = function(taskId){
}) })
selectResult.val('').trigger("change"); selectResult.val('').trigger("change");
$.post(ext.contextPath + "/activiti/workflow/getRoutesForSelect2.do", {taskId:taskId,passFlag:true}, function(data) { $.post(ext.contextPath + "/activiti/workflow/getRoutesForSelect2.do", {taskId:taskId,passFlag:true}, function(data) {
if (!data || data.length === 0) {
console.warn('getRoutesForSelect2: no routes found for passFlag=true');
return;
}
var selelct = $("#routeNum").select2({ var selelct = $("#routeNum").select2({
data: data, data: data,
placeholder:'请先选择审核结果',//默认文字提示 placeholder:'请先选择审核结果',//默认文字提示