wu 2 kuukautta sitten
vanhempi
commit
474ef32924

+ 24 - 0
src/custom/beans/CommonHepler.java

@@ -1,10 +1,15 @@
 package beans;
 
+import common.BaseClass;
 import common.Controller;
 import common.YosException;
+import common.data.QuerySQL;
+import common.data.Rows;
 import common.data.RowsMap;
+import common.data.SQLFactory;
 
 import java.util.ArrayList;
+import java.util.List;
 
 public class CommonHepler {
     public static RowsMap getAreaRowsMap(Controller controller, ArrayList<Long> sa_agentsids) throws YosException {
@@ -31,4 +36,23 @@ public class CommonHepler {
 
         return controller.dbConnect.runSqlQuery(sql).toRowsMap("sa_agentsid");
     }
+
+    public static RowsMap getDoctorRowsMap(Controller controller, List<Long> sa_hospitaldepids) throws YosException {
+        QuerySQL querySQL = SQLFactory.createQuerySQL(controller, "sa_doctor", "*").setTableAlias("t1");
+        querySQL.setSiteid(controller.siteid);
+        querySQL.setWhere("t1.isleader=1");
+        querySQL.setWhere("t1.sa_hospitaldepid ", sa_hospitaldepids);
+        Rows rows = querySQL.query();
+        return rows.toRowsMap("sa_hospitaldepid");
+    }
+
+    public static RowsMap getAgentRowsMap(Controller controller,List<Long> sa_customersids) throws YosException {
+        QuerySQL querySQL = SQLFactory.createQuerySQL(controller, "sa_agents_hospital", "*").setTableAlias("t1");
+        querySQL.addJoinTable(BaseClass.JOINTYPE.left, "sa_agents", "t2", "t2.sa_agentsid = t1.sa_agentsid AND t2.siteid = t1.siteid");
+        querySQL.addJoinTable(BaseClass.JOINTYPE.left, "sys_enterprise", "t3", "t3.sys_enterpriseid = t2.sys_enterpriseid AND t3.siteid = t2.siteid", "enterprisename");
+        querySQL.setSiteid(controller.siteid);
+        querySQL.setWhere("t1.sa_customersid ", sa_customersids);
+        Rows rows = querySQL.query();
+        return rows.toRowsMap("sa_customersid");
+    }
 }

+ 4 - 12
src/custom/restcontroller/prsx/doctor/doctor.java

@@ -1,5 +1,6 @@
 package restcontroller.prsx.doctor;
 
+import beans.CommonHepler;
 import beans.datacontrllog.DataContrlLog;
 import beans.datatag.DataTag;
 import beans.datateam.DataTeam;
@@ -34,7 +35,7 @@ public class doctor extends Controller {
         ArrayList<String> sqlList = new ArrayList<>();
         Long sa_doctorid = content.getLongValue("sa_doctorid");
         Long sa_hospitaldepid = content.getLongValue("sa_hospitaldepid");
-        Rows rows = dbConnect.runSqlQuery("SELECT * from sa_hospitaldep WHERE sa_hospitaldepid="+sa_hospitaldepid+" and siteid='" + siteid + "'");
+        Rows rows = dbConnect.runSqlQuery("SELECT * from sa_hospitaldep WHERE sa_hospitaldepid=" + sa_hospitaldepid + " and siteid='" + siteid + "'");
         Long sa_customersid = rows.isNotEmpty() ? rows.get(0).getLong("sa_customersid") : 0;
 
         if (sa_doctorid <= 0) {
@@ -244,7 +245,7 @@ public class doctor extends Controller {
         //系统标签
         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 = getDoctorRowsMap(ids);
+        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")));
@@ -259,7 +260,7 @@ public class doctor extends Controller {
             row.put("tag_sys", sys_tag);
             //科室负责人
             Rows doctorRows = doctorRowsMap.getOrDefault(id.toString(), new Rows());
-            row.putIfAbsent("doctors", StringUtils.join(doctorRows.toArray("doctorname"),","));
+            row.putIfAbsent("doctors", StringUtils.join(doctorRows.toArray("doctorname"), ","));
             String stagename = row.getString("stagename");
             for (Row stageRow : stageRows) {
                 if (stagename.equals(stageRow.getString("stagename"))) {
@@ -273,14 +274,5 @@ public class doctor extends Controller {
         return getSucReturnObject().setData(rows).toString();
     }
 
-    public RowsMap getDoctorRowsMap(List<Long> sa_hospitaldepids) throws YosException {
-        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_doctor", "*").setTableAlias("t1");
-        querySQL.setSiteid(siteid);
-        querySQL.setWhere("t1.isleader=1");
-        querySQL.setWhere("t1.sa_hospitaldepid ", sa_hospitaldepids);
-        Rows rows = querySQL.query();
-        return rows.toRowsMap("sa_hospitaldepid");
-    }
-
 
 }

+ 3 - 11
src/custom/restcontroller/prsx/hospitaldep/hospitaldep.java

@@ -1,5 +1,6 @@
 package restcontroller.prsx.hospitaldep;
 
+import beans.CommonHepler;
 import beans.datacontrllog.DataContrlLog;
 import beans.datatag.DataTag;
 import beans.datateam.DataTeam;
@@ -91,7 +92,7 @@ public class hospitaldep extends Controller {
         HashMap<Long, ArrayList<String>> tagList = DataTag.queryTag(this, "sa_hospitaldep", ids, false);
         //系统标签
         HashMap<Long, ArrayList<String>> sysTagList = DataTag.queryTag(this, "sa_hospitaldep", ids, true);
-        RowsMap doctorRowsMap = getDoctorRowsMap(ids);
+        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")));
@@ -193,7 +194,7 @@ public class hospitaldep extends Controller {
         //系统标签
         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 = getDoctorRowsMap(ids);
+        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")));
@@ -300,15 +301,6 @@ public class hospitaldep extends Controller {
         return getSucReturnObject().setData(rows).toString();
     }
 
-    public RowsMap getDoctorRowsMap(List<Long> sa_hospitaldepids) throws YosException {
-        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_doctor", "*").setTableAlias("t1");
-        querySQL.setSiteid(siteid);
-        querySQL.setWhere("t1.isleader=1");
-        querySQL.setWhere("t1.sa_hospitaldepid ", sa_hospitaldepids);
-        Rows rows = querySQL.query();
-        return rows.toRowsMap("sa_hospitaldepid");
-    }
-
     @API(title = "关联查询医生", apiversion = R.ID2025102214574202.v1.class)
     public String doctorlist() throws YosException {
         StringBuffer where = new StringBuffer(" 1=1 ");

+ 2 - 19
src/custom/restcontroller/sale/customer/Hospital.java

@@ -421,7 +421,7 @@ public class Hospital extends Controller {
         //系统标签
         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 = getAgentRowsMap(ids);
+        RowsMap AgentRowsMap = CommonHepler.getAgentRowsMap(this, ids);
         for (Row row : rows) {
             Long id = row.getLong("sa_customersid");
             row.put("leader", leaderRows.get(String.valueOf(id)));
@@ -472,15 +472,6 @@ public class Hospital extends Controller {
         return getSucReturnObject().setData(rows).toString();
     }
 
-    public RowsMap getAgentRowsMap(List<Long> sa_customersids) throws YosException {
-        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_agents_hospital", "*").setTableAlias("t1");
-        querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t2", "t2.sa_agentsid = t1.sa_agentsid 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("t1.sa_customersid ", sa_customersids);
-        Rows rows = querySQL.query();
-        return rows.toRowsMap("sa_customersid");
-    }
 
     @API(title = "关联医生查询", apiversion = R.ID2025102310134602.v1.class)
     public String queryDoctors() throws YosException {
@@ -565,7 +556,7 @@ public class Hospital extends Controller {
         //系统标签
         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 = getDoctorRowsMap(ids);
+        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")));
@@ -594,14 +585,6 @@ public class Hospital extends Controller {
         return getSucReturnObject().setData(rows).toString();
     }
 
-    public RowsMap getDoctorRowsMap(List<Long> sa_hospitaldepids) throws YosException {
-        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_doctor", "*").setTableAlias("t1");
-        querySQL.setSiteid(siteid);
-        querySQL.setWhere("t1.isleader=1");
-        querySQL.setWhere("t1.sa_hospitaldepid ", sa_hospitaldepids);
-        Rows rows = querySQL.query();
-        return rows.toRowsMap("sa_hospitaldepid");
-    }
 
     @API(title = "关联查询合同", apiversion = R.ID2025102710422402.v1.class)
     public String queryContract() throws YosException {

+ 3 - 13
src/custom/restcontroller/webmanage/sale/contract/Contract2.java

@@ -357,7 +357,7 @@ public class Contract2 extends Controller {
         //系统标签
         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 = getAgentRowsMap(ids);
+        RowsMap AgentRowsMap = CommonHepler.getAgentRowsMap(this, ids);
         for (Row row : rows) {
             Long id = row.getLong("sa_customersid");
             row.put("leader", leaderRows.get(String.valueOf(id)));
@@ -395,16 +395,6 @@ public class Contract2 extends Controller {
         return getSucReturnObject().setData(rows).toString();
     }
 
-    public RowsMap getAgentRowsMap(List<Long> sa_customersids) throws YosException {
-        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_agents_hospital", "*").setTableAlias("t1");
-        querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t2", "t2.sa_agentsid = t1.sa_agentsid 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("t1.sa_customersid ", sa_customersids);
-        Rows rows = querySQL.query();
-        return rows.toRowsMap("sa_customersid");
-    }
-
     @API(title = "选择经销商", apiversion = R.ID2025102416055302.v1.class)
     public String chooseAgentsList() throws YosException {
          /*
@@ -446,8 +436,8 @@ public class Contract2 extends Controller {
         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<>()));
+        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());

+ 9 - 19
src/custom/restcontroller/webmanage/sale/order/Order2.java

@@ -523,7 +523,7 @@ public class Order2 extends Controller {
         //系统标签
         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 = getAgentRowsMap(ids);
+        RowsMap AgentRowsMap = CommonHepler.getAgentRowsMap(this, ids);
         for (Row row : rows) {
             Long id = row.getLong("sa_customersid");
             row.put("leader", leaderRows.get(String.valueOf(id)));
@@ -557,16 +557,6 @@ public class Order2 extends Controller {
         return getSucReturnObject().setData(rows).toString();
     }
 
-    public RowsMap getAgentRowsMap(List<Long> sa_customersids) throws YosException {
-        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_agents_hospital", "*").setTableAlias("t1");
-        querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t2", "t2.sa_agentsid = t1.sa_agentsid 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("t1.sa_customersid ", sa_customersids);
-        Rows rows = querySQL.query();
-        return rows.toRowsMap("sa_customersid");
-    }
-
 
     @API(title = "经销商列表", apiversion = R.ID2025102814092602.v1.class)
     public String agentsList() throws YosException {
@@ -588,12 +578,12 @@ public class Order2 extends Controller {
         where.append(" and t1.status !='作废' ");
 
         Long sa_customersid = content.getLong("sa_customersid");
-        if(sa_customersid==0){
+        if (sa_customersid == 0) {
             //当前账号授权的,以及代理账号授权的经销商。
-            ArrayList<Long> hrids=Proxy.getProxyHrids(this);
+            ArrayList<Long> hrids = Proxy.getProxyHrids(this);
             hrids.add(hrid);
-            String sql=" and (t1.sa_agentsid IN (SELECT sa_agentsid FROM sys_enterprise_tradefield WHERE hrid IN "+hrids+"))";
-            sql=sql.replace("]",")").replace("[","(");
+            String sql = " and (t1.sa_agentsid IN (SELECT sa_agentsid FROM sys_enterprise_tradefield WHERE hrid IN " + hrids + "))";
+            sql = sql.replace("]", ")").replace("[", "(");
             where.append(sql);
 
         }
@@ -604,7 +594,7 @@ public class Order2 extends Controller {
         querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t2", "t1.siteid = t2.siteid and t1.sys_enterpriseid = t2.sys_enterpriseid",
                 "enterprisename", "province", "city", "county", "address");
 
-        if(sa_customersid>0) {
+        if (sa_customersid > 0) {
             querySQL.addJoinTable(JOINTYPE.inner, "sa_agents_hospital", "t9", "t9.sa_agentsid=t1.sa_agentsid and t9.siteid=t1.siteid", "sa_agents_hospitalid");
             querySQL.setWhere("t9.sa_customersid", sa_customersid);
         }
@@ -614,7 +604,7 @@ public class Order2 extends Controller {
         querySQL.setOrderBy("t1.createdate desc");
         Rows rows = querySQL.query();
 
-        RowsMap areaRowsMap = CommonHepler.getAreaRowsMap(this,rows.toArrayList("sa_agentsid", new ArrayList<>()));
+        RowsMap areaRowsMap = CommonHepler.getAreaRowsMap(this, rows.toArrayList("sa_agentsid", new ArrayList<>()));
         for (Row row : rows) {
             Rows areaRows = areaRowsMap.getOrDefault(row.getString("sa_agentsid"), new Rows());
             row.put("areanames", StringUtils.join(areaRows.toArrayList("areaname"), ","));
@@ -651,10 +641,10 @@ public class Order2 extends Controller {
         querySQL.addJoinTable(JOINTYPE.left, "sys_hr", "t6", "t6.hrid=t1.saler_hrid and t6.siteid=t1.siteid");
         querySQL.setSiteid(siteid);
         querySQL.setWhere(where);
-        if(sa_customersid>0) {
+        if (sa_customersid > 0) {
             querySQL.setWhere("t2.sa_customersid", sa_customersid);
             querySQL.setWhere("t1.type='医院协议'");
-        }else {
+        } else {
             querySQL.setWhere("t4.sa_agentsid", sa_agentsid);
             querySQL.setWhere("t1.type='经销商协议'");
         }