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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ Copyright (c) 2018-2025, lengleng All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~
~ Redistributions of source code must retain the above copyright notice,
~ this list of conditions and the following disclaimer.
~ Redistributions in binary form must reproduce the above copyright
~ notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~ Neither the name of the yifu4cloud.com developer nor the names of its
~ contributors may be used to endorse or promote products derived from
~ this software without specific prior written permission.
~ Author: lengleng (wangiegie@gmail.com)
~
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmployeeProjectBelongDeptMapper">
<resultMap id="tEmployeeProjectBelongDeptMap"
type="com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeProjectBelongDept">
<id property="id" column="ID"/>
<result property="empDeptname" column="emp_deptname"/>
<result property="empDeptid" column="emp_deptid"/>
</resultMap>
<sql id="tEmployeeProjectBelongDept_where">
/* 派单审核通过,或其他路径 2025-3-19 15:22:08 倩倩要求去掉审核条件*/
<if test="tEmployeeProjectBelongDept != null">
<if test="tEmployeeProjectBelongDept.deptId != null and tEmployeeProjectBelongDept.deptId.trim() != ''">
AND a.DEPT_ID = #{tEmployeeProjectBelongDept.deptId}
</if>
<if test="tEmployeeProjectBelongDept.empDeptId != null and tEmployeeProjectBelongDept.empDeptId.trim() != ''">
<if test="tEmployeeProjectBelongDept.empDeptId.trim() == '-1'">
/* 查询未关联的 */
AND b.id is null
</if>
<if test="tEmployeeProjectBelongDept.empDeptId.trim() == '不查数据'">
/* 不查数据 */
AND b.id = '不查数据'
</if>
</if>
<if test="tEmployeeProjectBelongDept.empName != null and tEmployeeProjectBelongDept.empName.trim() != ''">
AND a.EMP_NAME like concat('%',#{tEmployeeProjectBelongDept.empName},'%')
</if>
<if test="tEmployeeProjectBelongDept.empIdcard != null and tEmployeeProjectBelongDept.empIdcard.trim() != ''">
AND a.EMP_IDCARD like concat('%',#{tEmployeeProjectBelongDept.empIdcard},'%')
</if>
<if test="tEmployeeProjectBelongDept.empPhone != null and tEmployeeProjectBelongDept.empPhone.trim() != ''">
AND e.EMP_PHONE like concat('%',#{tEmployeeProjectBelongDept.empPhone},'%')
</if>
<if test="tEmployeeProjectBelongDept.ids != null and tEmployeeProjectBelongDept.ids.size() > 0">
a.ID in
<foreach collection="tEmployeeProjectBelongDept.ids" item="param" index="index" open="(" close=")"
separator=",">
#{param}
</foreach>
</if>
<if test="tEmployeeProjectBelongDept.empDeptIdArray != null and tEmployeeProjectBelongDept.empDeptIdArray.length > 0">
AND b.emp_deptid in
<foreach item="idStr" index="index" collection="tEmployeeProjectBelongDept.empDeptIdArray" open="("
separator="," close=")">
#{idStr}
</foreach>
</if>
<if test="tEmployeeProjectBelongDept.contractStatusArray != null and tEmployeeProjectBelongDept.contractStatusArray.length > 0">
AND a.CONTRACT_STATUS in
<foreach item="idStr" index="index" collection="tEmployeeProjectBelongDept.contractStatusArray" open="("
separator="," close=")">
#{idStr}
</foreach>
</if>
<if test="tEmployeeProjectBelongDept.insuranceStatusArray != null and tEmployeeProjectBelongDept.insuranceStatusArray.length > 0">
AND a.INSURANCE_STATUS in
<foreach item="idStr" index="index" collection="tEmployeeProjectBelongDept.insuranceStatusArray"
open="("
separator="," close=")">
#{idStr}
</foreach>
</if>
<if test="tEmployeeProjectBelongDept.projectStatusArray != null and tEmployeeProjectBelongDept.projectStatusArray.length > 0">
AND a.PROJECT_STATUS in
<foreach item="idStr" index="index" collection="tEmployeeProjectBelongDept.projectStatusArray" open="("
separator="," close=")">
#{idStr}
</foreach>
</if>
<if test="tEmployeeProjectBelongDept.postArray != null and tEmployeeProjectBelongDept.postArray.length > 0">
AND a.POST in
<foreach item="idStr" index="index" collection="tEmployeeProjectBelongDept.postArray" open="("
separator="," close=")">
#{idStr}
</foreach>
</if>
<if test="tEmployeeProjectBelongDept.enjoinDateAndLeaveTimeStart != null">
and if(a.PROJECT_STATUS=0,a.ENJOIN_DATE,a.LEAVE_TIME) <![CDATA[ >= ]]>
#{tEmployeeProjectBelongDept.enjoinDateAndLeaveTimeStart}
</if>
<if test="tEmployeeProjectBelongDept.enjoinDateAndLeaveTimeEnd != null">
and if(a.PROJECT_STATUS=0,a.ENJOIN_DATE,a.LEAVE_TIME) <![CDATA[ <= ]]>
#{tEmployeeProjectBelongDept.enjoinDateAndLeaveTimeEnd}
</if>
</if>
</sql>
<!--tEmployeeProjectBelongDept简单分页查询-->
<select id="getTEmployeeProjectBelongDeptPage"
resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeProjectScpVO">
select
a.EMP_NAME empName
,a.EMP_IDCARD empIdcard
,e.EMP_PHONE empPhone
,b.emp_deptname empDeptname
,a.POST post
,if(a.PROJECT_STATUS=0,'在职','离职') projectStatus
,if(a.PROJECT_STATUS=0,DATE_FORMAT(a.ENJOIN_DATE,'%Y-%m-%d'),DATE_FORMAT(a.LEAVE_TIME,'%Y-%m-%d')) enjoinDateAndLeaveTime
,a.CONTRACT_STATUS contractStatus
,a.INSURANCE_STATUS insuranceStatus
from t_employee_project a
LEFT JOIN t_employee_info e on a.emp_id=e.id
LEFT JOIN t_employee_project_belong_dept b on a.id=b.id
<where>
a.DELETE_FLAG ='0'
<include refid="tEmployeeProjectBelongDept_where"/>
</where>
</select>
<!-- 导出的条数 -->
<select id="getTEmployeeProjectBelongDeptCount" resultType="java.lang.Integer">
select
count(1)
from t_employee_project a
LEFT JOIN t_employee_info e on a.emp_id=e.id
LEFT JOIN t_employee_project_belong_dept b on a.id=b.id
<where>
a.DELETE_FLAG ='0'
<include refid="tEmployeeProjectBelongDept_where"/>
</where>
</select>
<!-- 导出的数据 -->
<select id="getTEmployeeProjectBelongDeptList"
resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeProjectScpVO">
select
a.EMP_NAME empName
,a.EMP_IDCARD empIdcard
,e.EMP_PHONE empPhone
,b.emp_deptname empDeptname
,a.POST post
,if(a.PROJECT_STATUS=0,'在职','离职') projectStatus
,if(a.PROJECT_STATUS=0,DATE_FORMAT(a.ENJOIN_DATE,'%Y-%m-%d'),DATE_FORMAT(a.LEAVE_TIME,'%Y-%m-%d'))
enjoinDateAndLeaveTime
,a.CONTRACT_STATUS contractStatus
,a.INSURANCE_STATUS insuranceStatus
from t_employee_project a
LEFT JOIN t_employee_info e on a.emp_id=e.id
LEFT JOIN t_employee_project_belong_dept b on a.id=b.id
<where>
a.DELETE_FLAG ='0'
<include refid="tEmployeeProjectBelongDept_where"/>
</where>
<if test="tEmployeeProjectBelongDept != null">
<if test="tEmployeeProjectBelongDept.limitStart != null">
limit #{tEmployeeProjectBelongDept.limitStart},#{tEmployeeProjectBelongDept.limitEnd}
</if>
</if>
</select>
<!-- 获取部门下花名册总数 -->
<select id="getDeptCount" resultType="java.lang.Integer">
select count(1)
from t_employee_project_belong_dept b
LEFT JOIN t_employee_project a on b.id = a.id
<where>
a.DELETE_FLAG ='0' and ((a.PROJECT_SOURCE = '1' and a.STATUS = 1) or a.PROJECT_SOURCE != '1')
<if test="tEmployeeProjectBelongDept.deptId != null and tEmployeeProjectBelongDept.deptId.trim() != ''">
AND a.DEPT_ID = #{tEmployeeProjectBelongDept.deptId}
</if>
<if test="tEmployeeProjectBelongDept.empDeptId != null and tEmployeeProjectBelongDept.empDeptId.trim() != ''">
AND b.emp_deptid = #{tEmployeeProjectBelongDept.empDeptId}
</if>
</where>
</select>
<!-- 根据权限获取对应部门ID下的花名册总数Map -->
<select id="getDeptCountMap" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.TEmployeeProjectBelongDeptSearchVo">
select emp_deptid as empDeptId, count(emp_deptid) as empNum
from t_employee_project_belong_dept b
LEFT JOIN t_employee_project a on b.id = a.id
<where>
a.DELETE_FLAG ='0' and ((a.PROJECT_SOURCE = '1' and a.STATUS = 1) or a.PROJECT_SOURCE != '1')
<if test="deptId != null and deptId.trim() != ''">
AND a.DEPT_ID = #{deptId}
</if>
<if test="departIdSet != null and departIdSet.size > 0">
AND b.emp_deptid in
<foreach item="idStr" index="index" collection="departIdSet" open="(" separator=","
close=")">
#{idStr}
</foreach>
</if>
</where>
group by emp_deptid
</select>
<!-- 没有关联部门的花名册总数 -->
<select id="getNoneDeptCount" resultType="java.lang.Integer">
select count(1)
from t_employee_project a
LEFT JOIN t_employee_project_belong_dept b on a.id=b.id
<where>
a.DELETE_FLAG ='0' and b.id is null
<if test="tEmployeeProjectBelongDept.deptId != null and tEmployeeProjectBelongDept.deptId.trim() != ''">
AND a.DEPT_ID = #{tEmployeeProjectBelongDept.deptId}
</if>
</where>
</select>
</mapper>