소스 검색

科室药品入出库增加药房互调库存业务

WANGJIALIANG 2 년 전
부모
커밋
9892717cd4

+ 3 - 3
src/main/java/cn/hnthyy/thmz/entity/his/yp/YpOutDetlYf.java

@@ -74,15 +74,15 @@ public class YpOutDetlYf {
 	 */
   private String outType;
 	/**
-	 * null
+	 * 记帐标志;1:结账
 	 */
   private String acctType;
 	/**
-	 * null
+	 * 结帐人
 	 */
   private String acctId;
 	/**
-	 * null
+	 * 结帐日期
 	 */
   private Date acctDate;
 	/**

+ 9 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/yp/YpZdGroupNameMapper.java

@@ -18,6 +18,15 @@ public interface YpZdGroupNameMapper {
     @Select("select group_no,dept_code,py_code,d_code wb_code,group_name,mz_flag,yf_flag from yp_zd_group_name WITH(NOLOCK) where group_no=#{groupNo}")
     YpZdGroupName selectByGroupNo(@Param("groupNo") String groupNo);
 
+    /**
+     * 根据科室编码查询药房
+     *
+     * @param deptCode
+     * @return
+     */
+    @Select("select group_no,dept_code,py_code,d_code wb_code,group_name,mz_flag,yf_flag from yp_zd_group_name WITH(NOLOCK) where dept_code=#{deptCode}")
+    YpZdGroupName selectByDeptCode(@Param("deptCode") String deptCode);
+
     /**
      * 分页查询药房库字典列表
      *

+ 32 - 7
src/main/java/cn/hnthyy/thmz/service/impl/his/yf/YpOutDetlYfServiceImpl.java

@@ -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,31 @@ 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);
+                    ypBaseYfMapper.insertYpBaseYf(ypBase);
+                }else{
+                    ypBaseYfMapper.updateStockAmount(chargeCode,serial,ypOutDetlYf.getGroupNoOut(),outAmt, multiply);
+                }
+                log.info("药房药品接收成功");
             }
             YpOutDetlYf yp = new YpOutDetlYf();
             yp.setConfirmId(userId);

+ 1 - 1
src/main/resources/templates/fy_config.html

@@ -34,7 +34,7 @@
                                 <option value="91">医材药房</option>
                             </select>
                         </div>
-                        <label class="control-label col-md-1 col-sm-1 col-xs-12" for="groupYk">当前库房
+                        <label class="control-label col-md-2 col-sm-2 col-xs-12" for="groupYk">当前库房<span style="color: red">(药房请保证当前库房为空)</span>
                         </label>
                         <div class="col-md-2 col-sm-2 col-xs-12">
                             <select class="form-control selectpicker show-tick" data-live-search="true"