main
黄海 1 year ago
parent 09ed0b9510
commit b075f2ae80

@ -64,7 +64,7 @@ public class OrganizationController extends Controller {
//是不是有权限操作这个单位或区域下的数据?
@LengthInterface({"org_name,2,64"})
public void addBureau(String org_code, String org_name, String parent_org_id, int org_type_id,
int school_type_id, int sort_id, String property_id, int level_id,int is_virtual) {
int school_type_id, int sort_id, String property_id, int level_id, int is_virtual) {
String person_id = SessionKit.get(getRequest(), getResponse(), "person_id");
if (org_code.trim().equals("-1")) {
renderJson(CommonUtil.returnMessageJson(false, "-1是保留字不能做为编码使用"));
@ -109,7 +109,7 @@ public class OrganizationController extends Controller {
//客户端ip_address
String ip_address = IpUtil.getIpAddr(getRequest());
model.addBureau(org_code, org_name, parent_org_id, org_type_id, school_type_id,
sort_id, operator, ip_address, property_id, level_id,is_virtual);
sort_id, operator, ip_address, property_id, level_id, is_virtual);
renderJson(CommonUtil.returnMessageJson(true, "保存成功!"));
}
@ -130,7 +130,7 @@ public class OrganizationController extends Controller {
@IsSysAdminInterface({"1", "2", "3"}) //是不是123号管理员
//是不是有权限操作这个单位或区域下的数据?
@LengthInterface({"bureau_name,2,64"})
public void updateBureau(String bureau_id, String org_code, String bureau_name, String parent_org_id, int sort_id, String main_school_id, int property_id,int is_virtual) {
public void updateBureau(String bureau_id, String org_code, String bureau_name, String parent_org_id, int sort_id, String main_school_id, int property_id, int is_virtual) {
if (model.getOrgCodeCountExceptSelf(bureau_id, org_code) > 0) {
renderJson(CommonUtil.returnMessageJson(false, "此单位代码已存在,不能添加!"));
return;
@ -139,7 +139,7 @@ public class OrganizationController extends Controller {
String operator = SessionKit.get(getRequest(), getResponse(), "person_id");
//客户端ip_address
String ip_address = IpUtil.getIpAddr(getRequest());
model.updateBureau(bureau_id, org_code, bureau_name, parent_org_id, sort_id, main_school_id, property_id, operator, ip_address,is_virtual);
model.updateBureau(bureau_id, org_code, bureau_name, parent_org_id, sort_id, main_school_id, property_id, operator, ip_address, is_virtual);
renderJson(CommonUtil.returnMessageJson(true, "修改成功!"));
}
@ -444,7 +444,7 @@ public class OrganizationController extends Controller {
@IsSysAdminInterface({"1", "2", "3", "4"})
@IsNumericInterface({"type_id", "page", "limit"})
@EmptyInterface({"area_id"})
public void getBureauListByAreaId(String area_id, String keyword, int type_id, int page, int limit) {
public void getBureauListByAreaId(String area_id, String keyword, int type_id, int not_include_child, int page, int limit) {
if (!SqlInjectionUtil.isSqlValid(keyword)) {
Kv kv = Kv.create();
kv.set("success", false);
@ -457,26 +457,11 @@ public class OrganizationController extends Controller {
}
DmModel dmModel = new DmModel();
List<Record> rs = dmModel.getAreaById(area_id);
if (rs == null || rs.size() == 0) {
if (rs == null || rs.isEmpty()) {
renderJson(CommonUtil.returnMessageJson(false, "传入的area_id无效!"));
return;
}
Page<Record> dt;
switch (type_id) {
case 0:
dt = model.getAllListByAreaId(area_id, keyword, page, limit);
renderJson(CommonUtil.renderJsonForLayUI(dt));
return;
case 1:
dt = model.getSchoolListByAreaId(area_id, keyword, page, limit);
renderJson(CommonUtil.renderJsonForLayUI(dt));
return;
case 2:
dt = model.getBureauListByAreaId(area_id, keyword, page, limit);
renderJson(CommonUtil.renderJsonForLayUI(dt));
return;
default:
renderJson(CommonUtil.returnMessageJson(false, "传入的类型不正确0:全部,1:学校,2:单位!"));
}
Page<Record> dt = model.getBureauListByAreaId(area_id, keyword, type_id, not_include_child, page, limit);
renderJson(CommonUtil.renderJsonForLayUI(dt));
}
}

@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
import com.dsideal.QingLong.Util.CommonUtil;
import com.dsideal.QingLong.Util.IpUtil;
import com.dsideal.QingLong.Util.PkUtil;
import com.jfinal.kit.Kv;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
@ -51,6 +52,8 @@ public class OrganizationModel {
}
}
String NullGuid = "00000000-0000-0000-0000-000000000000";
/**
*
*
@ -60,7 +63,6 @@ public class OrganizationModel {
* @return
*/
public Map<String, String> getAreaInfoById(String id) {
String NullGuid = "00000000-0000-0000-0000-000000000000";
Map<String, String> map = new HashMap<>();
String sql = Db.getSql("dm.getAreaById");
List<Record> records = Db.find(sql, id);
@ -530,31 +532,6 @@ public class OrganizationModel {
return Db.find(sql, bureau_id);
}
/**
* ID
*
* 2018-12-26
*
* @param area_id
* @param keyword
* @return
*/
public Page<Record> getSchoolListByAreaId(String area_id, String keyword, int page, int limit) {
return Db.paginate(page, limit, Db.getSqlPara("organization.getSchoolListByAreaId", area_id, area_id, "%" + keyword + "%"));
}
/**
* ID
*
* 2018-12-26
*
* @param area_id
* @param keyword
* @return
*/
public Page<Record> getBureauListByAreaId(String area_id, String keyword, int page, int limit) {
return Db.paginate(page, limit, Db.getSqlPara("organization.getBureauListByAreaId", area_id, area_id, "%" + keyword + "%"));
}
/**
* ID
@ -565,7 +542,28 @@ public class OrganizationModel {
* @param keyword
* @return
*/
public Page<Record> getAllListByAreaId(String area_id, String keyword, int page, int limit) {
return Db.paginate(page, limit, Db.getSqlPara("organization.getAllListByAreaId", area_id, area_id, "%" + keyword + "%"));
public Page<Record> getBureauListByAreaId(String area_id, String keyword, int type_id, int not_include_child, int page, int limit) {
Map<String, String> _map = getAreaInfoById(area_id);
Kv kv = Kv.create();
if (not_include_child > 0) {//不包含子节点
kv.set("not_include_child", not_include_child);
kv.set("city_id", _map.get("city_id"));
kv.set("area_id", _map.get("area_id"));
} else {//包含子节点
if (_map.get("area_id").equals(NullGuid)) {
kv.set("city_id", _map.get("city_id"));
} else {
kv.set("area_id", _map.get("area_id"));
}
}
kv.set("org_name", "%" + keyword + "%");
if (type_id == 1) {
kv.set("for_school", 1);
}
if (type_id == 2) {
kv.set("for_bureau", 1);
}
SqlPara sqlPara = Db.getSqlPara("organization.getAllListByAreaId", kv);
return Db.paginate(page, limit, sqlPara);
}
}

@ -92,20 +92,30 @@
and b_use=1 order by sort_id,update_ts
#end
-- 传入一个区域ID获取它下面的学校
#sql("getSchoolListByAreaId")
select org_id,org_code,org_name from t_base_organization where (city_id=#para(0) or area_id=#para(1)) and b_use=1 and is_bureau=1
and org_name like #para(2) and school_type_id>0 order by area_id,sort_id
#end
-- 传入一个区域ID获取它下面的单位
#sql("getBureauListByAreaId")
select org_id,org_code,org_name from t_base_organization where (city_id=#para(0) or area_id=#para(1)) and b_use=1 and is_bureau=1
and org_name like #para(2) and school_type_id<=0 order by area_id,sort_id
#end
-- 传入一个区域ID获取它下面全部
#sql("getAllListByAreaId")
select org_id,org_code,org_name from t_base_organization where (city_id=#para(0) or area_id=#para(1)) and b_use=1 and is_bureau=1
and org_name like #para(2) order by area_id,sort_id
select org_id,org_code,org_name from t_base_organization
where
#if(not_include_child)
city_id=#para(city_id) and area_id=#para(area_id)
#else
#if(city_id)
city_id=#para(city_id)
#end
#if(area_id)
area_id=#para(area_id)
#end
#end
and b_use=1 and is_bureau=1
-- type_id=0:全部 type_id=1:学校 type_id=2:单位
#if(for_school)
school_type_id>0
#end
#if(for_bureau)
school_type_id<=0
#end
and org_name like #para(org_name) order by area_id,sort_id
#end
--ID

Loading…
Cancel
Save