From 5a1a0d3c333b7f5dde1ebd88e9c913af4faea6cc Mon Sep 17 00:00:00 2001 From: HanLong <404402223@qq.com> Date: Fri, 13 Mar 2026 15:51:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:[=E8=B5=84=E6=BA=90=E5=BA=93=E7=AE=A1?= =?UTF-8?q?=E7=90=86][=E4=BE=9B=E8=AF=95=E5=93=81]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hxhq/business/controller/PublicController.java | 3 +- .../hxhq/business/service/IStudyGspService.java | 9 ++++++ .../business/service/impl/GspFfjlServiceImpl.java | 20 +++++++++--- .../business/service/impl/StudyGspServiceImpl.java | 37 +++++++++++++++++++++- 4 files changed, 63 insertions(+), 6 deletions(-) diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/PublicController.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/PublicController.java index b0ff569..9b0acb3 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/PublicController.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/PublicController.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hxhq.business.domain.*; +import com.hxhq.business.dto.gsp.GspListDto; import com.hxhq.business.dto.gyzj.ListDto; import com.hxhq.business.dto.sj.SjListDto; import com.hxhq.business.enums.NormalEnum; @@ -256,7 +257,7 @@ public class PublicController extends BaseController { public TableDataInfo gspList(GspSearchListForm form) { startPage(); - List list = gspService.queryList(form); + List list = gspService.queryStudyList(form); return getDataTable(list); } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyGspService.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyGspService.java index 455b8b5..695b2e3 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyGspService.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyGspService.java @@ -1,6 +1,9 @@ package com.hxhq.business.service; import java.util.List; + +import com.hxhq.business.domain.Gsp; +import com.hxhq.business.domain.Sj; import com.hxhq.business.domain.StudyGsp; import com.baomidou.mybatisplus.extension.service.IService; @@ -20,4 +23,10 @@ public interface IStudyGspService extends IService */ public List queryList(StudyGsp studyGsp); + /** + * 批量保存试验-试剂关联 + * @param studyId 试验id + * @param gspList 供试品列表 + */ + void saveBatch(Long studyId, List gspList); } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GspFfjlServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GspFfjlServiceImpl.java index d174ef1..12ceba1 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GspFfjlServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GspFfjlServiceImpl.java @@ -15,9 +15,7 @@ import com.hxhq.business.form.gsp.GspGhForm; import com.hxhq.business.form.gsp.GspJyForm; import com.hxhq.business.form.gsp.GspSearchListForm; import com.hxhq.business.form.mjy.*; -import com.hxhq.business.service.IArchiveLogService; -import com.hxhq.business.service.IGspFfjlJcgjService; -import com.hxhq.business.service.INoticeService; +import com.hxhq.business.service.*; import com.hxhq.business.utils.JctUtil; import com.hxhq.common.core.exception.ServiceException; import com.hxhq.common.core.utils.DateUtils; @@ -29,7 +27,6 @@ import org.apache.commons.lang3.math.NumberUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.hxhq.business.mapper.GspFfjlMapper; -import com.hxhq.business.service.IGspFfjlService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.transaction.annotation.Transactional; @@ -55,6 +52,9 @@ public class GspFfjlServiceImpl extends ServiceImpl impl @Autowired private INoticeService noticeService; + @Autowired + private IStudyGspService studyGspService; + /** * 查询供试品发放记录列表 * @return 供试品发放记录 @@ -137,6 +137,17 @@ public class GspFfjlServiceImpl extends ServiceImpl impl gspFfjl.setMdIds(mdIds); this.save(gspFfjl); + + if (StringUtils.isNoneBlank(mdIds)) { + String[] tmp = mdIds.split(","); + for (String sid : tmp) { + List gspList = new ArrayList<>(); + gspList.add(gsp); + studyGspService.saveBatch(Long.valueOf(sid), gspList); + + } + } + //region 稽查轨迹 Map formData = new LinkedHashMap<>(); formData.put("出库量", gsp.getKc() + gsp.getKcdw()); @@ -152,6 +163,7 @@ public class GspFfjlServiceImpl extends ServiceImpl impl gspFfjlJcgjService.saveJcgj(gspFfjl, JcgjlxEnum.lc.getValue(), "领取发放", "Distribution", JcmcysEnum.green.getValue(), JctUtil.formatStr(formData), JctUtil.formatStr(formDataEn), ffr1); //endregion + } @Override diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyGspServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyGspServiceImpl.java index ffe92c2..74a56a1 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyGspServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyGspServiceImpl.java @@ -1,9 +1,17 @@ package com.hxhq.business.service.impl; +import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; - import com.hxhq.common.core.utils.DateUtils; +import com.hxhq.business.domain.Gsp; +import com.hxhq.business.domain.StudySj; +import com.hxhq.common.core.domain.MpBaseEntity; +import com.hxhq.common.core.utils.DateUtils; import org.springframework.stereotype.Service; import com.hxhq.business.mapper.StudyGspMapper; import com.hxhq.business.domain.StudyGsp; @@ -32,4 +40,31 @@ public class StudyGspServiceImpl extends ServiceImpl i return this.list(queryWrapper); } + @Override + public void saveBatch(Long studyId, List gspList) { + List resourceIdList = gspList.stream().map(MpBaseEntity::getId).distinct().collect(Collectors.toList()); + + // 查询数据库中已有记录 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(StudyGsp::getStudyId, studyId) + .in(StudyGsp::getResourceId, resourceIdList); + List list = this.list(queryWrapper); + List dbResourceIdList = list.stream().map(StudyGsp::getResourceId).collect(Collectors.toList()); + + // 对比试剂id,插入数据库中没有的记录 + List insertResourceId = resourceIdList.stream() + .filter(element -> !dbResourceIdList.contains(element)) + .collect(Collectors.toList()); + if(CollectionUtils.isNotEmpty(insertResourceId)) { + List studyGspList = new ArrayList<>(); + for (Long resourceId : insertResourceId) { + StudyGsp studyGsp = new StudyGsp(); + studyGsp.setResourceId(resourceId); + studyGsp.setStudyId(studyId); + studyGspList.add(studyGsp); + } + this.saveBatch(studyGspList); + } + } + }