From 7fd2bc4fbead5a6596f43349138db654a9d5cd75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=B5=B7?= <10402852@qq.com> Date: Mon, 9 Jan 2023 11:30:14 +0800 Subject: [PATCH] 'commit' --- .../Organization/Controller/OrganizationController.java | 4 ++++ .../FengHuang/Organization/Model/OrganizationModel.java | 3 ++- FengHuang/src/main/resource/Sql/organization.sql | 7 ++++--- FengHuang/target/classes/Sql/organization.sql | 7 ++++--- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/FengHuang/src/main/java/com/dsideal/FengHuang/Organization/Controller/OrganizationController.java b/FengHuang/src/main/java/com/dsideal/FengHuang/Organization/Controller/OrganizationController.java index 5ff239c..08a7f1e 100644 --- a/FengHuang/src/main/java/com/dsideal/FengHuang/Organization/Controller/OrganizationController.java +++ b/FengHuang/src/main/java/com/dsideal/FengHuang/Organization/Controller/OrganizationController.java @@ -467,6 +467,7 @@ public class OrganizationController extends Controller { Record rOrg = model.getOrgInfo(bureau_id); root.put("title", rOrg.getStr("org_name")); root.put("parentId", "0"); + root.put("last", rOrg.getInt("cnt") > 0); //Level1 JSONArray level1 = new JSONArray(); @@ -479,6 +480,8 @@ public class OrganizationController extends Controller { jo.put("id", r1.getStr("org_id")); jo.put("title", r1.getStr("org_name")); jo.put("parentId", r1.getStr("parent_id")); + jo.put("last", r1.getInt("cnt") == 0); + JSONArray children = new JSONArray(); String org_id = r1.getStr("org_id"); for (Record r2 : secondList) { @@ -487,6 +490,7 @@ public class OrganizationController extends Controller { child.put("id", r2.getStr("org_id")); child.put("title", r2.getStr("org_name")); child.put("parentId", r2.getStr("parent_id")); + jo.put("last", false); children.add(child); } } diff --git a/FengHuang/src/main/java/com/dsideal/FengHuang/Organization/Model/OrganizationModel.java b/FengHuang/src/main/java/com/dsideal/FengHuang/Organization/Model/OrganizationModel.java index b6948ab..6d7bc8c 100644 --- a/FengHuang/src/main/java/com/dsideal/FengHuang/Organization/Model/OrganizationModel.java +++ b/FengHuang/src/main/java/com/dsideal/FengHuang/Organization/Model/OrganizationModel.java @@ -24,7 +24,8 @@ public class OrganizationModel { * @return */ public Record getOrgInfo(String org_id) { - return Db.findById("t_base_organization", "org_id", org_id); + String sql = "select t1.org_id,t1.org_name,t1.parent_id,(select count(1) from t_base_organization as t2 where t1.org_id=t2.parent_id) as cnt from t_base_organization as t1 where t1.org_id=?"; + return Db.findFirst(sql, org_id); } /** diff --git a/FengHuang/src/main/resource/Sql/organization.sql b/FengHuang/src/main/resource/Sql/organization.sql index 5900145..e35c8d4 100644 --- a/FengHuang/src/main/resource/Sql/organization.sql +++ b/FengHuang/src/main/resource/Sql/organization.sql @@ -110,12 +110,13 @@ #end #sql("getZyClassSelectTreeLevel1") - select org_id,org_name,parent_id from t_base_organization where bureau_id='#(bureau_id)' - and ((department_type_id =1) or (department_type_id =2 and parent_id='#(bureau_id)')) + select t1.org_id,t1.org_name,t1.parent_id,(select count(1) from t_base_organization as t2 where t1.parent_id=t2.org_id) as cnt + from t_base_organization as t1 where t1.bureau_id='#(bureau_id)' + and ((t1.department_type_id =1) or (t1.department_type_id =2 and t1.parent_id='#(bureau_id)')) #end #sql("getZyClassSelectTreeLevel2") - select org_id,org_name,parent_id from t_base_organization where bureau_id='#(bureau_id)' + select org_id,org_name,parent_id,0 as cnt from t_base_organization where bureau_id='#(bureau_id)' and (department_type_id =2 and parent_id<>'#(bureau_id)') #end #end \ No newline at end of file diff --git a/FengHuang/target/classes/Sql/organization.sql b/FengHuang/target/classes/Sql/organization.sql index 5900145..e35c8d4 100644 --- a/FengHuang/target/classes/Sql/organization.sql +++ b/FengHuang/target/classes/Sql/organization.sql @@ -110,12 +110,13 @@ #end #sql("getZyClassSelectTreeLevel1") - select org_id,org_name,parent_id from t_base_organization where bureau_id='#(bureau_id)' - and ((department_type_id =1) or (department_type_id =2 and parent_id='#(bureau_id)')) + select t1.org_id,t1.org_name,t1.parent_id,(select count(1) from t_base_organization as t2 where t1.parent_id=t2.org_id) as cnt + from t_base_organization as t1 where t1.bureau_id='#(bureau_id)' + and ((t1.department_type_id =1) or (t1.department_type_id =2 and t1.parent_id='#(bureau_id)')) #end #sql("getZyClassSelectTreeLevel2") - select org_id,org_name,parent_id from t_base_organization where bureau_id='#(bureau_id)' + select org_id,org_name,parent_id,0 as cnt from t_base_organization where bureau_id='#(bureau_id)' and (department_type_id =2 and parent_id<>'#(bureau_id)') #end #end \ No newline at end of file