From 4b8034d26b93a1f393aa0208b5c240c4b8b3f9d1 Mon Sep 17 00:00:00 2001 From: HanLong <404402223@qq.com> Date: Tue, 3 Feb 2026 17:36:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:[=E8=AF=95=E9=AA=8C=E7=AE=A1=E7=90=86][?= =?UTF-8?q?=E8=AF=95=E9=AA=8C=E6=96=B9=E6=B3=95]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hxhq/business/mapper/StudyMethodMapper.java | 1 + .../hxhq/business/service/IStudyMethodService.java | 1 + .../hxhq/business/service/impl/SjServiceImpl.java | 52 +++++++++++----------- .../service/impl/StudyMethodServiceImpl.java | 34 +++++++++++--- .../business/service/impl/StudySjServiceImpl.java | 2 +- .../java/com/hxhq/business/utils/CalUnitTools.java | 2 +- 6 files changed, 59 insertions(+), 33 deletions(-) diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/StudyMethodMapper.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/StudyMethodMapper.java index 3932a92..7974e20 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/StudyMethodMapper.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/StudyMethodMapper.java @@ -19,4 +19,5 @@ public interface StudyMethodMapper extends BaseMapper { List queryList(@Param("ew") Wrapper queryWrapper, @Param("qmrId") Long qmrId); + } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyMethodService.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyMethodService.java index 7189c17..16dfe70 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyMethodService.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyMethodService.java @@ -41,4 +41,5 @@ public interface IStudyMethodService extends IService * @return */ HashMap checkAllMethodReadStatus(Long userId, Long studyId, Long studySubjectId); + } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/SjServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/SjServiceImpl.java index 2ec9bcc..1bd5a5c 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/SjServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/SjServiceImpl.java @@ -22,6 +22,7 @@ import com.hxhq.business.form.gsp.GspJyForm; import com.hxhq.business.form.gsp.GspSearchListForm; import com.hxhq.business.form.sj.*; import com.hxhq.business.service.*; +import com.hxhq.business.utils.CalUnitTools; import com.hxhq.business.utils.JctUtil; import com.hxhq.business.utils.ObjectCompareUtil; import com.hxhq.common.core.exception.ServiceException; @@ -670,31 +671,28 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi if (studyFormFillResource.getType() == null) { if (sj == null) { sj = new Sj(); - sj.setStudyId(studyId); - sj.setStudyFormId(studyFormId); - sj.setDeptId(deptId); - sj.setZjzt(ZjztEnum.rk.getValue()); - sj.setJyzt(JyztEnum.wjy.getValue()); - sj.setDeptId(template.getDeptId()); - - sj.setMc(studyFormFillResource.getMc()); - sj.setBh(studyFormFillResource.getBh()); - sj.setNd(String.valueOf(studyFormFillResource.getNd())); - sj.setNddw(studyFormFillResource.getNddw()); - sj.setKc(studyFormFillResource.getKc()); - sj.setKcdw(studyFormFillResource.getKcdw()); - sj.setLy(studyFormFillResource.getLy()); - sj.setSxr(DateUtils.parseDate(studyFormFillResource.getSxrq())); - sj.setPzrq(studyFormFill.getStartDate()); - sj.setYxzq(studyFormFillResource.getYxzq()); - sj.setYxzqdw(studyFormFillResource.getYxzqdw()); } + sj.setStudyId(studyId); + sj.setStudyFormId(studyFormId); + sj.setDeptId(deptId); + sj.setZjzt(ZjztEnum.rk.getValue()); + sj.setJyzt(JyztEnum.wjy.getValue()); + sj.setDeptId(template.getDeptId()); + + sj.setMc(studyFormFillResource.getMc()); + sj.setBh(studyFormFillResource.getBh()); + sj.setNd(String.valueOf(studyFormFillResource.getNd())); + sj.setNddw(studyFormFillResource.getNddw()); + sj.setKc(studyFormFillResource.getKc()); + sj.setKcdw(studyFormFillResource.getKcdw()); + sj.setLy(studyFormFillResource.getLy()); + sj.setSxr(DateUtils.parseDate(studyFormFillResource.getSxrq())); + sj.setPzrq(studyFormFill.getStartDate()); + sj.setYxzq(studyFormFillResource.getYxzq()); + sj.setYxzqdw(studyFormFillResource.getYxzqdw()); if (sj.getId() == null) { this.save(sj); - sjList.add(sj); - sjMap.put(sj.getBh(), sj); - // 稽查轨迹 SjJcgj sjJcgj = sjJcgjService.genJcgj(sj.getId(), JcgjlxEnum.lc.getValue(), "配制完成", "Formulation Completed", JcmcysEnum.green.getValue(), null, null, qmr); @@ -704,14 +702,18 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi SjTz sjTz = sjTzService.genTz(sj.getId(), "配制完成", "Formulation Completed", sj.getKc(), sj.getKcdw(), null, qmr); tzList.add(sjTz); } else { -// this.updateById(sj); + this.updateById(sj); } + sjMap.put(sj.getBh(), sj); + sjList.add(sj); studyFormFillResource.setType(StudyFormFillResourceTypeEnum.sj.getValue()); }else{ //使用的才更新 Resource studyFormFillResource.setMc(sj.getMc()); studyFormFillResource.setNd(sj.getNd()); studyFormFillResource.setNddw(sj.getNddw()); + studyFormFillResource.setKc(sj.getKc()); + studyFormFillResource.setKcdw(sj.getKcdw()); studyFormFillResource.setPh(sj.getPh()); studyFormFillResource.setLy(sj.getLy()); if(sj.getSxr()!=null){ @@ -748,9 +750,8 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi // 使用 String syl = studyFormFillResource.getSyl(); if (StringUtils.isNotEmpty(syl) && NumberUtils.isParsable(syl)) { - BigDecimal kc = new BigDecimal(sj.getKc()); - kc = kc.subtract(new BigDecimal(syl)); - baseMapper.updateKc(sj.getId(), kc.toString()); + String kc = CalUnitTools.subTj(sj.getKc(), sj.getKcdw(), syl, studyFormFillResource.getSyldw()); + baseMapper.updateKc(sj.getId(), kc); // 使用稽查轨迹 Map jcnrMap = new LinkedHashMap<>(); @@ -763,7 +764,6 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi JcmcysEnum.green.getValue(), JctUtil.formatStr(jcnrMap), JctUtil.formatStr(jcnrEnMap), qmr); jcgjList.add(sjJcgj); - // 台账 SjTz sjTz = sjTzService.genTz(sj.getId(), "使用", "Usage", syl, studyFormFillResource.getKcdw(), null, qmr); tzList.add(sjTz); diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyMethodServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyMethodServiceImpl.java index 278d05f..4a9f99f 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyMethodServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyMethodServiceImpl.java @@ -82,13 +82,30 @@ public class StudyMethodServiceImpl extends ServiceImpl p.apply("(m.id IN (SELECT study_method_id FROM t_study_method_read WHERE del_flag = 0 AND qmr_id = {0} AND study_subject_id = {1}))" - , SecurityUtils.getUserId(), form.getStudySubjectId())); + if(form.getStudySubjectId() != null) { + queryWrapper.and(p -> p.apply("(m.id IN (SELECT study_method_id FROM t_study_method_read WHERE del_flag = 0 AND qmr_id = {0} AND study_subject_id = {1}))" + , SecurityUtils.getUserId(), form.getStudySubjectId())); + } else if(form.getStudyId() != null){ + queryWrapper.and(p -> p.apply("(m.id IN (SELECT study_method_id FROM t_study_method_read WHERE del_flag = 0 AND qmr_id = {0} AND study_id = {1}))" + , SecurityUtils.getUserId(), form.getStudyId())); + } else { + queryWrapper.and(p -> p.apply("(m.id IN (SELECT study_method_id FROM t_study_method_read WHERE del_flag = 0 AND qmr_id = {0}))" + , SecurityUtils.getUserId())); + } + } // 未读 if(form.getZt() != null && form.getZt() == StudyMethodStatusEnum.wd.getValue()) { - queryWrapper.and(p -> p.apply("(m.id NOT IN (SELECT study_method_id FROM t_study_method_read WHERE del_flag = 0 AND qmr_id = {0} AND study_subject_id = {1}))" - , SecurityUtils.getUserId(), form.getStudySubjectId())); + if(form.getStudySubjectId() != null) { + queryWrapper.and(p -> p.apply("(m.id NOT IN (SELECT study_method_id FROM t_study_method_read WHERE del_flag = 0 AND qmr_id = {0} AND study_subject_id = {1}))" + , SecurityUtils.getUserId(), form.getStudySubjectId())); + } else if(form.getStudyId() != null){ + queryWrapper.and(p -> p.apply("(m.id NOT IN (SELECT study_method_id FROM t_study_method_read WHERE del_flag = 0 AND qmr_id = {0} AND study_id = {1}))" + , SecurityUtils.getUserId(), form.getStudyId())); + } else { + queryWrapper.and(p -> p.apply("(m.id NOT IN (SELECT study_method_id FROM t_study_method_read WHERE del_flag = 0 AND qmr_id = {0}))" + , SecurityUtils.getUserId())); + } } queryWrapper.orderByDesc("m.create_time"); return baseMapper.queryList(queryWrapper, SecurityUtils.getUserId()); @@ -174,9 +191,16 @@ public class StudyMethodServiceImpl extends ServiceImpl list = this.list(studyMethodLambdaQueryWrapper); if(readCount != list.size()) { + // 获取未读方法 + StudyMethodSearchForm form = new StudyMethodSearchForm(); + form.setStudyId(studyId); + form.setStudySubjectId(studySubjectId); + form.setZt(StudyMethodStatusEnum.wd.getValue()); + List studyMethodList = queryList(form); + String toUrl=study.getType().equals(StudyTypeEnum.sy.getValue())?("/study/enter/"+study.getId()+"/syff"):study.getType().equals(StudyTypeEnum.fsy.getValue())?("/nonTrial/enter/"+study.getId()+"/syff"):study.getType().equals(StudyTypeEnum.mjy.getValue())?("/drug/enter/"+study.getId()+"/syff"):""; result.put("toUrl",toUrl); - result.put("ffmc","【" + list.stream().map(StudyMethod::getFfmc).collect(Collectors.joining(",")) + "】方法还未阅读,请先阅读后再进行操作]"); + result.put("ffmc","《" + studyMethodList.stream().map(StudyMethod::getFfmc).collect(Collectors.joining(",")) + "》方法还未阅读,请先阅读后再进行操作"); } } return result; diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudySjServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudySjServiceImpl.java index ffe7963..143640e 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudySjServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudySjServiceImpl.java @@ -43,7 +43,7 @@ public class StudySjServiceImpl extends ServiceImpl impl @Override @Async public void saveBatch(Long studyId, List sjList) { - List resourceIdList = sjList.stream().map(MpBaseEntity::getId).collect(Collectors.toList()); + List resourceIdList = sjList.stream().map(MpBaseEntity::getId).distinct().collect(Collectors.toList()); // 查询数据库中已有记录 LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/CalUnitTools.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/CalUnitTools.java index 8c4277b..923fc31 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/CalUnitTools.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/CalUnitTools.java @@ -57,7 +57,7 @@ public class CalUnitTools { */ public static String subTj(String kc, String kcdw, String subKc, String subKcdw) { validateUnit(kcdw); - validateUnit(subKc); + validateUnit(subKcdw); BigDecimal kcValue = formatKc(kc); BigDecimal addKcValue = formatKc(subKc); addKcValue = convert(addKcValue, subKcdw, kcdw);