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.

183 lines
7.7 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("Base")
-- 获取整个单位类型与职务+分管信息树数据
#sql("getLoginInfoByUserName")
select person_id,person_name,pwd,COALESCE(wx_openid,'0') as wx_openid,COALESCE(qq_openid,'0') as qq_openid,
identity_id,bureau_id,city_id,area_id
from t_sys_loginperson where b_use = 1 and login_name =?
#end
-- 获取整个单位类型与职务+分管信息树数据
#sql("getOrgTypePrincipalshipTree")
select t1.id,t1.code,t1.name,t1.parent_id as pId,(case when length(t1.code)>6 then 0 else 1 end) as open,
(case when length(t1.code)=10 then 1 else 0 end ) as nocheck,
(select count(1) from t_base_org_type_principalship as t2 where t2.parent_id=t1.id) as is_leaf,sort_id,b_use,
is_school,level,bureau_level
from t_base_org_type_principalship as t1 where b_use=1
order by level,sort_id
#end
-- 获取单位类型与职务+分管信息树数据指定结点的信息
#sql("getOrgTypePrincipalshipById")
select t1.id,t1.code,t1.name,t1.parent_id as pId,t1.sort_id,t1.b_use,t1.is_school,t1.level,t1.bureau_level,
(select count(1) from t_base_org_type_principalship as t2 where t2.parent_id=t1.id) as is_leaf
from t_base_org_type_principalship as t1 where t1.id=#para(0) order by t1.sort_id
#end
#sql("getOrgTypePrincipalship")
select t1.id,t1.name,t1.parent_id as "pId",t1.sort_id,t1.b_use,t1.is_school,t1.level,t1.bureau_level,t1.code,
(select count(1) from t_base_org_type_principalship as t2 where t2.parent_id=t1.id) as is_leaf
from t_base_org_type_principalship as t1 where t1.b_use=1
#if(parent_id)
and t1.parent_id=#para(parent_id)
#end
#if(is_school)
and t1.is_school=#para(is_school)
#end
#if(bureau_id)
and t1.code like concat((select code from t_base_org_type_principalship
where id=(select org_type_id from t_base_organization where org_id=#para(bureau_id))),'%')
#end
order by level,sort_id
#end
-- 修改一个OrgTypePrincipalship节点
#sql("updateOrgTypePrincipalshipNode")
update t_base_org_type_principalship set code=?,name=?,parent_id=?,sort_id=?,b_use=?,is_school=? where id=?
#end
-- 删除一个OrgTypePrincipalship节点
#sql("delOrgTypePrincipalshipById")
delete from t_base_org_type_principalship where id=?
#end
-- 获取单位类型与职务+分管信息树数据指定结点下一级的数据ByCode
#sql("getOrgTypePrincipalshipByParentparent_code")
select id,code,name,parent_id as pId,sort_id,b_use,is_school,level,bureau_level
from t_base_org_type_principalship where code like ? and length(code)=length(?)+2 and b_use=1 order by level,sort_id
#end
-- 获取指定CODE的个数
#sql("t_base_org_type_principalship_CountByCode")
select count(1) as c from t_base_org_type_principalship where code=? and b_use=1
#end
-- 获取指定CODE的个数,不包括自己
#sql("t_base_org_type_principalship_CountByCodeExceptSelf")
select count(1) as c from t_base_org_type_principalship where code=? and id!=? and b_use=1
#end
-- 通过单位ID获取职务权限树
#sql("getPrincipalshipTreeByBureauId")
select t1.id,t1.code,t1.name,t1.sort_id,t1.b_use,t1.is_school,t1.level,t1.bureau_level,
(case when length(t1.code)=6 then -1 else t1.parent_id end ) as parent_id,
(select count(1) from t_base_org_type_principalship as t2 where t2.parent_id=t1.id and t2.b_use=1) as is_leaf
from t_base_org_type_principalship as t1
where t1.code like concat((select code from t_base_org_type_principalship
where id=(select org_type_id from t_base_organization where org_id=?)),'%') and t1.b_use=1
order by t1.sort_id
#end
-- 获取职务列表打印EXCEL用来方便第三方系统提供接入的职务与系统对应关系
#sql("getPrincipalshipThirdParty")
select (case when substr(t1.code,1,4)='0101' then '市级' else '县区级' end ) as level_name,
(select t2.name from t_base_org_type_principalship as t2 where t2.code=SUBSTR(t1.code,1,6)) as org_type_name,
t1.name as zhiwu_name ,
COALESCE((select group_concat(name) as cols from t_base_org_type_principalship where parent_id=t1.id),'') as fenguan
from t_base_org_type_principalship as t1 where t1.level =4 and t1.b_use=1 order by t1.code
#end
-- 获取当前学期
#sql("getCurrentTerm")
select xq_id,(case xq_code when '09' then xn else xn+1 end) as xn,xq,
xqmc,ksrq,jsrq,memo,xq_code,is_current from t_base_term where is_current=1
#end
-- 按年份获取学期列表
#sql("getTermListByYear")
select xq_id,(case xq_code when '09' then xn else xn+1 end) as xn,xq,
xqmc,ksrq,jsrq,memo,xq_code,is_current from t_base_term where xn=#(batch_year)
#end
-- 获取当前人员
#sql("getCurrentPerson")
select t1.*,t4.rule_id
from t_sys_loginperson as t1
left join t_base_student as t2 on t2.sfzh=AES_DECRYPT(from_base64(t1.idcard_code),'DsideaL4r5t6y7u!')
left join t_base_class as t3 on t2.class_id=t3.class_id
left join t_jw_major_rule AS t4 ON t3.zydm = t4.zhuanye_code
and t3.entry_year = t4.entry_year
and t3.type_id = t4.zhaosheng_type_id
and t3.xq_code = t4.entry_term_code and t4.rule_type_id=1
where t1.person_id='#(person_id)'
#end
-- 获取当前学生所在班级
#sql("getCurrentClass")
select c.* from t_base_class as c left join t_sys_loginperson as l on c.class_id=l.s_class_id where l.person_id='#(person_id)' and l.identity_id=6
#end
-- 获取学期列表
#sql("getTermList")
select xq_id,xn,xq,xqmc,
ksrq,
jsrq,is_current
from t_base_term where
xq_id<=(select xq_id from t_base_term where is_current=1)
#if(addOne)
+1
#end
and xn>=2018 order by xq_id
#if(action_asc)
asc
#else
desc
#end
#end
-- 修改校历的文字描述信息
#sql("updateXiaoLiMemo")
update t_base_term set memo='#(memo)',ksrq='#(ksrq)',jsrq='#(jsrq)' where xq_id=#(xq_id)
#end
-- 是不是在职务列表中
#sql("isInDutyList")
select count(*) as c from t_person_duty_charge where person_id='#(person_id)' and duties_id in
(
#for(x:ids)
#(for.index == 0 ? "" : ",") #para(x)
#end
)
#end
-- 查询人员职务列表
#sql("selectDutyList")
select `name` from t_base_org_type_principalship where id in
( #for(x:ids)
#(for.index == 0 ? "" : ",")
#para(x)
#end )
#end
-- 教师选择器专用(多选)
#sql("selectPersonsByBureauId")
select person_id,person_name from t_sys_loginperson where bureau_id=? and b_use=1 and identity_id=5
order by person_name,sort_id
#end
-- 系内人员选择器(主部门待选)
#sql("selectZhuPersonsByOrgId")
select sl.person_id,sl.person_name
from t_sys_loginperson as sl
LEFT JOIN t_base_organization AS bo ON bo.org_id = sl.org_id
where sl.bureau_id=? and sl.b_use=1 and sl.identity_id=5
and (bo.org_id=? or bo.parent_id=?)
order by sl.person_name,sl.sort_id
#end
-- 获取指定单位下的班级列表
#sql("getBureauClassList")
select distinct t1.class_id,t1.class_name from t_base_class as t1
where COALESCE(graduate_flag,0)=0
#if(zhuanye_code)
and t1.zydm='#(zhuanye_code)'
#end
#if(batch_year)
and t1.entry_year=#(batch_year);
#end
#end
#end