From 34cad88334fdf37466aac8d6ca6a2e3399af61fe Mon Sep 17 00:00:00 2001 From: HanLong <404402223@qq.com> Date: Tue, 3 Feb 2026 11:53:30 +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][=E8=AF=95=E5=89=82=E7=AE=A1=E7=90=86]=E7=94=9F?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hxhq/business/controller/SjController.java | 51 ++++++--- .../com/hxhq/business/mapper/BacteriaMapper.java | 5 + .../com/hxhq/business/service/IGspFfjlService.java | 50 +++++++-- .../com/hxhq/business/service/IGspJcgjService.java | 2 + .../hxhq/business/service/IGspRkjlJcgjService.java | 2 + .../com/hxhq/business/service/IGspRkjlService.java | 70 +++++++++--- .../com/hxhq/business/service/IGspService.java | 105 ++++++++++++++---- .../hxhq/business/service/impl/SjServiceImpl.java | 3 +- .../java/com/hxhq/business/utils/CalUnitTools.java | 123 +++++++++++++++++++++ 9 files changed, 352 insertions(+), 59 deletions(-) create mode 100644 hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/CalUnitTools.java diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/SjController.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/SjController.java index ce803ae..0147128 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/SjController.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/SjController.java @@ -1,12 +1,12 @@ package com.hxhq.business.controller; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import java.util.*; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.hxhq.business.domain.*; import com.hxhq.business.dto.sj.SjListDto; +import com.hxhq.business.enums.zykgl.JcgjlxEnum; +import com.hxhq.business.enums.zykgl.JcmcysEnum; import com.hxhq.business.enums.zykgl.JyztEnum; import com.hxhq.business.enums.zykgl.ZjztEnum; import com.hxhq.business.form.gsp.GspSearchListForm; @@ -15,6 +15,7 @@ import com.hxhq.business.service.ISjService; import com.hxhq.business.service.ISjTzService; import com.hxhq.business.service.ISjJcgjService; import com.hxhq.business.service.IStudySubjectService; +import com.hxhq.business.utils.JctUtil; import com.hxhq.common.security.annotation.RequiresPermissions; import com.hxhq.common.security.utils.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -115,12 +116,19 @@ public class SjController extends BaseController } /** - * 配置完成 + * 分装 * @param form * @return */ @PostMapping("/subpackage") public AjaxResult subpackage(@RequestBody SjSubpackageForm form) { + Sj sj = sjService.getSjByBh(form.getBh()); + if(sj == null) { + sj = new Sj(); + sj.setBh(form.getBh()); + sjService.save(sj); + } + StudySubject studySubject = studySubjectService.getById(form.getStudySubjectId()); LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); @@ -128,18 +136,35 @@ public class SjController extends BaseController sjService.remove(queryWrapper); List list = form.getList(); List sjList = new ArrayList<>(); + List fz = new ArrayList<>(); for (SjSubpackageForm.SjSubpackageItemForm sjSubpackageItemForm : list) { - Sj sj = new Sj(); - sj.setParentBh(form.getBh()); - sj.setBh(sjSubpackageItemForm.getBh()); - sj.setKc(sjSubpackageItemForm.getKc()); - sj.setKcdw(sjSubpackageItemForm.getKcdw()); - sj.setStudyId(form.getStudyId()); - sj.setStudyFormId(form.getStudyFormId()); - sj.setDeptId(studySubject.getDeptId()); - sjList.add(sj); + Sj subpackageSj = new Sj(); + subpackageSj.setParentBh(form.getBh()); + subpackageSj.setBh(sjSubpackageItemForm.getBh()); + subpackageSj.setKc(sjSubpackageItemForm.getKc()); + subpackageSj.setKcdw(sjSubpackageItemForm.getKcdw()); + subpackageSj.setStudyId(form.getStudyId()); + subpackageSj.setStudyFormId(form.getStudyFormId()); + subpackageSj.setDeptId(studySubject.getDeptId()); + sjList.add(subpackageSj); + + fz.add(sjSubpackageItemForm.getBh() + "(" + sjSubpackageItemForm.getKc() + sjSubpackageItemForm.getKcdw() + ")"); } sjService.saveBatch(sjList); + + SjJcgj jcgj = new SjJcgj(); + jcgj.setSjId(sj.getId()); + jcgj.setJcmc("分装"); + jcgj.setJcgjlx(JcgjlxEnum.lc.getValue()); + jcgj.setJcmcys(JcmcysEnum.blue.getValue()); + + Map jcnrMap = new LinkedHashMap<>(); + jcnrMap.put("母液编号", form.getBh()); + jcnrMap.put("分装个数", String.valueOf(form.getList().size())); + jcnrMap.put("分装后编号及体积",String.join(",", fz)); + jcnrMap.put("分装人", SecurityUtils.getNickName()); + jcgj.setJcnr(JctUtil.formatStr(jcnrMap)); + sjJcgjService.save(jcgj); return success(); } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/BacteriaMapper.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/BacteriaMapper.java index 8cd9729..bc3e53c 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/BacteriaMapper.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/BacteriaMapper.java @@ -18,5 +18,10 @@ import java.util.List; public interface BacteriaMapper extends BaseMapper { + /** + * 试验物资列表 + * @param queryWrapper + * @return + */ List queryStudyList(@Param("ew") Wrapper queryWrapper); } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGspFfjlService.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGspFfjlService.java index 581e181..00d3720 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGspFfjlService.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGspFfjlService.java @@ -68,13 +68,22 @@ public interface IGspFfjlService extends IService */ void gh(GspGhForm form, Gsp gsp, SysUser ghr1, SysUser ghr2, SysUser jsr1, SysUser jsr2); - /** 解档 */ + /** + * 解档 + * @param form + */ void jd(FfjlJdForm form); - /** 批量归档 */ + /** + * 批量归档 + * @param form + */ void plgd(FfjlGdForm form); - /** 归档 */ + /** + * 归档 + * @param form + */ void gd(FfjlGdForm form); /** @@ -114,24 +123,45 @@ public interface IGspFfjlService extends IService */ public void jq(FfjlJqForm form); - /** 同意归档 */ + /** + * 同意归档 + * @param form + */ void agreeGd(GspGdForm form); - /** 拒绝归档 */ + /** + * 拒绝归档 + * @param form + */ void refuseGd(GspGdForm form); - /** 同意解档 */ + /** + * 同意解档 + * @param form + */ void agreeJd(GspGdForm form); - /** 拒绝解档 */ + /** + * 拒绝解档 + * @param form + */ void refuseJd(GspGdForm form); - /** 同意借阅 */ + /** + * 同意借阅 + * @param form + */ void agreeJy(GspJyForm form); - /** 拒绝借阅 */ + /** + * 拒绝借阅 + * @param form + */ void refuseJy(GspJyForm form); - /** 档案确认归还 */ + /** + * 档案确认归还 + * @param form + */ void archiveGh(GspGdForm form); } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGspJcgjService.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGspJcgjService.java index 8aa18d9..28dc2ca 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGspJcgjService.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGspJcgjService.java @@ -26,8 +26,10 @@ public interface IGspJcgjService extends IService * @param gspId 供试品id * @param jcgjlx 稽查轨迹类型:1:流程;3:编辑 * @param jcmc 稽查名称 + * @param jcmcEn 稽查名称-英文 * @param jcmcys 稽查名称颜色:1:蓝色;3:红色;5:绿色;7:橙色 * @param jcnr 稽查内容 + * @param jcnrEn 稽查内容-英文 * @param qmr 签名人 */ public void saveJcgj(Long gspId, Integer jcgjlx, String jcmc, String jcmcEn, Integer jcmcys, String jcnr, String jcnrEn, SysUser qmr); diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGspRkjlJcgjService.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGspRkjlJcgjService.java index 5a509b1..a3da51f 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGspRkjlJcgjService.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGspRkjlJcgjService.java @@ -26,8 +26,10 @@ public interface IGspRkjlJcgjService extends IService * @param gspRkjlId 供试品入库id * @param jcgjlx 稽查轨迹类型:1:流程;3:编辑 * @param jcmc 稽查名称 + * @param jcmcEn 稽查名称-英文 * @param jcmcys 稽查名称颜色:1:蓝色;3:红色;5:绿色;7:橙色 * @param jcnr 稽查内容 + * @param jcnrEn 稽查内容-英文 * @param qmr 签名人 */ public void saveJcgj(Long gspRkjlId, Integer jcgjlx, String jcmc, String jcmcEn, Integer jcmcys, String jcnr, String jcnrEn, SysUser qmr); diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGspRkjlService.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGspRkjlService.java index a0e7811..c74dbfe 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGspRkjlService.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGspRkjlService.java @@ -34,45 +34,87 @@ public interface IGspRkjlService extends IService */ void update(GspRkjlForm form); - /** 供试品入库记录锁定 */ + /** + * 供试品入库记录锁定 + * @param form + */ void sd(GspSdForm form); - /** 供试品入库记录解锁 */ + /** + * 供试品入库记录解锁 + * @param form + */ void js(GspJsForm form); - /** 批量锁定 */ + /** + * 批量锁定 + * @param form + */ void plsd(GspSdForm form); - /** 解档 */ + /** + * 解档 + * @param form + */ void jd(GspJdForm form); - /** 批量归档 */ + /** + * 批量归档 + * @param form + */ void plgd(GspGdForm form); - /** 归档 */ + /** + * 归档 + * @param form + */ void gd(GspGdForm form); - /** 借阅 */ + /** + * 借阅 + * @param form + */ void jy(GspJyForm form); - /** 同意归档 */ + /** + * 同意归档 + * @param form + */ void agreeGd(GspGdForm form); - /** 拒绝归档 */ + /** + * 拒绝归档 + * @param form + */ void refuseGd(GspGdForm form); - /** 同意解档 */ + /** + * 同意解档 + * @param form + */ void agreeJd(GspGdForm form); - /** 拒绝解档 */ + /** + * 拒绝解档 + * @param form + */ void refuseJd(GspGdForm form); - /** 同意借阅 */ + /** + * 同意借阅 + * @param form + */ void agreeJy(GspJyForm form); - /** 拒绝借阅 */ + /** + * 拒绝借阅 + * @param form + */ void refuseJy(GspJyForm form); - /** 档案确认归还 */ + /** + * 档案确认归还 + * @param form + */ void archiveGh(GspGdForm form); } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGspService.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGspService.java index e5d6ae1..a2327cf 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGspService.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGspService.java @@ -24,6 +24,11 @@ public interface IGspService extends IService */ public List queryList(GspSearchListForm form); + /** + * 供试品详情 + * @param id 供试品id + * @return + */ GspDto queryInfo(Long id); @@ -39,64 +44,124 @@ public interface IGspService extends IService */ void edit(GspBjForm gspForm); - /** 审核编辑 */ + /** + * 审核编辑 + * @param form + */ void shbj(GspShbjForm form); - /** 钥匙发放 */ + /** + * 钥匙发放 + * @param form + */ void ysff(GspYsffForm form); - /** 发放 */ + /** + * 发放 + * @param form + */ void ff(FfGspForm form); - /** 批量发放 */ + /** + * 批量发放 + * @param form + */ void plff(GspPlffForm form); - /** 修改库存 */ + /** + * 修改库存 + * @param form + */ void xgkc(GspXgkcForm form); - /** 审核修改库存 */ + /** + * 审核修改库存 + * @param form + */ void shxgkc(GspShxgkcForm form); - /** 批量锁定 */ + /** + * 批量锁定 + * @param form + */ void plsd(GspSdForm form); - /** 锁定 */ + /** + * 锁定 + * @param form + */ void sd(GspSdForm form); - /** 解锁 */ + /** + * 解锁 + * @param form + */ void js(GspJsForm form); - /** 处置 */ + /** + * 处置 + * @param form + */ void cz(GspCzForm form); - /** 批量处置 */ + /** + * 批量处置 + * @param form + */ void plcz(GspPlczForm form); - /** 借阅 */ + /** + * 借阅 + * @param form + */ void jy(GspJyForm form); - /** 解档 */ + /** + * 解档 + * @param form + */ void jd(GspJdForm form); - /** 供试品归档 */ + /** + * 供试品归档 + * @param form + */ void gd(GspGdForm form); - /** 批量归档 */ + /** + * 批量归档 + * @param form + */ void plgd(GspGdForm form); - /** 归还 */ + /** + * 归还 + * @param form + */ void gh(GspGhForm form); - /** 试验关联的供试品列表 */ + /** + * 试验关联的供试品列表 + * @param form + */ List queryStudyList(GspSearchListForm form); - /** 同意归档 */ + /** + * 同意归档 + * @param form + */ void agreeGd(GspGdForm form); - /** 拒绝归档 */ + /** + * 拒绝归档 + * @param form + */ void refuseGd(GspGdForm form); - /** 同意解档 */ + /** + * 同意解档 + * @param form + */ void agreeJd(GspGdForm form); /** 拒绝解档 */ 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 7e11591..2ec9bcc 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 @@ -667,7 +667,7 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi for (StudyFormFillResource studyFormFillResource : studyFormFillResourceList) { Sj sj = sjMap.get(studyFormFillResource.getBh()); //配置的才保存,或更新 - if (studyFormFillResource.getType() == null) {: + if (studyFormFillResource.getType() == null) { if (sj == null) { sj = new Sj(); sj.setStudyId(studyId); @@ -721,7 +721,6 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi // 使用 syl(studyFormFillResource, sj, jcgjList, tzList, qmr); sjMap.put(sj.getBh(), sj); - } } //更新 Resource 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 new file mode 100644 index 0000000..8c4277b --- /dev/null +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/CalUnitTools.java @@ -0,0 +1,123 @@ +package com.hxhq.business.utils; + +import com.hxhq.common.core.exception.ServiceException; +import com.hxhq.common.core.utils.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; + +import java.math.BigDecimal; +import java.text.DecimalFormat; +import java.util.HashMap; +import java.util.Map; + +/** + * 单位换算工具 + */ +public class CalUnitTools { + + private static String[] unitList = {"pL", "nL", "uL", "mL", "L"}; + + // 定义单位换算基准(以升L为基准单位) + private static final Map UNIT_TO_LITER = new HashMap<>(); + + static { + // 初始化单位换算关系 + UNIT_TO_LITER.put("L", new BigDecimal("1.0")); + UNIT_TO_LITER.put("mL", new BigDecimal("0.001")); // 毫升 + UNIT_TO_LITER.put("uL", new BigDecimal("0.000001")); // 微升 (μL,这里用uL代替) + UNIT_TO_LITER.put("nL", new BigDecimal("0.000000001")); // 纳升 + UNIT_TO_LITER.put("pL", new BigDecimal("0.000000000001")); // 皮升 + } + + /** + * 体积相加 + * @param kc 当前库存 + * @param kcdw 当前库存单位 + * @param addKc 增加库存 + * @param addKcdw 增加库存单位 + * @return + */ + public static String addTj(String kc, String kcdw, String addKc, String addKcdw) { + validateUnit(kcdw); + validateUnit(addKcdw); + BigDecimal kcValue = formatKc(kc); + BigDecimal addKcValue = formatKc(addKc); + addKcValue = convert(addKcValue, addKcdw, kcdw); + kcValue = kcValue.add(addKcValue); + + return kcValue.toString(); + } + + /** + * 体积相加 + * @param kc 当前库存 + * @param kcdw 当前库存单位 + * @param subKc 扣减库存 + * @param subKcdw 扣减库存单位 + * @return + */ + public static String subTj(String kc, String kcdw, String subKc, String subKcdw) { + validateUnit(kcdw); + validateUnit(subKc); + BigDecimal kcValue = formatKc(kc); + BigDecimal addKcValue = formatKc(subKc); + addKcValue = convert(addKcValue, subKcdw, kcdw); + kcValue = kcValue.add(addKcValue); + + DecimalFormat df = new DecimalFormat("#"); + + return df.format(kcValue); + } + + private static BigDecimal formatKc(String kc) { + if(StringUtils.isEmpty(kc)) { + return BigDecimal.ZERO; + } + if(!NumberUtils.isParsable(kc)) { + throw new ServiceException("不支持的库存数量" + kc); + } + return new BigDecimal(kc); + } + + /** + * 体积单位换算 + * @param value 需要转换的数值 + * @param fromUnit 原始单位 ("pL", "nL", "uL", "mL", "L") + * @param toUnit 目标单位 ("pL", "nL", "uL", "mL", "L") + * @return 转换后的数值 + * @throws IllegalArgumentException 当单位不支持时抛出异常 + */ + public static BigDecimal convert(BigDecimal value, String fromUnit, String toUnit) { + // 验证单位是否支持 + if (!UNIT_TO_LITER.containsKey(fromUnit) || !UNIT_TO_LITER.containsKey(toUnit)) { + throw new IllegalArgumentException( + "不支持的单位。支持的单位有: " + String.join(", ", UNIT_TO_LITER.keySet()) + ); + } + + // 如果单位相同,直接返回 + if (fromUnit.equals(toUnit)) { + return value; + } + + // 转换为基准单位(升) + BigDecimal valueInLiters = value.multiply(UNIT_TO_LITER.get(fromUnit)); + + // 从基准单位转换为目标单位 + return valueInLiters.divide(UNIT_TO_LITER.get(toUnit)); + } + + private static void validateUnit(String unit) { + boolean isValid = false; + for (String validUnit : unitList) { + if (validUnit.equalsIgnoreCase(unit)) { + isValid = true; + break; + } + } + if (!isValid) { + throw new ServiceException("不支持的单位: " + unit + + ",支持的单位有: pL, nL, uL, mL, L"); + } + } + +}