From 1564331c1e042df53cbf3962685267f15dfec7d2 Mon Sep 17 00:00:00 2001 From: "15881625488@163.com" <15881625488@163.com> Date: Mon, 26 Jan 2026 21:13:26 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A[=E8=AF=95=E9=AA=8C=E7=AE=A1?= =?UTF-8?q?=E7=90=86]=E9=BA=BB=E7=B2=BE=E8=8D=AF=EF=BC=8C=E7=BB=99?= =?UTF-8?q?=E8=8D=AF=E5=88=B6=E5=89=82=20=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hxhq/business/mapper/GyzjMapper.java | 21 ++++ .../java/com/hxhq/business/mapper/MjyMapper.java | 22 ++++ .../com/hxhq/business/service/IGyzjService.java | 12 +- .../com/hxhq/business/service/IMjyService.java | 12 +- .../hxhq/business/service/IStudyGyzjService.java | 8 ++ .../hxhq/business/service/IStudyMjyService.java | 9 ++ .../business/service/impl/GyzjServiceImpl.java | 123 +++++++++++++++++++ .../hxhq/business/service/impl/MjyServiceImpl.java | 130 +++++++++++++++++++++ .../service/impl/StudyFormFillServiceImpl.java | 17 ++- .../service/impl/StudyGyzjServiceImpl.java | 41 +++++++ .../business/service/impl/StudyMjyServiceImpl.java | 39 +++++++ .../main/resources/mapper/business/GyzjMapper.xml | 16 +++ .../main/resources/mapper/business/MjyMapper.xml | 16 +++ 13 files changed, 456 insertions(+), 10 deletions(-) diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/GyzjMapper.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/GyzjMapper.java index 4704a0e..c1bf725 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/GyzjMapper.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/GyzjMapper.java @@ -38,4 +38,25 @@ public interface GyzjMapper extends BaseMapper */ DetailDto queryInfo(@Param("id") Long id); + /** + * 修改库存 + * @param id 试剂id + * @param kc 库存量 + */ + void updateKc(@Param("id") Long id, @Param("kc") String kc); + + /** + * 批量修改库存 + * @param bhList 试剂编号 + * @param kc 库存量 + */ + void updateKcBatch(@Param("bhList") List bhList, @Param("kc") String kc); + + /** + * 修改存储条件 + * @param bhList 试剂编号 + * @param cctj 存储条件 + * @param ccwz 存储位置 + */ + void updateCc(@Param("bhList") List bhList, @Param("cctj") String cctj, @Param("ccwz") String ccwz); } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/MjyMapper.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/MjyMapper.java index 0726a4a..60be648 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/MjyMapper.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/MjyMapper.java @@ -38,4 +38,26 @@ public interface MjyMapper extends BaseMapper */ DetailDto queryInfo(@Param("id") Long id); + + /** + * 修改库存 + * @param id 试剂id + * @param kc 库存量 + */ + void updateKc(@Param("id") Long id, @Param("kc") String kc); + + /** + * 批量修改库存 + * @param bhList 试剂编号 + * @param kc 库存量 + */ + void updateKcBatch(@Param("bhList") List bhList, @Param("kc") String kc); + + /** + * 修改存储条件 + * @param bhList 试剂编号 + * @param cctj 存储条件 + * @param ccwz 存储位置 + */ + void updateCc(@Param("bhList") List bhList, @Param("cctj") String cctj, @Param("ccwz") String ccwz); } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGyzjService.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGyzjService.java index 650b5bc..e32676e 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGyzjService.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGyzjService.java @@ -4,6 +4,8 @@ import java.util.List; import com.hxhq.business.domain.Gyzj; import com.baomidou.mybatisplus.extension.service.IService; +import com.hxhq.business.domain.StudyFormFill; +import com.hxhq.business.domain.Template; import com.hxhq.business.dto.gyzj.DetailDto; import com.hxhq.business.dto.gyzj.ListDto; import com.hxhq.business.form.gyzj.*; @@ -18,6 +20,7 @@ import com.hxhq.business.form.sj.SjSearchListForm; public interface IGyzjService extends IService { //region 资源库管理 + /** * 查询给药制剂列表 * @@ -205,12 +208,17 @@ public interface IGyzjService extends IService { /** * 存储 */ - public void cc(CcForm form) ; + public void cc(CcForm form); /** * 取出 */ - public void qc(CcForm form) ; + public void qc(CcForm form); + + /** + * 表单生成 + */ + void genResource(StudyFormFill studyFormFill, Template template,String remark); //endregion diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IMjyService.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IMjyService.java index edf8d27..319680b 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IMjyService.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IMjyService.java @@ -4,10 +4,13 @@ import java.util.List; import com.hxhq.business.domain.Mjy; import com.baomidou.mybatisplus.extension.service.IService; +import com.hxhq.business.domain.StudyFormFill; +import com.hxhq.business.domain.Template; import com.hxhq.business.dto.mjy.DetailDto; import com.hxhq.business.dto.mjy.ListDto; import com.hxhq.business.form.mjy.ArchiveForm; import com.hxhq.business.form.mjy.*; + /** * 麻精药Service接口 * @@ -190,12 +193,17 @@ public interface IMjyService extends IService { /** * 存储 */ - public void cc(CcForm form) ; + public void cc(CcForm form); /** * 取出 */ - public void qc(CcForm form) ; + public void qc(CcForm form); + + /** + * 表单生成 + */ + void genResource(StudyFormFill studyFormFill, Template template,String remark); //endregion diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyGyzjService.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyGyzjService.java index 282c4b3..30c64ed 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyGyzjService.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyGyzjService.java @@ -2,8 +2,10 @@ package com.hxhq.business.service; import java.util.List; +import com.hxhq.business.domain.Gyzj; import com.hxhq.business.domain.StudyGyzj; import com.baomidou.mybatisplus.extension.service.IService; +import com.hxhq.business.domain.StudyMjy; import org.apache.ibatis.annotations.Param; /** @@ -21,4 +23,10 @@ public interface IStudyGyzjService extends IService { */ public void insertBatch(List list); + /** + * 关联试验 + * @param studyId + * @param sjList + */ + void saveBatch(Long studyId, List sjList); } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyMjyService.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyMjyService.java index 966d728..5d509da 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyMjyService.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyMjyService.java @@ -2,6 +2,8 @@ package com.hxhq.business.service; import java.util.List; +import com.hxhq.business.domain.Mjy; +import com.hxhq.business.domain.Sj; import com.hxhq.business.domain.StudyGyzj; import com.hxhq.business.domain.StudyMjy; import com.baomidou.mybatisplus.extension.service.IService; @@ -20,4 +22,11 @@ public interface IStudyMjyService extends IService * @param list */ public void insertBatch(List list); + + /** + * 关联试验 + * @param studyId + * @param sjList + */ + void saveBatch(Long studyId, List sjList); } 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 686b14d..f2611d7 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 @@ -20,6 +20,7 @@ import com.hxhq.business.form.gyzj.*; import com.hxhq.business.service.*; import com.hxhq.business.utils.JctUtil; import com.hxhq.business.utils.ObjectCompareUtil; +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.core.utils.StringUtils; @@ -59,6 +60,8 @@ public class GyzjServiceImpl extends ServiceImpl implements IG private IArchiveLogService archiveLogService; @Autowired private INoticeService noticeService; + @Autowired + private IStudyGyzjService studyGyzjService; //region 资源库管理 @@ -1306,6 +1309,126 @@ public class GyzjServiceImpl extends ServiceImpl implements IG gyzjTzService.saveTz(gyzjOld.getId(),null,null,qmr,qmr2,null,null,null,null,null,"取出",gyzjOld.getKc(),gyzjOld.getKcdw(),form.getRemark()); } + /** + * 表单生成 + * @param studyFormFill + * @param template + * @param remark + */ + @Override + public void genResource(StudyFormFill studyFormFill, Template template,String remark) { + System.out.println(System.currentTimeMillis()); + SysUser qmr = sysUserService.selectUserById(SecurityUtils.getUserId()); + + Long studyId = studyFormFill.getStudyId(); + Long studyFormId = studyFormFill.getId(); + // 生成/使用 + String resource = studyFormFill.getResource(); + Map gyzjMap = new HashMap<>(); + List gyzjList = new ArrayList<>(); + LinkedList jcgjList = new LinkedList<>(); + LinkedList tzList = new LinkedList<>(); + if(StringUtils.isNotEmpty(resource) && !StringUtils.equals("[]", resource)) { + List studyFormFillResourceList = JSONUtil.toList(resource, StudyFormFillResource.class); + List bhList = studyFormFillResourceList.stream().map(StudyFormFillResource::getBh).collect(Collectors.toList()); + // 根据编号获取需要处置的列表 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.in(Gyzj::getBh, bhList); + gyzjList = this.list(queryWrapper); + for (Gyzj gyzj : gyzjList) { + gyzjMap.put(gyzj.getBh(), gyzj); + } + + for (StudyFormFillResource studyFormFillResource : studyFormFillResourceList) { + Gyzj gyzj = gyzjMap.get(studyFormFillResource.getBh()); + if(gyzj == null) { + gyzj = new Gyzj(); + gyzj.setStudyId(studyId); + gyzj.setBdId(studyFormId); + gyzj.setZjzt(ZjztEnum.wrk.getValue()); + gyzj.setJyzt(JyztEnum.wjy.getValue()); + } + gyzj.setMc(studyFormFillResource.getMc()); + gyzj.setBh(studyFormFillResource.getBh()); + gyzj.setNd(String.valueOf(studyFormFillResource.getNdz())); + gyzj.setNddw(studyFormFillResource.getNddw()); + gyzj.setKc(String.valueOf(studyFormFillResource.getKc())); + gyzj.setKcdw(studyFormFillResource.getKcdw()); + gyzj.setSxrq(DateUtils.parseDate(studyFormFillResource.getSxrq())); + if(gyzj.getId() == null) { + this.save(gyzj); + gyzjList.add(gyzj); + gyzjMap.put(gyzj.getBh(), gyzj); + // 稽查轨迹 + jcgjList.add(gyzjJcgjService.getJcgj(gyzj.getId(), JcgjlxEnum.lc.getValue(), "配制完成",JcmcysEnum.green.getValue(), null, null, qmr,remark)); + // 台账 + tzList.add(gyzjTzService.getTz(gyzj.getId(), null,null, null,null, null,null, null,null, qmr,"配制完成" ,gyzj.getKc(),gyzj.getKcdw(), remark)); + } else { + this.updateById(gyzj); + } + // 使用 + String syl = studyFormFillResource.getSyl(); + if(StringUtils.isNotEmpty(syl) && NumberUtils.isParsable(syl)) { + BigDecimal kc = new BigDecimal(gyzj.getKc()); + kc = kc.subtract(new BigDecimal(syl)); + baseMapper.updateKc(gyzj.getId(), kc.toString()); + // 使用稽查轨迹 + HashMap formData = new LinkedHashMap<>(); + formData.put("使用量", syl + studyFormFillResource.getSyldw()); + // 稽查轨迹 + jcgjList.add(gyzjJcgjService.getJcgj(gyzj.getId(), JcgjlxEnum.lc.getValue(), "使用",JcmcysEnum.green.getValue(), JctUtil.formatStr(formData), JctUtil.formatStr(GyzjJcnrUtil.getMapEn(formData)), qmr,remark)); + // 台账 + tzList.add(gyzjTzService.getTz(gyzj.getId(), null,null, null,null, null,null, null,null, qmr,"使用" ,gyzj.getKc(),gyzj.getKcdw(), remark)); + } + gyzjMap.put(gyzj.getBh(), gyzj); + } + } + + // 存储 + String cclist = studyFormFill.getCclist(); + if(StringUtils.isNotEmpty(cclist) && !StringUtils.equals("[]", cclist)) { + List studyFormFillCcList = JSONUtil.toList(cclist, StudyFormFillCc.class); + for (StudyFormFillCc studyFormFillCc : studyFormFillCcList) { + baseMapper.updateCc(studyFormFillCc.getList(), studyFormFillCc.getCctj(), studyFormFillCc.getCcwz()); + for (String bh : studyFormFillCc.getList()) { + Gyzj gyzj = gyzjMap.get(bh); + + // 稽查轨迹 + HashMap formData = new HashMap<>(); + formData.put("存储位置", studyFormFillCc.getCcwz()); + formData.put("存储条件", studyFormFillCc.getCctj()); + jcgjList.add(gyzjJcgjService.getJcgj(gyzj.getId(), JcgjlxEnum.lc.getValue(), "存储",JcmcysEnum.green.getValue(), JctUtil.formatStr(formData), JctUtil.formatStr(GyzjJcnrUtil.getMapEn(formData)), qmr,remark)); + // 台账 + tzList.add(gyzjTzService.getTz(gyzj.getId(), null,null, null,null, null,null, null,null, qmr,"存储" ,gyzj.getKc(),gyzj.getKcdw(), remark)); + } + } + } + + // 处置,库存全变为0 + String czlist = studyFormFill.getCzlist(); + if(StringUtils.isNotEmpty(czlist) && !StringUtils.equals("[]", czlist)) { + List studyFormFillCzList = JSONUtil.toList(czlist, StudyFormFillCz.class); + for (StudyFormFillCz studyFormFillCz : studyFormFillCzList) { + for (String bh : studyFormFillCz.getList()) { + Gyzj gyzj = gyzjMap.get(bh); + // 稽查轨迹 + HashMap formData = new HashMap<>(); + formData.put("处置方式", studyFormFillCz.getCzfs()); + formData.put("处置量", gyzj.getKc() + gyzj.getKcdw()); + jcgjList.add(gyzjJcgjService.getJcgj(gyzj.getId(), JcgjlxEnum.lc.getValue(), "存储",JcmcysEnum.green.getValue(), JctUtil.formatStr(formData), JctUtil.formatStr(GyzjJcnrUtil.getMapEn(formData)), qmr,remark)); + + // 台账 + tzList.add(gyzjTzService.getTz(gyzj.getId(), null,null, null,null, null,null, null,null, qmr,"处置" ,gyzj.getKc(),gyzj.getKcdw(), remark)); + + } + baseMapper.updateKcBatch(studyFormFillCz.getList(), "0"); + } + } + gyzjJcgjService.saveBatch(jcgjList); + gyzjTzService.saveBatch(tzList); + studyGyzjService.saveBatch(studyId, gyzjList); + } + //endregion //region 档案管理 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 147d0a0..16fa5c6 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 @@ -4,11 +4,16 @@ 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.mjy.DetailDto; import com.hxhq.business.dto.mjy.ListDto; +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.StudyTypeEnum; import com.hxhq.business.enums.zykgl.*; @@ -16,12 +21,14 @@ import com.hxhq.business.form.mjy.*; import com.hxhq.business.service.*; import com.hxhq.business.utils.JctUtil; import com.hxhq.business.utils.ObjectCompareUtil; +import com.hxhq.business.utils.lang.MjyJcnrUtil; import com.hxhq.common.core.exception.ServiceException; import com.hxhq.common.core.utils.DateUtils; import com.hxhq.common.core.utils.StringUtils; import com.hxhq.common.security.utils.SecurityUtils; import com.hxhq.system.api.domain.SysUser; import com.hxhq.system.service.ISysUserService; +import org.apache.commons.lang3.math.NumberUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -54,6 +61,8 @@ public class MjyServiceImpl extends ServiceImpl implements IMjyS private IArchiveLogService archiveLogService; @Autowired private INoticeService noticeService; + @Autowired + private IStudyMjyService studyMjyService; //region 资源库管理 @@ -1205,6 +1214,127 @@ public class MjyServiceImpl extends ServiceImpl implements IMjyS mjyTzService.saveTz(mjyOld.getId(),null,null,qmr,qmr2,null,null,null,null,null,"取出",mjyOld.getKc(),mjyOld.getKcdw(),form.getRemark()); } + /** + * 表单生成 + * @param studyFormFill + * @param template + * @param remark + */ + @Override + public void genResource(StudyFormFill studyFormFill, Template template,String remark) { + System.out.println(System.currentTimeMillis()); + SysUser qmr = sysUserService.selectUserById(SecurityUtils.getUserId()); + + Long studyId = studyFormFill.getStudyId(); + Long studyFormId = studyFormFill.getId(); + // 生成/使用 + String resource = studyFormFill.getResource(); + Map mjyMap = new HashMap<>(); + List mjyList = new ArrayList<>(); + LinkedList jcgjList = new LinkedList<>(); + LinkedList tzList = new LinkedList<>(); + if(StringUtils.isNotEmpty(resource) && !StringUtils.equals("[]", resource)) { + List studyFormFillResourceList = JSONUtil.toList(resource, StudyFormFillResource.class); + List bhList = studyFormFillResourceList.stream().map(StudyFormFillResource::getBh).collect(Collectors.toList()); + // 根据编号获取需要处置的列表 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.in(Mjy::getBh, bhList); + mjyList = this.list(queryWrapper); + for (Mjy mjy : mjyList) { + mjyMap.put(mjy.getBh(), mjy); + } + + for (StudyFormFillResource studyFormFillResource : studyFormFillResourceList) { + Mjy mjy = mjyMap.get(studyFormFillResource.getBh()); + if(mjy == null) { + mjy = new Mjy(); + mjy.setStudyId(studyId); + mjy.setBdId(studyFormId); + mjy.setZjzt(ZjztEnum.wrk.getValue()); + mjy.setJyzt(JyztEnum.wjy.getValue()); + } + mjy.setMc(studyFormFillResource.getMc()); + mjy.setBh(studyFormFillResource.getBh()); + mjy.setNd(String.valueOf(studyFormFillResource.getNdz())); + mjy.setNddw(studyFormFillResource.getNddw()); + mjy.setKc(String.valueOf(studyFormFillResource.getKc())); + mjy.setKcdw(studyFormFillResource.getKcdw()); + mjy.setSxrq(DateUtils.parseDate(studyFormFillResource.getSxrq())); + if(mjy.getId() == null) { + this.save(mjy); + mjyList.add(mjy); + mjyMap.put(mjy.getBh(), mjy); + // 稽查轨迹 + jcgjList.add(mjyJcgjService.getJcgj(mjy.getId(), JcgjlxEnum.lc.getValue(), "配制完成",JcmcysEnum.green.getValue(), null, null, qmr,remark)); + // 台账 + tzList.add(mjyTzService.getTz(mjy.getId(), null,null, null,null, null,null, null,null, qmr,"配制完成" ,mjy.getKc(),mjy.getKcdw(), remark)); + } else { + this.updateById(mjy); + } + // 使用 + String syl = studyFormFillResource.getSyl(); + if(StringUtils.isNotEmpty(syl) && NumberUtils.isParsable(syl)) { + BigDecimal kc = new BigDecimal(mjy.getKc()); + kc = kc.subtract(new BigDecimal(syl)); + baseMapper.updateKc(mjy.getId(), kc.toString()); + // 使用稽查轨迹 + HashMap formData = new LinkedHashMap<>(); + formData.put("使用量", syl + studyFormFillResource.getSyldw()); + // 稽查轨迹 + jcgjList.add(mjyJcgjService.getJcgj(mjy.getId(), JcgjlxEnum.lc.getValue(), "使用",JcmcysEnum.green.getValue(), JctUtil.formatStr(formData), JctUtil.formatStr(MjyJcnrUtil.getMapEn(formData)), qmr,remark)); + // 台账 + tzList.add(mjyTzService.getTz(mjy.getId(), null,null, null,null, null,null, null,null, qmr,"使用" ,mjy.getKc(),mjy.getKcdw(), remark)); + } + mjyMap.put(mjy.getBh(), mjy); + } + } + + // 存储 + String cclist = studyFormFill.getCclist(); + if(StringUtils.isNotEmpty(cclist) && !StringUtils.equals("[]", cclist)) { + List studyFormFillCcList = JSONUtil.toList(cclist, StudyFormFillCc.class); + for (StudyFormFillCc studyFormFillCc : studyFormFillCcList) { + baseMapper.updateCc(studyFormFillCc.getList(), studyFormFillCc.getCctj(), studyFormFillCc.getCcwz()); + for (String bh : studyFormFillCc.getList()) { + Mjy mjy = mjyMap.get(bh); + + // 稽查轨迹 + HashMap formData = new HashMap<>(); + formData.put("存储位置", studyFormFillCc.getCcwz()); + formData.put("存储条件", studyFormFillCc.getCctj()); + jcgjList.add(mjyJcgjService.getJcgj(mjy.getId(), JcgjlxEnum.lc.getValue(), "存储",JcmcysEnum.green.getValue(), JctUtil.formatStr(formData), JctUtil.formatStr(MjyJcnrUtil.getMapEn(formData)), qmr,remark)); + // 台账 + tzList.add(mjyTzService.getTz(mjy.getId(), null,null, null,null, null,null, null,null, qmr,"存储" ,mjy.getKc(),mjy.getKcdw(), remark)); + } + } + } + + // 处置,库存全变为0 + String czlist = studyFormFill.getCzlist(); + if(StringUtils.isNotEmpty(czlist) && !StringUtils.equals("[]", czlist)) { + List studyFormFillCzList = JSONUtil.toList(czlist, StudyFormFillCz.class); + for (StudyFormFillCz studyFormFillCz : studyFormFillCzList) { + for (String bh : studyFormFillCz.getList()) { + Mjy mjy = mjyMap.get(bh); + // 稽查轨迹 + HashMap formData = new HashMap<>(); + formData.put("处置方式", studyFormFillCz.getCzfs()); + formData.put("处置量", mjy.getKc() + mjy.getKcdw()); + jcgjList.add(mjyJcgjService.getJcgj(mjy.getId(), JcgjlxEnum.lc.getValue(), "存储",JcmcysEnum.green.getValue(), JctUtil.formatStr(formData), JctUtil.formatStr(MjyJcnrUtil.getMapEn(formData)), qmr,remark)); + + // 台账 + tzList.add(mjyTzService.getTz(mjy.getId(), null,null, null,null, null,null, null,null, qmr,"处置" ,mjy.getKc(),mjy.getKcdw(), remark)); + + } + baseMapper.updateKcBatch(studyFormFillCz.getList(), "0"); + } + } + mjyJcgjService.saveBatch(jcgjList); + mjyTzService.saveBatch(tzList); + studyMjyService.saveBatch(studyId, mjyList); + + } + //endregion //region 档案管理 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 aa893b6..351e0b7 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 @@ -60,6 +60,10 @@ public class StudyFormFillServiceImpl extends ServiceImpl sjList) { + List resourceIdList = sjList.stream().map(MpBaseEntity::getId).collect(Collectors.toList()); + + // 查询数据库中已有记录 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(StudyGyzj::getStudyId, studyId) + .in(StudyGyzj::getResourceId, resourceIdList); + List list = this.list(queryWrapper); + List dbResourceIdList = list.stream().map(StudyGyzj::getResourceId).collect(Collectors.toList()); + + // 对比id,插入数据库中没有的记录 + List insertResourceId = resourceIdList.stream() + .filter(element -> !dbResourceIdList.contains(element)) + .collect(Collectors.toList()); + if(CollectionUtils.isNotEmpty(insertResourceId)) { + List studyGyzjList = new ArrayList<>(); + for (Long resourceId : insertResourceId) { + StudyGyzj studyGyzj = new StudyGyzj(); + studyGyzj.setResourceId(resourceId); + studyGyzj.setStudyId(studyId); + studyGyzjList.add(studyGyzj); + } + this.saveBatch(studyGyzjList); + } + } } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyMjyServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyMjyServiceImpl.java index c330251..1e5b5c2 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyMjyServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyMjyServiceImpl.java @@ -1,11 +1,18 @@ package com.hxhq.business.service.impl; +import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hxhq.business.domain.Mjy; import com.hxhq.business.domain.StudyGyzj; +import com.hxhq.common.core.domain.MpBaseEntity; import com.hxhq.common.core.utils.DateUtils; +import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import com.hxhq.business.mapper.StudyMjyMapper; import com.hxhq.business.domain.StudyMjy; @@ -31,4 +38,36 @@ public class StudyMjyServiceImpl extends ServiceImpl i } + /** + * 关联试验 + * @param studyId + * @param sjList + */ + @Override + @Async + public void saveBatch(Long studyId, List sjList) { + List resourceIdList = sjList.stream().map(MpBaseEntity::getId).collect(Collectors.toList()); + + // 查询数据库中已有记录 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(StudyMjy::getStudyId, studyId) + .in(StudyMjy::getResourceId, resourceIdList); + List list = this.list(queryWrapper); + List dbResourceIdList = list.stream().map(StudyMjy::getResourceId).collect(Collectors.toList()); + + // 对比id,插入数据库中没有的记录 + List insertResourceId = resourceIdList.stream() + .filter(element -> !dbResourceIdList.contains(element)) + .collect(Collectors.toList()); + if(CollectionUtils.isNotEmpty(insertResourceId)) { + List studyMjyList = new ArrayList<>(); + for (Long resourceId : insertResourceId) { + StudyMjy studyMjy = new StudyMjy(); + studyMjy.setResourceId(resourceId); + studyMjy.setStudyId(studyId); + studyMjyList.add(studyMjy); + } + this.saveBatch(studyMjyList); + } + } } diff --git a/hxhq-modules/hxhq-system/src/main/resources/mapper/business/GyzjMapper.xml b/hxhq-modules/hxhq-system/src/main/resources/mapper/business/GyzjMapper.xml index 32841c3..aeecc9c 100644 --- a/hxhq-modules/hxhq-system/src/main/resources/mapper/business/GyzjMapper.xml +++ b/hxhq-modules/hxhq-system/src/main/resources/mapper/business/GyzjMapper.xml @@ -39,4 +39,20 @@ + + UPDATE t_gyzj SET kc = #{kc} WHERE bh in + + (#{item}) + + + + UPDATE t_gyzj SET cctj = #{cctj}, ccwz = #{ccwz} WHERE bh in + + (#{item}) + + + + UPDATE t_gyzj SET kc = #{kc} WHERE id = #{id} + + \ No newline at end of file diff --git a/hxhq-modules/hxhq-system/src/main/resources/mapper/business/MjyMapper.xml b/hxhq-modules/hxhq-system/src/main/resources/mapper/business/MjyMapper.xml index f3c4475..23225df 100644 --- a/hxhq-modules/hxhq-system/src/main/resources/mapper/business/MjyMapper.xml +++ b/hxhq-modules/hxhq-system/src/main/resources/mapper/business/MjyMapper.xml @@ -37,4 +37,20 @@ + + UPDATE t_mjy SET kc = #{kc} WHERE bh in + + (#{item}) + + + + UPDATE t_mjy SET cctj = #{cctj}, ccwz = #{ccwz} WHERE bh in + + (#{item}) + + + + UPDATE t_mjy SET kc = #{kc} WHERE id = #{id} + + \ No newline at end of file