소스 검색

新品销售统计

hu 2 년 전
부모
커밋
4c79319003

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

@@ -5201,6 +5201,15 @@ public class R {
         public static class v1 {
         }
     }
+    public static class ID20230802100103 {
+        public static class v1 {
+        }
+    }
+    public static class ID20230802103303 {
+        public static class v1 {
+        }
+    }
+
 
 }
 

+ 4 - 0
src/custom/restcontroller/webmanage/sale/databoard/SQL/新品销售占比.sql

@@ -0,0 +1,4 @@
+ select t3.itemname,t1.siteid,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
+ left join plm_item t3 on t2.itemid=t3.itemid and t2.siteid=t3.siteid
+ where t1.siteid=$siteid$ and $where$ and t1.status not in('新建','提交') and t3.delistingstatus='新品' group by t3.itemname,t1.siteid

+ 4 - 0
src/custom/restcontroller/webmanage/sale/databoard/SQL/新品销售走势.sql

@@ -0,0 +1,4 @@
+ 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
+ left join plm_item t3 on t2.itemid=t3.itemid and t2.siteid=t3.siteid
+ where t1.siteid=$siteid$ and t1.status not in('新建','提交') and DATE_FORMAT(t1.checkdate,'%Y')=$year$ group by DATE_FORMAT(t1.checkdate,'%Y'),DATE_FORMAT(t1.checkdate,'%m')

+ 105 - 0
src/custom/restcontroller/webmanage/sale/databoard/databoard.java

@@ -447,6 +447,111 @@ public class databoard extends Controller {
         return getSucReturnObject().setData(topItemclassRows).toString();
     }
 
+    /**
+     * 新品销售占比
+     *
+     * @return
+     */
+    @API(title = "新品销售占比", apiversion = R.ID20230802100103.v1.class)
+    @CACHEING
+    public String newProductSalesAnalysis() throws Exception {
+
+        String datetype = content.getStringValue("datetype");
+        String begindate = "";
+        String enddate = "";
+        switch (datetype) {
+            case "月":
+                begindate = getMonthFirstDay();
+                enddate = getMonthLastDay();
+                break;
+            case "年":
+                begindate = new SimpleDateFormat("yyyy").format(new Date()) + "-01-01";
+                enddate = new SimpleDateFormat("yyyy").format(new Date()) + "-12-31";
+                break;
+            case "周":
+                begindate = getWeekFirstDay();
+                enddate = getWeekLastDay();
+                break;
+            default:
+                break;
+        }
+        /*
+         * 过滤条件设置
+         */
+        if (content.containsKey("where")) {
+            JSONObject whereObject = content.getJSONObject("where");
+            if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
+                begindate = whereObject.getString("begindate");
+            }
+            if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
+                enddate = whereObject.getString("enddate");
+            }
+        }
+
+        StringBuffer where = new StringBuffer(" 1=1 ");
+        StringBuffer whereLastYear = new StringBuffer(" 1=1 ");
+
+
+        if (begindate != "") {
+            where.append(" and DATE_FORMAT(t1.checkdate, '%Y-%m-%d') >='").append(begindate).append("' ");
+            Date date = sdf.parse(begindate);
+            //创建Calendar实例
+            Calendar cal = Calendar.getInstance();
+            //设置当前时间
+            cal.setTime(date);
+            //在当前时间基础上减一年
+            cal.add(Calendar.YEAR, -1);
+            whereLastYear.append(" and DATE_FORMAT(t1.checkdate, '%Y-%m-%d') >='").append(sdf.format(cal.getTime())).append("' ");
+        }
+        if (enddate != "") {
+            where.append(" and DATE_FORMAT(t1.checkdate, '%Y-%m-%d') <='").append(enddate).append("' ");
+            Date date = sdf.parse(enddate);
+            //创建Calendar实例
+            Calendar cal = Calendar.getInstance();
+            //设置当前时间
+            cal.setTime(date);
+            //在当前时间基础上减一年
+            cal.add(Calendar.YEAR, -1);
+            whereLastYear.append(" and DATE_FORMAT(t1.checkdate, '%Y-%m-%d') <='").append(sdf.format(cal.getTime())).append("' ");
+        }
+
+        SQLFactory factory = new SQLFactory(this, "新品销售占比");
+        factory.addParameter("siteid", siteid);
+        factory.addParameter_SQL("where", where);
+        Rows rows = dbConnect.runSqlQuery(factory.getSQL(false));
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    /**
+     * 新品销售走势
+     *
+     * @return
+     */
+    @API(title = "新品销售走势", apiversion = R.ID20230802103303.v1.class)
+    @CACHEING
+    public String newProductSalesTrend() throws Exception {
+        SQLFactory factory = new SQLFactory(this, "新品销售走势");
+        String year = new SimpleDateFormat("yyyy").format(new Date());
+        factory.addParameter("siteid", siteid);
+        factory.addParameter_SQL("year",year);
+        Rows rows = dbConnect.runSqlQuery(factory.getSQL(false));
+        List<DataTrans> list = new ArrayList();
+        for (Row row : rows) {
+            DataTrans dataTrans = new DataTrans();
+            if(row.getString("y").equals(year)){
+                dataTrans.setName(row.getString("y")+"-"+ row.getString("m"));
+                dataTrans.setMonth(row.getString("m"));
+                dataTrans.setYear(row.getString("y"));
+                dataTrans.setValue(row.getBigDecimal("typestatistics"));
+                list.add(dataTrans);
+            }
+        }
+        list=supplementDate(Integer.parseInt(year),list);
+        return getSucReturnObject().setData(list).toString();
+    }
+
+
 
     /**
      * 战区数据分析