|
|
@@ -121,7 +121,7 @@ public class salestargetstatistics extends Controller {
|
|
|
|
|
|
Rows arearows = dbConnect.runSqlQuery(" SELECT t1.*,t3.`name`,t3.userid FROM view_areas t1 "
|
|
|
+ " INNER JOIN sa_salearea_hr t2 ON t2.sa_saleareaid=t1.sa_saleareaid "
|
|
|
- + " INNER JOIN sys_hr t3 ON t3.hrid=t2.hrid " + " WHERE t1.siteid='" + siteid + "' AND (t1.parentid="+sa_saleareaid+" or t1.sa_saleareaid ="+sa_saleareaid+") ORDER BY t1.parentid,t1.sa_saleareaid");
|
|
|
+ + " INNER JOIN sys_hr t3 ON t3.hrid=t2.hrid " + " WHERE t1.siteid='" + siteid + "' AND (t1.parentid=" + sa_saleareaid + " or t1.sa_saleareaid =" + sa_saleareaid + ") ORDER BY t1.parentid,t1.sa_saleareaid");
|
|
|
|
|
|
|
|
|
SQLFactory sqlFactory = new SQLFactory(this, "按人员分组统计订单");
|
|
|
@@ -177,7 +177,7 @@ public class salestargetstatistics extends Controller {
|
|
|
+ " INNER JOIN sa_customers t2 ON t2.sa_saleareaid=t1.sa_saleareaid "
|
|
|
+ " INNER JOIN sys_enterprise t3 ON t3.sys_enterpriseid=t2.sys_enterpriseid "
|
|
|
+ " LEFT JOIN sys_datateam t4 ON t4.ownertable='sa_customers' and t4.ownerid=t2.sa_customersid and t4.isleader=1 "
|
|
|
- + " WHERE t1.siteid='" + siteid + "' AND (t1.parentid="+sa_saleareaid+" or t1.sa_saleareaid ="+sa_saleareaid+") ORDER BY t1.parentid,t1.sa_saleareaid ");
|
|
|
+ + " WHERE t1.siteid='" + siteid + "' AND (t1.parentid=" + sa_saleareaid + " or t1.sa_saleareaid =" + sa_saleareaid + ") ORDER BY t1.parentid,t1.sa_saleareaid ");
|
|
|
|
|
|
|
|
|
SQLFactory sqlFactory = new SQLFactory(this, "按医院分组统计订单");
|
|
|
@@ -234,7 +234,7 @@ public class salestargetstatistics extends Controller {
|
|
|
+ " INNER JOIN sys_enterprise t3 ON t3.sys_enterpriseid=t2.sys_enterpriseid "
|
|
|
+ " INNER JOIN sa_agents t4 ON t4.sa_agentsid=t2.sa_agentsid "
|
|
|
+ " LEFT JOIN sys_hr t5 ON t5.hrid=t2.hrid "
|
|
|
- + " WHERE t1.siteid='" + siteid + "' AND (t1.parentid="+sa_saleareaid+" or t1.sa_saleareaid ="+sa_saleareaid+") and t4.status='启用'"
|
|
|
+ + " WHERE t1.siteid='" + siteid + "' AND (t1.parentid=" + sa_saleareaid + " or t1.sa_saleareaid =" + sa_saleareaid + ") and t4.status='启用'"
|
|
|
+ " GROUP BY t1.sa_saleareaid,t1.parentid,t1.parentareaname,t1.areaname,t1.siteid,t3.enterprisename,t2.sa_agentsid "
|
|
|
+ " ORDER BY t1.parentid,t1.sa_saleareaid ");
|
|
|
|
|
|
@@ -1488,7 +1488,7 @@ public class salestargetstatistics extends Controller {
|
|
|
sqlFactory = new SQLFactory(this, "首页医院金额");
|
|
|
sqlFactory.addParameter("siteid", siteid);
|
|
|
sqlFactory.addParameter("start", startMonth + "-01");
|
|
|
- sqlFactory.addParameter("end", getNextMonth(endMonth) + "-01");
|
|
|
+ sqlFactory.addParameter("end", getNextMonth(endMonth) + "-01");
|
|
|
sqlFactory.addParameter("userid", userid);
|
|
|
BigDecimal saleamount = dbConnect.runSqlQuery(sqlFactory).get(0).getBigDecimal("saleamount");
|
|
|
|
|
|
@@ -1574,5 +1574,186 @@ public class salestargetstatistics extends Controller {
|
|
|
return getSucReturnObject().setData(detailrow).toString();
|
|
|
}
|
|
|
|
|
|
+ @API(title = "业务员负责的医院", apiversion = R.ID2026012013441802.v1.class)
|
|
|
+ public String salerHospitals() throws YosException {
|
|
|
+
|
|
|
+ String tablename = "sa_customers";
|
|
|
+ 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.billno like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.province like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.city like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.county like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.address like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t2.enterprisename like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t2.abbreviation like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t6.name like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t8.depname like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ where.append(" and ( t1.datastatus in (0,2) )");
|
|
|
+
|
|
|
+
|
|
|
+ Long userid = content.getLongValue("userid");
|
|
|
+
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_customers", "sa_customersid", "createby", "createdate",
|
|
|
+ "sys_enterpriseid", "status", "type", "tradingstatus", "datastatus", "billno", "province", "city", "county", "address", "stagename", "grade", "sa_saleareaid");
|
|
|
+ querySQL.setTableAlias("t1");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t2", "t2.sys_enterpriseid = t1.sys_enterpriseid AND t2.siteid = t1.siteid", "enterprisename");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_salearea", "t3", "t3.sa_saleareaid = t1.sa_saleareaid AND t3.siteid = t1.siteid", "areaname");
|
|
|
+
|
|
|
+ QuerySQL t5 = SQLFactory.createQuerySQL(this, "sys_datafollowup", "ownerid");
|
|
|
+ t5.setWhere("ownertable", "sa_customers");
|
|
|
+ t5.setSiteid(siteid);
|
|
|
+ t5.addGroupBy("ownerid");
|
|
|
+ t5.addQueryFields("followdate", "max(createdate)");
|
|
|
+ t5.setRoleDataLimit(false);
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, t5, "t5", "t5.ownerid = t1.sa_customersid", "followdate");
|
|
|
+ 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.left, "sys_dataextend", "t10", "t1.siteid = t10.siteid and t1.sa_customersid = t10.ownerid and t10.ownertable = 'sa_customers'", "deletereason");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere(where);
|
|
|
+ querySQL.setWhere("t6.userid", userid);
|
|
|
+
|
|
|
+ querySQL.setPage(pageSize, pageNumber);
|
|
|
+
|
|
|
+ if (pageSorting.equals("''")) {
|
|
|
+ pageSorting = "t1.createdate desc";
|
|
|
+ }
|
|
|
+ querySQL.setOrderBy(pageSorting);
|
|
|
+
|
|
|
+ querySQL.setRoleDataLimit(false);
|
|
|
+ querySQL.withDeleteData(true);
|
|
|
+ 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<>());
|
|
|
+ //标签
|
|
|
+ HashMap<Long, ArrayList<String>> tagList = DataTag.queryTag(this, tablename, ids, false);
|
|
|
+ //系统标签
|
|
|
+ HashMap<Long, ArrayList<String>> sysTagList = DataTag.queryTag(this, tablename, ids, true);
|
|
|
+ Rows stageRows = dbConnect.runSqlQuery("SELECT stagename,sequence from sa_devstage WHERE siteid='" + siteid + "' order by sequence");
|
|
|
+ RowsMap AgentRowsMap = CommonHepler.getAgentRowsMap(this, ids);
|
|
|
+ RowsMap KeyDoctorsRowsMap = CommonHepler.getKeyDoctorsRowsMap(this, ids);
|
|
|
+ RowsMap opRowsMap = CommonHepler.getHospitalOPRowsMap(this);
|
|
|
+ for (Row row : rows) {
|
|
|
+ Long id = row.getLong("sa_customersid");
|
|
|
+ row.put("leader", leaderRows.get(String.valueOf(id)));
|
|
|
+ if (leaderRows.get(String.valueOf(id)).isNotEmpty()) {
|
|
|
+ row.put("name", leaderRows.get(String.valueOf(id)).get(0).getString("name"));
|
|
|
+ row.put("depname", leaderRows.get(String.valueOf(id)).get(0).getString("depname"));
|
|
|
+ }
|
|
|
+ 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>();
|
|
|
+ //非系统标签
|
|
|
+ row.put("tag", tag);
|
|
|
+ //系统标签
|
|
|
+ row.put("tag_sys", sys_tag);
|
|
|
+ ArrayList<String> tags = new ArrayList<>();
|
|
|
+ tags.addAll(tag);
|
|
|
+ tags.addAll(sys_tag);
|
|
|
+ row.put("tagstr", StringUtils.join(tags, ","));
|
|
|
+ row.putIfAbsent("followdate", "");
|
|
|
+ //预估手术总量
|
|
|
+ Rows totalop = opRowsMap.getOrDefault(String.valueOf(id), new Rows());
|
|
|
+ row.putIfAbsent("totalop", totalop.isNotEmpty() ? totalop.get(0).getInteger("qty") : 0);
|
|
|
+ //关键人
|
|
|
+ Rows KeyDoctors = KeyDoctorsRowsMap.getOrDefault(String.valueOf(id), new Rows());
|
|
|
+ row.putIfAbsent("keyperson", StringUtils.join(KeyDoctors.toArray("doctorname"), ","));
|
|
|
+ //签约经销商
|
|
|
+ Rows signagent = AgentRowsMap.getOrDefault(String.valueOf(id), new Rows());
|
|
|
+ row.putIfAbsent("signagent", StringUtils.join(signagent.toArray("enterprisename"), ","));
|
|
|
+ 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.ID2026012013445102.v1.class)
|
|
|
+ public String salerHospitaldeps() throws YosException {
|
|
|
+ String tablename = "sa_hospitaldep";
|
|
|
+ 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("or t3.enterprisename like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t5.name like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t6.doctors like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ Long userid = content.getLongValue("userid");
|
|
|
+
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "查询科室负责人");
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
+
|
|
|
+ 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.addJoinTable(JOINTYPE.left, "sys_datateam", "t5", "t5.ownerid = t1.sa_hospitaldepid and t5.siteid = t1.siteid and t5.ownertable = 'sa_hospitaldep' and t5.isleader = 1");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, sqlFactory, "t6", "t6.sa_hospitaldepid = t1.sa_hospitaldepid", "doctors");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sys_datateam", "t7", "t7.ownertable = 'sa_hospitaldep' and t7.siteid = t1.siteid and t7.ownerid = t1.sa_hospitaldepid and t7.isleader = 1");
|
|
|
+ querySQL.addQueryFields("leadername", "t7.name");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere(where);
|
|
|
+ querySQL.setWhere("t7.userid", userid);
|
|
|
+ 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");
|
|
|
+ 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);
|
|
|
+ ArrayList<String> tags = new ArrayList<>();
|
|
|
+ tags.addAll(tag);
|
|
|
+ tags.addAll(sys_tag);
|
|
|
+ row.put("tagstr", StringUtils.join(tags, ","));
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|