kgdxpr 3 years ago
commit 3b17543edc

@ -467,6 +467,7 @@ public class OrganizationController extends Controller {
Record rOrg = model.getOrgInfo(bureau_id); Record rOrg = model.getOrgInfo(bureau_id);
root.put("title", rOrg.getStr("org_name")); root.put("title", rOrg.getStr("org_name"));
root.put("parentId", "0"); root.put("parentId", "0");
root.put("last", rOrg.getInt("cnt") == 0);
//Level1 //Level1
JSONArray level1 = new JSONArray(); JSONArray level1 = new JSONArray();
@ -479,6 +480,7 @@ public class OrganizationController extends Controller {
jo.put("id", r1.getStr("org_id")); jo.put("id", r1.getStr("org_id"));
jo.put("title", r1.getStr("org_name")); jo.put("title", r1.getStr("org_name"));
jo.put("parentId", r1.getStr("parent_id")); jo.put("parentId", r1.getStr("parent_id"));
JSONArray children = new JSONArray(); JSONArray children = new JSONArray();
String org_id = r1.getStr("org_id"); String org_id = r1.getStr("org_id");
for (Record r2 : secondList) { for (Record r2 : secondList) {
@ -487,9 +489,11 @@ public class OrganizationController extends Controller {
child.put("id", r2.getStr("org_id")); child.put("id", r2.getStr("org_id"));
child.put("title", r2.getStr("org_name")); child.put("title", r2.getStr("org_name"));
child.put("parentId", r2.getStr("parent_id")); child.put("parentId", r2.getStr("parent_id"));
child.put("last", true);
children.add(child); children.add(child);
} }
} }
jo.put("last", children.size()==0);
jo.put("children", children); jo.put("children", children);
level1.add(jo); level1.add(jo);
} }

@ -24,7 +24,8 @@ public class OrganizationModel {
* @return * @return
*/ */
public Record getOrgInfo(String org_id) { 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);
} }
/** /**

@ -110,12 +110,13 @@
#end #end
#sql("getZyClassSelectTreeLevel1") #sql("getZyClassSelectTreeLevel1")
select org_id,org_name,parent_id from t_base_organization where bureau_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
and ((department_type_id =1) or (department_type_id =2 and parent_id='#(bureau_id)')) 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 #end
#sql("getZyClassSelectTreeLevel2") #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)') and (department_type_id =2 and parent_id<>'#(bureau_id)')
#end #end
#end #end

@ -110,12 +110,13 @@
#end #end
#sql("getZyClassSelectTreeLevel1") #sql("getZyClassSelectTreeLevel1")
select org_id,org_name,parent_id from t_base_organization where bureau_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
and ((department_type_id =1) or (department_type_id =2 and parent_id='#(bureau_id)')) 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 #end
#sql("getZyClassSelectTreeLevel2") #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)') and (department_type_id =2 and parent_id<>'#(bureau_id)')
#end #end
#end #end
Loading…
Cancel
Save