|
|
@@ -971,6 +971,107 @@ public class salestargetstatistics extends Controller {
|
|
|
return getSucReturnObject().setData(arearows).toString();
|
|
|
}
|
|
|
|
|
|
+ @API(title = "小程序人员/医院/经销商产品类别", apiversion = R.ID2026010714131502.v1.class)
|
|
|
+ public String mATargetCategory() 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 itemclassrows = dbConnect.runSqlQuery("SELECT DISTINCT itemclassname from plm_itemclass WHERE siteid='" + siteid + "' ");
|
|
|
+
|
|
|
+
|
|
|
+ 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("itemclassname");
|
|
|
+
|
|
|
+ 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);
|
|
|
+ RowsMap targetRowsMap = targetrows.toRowsMap("itemclassname");
|
|
|
+
|
|
|
+ ArrayList<String> itemclassnames = itemclassrows.toArrayList("itemclassname");
|
|
|
+ ArrayList<String> alldates = yearToDate(yearMonthStr);
|
|
|
+ Rows datas = new Rows();
|
|
|
+ for (String itemclassname : itemclassnames) {
|
|
|
+ Rows salesRows = salesRowsMap.getOrDefault(itemclassname, new Rows());
|
|
|
+ RowsMap dateDateRow = salesRows.toRowsMap("ym");
|
|
|
+ Rows targetRows = targetRowsMap.getOrDefault(itemclassname, new Rows());
|
|
|
+ for (String date : alldates) {
|
|
|
+ Rows dateDate = dateDateRow.getOrDefault(date, new Rows());
|
|
|
+ Row row = new Row();
|
|
|
+ row.put("itemclassname", itemclassname);
|
|
|
+ processDataRows(datas, row, dateDate, targetRows, date);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ RowsMap dataRowsMap = datas.toRowsMap("itemclassname");
|
|
|
+
|
|
|
+ for (Row arearow : itemclassrows) {
|
|
|
+ Rows dataRows = dataRowsMap.getOrDefault(arearow.getString("itemclassname"), new Rows());
|
|
|
+ //计算范围
|
|
|
+ calculate("m", arearow, dataRows, getMonths(year, month_start, month_end));
|
|
|
+ }
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(itemclassrows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@API(title = "查询当前账号的营销区域", apiversion = R.ID2026010513574702.v1.class)
|
|
|
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 + "'");
|