|
|
@@ -845,5 +845,57 @@ public class Hospital extends Controller {
|
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
|
|
|
|
+ @API(title = "选择经销商列表", apiversion = R.ID2025102714042402.v1.class)
|
|
|
+ public String chooseAgents() throws YosException {
|
|
|
+ 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(")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ where.append(" and t1.status !='作废' ");
|
|
|
+
|
|
|
+ ArrayList<Long> hrids = Proxy.getProxyHrids(this);
|
|
|
+ hrids.add(hrid);
|
|
|
+
|
|
|
+ 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.addJoinTable(JOINTYPE.inner, "sys_enterprise_tradefield", "t4", "t4.sa_agentsid=t1.sa_agentsid and t4.siteid=t1.siteid");
|
|
|
+ querySQL.setWhere("t4.hrid", hrids);
|
|
|
+
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere(where);
|
|
|
+ querySQL.setPage(pageSize, pageNumber);
|
|
|
+ querySQL.setOrderBy("t1.createdate desc");
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+
|
|
|
+ RowsMap areaRowsMap = getAreaRowsMap(rows.toArrayList("sa_agentsid", new ArrayList<>()));
|
|
|
+ RowsMap salerRowsMap = getSalerNameRowsMap(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();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|