|
|
|
@ -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<ObjectCompareUtil.FieldChange> 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<String> errorBh = new ArrayList<>(); |
|
|
|
List<Sj> 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<ObjectCompareUtil.FieldChange> 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<String, String> 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); |
|
|
|
} |
|
|
|
|