Ver Fonte

预估手术量

wu há 5 meses atrás
pai
commit
2fd04db5ce

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

@@ -67,4 +67,11 @@ public class CommonHepler {
         Rows rows = querySQL.query();
         return rows.toRowsMap("sa_customersid");
     }
+
+    //获取医院最新年度手术预估手术量
+    public static RowsMap getHospitalOPRowsMap(Controller controller) throws YosException {
+        return controller.dbConnect.runSqlQuery("SELECT t1.sa_customersid,sum(qty) qty,max(year) year from sa_surgeryforecast t1 " +
+                "INNER JOIN sa_surgeryforecast_items t2 ON t2.sa_surgeryforecastid=t1.sa_surgeryforecastid and t1.siteid=t2.siteid " +
+                "GROUP BY t1.sa_customersid").toRowsMap("sa_customersid");
+    }
 }

+ 10 - 0
src/custom/restcontroller/R.java

@@ -7522,6 +7522,16 @@ public class R {
         public static class v1 {
         }
     }
+
+    public static class ID2025111516284402 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025111516294302 {
+        public static class v1 {
+        }
+    }
 }
 
 

+ 9 - 1
src/custom/restcontroller/prsx/surgeryforecast.java

@@ -28,9 +28,12 @@ public class surgeryforecast extends Controller {
         querySQL.setPage(pageSize, pageNumber).setOrderBy("t1.createdate desc");
         Rows rows = querySQL.query();
 
-        RowsMap rowsMap = dbConnect.runSqlQuery("SELECT sa_surgeryforecastid,sum(qty) sumqty ,GROUP_CONCAT(DISTINCT type ) types from sa_surgeryforecast_items \n" +
+        RowsMap rowsMap = dbConnect.runSqlQuery("SELECT sa_surgeryforecastid,sum(qty) sumqty ,GROUP_CONCAT(DISTINCT CONCAT(type,qty) ) types from sa_surgeryforecast_items \n" +
                 "WHERE siteid='" + siteid + "'" +
                 "GROUP BY sa_surgeryforecastid").toRowsMap("sa_surgeryforecastid");
+        RowsMap dateRowsMap = dbConnect.runSqlQuery("SELECT sa_surgeryforecastid,max(changedate) changedate,max(changeby) changeby from sa_surgeryforecast_items t1\n" +
+                "WHERE sa_customersid =" + sa_customersid + " " +
+                "GROUP BY sa_surgeryforecastid").toRowsMap("sa_surgeryforecastid");
         for (Row row : rows) {
             Rows rows1 = rowsMap.getOrDefault(row.getString("sa_surgeryforecastid"), new Rows());
             if (rows1.isNotEmpty()) {
@@ -39,6 +42,11 @@ public class surgeryforecast extends Controller {
             }
             row.putIfAbsent("sumqty", 0);
             row.putIfAbsent("types", "");
+            Rows rows2 = dateRowsMap.getOrDefault(row.getString("sa_surgeryforecastid"), new Rows());
+            if (rows2.isNotEmpty()) {
+                row.put("changedate", rows2.getRow(0).getString("changedate"));
+                row.put("changeby", rows2.getRow(0).getString("changeby"));
+            }
 
         }
 

+ 12 - 6
src/custom/restcontroller/sale/customer/Hospital.java

@@ -22,6 +22,7 @@ import org.apache.commons.lang.StringUtils;
 import org.apache.poi.xssf.usermodel.XSSFCellStyle;
 import org.apache.poi.xssf.usermodel.XSSFSheet;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.sqlite.core.DB;
 import restcontroller.R;
 import restcontroller.webmanage.executorService.Executor;
 
@@ -241,6 +242,7 @@ public class Hospital extends Controller {
         HashMap<Long, ArrayList<String>> tagList = DataTag.queryTag(this, "sa_customers", ids, false);
         //系统标签
         HashMap<Long, ArrayList<String>> sysTagList = DataTag.queryTag(this, "sa_customers", ids, true);
+        RowsMap opRowsMap = CommonHepler.getHospitalOPRowsMap(this);
         for (Row row : rows) {
             Long id = row.getLong("sa_customersid");
             row.put("leader", leaderRows.get(row.getString("sa_customersid")));
@@ -258,7 +260,9 @@ public class Hospital extends Controller {
             //系统标签
             row.put("tag_sys", sys_tag);
             //预估手术总量
-            row.putIfAbsent("totalop", 0);
+            //预估手术总量
+            Rows totalop = opRowsMap.getOrDefault(String.valueOf(id), new Rows());
+            row.putIfAbsent("totalop", totalop.isNotEmpty() ? totalop.get(0).getInteger("qty") : 0);
         }
 
         Row row = rows.isNotEmpty() ? rows.get(0) : new Row();
@@ -335,7 +339,7 @@ public class Hospital extends Controller {
             //标签
             if (whereObject.containsKey("tag") && !whereObject.getJSONArray("tag").isEmpty()) {
                 JSONArray tags = whereObject.getJSONArray("tag");
-                String tag=tags.toString().replace("[","(").replace("]",")");
+                String tag = tags.toString().replace("[", "(").replace("]", ")");
                 if (tags.size() > 0) {
                     where.append(" and exists(select 1 from sys_datatag WHERE ownertable = 'sa_customers' and siteid='").append(siteid).append("' ");
                     where.append(" and tag in ").append(tag).append(" and t1.sa_customersid=ownerid ");
@@ -427,6 +431,7 @@ public class Hospital extends Controller {
         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)));
@@ -442,7 +447,8 @@ public class Hospital extends Controller {
             row.put("tag_sys", sys_tag);
             row.putIfAbsent("followdate", "");
             //预估手术总量
-            row.putIfAbsent("totalop", 0);
+            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"), ","));
@@ -735,7 +741,7 @@ public class Hospital extends Controller {
         Long sa_customersid = content.getLong("sa_customersid");
 
         QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_agents",
-                        "sa_agentsid", "sys_enterpriseid", "gmname", "gmphonenumber", "agentnum", "cooperatetype", "remarks", "status", "createdate","scale","mainproducts").
+                        "sa_agentsid", "sys_enterpriseid", "gmname", "gmphonenumber", "agentnum", "cooperatetype", "remarks", "status", "createdate", "scale", "mainproducts").
                 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");
@@ -744,7 +750,7 @@ public class Hospital extends Controller {
         querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t4", "t4.siteid = t1.siteid and t4.sa_agentsid = t1.parentid");
         querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t5", "t5.siteid = t4.siteid and t5.sys_enterpriseid = t4.sys_enterpriseid");
         querySQL.addJoinTable(JOINTYPE.inner, "sa_agents_hospital", "t9", "t9.sa_agentsid=t1.sa_agentsid and t9.siteid=t1.siteid", "sa_agents_hospitalid");
-        querySQL.addQueryFields("parent_enterprisename","t5.enterprisename");
+        querySQL.addQueryFields("parent_enterprisename", "t5.enterprisename");
         querySQL.setWhere("t9.sa_customersid", sa_customersid);
         querySQL.setSiteid(siteid);
         querySQL.setWhere(where);
@@ -835,7 +841,7 @@ public class Hospital extends Controller {
         hrids.add(hrid);
 
         QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_agents",
-                        "sa_agentsid", "sys_enterpriseid", "gmname", "gmphonenumber", "agentnum", "cooperatetype", "remarks", "status", "createdate","scale","mainproducts").
+                        "sa_agentsid", "sys_enterpriseid", "gmname", "gmphonenumber", "agentnum", "cooperatetype", "remarks", "status", "createdate", "scale", "mainproducts").
                 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");