|
|
@@ -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();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 战区数据分析
|