|
|
|
@ -1,13 +1,33 @@ |
|
|
|
package com.hxhq.business.service.impl; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.LinkedHashMap; |
|
|
|
import java.util.List; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.hxhq.business.domain.SjkcJcgj; |
|
|
|
import com.hxhq.business.enums.zykgl.JcgjlxEnum; |
|
|
|
import com.hxhq.business.enums.zykgl.JcmcysEnum; |
|
|
|
import com.hxhq.business.enums.zykgl.ZjztEnum; |
|
|
|
import com.hxhq.business.form.sj.CzsjForm; |
|
|
|
import com.hxhq.business.form.sj.SjXgkcForm; |
|
|
|
import com.hxhq.business.service.ISjkcJcgjService; |
|
|
|
import com.hxhq.business.utils.JctUtil; |
|
|
|
import com.hxhq.business.utils.ObjectCompareUtil; |
|
|
|
import com.hxhq.common.core.exception.ServiceException; |
|
|
|
import com.hxhq.system.api.domain.SysUser; |
|
|
|
import com.hxhq.system.service.ISysUserService; |
|
|
|
import org.apache.commons.lang3.math.NumberUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import com.hxhq.business.mapper.SjkcMapper; |
|
|
|
import com.hxhq.business.domain.Sjkc; |
|
|
|
import com.hxhq.business.service.ISjkcService; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.sql.rowset.serial.SerialException; |
|
|
|
|
|
|
|
/** |
|
|
|
* 试剂库存Service业务层处理 |
|
|
|
@ -18,6 +38,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
@Service |
|
|
|
public class SjkcServiceImpl extends ServiceImpl<SjkcMapper, Sjkc> implements ISjkcService |
|
|
|
{ |
|
|
|
@Autowired |
|
|
|
private ISysUserService sysUserService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ISjkcJcgjService sjkcJcgjService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询试剂库存列表 |
|
|
|
* |
|
|
|
@ -31,4 +57,89 @@ public class SjkcServiceImpl extends ServiceImpl implements IS |
|
|
|
return this.list(queryWrapper); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void xgkc(SjXgkcForm form) { |
|
|
|
SysUser qmr = sysUserService.selectUserById(form.getQmrId()); |
|
|
|
//验证签名人密码 todo |
|
|
|
if (form.getId() == null || form.getId().longValue() < 0) { |
|
|
|
throw new SecurityException("参数id不正确"); |
|
|
|
} |
|
|
|
Sjkc sjkcOld = this.getById(form.getId()); |
|
|
|
if (sjkcOld == null) { |
|
|
|
throw new SecurityException("试剂不存在或已删除"); |
|
|
|
} |
|
|
|
if (!sjkcOld.getZjzt().equals(ZjztEnum.rk.getValue())) { |
|
|
|
throw new SecurityException("试剂【" + sjkcOld.getMc() + "】不是入库状态,不能修改库存"); |
|
|
|
} |
|
|
|
List<ObjectCompareUtil.FieldChange> fieldChanges = ObjectCompareUtil.compareObjects(sjkcOld, form); |
|
|
|
if (fieldChanges.size() == 0) { |
|
|
|
throw new SecurityException("你没有修改任何内容"); |
|
|
|
} |
|
|
|
List<SjkcJcgj> sjkcJcgjList = new ArrayList<>(); |
|
|
|
//region 稽查轨迹 |
|
|
|
for (ObjectCompareUtil.FieldChange fieldChange : fieldChanges) { |
|
|
|
SjkcJcgj mjyJcgj = new SjkcJcgj(); |
|
|
|
mjyJcgj.setSjkcId(sjkcOld.getId()); |
|
|
|
mjyJcgj.setJcgjlx(JcgjlxEnum.lc.getValue()); |
|
|
|
mjyJcgj.setJcmc("修改库存"); |
|
|
|
mjyJcgj.setJcmcys(JcmcysEnum.green.getValue()); |
|
|
|
mjyJcgj.setJcnr(fieldChange.toString()); |
|
|
|
mjyJcgj.setQmyy("修改库存"); |
|
|
|
mjyJcgj.setQmrId(qmr.getUserId()); |
|
|
|
mjyJcgj.setQmrMc(qmr.getNickName()); |
|
|
|
sjkcJcgjList.add(mjyJcgj); |
|
|
|
} |
|
|
|
//endregion |
|
|
|
|
|
|
|
sjkcOld.setKcdw(form.getKcdw()); |
|
|
|
sjkcOld.setKc(form.getKc()); |
|
|
|
this.updateById(sjkcOld); |
|
|
|
sjkcJcgjService.saveBatch(sjkcJcgjList); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void cz(CzsjForm form) { |
|
|
|
SysUser qmr = sysUserService.selectUserById(form.getQmrId()); |
|
|
|
//验证签名人密码 todo |
|
|
|
if (form.getId() == null || form.getId() < 0) { |
|
|
|
throw new SecurityException("参数id不正确"); |
|
|
|
} |
|
|
|
Sjkc sjkc = this.getById(form.getId()); |
|
|
|
if (sjkc == null) { |
|
|
|
throw new SecurityException("试剂不存在或已删除"); |
|
|
|
} |
|
|
|
if (!sjkc.getZjzt().equals(ZjztEnum.rk.getValue())) { |
|
|
|
throw new SecurityException("试剂【" + sjkc.getMc() + "】不是入库状态,不能处置"); |
|
|
|
} |
|
|
|
if(!NumberUtils.isParsable(form.getCzl())) { |
|
|
|
throw new ServiceException("请输入正确的处置量"); |
|
|
|
} |
|
|
|
BigDecimal czl = new BigDecimal(form.getCzl()); |
|
|
|
BigDecimal kc = new BigDecimal(sjkc.getKc()); |
|
|
|
if(czl.compareTo(kc) > 0) { |
|
|
|
throw new ServiceException("处置量不应大于库存量"); |
|
|
|
} |
|
|
|
kc = kc.subtract(czl); |
|
|
|
sjkc.setKc(kc.toString()); |
|
|
|
updateById(sjkc); |
|
|
|
|
|
|
|
LinkedHashMap<String, String> jcnrMap = new LinkedHashMap<>(); |
|
|
|
jcnrMap.put("处置方式", form.getCzfs()); |
|
|
|
jcnrMap.put("处置量", form.getCzl()); |
|
|
|
jcnrMap.put("原因", form.getRemark()); |
|
|
|
SjkcJcgj sjkcJcgj = new SjkcJcgj(); |
|
|
|
sjkcJcgj.setSjkcId(sjkc.getId()); |
|
|
|
sjkcJcgj.setJcgjlx(JcgjlxEnum.bj.getValue()); |
|
|
|
sjkcJcgj.setJcmc("处置"); |
|
|
|
sjkcJcgj.setJcnr(JctUtil.formatStr(jcnrMap)); |
|
|
|
sjkcJcgj.setJcmcys(JcmcysEnum.green.getValue()); |
|
|
|
sjkcJcgj.setQmyy("处置"); |
|
|
|
sjkcJcgj.setQmrId(qmr.getUserId()); |
|
|
|
sjkcJcgj.setQmrMc(qmr.getNickName()); |
|
|
|
sjkcJcgjService.save(sjkcJcgj); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |