Parcourir la source

仓库业务->出库、货转、调拨、通关确认时候也要校验件数、毛重、净重

caifc il y a 3 ans
Parent
commit
8f1ddaac53

+ 30 - 15
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehouseBillsServiceImpl.java

@@ -3603,10 +3603,8 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
                 }
                 //校验计费日期是等于库存总帐计费日,如果不相等则报错
                 checkWhgenleg(wbItem, tWhgenle);
-                //  库存 <  出库件数
-                if (tWhgenle.getfQtyblc() < wbItem.getfQty()) {
-                    throw new WarehouseException("库存明细第" + i + "行库存不足");
-                }
+                //  1、  库存 <  调拨件数  提示库存不足
+                judgeItemQty(tWhgenle, wbItem, i);
                 // 更新库存总账
                 updateTWhgenlegData(wbItem, tWhgenle.getfId(), billsType);
                 wbItem.setfBillstatus(40L);
@@ -3614,11 +3612,10 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
                 //校验计费日期是等于库存总帐计费日,如果不相等则报错
                 checkWhgenleg(wbItem, tWhgenle);
                 if (!Objects.equals(wbItem.getfWarehouselocid(), wbItem.getfTransferWarehouselocid())) {
-                    if (tWhgenle.getfQtyblc() < wbItem.getfQty()) {  //  1、  库存 <  调拨件数  提示库存不足
-                        throw new WarehouseException("库存明细第" + i + "行库存不足");
-                    } else {  // 2、 库存足够 先 进行出库操作
-                        updateTWhgenlegData(wbItem, tWhgenle.getfId(), WarehouseTypeEnum.SJCK.getType());
-                    }
+                    //  1、  库存 <  调拨件数  提示库存不足
+                    judgeItemQty(tWhgenle, wbItem, i);
+                    // 2、 库存足够 先 进行出库操作
+                    updateTWhgenlegData(wbItem, tWhgenle.getfId(), WarehouseTypeEnum.SJCK.getType());
                     // 3、 进行入库操作 查询是否存在库存
                     TWhgenleg tWhgenle1 = queryWhgenlegService.secondStockWhgenleg(tWarehouseBills, wbItem, goods.getIfCntrno(), WarehouseTypeEnum.NOT_JUDGE_BOX.getType());
                     if (StringUtils.isNull(tWhgenle1)) {   // 5、 不存在 进行新增库存
@@ -3633,11 +3630,9 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
                 wbItem.setfBillingway(tWarehouseBills.getfBillingway());
                 //校验计费日期是等于库存总帐计费日,如果不相等则报错
                 checkWhgenleg(wbItem, tWhgenle);
-                if (tWhgenle.getfQtyblc() < wbItem.getfQty()) {  //  1、  库存 <  调拨件数  提示库存不足
-                    throw new WarehouseException("库存明细第" + i + "行库存不足");
-                } else {  // 2、 库存足够 先 进行出库操作
-                    updateTWhgenlegData(wbItem, tWhgenle.getfId(), WarehouseTypeEnum.SJCK.getType());
-                }
+                //  1、  库存 <  调拨件数  提示库存不足
+                judgeItemQty(tWhgenle, wbItem, i);
+                updateTWhgenlegData(wbItem, tWhgenle.getfId(), WarehouseTypeEnum.SJCK.getType());
                 long corpId = tWarehouseBills.getfCorpid();
                 tWarehouseBills.setfCorpid(tWarehouseBills.getfTocorpid());
                 // 3、 进行入库操作 查询是否存在库存
@@ -3653,7 +3648,6 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
             int num = 0;
             wbItem.setfPid(fPid);
             wbItem.setfBillno(tWarehouseBills.getfBillno());
-//            wbItem.setfBsdate(tWarehouseBills.getfBsdate());
             if (StringUtils.isNotNull(wbItem.getfId())) {
                 wbItem.setUpdateBy(loginUser.getUser().getUserName());
                 wbItem.setUpdateTime(new Date());
@@ -3743,6 +3737,27 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
     }
 
     /**
+     *  判断数量、毛重、净重是否超出库存总帐
+     * @param whgenleg  库存总账
+     * @param wbItem    明细
+     * @param line      行号
+     */
+    private void judgeItemQty(TWhgenleg whgenleg, TWarehousebillsitems wbItem, int line) {
+        //  库存 <  出库件数
+        if (whgenleg.getfQtyblc() < wbItem.getfQty()) {
+            throw new WarehouseException("库存明细第" + line + "行库存数量不足");
+        }
+        //  库存 <  出库净重
+        if (whgenleg.getfNetweightblc().compareTo(wbItem.getfNetweight()) < 0) {
+            throw new WarehouseException("库存明细第" + line + "行库存净重不足");
+        }
+        //  库存 <  出库毛重
+        if (whgenleg.getfGrossweightblc().compareTo(wbItem.getfGrossweight()) < 0) {
+            throw new WarehouseException("库存明细第" + line + "行库存毛重不足");
+        }
+    }
+
+    /**
      * 校验计费日期是等于库存总帐计费日,如果不相等则报错
      *
      * @param wbItem

+ 4 - 2
ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsMapper.xml

@@ -652,11 +652,12 @@
             AND dicttr.STATUS = '0'
             AND dicttr.dict_type = 'data_trademodes'
             AND leg.f_billtype in ('SJRK','CKDB')
+            AND it.f_billstatus = 40
             <if test="fGoodsid != null ">and it.f_goodsid = #{fGoodsid}</if>
             <if test="fTrademodeid != null ">and leg.f_trademodeid = #{fTrademodeid}</if>
             <if test="fNewTrademodeid != null ">and leg.f_new_trademodeid = #{fNewTrademodeid}</if>
             <if test="fCorpid != null ">and leg.f_corpid = #{fCorpid}</if>
-            <if test="fMblno != null ">and leg.f_mblno like concat('%',#{fMblno},'%')</if>
+            <if test="fMblno != null ">and it.f_mblno like concat('%',#{fMblno},'%')</if>
             <if test="fLocation != null  and fLocation ==1 ">
                 and it.f_warehouselocid = #{fWarehouseid}
             </if>
@@ -721,11 +722,12 @@
             AND dicttr.STATUS = '0'
             AND dicttr.dict_type = 'data_trademodes'
             AND leg.f_billtype in ('SJCK','CKDB')
+            AND it.f_billstatus = 40
             <if test="fGoodsid != null ">and it.f_goodsid = #{fGoodsid}</if>
             <if test="fTrademodeid != null ">and leg.f_trademodeid = #{fTrademodeid}</if>
             <if test="fNewTrademodeid != null ">and leg.f_new_trademodeid = #{fNewTrademodeid}</if>
             <if test="fCorpid != null ">and leg.f_corpid = #{fCorpid}</if>
-            <if test="fMblno != null ">and leg.f_mblno like concat('%',#{fMblno},'%')</if>
+            <if test="fMblno != null ">and it.f_mblno like concat('%',#{fMblno},'%')</if>
             <if test="fLocation != null  and fLocation ==1 ">
                 and it.f_warehouselocid = #{fWarehouseid}
             </if>