From 3dc60e9745df6c6dc450b2091263791b3e80958c Mon Sep 17 00:00:00 2001
From: 吴羡 <16976746+Xian-TT3@user.noreply.gitee.com>
Date: 星期三, 21 十月 2026 15:05:45 +0800
Subject: [PATCH] feat: 标准维护支持按标准分类筛选
---
basic-server/src/main/java/com/ruoyi/basic/service/impl/StandardMethodServiceImpl.java | 31 ++++++++++++++++++++++++++++---
1 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/basic-server/src/main/java/com/ruoyi/basic/service/impl/StandardMethodServiceImpl.java b/basic-server/src/main/java/com/ruoyi/basic/service/impl/StandardMethodServiceImpl.java
index f14bb35..6d4af01 100644
--- a/basic-server/src/main/java/com/ruoyi/basic/service/impl/StandardMethodServiceImpl.java
+++ b/basic-server/src/main/java/com/ruoyi/basic/service/impl/StandardMethodServiceImpl.java
@@ -2,12 +2,14 @@
import cn.hutool.json.JSONUtil;
import cn.hutool.poi.excel.ExcelUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.basic.pojo.StandardMethodList;
+import com.ruoyi.basic.event.StandardMethodSavedEvent;
import com.ruoyi.common.utils.QueryWrappers;
import com.ruoyi.basic.mapper.StandardMethodMapper;
import com.ruoyi.basic.mapper.StandardProductListMapper;
@@ -31,6 +33,7 @@
import com.ruoyi.basic.utils.StandardTreePath;
import com.ruoyi.basic.utils.StandardTreePathParser;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
@@ -66,6 +69,7 @@
private LaboratoryMapper laboratoryMapper;
private StandardTreeMapper standardTreeMapper;
private StandardTreeTemplateBindingMapper standardTreeTemplateBindingMapper;
+ private final ApplicationEventPublisher eventPublisher;
@Value("${file.path}")
private String filePath;
@@ -86,7 +90,8 @@
StandardMethodAttachmentMapper standardMethodAttachmentMapper,
LaboratoryMapper laboratoryMapper,
StandardTreeMapper standardTreeMapper,
- StandardTreeTemplateBindingMapper standardTreeTemplateBindingMapper) {
+ StandardTreeTemplateBindingMapper standardTreeTemplateBindingMapper,
+ ApplicationEventPublisher eventPublisher) {
this.standardMethodMapper = standardMethodMapper;
this.standardProductListMapper = standardProductListMapper;
this.standardProductListService = standardProductListService;
@@ -97,11 +102,16 @@
this.laboratoryMapper = laboratoryMapper;
this.standardTreeMapper = standardTreeMapper;
this.standardTreeTemplateBindingMapper = standardTreeTemplateBindingMapper;
+ this.eventPublisher = eventPublisher;
}
@Override
- public IPage<StandardMethod> selectStandardMethodList(Page page, StandardMethod standardMethod) {
- IPage<StandardMethod> result = standardMethodMapper.selectStandardMethodList(page, QueryWrappers.queryWrappers(standardMethod));
+ public IPage<StandardMethod> selectStandardMethodList(Page page, StandardMethod standardMethod, Integer industryId) {
+ QueryWrapper<StandardMethod> wrapper = QueryWrappers.queryWrappers(standardMethod);
+ if (industryId != null) {
+ wrapper.exists("select 1 from standard_method_industry smi where smi.standard_method_id = a.id and smi.industry_id = {0}", industryId);
+ }
+ IPage<StandardMethod> result = standardMethodMapper.selectStandardMethodList(page, wrapper);
for (StandardMethod method : result.getRecords()) {
method.setIndustryIds(selectIndustryIds(method.getId()));
}
@@ -117,8 +127,12 @@
@Transactional(rollbackFor = Exception.class)
public Integer addStandardMethod(StandardMethod standardMethod) {
standardMethod.setStructureTestObjectId(null);
+ if (standardMethod.getNeedSearchNew() == null) {
+ standardMethod.setNeedSearchNew(0);
+ }
standardMethodMapper.insert(standardMethod);
syncIndustries(standardMethod, Collections.<Integer>emptySet());
+ publishSavedEvent(standardMethod, false);
return standardMethod.getId();
}
@@ -149,11 +163,22 @@
if (!oldStandardMethod.getCode().equals(standardMethod.getCode())) {
CompletableFuture.supplyAsync(() -> replaceMethod(oldStandardMethod.getCode(), standardMethod.getCode()));
}
+ if (standardMethod.getNeedSearchNew() == null) {
+ standardMethod.setNeedSearchNew(oldStandardMethod.getNeedSearchNew() == null
+ ? 0 : oldStandardMethod.getNeedSearchNew());
+ }
int i = standardMethodMapper.updateById(standardMethod);
syncIndustries(standardMethod, new LinkedHashSet<>(selectIndustryIds(oldStandardMethod.getId())));
+ publishSavedEvent(standardMethodMapper.selectById(standardMethod.getId()), true);
return i;
}
+ private void publishSavedEvent(StandardMethod standardMethod, boolean edit) {
+ eventPublisher.publishEvent(new StandardMethodSavedEvent(
+ standardMethod.getId(), standardMethod.getCode(), standardMethod.getName(),
+ standardMethod.getNeedSearchNew(), edit));
+ }
+
private List<Integer> selectIndustryIds(Integer methodId) {
List<StandardMethodIndustry> list = standardMethodIndustryMapper.selectList(
Wrappers.<StandardMethodIndustry>lambdaQuery()
--
Gitblit v1.9.3