kgdxpr 3 years ago
commit 49d3e80c74

@ -12,8 +12,12 @@ import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import com.jfinal.ext.interceptor.GET;
import com.jfinal.ext.interceptor.POST;
import com.jfinal.kit.JsonKit;
import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import java.util.List;
import java.util.Map;
public class ClassController extends Controller {

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.dsideal.FengHuang.Util.CommonUtil;
import com.dsideal.FengHuang.Util.IpUtil;
import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
@ -283,4 +284,5 @@ public class ClassModel {
}
return ja;
}
}

@ -1,5 +1,7 @@
package com.dsideal.FengHuang.Organization.Controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.dsideal.FengHuang.Interceptor.*;
import com.dsideal.FengHuang.Util.CommonUtil;
import com.dsideal.FengHuang.Util.IpUtil;
@ -10,6 +12,7 @@ import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import com.jfinal.ext.interceptor.GET;
import com.jfinal.ext.interceptor.POST;
import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
@ -449,4 +452,52 @@ public class OrganizationController extends Controller {
return;
}
}
// http://10.10.11.124:9000/FengHuang/organization/getZyClassSelectTree?bureau_id=0D8C9679-16B6-4A3B-A6FC-5CF4FF066437
@Before({GET.class})
@EmptyInterface({"bureau_id"})
public void getZyClassSelectTree(String bureau_id) {
Kv res = Kv.create();
Kv status = Kv.by("code", 200).set("message", "操作成功");
JSONArray data = new JSONArray();
JSONObject root = new JSONObject();
root.put("org_id", bureau_id);
Record rOrg = model.getOrgInfo(bureau_id);
root.put("org_name", rOrg.getStr("org_name"));
root.put("parent_id", "0");
//Level1
JSONArray level1 = new JSONArray();
List<Record> firstList = model.getZyClassSelectTreeLevel1(bureau_id);
//Level2
List<Record> secondList = model.getZyClassSelectTreeLevel2(bureau_id);
for (Record r1 : firstList) {
JSONObject jo = new JSONObject();
jo.put("org_id", r1.getStr("org_id"));
jo.put("org_name", r1.getStr("org_name"));
jo.put("parent_id", r1.getStr("parent_id"));
JSONArray children = new JSONArray();
String org_id = r1.getStr("org_id");
for (Record r2 : secondList) {
if (r2.getStr("parent_id").equals(org_id)) {
JSONObject child = new JSONObject();
child.put("org_id", r2.getStr("org_id"));
child.put("org_name", r2.getStr("org_name"));
child.put("parent_id", r2.getStr("parent_id"));
children.add(child);
}
}
jo.put("children", children);
level1.add(jo);
}
root.put("children", level1);
data.add(root);
res.set("status", status);
res.set("data", data);
renderJson(res);
}
}

@ -3,6 +3,7 @@ package com.dsideal.FengHuang.Organization.Model;
import com.dsideal.FengHuang.Util.CommonUtil;
import com.dsideal.FengHuang.Util.IpUtil;
import com.dsideal.FengHuang.Util.PkUtil;
import com.jfinal.kit.Kv;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
@ -564,4 +565,16 @@ public class OrganizationModel {
Page<?> dataPage = Db.paginate(page, limit, Db.getSqlPara("organization.getAllListByAreaId", area_id, area_id, "%" + keyword + "%"));
return dataPage;
}
public List<Record> getZyClassSelectTreeLevel1(String bureau_id) {
Kv kv = Kv.by("bureau_id", bureau_id);
SqlPara sqlPara = Db.getSqlPara("organization.getZyClassSelectTreeLevel1", kv);
return Db.find(sqlPara);
}
public List<Record> getZyClassSelectTreeLevel2(String bureau_id) {
Kv kv = Kv.by("bureau_id", bureau_id);
SqlPara sqlPara = Db.getSqlPara("organization.getZyClassSelectTreeLevel2", kv);
return Db.find(sqlPara);
}
}

@ -51,4 +51,5 @@
#sql("getClassName")
select class_id,class_name,stage_id from t_base_class where bureau_id=? and b_use=1
#end
#end

@ -109,4 +109,13 @@
select org_id,org_name from t_base_organization where bureau_id=? and parent_id=? and b_use=1
#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)'))
#end
#sql("getZyClassSelectTreeLevel2")
select org_id,org_name,parent_id from t_base_organization where bureau_id='#(bureau_id)'
and (department_type_id =2 and parent_id<>'#(bureau_id)')
#end
#end

@ -51,4 +51,5 @@
#sql("getClassName")
select class_id,class_name,stage_id from t_base_class where bureau_id=? and b_use=1
#end
#end

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