|
@@ -24,9 +24,8 @@ import java.math.BigDecimal;
|
|
|
import java.time.YearMonth;
|
|
import java.time.YearMonth;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.time.temporal.IsoFields;
|
|
import java.time.temporal.IsoFields;
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.HashMap;
|
|
|
|
|
-import java.util.HashSet;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
public class salestargetstatistics extends Controller {
|
|
public class salestargetstatistics extends Controller {
|
|
|
/**
|
|
/**
|
|
@@ -787,6 +786,17 @@ public class salestargetstatistics extends Controller {
|
|
|
return ym.minusYears(1).format(DateTimeFormatter.ofPattern("yyyy-MM"));
|
|
return ym.minusYears(1).format(DateTimeFormatter.ofPattern("yyyy-MM"));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public static ArrayList<String> getMonths(int year, int month_start, int month_end) {
|
|
|
|
|
+ YearMonth ymstart = YearMonth.of(year, month_start);
|
|
|
|
|
+ YearMonth ymend = YearMonth.of(year, month_end);
|
|
|
|
|
+ ArrayList<String> months = new ArrayList<>();
|
|
|
|
|
+ for (YearMonth ym = ymstart; !ym.isAfter(ymend); ym = ym.plusMonths(1)) {
|
|
|
|
|
+ months.add(ym.toString()); // 本期
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return months;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@API(title = "小程序人员目标概况", apiversion = R.ID2026010509531602.v1.class)
|
|
@API(title = "小程序人员目标概况", apiversion = R.ID2026010509531602.v1.class)
|
|
|
public String mAPeopleInfo() throws YosException {
|
|
public String mAPeopleInfo() throws YosException {
|
|
|
int year = content.getIntValue("year");
|
|
int year = content.getIntValue("year");
|
|
@@ -864,6 +874,103 @@ public class salestargetstatistics extends Controller {
|
|
|
return getSucReturnObject().setData(arearows).toString();
|
|
return getSucReturnObject().setData(arearows).toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @API(title = "小程序人员/医院/经销商目标", apiversion = R.ID2026010610085402.v1.class)
|
|
|
|
|
+ public String mATarget() throws YosException {
|
|
|
|
|
+ int type = content.getIntValue("type", 1);
|
|
|
|
|
+ int year = content.getIntValue("year");
|
|
|
|
|
+ int befyear = year - 1;
|
|
|
|
|
+ int month_start = content.getIntValue("month_start");
|
|
|
|
|
+ int month_end = content.getIntValue("month_end");
|
|
|
|
|
+ String yearMonthStr = year + "-12";
|
|
|
|
|
+ Long sa_saleareaid = content.getLongValue("sa_saleareaid");
|
|
|
|
|
+ Long userid = content.getLongValue("userid");
|
|
|
|
|
+ Long sa_customersid = content.getLongValue("sa_customersid");
|
|
|
|
|
+ Long sa_agentsid = content.getLongValue("sa_agentsid");
|
|
|
|
|
+
|
|
|
|
|
+ ArrayList<Long> sa_saleareaids = new ArrayList<>();
|
|
|
|
|
+ if (sa_saleareaid == 0) {
|
|
|
|
|
+ Rows rows = dbConnect.runSqlQuery("SELECT sa_saleareaid from sa_salearea_hr WHERE siteid='" + siteid + "' and hrid=" + hrid);
|
|
|
|
|
+ sa_saleareaids = rows.toArrayList("sa_saleareaid", new ArrayList<>());
|
|
|
|
|
+ if (sa_saleareaids.size() == 0) {
|
|
|
|
|
+ rows = dbConnect.runSqlQuery("SELECT sa_saleareaid from sa_salearea WHERE siteid='" + siteid + "' and level=1");
|
|
|
|
|
+ sa_saleareaids = rows.toArrayList("sa_saleareaid", new ArrayList<>());
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ sa_saleareaids.add(sa_saleareaid);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ArrayList<Long> subSaleAreaIds = SaleArea.getSubSaleAreaIds(this, sa_saleareaids);
|
|
|
|
|
+ subSaleAreaIds.add(sa_saleareaid);
|
|
|
|
|
+ StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
|
|
+ String sql = " and t4.sa_saleareaid in " + subSaleAreaIds + " ";
|
|
|
|
|
+ sql = sql.replace("[", "(").replace("]", ")");
|
|
|
|
|
+ where.append(sql);
|
|
|
|
|
+
|
|
|
|
|
+ Rows arearows = new Rows();
|
|
|
|
|
+ Row temprow = new Row();
|
|
|
|
|
+ temprow.put("year", year);
|
|
|
|
|
+ temprow.put("month_start", month_start);
|
|
|
|
|
+ temprow.put("month_end", month_end);
|
|
|
|
|
+ arearows.add(temprow);
|
|
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "小程序人员订单");
|
|
|
|
|
+ if (type == 1) {
|
|
|
|
|
+ sqlFactory = new SQLFactory(this, "小程序人员订单");
|
|
|
|
|
+ sqlFactory.addParameter_SQL("where", where);
|
|
|
|
|
+ sqlFactory.addParameter("userid", userid);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (type == 2) {
|
|
|
|
|
+ sqlFactory = new SQLFactory(this, "小程序医院订单");
|
|
|
|
|
+ sqlFactory.addParameter("sa_customersid", sa_customersid);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (type == 3) {
|
|
|
|
|
+ sqlFactory = new SQLFactory(this, "小程序经销商订单");
|
|
|
|
|
+ sqlFactory.addParameter("sa_agentsid", sa_agentsid);
|
|
|
|
|
+ }
|
|
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
|
|
+ sqlFactory.addParameter("year", year);
|
|
|
|
|
+ sqlFactory.addParameter("befyear", befyear);
|
|
|
|
|
+ Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
|
|
+ RowsMap salesRowsMap = rows.toRowsMap("ym");
|
|
|
|
|
+
|
|
|
|
|
+ sqlFactory = new SQLFactory(this, "小程序人员目标");
|
|
|
|
|
+ if (type == 1) {
|
|
|
|
|
+ sqlFactory = new SQLFactory(this, "小程序人员目标");
|
|
|
|
|
+ sqlFactory.addParameter_SQL("where", where);
|
|
|
|
|
+ sqlFactory.addParameter("userid", userid);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (type == 2) {
|
|
|
|
|
+ sqlFactory = new SQLFactory(this, "小程序医院目标");
|
|
|
|
|
+ sqlFactory.addParameter("sa_customersid", sa_customersid);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (type == 3) {
|
|
|
|
|
+ sqlFactory = new SQLFactory(this, "小程序经销商目标");
|
|
|
|
|
+ sqlFactory.addParameter("sa_agentsid", sa_agentsid);
|
|
|
|
|
+ }
|
|
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
|
|
+ sqlFactory.addParameter("year", year);
|
|
|
|
|
+ Rows targetrows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
|
|
+
|
|
|
|
|
+ ArrayList<String> alldates = yearToDate(yearMonthStr);
|
|
|
|
|
+ Rows datas = new Rows();
|
|
|
|
|
+
|
|
|
|
|
+ for (String date : alldates) {
|
|
|
|
|
+ Rows dateDate = salesRowsMap.getOrDefault(date, new Rows());
|
|
|
|
|
+ Row row = new Row();
|
|
|
|
|
+ row.put("date", date);
|
|
|
|
|
+ processDataRows(datas, row, dateDate, targetrows, date);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ RowsMap dataRowsMap = datas.toRowsMap("tempMonth");
|
|
|
|
|
+
|
|
|
|
|
+ for (Row arearow : arearows) {
|
|
|
|
|
+ Rows dataRows = dataRowsMap.getOrDefault(arearow.getString("tempMonth"), new Rows());
|
|
|
|
|
+ //计算范围
|
|
|
|
|
+ calculate("m", arearow, dataRows, getMonths(year, month_start, month_end));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return getSucReturnObject().setData(arearows).toString();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@API(title = "查询当前账号的营销区域", apiversion = R.ID2026010513574702.v1.class)
|
|
@API(title = "查询当前账号的营销区域", apiversion = R.ID2026010513574702.v1.class)
|
|
|
public String queryCurrentUserarea() throws YosException {
|
|
public String queryCurrentUserarea() throws YosException {
|
|
|
Rows rows = dbConnect.runSqlQuery("SELECT t1.*FROM sa_salearea t1 INNER JOIN sa_salearea_hr t2 ON t2.sa_saleareaid=t1.sa_saleareaid WHERE t2.hrid=" + hrid + " and t1.siteid='" + siteid + "'");
|
|
Rows rows = dbConnect.runSqlQuery("SELECT t1.*FROM sa_salearea t1 INNER JOIN sa_salearea_hr t2 ON t2.sa_saleareaid=t1.sa_saleareaid WHERE t2.hrid=" + hrid + " and t1.siteid='" + siteid + "'");
|