Sfoglia il codice sorgente

发货商品查询添加按订单号查询及订单表体添加预计可用量

hu 3 anni fa
parent
commit
e8b1911538

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

@@ -80,6 +80,7 @@ public class dispatchItems extends Controller {
                 where.append("t1.itemname like'%").append(whereObject.getString("condition")).append("%' ");
                 where.append("t1.itemname like'%").append(whereObject.getString("condition")).append("%' ");
                 where.append("or t1.itemno like'%").append(whereObject.getString("condition")).append("%' ");
                 where.append("or t1.itemno like'%").append(whereObject.getString("condition")).append("%' ");
                 where.append("or t1.unit like'%").append(whereObject.getString("condition")).append("%' ");
                 where.append("or t1.unit like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t3.sonum like'%").append(whereObject.getString("condition")).append("%' ");
                 where.append(")");
                 where.append(")");
             }
             }
             if (whereObject.containsKey("sa_orderid") && !"".equals(whereObject.getString("sa_orderid"))) {
             if (whereObject.containsKey("sa_orderid") && !"".equals(whereObject.getString("sa_orderid"))) {

+ 34 - 0
src/custom/restcontroller/webmanage/sale/order/OrderItems.java

@@ -26,6 +26,7 @@ import restcontroller.webmanage.sale.aftersalesmag.twriteoffbill_orderchange;
 import restcontroller.webmanage.sale.rebate.Rebate;
 import restcontroller.webmanage.sale.rebate.Rebate;
 import restcontroller.webmanage.sale.toolbill.ToolBilItem;
 import restcontroller.webmanage.sale.toolbill.ToolBilItem;
 import restcontroller.webmanage.sale.toolbill.ToolBill;
 import restcontroller.webmanage.sale.toolbill.ToolBill;
+import utility.ERPDocking;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
@@ -347,9 +348,42 @@ public class OrderItems extends Controller {
         sqlFactory.addParameter_SQL("where", where);
         sqlFactory.addParameter_SQL("where", where);
         Rows rows = dbConnect.runSqlQuery(sqlFactory);
         Rows rows = dbConnect.runSqlQuery(sqlFactory);
         ArrayList<Long> ids = rows.toArrayList("itemid", new ArrayList<>());
         ArrayList<Long> ids = rows.toArrayList("itemid", new ArrayList<>());
+        RowsMap rowsMap =rows.toRowsMap("itemno");
+
+        SQLFactory sqlFactory1 =new SQLFactory(this,"商品发货数量汇总");
+        sqlFactory1.addParameter("siteid", siteid);
+        Rows sumQtyRows = dbConnect.runSqlQuery(sqlFactory1);
+        RowsMap sumQtyRowsMap= sumQtyRows.toRowsMap("itemno");
+
+        ERPDocking erpDocking =new ERPDocking();
+        JSONArray jsonArray =new JSONArray();
+        if(rows.toJsonArray("itemno").size()!=0){
+            if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true")) {
+                jsonArray=erpDocking.getErpIcinvbalRows(200000, 1,rows.toJsonArray("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("invbalqty", jsonObject.getBigDecimalValue("fqty"));
+                    }
+                }
+            }
+        }
         //查询附件
         //查询附件
         RowsMap attinfoRowsMap = getAttachmentUrl("plm_item", ids);
         RowsMap attinfoRowsMap = getAttachmentUrl("plm_item", ids);
         for (Row row : rows) {
         for (Row row : rows) {
+            if(sumQtyRowsMap.get(row.getString("itemno")).isNotEmpty()){
+                row.put("unsoldqty", sumQtyRowsMap.get(row.getString("itemno")).get(0).getBigDecimal("qty"));
+            }else {
+                row.put("unsoldqty", BigDecimal.ZERO);
+            }
+            if(!row.containsKey("invbalqty")){
+                row.put("invbalqty",BigDecimal.ZERO);
+            }
             row.put("attinfos", attinfoRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
             row.put("attinfos", attinfoRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
             row.put("contractprice", 0);
             row.put("contractprice", 0);
         }
         }

+ 6 - 0
src/custom/restcontroller/webmanage/sale/order/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