Parcourir la source

发货单表体预计库存可用量算法变更

hu il y a 2 ans
Parent
commit
66f3962585

+ 6 - 0
src/custom/restcontroller/webmanage/sale/dispatch/SQL/商品发货数量汇总.sql

@@ -0,0 +1,6 @@
+SELECT  t3.itemno,
+        SUM(t1.qty-ifnull(t1.outwarehouseqty,0)) qty
+FROM sa_dispatch_items t1
+         inner join sa_dispatch t2 on t1.siteid = t2.siteid and t1.sa_dispatchid = t2.sa_dispatchid
+         inner join plm_item t3 on t1.siteid = t3.siteid and t1.itemid = t3.itemid
+WHERE t2.STATUS in ('审核','复核') and t1.siteid=$siteid$ group by t3.itemno

+ 11 - 1
src/custom/restcontroller/webmanage/sale/dispatch/dispatchItems.java

@@ -217,12 +217,22 @@ public class dispatchItems extends Controller {
             }
 
         }
+        SQLFactory sqlFactory1 =new SQLFactory(this,"商品发货数量汇总");
+        sqlFactory1.addParameter("siteid", siteid);
+        Rows sumQtyRows = dbConnect.runSqlQuery(sqlFactory1);
+        RowsMap sumQtyRowsMap= sumQtyRows.toRowsMap("itemno");
+
         if(!jsonArray.isEmpty()){
             for (Object object:jsonArray) {
                 JSONObject jsonObject =(JSONObject)object;
+
                 if(rowsMap.containsKey(jsonObject.getString("fitemno"))){
                     if(rowsMap.get(jsonObject.getString("fitemno")).isNotEmpty()){
-                        rowsMap.get(jsonObject.getString("fitemno")).get(0).put("delinvbalqty", jsonObject.getBigDecimalValue("fqty").subtract( rowsMap.get(jsonObject.getString("fitemno")).get(0).getBigDecimal("undeliqty")));
+                        if(sumQtyRowsMap.containsKey(jsonObject.getString("fitemno"))){
+                            rowsMap.get(jsonObject.getString("fitemno")).get(0).put("delinvbalqty", jsonObject.getBigDecimalValue("fqty").subtract( sumQtyRowsMap.get(jsonObject.getString("fitemno")).get(0).getBigDecimal("qty")));
+                        }else {
+                            rowsMap.get(jsonObject.getString("fitemno")).get(0).put("delinvbalqty", jsonObject.getBigDecimalValue("fqty"));
+                        }
                         rowsMap.get(jsonObject.getString("fitemno")).get(0).put("invbalqty", jsonObject.getBigDecimalValue("fqty"));
                     }
                 }

+ 1 - 1
src/custom/restcontroller/webmanage/sale/invbal/SQL/商品发货数量汇总.sql

@@ -3,4 +3,4 @@ SELECT  t3.itemno,
 FROM sa_dispatch_items t1
          inner join sa_dispatch t2 on t1.siteid = t2.siteid and t1.sa_dispatchid = t2.sa_dispatchid
          inner join plm_item t3 on t1.siteid = t3.siteid and t1.itemid = t3.itemid
-WHERE t2.STATUS in ('审核','关闭') and t1.siteid=$siteid$ group by t3.itemno
+WHERE t2.STATUS in ('审核','复核') and t1.siteid=$siteid$ group by t3.itemno