|
@@ -1,5 +1,6 @@
|
|
|
package restcontroller.webmanage.sale.salearea;
|
|
package restcontroller.webmanage.sale.salearea;
|
|
|
|
|
|
|
|
|
|
+import beans.CommonHepler;
|
|
|
import beans.data.BatchDeleteErr;
|
|
import beans.data.BatchDeleteErr;
|
|
|
import beans.datacontrllog.DataContrlLog;
|
|
import beans.datacontrllog.DataContrlLog;
|
|
|
import beans.dataextend.DataExtend;
|
|
import beans.dataextend.DataExtend;
|
|
@@ -15,6 +16,7 @@ import common.annotation.CACHEING;
|
|
|
import common.annotation.CACHEING_CLEAN;
|
|
import common.annotation.CACHEING_CLEAN;
|
|
|
import common.annotation.cm;
|
|
import common.annotation.cm;
|
|
|
import common.data.*;
|
|
import common.data.*;
|
|
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
import restcontroller.R;
|
|
import restcontroller.R;
|
|
|
import restcontroller.webmanage.hr.hr;
|
|
import restcontroller.webmanage.hr.hr;
|
|
|
import restcontroller.webmanage.sale.enterprisesaleclass.EnterpriseSaleClass;
|
|
import restcontroller.webmanage.sale.enterprisesaleclass.EnterpriseSaleClass;
|
|
@@ -31,6 +33,105 @@ public class salearea extends Controller {
|
|
|
super(content);
|
|
super(content);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @API(title = "营销区域查询经销商", apiversion = R.ID20221011144903.v1.class)
|
|
|
|
|
+ public String query_agent() throws YosException, IOException {
|
|
|
|
|
+ /*
|
|
|
|
|
+ 过滤条件设置
|
|
|
|
|
+ */
|
|
|
|
|
+ StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
|
|
+ if (content.containsKey("where")) {
|
|
|
|
|
+ JSONObject whereObject = content.getJSONObject("where");
|
|
|
|
|
+ if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
|
|
|
|
|
+ where.append(" and(");
|
|
|
|
|
+ where.append("t1.agentnum like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
|
|
+ where.append("or t2.enterprisename like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
|
|
+ where.append("or t2.province like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
|
|
+ where.append("or t2.city like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
|
|
+ where.append("or t2.county like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
|
|
+ where.append("or t2.address like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
|
|
+ where.append("or t3.erpagentnum like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
|
|
+ where.append(")");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (whereObject.containsKey("startdate") && !"".equals(whereObject.getString("startdate"))) {
|
|
|
|
|
+ where.append(" and(");
|
|
|
|
|
+ where.append("t1.createdate >='").append(whereObject.getString("startdate")).append(" 00:00:00' ");
|
|
|
|
|
+ where.append(")");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
|
|
|
|
|
+ where.append(" and(");
|
|
|
|
|
+ where.append("t1.createdate <='").append(whereObject.getString("enddate")).append(" 23:59:59' ");
|
|
|
|
|
+ where.append(")");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
|
|
|
|
|
+ where.append(" and ");
|
|
|
|
|
+ where.append("t1.status = '").append(whereObject.getString("status")).append("' ");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (whereObject.containsKey("cooperatetype") && !"".equals(whereObject.getString("cooperatetype"))) {
|
|
|
|
|
+ where.append(" and ");
|
|
|
|
|
+ where.append("t1.cooperatetype = '").append(whereObject.getString("cooperatetype")).append("' ");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ boolean isdeleted = content.getBooleanValue("isdeleted");
|
|
|
|
|
+ if (isdeleted) {
|
|
|
|
|
+ where.append(" and t1.status ='作废' ");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ where.append(" and t1.status !='作废' ");
|
|
|
|
|
+ }
|
|
|
|
|
+ JSONArray sa_saleareaidsArray = content.getJSONArray("sa_saleareaids");
|
|
|
|
|
+ ArrayList<Long> sa_saleareaidsList = new ArrayList<>();
|
|
|
|
|
+ for (Object o : sa_saleareaidsArray) {
|
|
|
|
|
+ String sa_saleareaid = o.toString();
|
|
|
|
|
+ sa_saleareaidsList.add(Long.parseLong(sa_saleareaid));
|
|
|
|
|
+ sa_saleareaidsList.addAll(SaleArea.getSubSaleAreaIds(this, Long.parseLong(sa_saleareaid)));
|
|
|
|
|
+ }
|
|
|
|
|
+ boolean isExport = content.getBooleanValue("isExport");
|
|
|
|
|
+ if (sa_saleareaidsArray.size() > 0) {
|
|
|
|
|
+ if (userInfo.isSaler()) {
|
|
|
|
|
+ ArrayList<Long> saleAreaids = SaleArea.getSubSaleAreaIds(this, userInfo.getHrSaleAreaIds(hrid));
|
|
|
|
|
+ saleAreaids.addAll(userInfo.getHrSaleAreaIds(hrid));
|
|
|
|
|
+ saleAreaids.add(-1L);
|
|
|
|
|
+ if (sa_saleareaidsList.size() > 0) {
|
|
|
|
|
+ String sqlStr = " and t1.sys_enterpriseid in (SELECT DISTINCT sys_enterpriseid from sys_enterprise_tradefield WHERE sa_saleareaid in " + saleAreaids + " )";
|
|
|
|
|
+ sqlStr = sqlStr.replace("[", "(").replace("]", ")");
|
|
|
|
|
+ where.append(sqlStr);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (sa_saleareaidsList.size() > 0) {
|
|
|
|
|
+ String sqlStr = " and t1.sys_enterpriseid in (SELECT DISTINCT sys_enterpriseid from sys_enterprise_tradefield WHERE sa_saleareaid in " + sa_saleareaidsList + " )";
|
|
|
|
|
+ sqlStr = sqlStr.replace("[", "(").replace("]", ")");
|
|
|
|
|
+ where.append(sqlStr);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_agents",
|
|
|
|
|
+ "sa_agentsid", "sys_enterpriseid", "gmname", "gmphonenumber", "agentnum", "cooperatetype", "remarks", "status", "createdate").
|
|
|
|
|
+ setTableAlias("t1");
|
|
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t2", "t1.siteid = t2.siteid and t1.sys_enterpriseid = t2.sys_enterpriseid",
|
|
|
|
|
+ "enterprisename", "province", "city", "county", "address");
|
|
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sys_dataextend", "t3", "t1.sys_enterpriseid = t3.ownerid and ownertable = 'sys_enterprise' and t1.siteid = t3.siteid",
|
|
|
|
|
+ "erpagentnum");
|
|
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
|
|
+ querySQL.setWhere(where);
|
|
|
|
|
+
|
|
|
|
|
+ if (!isExport) {
|
|
|
|
|
+ querySQL.setPage(pageSize, pageNumber);
|
|
|
|
|
+ }
|
|
|
|
|
+ querySQL.setOrderBy("t1.createdate desc");
|
|
|
|
|
+ Rows rows = querySQL.query();
|
|
|
|
|
+
|
|
|
|
|
+ RowsMap areaRowsMap = CommonHepler.getAreaRowsMap(this, rows.toArrayList("sa_agentsid", new ArrayList<>()));
|
|
|
|
|
+ RowsMap salerRowsMap = CommonHepler.getSalerNameRowsMap(this, rows.toArrayList("sa_agentsid", new ArrayList<>()));
|
|
|
|
|
+ for (Row row : rows) {
|
|
|
|
|
+ row.put("p_c_c", row.getString("province") + "-" + row.getString("city") + "-" + row.getString("county"));
|
|
|
|
|
+ Rows areaRows = areaRowsMap.getOrDefault(row.getString("sa_agentsid"), new Rows());
|
|
|
|
|
+ row.put("areanames", StringUtils.join(areaRows.toArrayList("areaname"), ","));
|
|
|
|
|
+ Rows salerRows = salerRowsMap.getOrDefault(row.getString("sa_agentsid"), new Rows());
|
|
|
|
|
+ row.put("salernames", StringUtils.join(salerRows.toArrayList("name"), ","));
|
|
|
|
|
+ row.putIfAbsent("scale", "");
|
|
|
|
|
+ row.putIfAbsent("mainproducts", "");
|
|
|
|
|
+ }
|
|
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
@API(title = "营销区域列表查询")
|
|
@API(title = "营销区域列表查询")
|
|
|
@CACHEING
|
|
@CACHEING
|