Kaynağa Gözat

小程序医院目标-产品目标

wu 2 hafta önce
ebeveyn
işleme
9f9c5fed37

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

@@ -7753,6 +7753,11 @@ public class R {
         public static class v1 {
         }
     }
+
+    public static class ID2026010716393302 {
+        public static class v1 {
+        }
+    }
 }
 
 

+ 21 - 0
src/custom/restcontroller/webmanage/sale/salestarget2/SQL/小程序医院目标-产品-目标.sql

@@ -0,0 +1,21 @@
+SELECT
+    t2.itemid,
+    sum(ROUND(m1 * price, 2))  m1amount,
+    sum(ROUND(m2 * price, 2))  m2amount,
+    sum(ROUND(m3 * price, 2))  m3amount,
+    sum(ROUND(m4 * price, 2))  m4amount,
+    sum(ROUND(m5 * price, 2))  m5amount,
+    sum(ROUND(m6 * price, 2))  m6amount,
+    sum(ROUND(m7 * price, 2))  m7amount,
+    sum(ROUND(m8 * price, 2))  m8amount,
+    sum(ROUND(m9 * price, 2))  m9amount,
+    sum(ROUND(m10 * price, 2)) m10amount,
+    sum(ROUND(m11 * price, 2)) m11amount,
+    sum(ROUND(m12 * price, 2)) m12amount
+from sa_salestargetbill t1
+         INNER JOIN sa_salestarget t2 ON t2.sa_salestargetbillid = t1.sa_salestargetbillid
+
+WHERE t1.year = $year$
+  and t1.`status` = '审核'
+  and t1.siteid = $siteid$   and t1.sa_customersid=$sa_customersid$
+GROUP BY  t2.itemid

+ 6 - 0
src/custom/restcontroller/webmanage/sale/salestarget2/SQL/小程序医院目标-产品-订单.sql

@@ -0,0 +1,6 @@
+SELECT  sum(t2.amount) amount, DATE_FORMAT(t1.checkdate, '%Y-%m') ym,t2.itemid
+from sa_order t1
+         INNER JOIN sa_orderitems t2 ON t2.sa_orderid = t1.sa_orderid and t2.siteid = t1.siteid
+
+WHERE t1.siteid = $siteid$ and t1.`status` in ('审核', '关闭') and YEAR (t1.checkdate) in ($year$, $befyear$)  and t1.sa_customersid =$sa_customersid$
+GROUP BY DATE_FORMAT(t1.checkdate, '%Y-%m'),t2.itemid

+ 12 - 0
src/custom/restcontroller/webmanage/sale/salestarget2/SQL/小程序医院目标-产品.sql

@@ -0,0 +1,12 @@
+SELECT DISTINCT t2.itemid, t2.itemname, t2.model, t3.spec, t5.itemclassname
+from sa_order t1
+         INNER JOIN sa_orderitems t2 ON t2.sa_orderid = t1.sa_orderid
+         LEFT JOIN plm_item t3 ON t3.itemid = t2.itemid
+         LEFT JOIN sa_itemsaleclass t4 ON t4.itemid = t2.itemid
+         LEFT JOIN plm_itemclass t5 ON t5.itemclassid = t4.itemclassid
+WHERE t1.siteid = $siteid$
+  and t1.status in ('审核', '关闭')
+  and t1.checkdate >= $startMonth$
+  and t1.checkdate < $endMonth$
+  and t1.sa_customersid = $sa_customersid$
+  and t5.itemclassname = $itemclassname$

+ 67 - 0
src/custom/restcontroller/webmanage/sale/salestarget2/salestargetstatistics.java

@@ -1071,6 +1071,73 @@ public class salestargetstatistics extends Controller {
         return getSucReturnObject().setData(itemclassrows).toString();
     }
 
+    @API(title = "小程序医院目标-产品目标", apiversion = R.ID2026010716393302.v1.class)
+    public String mATargetGoods() throws YosException {
+        int year = content.getIntValue("year");
+        int befyear = year - 1;
+        int month_start = content.getIntValue("month_start");
+        int month_end = content.getIntValue("month_end");
+        String itemclassname = content.getStringValue("itemclassname");
+        String yearMonthStr = year + "-12";
+        String startMonth = year + "-" + (month_start > 9 ? month_start : "0" + month_start) + "-01";
+        String endMonth = (year + 1) + "-01-01";
+        if (month_end < 12) {
+            endMonth = year + "-" + ((month_end + 1) > 9 ? (month_end + 1) : "0" + (month_end + 1)) + "-01";
+        }
+
+        Long sa_customersid = content.getLongValue("sa_customersid");
+
+        //查询商品
+        SQLFactory sqlFactory = new SQLFactory(this, "小程序医院目标-产品");
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter("startMonth", startMonth);
+        sqlFactory.addParameter("endMonth", endMonth);
+        sqlFactory.addParameter("itemclassname", itemclassname);
+        sqlFactory.addParameter("sa_customersid", sa_customersid);
+        Rows itemrows = dbConnect.runSqlQuery(sqlFactory);
+
+
+        sqlFactory = new SQLFactory(this, "小程序医院目标-产品-订单");
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter("year", year);
+        sqlFactory.addParameter("befyear", befyear);
+        sqlFactory.addParameter("sa_customersid", sa_customersid);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory);
+        RowsMap salesRowsMap = rows.toRowsMap("itemid");
+
+        sqlFactory = new SQLFactory(this, "小程序医院目标-产品-目标");
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter("year", year);
+        sqlFactory.addParameter("sa_customersid", sa_customersid);
+        Rows targetrows = dbConnect.runSqlQuery(sqlFactory);
+        RowsMap targetRowsMap = targetrows.toRowsMap("itemid");
+
+        ArrayList<String> itemids = itemrows.toArrayList("itemid");
+        ArrayList<String> alldates = yearToDate(yearMonthStr);
+        Rows datas = new Rows();
+        for (String itemid : itemids) {
+            Rows salesRows = salesRowsMap.getOrDefault(itemid, new Rows());
+            RowsMap dateDateRow = salesRows.toRowsMap("ym");
+            Rows targetRows = targetRowsMap.getOrDefault(itemid, new Rows());
+            for (String date : alldates) {
+                Rows dateDate = dateDateRow.getOrDefault(date, new Rows());
+                Row row = new Row();
+                row.put("itemid", itemid);
+                processDataRows(datas, row, dateDate, targetRows, date);
+            }
+        }
+
+        RowsMap dataRowsMap = datas.toRowsMap("itemid");
+
+        for (Row arearow : itemrows) {
+            Rows dataRows = dataRowsMap.getOrDefault(arearow.getString("itemid"), new Rows());
+            //计算范围
+            calculate("m", arearow, dataRows, getMonths(year, month_start, month_end));
+        }
+
+        return getSucReturnObject().setData(itemrows).toString();
+    }
+
 
     @API(title = "查询当前账号的营销区域", apiversion = R.ID2026010513574702.v1.class)
     public String queryCurrentUserarea() throws YosException {