|
@@ -4,11 +4,9 @@ import cn.hnthyy.thmz.entity.MzException;
|
|
|
import cn.hnthyy.thmz.entity.his.yp.YpBaseYf;
|
|
|
import cn.hnthyy.thmz.entity.his.yp.YpOutDetlYf;
|
|
|
import cn.hnthyy.thmz.entity.his.yp.YpZdDict;
|
|
|
+import cn.hnthyy.thmz.entity.his.yp.YpZdGroupName;
|
|
|
import cn.hnthyy.thmz.mapper.his.mz.EmployeeMapper;
|
|
|
-import cn.hnthyy.thmz.mapper.his.yp.YpBaseYfMapper;
|
|
|
-import cn.hnthyy.thmz.mapper.his.yp.YpOutDetlYfMapper;
|
|
|
-import cn.hnthyy.thmz.mapper.his.yp.YpZdDictMapper;
|
|
|
-import cn.hnthyy.thmz.mapper.his.yp.YpZdManufactoryMapper;
|
|
|
+import cn.hnthyy.thmz.mapper.his.yp.*;
|
|
|
import cn.hnthyy.thmz.mapper.his.zd.ZdUnitCodeMapper;
|
|
|
import cn.hnthyy.thmz.service.his.yf.YpOutDetlYfService;
|
|
|
import cn.hnthyy.thmz.service.his.yp.YpConfigService;
|
|
@@ -55,6 +53,9 @@ public class YpOutDetlYfServiceImpl implements YpOutDetlYfService {
|
|
|
@SuppressWarnings("all")
|
|
|
@Autowired
|
|
|
private YpZdManufactoryMapper ypZdManufactoryMapper;
|
|
|
+ @SuppressWarnings("all")
|
|
|
+ @Autowired
|
|
|
+ private YpZdGroupNameMapper ypZdGroupNameMapper;
|
|
|
|
|
|
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
|
|
|
@Override
|
|
@@ -98,6 +99,10 @@ public class YpOutDetlYfServiceImpl implements YpOutDetlYfService {
|
|
|
ypOutDetlYf.setInputId(userId);
|
|
|
ypOutDetlYf.setKeeper(userId);
|
|
|
ypOutDetlYf.setConfirmFlag("0");
|
|
|
+ YpZdGroupName ypZdGroupName = ypZdGroupNameMapper.selectByDeptCode(ypOutDetlYf.getDeptCode());
|
|
|
+ if(null != ypZdGroupName){
|
|
|
+ ypOutDetlYf.setGroupNoOut(ypZdGroupName.getGroupNo());
|
|
|
+ }
|
|
|
ypOutDetlYfMapper.insertYpOutDetlYf(ypOutDetlYf);
|
|
|
}
|
|
|
return 0;
|
|
@@ -137,11 +142,33 @@ public class YpOutDetlYfServiceImpl implements YpOutDetlYfService {
|
|
|
List<YpOutDetlYf> ypOutDetlYfs = ypOutDetlYfMapper.selectYpOutDetlYfDetl(drawNo);
|
|
|
for (int i = 0; i < ypOutDetlYfs.size(); i++) {
|
|
|
YpOutDetlYf ypOutDetlYf = ypOutDetlYfs.get(i);
|
|
|
- if(1 == ypBaseYfMapper.updateStockAmount(ypOutDetlYf.getChargeCode(),ypOutDetlYf.getSerial(),
|
|
|
- ypOutDetlYf.getGroupNo(),-ypOutDetlYf.getOutAmt(), BigDecimal.valueOf(-ypOutDetlYf.getOutAmt()).multiply(ypOutDetlYf.getPackRetprice()))){
|
|
|
+ String chargeCode = ypOutDetlYf.getChargeCode();
|
|
|
+ String serial = ypOutDetlYf.getSerial();
|
|
|
+ double outAmt = ypOutDetlYf.getOutAmt();
|
|
|
+ BigDecimal multiply = BigDecimal.valueOf(ypOutDetlYf.getOutAmt()).multiply(ypOutDetlYf.getPackRetprice());
|
|
|
+
|
|
|
+ if(1 == ypBaseYfMapper.updateStockAmount(chargeCode,serial,
|
|
|
+ ypOutDetlYf.getGroupNo(),-outAmt, multiply.negate())){
|
|
|
log.info("药房出库药品成功[单号:{},编码:{},规格:{},数量:{}]", drawNo,ypOutDetlYf.getChargeCode(),ypOutDetlYf.getSerial(),-ypOutDetlYf.getOutAmt());
|
|
|
}else{
|
|
|
- new MzException("药房出库药品审核失败,单号:"+drawNo);
|
|
|
+ new MzException("药房出库药品审核失败,药房扣库异常,单号:"+drawNo);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(ypOutDetlYf.getGroupNoOut())){
|
|
|
+ YpBaseYf ypBaseYf = ypBaseYfMapper.selectYpBaseYf(chargeCode, serial, ypOutDetlYf.getGroupNoOut(), null);
|
|
|
+ if(null == ypBaseYf){
|
|
|
+ YpBaseYf ypBase = ypBaseYfMapper.selectYpBaseYf(chargeCode, serial, ypOutDetlYf.getGroupNo(), null);
|
|
|
+ ypBase.setVisibleFlagMz("0");
|
|
|
+ ypBase.setVisibleFlagStop("0");
|
|
|
+ ypBase.setVisibleFlagZy("0");
|
|
|
+ ypBase.setStockAmount(outAmt);
|
|
|
+ ypBase.setStockValue(multiply);
|
|
|
+ ypBase.setStockAmountVirtual(outAmt);
|
|
|
+ ypBase.setGroupNo(ypOutDetlYf.getGroupNoOut());
|
|
|
+ ypBaseYfMapper.insertYpBaseYf(ypBase);
|
|
|
+ }else{
|
|
|
+ ypBaseYfMapper.updateStockAmount(chargeCode,serial,ypOutDetlYf.getGroupNoOut(),outAmt, multiply);
|
|
|
+ }
|
|
|
+ log.info("药房药品接收成功");
|
|
|
}
|
|
|
YpOutDetlYf yp = new YpOutDetlYf();
|
|
|
yp.setConfirmId(userId);
|