|
|
@@ -10,10 +10,7 @@ import common.annotation.API;
|
|
|
import common.annotation.CACHEING;
|
|
|
import common.annotation.CACHEING_CLEAN;
|
|
|
import common.annotation.cm;
|
|
|
-import common.data.Row;
|
|
|
-import common.data.Rows;
|
|
|
-import common.data.RowsMap;
|
|
|
-import common.data.SQLFactory;
|
|
|
+import common.data.*;
|
|
|
import restcontroller.R;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
@@ -354,25 +351,45 @@ public class salearea extends Controller {
|
|
|
}
|
|
|
boolean isExport = content.getBooleanValue("isExport");
|
|
|
Boolean isAll = content.getBooleanValue("isAll");
|
|
|
- if (sa_saleareaidsList.isEmpty()) isAll = true;
|
|
|
- if (isAll) {
|
|
|
- sa_saleareaidsList = dbConnect.runSqlQuery("SELECT sa_saleareaid from sa_salearea WHERE siteid = '" + siteid + "' AND isused").toArrayList("sa_saleareaid", new ArrayList<>());
|
|
|
- } else {
|
|
|
- String sqlStr = "and t5.sa_saleareaid in " + sa_saleareaidsList;
|
|
|
+ if (sa_saleareaidsList.isEmpty()) {
|
|
|
+ isAll = true;
|
|
|
+ }
|
|
|
+ if (!isAll) {
|
|
|
+ String sqlStr = "and t1.sys_enterpriseid in (SELECT sys_enterpriseid from sys_enterprise_tradefield WHERE sa_saleareaid in " + sa_saleareaidsList + ")";
|
|
|
sqlStr = sqlStr.replace("[", "(").replace("]", ")");
|
|
|
where.append(sqlStr);
|
|
|
}
|
|
|
|
|
|
|
|
|
- SQLFactory sqlFactory = new SQLFactory(this, "营销区域经销商查询", pageSize, pageNumber, pageSorting);
|
|
|
- if (isExport) {
|
|
|
- sqlFactory = new SQLFactory(this, "营销区域经销商查询");
|
|
|
- }
|
|
|
- sqlFactory.addParameter_in("sa_saleareaid", sa_saleareaidsList);
|
|
|
+// SQLFactory sqlFactory = new SQLFactory(this, "营销区域经销商查询", pageSize, pageNumber, pageSorting);
|
|
|
+// if (isExport) {
|
|
|
+// sqlFactory = new SQLFactory(this, "营销区域经销商查询");
|
|
|
+// }
|
|
|
+// sqlFactory.addParameter("siteid", siteid);
|
|
|
+// sqlFactory.addParameter_SQL("where", where);
|
|
|
+// String sql = sqlFactory.getSQL();
|
|
|
+// Rows rows = dbConnect.runSqlQuery(sql);
|
|
|
+ QuerySQL querySQL = getAgentList(where.toString());
|
|
|
+ querySQL.setOrderBy(pageSorting);
|
|
|
+ querySQL.setPage(pageSize, pageNumber);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+ ArrayList<Long> ids = rows.toArrayList("sys_enterpriseid", new ArrayList<>());
|
|
|
+
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "查询经销商主账号信息");
|
|
|
sqlFactory.addParameter("siteid", siteid);
|
|
|
- sqlFactory.addParameter_SQL("where", where);
|
|
|
- String sql = sqlFactory.getSQL();
|
|
|
- Rows rows = dbConnect.runSqlQuery(sql);
|
|
|
+ sqlFactory.addParameter_in("sys_enterpriseid", ids);
|
|
|
+ RowsMap rowsMap = dbConnect.runSqlQuery(sqlFactory).toRowsMap("sys_enterpriseid");
|
|
|
+ for (Row row : rows) {
|
|
|
+ Rows tempRows = rowsMap.getOrDefault(row.getString("sys_enterpriseid"), new Rows());
|
|
|
+ if (tempRows.isNotEmpty()) {
|
|
|
+ row.put("userid", tempRows.get(0).getLong("userid"));
|
|
|
+ row.put("accountno", tempRows.get(0).getLong("accountno"));
|
|
|
+ } else {
|
|
|
+ row.put("userid", 0);
|
|
|
+ row.put("accountno", "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
if (isExport) {
|
|
|
//去除不需要导出项
|
|
|
@@ -389,6 +406,19 @@ public class salearea extends Controller {
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public QuerySQL getAgentList(String where) throws YosException {
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_agents");
|
|
|
+ querySQL.setTableAlias("t1");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.inner, "sys_enterprise", "t2", "t1.siteid = t2.siteid and t1.sys_enterpriseid = t2.sys_enterpriseid",
|
|
|
+ "enterprisename", "phonenumber", "contact", "province", "city", "county", "address", "limitreturnday", "freefreightamount", "invoicingpoint");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sys_dataextend", "t4", "t1.sys_enterpriseid = t4.ownerid and ownertable = 'sys_enterprise' and t1.siteid = t4.siteid",
|
|
|
+ "erpagentnum");
|
|
|
+ querySQL.setWhere("t1.siteid", siteid);
|
|
|
+ querySQL.setWhere(where);
|
|
|
+ return querySQL;
|
|
|
+ }
|
|
|
+
|
|
|
//返回导出的标题
|
|
|
public HashMap<String, String> getTitleMap() {
|
|
|
//
|