xuekang
2024-05-13 15a0280ae9e7db96fdf0744c722d214d2cb5a0e5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
package com.nuvole.four.mapper;
 
import com.nuvole.four.domain.SysOrg;
import com.nuvole.four.domain.dto.ChannelOrgConfigDetailDto;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
 
import java.util.List;
import java.util.Map;
 
public interface SysOrgMapper {
    int deleteByPrimaryKey(Long id);
 
    int insert(SysOrg record);
 
    int insertSelective(SysOrg record);
 
    SysOrg selectByPrimaryKey(Long id);
 
    int updateByPrimaryKeySelective(SysOrg record);
 
    int updateByPrimaryKey(SysOrg record);
 
    /**
     * @Author : liu.q [916000612@qq.com]
     * @Date : 2019-04-04 14:15
     * @Description :查询全部
     */
    List<SysOrg> selectAll(Map map);
 
    /**
     * @Author : liu.q [916000612@qq.com]
     * @Date : 2019-04-07 19:21
     * @Description :查询全部
     */
    List<Map> selectAllOfMap(Map map);
 
    /**
     * 根据机构编号查询机构信息
     *
     * @author zxc
     * @Date 2019/6/4 11:35
     **/
    SysOrg getOrgByCode(String code);
 
    @Select("select org.*,org2.org_Code pOrgCode from sys_org org left join sys_org org2 on org.pid = org2.id where org.org_code=#{code}")
    Map getOrgByCode2(String code);
 
    List<Map> getBranchByOrgCode(@Param("code") String code, @Param("keyText") String keyText, @Param("userType") Short userType);
 
 
    /**
     * 查询机构byCode
     *
     * @Author: lc
     * @Date: 2019/6/12 16:20
     */
    SysOrg selectOrgByCode(String code);
 
    /**
     * 批量执行导入
     *
     * @author zxc
     * @Date 2019/6/11 18:59
     **/
    int batchImportOrg(List<Map> list);
 
    /**
     * 查询全部机构
     *
     * @Author: lc
     * @Date: 2019/6/13 9:39
     */
    @Select("select * from sys_org ")
    List<SysOrg> getOrgList();
 
    /**
     * 查询父机构useCode 以及 子机构maxCode
     *
     * @author zxc
     * @Date 2019/7/13 18:49
     **/
    @Select("select max(a.org_code) maxCode,a.pid,(select b.org_code from sys_org b where b.id = a.pid) pCode from sys_org a group by a.pid")
    List<Map> selectUseCodeForImport();
 
    /**
     * 查询本级最大code
     *
     * @Author: lc
     * @Date: 2019/6/13 13:40
     */
    @Select("select max(org_code) from sys_org where pid=#{pid} ")
    String getMaxCode(@Param("pid") Long pid);
 
    /**
     * 根据机构编号获取机构
     *
     * @param orgCode
     * @return
     */
    @Select("select * from sys_org where user_org_code = #{orgCode}")
    SysOrg selectByOrgCode(@Param("orgCode") String orgCode);
 
    /**
     * 角色管理人员配置机构树
     *
     * @author zxc
     * @Date 2019/6/13 17:19
     **/
    List<SysOrg> getListForRoleUser(Map map);
 
    /**
     * Createed by PKZ
     * Date 2019/6/17 16:11
     * Description:根据userOrgCode查询机构信息
     **/
    @Select("select a.org_code zj_org_code,a.id zj_id,a.name zj_name,b.id xq_id,b.name xq_name,c.id sj_id,c.name sj_name from sys_org a,sys_org b,sys_org c where a.user_org_code = #{orgCode} and b.id=a.pid and c.id=b.pid")
    Map getOrgByUserCode(@Param("orgCode") String code);
 
    List<SysOrg> getOrgForSelector(@Param("pid") Long pid, @Param("rootId") Long rootId);
 
    @Select("select pid from sys_org where id = #{id}")
    Long queryPidById(@Param("id") Long id);
 
    @Select("select lv from sys_org where id = #{id}")
    Integer queryLvById(@Param("id") Long id);
 
    Integer getByOrgCode(SysOrg sysOrg);
 
 
    @Select("select id,name,org_code,user_org_code,pid from sys_org where state=1 and lv<2")
    List<SysOrg> getOrgEndS();
 
    @Select("select id, name from sys_org where pid = #{orgId}")
    List<SysOrg> getOrgMapByLogin(Long orgId);
 
    @Select("select id, name from sys_org where id = #{orgId} and lv = 3")
    List<SysOrg> getOrgMapByLoginLv(Long orgId);
 
    @Select("select lv from sys_org where org_code = #{orgCode}")
    Integer getOrgLvByOrgCode(String orgCode);
 
 
 
 
 
    /**
     * 查询所有支局
     */
    @Select("select id, name from sys_org where  lv = 3")
    List<SysOrg> getWdIdOrName();
 
    /**
     * 查询所有支局
     */
    @Select("select * from sys_org where  lv = 0 limit 1")
    SysOrg getSjOrgInfo();
 
    @Select("select * from sys_org where pid=(select id from sys_org where org_code = #{orgCode} ) or org_code = #{orgCode}")
    List<SysOrg> selectOrgByOrgCode(String orgCode);
 
    @Select("select name as orgName ,org_code as orgCode from sys_org group by org_code ")
    List<Map> getOrgCodeCache();
 
    @Select("select a.name,c.org_code orgCode from sys_area a left join sys_org_area b on b.area_id = a.id left join sys_org c on c.id = b.org_id where a.lv = 2")
    List<Map> getSjOrgCodeAreaNameRef();
 
 
    /**
     * 禁用机构
     *
     * @param orgCode
     * @return CONCAT(' % ', # { 0 }, ' % ')
     */
    @Update("update sys_org set state=#{state} where org_code like CONCAT('%',#{orgCode},'%')")
    int updateState(@Param("orgCode") String orgCode, @Param("state") Integer state);
 
    /**
     * 方法描述: 根据orgId查询机构名称、父级机构名称
     *
     * @date  2024-04-11 20:30
     **/
    @Select("select a.id,a.name orgName,a.pid pId,a.lv,(select b.name from sys_org b where b.id = a.pid) parentOrgName from sys_org a where a.id = #{orgId}")
    ChannelOrgConfigDetailDto queryNameAndParentName(@Param("orgId") Long orgId);
}