From 0d61b9bfca526e9c3da2209de8f9f367e76fd013 Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期四, 18 九月 2025 18:09:35 +0800
Subject: [PATCH] 修改constant类名

---
 blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/service/FlowBusinessService.java |  126 ++++++++++++++++++++++++++----------------
 1 files changed, 78 insertions(+), 48 deletions(-)

diff --git a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/service/FlowBusinessService.java b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/service/FlowBusinessService.java
index 5b8613e..0e78703 100644
--- a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/service/FlowBusinessService.java
+++ b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/service/FlowBusinessService.java
@@ -18,13 +18,15 @@
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.*;
 
-import org.springblade.mdm.flow.constants.FlowContants;
+import org.springblade.mdm.basesetting.machine.entity.Machine;
+import org.springblade.mdm.basesetting.machine.service.MachineService;
+import org.springblade.mdm.commons.service.ParamService;
+import org.springblade.mdm.flow.constants.FlowVariableConstant;
 import org.springblade.mdm.flow.entity.FlowProgramFile;
 import org.springblade.mdm.flow.entity.MdmFlowProcess;
 import org.springblade.mdm.flow.util.MdmFlowCache;
 import org.springblade.mdm.flow.vo.FlowVO;
-import org.springblade.mdm.program.service.NcProgramService;
-import org.springblade.mdm.program.service.ProcessProgRefService;
+import org.springblade.mdm.flow.vo.TodoQueryVO;
 import org.springblade.system.feign.IUserClient;
 import org.springblade.system.pojo.entity.User;
 import org.springframework.stereotype.Service;
@@ -36,7 +38,7 @@
 /**
  * 娴佺▼涓氬姟瀹炵幇绫�
  *
- * @author Chill
+ * @author yangys
  */
 @Service
 @AllArgsConstructor
@@ -46,6 +48,8 @@
 	private final HistoryService historyService;
 	private final IUserClient userClient;
 	private final FlowProgramFileService flowProgramFileService;
+	private final ParamService paramService;
+	private final MachineService machineService;
 	/**
 	 * 鏌ヨ鎴戠殑娴佺▼(涓汉寰呭姙鍒楄〃)
 	 * @param page 鍒嗛〉淇℃伅
@@ -54,21 +58,47 @@
 	 * @param keyword 鏌ヨ鍏抽敭瀛�
 	 * @return
 	 */
-	public IPage<FlowVO> selectTodoPage(IPage<FlowVO> page, LocalDateTime createTimeBegin, LocalDateTime createTimeEnd, String keyword) {
+	public IPage<FlowVO> selectTodoPage(IPage<FlowVO> page, TodoQueryVO queryVO) {//LocalDateTime createTimeBegin, LocalDateTime createTimeEnd, String keyword
 		//String taskUser = TaskUtil.getTaskUser();
 		String userId = "" + AuthUtil.getUserId();
 		List<FlowVO> flowList = new LinkedList<>();
 
 		TaskQuery todoQuery = taskService.createTaskQuery().taskAssignee(userId).active().includeProcessVariables();
-		if (Func.isNotEmpty(createTimeBegin)) {
-			todoQuery.taskCreatedAfter(DateUtil.toDate(createTimeBegin));
+
+		if(queryVO.getMachineSpec() != null){
+			if(queryVO.getMachineSpec().length==1) {//2涓负鍏ㄩ��
+				//鏌ヨ杞﹀簥浠g爜闆嗗悎
+				String turnVal = paramService.turninngValue();
+				List<Machine> machines = machineService.lambdaQuery().eq(Machine::getMachineSpec, turnVal).eq(Machine::getStatus, Machine.STATUS_ENABLE).list();
+				List<String> turnMachineCodes = machines.stream().map(Machine::getCode).toList();
+
+				List<String> specs = Arrays.asList(queryVO.getMachineSpec());
+				if (specs.contains("1")) {
+					//杞﹀簥
+					todoQuery.or();
+					for (String mCode : turnMachineCodes) {
+						todoQuery.processVariableValueEquals(FlowVariableConstant.MACHINE_CODE, mCode);
+					}
+					todoQuery.endOr();
+				} else {
+					//鍔犲伐涓績
+					todoQuery.or();
+					for (String mCode : turnMachineCodes) {
+						todoQuery.processVariableValueNotEquals(FlowVariableConstant.MACHINE_CODE, mCode);
+					}
+					todoQuery.endOr();
+				}
+			}
 		}
-		if (Func.isNotEmpty(createTimeEnd)) {
-			todoQuery.taskCreatedBefore(DateUtil.toDate(createTimeEnd));
-			//todoQuery.taskInProgressStartTimeBefore(DateUtil.toDate(createTimeEnd));
+
+		if (Func.isNotEmpty(queryVO.getCreateTimeBegin())) {
+			todoQuery.taskCreatedAfter(DateUtil.toDate(queryVO.getCreateTimeBegin()));
 		}
-		if (Func.isNotEmpty(keyword)) {
-			addKeywordCondition(todoQuery, keyword);
+		if (Func.isNotEmpty(queryVO.getCreateTimeEnd())) {
+			todoQuery.taskCreatedBefore(DateUtil.toDate(queryVO.getCreateTimeEnd()));
+		}
+		if (Func.isNotEmpty(queryVO.getKeyword())) {
+			addKeywordCondition(todoQuery, queryVO.getKeyword());
 		}
 
 		todoQuery.orderByTaskCreateTime().desc();
@@ -92,13 +122,13 @@
 		if(Func.isNotEmpty(keyword)) {
 			String likeVal = "%" + keyword + "%";
 			todoQuery.or();
-			todoQuery.processVariableValueLike(FlowContants.TITLE,likeVal);
-			todoQuery.processVariableValueLike(FlowContants.PROCESS_NO, likeVal);
-			todoQuery.processVariableValueLike(FlowContants.MACHINE_CODE, likeVal);
-			todoQuery.processVariableValueLike(FlowContants.MACHINE_MODE, likeVal);
-			todoQuery.processVariableValueLike(FlowContants.PROCESS_NAME, likeVal);
-			todoQuery.processVariableValueLike(FlowContants.PROCESS_EDITION, likeVal);
-			todoQuery.processVariableValueLike(FlowContants.CRAFT_EDITION, likeVal);
+			todoQuery.processVariableValueLike(FlowVariableConstant.TITLE,likeVal);
+			todoQuery.processVariableValueLike(FlowVariableConstant.PROCESS_NO, likeVal);
+			todoQuery.processVariableValueLike(FlowVariableConstant.MACHINE_CODE, likeVal);
+			todoQuery.processVariableValueLike(FlowVariableConstant.MACHINE_MODE, likeVal);
+			todoQuery.processVariableValueLike(FlowVariableConstant.PROCESS_NAME, likeVal);
+			todoQuery.processVariableValueLike(FlowVariableConstant.PROCESS_EDITION, likeVal);
+			todoQuery.processVariableValueLike(FlowVariableConstant.CRAFT_EDITION, likeVal);
 
 			todoQuery.processDefinitionNameLike(likeVal);
 			todoQuery.endOr();
@@ -156,7 +186,6 @@
 			if(ru.isSuccess()) {
 				flow.setStartUserName(ru.getData().getName());
 			}
-			;
 			List<Comment> comments = lastStepComments(task);//taskService.getTaskComments(task.getId());
 			if(!comments.isEmpty()){
 				flow.setComment(comments.get(0).getFullMessage());
@@ -203,15 +232,7 @@
 			return Collections.emptyList();
 		}
 	}
-	/**
-	 * 鑾峰彇鍘嗗彶娴佺▼
-	 *
-	 * @param processInstanceId 娴佺▼瀹炰緥id
-	 * @return HistoricProcessInstance
-	 */
-	private HistoricProcessInstance getHistoricProcessInstance(String processInstanceId) {
-		return historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
-	}
+
 
 	public IPage<FlowVO> selectAllTaskPage(IPage<FlowVO> page, String keyword) {
 
@@ -298,7 +319,7 @@
 			taskQuery.taskCreatedBefore(DateUtil.toDate(createTimeEnd.plusDays(1)));
 		}
 		if(Func.isNotEmpty(myProcessName)) {
-			taskQuery.processVariableValueEquals(FlowContants.MY_PROCESS_NAME, myProcessName);
+			taskQuery.processVariableValueEquals(FlowVariableConstant.MY_PROCESS_NAME, myProcessName);
 		}
 
 		addKeywordCondition(taskQuery, keyword);
@@ -335,7 +356,7 @@
 		HistoricProcessInstanceQuery query = this.historyService.createHistoricProcessInstanceQuery().finished().includeProcessVariables();
 			//.finished() // 鍙煡璇㈠凡瀹屾垚鐨勬祦绋�.unfinished() // 鏌ヨ鏈畬鎴愮殑娴佺▼
 		if(Func.isNotEmpty(myProcessName)) {
-			query.variableValueEquals(FlowContants.MY_PROCESS_NAME, myProcessName);
+			query.variableValueEquals(FlowVariableConstant.MY_PROCESS_NAME, myProcessName);
 		}
 		if(createTimeBegin!=null) {
 			query.startedAfter(DateUtil.toDate(createTimeBegin));
@@ -346,13 +367,13 @@
 		if(Func.isNotEmpty(keyword)) {
 			String likeVal = "%" + keyword + "%";
 			query.or();
-			query.variableValueLike(FlowContants.TITLE,likeVal);
-			query.variableValueLike(FlowContants.PROCESS_NO, likeVal);
-			query.variableValueLike(FlowContants.MACHINE_CODE, likeVal);
-			query.variableValueLike(FlowContants.MACHINE_MODE, likeVal);
-			query.variableValueLike(FlowContants.PROCESS_NAME, likeVal);
-			query.variableValueLike(FlowContants.PROCESS_EDITION, likeVal);
-			query.variableValueLike(FlowContants.CRAFT_EDITION, likeVal);
+			query.variableValueLike(FlowVariableConstant.TITLE,likeVal);
+			query.variableValueLike(FlowVariableConstant.PROCESS_NO, likeVal);
+			query.variableValueLike(FlowVariableConstant.MACHINE_CODE, likeVal);
+			query.variableValueLike(FlowVariableConstant.MACHINE_MODE, likeVal);
+			query.variableValueLike(FlowVariableConstant.PROCESS_NAME, likeVal);
+			query.variableValueLike(FlowVariableConstant.PROCESS_EDITION, likeVal);
+			query.variableValueLike(FlowVariableConstant.CRAFT_EDITION, likeVal);
 
 			query.endOr();
 		}
@@ -376,6 +397,11 @@
 
 			vo.setProcessCreateTime(processInstance.getStartTime());
 			vo.setHistoryTaskEndTime(processInstance.getEndTime());
+
+			R<User> ru = userClient.userInfoById(Long.valueOf(processInstance.getStartUserId()));
+			if(ru.isSuccess()) {
+				vo.setStartUserName(ru.getData().getName());
+			}
 
 			vo.setFile(getFileString(processInstance.getId()));
 			records.add(vo);
@@ -399,9 +425,9 @@
 		HistoricProcessInstanceQuery query = this.historyService.createHistoricProcessInstanceQuery().finished().includeProcessVariables();
 		//.finished() // 鍙煡璇㈠凡瀹屾垚鐨勬祦绋�.unfinished() // 鏌ヨ鏈畬鎴愮殑娴佺▼
 
-		query.variableValueEquals(FlowContants.EXCEPTION, "1");
+		query.variableValueEquals(FlowVariableConstant.EXCEPTION, "1");
 		if(Func.isNotEmpty(myProcessName)) {
-			query.variableValueEquals(FlowContants.MY_PROCESS_NAME, myProcessName);
+			query.variableValueEquals(FlowVariableConstant.MY_PROCESS_NAME, myProcessName);
 		}
 		if(createTimeBegin!=null) {
 			query.startedAfter(DateUtil.toDate(createTimeBegin));
@@ -412,13 +438,13 @@
 		if(Func.isNotEmpty(keyword)) {
 			String likeVal = "%" + keyword + "%";
 			query.or();
-			query.variableValueLike(FlowContants.TITLE,likeVal);
-			query.variableValueLike(FlowContants.PROCESS_NO, likeVal);
-			query.variableValueLike(FlowContants.MACHINE_CODE, likeVal);
-			query.variableValueLike(FlowContants.MACHINE_MODE, likeVal);
-			query.variableValueLike(FlowContants.PROCESS_NAME, likeVal);
-			query.variableValueLike(FlowContants.PROCESS_EDITION, likeVal);
-			query.variableValueLike(FlowContants.CRAFT_EDITION, likeVal);
+			query.variableValueLike(FlowVariableConstant.TITLE,likeVal);
+			query.variableValueLike(FlowVariableConstant.PROCESS_NO, likeVal);
+			query.variableValueLike(FlowVariableConstant.MACHINE_CODE, likeVal);
+			query.variableValueLike(FlowVariableConstant.MACHINE_MODE, likeVal);
+			query.variableValueLike(FlowVariableConstant.PROCESS_NAME, likeVal);
+			query.variableValueLike(FlowVariableConstant.PROCESS_EDITION, likeVal);
+			query.variableValueLike(FlowVariableConstant.CRAFT_EDITION, likeVal);
 
 			query.endOr();
 		}
@@ -442,7 +468,10 @@
 
 			vo.setProcessCreateTime(processInstance.getStartTime());
 			vo.setHistoryTaskEndTime(processInstance.getEndTime());
-
+			R<User> ru = userClient.userInfoById(Long.valueOf(processInstance.getStartUserId()));
+			if(ru.isSuccess()) {
+				vo.setStartUserName(ru.getData().getName());
+			}
 			vo.setFile(getFileString(processInstance.getId()));
 			records.add(vo);
 		}
@@ -550,4 +579,5 @@
 
 		return page;
 	}
+
 }

--
Gitblit v1.9.3