diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/GspFfjlController.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/GspFfjlController.java index d3f13cb..78a4ab2 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/GspFfjlController.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/GspFfjlController.java @@ -2,6 +2,7 @@ package com.hxhq.business.controller; import java.util.Arrays; import java.util.List; +import java.util.Map; import com.hxhq.business.domain.GspFfjlJcgj; import com.hxhq.business.domain.MjyFfjlJcgj; @@ -15,6 +16,7 @@ import com.hxhq.business.service.IStudyService; import com.hxhq.common.core.utils.StringUtils; import com.hxhq.common.security.annotation.RequiresPermissions; import com.hxhq.common.security.utils.SecurityUtils; +import org.aspectj.weaver.loadtime.Aj; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -54,6 +56,18 @@ public class GspFfjlController extends BaseController } /** + * 出库量、入库量、使用量 统计 + * @param form + * @return + */ + @GetMapping("/statistics") + public AjaxResult getStatistics(GspSearchListForm form) + { + Map statistics = gspFfjlService.getStatistics(form); + return success(statistics); + } + + /** * 详细信息 */ @GetMapping(value = "/info") diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/GspRkjlController.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/GspRkjlController.java index 6b71b28..60f59b5 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/GspRkjlController.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/GspRkjlController.java @@ -1,10 +1,8 @@ package com.hxhq.business.controller; import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.List; +import java.math.BigDecimal; +import java.util.*; import cn.hutool.json.JSONUtil; import com.hxhq.business.domain.GspFfjlJcgj; @@ -84,6 +82,18 @@ public class GspRkjlController extends BaseController } /** + * 统计入库量 + * @return + */ + @GetMapping("/sumRkl") + public AjaxResult sumRkl(GspSearchListForm form) { + String rkl = gspRkjlService.getRkl(form); + Map result = new HashMap<>(); + result.put("rkl", rkl); + return success(result); + } + + /** * 新增供试品入库记录信息 */ @PostMapping("/xz") 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 9b0acb3..81a8971 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 @@ -279,6 +279,7 @@ public class PublicController extends BaseController { @GetMapping("/cellList") public TableDataInfo getCellList(StudyCellSearchForm form) { startPage(); + form.setStudyId(null); List cells = cellService.queryStudyList(form); return getDataTable(cells); } @@ -290,6 +291,7 @@ public class PublicController extends BaseController { @GetMapping("/bacteriaList") public TableDataInfo getBacteriaList(StudyCellSearchForm form) { startPage(); + form.setStudyId(null); List list = bacteriaService.queryStudyList(form); return getDataTable(list); } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/Gsp.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/Gsp.java index 089470b..cf6328b 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/Gsp.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/Gsp.java @@ -33,6 +33,15 @@ public class Gsp extends MpBaseEntity /** 库存编辑状态:1:未编辑 3:审核中 */ private Integer kcbjzt; + /** 存储状态:1:取出;3:存储*/ + private Integer cczt; + + /** 试验id */ + private Long studyId; + + /** 表单id */ + private Long studyFormId; + /** 名称 */ @Compare(name = "名称", nameEn = "Name") private String mc; @@ -72,6 +81,9 @@ public class Gsp extends MpBaseEntity @Compare(name = "存储条件", nameEn = "Storage Condition") private String cctj; + /** 存储位置 */ + private String ccwz; + /** 注意事项 */ @Compare(name = "注意事项", nameEn = "Notification") private String zysx; @@ -630,4 +642,37 @@ public class Gsp extends MpBaseEntity public void setMdOther(String mdOther) { this.mdOther = mdOther; } + + public Long getStudyId() { + return studyId; + } + + public void setStudyId(Long studyId) { + this.studyId = studyId; + } + + public Long getStudyFormId() { + return studyFormId; + } + + public void setStudyFormId(Long studyFormId) { + this.studyFormId = studyFormId; + } + + public Integer getCczt() { + return cczt; + } + + public void setCczt(Integer cczt) { + this.cczt = cczt; + } + + public String getCcwz() { + return ccwz; + } + + public void setCcwz(String ccwz) { + this.ccwz = ccwz; + } + } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/GspFfjl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/GspFfjl.java index 742d8a3..6b3793d 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/GspFfjl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/GspFfjl.java @@ -1,5 +1,6 @@ package com.hxhq.business.domain; +import java.math.BigDecimal; import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; import com.baomidou.mybatisplus.annotation.TableName; @@ -23,6 +24,9 @@ public class GspFfjl extends MpBaseEntity /** 借阅状态 1:未借阅 3:待借阅 5:借阅中 */ private Integer jyzt; + /** 暂存柜id */ + private Long zcgId; + /** 供试品id */ private Long gspId; @@ -60,6 +64,9 @@ public class GspFfjl extends MpBaseEntity /** 出库单位 */ private String ckldw; + /** 出库数量-基础单位 */ + private BigDecimal basicCkl; + /** 领取人1id */ private Long lqr1Id; @@ -121,12 +128,18 @@ public class GspFfjl extends MpBaseEntity /** 入库单位 */ private String rkldw; + /** 入库数量-基础单位 */ + private BigDecimal basicRkl; + /** 使用量 */ private String syl; /** 使用量单位 */ private String syldw; + /** 使用量-基础单位 */ + private BigDecimal basicSyl; + /** 归还日期 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date ghrq; @@ -575,4 +588,36 @@ public class GspFfjl extends MpBaseEntity public void setMdOther(String mdOther) { this.mdOther = mdOther; } + + public BigDecimal getBasicCkl() { + return basicCkl; + } + + public void setBasicCkl(BigDecimal basicCkl) { + this.basicCkl = basicCkl; + } + + public BigDecimal getBasicRkl() { + return basicRkl; + } + + public void setBasicRkl(BigDecimal basicRkl) { + this.basicRkl = basicRkl; + } + + public BigDecimal getBasicSyl() { + return basicSyl; + } + + public void setBasicSyl(BigDecimal basicSyl) { + this.basicSyl = basicSyl; + } + + public Long getZcgId() { + return zcgId; + } + + public void setZcgId(Long zcgId) { + this.zcgId = zcgId; + } } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/GspJcgj.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/GspJcgj.java index edbab50..c8bf2eb 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/GspJcgj.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/GspJcgj.java @@ -18,6 +18,9 @@ public class GspJcgj extends MpBaseEntity /** 供试品id */ private Long gspId; + /** 供试品编号 */ + private String gspBh; + /** 稽查轨迹类型 */ private Integer jcgjlx; @@ -133,4 +136,12 @@ public class GspJcgj extends MpBaseEntity public void setQmrMcEn(String qmrMcEn) { this.qmrMcEn = qmrMcEn; } + + public String getGspBh() { + return gspBh; + } + + public void setGspBh(String gspBh) { + this.gspBh = gspBh; + } } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/GspRkjl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/GspRkjl.java index b96b7da..5946cd3 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/GspRkjl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/GspRkjl.java @@ -1,5 +1,6 @@ package com.hxhq.business.domain; +import java.math.BigDecimal; import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; import com.baomidou.mybatisplus.annotation.TableName; @@ -44,6 +45,9 @@ public class GspRkjl extends MpBaseEntity @Compare(name = "入库量", nameEn = "Amount In") private String rkl; + /** 基本单位-入库数量 */ + private BigDecimal basicRkl; + /** 入库单位 */ @Compare(name = "入库量单位", nameEn = "Amount In Unit") private String rkdw; @@ -244,4 +248,12 @@ public class GspRkjl extends MpBaseEntity public void setYxq(Date yxq) { this.yxq = yxq; } + + public BigDecimal getBasicRkl() { + return basicRkl; + } + + public void setBasicRkl(BigDecimal basicRkl) { + this.basicRkl = basicRkl; + } } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/SjJcgj.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/SjJcgj.java index 04ec947..c090f25 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/SjJcgj.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/SjJcgj.java @@ -18,6 +18,9 @@ public class SjJcgj extends MpBaseEntity /** 试剂id */ private Long sjId; + /** 试剂编号 */ + private String sjBh; + /** 稽查轨迹类型 */ private Integer jcgjlx; @@ -133,4 +136,12 @@ public class SjJcgj extends MpBaseEntity public String getQmrMc() { return qmrMc; } + + public String getSjBh() { + return sjBh; + } + + public void setSjBh(String sjBh) { + this.sjBh = sjBh; + } } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/GspFfjlMapper.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/GspFfjlMapper.java index 8404725..7f266b1 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/GspFfjlMapper.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/GspFfjlMapper.java @@ -3,12 +3,15 @@ package com.hxhq.business.mapper; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.hxhq.business.domain.GspFfjl; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hxhq.business.domain.GspRkjl; import com.hxhq.business.domain.GyzjFfjl; import com.hxhq.business.dto.gsp.GspFfjlListDto; import com.hxhq.business.dto.gyzj.FfjlListDto; import org.apache.ibatis.annotations.Param; +import java.math.BigDecimal; import java.util.List; +import java.util.Map; /** * 供试品发放记录Mapper接口 @@ -32,4 +35,35 @@ public interface GspFfjlMapper extends BaseMapper * @return */ GspFfjlListDto queryInfo(Long id); + + /** + * 出库量、入库量、使用量 出现频率最高的单位 + * @param queryWrapper + * @return + */ + Map getStatisticsUnit(@Param("ew") Wrapper queryWrapper); + Map getStatistics(@Param("ew") Wrapper queryWrapper, @Param("rkldw") String rkldw, @Param("ckldw") String ckldw, @Param("syldw") String syldw); + + + /** + * 入库量 统计 + * @param queryWrapper + * @return + */ + BigDecimal sumRkl(@Param("ew") Wrapper queryWrapper); + + /** + * 出库量 统计 + * @param queryWrapper + * @return + */ + BigDecimal sumCkl(@Param("ew") Wrapper queryWrapper); + + /** + * 使用量 统计 + * @param queryWrapper + * @return + */ + BigDecimal sumSyl(@Param("ew") Wrapper queryWrapper); + } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/GspMapper.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/GspMapper.java index 6d00ebd..4b62f42 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/GspMapper.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/GspMapper.java @@ -33,4 +33,26 @@ public interface GspMapper extends BaseMapper * @return */ GspDto queryInfo(Long id); + + /** + * 修改库存 + * @param id 试剂id + * @param kc 库存量 + */ + void updateKc(@Param("id") Long id, @Param("kc") String kc); + + /** + * 批量修改库存 + * @param idList id + * @param kc 库存量 + */ + void updateKcBatch(@Param("idList") List idList, @Param("kc") String kc); + + /** + * 修改存储条件 + * @param idList id + * @param cctj 存储条件 + * @param ccwz 存储位置 + */ + void updateCc(@Param("idList") List idList, @Param("cctj") String cctj, @Param("ccwz") String ccwz); } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/GspRkjlMapper.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/GspRkjlMapper.java index 98672e3..746c494 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/GspRkjlMapper.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/GspRkjlMapper.java @@ -1,7 +1,14 @@ package com.hxhq.business.mapper; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.hxhq.business.domain.Gsp; import com.hxhq.business.domain.GspRkjl; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; + +import java.math.BigDecimal; +import java.util.Map; + /** * 供试品入库记录Mapper接口 * @@ -11,4 +18,20 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; public interface GspRkjlMapper extends BaseMapper { + + + /** + * 筛选项中出现频率最高的入库单位 + * @param queryWrapper + * @return + */ + Map getRklUnit(@Param("ew") Wrapper queryWrapper); + + /** + * 统计入库量 + * @param queryWrapper + * @return + */ + BigDecimal sumRkl(@Param("ew") Wrapper queryWrapper); + } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IBacteriaService.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IBacteriaService.java index 199b05c..d4c46db 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IBacteriaService.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IBacteriaService.java @@ -24,6 +24,7 @@ public interface IBacteriaService extends IService */ List queryStudyList(StudyCellSearchForm form); + /** * 处置 * @param form 处置表单 diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/ICellService.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/ICellService.java index 1e509c6..e752323 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/ICellService.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/ICellService.java @@ -24,6 +24,7 @@ public interface ICellService extends IService */ public List queryStudyList(StudyCellSearchForm form); + /** * 处置 * @param form 处置表单 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 534a1d3..65171e7 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 @@ -2,6 +2,7 @@ package com.hxhq.business.service; import java.util.Date; import java.util.List; +import java.util.Map; import com.hxhq.business.domain.Gsp; import com.hxhq.business.domain.GspFfjl; @@ -169,4 +170,16 @@ public interface IGspFfjlService extends IService * 借阅到期自动归还 */ public void autoJyExpireReturn(); + + /** + * 出库量、入库量、使用量 出现频率最高的单位 + * @return + */ + Map getStatisticsUnit(GspSearchListForm form); + + /** + * 出库量、入库量、使用量 统计 + * @return + */ + Map getStatistics(GspSearchListForm 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 59b288c..ca592f0 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 @@ -2,11 +2,8 @@ package com.hxhq.business.service; import java.util.List; -import com.hxhq.business.domain.Gsp; -import com.hxhq.business.domain.GspJcgj; +import com.hxhq.business.domain.*; import com.baomidou.mybatisplus.extension.service.IService; -import com.hxhq.business.domain.Sj; -import com.hxhq.business.domain.SjJcgj; import com.hxhq.system.api.domain.SysUser; /** @@ -46,23 +43,30 @@ public interface IGspJcgjService extends IService void saveBatchWithLog(Gsp gsp, List jcgjList); /** + * 批量保存稽查轨迹-并保留日志 + * @param jcgjList + */ + void saveBatchWithLog(List jcgjList); + + /** * 保存稽查轨迹-并保留日志 * @param gsp * @param jcgj */ void saveWithLog(Gsp gsp, GspJcgj jcgj); + /** - * 生成稽查轨迹 - * @param gspId 供试品id - * @param jcgjlx 稽查轨迹类型:1:流程;3:编辑 - * @param jcmc 稽查名称 - * @param jcmcEn 稽查名称-英文 - * @param jcmcys 稽查名称颜色:1:蓝色;3:红色;5:绿色;7:橙色 - * @param jcnr 稽查内容 - * @param jcnrEn 稽查内容-英文 - * @param qmr 签名人信息 + * 新增稽查轨迹 + * @param gsp 供试品 + * @param jcgjlx 稽查轨迹类型:1:流程;3:编辑 + * @param jcmc 稽查名称 + * @param jcmcys 稽查名称颜色:1:蓝色;3:红色;5:绿色;7:橙色 + * @param jcnr 稽查内容 + * @param jcnrEn 稽查内容英文 + * @param qmr 签名人 + * @param remark 备注 * @return */ - GspJcgj genJcgj(Long gspId, Integer jcgjlx, String jcmc, String jcmcEn, Integer jcmcys, String jcnr, String jcnrEn, SysUser qmr); + public GspJcgj getJcgj(Gsp gsp, Integer jcgjlx, String jcmc, Integer jcmcys, String jcnr, String jcnrEn, SysUser qmr, String remark); } 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 ef8fb0c..4f11e33 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 @@ -1,5 +1,6 @@ package com.hxhq.business.service; +import java.math.BigDecimal; import java.util.List; import com.hxhq.business.domain.GspRkjl; import com.baomidou.mybatisplus.extension.service.IService; @@ -136,4 +137,18 @@ public interface IGspRkjlService extends IService * 借阅到期自动归还 */ public void autoJyExpireReturn(); + + /** + * 筛选项中出现频率最高的入库量单位 + * @param form + * @return + */ + public String getRklUnit(GspSearchListForm form); + + /** + * 统计入库量 + * @param form + * @return + */ + String getRkl(GspSearchListForm 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 9a813de..28c1ae0 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 @@ -9,6 +9,7 @@ import com.hxhq.business.dto.gsp.GspDto; import com.hxhq.business.dto.gsp.GspListDto; import com.hxhq.business.form.gsp.*; import com.hxhq.business.form.gyzj.SearchForm; +import com.hxhq.business.form.study.StudyFormConfigurationForm; /** * 供试品管理Service接口 diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGspTzService.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGspTzService.java index ef0a88e..1a88870 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGspTzService.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGspTzService.java @@ -3,6 +3,7 @@ package com.hxhq.business.service; import java.util.List; import com.hxhq.business.domain.GspTz; import com.baomidou.mybatisplus.extension.service.IService; +import com.hxhq.business.domain.GyzjTz; import com.hxhq.system.api.domain.SysUser; /** @@ -67,4 +68,27 @@ public interface IGspTzService extends IService */ public void saveGhTz(Long gspId, SysUser ghr1, SysUser ghr2, SysUser jsr1, SysUser jsr2, SysUser qmr, String qmyy,String qmyyEn, String czl, String czldw, String remark); + + + /** + * 新增台账 + * @param gspId 供试品id + * @param lqr1 领取人1 + * @param lqr2 领取人2 + * @param ghr1 归还人1 + * @param ghr2 归还人2 + * @param ffr1 发放人1 + * @param ffr2 发放人2 + * @param jsr1 接收人1 + * @param jsr2 接收人2 + * @param qmr 签名人 + * @param qmyy 签名意义 + * @param czl 操作量 + * @param czldw 操作量单位 + * @param remark 备注 + * @param bdId 表单id + * @return + */ + public GspTz getTzGen(Long gspId, SysUser lqr1, SysUser lqr2, SysUser ghr1, SysUser ghr2, SysUser ffr1, SysUser ffr2, SysUser jsr1, SysUser jsr2, SysUser qmr, String qmyy, String czl, String czldw, String remark, Long bdId); + } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/ISjJcgjService.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/ISjJcgjService.java index 94baecd..6898c30 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/ISjJcgjService.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/ISjJcgjService.java @@ -29,6 +29,7 @@ public interface ISjJcgjService extends IService * @param sjJcgjList */ void saveBatchWithLog(Sj sj, List sjJcgjList); + void saveBatchWithLog(List sjJcgjList); /** * 保存稽查轨迹-并保留日志 @@ -51,7 +52,7 @@ public interface ISjJcgjService extends IService /** * 生成稽查轨迹 - * @param sjId 试剂id + * @param sj 试剂 * @param jcgjlx 稽查轨迹类型:1:流程;3:编辑 * @param jcmc 稽查名称 * @param jcmcEn 稽查名称-英文 @@ -61,5 +62,5 @@ public interface ISjJcgjService extends IService * @param qmr 签名人信息 * @return */ - SjJcgj genJcgj(Long sjId, Integer jcgjlx, String jcmc, String jcmcEn, Integer jcmcys, String jcnr, String jcnrEn, SysUser qmr); + SjJcgj genJcgj(Sj sj, 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/impl/CellServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/CellServiceImpl.java index ab22f2c..9b7ba17 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/CellServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/CellServiceImpl.java @@ -82,6 +82,7 @@ public class CellServiceImpl extends ServiceImpl implements IC return baseMapper.queryStudyList(queryWrapper); } + @Override public void cz(CzForm form) { SysUser qmr = sysUserService.selectUserById(form.getQmrId()); 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 12ceba1..01ee688 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 @@ -17,6 +17,7 @@ import com.hxhq.business.form.gsp.GspSearchListForm; import com.hxhq.business.form.mjy.*; import com.hxhq.business.service.*; import com.hxhq.business.utils.JctUtil; +import com.hxhq.business.utils.UnitTools; import com.hxhq.common.core.exception.ServiceException; import com.hxhq.common.core.utils.DateUtils; import com.hxhq.common.core.utils.StringUtils; @@ -88,6 +89,11 @@ public class GspFfjlServiceImpl extends ServiceImpl impl if (StringUtils.isNoneBlank(form.getEndDateRk())) { queryWrapper.apply("t.ghrq>={0}", form.getEndDateRk()); } + if (StringUtils.isNoneBlank(form.getMd())) { + queryWrapper.and(p -> p.like("t.md_other", form.getMd()) + .or().apply(" exists(select s.* from t_study s where find_in_set(s.id, t.`md_ids`) and s.name like CONCAT('%', {0}, '%'))",form.getMd()) + ); + } queryWrapper.orderByDesc("t.id"); return baseMapper.queryList(queryWrapper); } @@ -115,6 +121,8 @@ public class GspFfjlServiceImpl extends ServiceImpl impl gspFfjl.setFfzytj(zytj); gspFfjl.setCkl(ckl); gspFfjl.setCkldw(ckdw); + BigDecimal basicCkl = UnitTools.convert2Basic(ckl, ckdw); + gspFfjl.setBasicCkl(basicCkl); gspFfjl.setJyzt(JyztEnum.wjy.getValue()); gspFfjl.setJlzt(JlztEnum.wsd.getValue()); gspFfjl.setMdIds(gsp.getMdIds()); @@ -181,11 +189,19 @@ public class GspFfjlServiceImpl extends ServiceImpl impl throw new ServiceException("入库量不应大于出库量"); } BigDecimal syl = ckl.subtract(rkl); + // 使用量 gspFfjl.setSyl(syl.toString()); gspFfjl.setSyldw(gspFfjl.getCkldw()); + BigDecimal basicSyl = UnitTools.convert2Basic(syl.toString(), gspFfjl.getCkldw()); + gspFfjl.setBasicSyl(basicSyl); + gspFfjl.setGhzytj(form.getGhzytj()); + // 入库量 gspFfjl.setRkl(form.getRkl()); gspFfjl.setRkldw(form.getRkldw()); + BigDecimal basicRkl = UnitTools.convert2Basic(form.getRkl(), form.getRkldw()); + + gspFfjl.setBasicRkl(basicRkl); gspFfjl.setGhr1Id(ghr1.getUserId()); gspFfjl.setGhr1Mc(ghr1.getNickName()); if(ghr2 != null) { @@ -845,6 +861,104 @@ public class GspFfjlServiceImpl extends ServiceImpl impl } } + @Override + public Map getStatisticsUnit(GspSearchListForm form) { + QueryWrapper queryWrapper = Wrappers.query(); + queryWrapper.eq("del_flag", "0"); + if (form.getJyzt() != null && form.getJyzt().intValue() > 0) { + queryWrapper.eq("jyzt", form.getJyzt()); + } + if (form.getJlzt() != null && form.getJlzt().intValue() > 0) { + queryWrapper.eq("jlzt", form.getJlzt()); + } + if (StringUtils.isNoneBlank(form.getMc())) { + queryWrapper.and(p -> p.like("`mc`", form.getMc())); + } + if (StringUtils.isNoneBlank(form.getBh())) { + queryWrapper.and(p -> p.like("`bh`", form.getBh())); + } + if (StringUtils.isNoneBlank(form.getStartDateCk())) { + queryWrapper.and(p -> p.apply("ffrq>={0}", form.getStartDateCk())); + } + if (StringUtils.isNoneBlank(form.getEndDateCk())) { + queryWrapper.apply("ffrq>={0}", form.getStartDateCk()); + } + if (StringUtils.isNoneBlank(form.getStartDateRk())) { + queryWrapper.and(p -> p.apply("ghrq>={0}", form.getStartDateRk())); + } + if (StringUtils.isNoneBlank(form.getEndDateRk())) { + queryWrapper.apply("ghrq>={0}", form.getEndDateRk()); + } + return baseMapper.getStatisticsUnit(queryWrapper); + } + + @Override + public Map getStatistics(GspSearchListForm form) { + Map result = new HashMap<>(); + result.put("ckl", "0"); + result.put("rkl", "0"); + result.put("syl", "0"); + + Map unitMap = getStatisticsUnit(form); + if(unitMap == null || unitMap.size() == 0) { + return result; + } + String ckldw = unitMap.get("ckldw"); + String syldw = unitMap.get("syldw"); + String rkldw = unitMap.get("rkldw"); + + QueryWrapper queryWrapper = Wrappers.query(); + queryWrapper.eq("del_flag", 0); + if (form.getJyzt() != null && form.getJyzt().intValue() > 0) { + queryWrapper.eq("jyzt", form.getJyzt()); + } + if (form.getJlzt() != null && form.getJlzt().intValue() > 0) { + queryWrapper.eq("jlzt", form.getJlzt()); + } + if (StringUtils.isNoneBlank(form.getMc())) { + queryWrapper.and(p -> p.like("`mc`", form.getMc())); + } + if (StringUtils.isNoneBlank(form.getBh())) { + queryWrapper.and(p -> p.like("`bh`", form.getBh())); + } + if (StringUtils.isNoneBlank(form.getStartDateCk())) { + queryWrapper.and(p -> p.apply("ffrq>={0}", form.getStartDateCk())); + } + if (StringUtils.isNoneBlank(form.getEndDateCk())) { + queryWrapper.apply("ffrq>={0}", form.getStartDateCk()); + } + if (StringUtils.isNoneBlank(form.getStartDateRk())) { + queryWrapper.and(p -> p.apply("ghrq>={0}", form.getStartDateRk())); + } + if (StringUtils.isNoneBlank(form.getEndDateRk())) { + queryWrapper.apply("ghrq>={0}", form.getEndDateRk()); + } + Map map = baseMapper.getStatistics(queryWrapper, rkldw, ckldw, syldw); + + if(StringUtils.isNotEmpty(rkldw)) { + Double rkl = map.get("rkl"); + BigDecimal rklTotal = UnitTools.convert(new BigDecimal(rkl), rkldw); + result.put("rkl", rklTotal.toString() + rkldw); + } + + + if(StringUtils.isNotEmpty(ckldw)) { + Double ckl = map.get("ckl"); + BigDecimal cklTotal = UnitTools.convert(new BigDecimal(ckl), ckldw); + result.put("ckl", cklTotal.toString() + ckldw); + } + + + if(StringUtils.isNotEmpty(syldw)) { + Double syl = map.get("syl"); + BigDecimal sylTotal = UnitTools.convert(new BigDecimal(syl), syldw); + result.put("syl", sylTotal.toString() + syldw); + } + + + return result; + } + /** * 获取通知的跳转url * @param tab diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GspJcgjServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GspJcgjServiceImpl.java index b98cebb..b16747e 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GspJcgjServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GspJcgjServiceImpl.java @@ -6,10 +6,9 @@ import java.util.List; 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.Gsp; -import com.hxhq.business.domain.MjyJcgj; -import com.hxhq.business.domain.SjJcgj; +import com.hxhq.business.domain.*; import com.hxhq.business.service.ISystemLogService; +import com.hxhq.business.utils.lang.GyzjJcnrUtil; import com.hxhq.common.core.domain.MpBaseEntity; import com.hxhq.common.core.utils.StringUtils; import com.hxhq.system.api.domain.SysUser; @@ -17,7 +16,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import com.hxhq.business.mapper.GspJcgjMapper; -import com.hxhq.business.domain.GspJcgj; import com.hxhq.business.service.IGspJcgjService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -65,6 +63,7 @@ public class GspJcgjServiceImpl extends ServiceImpl impl GspJcgj jcgj = new GspJcgj(); jcgj.setGspId(gsp.getId()); + jcgj.setGspBh(gsp.getBh()); jcgj.setJcgjlx(jcgjlx); jcgj.setJcmc(jcmc); jcgj.setJcmcEn(jcmcEn); @@ -87,6 +86,7 @@ public class GspJcgjServiceImpl extends ServiceImpl impl Date date = new Date(); for (GspJcgj gspJcgj : jcgjList) { gspJcgj.setCreateTime(date); + gspJcgj.setGspBh(gsp.getBh()); } this.saveBatch(jcgjList); for (GspJcgj jcgj : jcgjList) { @@ -97,22 +97,35 @@ public class GspJcgjServiceImpl extends ServiceImpl impl @Override @Async + public void saveBatchWithLog(List jcgjList) { + Date date = new Date(); + for (GspJcgj jcgj : jcgjList) { + systemLogService.saveInfoWithData(jcgj.getGspBh(), jcgj.getGspBh(), jcgj.getJcmc(), jcgj.getJcmcEn(), + jcgj.getJcnr(), jcgj.getJcnrEn(), jcgj.getQmrId(), jcgj.getQmrMc(), jcgj.getQmrMcEn(), jcgj.getRemark(), date); + } + } + + @Override + @Async public void saveWithLog(Gsp gsp, GspJcgj jcgj) { Date date = new Date(); jcgj.setCreateTime(date); + jcgj.setGspBh(gsp.getBh()); this.save(jcgj); systemLogService.saveInfoWithData(gsp.getBh(), gsp.getBh(), jcgj.getJcmc(), jcgj.getJcmcEn(), jcgj.getJcnr(), jcgj.getJcnrEn(), jcgj.getQmrId(), jcgj.getQmrMc(), jcgj.getQmrMcEn(), jcgj.getRemark(), date); } + @Override - public GspJcgj genJcgj(Long gspId, Integer jcgjlx, String jcmc, String jcmcEn, Integer jcmcys, String jcnr, String jcnrEn, SysUser qmr) { + public GspJcgj getJcgj(Gsp gsp, Integer jcgjlx, String jcmc, Integer jcmcys, String jcnr, String jcnrEn, SysUser qmr, String remark) { GspJcgj gspJcgj = new GspJcgj(); - gspJcgj.setGspId(gspId); + gspJcgj.setGspId(gsp.getId()); + gspJcgj.setGspBh(gsp.getBh()); gspJcgj.setJcgjlx(jcgjlx); gspJcgj.setJcmc(jcmc); - gspJcgj.setJcmcEn(jcmcEn); + gspJcgj.setJcmcEn(GyzjJcnrUtil.getEn(jcmc)); gspJcgj.setJcmcys(jcmcys); gspJcgj.setJcnr(jcnr); gspJcgj.setJcnr(jcnrEn); diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GspRkjlServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GspRkjlServiceImpl.java index b292acc..5325042 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GspRkjlServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GspRkjlServiceImpl.java @@ -1,5 +1,6 @@ package com.hxhq.business.service.impl; +import java.math.BigDecimal; import java.util.*; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -12,6 +13,7 @@ import com.hxhq.business.service.IGspRkjlJcgjService; import com.hxhq.business.service.INoticeService; import com.hxhq.business.utils.JctUtil; import com.hxhq.business.utils.ObjectCompareUtil; +import com.hxhq.business.utils.UnitTools; import com.hxhq.common.core.exception.ServiceException; import com.hxhq.common.core.utils.DateUtils; import com.hxhq.common.security.utils.SecurityUtils; @@ -55,14 +57,11 @@ public class GspRkjlServiceImpl extends ServiceImpl impl if(StringUtils.isNotEmpty(form.getMc())) { queryWrapper.like("mc", form.getMc()); } - if(StringUtils.isNotEmpty(form.getBh())) { - queryWrapper.like("bh", form.getBh()); - } if(StringUtils.isNotEmpty(form.getPh())) { queryWrapper.like("ph", form.getPh()); } if(StringUtils.isNotEmpty(form.getGg())) { - queryWrapper.and(p -> p.apply("CONCAT(gg, ggdw) LIKE #{0}", form.getGg())); + queryWrapper.and(p -> p.apply("CONCAT(gg, ggdw) LIKE {0}", form.getGg())); } if(StringUtils.isNotEmpty(form.getStartDate())) { queryWrapper.ge("rksj", form.getStartDate()); @@ -79,6 +78,7 @@ public class GspRkjlServiceImpl extends ServiceImpl impl if(form.getArchive() != null && form.getArchive() == DaztEnum.ygd.getValue()) { queryWrapper.in("jlzt", JlztEnum.dgd.getValue(), JlztEnum.gd.getValue(), JlztEnum.djd.getValue()); } + queryWrapper.orderByDesc("id"); return this.list(queryWrapper); } @@ -90,6 +90,9 @@ public class GspRkjlServiceImpl extends ServiceImpl impl BeanUtils.copyProperties(form, gspRkjl); gspRkjl.setJlzt(JlztEnum.wsd.getValue()); gspRkjl.setJyzt(JyztEnum.wjy.getValue()); + BigDecimal basicRkl = UnitTools.convert2Basic(gspRkjl.getRkl(), gspRkjl.getRkdw()); + gspRkjl.setBasicRkl(basicRkl); + this.save(gspRkjl); Map formData = new LinkedHashMap<>(); @@ -112,6 +115,8 @@ public class GspRkjlServiceImpl extends ServiceImpl impl BeanUtils.copyProperties(gspRkjlForm, gspRkjl); gspRkjl.setJlzt(JlztEnum.wsd.getValue()); gspRkjl.setJyzt(JyztEnum.wjy.getValue()); + BigDecimal basicRkl = UnitTools.convert2Basic(gspRkjl.getRkl(), gspRkjl.getRkdw()); + gspRkjl.setBasicRkl(basicRkl); gspRkjlList.add(gspRkjl); } this.saveBatch(gspRkjlList); @@ -650,6 +655,80 @@ public class GspRkjlServiceImpl extends ServiceImpl impl } } + @Override + public String getRklUnit(GspSearchListForm form) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.isNotNull("rkdw") + .eq("del_flag", 0); + if(StringUtils.isNotEmpty(form.getMc())) { + queryWrapper.like("mc", form.getMc()); + } + if(StringUtils.isNotEmpty(form.getPh())) { + queryWrapper.like("ph", form.getPh()); + } + if(StringUtils.isNotEmpty(form.getGg())) { + queryWrapper.and(p -> p.apply("CONCAT(gg, ggdw) LIKE {0}", form.getGg())); + } + if(StringUtils.isNotEmpty(form.getStartDate())) { + queryWrapper.ge("rksj", form.getStartDate()); + } + if(StringUtils.isNotEmpty(form.getEndDate())) { + queryWrapper.le("rksj", form.getEndDate()); + } + if(form.getJlzt() != null) { + queryWrapper.eq("jlzt", form.getJlzt()); + } + if(form.getJyzt() != null) { + queryWrapper.eq("jyzt", form.getJyzt()); + } + if(form.getArchive() != null && form.getArchive() == DaztEnum.ygd.getValue()) { + queryWrapper.in("jlzt", JlztEnum.dgd.getValue(), JlztEnum.gd.getValue(), JlztEnum.djd.getValue()); + } + Map map = baseMapper.getRklUnit(queryWrapper); + return map.get("rkdw"); + } + + @Override + public String getRkl(GspSearchListForm form) { + String rkdw = getRklUnit(form); + if(StringUtils.isEmpty(rkdw)) { + return null; + } + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.isNotNull("rkdw") + .eq("rkdw", rkdw) + .eq("del_flag", 0); + if(StringUtils.isNotEmpty(form.getMc())) { + queryWrapper.like("mc", form.getMc()); + } + if(StringUtils.isNotEmpty(form.getPh())) { + queryWrapper.like("ph", form.getPh()); + } + if(StringUtils.isNotEmpty(form.getGg())) { + queryWrapper.and(p -> p.apply("CONCAT(gg, ggdw) LIKE {0}", form.getGg())); + } + if(StringUtils.isNotEmpty(form.getStartDate())) { + queryWrapper.ge("rksj", form.getStartDate()); + } + if(StringUtils.isNotEmpty(form.getEndDate())) { + queryWrapper.le("rksj", form.getEndDate()); + } + if(form.getJlzt() != null) { + queryWrapper.eq("jlzt", form.getJlzt()); + } + if(form.getJyzt() != null) { + queryWrapper.eq("jyzt", form.getJyzt()); + } + if(form.getArchive() != null && form.getArchive() == DaztEnum.ygd.getValue()) { + queryWrapper.in("jlzt", JlztEnum.dgd.getValue(), JlztEnum.gd.getValue(), JlztEnum.djd.getValue()); + } + BigDecimal rkl = baseMapper.sumRkl(queryWrapper); + + // 单位转换 + rkl = UnitTools.convert(rkl, rkdw); + return rkl.toString() + rkdw; + } + /** * 获取通知的跳转url * @param tab diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GspServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GspServiceImpl.java index 3aa8aa0..c79c47a 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GspServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GspServiceImpl.java @@ -4,17 +4,26 @@ import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; +import cn.hutool.json.JSONUtil; +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.GspDto; import com.hxhq.business.dto.gsp.GspListDto; +import com.hxhq.business.dto.study.StudyFormFillCc; +import com.hxhq.business.dto.study.StudyFormFillCz; +import com.hxhq.business.dto.study.StudyFormFillResource; import com.hxhq.business.enums.archive.ArchiveLogTypeEnum; +import com.hxhq.business.enums.study.StudyFormFillResourceTypeEnum; import com.hxhq.business.enums.zykgl.*; import com.hxhq.business.form.gsp.*; +import com.hxhq.business.form.study.StudyFormConfigurationForm; import com.hxhq.business.service.*; import com.hxhq.business.utils.JctUtil; import com.hxhq.business.utils.ObjectCompareUtil; +import com.hxhq.business.utils.UnitTools; +import com.hxhq.business.utils.lang.GyzjJcnrUtil; import com.hxhq.common.core.exception.ServiceException; import com.hxhq.common.core.utils.DateUtils; import com.hxhq.common.security.utils.SecurityUtils; @@ -58,6 +67,9 @@ public class GspServiceImpl extends ServiceImpl implements IGspS @Autowired private INoticeService noticeService; + @Autowired + private IStudyGspService studyGspService; + /** * 药剂存储 * @param studyFormFill @@ -66,9 +78,125 @@ public class GspServiceImpl extends ServiceImpl implements IGspS */ @Override public void storageResource(StudyFormFill studyFormFill, Template template,String remark){ - //todo + Boolean mark = template.getProduct().equals(StudyFormFillResourceTypeEnum.gsp.getValue()) ? true : false; + SysUser qmr = sysUserService.selectUserById(SecurityUtils.getUserId()); + Long studyId = studyFormFill.getStudyId(); + String resource = studyFormFill.getResource(); + Map gspMap = new HashMap<>(10); + List gspList = new ArrayList<>(); + LinkedList jcgjList = new LinkedList<>(); + LinkedList tzList = new LinkedList<>(); + String empty = "[]"; + if (com.hxhq.common.core.utils.StringUtils.isNotEmpty(resource) && !com.hxhq.common.core.utils.StringUtils.equals(empty, resource)) { + List studyFormFillResourceList = JSONUtil.toList(resource, StudyFormFillResource.class); + List tmp = studyFormFillResourceList.stream().filter(p -> (p.getType() == null && mark) || (p.getType() != null && StudyFormFillResourceTypeEnum.gsp.getValue() == p.getType())).collect(Collectors.toList()); + if (tmp.size() > 0) { + List bhList = tmp.stream().map(StudyFormFillResource::getBh).collect(Collectors.toList()); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.in(Gsp::getBh, bhList); + gspList = this.list(queryWrapper); + for (Gsp gsp : gspList) { + gsp.setCczt(CcztEnum.Cc.getValue()); + this.updateById(gsp); + gspMap.put(gsp.getBh(), gsp); + } + // 存储 + cc(studyFormFill, gspMap, jcgjList, tzList, remark, qmr); + } + } + if (jcgjList.size() > 0) { + gspJcgjService.saveBatchWithLog(jcgjList); + } + if (tzList.size() > 0) { + gspTzService.saveBatch(tzList); + } + if (gspList.size() > 0) { + studyGspService.saveBatch(studyId, gspList); + } + } + + /** + * 存储 + * + * @param studyFormFill + * @param gspMap + * @param jcgjList + * @param tzList + * @param remark + */ + public void cc(StudyFormFill studyFormFill, Map gspMap, LinkedList jcgjList, LinkedList tzList, String remark, SysUser qmr) { + String empty = "[]"; + if (gspMap.size() > 0) { + // 存储 + String cclist = studyFormFill.getCclist(); + if (com.hxhq.common.core.utils.StringUtils.isNotEmpty(cclist) && !com.hxhq.common.core.utils.StringUtils.equals(empty, cclist)) { + List studyFormFillCcList = JSONUtil.toList(cclist, StudyFormFillCc.class); + for (StudyFormFillCc studyFormFillCc : studyFormFillCcList) { + List list = new ArrayList<>(); + for (String bh : studyFormFillCc.getList()) { + Gsp gsp = gspMap.get(bh); + if (gsp != null) { + list.add(gsp.getId()); + // 稽查轨迹 + HashMap formData = new HashMap<>(2); + formData.put("存储位置", studyFormFillCc.getCcwz()); + formData.put("存储条件", studyFormFillCc.getCctj()); + jcgjList.add(gspJcgjService.getJcgj(gsp, JcgjlxEnum.lc.getValue(), "存储", JcmcysEnum.green.getValue(), JctUtil.formatStr(formData), JctUtil.formatStr(GyzjJcnrUtil.getMapEn(formData)), qmr, remark)); + // 台账 + tzList.add(gspTzService.getTzGen(gsp.getId(), null, null, null, null, null, null, null, null, qmr, "存储", gsp.getKc(), gsp.getKcdw(), remark, studyFormFill.getId())); + } + } + if (list.size() > 0) { + baseMapper.updateCc(list, studyFormFillCc.getCctj(), studyFormFillCc.getCcwz()); + } + } + } + + } + } + + /** + * 处置 + * + * @param studyFormFill + * @param gspMap + * @param jcgjList + * @param tzList + * @param remark + */ + public void cz(StudyFormFill studyFormFill, Map gspMap, LinkedList jcgjList, LinkedList tzList, String remark, SysUser qmr) { + String empty = "[]"; + if (gspMap.size() > 0) { + + // 处置,库存全变为0 + String czlist = studyFormFill.getCzlist(); + if (com.hxhq.common.core.utils.StringUtils.isNotEmpty(czlist) && !com.hxhq.common.core.utils.StringUtils.equals(empty, czlist)) { + List studyFormFillCzList = JSONUtil.toList(czlist, StudyFormFillCz.class); + for (StudyFormFillCz studyFormFillCz : studyFormFillCzList) { + List list = new ArrayList<>(); + for (String bh : studyFormFillCz.getList()) { + Gsp gsp = gspMap.get(bh); + if (gsp != null) { + list.add(gsp.getId()); + // 稽查轨迹 + HashMap formData = new HashMap<>(2); + formData.put("处置方式", studyFormFillCz.getCzfs()); + formData.put("处置量", gsp.getKc() + gsp.getKcdw()); + jcgjList.add(gspJcgjService.getJcgj(gsp, JcgjlxEnum.lc.getValue(), "处置", JcmcysEnum.green.getValue(), JctUtil.formatStr(formData), JctUtil.formatStr(GyzjJcnrUtil.getMapEn(formData)), qmr, remark)); + + // 台账 + tzList.add(gspTzService.getTzGen(gsp.getId(), null, null, null, null, null, null, null, null, qmr, "处置", gsp.getKc(), gsp.getKcdw(), remark, studyFormFill.getId())); + } + } + if (list.size() > 0) { + baseMapper.updateKcBatch(list, "0"); + } + } + } + } } + /** * 查询供试品管理列表 * @@ -293,12 +421,20 @@ public class GspServiceImpl extends ServiceImpl implements IGspS if (gspList.size() <= form.getIds().length) { throw new ServiceException("供试品已被发放,请不要重复发放"); } + + QueryWrapper gspFfjlQueryWrapper = Wrappers.query(); + gspFfjlQueryWrapper.in("gsp_id", form.getIds()); + List gspFfjlList = gspFfjlService.list(gspFfjlQueryWrapper); + for (GspFfjl gspFfjl : gspFfjlList) { + gspFfjl.setZcgId(zcg.getId()); + } + String glyj = ""; for (Gsp gsp : gspList) { //更新暂存柜id gsp.setZcgId(zcg.getId()); //更新暂存柜关联药剂 - if (com.hxhq.common.core.utils.StringUtils.isBlank(glyj)) { + if (StringUtils.isBlank(glyj)) { glyj += gsp.getMc(); } else { glyj += "," + gsp.getMc(); @@ -336,7 +472,7 @@ public class GspServiceImpl extends ServiceImpl implements IGspS //endregion } - if (com.hxhq.common.core.utils.StringUtils.isBlank(zcg.getGlyj())) { + if (StringUtils.isBlank(zcg.getGlyj())) { zcg.setGlyj(glyj); } else { zcg.setGlyj(zcg.getGlyj() + "," + glyj); @@ -344,6 +480,9 @@ public class GspServiceImpl extends ServiceImpl implements IGspS zcg.setZt(zcgJyztEnum.jyz.getValue()); zcgService.updateById(zcg); this.saveOrUpdateBatch(gspList); + if (gspFfjlList.size() > 0) { + gspFfjlService.updateBatchById(gspFfjlList); + } } @Override @@ -1366,8 +1505,8 @@ public class GspServiceImpl extends ServiceImpl implements IGspS for(Gsp gsp:gspList){ gsp.setJyzt(JyztEnum.wjy.getValue()); //稽查轨迹 - GspJcgj jcgj = gspJcgjService.genJcgj(gsp.getId(), JcgjlxEnum.lc.getValue(), "到期自动归还", "Check-out End on Time", - JcmcysEnum.green.getValue(), null, null, null); + GspJcgj jcgj = gspJcgjService.getJcgj(gsp, JcgjlxEnum.lc.getValue(), "到期自动归还", + JcmcysEnum.green.getValue(), null, null, null, null); jcgjList.add(jcgj); } this.updateBatchById(gspList); diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GspTzServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GspTzServiceImpl.java index 7a220d3..d8b6a46 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GspTzServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GspTzServiceImpl.java @@ -3,12 +3,11 @@ package com.hxhq.business.service.impl; import java.util.List; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.hxhq.business.domain.MjyTz; -import com.hxhq.business.domain.SjTz; +import com.hxhq.business.domain.*; +import com.hxhq.business.utils.lang.GyzjJcnrUtil; import com.hxhq.system.api.domain.SysUser; import org.springframework.stereotype.Service; import com.hxhq.business.mapper.GspTzMapper; -import com.hxhq.business.domain.GspTz; import com.hxhq.business.service.IGspTzService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -93,4 +92,39 @@ public class GspTzServiceImpl extends ServiceImpl implements this.save(gspTz); } + @Override + public GspTz getTzGen(Long gspId, SysUser lqr1, SysUser lqr2, SysUser ghr1, SysUser ghr2, SysUser ffr1, SysUser ffr2, SysUser jsr1, SysUser jsr2, SysUser qmr, String qmyy, String czl, String czldw, String remark, Long bdId) { + GspTz gspTz = new GspTz(); + gspTz.setGspId(gspId); + if (lqr1 != null && lqr2 != null) { + gspTz.setLqrMc(lqr1.getNickName() +","+ lqr2.getNickName()); + gspTz.setLqrMcEn(lqr1.getUserName() +","+ lqr2.getUserName()); + } + + if (ghr1 != null && ghr2 != null) { + gspTz.setGhrMc(ghr1.getNickName() +","+ ghr2.getNickName()); + gspTz.setGhrMcEn(ghr1.getUserName() +","+ ghr2.getUserName()); + } + if (ffr1 != null && ffr2 != null) { + gspTz.setFfrMc(ffr1.getNickName() +","+ ffr2.getNickName()); + gspTz.setFfrMcEn(ffr1.getUserName() +","+ ffr2.getUserName()); + } + if (jsr1 != null && jsr2 != null) { + gspTz.setJsrMc(jsr1.getNickName() +","+ jsr2.getNickName()); + gspTz.setJsrMcEn(jsr1.getUserName() +","+ jsr2.getUserName()); + } + if (qmr != null) { + gspTz.setQmrId(qmr.getUserId()); + gspTz.setQmrMc(qmr.getNickName()); + gspTz.setQmrMcEn(qmr.getUserName()); + } + gspTz.setQmyy(qmyy); + gspTz.setQmyyEn(GyzjJcnrUtil.getEn(qmyy)); + gspTz.setCzldw(czldw); + gspTz.setCzl(czl); + gspTz.setRemark(remark); + gspTz.setBdId(bdId); + return gspTz; + } + } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GyzjServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GyzjServiceImpl.java index b3aed6d..0036bf4 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GyzjServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GyzjServiceImpl.java @@ -24,7 +24,8 @@ import com.hxhq.business.form.study.StudyFormConfigurationForm; import com.hxhq.business.form.study.StudyFormFillSubpackageForm; import com.hxhq.business.form.study.StudyFormFillSubpackageItemForm; import com.hxhq.business.service.*; -import com.hxhq.business.utils.CalUnitTools; +import com.hxhq.business.utils.UnitTools; +import com.hxhq.business.utils.VolumeUnitTools; import com.hxhq.business.utils.JctUtil; import com.hxhq.business.utils.ObjectCompareUtil; import com.hxhq.business.utils.lang.GyzjJcnrUtil; @@ -1515,7 +1516,7 @@ public class GyzjServiceImpl extends ServiceImpl implements IG studyFormFillResource.setLy(gyzj.getLy()); String syl = studyFormFillResource.getSyl(); if (StringUtils.isNotEmpty(syl) && NumberUtils.isParsable(syl)) { - String kc = CalUnitTools.subTj(gyzj.getKc(), gyzj.getKcdw(), syl, studyFormFillResource.getSyldw()); + String kc = UnitTools.subTj(gyzj.getKc(), gyzj.getKcdw(), syl, studyFormFillResource.getSyldw()); gyzj.setKc(kc); baseMapper.updateKc(gyzj.getId(), kc); HashMap formData = new LinkedHashMap<>(); diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/MjyServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/MjyServiceImpl.java index 4560a11..2d3b393 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/MjyServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/MjyServiceImpl.java @@ -20,10 +20,9 @@ import com.hxhq.business.enums.archive.ArchiveLogTypeEnum; import com.hxhq.business.enums.study.StudyFormFillResourceTypeEnum; import com.hxhq.business.enums.zykgl.*; import com.hxhq.business.form.mjy.*; -import com.hxhq.business.form.study.StudyFormConfigurationForm; -import com.hxhq.business.form.study.StudyFormFillSubpackageForm; import com.hxhq.business.service.*; -import com.hxhq.business.utils.CalUnitTools; +import com.hxhq.business.utils.UnitTools; +import com.hxhq.business.utils.VolumeUnitTools; import com.hxhq.business.utils.JctUtil; import com.hxhq.business.utils.ObjectCompareUtil; import com.hxhq.business.utils.lang.MjyJcnrUtil; @@ -1290,7 +1289,7 @@ public class MjyServiceImpl extends ServiceImpl implements IMjyS studyFormFillResource.setLy(mjy.getLy()); String syl = studyFormFillResource.getSyl(); if (StringUtils.isNotEmpty(syl) && NumberUtils.isParsable(syl)) { - String kc = CalUnitTools.subTj(mjy.getKc(), mjy.getKcdw(), syl, studyFormFillResource.getSyldw()); + String kc = UnitTools.subTj(mjy.getKc(), mjy.getKcdw(), syl, studyFormFillResource.getSyldw()); mjy.setKc(kc); baseMapper.updateKc(mjy.getId(), kc); HashMap formData = new LinkedHashMap<>(); diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/SjJcgjServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/SjJcgjServiceImpl.java index 764949d..fa67859 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/SjJcgjServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/SjJcgjServiceImpl.java @@ -57,6 +57,9 @@ public class SjJcgjServiceImpl extends ServiceImpl imple @Override @Async public void saveBatchWithLog(Sj sj, List sjJcgjList) { + for (SjJcgj sjJcgj : sjJcgjList) { + sjJcgj.setSjBh(sj.getBh()); + } this.saveBatch(sjJcgjList); for (SjJcgj sjJcgj : sjJcgjList) { systemLogService.saveInfoWithData(sj.getBh(), sj.getBh(), sjJcgj.getJcmc(), sjJcgj.getJcmcEn(), @@ -66,9 +69,20 @@ public class SjJcgjServiceImpl extends ServiceImpl imple @Override @Async + public void saveBatchWithLog(List sjJcgjList) { + this.saveBatch(sjJcgjList); + for (SjJcgj sjJcgj : sjJcgjList) { + systemLogService.saveInfoWithData(sjJcgj.getSjBh(), sjJcgj.getSjBh(), sjJcgj.getJcmc(), sjJcgj.getJcmcEn(), + sjJcgj.getJcnr(), sjJcgj.getJcnrEn(), sjJcgj.getQmrId(), sjJcgj.getQmrMc(), sjJcgj.getQmrMcEn(), sjJcgj.getRemark(), sjJcgj.getCreateTime()); + } + } + + @Override + @Async public void saveWithLog(Sj sj, SjJcgj sjJcgj) { Date date = new Date(); sjJcgj.setCreateTime(date); + sjJcgj.setSjBh(sj.getBh()); this.save(sjJcgj); systemLogService.saveInfoWithData(sj.getBh(), sj.getBh(), sjJcgj.getJcmc(), sjJcgj.getJcmcEn(), sjJcgj.getJcnr(), sjJcgj.getJcnrEn(), sjJcgj.getQmrId(), sjJcgj.getQmrMc(), sjJcgj.getQmrMcEn(), sjJcgj.getRemark(), date); @@ -80,6 +94,7 @@ public class SjJcgjServiceImpl extends ServiceImpl imple SysUser sysUser = SecurityUtils.getLoginUser().getSysUser(); SjJcgj sjJcgj = new SjJcgj(); sjJcgj.setSjId(sj.getId()); + sjJcgj.setSjBh(sj.getBh()); sjJcgj.setJcgjlx(jcgjlx); sjJcgj.setJcmc(jcmc); sjJcgj.setJcmcEn(jcmcEn); @@ -98,9 +113,10 @@ public class SjJcgjServiceImpl extends ServiceImpl imple } @Override - public SjJcgj genJcgj(Long sjId, Integer jcgjlx, String jcmc, String jcmcEn, Integer jcmcys, String jcnr, String jcnrEn, SysUser qmr) { + public SjJcgj genJcgj(Sj sj, Integer jcgjlx, String jcmc, String jcmcEn, Integer jcmcys, String jcnr, String jcnrEn, SysUser qmr) { SjJcgj sjJcgj = new SjJcgj(); - sjJcgj.setSjId(sjId); + sjJcgj.setSjId(sj.getId()); + sjJcgj.setSjBh(sj.getBh()); sjJcgj.setJcgjlx(jcgjlx); sjJcgj.setJcmc(jcmc); sjJcgj.setJcmcEn(jcmcEn); 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 b550669..4184aaa 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 @@ -8,6 +8,7 @@ import cn.hutool.json.JSONUtil; import com.alibaba.fastjson2.JSONObject; 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.business.domain.*; import com.hxhq.business.dto.sj.SjListDto; @@ -26,7 +27,8 @@ import com.hxhq.business.form.study.StudyFormConfigurationForm; import com.hxhq.business.form.study.StudyFormFillSubpackageForm; import com.hxhq.business.form.study.StudyFormFillSubpackageItemForm; import com.hxhq.business.service.*; -import com.hxhq.business.utils.CalUnitTools; +import com.hxhq.business.utils.UnitTools; +import com.hxhq.business.utils.VolumeUnitTools; import com.hxhq.business.utils.JctUtil; import com.hxhq.business.utils.ObjectCompareUtil; import com.hxhq.common.core.exception.ServiceException; @@ -159,7 +161,7 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi throw new SecurityException("试剂不存在或已删除"); } if (!sjOld.getZjzt().equals(ZjztEnum.rk.getValue())) { - throw new SecurityException("试剂【" + sjOld.getMc() + "】不是入库状态,不能修改库存"); + throw new SecurityException("试剂【" + sjOld.getBh() + "】不是入库状态,不能修改库存"); } List fieldChanges = ObjectCompareUtil.compareObjects(sjOld, form); if (fieldChanges.size() == 0) { @@ -210,16 +212,13 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi throw new SecurityException("试剂不存在或已删除"); } if (!sjOld.getZjzt().equals(ZjztEnum.rk.getValue())) { - throw new SecurityException("试剂【" + sjOld.getMc() + "】不是入库状态,不能处置"); + throw new SecurityException("试剂【" + sjOld.getBh() + "】不是入库状态,不能处置"); } if (!NumberUtils.isParsable(form.getCzl())) { throw new ServiceException("请输入正确的处置量"); } BigDecimal czl = new BigDecimal(form.getCzl()); BigDecimal kc = new BigDecimal(sjOld.getKc()); - if (czl.compareTo(kc) > 0) { - throw new ServiceException("处置量不应大于库存量"); - } kc = kc.subtract(czl); sjOld.setKc(kc.toString()); updateById(sjOld); @@ -246,11 +245,9 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi sjJcgj.setQmrMcEn(qmr.getUserName()); sjJcgjService.saveWithLog(sjOld, sjJcgj); - // 台账 sjTzService.saveTz(sjOld.getId(), qmr.getUserId(), qmr.getNickName(), qmr.getUserName(), "处置", "Dispose", form.getCzl(), sjOld.getKcdw(), form.getRemark()); - } @Override @@ -270,7 +267,7 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi throw new SecurityException("试剂不存在或已删除"); } if (!sj.getZjzt().equals(ZjztEnum.rk.getValue())) { - throw new SecurityException("试剂【" + sj.getMc() + "】不是入库状态,不能处置"); + throw new SecurityException("试剂【" + sj.getBh() + "】不是入库状态,不能处置"); } if (!NumberUtils.isParsable(itemForm.getCzl())) { throw new ServiceException("请输入正确的处置量"); @@ -344,7 +341,11 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi throw new SecurityException("试剂不存在或已删除"); } if (!sj.getZjzt().equals(ZjztEnum.rk.getValue())) { - throw new SecurityException("试剂【" + sj.getMc() + "】不是入库状态,不能锁定"); + throw new SecurityException("试剂【" + sj.getBh() + "】不是入库状态,不能锁定"); + } + BigDecimal kc = new BigDecimal(sj.getKc()); + if(kc.compareTo(BigDecimal.ZERO) > 0) { + throw new SecurityException("所选的" + sj.getBh() +"试剂库存量大于0,请先进行处置剩余库存量后再锁定试剂"); } sj.setZjzt(ZjztEnum.ysd.getValue()); this.updateById(sj); @@ -364,6 +365,7 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi SysUser qmr = sysUserService.selectUserById(form.getQmrId()); sysUserService.checkPassword(qmr, form.getQmrmm(), false); + List errorBh = new ArrayList<>(); List sjList = new ArrayList<>(); for (Long id : form.getIds()) { if (id == null || id < 0) { @@ -374,11 +376,18 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi throw new SecurityException("试剂不存在或已删除"); } if (!sj.getZjzt().equals(ZjztEnum.rk.getValue())) { - throw new SecurityException("试剂【" + sj.getMc() + "】不是入库状态,不能锁定"); + throw new SecurityException("试剂【" + sj.getBh() + "】不是入库状态,不能锁定"); + } + BigDecimal kc = new BigDecimal(sj.getKc()); + if(kc.compareTo(BigDecimal.ZERO) > 0) { + errorBh.add(sj.getBh()); } sj.setZjzt(ZjztEnum.ysd.getValue()); sjList.add(sj); } + if(CollectionUtils.isNotEmpty(errorBh)) { + throw new SecurityException("所选的" + String.join("、", errorBh) +"试剂库存量大于0,请先进行处置剩余库存量后再锁定试剂"); + } this.updateBatchById(sjList); //稽查轨迹 for (Sj sj : sjList) { @@ -406,7 +415,7 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi throw new SecurityException("试剂不存在或已删除"); } if (!sjOld.getZjzt().equals(ZjztEnum.ysd.getValue())) { - throw new SecurityException("试剂【" + sjOld.getMc() + "】不是已锁定状态,不能解锁"); + throw new SecurityException("试剂【" + sjOld.getBh() + "】不是已锁定状态,不能解锁"); } //点击解锁,状态更新为入库; sjOld.setZjzt(ZjztEnum.rk.getValue()); @@ -434,10 +443,10 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi throw new SecurityException("试剂不存在或已删除"); } if (!sjOld.getZjzt().equals(ZjztEnum.gd.getValue())) { - throw new SecurityException("试剂【" + sjOld.getMc() + "】不是归档状态,不能借阅"); + throw new SecurityException("试剂【" + sjOld.getBh() + "】不是归档状态,不能借阅"); } if (!sjOld.getJyzt().equals(JyztEnum.wjy.getValue())) { - throw new SecurityException("试剂【" + sjOld.getMc() + "】不是未借阅状态,不能借阅"); + throw new SecurityException("试剂【" + sjOld.getBh() + "】不是未借阅状态,不能借阅"); } if (!sjOld.getGdsqrId().equals(qmr.getUserId())) { throw new ServiceException("只有归档申请人才能操作"); @@ -477,7 +486,7 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi throw new SecurityException("试剂不存在或已删除"); } if (!sjOld.getZjzt().equals(ZjztEnum.gd.getValue())) { - throw new SecurityException("试剂【" + sjOld.getMc() + "】未归档,不能解档"); + throw new SecurityException("试剂【" + sjOld.getBh() + "】未归档,不能解档"); } if (!sjOld.getGdsqrId().equals(qmr.getUserId())) { throw new ServiceException("只有归档申请人才能操作"); @@ -511,7 +520,7 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi throw new SecurityException("试剂不存在或已删除"); } if (!sjOld.getZjzt().equals(ZjztEnum.ysd.getValue())) { - throw new SecurityException("试剂【" + sjOld.getMc() + "】不是锁定状态,不能归档"); + throw new SecurityException("试剂【" + sjOld.getBh() + "】不是锁定状态,不能归档"); } //申请归档,档案员可在档案管理中进行确认归档审核;申请后状态更新成待归档; sjOld.setZjzt(ZjztEnum.dgd.getValue()); @@ -547,7 +556,7 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi throw new SecurityException("试剂不存在或已删除"); } if (!sjOld.getZjzt().equals(ZjztEnum.ysd.getValue())) { - throw new SecurityException("试剂【" + sjOld.getMc() + "】不是锁定状态,不能归档"); + throw new SecurityException("试剂【" + sjOld.getBh() + "】不是锁定状态,不能归档"); } //申请归档,档案员可在档案管理中进行确认归档审核;申请后状态更新成待归档; sjOld.setZjzt(ZjztEnum.dgd.getValue()); @@ -583,7 +592,7 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi throw new SecurityException("试剂不存在或已删除"); } if (!sjOld.getZjzt().equals(ZjztEnum.rk.getValue())) { - throw new SecurityException("试剂【" + sjOld.getMc() + "】不是入库状态,不能编辑"); + throw new SecurityException("试剂【" + sjOld.getBh() + "】不是入库状态,不能编辑"); } List fieldChanges = ObjectCompareUtil.compareObjects(sjOld, form); if (fieldChanges.size() == 0) { @@ -669,6 +678,9 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi sjMap.put(sj.getBh(), sj); } for (StudyFormFillResource studyFormFillResource : studyFormFillResourceList) { + if(StringUtils.isEmpty(studyFormFillResource.getBh())) { + continue; + } Sj sj = sjMap.get(studyFormFillResource.getBh()); if (mark) { if (studyFormFillResource.getType() == null) { @@ -694,7 +706,7 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi sj.setYxzq(studyFormFillResource.getYxzq()); sj.setYxzqdw(studyFormFillResource.getYxzqdw()); this.saveOrUpdate(sj);if(isAdd){sjList.add(sj);}sjMap.put(sj.getBh(), sj); - jcgjList.add(sjJcgjService.genJcgj(sj.getId(), JcgjlxEnum.lc.getValue(), "配制完成", "Formulation Completed", JcmcysEnum.green.getValue(), null, null, qmr)); + jcgjList.add(sjJcgjService.genJcgj(sj, JcgjlxEnum.lc.getValue(), "配制完成", "Formulation Completed", JcmcysEnum.green.getValue(), null, null, qmr)); tzList.add(sjTzService.genTz(sj.getId(), "配制完成", "Formulation Completed", sj.getKc(), sj.getKcdw(), null, qmr)); } studyFormFillResource.setType(StudyFormFillResourceTypeEnum.sj.getValue()); @@ -717,7 +729,7 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi cc(studyFormFill, sjMap, jcgjList, tzList, qmr);cz(studyFormFill, sjMap, jcgjList, tzList, qmr); } if (jcgjList.size() > 0) { - sjJcgjService.saveBatch(jcgjList); + sjJcgjService.saveBatchWithLog(jcgjList); } if (tzList.size() > 0) { sjTzService.saveBatch(tzList); @@ -731,7 +743,7 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi // 使用 String syl = studyFormFillResource.getSyl(); if (StringUtils.isNotEmpty(syl) && NumberUtils.isParsable(syl)) { - String kc = CalUnitTools.subTj(sj.getKc(), sj.getKcdw(), syl, studyFormFillResource.getSyldw()); + String kc = UnitTools.subTj(sj.getKc(), sj.getKcdw(), syl, studyFormFillResource.getSyldw()); baseMapper.updateKc(sj.getId(), kc); // 使用稽查轨迹 @@ -741,7 +753,7 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi Map jcnrEnMap = new LinkedHashMap<>(); jcnrEnMap.put("Usage Amount", syl + studyFormFillResource.getSyldw()); - SjJcgj sjJcgj = sjJcgjService.genJcgj(sj.getId(), JcgjlxEnum.lc.getValue(), "使用", "Usage", + SjJcgj sjJcgj = sjJcgjService.genJcgj(sj, JcgjlxEnum.lc.getValue(), "使用", "Usage", JcmcysEnum.green.getValue(), JctUtil.formatStr(jcnrMap), JctUtil.formatStr(jcnrEnMap), qmr); jcgjList.add(sjJcgj); @@ -899,7 +911,7 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi jcnrEnMap.put("Storage Location", studyFormFillCc.getCcwz()); jcnrEnMap.put("Storage Condition", studyFormFillCc.getCctj()); - SjJcgj sjJcgj = sjJcgjService.genJcgj(sj.getId(), JcgjlxEnum.lc.getValue(), "存储", "Storage", + SjJcgj sjJcgj = sjJcgjService.genJcgj(sj, JcgjlxEnum.lc.getValue(), "存储", "Storage", JcmcysEnum.green.getValue(), JctUtil.formatStr(jcnrMap), JctUtil.formatStr(jcnrEnMap), qmr); jcgjList.add(sjJcgj); @@ -945,7 +957,7 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi jcnrEnMap.put("Dispose Method", studyFormFillCz.getCzfs()); jcnrEnMap.put("Amount", sj.getKc() + sj.getKcdw()); - SjJcgj sjJcgj = sjJcgjService.genJcgj(sj.getId(), JcgjlxEnum.lc.getValue(), "处置", "Dispose", + SjJcgj sjJcgj = sjJcgjService.genJcgj(sj, JcgjlxEnum.lc.getValue(), "处置", "Dispose", JcmcysEnum.green.getValue(), JctUtil.formatStr(jcnrMap), JctUtil.formatStr(jcnrEnMap), qmr); jcgjList.add(sjJcgj); @@ -974,7 +986,7 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi throw new SecurityException("试剂不存在或已删除"); } if (!sj.getZjzt().equals(ZjztEnum.dgd.getValue())) { - throw new SecurityException("试剂【" + sj.getMc() + "】不是待归档状态,不能操作"); + throw new SecurityException("试剂【" + sj.getBh() + "】不是待归档状态,不能操作"); } sj.setZjzt(ZjztEnum.gd.getValue()); this.updateById(sj); @@ -1005,7 +1017,7 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi throw new SecurityException("试剂不存在或已删除"); } if (!sj.getZjzt().equals(ZjztEnum.dgd.getValue())) { - throw new SecurityException("试剂【" + sj.getMc() + "】不是待归档状态,不能操作"); + throw new SecurityException("试剂【" + sj.getBh() + "】不是待归档状态,不能操作"); } sj.setZjzt(ZjztEnum.ysd.getValue()); this.updateById(sj); @@ -1036,7 +1048,7 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi throw new SecurityException("试剂不存在或已删除"); } if (!sj.getZjzt().equals(ZjztEnum.djd.getValue())) { - throw new SecurityException("试剂【" + sj.getMc() + "】不是待解档状态,不能操作"); + throw new SecurityException("试剂【" + sj.getBh() + "】不是待解档状态,不能操作"); } sj.setZjzt(ZjztEnum.ysd.getValue()); this.updateById(sj); @@ -1067,7 +1079,7 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi throw new SecurityException("试剂不存在或已删除"); } if (!sj.getZjzt().equals(ZjztEnum.djd.getValue())) { - throw new SecurityException("试剂【" + sj.getMc() + "】不是待解档状态,不能操作"); + throw new SecurityException("试剂【" + sj.getBh() + "】不是待解档状态,不能操作"); } sj.setZjzt(ZjztEnum.gd.getValue()); this.updateById(sj); @@ -1098,7 +1110,7 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi throw new SecurityException("试剂不存在或已删除"); } if (!sj.getJyzt().equals(JyztEnum.djy.getValue())) { - throw new SecurityException("试剂【" + sj.getMc() + "】不是待借阅状态,不能操作"); + throw new SecurityException("试剂【" + sj.getBh() + "】不是待借阅状态,不能操作"); } sj.setJyzt(JyztEnum.jyz.getValue()); sj.setJyksrq(form.getStartDate()); @@ -1131,7 +1143,7 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi throw new SecurityException("试剂不存在或已删除"); } if (!sj.getJyzt().equals(JyztEnum.djy.getValue())) { - throw new SecurityException("试剂【" + sj.getMc() + "】不是待借阅状态,不能操作"); + throw new SecurityException("试剂【" + sj.getBh() + "】不是待借阅状态,不能操作"); } sj.setJyzt(JyztEnum.wjy.getValue()); this.updateById(sj); @@ -1162,7 +1174,7 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi throw new SecurityException("试剂不存在或已删除"); } if (!sj.getJyzt().equals(JyztEnum.jyz.getValue())) { - throw new SecurityException("试剂【" + sj.getMc() + "】不是借阅中状态,不能操作"); + throw new SecurityException("试剂【" + sj.getBh() + "】不是借阅中状态,不能操作"); } sj.setJyzt(JyztEnum.wjy.getValue()); this.updateById(sj); @@ -1189,7 +1201,7 @@ public class SjServiceImpl extends ServiceImpl implements ISjServi for (Sj sj : sjList) { sj.setJyzt(JyztEnum.wjy.getValue()); //稽查轨迹 - SjJcgj jcgj = sjJcgjService.genJcgj(sj.getId(), JcgjlxEnum.lc.getValue(), "到期自动归还", "Check-out End on Time", + SjJcgj jcgj = sjJcgjService.genJcgj(sj, JcgjlxEnum.lc.getValue(), "到期自动归还", "Check-out End on Time", JcmcysEnum.green.getValue(), null, null, null); sjJcgjService.save(jcgj); } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyFormFillServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyFormFillServiceImpl.java index f65bdc0..4849d32 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyFormFillServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyFormFillServiceImpl.java @@ -145,6 +145,10 @@ public class StudyFormFillServiceImpl extends ServiceImpl UNIT_TO_LITER = new HashMap<>(); + + static { + UNIT_TO_LITER.put("pL", new BigDecimal(1.0)); // 皮升(基准) + UNIT_TO_LITER.put("nL", new BigDecimal(1_000.0)); // 纳升 = 1000 pL + UNIT_TO_LITER.put("uL", new BigDecimal(1_000_000.0)); // 微升 = 1,000,000 pL + UNIT_TO_LITER.put("mL", new BigDecimal(1_000_000_000.0)); // 毫升 = 1,000,000,000 pL + UNIT_TO_LITER.put("L", new BigDecimal(1_000_000_000_000.0)); // 升 = 1,000,000,000,000 pL + + UNIT_TO_LITER.put("pg", new BigDecimal(1.0)); // 皮克 + UNIT_TO_LITER.put("ng", new BigDecimal(1_000.0)); // 纳克 = 1000 pg + UNIT_TO_LITER.put("ug", new BigDecimal(1_000_000.0)); // 微克 = 1,000,000 pg + UNIT_TO_LITER.put("mg", new BigDecimal(1_000_000_000.0)); // 毫克 = 1,000,000,000 pg + UNIT_TO_LITER.put("g", new BigDecimal(1_000_000_000_000.0)); // 克 = 1,000,000,000,000 pg + UNIT_TO_LITER.put("kg", new BigDecimal(1_000_000_000_000_000.0)); // 千克 = 1,000,000,000,000,000 pg + } + + /** + * 体积相加 + * @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(subKcdw); + BigDecimal kcValue = formatKc(kc); + BigDecimal subKcValue = formatKc(subKc); + subKcValue = convert(subKcValue, subKcdw, kcdw); + kcValue = kcValue.subtract(subKcValue); + + 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 原始单位 + * @param toUnit 目标单位 + * @return 转换后的数值 + * @throws IllegalArgumentException 当单位不支持时抛出异常 + */ + public static BigDecimal convert(BigDecimal value, String fromUnit, String toUnit) { + // 验证单位是否支持 + if (!UNIT_TO_LITER.containsKey(fromUnit) ) { + throw new ServiceException( "不支持的单位:" + fromUnit); + } + if (!UNIT_TO_LITER.containsKey(toUnit) ) { + throw new ServiceException( "不支持的单位:" + toUnit); + } + + // 如果单位相同,直接返回 + if (fromUnit.equals(toUnit)) { + return value; + } + + // 转换为基准单位 + BigDecimal valueInLiters = value.multiply(UNIT_TO_LITER.get(fromUnit)); + BigDecimal to = UNIT_TO_LITER.get(toUnit); + // 从基准单位转换为目标单位 + return valueInLiters.divide(to); + } + + /** + * 转换为基础单位 + * @param value 数值 + * @param fromUnit 原单位 + * @return + */ + public static BigDecimal convert2Basic(String value, String fromUnit) { + if(StringUtils.isEmpty(value) || !NumberUtils.isParsable(value)) { + return BigDecimal.ZERO; + } + // 验证单位是否支持 + if (!UNIT_TO_LITER.containsKey(fromUnit) ) { + return BigDecimal.ZERO; + } + + String toUnit = ""; + if(Arrays.asList(VOLUME_UNIT_LIST).contains(fromUnit)) { + toUnit = "pL"; + } else if(Arrays.asList(WEIGHT_UNIT_LIST).contains(fromUnit)) { + toUnit = "pg"; + } + + // 如果单位相同,直接返回 + if (fromUnit.equals(toUnit)) { + return new BigDecimal(value); + } + + // 转换为基准单位 + BigDecimal valueInLiters = new BigDecimal(value).multiply(UNIT_TO_LITER.get(fromUnit)); + BigDecimal to = UNIT_TO_LITER.get(toUnit); + // 从基准单位转换为目标单位 + return valueInLiters.divide(to); + } + + /** + * 从基础单位转换为指定单位 + * @param value 数值 + * @param toUnit 原单位 + * @return + */ + public static BigDecimal convert(BigDecimal value, String toUnit) { + // 验证单位是否支持 + if (!UNIT_TO_LITER.containsKey(toUnit) ) { + return value; + } + + String fromUnit = ""; + if(Arrays.asList(VOLUME_UNIT_LIST).contains(toUnit)) { + fromUnit = "pL"; + } else if(Arrays.asList(WEIGHT_UNIT_LIST).contains(toUnit)) { + fromUnit = "pg"; + } + + return convert(value, fromUnit, 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 ); + } + } + + public static void main(String[] args) { + /* System.out.println("1 L = " + convert(new BigDecimal(1), "L", "mL") + " mL"); // 1000.0 + System.out.println("1 mL = " + convert(new BigDecimal(1), "mL", "uL") + " uL"); // 1000.0 + System.out.println("1 uL = " + convert(new BigDecimal(1), "uL", "nL") + " nL"); // 1000.0 + System.out.println("1 nL = " + convert(new BigDecimal(1), "nL", "pL") + " pL"); // 1000.0 + System.out.println("1 pL = " + convert(new BigDecimal(1), "pL", "L") + " L"); // 1.0E-12 + System.out.println("1000 mL = " + convert(new BigDecimal(1000), "mL", "L") + " L"); // 1.0 + System.out.println("1.5 L = " + convert(new BigDecimal(1.5), "L", "uL") + " uL"); // 1500,000.0 +*/ + + System.out.println("1 kg = " + convert(new BigDecimal(1), "kg", "g") + " g"); // 1000.0 + System.out.println("1 mg = " + convert(new BigDecimal(1), "mg", "g") + " g"); // 1000.0 + System.out.println("1 ug = " + convert(new BigDecimal(1), "ug", "g") + " g"); // 1000.0 + System.out.println("1 ng = " + convert(new BigDecimal(1), "ng", "g") + " g"); // 1000.0 + System.out.println("1 pg = " + convert(new BigDecimal(1), "pg", "g") + " g"); // 1.0E-12 + System.out.println("1000 mg = " + convert(new BigDecimal(1000), "mg", "g") + " g"); // 1.0 + System.out.println("1.5 kg = " + convert(new BigDecimal(1.5), "kg", "g") + " g"); // 1500.0 + } +} 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/VolumeUnitTools.java similarity index 84% rename from hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/CalUnitTools.java rename to hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/VolumeUnitTools.java index 1920775..3ecdcaa 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/VolumeUnitTools.java @@ -10,29 +10,24 @@ import java.util.HashMap; import java.util.Map; /** - * 单位换算工具 + * 体积单位换算工具 * @author HanLong */ -public class CalUnitTools { +public class VolumeUnitTools { private static String[] unitList = {"pL", "nL", "uL", "mL", "L"}; /** - * 定义单位换算基准(以升L为基准单位) + * 单位与皮升(pL)的换算关系(1单位 = 多少 pL) */ 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")); - // 微升 (μL,这里用uL代替) - UNIT_TO_LITER.put("uL", new BigDecimal("0.000001")); - // 纳升 - UNIT_TO_LITER.put("nL", new BigDecimal("0.000000001")); - // 皮升 - UNIT_TO_LITER.put("pL", new BigDecimal("0.000000000001")); + UNIT_TO_LITER.put("pL", new BigDecimal(1.0)); // 皮升(基准) + UNIT_TO_LITER.put("nL", new BigDecimal(1_000.0)); // 纳升 = 1000 pL + UNIT_TO_LITER.put("uL", new BigDecimal(1_000_000.0)); // 微升 = 1,000,000 pL + UNIT_TO_LITER.put("mL", new BigDecimal(1_000_000_000.0)); // 毫升 = 1,000,000,000 pL + UNIT_TO_LITER.put("L", new BigDecimal(1_000_000_000_000.0)); // 升 = 1,000,000,000,000 pL } /** @@ -55,7 +50,7 @@ public class CalUnitTools { } /** - * 体积相加 + * 体积相减 * @param kc 当前库存 * @param kcdw 当前库存单位 * @param subKc 扣减库存 @@ -106,7 +101,7 @@ public class CalUnitTools { return value; } - // 转换为基准单位(升) + // 转换为基准单位(pL) BigDecimal valueInLiters = value.multiply(UNIT_TO_LITER.get(fromUnit)); // 从基准单位转换为目标单位 diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/WeightUnitTools.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/WeightUnitTools.java new file mode 100644 index 0000000..5f7c528 --- /dev/null +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/WeightUnitTools.java @@ -0,0 +1,126 @@ +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; + +/** + * 质量单位转换工具类(以pg为基础单位) + */ +public class WeightUnitTools { + + private static String[] unitList = {"pg", "ng", "ug", "mg", "g", "kg"}; + + /** + * 单位与皮克(pg)的换算关系(1单位 = 多少 pg) + */ + private static final Map UNIT_TO_LITER = new HashMap<>(); + + static { + UNIT_TO_LITER.put("pg", new BigDecimal(1.0)); // 皮克 + UNIT_TO_LITER.put("ng", new BigDecimal(1_000.0)); // 纳克 = 1000 pg + UNIT_TO_LITER.put("ug", new BigDecimal(1_000_000.0)); // 微克 = 1,000,000 pg + UNIT_TO_LITER.put("mg", new BigDecimal(1_000_000_000.0)); // 毫克 = 1,000,000,000 pg + UNIT_TO_LITER.put("g", new BigDecimal(1_000_000_000_000.0)); // 克 = 1,000,000,000,000 pg + UNIT_TO_LITER.put("kg", new BigDecimal(1_000_000_000_000.0)); // 千克 = 1,000,000,000,000,000 pg + } + + /** + * 体积相加 + * @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(subKcdw); + BigDecimal kcValue = formatKc(kc); + BigDecimal subKcValue = formatKc(subKc); + subKcValue = convert(subKcValue, subKcdw, kcdw); + kcValue = kcValue.subtract(subKcValue); + + 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 原始单位 + * @param toUnit 目标单位 + * @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; + } + + // 转换为基准单位(pL) + 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 + + ",支持的单位有: pg, ng, ug, mg, g, kg"); + } + } + + +} diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/lang/GspJcnrUtil.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/lang/GspJcnrUtil.java index e921ade..fb82620 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/lang/GspJcnrUtil.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/lang/GspJcnrUtil.java @@ -108,7 +108,7 @@ public class GspJcnrUtil { mapLang.put("存储","Storage"); mapLang.put("取出","Take Out"); mapLang.put("给药制剂详情","Formulation Information"); - mapLang.put("到期自动归还","到期自动归还"); + mapLang.put("到期自动归还","Check-out End on Time"); mapLang.put("原因","Reason"); diff --git a/hxhq-modules/hxhq-system/src/main/resources/mapper/business/GspFfjlMapper.xml b/hxhq-modules/hxhq-system/src/main/resources/mapper/business/GspFfjlMapper.xml index e6fa66f..8031f2b 100644 --- a/hxhq-modules/hxhq-system/src/main/resources/mapper/business/GspFfjlMapper.xml +++ b/hxhq-modules/hxhq-system/src/main/resources/mapper/business/GspFfjlMapper.xml @@ -5,9 +5,10 @@ + + + + + + \ No newline at end of file diff --git a/hxhq-modules/hxhq-system/src/main/resources/mapper/business/GspMapper.xml b/hxhq-modules/hxhq-system/src/main/resources/mapper/business/GspMapper.xml index 50451e3..0b84b4e 100644 --- a/hxhq-modules/hxhq-system/src/main/resources/mapper/business/GspMapper.xml +++ b/hxhq-modules/hxhq-system/src/main/resources/mapper/business/GspMapper.xml @@ -19,4 +19,20 @@ FROM `t_gsp` t where t.id=#{id} + + + UPDATE t_gsp SET kc = #{kc} WHERE id in + + #{item} + + + + UPDATE t_gsp SET cctj = #{cctj}, ccwz = #{ccwz} WHERE id in + + #{item} + + + + UPDATE t_gsp SET kc = #{kc} WHERE id = #{id} + \ No newline at end of file diff --git a/hxhq-modules/hxhq-system/src/main/resources/mapper/business/GspRkjlMapper.xml b/hxhq-modules/hxhq-system/src/main/resources/mapper/business/GspRkjlMapper.xml index b260bab..c5e9ccb 100644 --- a/hxhq-modules/hxhq-system/src/main/resources/mapper/business/GspRkjlMapper.xml +++ b/hxhq-modules/hxhq-system/src/main/resources/mapper/business/GspRkjlMapper.xml @@ -3,4 +3,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> + + \ No newline at end of file