Przeglądaj źródła

Merge remote-tracking branch 'origin/develop' into develop

沈静伟 2 lat temu
rodzic
commit
6eebd2fa9b

+ 30 - 0
src/custom/restcontroller/sale/itemgroup/SQL/查询商品列表.sql

@@ -0,0 +1,30 @@
+SELECT t1.*,
+       t2.unitname, 
+       t8.caliber,
+       t8.pressure,
+       t8.material,
+       t8.butterflyplatedrive,
+       t8.connection,
+       t8.valveplatematerial,
+       t8.bodymaterial,
+       t8.actuatortype,
+       t8.actuatorbrand,
+       t8.isbutterfly,
+       t8.erpitemno,
+       t8.erpitemname,
+       t8.specalnote,
+       t8.prodline,
+       t8.device,
+			 t3.candispatchqty,
+			 t3.cansaleqty,
+			 t3.qty,
+        (SELECT (case
+                    when t3.cansaleqty >= t1.stockstatus1 then '充足'
+                    when t3.cansaleqty <= t1.stockstatus2 then '缺货'
+                    else '紧缺' end)) stockstatus
+FROM plm_item t1
+         LEFT JOIN plm_unit t2 ON t2.unitid = t1.unitid AND t2.siteid = t1.siteid
+          LEFT JOIN st_invbal_sale t3 ON t3.siteid = t1.siteid AND t3.itemid = t1.itemid
+         LEFT JOIN plm_itemextend t8 ON t8.itemid= t1.itemid AND t8.siteid = t1.siteid
+WHERE t1.siteid = $siteid$
+  and t1.itemid in $itemids$

+ 24 - 1
src/custom/restcontroller/sale/itemgroup/itemgroup.java

@@ -218,6 +218,24 @@ public class itemgroup extends Controller {
 
         ArrayList<Long> ids = rows.toArrayList("itemid", new ArrayList<>());
 
+        /**
+         * 查询商品明细
+         */
+        SQLFactory sqlFactory = new SQLFactory(this, "查询商品列表", pageSize, pageNumber, pageSorting);
+        sqlFactory.addParameter_in("itemids", ids);
+        sqlFactory.addParameter("siteid", siteid);
+        Rows itemrows = dbConnect.runSqlQuery(sqlFactory.getSQL());
+        for (Row row : itemrows) {
+            ItemPrice itemPrice = ItemPrice.getItemPrice(this, sys_enterpriseid, row.getLong("itemid"));
+            row.put("oldprice", itemPrice.getPrice());
+            if (sys_enterpriseid > 0 || (usertype == 21 || usertype == 22)) {
+                row.put("gradeprice", itemPrice.getContractprice());
+            } else {
+                row.put("gradeprice", itemPrice.getMarketprice());
+            }
+        }
+        RowsMap itemRowsMap =itemrows.toRowsMap("itemid");
+
         //默认商品图片
         Rows defaultImageRows = getAttachmentUrl("system", (long) 1, "defaultImage");
         // 封面cover
@@ -230,7 +248,12 @@ public class itemgroup extends Controller {
                         + siteid + "'");
         RowsMap itemclassRowsMap = rowsitemclass.toRowsMap("itemid");
         for (Row row : rows) {
-
+            Rows itemRows = itemRowsMap.get(row.getString("itemid"));
+            if (!itemRows.isEmpty()) {
+                row.put("item",itemRows);
+            } else {
+                row.put("item", new Rows());
+            }
 
             Rows coverRows = coverRowsMap.get(row.getString("itemid"));
             if (coverRows.isEmpty()) {

+ 11 - 19
src/custom/restcontroller/webmanage/sale/databoard/SQL/工厂待发合计金额及数量查询.sql

@@ -1,19 +1,11 @@
-select sum(t1.qty - ifnull(t3.sumoutwarehouseqty, 0))              sumundeliqty,
-       sum((t1.qty - ifnull(t3.sumoutwarehouseqty, 0)) * t1.price) sumundeliamount
-from sa_orderitems t1
-         inner join sa_order t2 on t1.sa_orderid = t2.sa_orderid and t1.siteid = t2.siteid
-         left join (select t1.sa_orderitemsid, t1.siteid, sum(t1.outwarehouseqty) sumoutwarehouseqty
-                    from sa_dispatch_items t1
-                             inner join sa_orderitems t2
-                                        on t1.sa_orderitemsid = t2.sa_orderitemsid and t1.siteid = t2.siteid
-                             inner join sa_dispatch t3 on t1.siteid = t3.siteid and t3.sa_dispatchid = t1.sa_dispatchid
-                    where t1.outwarehouseqty > 0
-                      and t1.siteid = $siteid$
-                      and $where2$
-                    group by t1.sa_orderitemsid, t1.siteid) t3
-                   on t1.sa_orderitemsid = t3.sa_orderitemsid and t1.siteid = t3.siteid
-         left join plm_item t4 on t1.itemid = t4.itemid and t1.siteid = t4.siteid
-where t2.status = '审核'
-  and t1.siteid = $siteid$
-  and $where$
-  and t1.qty - ifnull(t3.sumoutwarehouseqty, 0) > 0
+select sum(undeliqty) sumundeliqty,sum(undeliamount) sumundeliamount from (
+select t3.sonum,t3.billdate,t5.itemno,t5.itemname,t2.sa_orderitemsid,t4.price,
+t4.qty - sum( t2.outwarehouseqty ) undeliqty,
+(t4.qty - sum( t2.outwarehouseqty )) * t4.price undeliamount
+from sa_dispatch t1
+inner join sa_dispatch_items t2 on t1.siteid=t2.siteid and t1.sa_dispatchid=t2.sa_dispatchid
+inner join sa_order t3 on t1.siteid=t3.siteid and t1.sa_orderid=t3.sa_orderid and t3.status='审核'
+inner join sa_orderitems t4 on t3.siteid=t4.siteid and t3.sa_orderid=t4.sa_orderid and t2.sa_orderitemsid=t4.sa_orderitemsid
+inner join plm_item t5 on t4.siteid=t5.siteid and t4.itemid=t5.itemid
+where t1.siteid = $siteid$ AND t2.outwarehouseqty>0 and $where$
+GROUP BY t3.sonum,t3.billdate,t5.itemno,t5.itemname,t2.sa_orderitemsid,t4.price ,t4.qty having t4.qty - sum( t2.outwarehouseqty )  > 0) t

+ 10 - 25
src/custom/restcontroller/webmanage/sale/databoard/SQL/工厂待发明细查询.sql

@@ -1,25 +1,10 @@
-select t2.sonum,
-       t2.billdate,
-       t4.itemno,
-       t4.itemname,
-       t1.price,
-       t1.qty - ifnull(t3.sumoutwarehouseqty, 0)              undeliqty,
-       (t1.qty - ifnull(t3.sumoutwarehouseqty, 0)) * t1.price undeliamount
-from sa_orderitems t1
-         inner join sa_order t2 on t1.sa_orderid = t2.sa_orderid and t1.siteid = t2.siteid
-         left join (select t1.sa_orderitemsid, t1.siteid, sum(t1.outwarehouseqty) sumoutwarehouseqty
-                    from sa_dispatch_items t1
-                             inner join sa_orderitems t2
-                                        on t1.sa_orderitemsid = t2.sa_orderitemsid and t1.siteid = t2.siteid
-                             inner join sa_dispatch t3 on t1.siteid = t3.siteid and t3.sa_dispatchid = t1.sa_dispatchid
-                    where t1.outwarehouseqty > 0
-                      and t1.siteid = $siteid$
-                      and t3.status in ('复核','关闭','手工关闭')
-                      and $where2$
-                    group by t1.sa_orderitemsid, t1.siteid) t3
-                   on t1.sa_orderitemsid = t3.sa_orderitemsid and t1.siteid = t3.siteid
-         left join plm_item t4 on t1.itemid = t4.itemid and t1.siteid = t4.siteid
-where t2.status = '审核'
-  and t1.siteid = $siteid$
-  and $where$
-  and t1.qty - ifnull(t3.sumoutwarehouseqty, 0) > 0
+select t3.sonum,t3.billdate,t5.itemno,t5.itemname,t2.sa_orderitemsid,t4.price,
+t4.qty - sum( t2.outwarehouseqty ) undeliqty,
+(t4.qty - sum( t2.outwarehouseqty )) * t4.price undeliamount
+from sa_dispatch t1
+inner join sa_dispatch_items t2 on t1.siteid=t2.siteid and t1.sa_dispatchid=t2.sa_dispatchid
+inner join sa_order t3 on t1.siteid=t3.siteid and t1.sa_orderid=t3.sa_orderid and t3.status='审核'
+inner join sa_orderitems t4 on t3.siteid=t4.siteid and t3.sa_orderid=t4.sa_orderid and t2.sa_orderitemsid=t4.sa_orderitemsid
+inner join plm_item t5 on t4.siteid=t5.siteid and t4.itemid=t5.itemid
+where t1.siteid = $siteid$ AND t2.outwarehouseqty>0 and $where$
+GROUP BY t3.sonum,t3.billdate,t5.itemno,t5.itemname,t2.sa_orderitemsid,t4.price ,t4.qty having t4.qty - sum( t2.outwarehouseqty )  > 0

+ 4 - 7
src/custom/restcontroller/webmanage/sale/databoard/databoard.java

@@ -886,31 +886,28 @@ public class databoard extends Controller {
          * 过滤条件设置
          */
         StringBuffer where = new StringBuffer(" 1=1 ");
-        StringBuffer where2 = new StringBuffer(" 1=1 ");
         if (sys_enterpriseid > 0) {
-            where.append(" and t2.sys_enterpriseid=" + sys_enterpriseid);
-            where2.append(" and t3.sys_enterpriseid=" + sys_enterpriseid);
+            where.append(" and t3.sys_enterpriseid=" + sys_enterpriseid);
+
         }
         if (content.containsKey("where")) {
             JSONObject whereObject = content.getJSONObject("where");
             if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
-                where.append(" and DATE_FORMAT(t2.checkdate, '%Y-%m-%d') >='").append(whereObject.getString("begindate")).append("' ");
+                where.append(" and DATE_FORMAT(t3.checkdate, '%Y-%m-%d') >='").append(whereObject.getString("begindate")).append("' ");
             }
             if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
-                where.append(" and DATE_FORMAT(t2.checkdate, '%Y-%m-%d') <='").append(whereObject.getString("enddate")).append("' ");
+                where.append(" and DATE_FORMAT(t3.checkdate, '%Y-%m-%d') <='").append(whereObject.getString("enddate")).append("' ");
             }
         }
 
         SQLFactory factory = new SQLFactory(this, "工厂待发明细查询");
         factory.addParameter("siteid", siteid);
         factory.addParameter_SQL("where", where);
-        factory.addParameter_SQL("where2", where2);
         Rows rows = dbConnect.runSqlQuery(factory.getSQL(false));
 
         SQLFactory sumfactory = new SQLFactory(this, "工厂待发合计金额及数量查询");
         sumfactory.addParameter("siteid", siteid);
         sumfactory.addParameter_SQL("where", where);
-        sumfactory.addParameter_SQL("where2", where2);
         Rows sumrows = dbConnect.runSqlQuery(sumfactory.getSQL(false));
         if (rows.isNotEmpty()) {
             rows.get(0).put("sumrows", sumrows);