From 2efc05d570d23d86b02b6fd8f73491b3d520bde0 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期三, 14 十月 2026 10:47:31 +0800
Subject: [PATCH] fix(mes-dv): 设备模块列表查询补充按创建时间降序排序
---
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pd/project/MesPdProjectServiceImpl.java | 81 ++++++++++++++++++++--------------------
1 files changed, 41 insertions(+), 40 deletions(-)
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pd/project/MesPdProjectServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pd/project/MesPdProjectServiceImpl.java
index 6648c60..a28b1d9 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pd/project/MesPdProjectServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pd/project/MesPdProjectServiceImpl.java
@@ -7,8 +7,7 @@
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO;
import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum;
-import cn.iocoder.yudao.module.bpm.service.definition.BpmCategoryService;
-import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessDefinitionService;
+import cn.iocoder.yudao.module.mes.service.common.bpm.MesBpmProcessService;
import cn.iocoder.yudao.module.mes.controller.admin.pd.project.vo.MesPdProjectPageReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.pd.project.vo.MesPdProjectSaveReqVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.pd.document.MesPdDocumentDO;
@@ -80,10 +79,7 @@
private BpmProcessInstanceApi processInstanceApi;
@Resource
- private BpmCategoryService bpmCategoryService;
-
- @Resource
- private BpmProcessDefinitionService bpmProcessDefinitionService;
+ private MesBpmProcessService mesBpmProcessService;
@Override
@Transactional(rollbackFor = Exception.class)
@@ -223,6 +219,18 @@
throw exception(PD_PROJECT_AUDIT_NOT_FINISHED);
}
// 3. 鍒涘缓 BPM 娴佺▼瀹炰緥
+ // 鍏ㄥ眬鍏嶅鎵癸細涓氬姟鏍¢獙閫氳繃鍚庣洿鎺ユ墽琛屽鎵归�氳繃閫昏緫锛屾棤闇�娴佺▼妯″瀷銆�
+ if (processInstanceApi.isGlobalAutoApprove()) {
+ projectMapper.updateById(MesPdProjectDO.builder()
+ .id(id)
+ .status(MesPdProjectStatusEnum.APPROVING.getStatus())
+ .processInstanceId("")
+ .processDefinitionKey("")
+ .build());
+ updateProjectAuditStatus(id, cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceStatusEnum.APPROVE.getStatus());
+ return;
+ }
+
String processInstanceId = processInstanceApi.createProcessInstance(getLoginUserId(),
new BpmProcessInstanceCreateReqDTO()
.setProcessDefinitionKey(processDefinitionKey)
@@ -238,40 +246,7 @@
@Override
public List<Map<String, Object>> getProjectApproveProcessDefinitionList() {
- // 1. 鏍¢獙鍒嗙被鏄惁瀛樺湪
- List<BpmCategoryDO> categories = bpmCategoryService.getCategoryListByCode(
- Collections.singletonList(BPM_PROCESS_DEFINITION_CATEGORY_CODE));
- if (CollUtil.isEmpty(categories)) {
- throw exception(PD_PROJECT_BPM_CATEGORY_NOT_EXISTS);
- }
- // 2. 鑾峰彇鍒嗙被涓嬬殑娴佺▼瀹氫箟淇℃伅
- List<BpmProcessDefinitionInfoDO> definitionInfoList = bpmProcessDefinitionService
- .getProcessDefinitionInfoListByCategory(BPM_PROCESS_DEFINITION_CATEGORY_CODE);
- if (CollUtil.isEmpty(definitionInfoList)) {
- return Collections.emptyList();
- }
- // 3. 杩囨护婵�娲荤姸鎬侊紝淇濈暀鏈�鏂扮増鏈�
- Map<String, ProcessDefinition> latestVersionMap = new HashMap<>();
- for (BpmProcessDefinitionInfoDO info : definitionInfoList) {
- ProcessDefinition pd = bpmProcessDefinitionService.getProcessDefinition(info.getProcessDefinitionId());
- if (pd == null || pd.isSuspended()) {
- continue;
- }
- ProcessDefinition existing = latestVersionMap.get(pd.getKey());
- if (existing == null || pd.getVersion() > existing.getVersion()) {
- latestVersionMap.put(pd.getKey(), pd);
- }
- }
- // 4. 杩斿洖娴佺▼瀹氫箟鍒楄〃
- List<Map<String, Object>> result = new ArrayList<>();
- for (ProcessDefinition pd : latestVersionMap.values()) {
- Map<String, Object> item = new HashMap<>();
- item.put("id", pd.getId());
- item.put("key", pd.getKey());
- item.put("name", pd.getName());
- result.add(item);
- }
- return result;
+ return mesBpmProcessService.getApproveProcessDefinitionList(BPM_PROCESS_DEFINITION_CATEGORY_CODE);
}
@Override
@@ -343,6 +318,32 @@
return projectMapper.selectList(new QueryWrapper<MesPdProjectDO>().lambda().eq(MesPdProjectDO::getProductCode,productCode).eq(MesPdProjectDO::getStatus, MesPdProjectStatusEnum.ARCHIVE.getStatus()));
}
+ @Override
+ public Map<Long, Integer> getPendingAuditCountMap(Collection<Long> projectIds) {
+ if (CollUtil.isEmpty(projectIds)) {
+ return Collections.emptyMap();
+ }
+ // 1. 鎵归噺鏌ュ嚭杩欎簺椤圭洰涓嬬殑鎵�鏈夎祫鏂�
+ List<MesPdDocumentDO> documents = documentService.getDocumentListByProjectIds(projectIds);
+ if (CollUtil.isEmpty(documents)) {
+ return Collections.emptyMap();
+ }
+ // 2. 璧勬枡ID -> 椤圭洰ID
+ Map<Long, Long> documentProjectIdMap = convertMap(documents, MesPdDocumentDO::getId, MesPdDocumentDO::getProjectId);
+ // 3. 鎵归噺鏌ュ嚭鎵�鏈夊緟瀹℃牳璁板綍锛坅uditStatus=0锛�
+ List<MesPdDocumentAuditDO> pendingAudits =
+ documentAuditMapper.selectPendingAuditListByDocumentIds(documentProjectIdMap.keySet());
+ // 4. 鎸夐」鐩粺璁″緟瀹℃牳鏂囦欢鏁�
+ Map<Long, Integer> result = new HashMap<>();
+ for (MesPdDocumentAuditDO audit : pendingAudits) {
+ Long projectId = documentProjectIdMap.get(audit.getDocumentId());
+ if (projectId != null) {
+ result.merge(projectId, 1, Integer::sum);
+ }
+ }
+ return result;
+ }
+
private void validateProjectInitiate(MesPdProjectDO project) {
if (!MesPdProjectStatusEnum.INITIATE.getStatus().equals(project.getStatus())) {
throw exception(PD_PROJECT_NOT_INITIATE);
--
Gitblit v1.9.3