فهرست منبع

药品分装组合bug修复

hsh 2 سال پیش
والد
کامیت
d5e776e853

+ 11 - 11
src/main/java/cn/hnthyy/thmz/mapper/his/yp/YpBaseYfMapper.java

@@ -114,7 +114,7 @@ public interface YpBaseYfMapper {
      * @return
      */
     @Select({"<script>",
-            "select charge_code,serial,stock_amount,stock_value,group_no,location,visible_flag_mz,visible_flag_zy,max_stock,mini_stock,isnull(split_percent,0)split_percent,retprice,pack_retprice," +
+            "select rtrim(charge_code) as charge_code,serial,stock_amount,stock_value,group_no,location,visible_flag_mz,visible_flag_zy,max_stock,mini_stock,isnull(split_percent,0)split_percent,retprice,pack_retprice," +
                     "       visible_flag_stop,stock_amount_virtual,stock_amount_virtual2,(case when open_virtual2='' then 0 else isnull(open_virtual2,0) end) as open_virtual2 " +
                     "from yp_base_yf WITH(NOLOCK) where charge_code=#{chargeCode} and serial=#{serial} and group_no=#{groupNo} ",
             "<when test='visibleFlagMz!=null'>",
@@ -177,7 +177,7 @@ public interface YpBaseYfMapper {
      * @param groupNo
      * @return
      */
-    @Select("  SELECT a.charge_code as code,   " +
+    @Select("  SELECT rtrim(a.charge_code) as code,   " +
             "         a.serial,   " +
             "         a.stock_amount,   " +
             "         a.pack_retprice,   " +
@@ -205,21 +205,21 @@ public interface YpBaseYfMapper {
      * @param chargeCode
      * @return
      */
-    @Select("  SELECT a.charge_code,   " +
-            "         a.serial,   " +
+    @Select("  SELECT rtrim(b.code) as charge_code,   " +
+            "         b.serial,   " +
             "         a.stock_amount,   " +
-            "         a.pack_retprice,   " +
+            "         b.pack_retprice,   " +
             "         b.name,   " +
             "         b.specification,   " +
             "         b.pack_size,   " +
             "         b.py_code,   " +
             "         b.d_code  " +
-            "    FROM yp_base_yf a WITH(NOLOCK),   " +
-            "         yp_zd_dict b WITH(NOLOCK) " +
-            "   WHERE ( a.serial = b.serial )  and" +
-            "          a.charge_code = b.code  and" +
-            "          a.charge_code = #{chargeCode} and" +
-            "          a.group_no = #{groupNo}")
+            "   FROM yp_zd_dict b WITH ( NOLOCK ) " +
+            "   left join yp_base_yf a WITH ( NOLOCK ) " +
+            "   on a.charge_code = b.code " +
+            "   and a.serial = b.serial " +
+            "   and a.group_no = #{groupNo} " +
+            "   WHERE b.code = #{chargeCode}  ")
     List<YpBaseYfVo> selectYpByChargeCodeAndGroupNo(@Param("chargeCode") String chargeCode, @Param("groupNo") String groupNo);
 
     /**

+ 25 - 10
src/main/java/cn/hnthyy/thmz/service/impl/his/yf/YfDivideServiceImpl.java

@@ -6,6 +6,7 @@ import cn.hnthyy.thmz.mapper.his.yf.YfDivideMapper;
 import cn.hnthyy.thmz.mapper.his.yp.*;
 import cn.hnthyy.thmz.service.his.yf.YfDivideService;
 import cn.hnthyy.thmz.vo.YpBaseYfVo;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
@@ -104,8 +105,8 @@ public class YfDivideServiceImpl implements YfDivideService {
             ypInDetlYf.setAcctType("1");
             ypInDetlYf.setGroupOut(ypBaseYfVo.getGroupNo());
             ypInDetlYf.setGroupNo(ypBaseYfVo.getGroupNo());
-            ypInDetlYf.setCurrentStock(ypBaseYfVo.getAmount()+ypBaseYf.getStockAmount());
-            ypInDetlYf.setStockAmount(ypBaseYf.getStockAmount());
+            ypInDetlYf.setCurrentStock(ypBaseYfVo.getAmount()+(null == ypBaseYf?0:ypBaseYf.getStockAmount()));
+            ypInDetlYf.setStockAmount((null == ypBaseYf?0:ypBaseYf.getStockAmount()));
             ypInDetlYf.setSysDate(new Date());
             ypInDetlYfMapper.insertYpInDetlYf(ypInDetlYf);
             YpOutDetlYf ypOutDetlYf = new YpOutDetlYf();
@@ -138,14 +139,28 @@ public class YfDivideServiceImpl implements YfDivideService {
             ypOutDetlYf.setComment("分装出库");
             ypOutDetlYfMapper.insertYpOutDetlYf(ypOutDetlYf);
             YpBaseYf ypBaseYfNew = new YpBaseYf();
-            double stockAmount = ypBaseYf.getStockAmount() + ypBaseYfVo.getAmount();
-            ypBaseYfNew.setStockAmount(stockAmount);
-            ypBaseYfNew.setStockAmountVirtual(stockAmount);
-            ypBaseYfNew.setStockValue(ypZdDict.getPackRetprice().multiply(BigDecimal.valueOf(stockAmount)));
-            ypBaseYfNew.setChargeCode(ypBaseYfVo.getChargeCode());
-            ypBaseYfNew.setSerial(ypBaseYfVo.getSerial());
-            ypBaseYfNew.setGroupNo(ypBaseYfVo.getGroupNo());
-            ypBaseYfMapper.updateYpBaseYf(ypBaseYfNew);
+            if(null == ypBaseYf){
+                BeanUtils.copyProperties(ypBaseYfOld, ypBaseYfNew);
+                double stockAmount = ypInDetlYf.getCurrentStock();
+                ypBaseYfNew.setStockAmount(stockAmount);
+                ypBaseYfNew.setStockAmountVirtual(stockAmount);
+                ypBaseYfNew.setStockValue(ypZdDict.getPackRetprice().multiply(BigDecimal.valueOf(stockAmount)));
+                ypBaseYfNew.setChargeCode(ypBaseYfVo.getChargeCode());
+                // 新药拆零没有拆零包装的规格,这里是拆零包装的
+                ypBaseYfNew.setSerial("01");
+                ypBaseYfNew.setGroupNo(ypBaseYfVo.getGroupNo());
+                ypBaseYfNew.setLocation(ypBaseYfVo.getLocation());
+                ypBaseYfMapper.insertYpBaseYf(ypBaseYfNew);
+            }else{
+                double stockAmount = ypInDetlYf.getCurrentStock();
+                ypBaseYfNew.setStockAmount(stockAmount);
+                ypBaseYfNew.setStockAmountVirtual(stockAmount);
+                ypBaseYfNew.setStockValue(ypZdDict.getPackRetprice().multiply(BigDecimal.valueOf(stockAmount)));
+                ypBaseYfNew.setChargeCode(ypBaseYfVo.getChargeCode());
+                ypBaseYfNew.setSerial(ypBaseYfVo.getSerial());
+                ypBaseYfNew.setGroupNo(ypBaseYfVo.getGroupNo());
+                ypBaseYfMapper.updateYpBaseYf(ypBaseYfNew);
+            }
             YpBaseYf ypBaseYfNewOld = new YpBaseYf();
             double stockAmountOld = ypBaseYfOld.getStockAmount() - ypBaseYfVo.getOldAmount();
             ypBaseYfNewOld.setStockAmount(stockAmountOld);

+ 3 - 3
src/main/java/cn/hnthyy/thmz/service/impl/his/yp/YpRepriceServiceImpl.java

@@ -86,7 +86,7 @@ public class YpRepriceServiceImpl implements YpRepricelService {
         ypZdDict.setCode(ypReprice.getChargeCode());
         ypZdDict.setSerial(ypReprice.getSerial());
         ypZdDict.setPackRetprice(ypReprice.getNewPrice());
-        ypZdDict.setRetprice(ypReprice.getNewPrice().divide(yp.getPackSize(),2, BigDecimal.ROUND_HALF_UP));
+        ypZdDict.setRetprice(ypReprice.getNewPrice().divide(yp.getPackSize(),3, BigDecimal.ROUND_HALF_UP));
         ypZdDict.setBuyPrice(ypReprice.getNewBuyPrice());
         ypZdDict.setFixPrice(ypReprice.getNewBuyPrice());
         ypZdDict.setYbxjPrice(ypReprice.getNewBuyPrice());
@@ -109,7 +109,7 @@ public class YpRepriceServiceImpl implements YpRepricelService {
             ypReprice.setReajustSerial(2);
             ypReprice.setSerial("01");
             ypReprice.setOrigPrice(yp.getRetprice());
-            ypReprice.setNewPrice(ypReprice.getNewPrice().divide(yp.getPackSize(),2, BigDecimal.ROUND_HALF_UP));
+            ypReprice.setNewPrice(ypReprice.getNewPrice().divide(yp.getPackSize(),3, BigDecimal.ROUND_HALF_UP));
             changedNotFieldsOfSql = ColumnSqlUtil.getChangedNotFieldsOfSql(new YpReprice(), ypReprice, 1);
             if (ypRepriceMapper.insertYpReprice(changedNotFieldsOfSql) != 1) {
                 throw new MzException("插入调价记录异常");
@@ -122,7 +122,7 @@ public class YpRepriceServiceImpl implements YpRepricelService {
             ypZdDict.setSerial("01");
             ypZdDict.setPackRetprice(ypReprice.getNewPrice());
             ypZdDict.setRetprice(ypZdDict.getPackRetprice());
-            ypZdDict.setBuyPrice(ypReprice.getNewBuyPrice().divide(yp.getPackSize(),2, BigDecimal.ROUND_HALF_UP));
+            ypZdDict.setBuyPrice(ypReprice.getNewBuyPrice().divide(yp.getPackSize(),3, BigDecimal.ROUND_HALF_UP));
             ypZdDict.setFixPrice(ypZdDict.getBuyPrice());
             ypZdDict.setYbxjPrice(ypZdDict.getBuyPrice());
             if (1 != ypZdDictMapper.updateYpZdDict(ypZdDict)) {

+ 1 - 1
src/main/resources/templates/yk/drug_sales_return.html

@@ -44,7 +44,7 @@
                            style="margin-top: 0px;border: transparent !important;">
                         <tr style="font-weight: 700;background-color: #EBEBE4;height: 70px;">
                             <td colspan="14" style="font-size: 21px;text-align: center;border: transparent !important;">
-                                <span class="title">长沙泰和医院西药库退货单</span></td>
+                                <span class="title">长沙泰和医院退货单</span></td>
                         </tr>
                         <tr style="font-weight: 700;background-color: #EBEBE4">
                             <td colspan="3" style="text-align: left;border: transparent !important;">供应商:<span