From 4a1495ed4cbd1e8ef7305b2cc48a764b66e09280 Mon Sep 17 00:00:00 2001 From: yangys <y_ys79@sina.com> Date: 星期二, 10 六月 2025 23:53:10 +0800 Subject: [PATCH] todo查询 --- blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/excution/AutoAssignUsersService.java | 16 + blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/entity/MdmFlowProcess.java | 74 ++++++ blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/excution/StartDispatcher.java | 18 + blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/controller/MyFlowController.java | 44 ++++ doc/sql/mdm/mdm.all.create.sql | 26 ++ blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/service/FlowBusinessService.java | 347 +++++++++++++++++++++++++++++++ blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/util/MdmFlowCache.java | 90 ++++++++ 7 files changed, 602 insertions(+), 13 deletions(-) diff --git a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/controller/MyFlowController.java b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/controller/MyFlowController.java new file mode 100644 index 0000000..ea3ebd6 --- /dev/null +++ b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/controller/MyFlowController.java @@ -0,0 +1,44 @@ +package org.springblade.mdm.flow.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.TaskService; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.support.Kv; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.StringUtil; +import org.springblade.flow.core.pojo.entity.BladeFlow; +import org.springblade.mdm.flow.excution.StartDispatcher; +import org.springblade.mdm.flow.service.FlowBusinessService; +import org.springblade.mdm.flow.vo.TaskAssignVO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +@Slf4j +@RestController +@RequestMapping("/flow/") +@Tag(name = "娲惧伐娴佺▼", description = "娲惧伐娴佺▼") +public class MyFlowController { + + @Autowired + private FlowBusinessService businessService; + + /** + * 寰呭姙浜嬪姟鍒楄〃椤� + */ + @GetMapping("todo-list") + @ApiOperationSupport(order = 3) + @Operation(summary = "鎴戠殑娴佺▼", description = "浼犲叆娴佺▼淇℃伅") + public R<IPage<BladeFlow>> todoList(@Parameter(description = "鍏抽敭瀛�") String keyword, Query query) { + IPage<BladeFlow> pages = businessService.selectTodoPage(Condition.getPage(query), keyword); + return R.data(pages); + } +} diff --git a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/entity/MdmFlowProcess.java b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/entity/MdmFlowProcess.java new file mode 100644 index 0000000..c794867 --- /dev/null +++ b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/entity/MdmFlowProcess.java @@ -0,0 +1,74 @@ +/** + * BladeX Commercial License Agreement + * Copyright (c) 2018-2099, https://bladex.cn. All rights reserved. + * <p> + * Use of this software is governed by the Commercial License Agreement + * obtained after purchasing a license from BladeX. + * <p> + * 1. This software is for development use only under a valid license + * from BladeX. + * <p> + * 2. Redistribution of this software's source code to any third party + * without a commercial license is strictly prohibited. + * <p> + * 3. Licensees may copyright their own code but cannot use segments + * from this software for such purposes. Copyright of this software + * remains with BladeX. + * <p> + * Using this software signifies agreement to this License, and the software + * must not be used for illegal purposes. + * <p> + * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is + * not liable for any claims arising from secondary or illegal development. + * <p> + * Author: Chill Zhuang (bladejava@qq.com) + */ +package org.springblade.mdm.flow.entity; + +import lombok.Data; +import lombok.NoArgsConstructor; +import org.flowable.engine.impl.persistence.entity.ProcessDefinitionEntityImpl; +import org.springblade.mdm.flow.util.MdmFlowCache; + +import java.io.Serializable; +import java.util.Date; + +/** + * FlowProcess + * + * @author Chill + */ +@Data +@NoArgsConstructor +public class MdmFlowProcess implements Serializable { + + private String id; + private String tenantId; + private String name; + private String key; + private String category; + private String categoryName; + private Integer version; + private String deploymentId; + private String resourceName; + private String diagramResourceName; + private Integer suspensionState; + private Date deploymentTime; + + public MdmFlowProcess(ProcessDefinitionEntityImpl entity) { + if (entity != null) { + this.id = entity.getId(); + this.tenantId = entity.getTenantId(); + this.name = entity.getName(); + this.key = entity.getKey(); + this.category = entity.getCategory(); + this.categoryName = MdmFlowCache.getCategoryName(entity.getCategory()); + this.version = entity.getVersion(); + this.deploymentId = entity.getDeploymentId(); + this.resourceName = entity.getResourceName(); + this.diagramResourceName = entity.getDiagramResourceName(); + this.suspensionState = entity.getSuspensionState(); + } + } + +} diff --git a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/excution/AutoAssignUsersService.java b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/excution/AutoAssignUsersService.java index 281053d..e991055 100644 --- a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/excution/AutoAssignUsersService.java +++ b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/excution/AutoAssignUsersService.java @@ -1,5 +1,8 @@ package org.springblade.mdm.flow.excution; +import org.springblade.mdm.basesetting.produceplan.entity.ProducePlan; +import org.springblade.mdm.basesetting.produceplan.mapper.ProducePlanMapper; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.HashMap; @@ -10,13 +13,16 @@ */ @Service public class AutoAssignUsersService { + @Autowired + private ProducePlanMapper planMapper; - public Map<String,Object> autoAssignUsers(long productPlanId){ + public Map<String,Object> autoAssignUsers(long producePlanId){ + ProducePlan pplan = planMapper.selectById(producePlanId); Map<String,Object> result = new HashMap<String,Object>(); - result.put("teamLeader","zuzhang1"); - result.put("programmer","gongyiyuan1"); - result.put("checker","gongyiyuan2"); - result.put("senior","gaoshi1"); + result.put("teamLeader",pplan.getTeamLeaderId()); + result.put("programmer",pplan.getProgrammerId()); + result.put("checker",pplan.getCheckerId()); + result.put("senior",pplan.getSeniorId()); return result; } } diff --git a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/excution/StartDispatcher.java b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/excution/StartDispatcher.java index 8a7313a..9375533 100644 --- a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/excution/StartDispatcher.java +++ b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/excution/StartDispatcher.java @@ -17,8 +17,7 @@ @Service("startDispatcher") public class StartDispatcher { - @Autowired - private IFlowClient flowClient; + @Autowired private RuntimeService runtimeService; @Autowired @@ -32,12 +31,23 @@ Map<String,Object> preAssignee = autoAssignUsersService.autoAssignUsers(startVO.getProducePlanId()); Map<String, Object> vars = new HashMap<>(preAssignee); + vars.put("machineCode",startVO.getMachineCode()); + vars.put("machineMode",startVO.getMachineMode()); + + vars.put("processNo",startVO.getProcessNo()); + vars.put("processName",startVO.getProcessName()); + vars.put("processEdition",startVO.getProcessEdition()); + + vars.put("craftEdition",startVO.getCraftEdition()); + vars.put("planStartTime",startVO.getPlanStartTime()); + + //vars.put("producePlanId",startVO.getCraftEdition()); + + String businessKey = "0";//涓氬姟琛╧ey identityService.setAuthenticatedUserId(String.valueOf(AuthUtil.getUserId()));//璁剧疆娴佺▼鍙戣捣浜� ProcessInstance pinst = runtimeService.startProcessInstanceByKey(PROCESS_KEY,businessKey,vars); - //R<BladeFlow> flowR = flowClient.startProcessInstanceByKey(PROCESS_KEY,businessKey,vars); - //R<BladeFlow> flowR = flowClient.startProcessInstanceById(PROCESS_KEY,businessKey,vars); int a=1; a =2; 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 new file mode 100644 index 0000000..529e9e8 --- /dev/null +++ b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/service/FlowBusinessService.java @@ -0,0 +1,347 @@ +/** + * BladeX Commercial License Agreement + * Copyright (c) 2018-2099, https://bladex.cn. All rights reserved. + * <p> + * Use of this software is governed by the Commercial License Agreement + * obtained after purchasing a license from BladeX. + * <p> + * 1. This software is for development use only under a valid license + * from BladeX. + * <p> + * 2. Redistribution of this software's source code to any third party + * without a commercial license is strictly prohibited. + * <p> + * 3. Licensees may copyright their own code but cannot use segments + * from this software for such purposes. Copyright of this software + * remains with BladeX. + * <p> + * Using this software signifies agreement to this License, and the software + * must not be used for illegal purposes. + * <p> + * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is + * not liable for any claims arising from secondary or illegal development. + * <p> + * Author: Chill Zhuang (bladejava@qq.com) + */ +package org.springblade.mdm.flow.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import lombok.AllArgsConstructor; +import org.flowable.engine.HistoryService; +import org.flowable.engine.TaskService; +import org.flowable.engine.history.HistoricProcessInstance; +import org.flowable.engine.history.HistoricProcessInstanceQuery; +import org.flowable.task.api.Task; +import org.flowable.task.api.TaskQuery; +import org.flowable.task.api.history.HistoricTaskInstance; +import org.flowable.task.api.history.HistoricTaskInstanceQuery; +import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.core.tool.support.Kv; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.StringPool; +import org.springblade.core.tool.utils.StringUtil; +import org.springblade.flow.core.constant.ProcessConstant; +import org.springblade.flow.core.pojo.entity.BladeFlow; +import org.springblade.flow.core.utils.TaskUtil; + +import org.springblade.mdm.flow.entity.MdmFlowProcess; +import org.springblade.mdm.flow.util.MdmFlowCache; +import org.springframework.stereotype.Service; + +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +/** + * 娴佺▼涓氬姟瀹炵幇绫� + * + * @author Chill + */ +@Service +@AllArgsConstructor +public class FlowBusinessService { + + private final TaskService taskService; + private final HistoryService historyService; + + + public IPage<BladeFlow> selectTodoPage(IPage<BladeFlow> page, String keyword) { + //String taskUser = TaskUtil.getTaskUser(); + String userId = ""+AuthUtil.getUserId(); + List<BladeFlow> flowList = new LinkedList<>(); + + TaskQuery todoQuery = taskService.createTaskQuery().taskAssignee("1930600500876619777").active().includeProcessVariables(); + + if(Func.isNotEmpty(keyword)){ + todoQuery.or(); + + todoQuery.processVariableValueLike("processNo",keyword); + todoQuery.processVariableValueLike("machineCode",keyword); + todoQuery.processVariableValueLike("machineMode",keyword); + + todoQuery.processVariableValueLike("processName",keyword); + todoQuery.processVariableValueLike("processEdition",keyword); + + todoQuery.processVariableValueLike("craftEdition",keyword); + //TODO 澶氫釜瀛楁閮借鍖归厤 + + todoQuery.endOr(); + } + + todoQuery.orderByTaskCreateTime().desc(); + //List<Task> listt = todoQuery.list(); + + // 宸茬鏀剁殑浠诲姟.caseVariableValueLike("processNo",keyword) + /* + TaskQuery todoQuery = taskService.createTaskQuery().taskAssignee(userId).active() + .includeProcessVariables().orderByTaskCreateTime().desc(); + + */ + + // 鏋勫缓鍒楄〃鏁版嵁 + BladeFlow bladeFlow = new BladeFlow(); + buildFlowTaskList(bladeFlow, flowList, todoQuery, "todo");//FlowEngineConstant.STATUS_TODO + + // 璁$畻鎬绘暟 + long count = todoQuery.count(); + // 璁剧疆椤垫暟 + page.setSize(count); + // 璁剧疆鎬绘暟 + page.setTotal(count); + // 璁剧疆鏁版嵁 + page.setRecords(flowList); + return page; + } + /* + @Override + public IPage<BladeFlow> selectSendPage(IPage<BladeFlow> page, BladeFlow bladeFlow) { + String taskUser = TaskUtil.getTaskUser(); + List<BladeFlow> flowList = new LinkedList<>(); + + HistoricProcessInstanceQuery historyQuery = historyService.createHistoricProcessInstanceQuery().startedBy(taskUser).orderByProcessInstanceStartTime().desc(); + + if (bladeFlow.getCategory() != null) { + historyQuery.processDefinitionCategory(bladeFlow.getCategory()); + } + if (bladeFlow.getProcessDefinitionName() != null) { + historyQuery.processDefinitionName(bladeFlow.getProcessDefinitionName()); + } + if (bladeFlow.getBeginDate() != null) { + historyQuery.startedAfter(bladeFlow.getBeginDate()); + } + if (bladeFlow.getEndDate() != null) { + historyQuery.startedBefore(bladeFlow.getEndDate()); + } + + // 鏌ヨ鍒楄〃 + List<HistoricProcessInstance> historyList = historyQuery.listPage(Func.toInt((page.getCurrent() - 1) * page.getSize()), Func.toInt(page.getSize())); + + historyList.forEach(historicProcessInstance -> { + BladeFlow flow = new BladeFlow(); + // historicProcessInstance + flow.setCreateTime(historicProcessInstance.getStartTime()); + flow.setEndTime(historicProcessInstance.getEndTime()); + flow.setVariables(historicProcessInstance.getProcessVariables()); + String[] businessKey = Func.toStrArray(StringPool.COLON, historicProcessInstance.getBusinessKey()); + if (businessKey.length > 1) { + flow.setBusinessTable(businessKey[0]); + flow.setBusinessId(businessKey[1]); + } + flow.setHistoryActivityName(historicProcessInstance.getName()); + flow.setProcessInstanceId(historicProcessInstance.getId()); + flow.setHistoryProcessInstanceId(historicProcessInstance.getId()); + // ProcessDefinition + FlowProcess processDefinition = FlowCache.getProcessDefinition(historicProcessInstance.getProcessDefinitionId()); + flow.setProcessDefinitionId(processDefinition.getId()); + flow.setProcessDefinitionName(processDefinition.getName()); + flow.setProcessDefinitionVersion(processDefinition.getVersion()); + flow.setProcessDefinitionKey(processDefinition.getKey()); + flow.setCategory(processDefinition.getCategory()); + flow.setCategoryName(FlowCache.getCategoryName(processDefinition.getCategory())); + flow.setProcessInstanceId(historicProcessInstance.getId()); + // HistoricTaskInstance + List<HistoricTaskInstance> historyTasks = historyService.createHistoricTaskInstanceQuery().processInstanceId(historicProcessInstance.getId()).orderByHistoricTaskInstanceEndTime().desc().list(); + if (Func.isNotEmpty(historyTasks)) { + HistoricTaskInstance historyTask = historyTasks.iterator().next(); + flow.setTaskId(historyTask.getId()); + flow.setTaskName(historyTask.getName()); + flow.setTaskDefinitionKey(historyTask.getTaskDefinitionKey()); + } + // Status + if (historicProcessInstance.getEndActivityId() != null) { + flow.setProcessIsFinished(FlowEngineConstant.STATUS_FINISHED); + } else { + flow.setProcessIsFinished(FlowEngineConstant.STATUS_UNFINISHED); + } + flow.setStatus(FlowEngineConstant.STATUS_FINISH); + flowList.add(flow); + }); + + // 璁$畻鎬绘暟 + long count = historyQuery.count(); + // 璁剧疆鎬绘暟 + page.setTotal(count); + page.setRecords(flowList); + return page; + } + + @Override + public IPage<BladeFlow> selectDonePage(IPage<BladeFlow> page, BladeFlow bladeFlow) { + String taskUser = TaskUtil.getTaskUser(); + List<BladeFlow> flowList = new LinkedList<>(); + + HistoricTaskInstanceQuery doneQuery = historyService.createHistoricTaskInstanceQuery().taskAssignee(taskUser).finished() + .includeProcessVariables().orderByHistoricTaskInstanceEndTime().desc(); + + if (bladeFlow.getCategory() != null) { + doneQuery.processCategoryIn(Func.toStrList(bladeFlow.getCategory())); + } + if (bladeFlow.getProcessDefinitionName() != null) { + doneQuery.processDefinitionName(bladeFlow.getProcessDefinitionName()); + } + if (bladeFlow.getBeginDate() != null) { + doneQuery.taskCompletedAfter(bladeFlow.getBeginDate()); + } + if (bladeFlow.getEndDate() != null) { + doneQuery.taskCompletedBefore(bladeFlow.getEndDate()); + } + + // 鏌ヨ鍒楄〃 + List<HistoricTaskInstance> doneList = doneQuery.listPage(Func.toInt((page.getCurrent() - 1) * page.getSize()), Func.toInt(page.getSize())); + doneList.forEach(historicTaskInstance -> { + BladeFlow flow = new BladeFlow(); + flow.setTaskId(historicTaskInstance.getId()); + flow.setTaskDefinitionKey(historicTaskInstance.getTaskDefinitionKey()); + flow.setTaskName(historicTaskInstance.getName()); + flow.setAssignee(historicTaskInstance.getAssignee()); + flow.setCreateTime(historicTaskInstance.getCreateTime()); + flow.setExecutionId(historicTaskInstance.getExecutionId()); + flow.setHistoryTaskEndTime(historicTaskInstance.getEndTime()); + flow.setVariables(historicTaskInstance.getProcessVariables()); + + FlowProcess processDefinition = FlowCache.getProcessDefinition(historicTaskInstance.getProcessDefinitionId()); + flow.setProcessDefinitionId(processDefinition.getId()); + flow.setProcessDefinitionName(processDefinition.getName()); + flow.setProcessDefinitionKey(processDefinition.getKey()); + flow.setProcessDefinitionVersion(processDefinition.getVersion()); + flow.setCategory(processDefinition.getCategory()); + flow.setCategoryName(FlowCache.getCategoryName(processDefinition.getCategory())); + + flow.setProcessInstanceId(historicTaskInstance.getProcessInstanceId()); + flow.setHistoryProcessInstanceId(historicTaskInstance.getProcessInstanceId()); + HistoricProcessInstance historicProcessInstance = getHistoricProcessInstance((historicTaskInstance.getProcessInstanceId())); + if (Func.isNotEmpty(historicProcessInstance)) { + String[] businessKey = Func.toStrArray(StringPool.COLON, historicProcessInstance.getBusinessKey()); + flow.setBusinessTable(businessKey[0]); + flow.setBusinessId(businessKey[1]); + if (historicProcessInstance.getEndActivityId() != null) { + flow.setProcessIsFinished(FlowEngineConstant.STATUS_FINISHED); + } else { + flow.setProcessIsFinished(FlowEngineConstant.STATUS_UNFINISHED); + } + } + flow.setStatus(FlowEngineConstant.STATUS_FINISH); + flowList.add(flow); + }); + // 璁$畻鎬绘暟 + long count = doneQuery.count(); + // 璁剧疆鎬绘暟 + page.setTotal(count); + page.setRecords(flowList); + return page; + } + + @Override + public boolean completeTask(BladeFlow flow) { + String taskId = flow.getTaskId(); + String processInstanceId = flow.getProcessInstanceId(); + String comment = Func.toStr(flow.getComment(), ProcessConstant.PASS_COMMENT); + // 澧炲姞璇勮 + if (StringUtil.isNoneBlank(processInstanceId, comment)) { + taskService.addComment(taskId, processInstanceId, comment); + } + // 鍒涘缓鍙橀噺 + Map<String, Object> variables = flow.getVariables(); + if (variables == null) { + variables = Kv.create(); + } + variables.put(ProcessConstant.PASS_KEY, flow.isPass()); + // 瀹屾垚浠诲姟 + taskService.complete(taskId, variables); + return true; + } + */ + /** + * 鏋勫缓娴佺▼ + * + * @param bladeFlow 娴佺▼閫氱敤绫� + * @param flowList 娴佺▼鍒楄〃 + * @param taskQuery 浠诲姟鏌ヨ绫� + * @param status 鐘舵�� + */ + private void buildFlowTaskList(BladeFlow bladeFlow, List<BladeFlow> flowList, TaskQuery taskQuery, String status) { + if (bladeFlow.getCategory() != null) { + taskQuery.processCategoryIn(Func.toStrList(bladeFlow.getCategory())); + } + if (bladeFlow.getProcessDefinitionName() != null) { + taskQuery.processDefinitionName(bladeFlow.getProcessDefinitionName()); + } + if (bladeFlow.getBeginDate() != null) { + taskQuery.taskCreatedAfter(bladeFlow.getBeginDate()); + } + if (bladeFlow.getEndDate() != null) { + taskQuery.taskCreatedBefore(bladeFlow.getEndDate()); + } + List<Task> tasks = taskQuery.list(); + tasks.forEach(task -> { + BladeFlow flow = new BladeFlow(); + flow.setTaskId(task.getId()); + flow.setTaskDefinitionKey(task.getTaskDefinitionKey()); + flow.setTaskName(task.getName()); + flow.setAssignee(task.getAssignee()); + flow.setCreateTime(task.getCreateTime()); + flow.setClaimTime(task.getClaimTime()); + flow.setExecutionId(task.getExecutionId()); + flow.setVariables(task.getProcessVariables()); + + flow.setProcessDefinitionId(task.getProcessDefinitionId()); + //flow.setProcessDefinitionName(task.getprocessd); + + //flow.setProcessDefinitionKey(processDefinition.getKey()); + //flow.setProcessDefinitionVersion(processDefinition.getVersion()); + flow.setProcessInstanceId(task.getProcessInstanceId()); + /* + HistoricProcessInstance historicProcessInstance = getHistoricProcessInstance(task.getProcessInstanceId()); + if (Func.isNotEmpty(historicProcessInstance)) { + String[] businessKey = Func.toStrArray(StringPool.COLON, historicProcessInstance.getBusinessKey()); + flow.setBusinessTable(businessKey[0]); + flow.setBusinessId(businessKey[1]); + }*/ + + MdmFlowProcess processDefinition = MdmFlowCache.getProcessDefinition(task.getProcessDefinitionId()); + + flow.setCategory(processDefinition.getCategory()); + flow.setCategoryName(MdmFlowCache.getCategoryName(processDefinition.getCategory())); + flow.setProcessDefinitionId(processDefinition.getId()); + flow.setProcessDefinitionName(processDefinition.getName()); + flow.setProcessDefinitionKey(processDefinition.getKey()); + flow.setProcessDefinitionVersion(processDefinition.getVersion()); + flow.setProcessInstanceId(task.getProcessInstanceId()); + //flow.setStatus(status); + /* + */ + flowList.add(flow); + }); + } + + /** + * 鑾峰彇鍘嗗彶娴佺▼ + * + * @param processInstanceId 娴佺▼瀹炰緥id + * @return HistoricProcessInstance + */ + private HistoricProcessInstance getHistoricProcessInstance(String processInstanceId) { + return historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); + } + +} diff --git a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/util/MdmFlowCache.java b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/util/MdmFlowCache.java new file mode 100644 index 0000000..1232844 --- /dev/null +++ b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/util/MdmFlowCache.java @@ -0,0 +1,90 @@ +/** + * BladeX Commercial License Agreement + * Copyright (c) 2018-2099, https://bladex.cn. All rights reserved. + * <p> + * Use of this software is governed by the Commercial License Agreement + * obtained after purchasing a license from BladeX. + * <p> + * 1. This software is for development use only under a valid license + * from BladeX. + * <p> + * 2. Redistribution of this software's source code to any third party + * without a commercial license is strictly prohibited. + * <p> + * 3. Licensees may copyright their own code but cannot use segments + * from this software for such purposes. Copyright of this software + * remains with BladeX. + * <p> + * Using this software signifies agreement to this License, and the software + * must not be used for illegal purposes. + * <p> + * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is + * not liable for any claims arising from secondary or illegal development. + * <p> + * Author: Chill Zhuang (bladejava@qq.com) + */ +package org.springblade.mdm.flow.util; + +import org.flowable.engine.RepositoryService; +import org.flowable.engine.impl.persistence.entity.ProcessDefinitionEntityImpl; +import org.flowable.engine.repository.ProcessDefinition; +import org.springblade.core.cache.utils.CacheUtil; +import org.springblade.core.tool.utils.BeanUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.SpringUtil; +import org.springblade.core.tool.utils.StringPool; + +import org.springblade.mdm.flow.entity.MdmFlowProcess; +import org.springblade.system.cache.DictCache; + +/** + * 娴佺▼缂撳瓨 + * + * @author Chill + */ +public class MdmFlowCache { + + private static final String FLOW_CACHE = "mdmflow:process"; + private static final String FLOW_DEFINITION_ID = "definition:id"; + private static RepositoryService repositoryService; + + private static RepositoryService getRepositoryService() { + if (repositoryService == null) { + repositoryService = SpringUtil.getBean(RepositoryService.class); + } + return repositoryService; + } + + /** + * 鑾峰緱娴佺▼瀹氫箟瀵硅薄 + * + * @param processDefinitionId 娴佺▼瀵硅薄id + * @return + */ + public static MdmFlowProcess getProcessDefinition(String processDefinitionId) { + return CacheUtil.get(FLOW_CACHE, FLOW_DEFINITION_ID, processDefinitionId, () -> { + ProcessDefinition processDefinition = getRepositoryService().createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult(); + ProcessDefinitionEntityImpl processDefinitionEntity = BeanUtil.copyProperties(processDefinition, ProcessDefinitionEntityImpl.class); + return new MdmFlowProcess(processDefinitionEntity); + }); + } + + /** + * 鑾峰彇娴佺▼绫诲瀷鍚� + * + * @param category 娴佺▼绫诲瀷 + * @return + */ + public static String getCategoryName(String category) { + if (Func.isEmpty(category)) { + return StringPool.EMPTY; + } + String[] categoryArr = category.split(StringPool.UNDERSCORE); + if (categoryArr.length <= 1) { + return StringPool.EMPTY; + } else { + return DictCache.getValue(category.split(StringPool.UNDERSCORE)[0], Func.toInt(category.split(StringPool.UNDERSCORE)[1])); + } + } + +} diff --git a/doc/sql/mdm/mdm.all.create.sql b/doc/sql/mdm/mdm.all.create.sql index fb6d791..27fbbd2 100644 --- a/doc/sql/mdm/mdm.all.create.sql +++ b/doc/sql/mdm/mdm.all.create.sql @@ -11,7 +11,7 @@ `status` int DEFAULT '1' COMMENT '鐘舵��', `is_deleted` int DEFAULT '0' COMMENT '鏄惁宸插垹闄�', PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='鏈哄簥缁�'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='鏈哄簥缁�'; CREATE TABLE `mdm_machine` ( @@ -39,8 +39,26 @@ `update_user` bigint DEFAULT NULL COMMENT '鏇存柊浜�', PRIMARY KEY (`id`) USING BTREE, UNIQUE KEY `uniqueCodeIndex` (`code`,`is_deleted`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='鏈哄簥'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='鏈哄簥'; +CREATE TABLE `mdm_produce_plan` ( + `id` bigint NOT NULL, + `team_leader_id` bigint NOT NULL COMMENT '涓撲笟缁勯暱璐﹀彿', + `programmer_id` bigint NOT NULL COMMENT '缂栧埗鍛樿处鍙�', + `checker_id` bigint NOT NULL COMMENT '鏍″鍛樿处鍙凤紙宸ヨ壓鍛樿鑹诧級', + `senior_id` bigint NOT NULL COMMENT '瀹℃壒楂樺笀璐﹀彿', + + `tenant_id` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '000000' COMMENT '绉熸埛ID', + `status` int DEFAULT NULL COMMENT '涓氬姟鐘舵��', + `create_dept` bigint DEFAULT NULL COMMENT '鍒涘缓鍗曚綅', + `is_deleted` int DEFAULT 0, + `create_time` datetime DEFAULT NULL COMMENT '鍒涘缓鏃堕棿', + `create_user` bigint DEFAULT NULL COMMENT '鍒涘缓浜�', + `update_time` datetime DEFAULT NULL COMMENT '鏇存柊鏃堕棿', + `update_user` bigint DEFAULT NULL COMMENT '鏇存柊浜�', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE KEY `uniqueCheckIndex` (`team_leader_id`,`programmer_id`,`checker_id`,`senior_id`,`is_deleted`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='涓诲埗璁″垝琛�'; CREATE TABLE `mdm_nc_program` ( `id` bigint NOT NULL, @@ -59,7 +77,7 @@ `update_user` bigint DEFAULT NULL COMMENT '鏇存柊浜�' PRIMARY KEY (`id`) USING BTREE, UNIQUE KEY `uniqueCodeIndex` (`code`,`is_deleted`) USING BTREE, -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='鏁版帶绋嬪簭'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='鏁版帶绋嬪簭'; CREATE TABLE `mdm_task_receive` ( @@ -77,4 +95,4 @@ `update_user` bigint DEFAULT NULL COMMENT '鏇存柊浜�' PRIMARY KEY (`id`) USING BTREE, UNIQUE KEY `uniqueCodeIndex` (`name`,`is_deleted`) USING BTREE, -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='浠诲姟鎺ユ敹琛�'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='浠诲姟鎺ユ敹琛�'; -- Gitblit v1.9.3