You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
5.1 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

-- 组织机构命名空间
#namespace("organization")
-- 获取组织机构的最大主键号
#sql("getMaxPkByOrg")
select coalesce(max(org_pk_num),'0') as org_pk_num from t_base_organization
#end
-- 获取指定单位或组织机构的信息
#sql("getOrgInfoById")
select org_id,org_code,org_name,parent_id,org_type_id,school_type_id,sort_id,create_time,
update_ts,b_use,org_pk_num,coalesce(city_id, '-1') as city_id,coalesce(area_id, '-1') as area_id,
coalesce(main_school_id, '-1') as main_school_id,bureau_id,property_id,level_id
from t_base_organization where org_id=? and b_use=1
#end
-- 判断一个组织机构号是不是单位
#sql("IsBureau")
select count(1) as c from t_base_organization where org_id=? and org_id=bureau_id
#end
-- 根据单位号获取下面正常部门的个数
#sql("getOrgCountByBureauId")
select count(1) as c from t_base_organization where bureau_id=? and org_id<>? and b_use=1
#end
-- 删除一个机构
#sql("deleteOrgById")
update t_base_organization set b_use=0,operator=?,ip_address=? where org_id=?
#end
-- 判断此ORG_CODE是不是存在
#sql("getOrgCodeCount")
select count(1) as c from t_base_organization where org_code=? and b_use=1
#end
-- 判断此ORG_CODE是不是存在(排除自己用于修改)
#sql("getOrgCodeCountExceptSelf")
select count(1) as c from t_base_organization where org_code=? and org_id!=? and b_use=1
#end
-- 获取部门列表
#sql("getOrgList")
select * from t_base_organization where parent_id=#para(0) and b_use=1 order by sort_id
#end
-- 获取学校列表
#sql("getSchoolList")
select t1.org_id,t1.org_code,t1.org_name,t1.parent_id,t1.org_type_id,t1.school_type_id,t1.sort_id,
t1.create_time,t1.update_ts,t1.b_use,t1.org_pk_num,t1.city_id,t1.area_id,t1.main_school_id,t1.bureau_id,
(select t2.school_type_name from t_dm_schooltype as t2 where t2.school_type_id=t1.school_type_id) as school_type_name
from t_base_organization as t1 where t1.parent_id=#para(0) and t1.b_use=1 and t1.school_type_id>0
#end
-- 获取学校列表(指定学校类型)
#sql("getSchoolListBySchoolType")
select t1.org_id,t1.org_code,t1.org_name,t1.parent_id,t1.org_type_id,
t1.school_type_id,t1.sort_id,t1.create_time,t1.update_ts,t1.b_use,
t1.org_pk_num,t1.city_id,t1.area_id,t1.main_school_id,t1.bureau_id,
(select t2.school_type_name from t_dm_schooltype as t2 where t2.school_type_id=t1.school_type_id) as school_type_name
from t_base_organization as t1 where t1.parent_id=#para(0) and t1.b_use=1 and t1.school_type_id =#para(1)
#end
-- 获取单位列表
#sql("getBureauList")
select t1.org_id,t1.org_code,t1.org_name,t1.parent_id,t1.org_type_id,
(select t2.name from t_base_org_type_principalship as t2 WHERE t2.id=t1.org_type_id) as org_type_name,
t1.school_type_id,t1.sort_id,t1.create_time,
t1.update_ts,t1.b_use,t1.org_pk_num,t1.city_id,t1.area_id,t1.main_school_id,t1.bureau_id
from t_base_organization as t1 where t1.parent_id=#para(0) and t1.school_type_id<=0 and t1.b_use=1 order by t1.sort_id,t1.update_ts
#end
-- 获取单位列表(指定单位类型)
#sql("getBureauListByBureauType")
select t1.org_id,t1.org_code,t1.org_name,t1.parent_id,t1.org_type_id,
(select t2.name from t_base_org_type_principalship as t2 WHERE t2.id=t1.org_type_id) as org_type_name,
t1.school_type_id,t1.sort_id,t1.create_time,
t1.update_ts,t1.b_use,t1.org_pk_num,t1.city_id,t1.area_id,t1.main_school_id,t1.bureau_id
from t_base_organization as t1 where t1.parent_id=#para(0) and t1.school_type_id<=0 and t1.org_type_id = #para(1)
and t1.b_use=1 order by t1.sort_id,t1.update_ts
#end
-- 组织机构部门树
#sql("getOrgTreeByBureauId")
select org_id,org_name,(case when bureau_id=org_id then '-1' else parent_id end) as parent_id,bureau_id from t_base_organization where bureau_id=?
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
#end
--传入一个单位ID获取它的一级部门有哪些
#sql("getFirstLevelOrgName")
select org_id,org_name from t_base_organization where bureau_id=? and parent_id=? and b_use=1
#end
#end