Просмотр исходного кода

增加经销商首页(数据看板)部分

hu 2 лет назад
Родитель
Сommit
a1d7119e99

+ 6 - 0
src/custom/restcontroller/R.java

@@ -5213,6 +5213,12 @@ public class R {
         public static class v1 {
         }
     }
+    public static class ID20230803140903 {
+        public static class v1 {
+        }
+    }
+
+
 }
 
 

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

@@ -0,0 +1,5 @@
+	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(ifnull(t1.outwarehouseqty,0)) sumoutwarehouseqty from sa_dispatch_items t1 inner join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid 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

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

@@ -0,0 +1,5 @@
+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(ifnull(t1.outwarehouseqty,0)) sumoutwarehouseqty from sa_dispatch_items t1 inner join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid 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

+ 1 - 1
src/custom/restcontroller/webmanage/sale/databoard/SQL/销售单量统计查询_月份.sql

@@ -1 +1 @@
-select  DATE_FORMAT(t1.checkdate,'%Y') y,DATE_FORMAT(t1.checkdate,'%m') m,CAST(count(1) AS DECIMAL(16,0)) typestatistics from sa_order t1 where t1.status not in('新建','提交') and t1.siteid =$siteid$  group by DATE_FORMAT(t1.checkdate,'%Y'),DATE_FORMAT(t1.checkdate,'%m')
+select  DATE_FORMAT(t1.checkdate,'%Y') y,DATE_FORMAT(t1.checkdate,'%m') m,CAST(count(1) AS DECIMAL(16,0)) typestatistics from sa_order t1 where t1.status not in('新建','提交') and t1.siteid =$siteid$ and $where$  group by DATE_FORMAT(t1.checkdate,'%Y'),DATE_FORMAT(t1.checkdate,'%m')

+ 1 - 1
src/custom/restcontroller/webmanage/sale/databoard/SQL/销售额统计查询_月份.sql

@@ -1,2 +1,2 @@
-select  DATE_FORMAT(t1.checkdate,'%Y') y,DATE_FORMAT(t1.checkdate,'%m') m,cast(ifnull(sum(if(t2.isclose,t2.deliedqty*t2.price,t2.amount)),0) AS DECIMAL(16,6)) typestatistics  from sa_order t1 inner join sa_orderitems t2 on t1.sa_orderid=t2.sa_orderid and t1.siteid=t2.siteid where t1.siteid=$siteid$ and t1.status not in('新建','提交') group by  DATE_FORMAT(t1.checkdate,'%Y'),DATE_FORMAT(t1.checkdate,'%m')
+select  DATE_FORMAT(t1.checkdate,'%Y') y,DATE_FORMAT(t1.checkdate,'%m') m,cast(ifnull(sum(if(t2.isclose,t2.deliedqty*t2.price,t2.amount)),0) AS DECIMAL(16,6)) typestatistics  from sa_order t1 inner join sa_orderitems t2 on t1.sa_orderid=t2.sa_orderid and t1.siteid=t2.siteid where t1.siteid=$siteid$ and t1.status not in('新建','提交') and $where$  group by  DATE_FORMAT(t1.checkdate,'%Y'),DATE_FORMAT(t1.checkdate,'%m')
 

+ 58 - 1
src/custom/restcontroller/webmanage/sale/databoard/databoard.java

@@ -13,6 +13,7 @@ import common.data.Row;
 import common.data.Rows;
 import common.data.RowsMap;
 import common.data.SQLFactory;
+import jdk.nashorn.internal.objects.annotations.Where;
 import org.apache.commons.lang.StringUtils;
 import restcontroller.R;
 
@@ -213,6 +214,10 @@ public class databoard extends Controller {
     public String SalesOrderByMonthAnalysis() throws Exception {
 
         String datatype = content.getString("datatype");
+        String where = " 1=1 ";
+        if(sys_enterpriseid>0){
+            where=where+" and t1.sys_enterpriseid="+sys_enterpriseid;
+        }
         /*
          * 过滤条件设置
          */
@@ -235,6 +240,7 @@ public class databoard extends Controller {
             return getErrReturnObject().setErrMsg("datatype类型错误").toString();
         }
         factory.addParameter("siteid", siteid);
+        factory.addParameter_SQL("where", where);
         Rows rows = dbConnect.runSqlQuery(factory.getSQL(false));
         String year = new SimpleDateFormat("yyyy").format(new Date());
         String lastyear = String.valueOf(Integer.parseInt(new SimpleDateFormat("yyyy").format(new Date())) - 1);
@@ -393,6 +399,10 @@ public class databoard extends Controller {
             whereLastYear.append(" and DATE_FORMAT(t1.checkdate, '%Y-%m-%d') <='").append(sdf.format(cal.getTime())).append("' ");
         }
 
+        if(sys_enterpriseid>0){
+            where.append(" and t1.sys_enterpriseid="+sys_enterpriseid);
+        }
+
         if (datatype.equals("标准")) {
             where.append(" and t1.type='标准订单' ");
             whereLastYear.append(" and t1.type='标准订单' ");
@@ -446,7 +456,8 @@ public class databoard extends Controller {
                 row.put("proportion", row.getBigDecimal("amount").divide(sumamount, 4, BigDecimal.ROUND_HALF_UP));
             }
         }
-
+        topItemclassRows.sort(Comparator.comparingDouble(o ->o.getDouble("amount")));
+        Collections.reverse(topItemclassRows);
         return getSucReturnObject().setData(topItemclassRows).toString();
     }
 
@@ -734,6 +745,52 @@ public class databoard extends Controller {
     }
 
 
+    /**
+     * 工厂待发明细
+     *
+     * @return
+     */
+    @API(title = "工厂待发明细", apiversion = R.ID20230803140903.v1.class)
+    @CACHEING
+    public String factoryPendingDetails() throws YosException {
+
+
+        /*
+         * 过滤条件设置
+         */
+        StringBuffer where = new StringBuffer(" 1=1 ");
+        if(sys_enterpriseid>0){
+            where.append(" and t2.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("' ");
+                }
+            if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
+                where.append(" and DATE_FORMAT(t2.checkdate, '%Y-%m-%d') <='").append(whereObject.getString("enddate")).append("' ");
+            }
+        }
+
+
+
+        SQLFactory factory = new SQLFactory(this, "工厂待发明细查询");
+        factory.addParameter("siteid", siteid);
+        factory.addParameter_SQL("where", where);
+        Rows rows = dbConnect.runSqlQuery(factory.getSQL(false));
+
+        SQLFactory sumfactory = new SQLFactory(this, "工厂待发合计金额及数量查询");
+        sumfactory.addParameter("siteid", siteid);
+        sumfactory.addParameter_SQL("where", where);
+        Rows sumrows = dbConnect.runSqlQuery(sumfactory.getSQL(false));
+        if(rows.isNotEmpty()){
+            rows.get(0).put("sumrows", sumrows);
+        }
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+
     /**
      * @Description: 获取季度第一天
      * 1.根据给定日期计算当前季度的第一个月份