|
|
@@ -1,10 +1,12 @@
|
|
|
package restcontroller.webmanage.sale.agents;
|
|
|
|
|
|
import beans.CommonHepler;
|
|
|
+import beans.datacontrllog.DataContrlLog;
|
|
|
import beans.datatag.DataTag;
|
|
|
import beans.datateam.DataTeam;
|
|
|
import beans.recycle.Recycle;
|
|
|
import beans.salearea.SaleArea;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import common.Controller;
|
|
|
import common.YosException;
|
|
|
@@ -53,15 +55,16 @@ public class agents2 extends Controller {
|
|
|
querySQL.addJoinTable(JOINTYPE.left, "sys_datateam", "t6", "t6.ownerid = t1.sa_customersid and t6.siteid = t1.siteid and t6.ownertable = 'sa_customers' and t6.isleader = 1");
|
|
|
querySQL.addJoinTable(JOINTYPE.left, "sys_hr", "t7", "t7.userid = t6.userid and t7.siteid = t6.siteid ");
|
|
|
querySQL.addJoinTable(JOINTYPE.left, "sys_department", "t8", "t8.departmentid = t7.departmentid and t8.siteid = t7.siteid ");
|
|
|
- querySQL.addJoinTable(JOINTYPE.inner, "sa_agents_hospital", "t9", "t9.sa_customersid=t1.sa_customersid and t9.siteid=t1.siteid");
|
|
|
+
|
|
|
querySQL.setSiteid(siteid);
|
|
|
- querySQL.setWhere("t9.sa_agentsid", sa_agentsid);
|
|
|
+ querySQL.setWhere("t1.sa_customersid in (SELECT sa_customersid from sa_agents_hospital WHERE sa_agentsid=" + sa_agentsid + " and siteid='" + siteid + "')");
|
|
|
querySQL.setWhere("t1.datastatus in (0,2) ");
|
|
|
querySQL.setPage(pageSize, pageNumber);
|
|
|
querySQL.setOrderBy(pageSorting);
|
|
|
|
|
|
querySQL.setRoleDataLimit(false);
|
|
|
querySQL.withDeleteData(true);
|
|
|
+ querySQL.setCondition("t1.billno", "t2.enterprisename");
|
|
|
Rows rows = querySQL.query();
|
|
|
RowsMap leaderRows = DataTeam.getLeaderWithoutHeadpic(this, "sa_customers", rows.toArrayList("sa_customersid")).toRowsMap("ownerid");
|
|
|
ArrayList<Long> ids = rows.toArrayList("sa_customersid", new ArrayList<>());
|
|
|
@@ -80,10 +83,6 @@ public class agents2 extends Controller {
|
|
|
}
|
|
|
ArrayList<String> tag = tagList.get(id) != null ? tagList.get(id) : new ArrayList<String>();
|
|
|
ArrayList<String> sys_tag = sysTagList.get(id) != null ? sysTagList.get(id) : new ArrayList<String>();
|
|
|
- if (row.getString("agentsstatus").equals("禁用") || row.getString("agentsstatus").equals("作废")) {
|
|
|
- tag.removeAll(row.getJSONArray("agentstag").toJavaList(String.class));
|
|
|
- sys_tag.removeAll(row.getJSONArray("agentstag").toJavaList(String.class));
|
|
|
- }
|
|
|
//非系统标签
|
|
|
row.put("tag", tag);
|
|
|
//系统标签
|
|
|
@@ -92,7 +91,69 @@ public class agents2 extends Controller {
|
|
|
row.putIfAbsent("totalop", 0);
|
|
|
//关键人
|
|
|
Rows KeyDoctors = KeyDoctorsRowsMap.getOrDefault(String.valueOf(id), new Rows());
|
|
|
- row.putIfAbsent("keyperson", StringUtils.join(KeyDoctors.toArray("doctorname"),","));
|
|
|
+ row.putIfAbsent("keyperson", StringUtils.join(KeyDoctors.toArray("doctorname"), ","));
|
|
|
+ String stagename = row.getString("stagename");
|
|
|
+ for (Row stageRow : stageRows) {
|
|
|
+ if (stagename.equals(stageRow.getString("stagename"))) {
|
|
|
+ stageRow.put("active", 1);
|
|
|
+ }
|
|
|
+ stageRow.putIfAbsent("active", 0);
|
|
|
+ }
|
|
|
+ row.put("stages", stageRows);
|
|
|
+ }
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "关联查询科室", apiversion = R.ID2025111909582402.v1.class)
|
|
|
+ public String queryhospitaldepList() throws YosException {
|
|
|
+
|
|
|
+ Long sa_agentsid = content.getLongValue("sa_agentsid");
|
|
|
+
|
|
|
+
|
|
|
+ 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.hospitaldepname like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.remarks like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_hospitaldep", "*").setTableAlias("t1");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_customers", "t2", "t2.sa_customersid=t1.sa_customersid and t2.siteid=t1.siteid");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t3", "t3.sys_enterpriseid=t2.sys_enterpriseid and t3.siteid=t2.siteid", "enterprisename");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere(where);
|
|
|
+ querySQL.setWhere("t1.sa_hospitaldepid in (SELECT sa_hospitaldepid from sa_agents_hospital WHERE sa_agentsid=" + sa_agentsid + " and siteid='" + siteid + "')");
|
|
|
+ querySQL.setPage(pageSize, pageNumber).setOrderBy(pageSorting);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+
|
|
|
+ ArrayList<Long> ids = rows.toArrayList("sa_hospitaldepid", new ArrayList<>());
|
|
|
+ RowsMap leaderRows = DataTeam.getLeader(this, "sa_hospitaldep", rows.toArrayList("sa_hospitaldepid")).toRowsMap("ownerid");
|
|
|
+ //标签
|
|
|
+ HashMap<Long, ArrayList<String>> tagList = DataTag.queryTag(this, "sa_hospitaldep", ids, false);
|
|
|
+ //系统标签
|
|
|
+ HashMap<Long, ArrayList<String>> sysTagList = DataTag.queryTag(this, "sa_hospitaldep", ids, true);
|
|
|
+ Rows stageRows = dbConnect.runSqlQuery("SELECT stagename,sequence from sa_devstage WHERE siteid='" + siteid + "' order by sequence");
|
|
|
+ RowsMap doctorRowsMap = CommonHepler.getDoctorRowsMap(this, ids);
|
|
|
+ for (Row row : rows) {
|
|
|
+ Long id = row.getLong("sa_hospitaldepid");
|
|
|
+ row.put("leader", leaderRows.get(row.getString("sa_hospitaldepid")));
|
|
|
+ if (leaderRows.get(String.valueOf(id)).isNotEmpty()) {
|
|
|
+ row.put("depname", leaderRows.get(String.valueOf(id)).get(0).getString("depname"));
|
|
|
+ }
|
|
|
+ ArrayList<String> tag = tagList.get(id) != null ? tagList.get(id) : new ArrayList<>();
|
|
|
+ ArrayList<String> sys_tag = sysTagList.get(id) != null ? sysTagList.get(id) : new ArrayList<>();
|
|
|
+ //非系统标签
|
|
|
+ row.put("tag", tag);
|
|
|
+ //系统标签
|
|
|
+ row.put("tag_sys", sys_tag);
|
|
|
+ //科室负责人
|
|
|
+ Rows doctorRows = doctorRowsMap.getOrDefault(id.toString(), new Rows());
|
|
|
+ row.putIfAbsent("doctors", StringUtils.join(doctorRows.toArray("doctorname"), ","));
|
|
|
String stagename = row.getString("stagename");
|
|
|
for (Row stageRow : stageRows) {
|
|
|
if (stagename.equals(stageRow.getString("stagename"))) {
|
|
|
@@ -102,9 +163,11 @@ public class agents2 extends Controller {
|
|
|
}
|
|
|
row.put("stages", stageRows);
|
|
|
}
|
|
|
+
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@API(title = "关联查询合同", apiversion = R.ID2025102710011202.v1.class)
|
|
|
public String queryContractList() throws YosException {
|
|
|
|
|
|
@@ -135,7 +198,7 @@ public class agents2 extends Controller {
|
|
|
querySQL.addJoinTable(JOINTYPE.left, "sys_dataextend", "t7", "t1.siteid = t7.siteid and t1.sa_contractid = t7.ownerid and t7.ownertable = 'sa_contract'", "deletereason");
|
|
|
querySQL.setSiteid(siteid);
|
|
|
querySQL.setWhere(where);
|
|
|
- querySQL.setWhere("t4.sa_agentsid",sa_agentsid);
|
|
|
+ querySQL.setWhere("t4.sa_agentsid", sa_agentsid);
|
|
|
querySQL.addQueryFields("hospitalname", "t3.enterprisename");
|
|
|
querySQL.addQueryFields("agentname", "t5.enterprisename");
|
|
|
querySQL.addQueryFields("salername", "t6.name");
|
|
|
@@ -172,5 +235,105 @@ public class agents2 extends Controller {
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
|
|
|
|
+ @API(title = "添加科室", apiversion = R.ID2025111914313002.v1.class)
|
|
|
+ public String addhospitaldep() throws YosException {
|
|
|
+
|
|
|
+
|
|
|
+ Long sa_agentsid = content.getLongValue("sa_agentsid");
|
|
|
+ JSONArray sa_hospitaldepids = content.getJSONArray("sa_hospitaldepids");
|
|
|
+
|
|
|
+
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (Object object : sa_hospitaldepids) {
|
|
|
+ Long sa_hospitaldepid = Long.valueOf(object.toString());
|
|
|
+ Rows rows = dbConnect.runSqlQuery("SELECT * from sa_hospitaldep WHERE sa_hospitaldepid=" + sa_hospitaldepid);
|
|
|
+ Long sa_customersid = 0L;
|
|
|
+ if (rows.isNotEmpty()) {
|
|
|
+ sa_customersid = rows.get(0).getLong("sa_customersid");
|
|
|
+ }
|
|
|
+
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_agents_hospital");
|
|
|
+ insertSQL.setUniqueid(createTableID("sa_agents_hospital"));
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setValue("sa_agentsid", sa_agentsid);
|
|
|
+ insertSQL.setValue("sa_hospitaldepid", sa_hospitaldepid);
|
|
|
+ insertSQL.setValue("sa_customersid", sa_customersid);
|
|
|
+ insertSQL.setWhere(" not exists(select 1 from sa_agents_hospital where sa_agentsid=" + sa_agentsid + " and siteid='" + siteid + "' and sa_hospitaldepid='" + sa_hospitaldepid + "')");
|
|
|
+ sqlList.add(insertSQL.getSQL());
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sa_hospitaldep", sa_hospitaldepid, "关联经销商", "关联经销商ID:" + sa_agentsid).getSQL());
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sa_agents", sa_agentsid, "签约科室", "签约科室ID:" + sa_hospitaldepid).getSQL());
|
|
|
+ DataTag.createSystemTag(this, "sa_customers", sa_customersid, "经销");
|
|
|
+ }
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "选择科室", apiversion = R.ID2025111914425902.v1.class)
|
|
|
+ public String chooseHospitalDep() 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.hospitaldepname like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.remarks like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Long sa_agentsid = content.getLongValue("sa_agentsid");
|
|
|
+ where.append(" and t1.sa_hospitaldepid in (SELECT ownerid from sys_enterprise_tradefield t1 " +
|
|
|
+ "INNER JOIN sys_hr t2 ON t2.hrid=t1.hrid and t2.siteid=t1.siteid " +
|
|
|
+ "INNER JOIN sys_datateam t3 ON t3.userid=t2.userid and t3.ownertable='sa_hospitaldep' and t3.isleader=1 and t3.siteid=t2.siteid " +
|
|
|
+ "WHERE sa_agentsid="+sa_agentsid+")");
|
|
|
+ where.append(" and t1.sa_hospitaldepid not in (SELECT sa_hospitaldepid from sa_agents_hospital " +
|
|
|
+ "WHERE sa_agentsid="+sa_agentsid+")");
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_hospitaldep", "*").setTableAlias("t1");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_customers", "t2", "t2.sa_customersid=t1.sa_customersid and t2.siteid=t1.siteid");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t3", "t3.sys_enterpriseid=t2.sys_enterpriseid and t3.siteid=t2.siteid", "enterprisename");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere(where);
|
|
|
+ querySQL.setPage(pageSize, pageNumber).setOrderBy(pageSorting);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+
|
|
|
+ ArrayList<Long> ids = rows.toArrayList("sa_hospitaldepid", new ArrayList<>());
|
|
|
+ RowsMap leaderRows = DataTeam.getLeader(this, "sa_hospitaldep", rows.toArrayList("sa_hospitaldepid")).toRowsMap("ownerid");
|
|
|
+ //标签
|
|
|
+ HashMap<Long, ArrayList<String>> tagList = DataTag.queryTag(this, "sa_hospitaldep", ids, false);
|
|
|
+ //系统标签
|
|
|
+ HashMap<Long, ArrayList<String>> sysTagList = DataTag.queryTag(this, "sa_hospitaldep", ids, true);
|
|
|
+ Rows stageRows = dbConnect.runSqlQuery("SELECT stagename,sequence from sa_devstage WHERE siteid='" + siteid + "' order by sequence");
|
|
|
+ RowsMap doctorRowsMap = CommonHepler.getDoctorRowsMap(this, ids);
|
|
|
+ for (Row row : rows) {
|
|
|
+ Long id = row.getLong("sa_hospitaldepid");
|
|
|
+ row.put("leader", leaderRows.get(row.getString("sa_hospitaldepid")));
|
|
|
+ if (leaderRows.get(String.valueOf(id)).isNotEmpty()) {
|
|
|
+ row.put("depname", leaderRows.get(String.valueOf(id)).get(0).getString("depname"));
|
|
|
+ }
|
|
|
+ ArrayList<String> tag = tagList.get(id) != null ? tagList.get(id) : new ArrayList<>();
|
|
|
+ ArrayList<String> sys_tag = sysTagList.get(id) != null ? sysTagList.get(id) : new ArrayList<>();
|
|
|
+ //非系统标签
|
|
|
+ row.put("tag", tag);
|
|
|
+ //系统标签
|
|
|
+ row.put("tag_sys", sys_tag);
|
|
|
+ //科室负责人
|
|
|
+ Rows doctorRows = doctorRowsMap.getOrDefault(id.toString(), new Rows());
|
|
|
+ row.putIfAbsent("doctors", StringUtils.join(doctorRows.toArray("doctorname"), ","));
|
|
|
+ String stagename = row.getString("stagename");
|
|
|
+ for (Row stageRow : stageRows) {
|
|
|
+ if (stagename.equals(stageRow.getString("stagename"))) {
|
|
|
+ stageRow.put("active", 1);
|
|
|
+ }
|
|
|
+ stageRow.putIfAbsent("active", 0);
|
|
|
+ }
|
|
|
+ row.put("stages", stageRows);
|
|
|
+ }
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|