|
@@ -1,6 +1,7 @@
|
|
|
package restcontroller.webmanage.sale.databoard;
|
|
|
|
|
|
import beans.itemclass.ItemClass;
|
|
|
+import beans.salearea.SaleArea;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import common.Controller;
|
|
@@ -13,6 +14,7 @@ import common.data.RowsMap;
|
|
|
import common.data.SQLFactory;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import restcontroller.R;
|
|
|
+import restcontroller.sale.promotion.promotion;
|
|
|
import restcontroller.webmanage.sale.salestarget.personnel;
|
|
|
|
|
|
import javax.annotation.processing.SupportedSourceVersion;
|
|
@@ -253,6 +255,10 @@ public class databoard extends Controller {
|
|
|
StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
StringBuffer whereLastYear = new StringBuffer(" 1=1 ");
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ //区域经理判断
|
|
|
+ where.append(getManangerSqlWhere("t1",hrid));
|
|
|
+ whereLastYear.append(getManangerSqlWhere("t1",hrid));
|
|
|
+
|
|
|
|
|
|
if (!begindate.equals("")) {
|
|
|
where.append(" and t1.checkdate >='").append(begindate).append(" 00:00:00'");
|
|
@@ -417,6 +423,10 @@ public class databoard extends Controller {
|
|
|
if (sys_enterpriseid > 0) {
|
|
|
where = where + " and t1.sys_enterpriseid=" + sys_enterpriseid;
|
|
|
}
|
|
|
+ if(hrid>0){
|
|
|
+ //区域经理判断
|
|
|
+ where = where + getManangerSqlWhere("t1",hrid);
|
|
|
+ }
|
|
|
/*
|
|
|
* 过滤条件设置
|
|
|
*/
|
|
@@ -510,7 +520,8 @@ public class databoard extends Controller {
|
|
|
if (!enddate.equals("")) {
|
|
|
where.append(" and DATE_FORMAT(t1.checkdate, '%Y-%m-%d') <='").append(enddate).append("' ");
|
|
|
}
|
|
|
-
|
|
|
+ //区域经理判断
|
|
|
+ where.append(getManangerSqlWhere("t1", hrid));
|
|
|
|
|
|
SQLFactory factory;
|
|
|
if (datatype.equals("销售额")) {
|
|
@@ -573,7 +584,9 @@ public class databoard extends Controller {
|
|
|
|
|
|
StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
StringBuffer whereLastYear = new StringBuffer(" 1=1 ");
|
|
|
-
|
|
|
+ //区域经理判断
|
|
|
+ where.append(getManangerSqlWhere("t1", hrid));
|
|
|
+ whereLastYear.append(getManangerSqlWhere("t1", hrid));
|
|
|
|
|
|
if (!begindate.equals("")) {
|
|
|
where.append(" and DATE_FORMAT(t1.checkdate, '%Y-%m-%d') >='").append(begindate).append("' ");
|
|
@@ -677,6 +690,10 @@ public class databoard extends Controller {
|
|
|
String enddate = "";
|
|
|
StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
SQLFactory factory;
|
|
|
+
|
|
|
+ //区域经理判断
|
|
|
+ where.append(getManangerSqlWhere("", hrid));
|
|
|
+
|
|
|
switch (datetype) {
|
|
|
case "月":
|
|
|
factory = new SQLFactory(this, "财务统计_月");
|
|
@@ -818,6 +835,9 @@ public class databoard extends Controller {
|
|
|
StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
StringBuffer whereLastYear = new StringBuffer(" 1=1 ");
|
|
|
|
|
|
+ //区域经理判断
|
|
|
+ where.append(getManangerSqlWhere("t1", hrid));
|
|
|
+ whereLastYear.append(getManangerSqlWhere("t1", hrid));
|
|
|
|
|
|
if (!begindate.equals("")) {
|
|
|
where.append(" and DATE_FORMAT(t1.checkdate, '%Y-%m-%d') >='").append(begindate).append("' ");
|
|
@@ -858,10 +878,15 @@ public class databoard extends Controller {
|
|
|
@API(title = "新品销售走势", apiversion = R.ID20230802103303.v1.class)
|
|
|
@CACHEING
|
|
|
public String newProductSalesTrend() throws Exception {
|
|
|
+ StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
+ //区域经理判断
|
|
|
+ where.append(getManangerSqlWhere("t1", hrid));
|
|
|
+
|
|
|
SQLFactory factory = new SQLFactory(this, "新品销售走势");
|
|
|
String year = new SimpleDateFormat("yyyy").format(new Date());
|
|
|
factory.addParameter("siteid", siteid);
|
|
|
- factory.addParameter_SQL("year", year);
|
|
|
+ factory.addParameter("year", year);
|
|
|
+ factory.addParameter_SQL("where", where);
|
|
|
Rows rows = dbConnect.runSqlQuery(factory.getSQL(false));
|
|
|
List<DataTrans> list = new ArrayList();
|
|
|
for (Row row : rows) {
|
|
@@ -922,6 +947,7 @@ public class databoard extends Controller {
|
|
|
}
|
|
|
|
|
|
StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
+ StringBuffer where2 = new StringBuffer(" 1=1 ");
|
|
|
if (!begindate.equals("")) {
|
|
|
where.append(" and DATE_FORMAT(t1.checkdate, '%Y-%m-%d') >='").append(begindate).append("' ");
|
|
|
}
|
|
@@ -933,14 +959,19 @@ public class databoard extends Controller {
|
|
|
SQLFactory factory;
|
|
|
if (datatype.equals("经销商")) {
|
|
|
factory = new SQLFactory(this, "战区数据_经销商");
|
|
|
+ //区域经理判断
|
|
|
+ where2.append(getManangerSqlWhere("t1", hrid));
|
|
|
} else if (datatype.equals("区域")) {
|
|
|
factory = new SQLFactory(this, "战区数据_区域");
|
|
|
+ //区域经理判断
|
|
|
+ where2.append(getManangerSqlWhere_area("t4", hrid));
|
|
|
} else {
|
|
|
return getErrReturnObject().setErrMsg("datatype类型错误").toString();
|
|
|
}
|
|
|
|
|
|
factory.addParameter("siteid", siteid);
|
|
|
factory.addParameter_SQL("where", where);
|
|
|
+ factory.addParameter_SQL("where2", where2);
|
|
|
Rows rows = dbConnect.runSqlQuery(factory.getSQL(false));
|
|
|
|
|
|
BigDecimal totalamount= rows.sum("totalamount");
|
|
@@ -968,7 +999,9 @@ public class databoard extends Controller {
|
|
|
StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
if (sys_enterpriseid > 0) {
|
|
|
where.append(" and t1.sys_enterpriseid=" + sys_enterpriseid);
|
|
|
-
|
|
|
+ }
|
|
|
+ if (hrid > 0) {
|
|
|
+ where.append(getManangerSqlWhere("t1", hrid));
|
|
|
}
|
|
|
if (content.containsKey("where")) {
|
|
|
JSONObject whereObject = content.getJSONObject("where");
|
|
@@ -1234,5 +1267,53 @@ public class databoard extends Controller {
|
|
|
return sdf.format(cal.getTime());
|
|
|
}
|
|
|
|
|
|
+ public String getManangerSqlWhere(String alias,long hrid) throws YosException {
|
|
|
+ String where =" and 1=1 ";
|
|
|
+ SQLFactory areasqlFactory = new SQLFactory(new promotion(content), "区域经理查询下属营销区域");
|
|
|
+ areasqlFactory.addParameter("siteid", siteid);
|
|
|
+ areasqlFactory.addParameter("hrid", hrid);
|
|
|
+ Rows arearows = dbConnect.runSqlQuery(areasqlFactory);
|
|
|
+
|
|
|
+
|
|
|
+ if(arearows.isNotEmpty()){
|
|
|
+ ArrayList<Long> arrayList =arearows.toArrayList("sa_saleareaid", new ArrayList<Long>());
|
|
|
+ arrayList.addAll(SaleArea.getSubSaleAreaIds(this, arrayList));
|
|
|
+ String sql ="";
|
|
|
+ if(alias.equals("")){
|
|
|
+ sql = " and sys_enterpriseid in (select sys_enterpriseid from sys_enterprise_tradefield where sa_saleareaid in "+arrayList+") ";
|
|
|
+ }else{
|
|
|
+ sql = " and "+alias+".sys_enterpriseid in (select sys_enterpriseid from sys_enterprise_tradefield where sa_saleareaid in "+arrayList+") ";
|
|
|
+ }
|
|
|
+
|
|
|
+ sql = sql.replace("[", "(").replace("]", ")");
|
|
|
+ where=where+sql;
|
|
|
+ }
|
|
|
+ return where;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getManangerSqlWhere_area(String alias,long hrid) throws YosException {
|
|
|
+ String where =" and 1=1 ";
|
|
|
+ SQLFactory areasqlFactory = new SQLFactory(new promotion(content), "区域经理查询下属营销区域");
|
|
|
+ areasqlFactory.addParameter("siteid", siteid);
|
|
|
+ areasqlFactory.addParameter("hrid", hrid);
|
|
|
+ Rows arearows = dbConnect.runSqlQuery(areasqlFactory);
|
|
|
+
|
|
|
+
|
|
|
+ if(arearows.isNotEmpty()){
|
|
|
+ ArrayList<Long> arrayList =arearows.toArrayList("sa_saleareaid", new ArrayList<Long>());
|
|
|
+ arrayList.addAll(SaleArea.getSubSaleAreaIds(this, arrayList));
|
|
|
+ String sql ="";
|
|
|
+ if(alias.equals("")){
|
|
|
+ sql = " and sa_saleareaid in "+arrayList;
|
|
|
+ }else{
|
|
|
+ sql = " and "+alias+".sa_saleareaid in "+arrayList;
|
|
|
+ }
|
|
|
+
|
|
|
+ sql = sql.replace("[", "(").replace("]", ")");
|
|
|
+ where=where+sql;
|
|
|
+ }
|
|
|
+ return where;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|