Commit d1b4d4ab by yubin

修改

parent d0f62691
...@@ -61,7 +61,7 @@ public class KeyDmUserServiceImpl { ...@@ -61,7 +61,7 @@ public class KeyDmUserServiceImpl {
// 3. 优化if判断:先判断isLeave是否为null,再调用equals;修正leaveTime的判断逻辑 // 3. 优化if判断:先判断isLeave是否为null,再调用equals;修正leaveTime的判断逻辑
// 若要判断leaveTime是否为"null"字符串或实际null,可补充判断 // 若要判断leaveTime是否为"null"字符串或实际null,可补充判断
if (("1".equals(isLeave)) || (leaveTime == null || "".equals(leaveTime) || "null".equals(leaveTime))) { if (("1".equals(isLeave)) && (leaveTime == null || "".equals(leaveTime) || "null".equals(leaveTime))) {
map.put("leave_time", LocalDateTime.now()); map.put("leave_time", LocalDateTime.now());
} }
Map<String, Object> exists = commonService.getObject(namespace + "getById", map); Map<String, Object> exists = commonService.getObject(namespace + "getById", map);
......
...@@ -15,10 +15,12 @@ ...@@ -15,10 +15,12 @@
AND user_name LIKE CONCAT('%', #{params.user_name}, '%') AND user_name LIKE CONCAT('%', #{params.user_name}, '%')
</if> </if>
<!-- 支持按起止时间区间查询(来自 params.params.start_time / params.params.end_time):返回与区间有交集的请假记录 --> <!-- 支持按起止时间区间查询(来自 params.params.start_time / params.params.end_time):返回与区间有交集的请假记录 -->
<if test="params.params != null and params.params.start_time != null and params.params.start_time != '' and params.params.end_time != null and params.params.end_time != ''"> <if test="params.params != null and params.params.start_time != null and params.params.start_time != ''">
AND submit_time &lt; #{params.params.end_time}
AND submit_time &gt;= #{params.params.start_time} AND submit_time &gt;= #{params.params.start_time}
</if> </if>
<if test="params.params != null and params.params.end_time != null and params.params.end_time != ''">
AND submit_time &lt; #{params.params.end_time}
</if>
<!-- 支持按状态过滤(来自 params.params.status,例如: 0,1,2,9,-1) --> <!-- 支持按状态过滤(来自 params.params.status,例如: 0,1,2,9,-1) -->
<if test="params.params != null and params.params.status != null and params.params.status != ''"> <if test="params.params != null and params.params.status != null and params.params.status != ''">
AND status = #{params.params.status} AND status = #{params.params.status}
...@@ -68,11 +70,13 @@ ...@@ -68,11 +70,13 @@
<if test="params._user.id != null and params._user.id != ''"> <if test="params._user.id != null and params._user.id != ''">
AND a.user_id LIKE CONCAT('%', #{params._user.id}, '%') AND a.user_id LIKE CONCAT('%', #{params._user.id}, '%')
</if> </if>
<!-- 支持按起止时间区间查询(来自 params.params.start_time / params.params.end_time) --> <!-- 支持按起止时间查询(来自 params.params.start_time / params.params.end_time):可单独填写一个时间进行查询 -->
<if test="params.params != null and params.params.start_time != null and params.params.start_time != '' and params.params.end_time != null and params.params.end_time != ''"> <if test="params.params != null and params.params.start_time != null and params.params.start_time != ''">
AND a.start_time &lt; #{params.params.end_time}
AND a.end_time &gt;= #{params.params.start_time} AND a.end_time &gt;= #{params.params.start_time}
</if> </if>
<if test="params.params != null and params.params.end_time != null and params.params.end_time != ''">
AND a.start_time &lt; #{params.params.end_time}
</if>
<!-- 支持按状态过滤(来自 params.params.status) --> <!-- 支持按状态过滤(来自 params.params.status) -->
<if test="params.params != null and params.params.status != null and params.params.status != ''"> <if test="params.params != null and params.params.status != null and params.params.status != ''">
AND a.status = #{params.params.status} AND a.status = #{params.params.status}
...@@ -118,11 +122,13 @@ ...@@ -118,11 +122,13 @@
<if test="params._user.id != null and params._user.id != ''"> <if test="params._user.id != null and params._user.id != ''">
AND r.approver_id = #{params._user.id} AND r.approver_id = #{params._user.id}
</if> </if>
<!-- 支持按起止时间区间查询(来自 params.params.start_time / params.params.end_time) --> <!-- 支持按起止时间查询(来自 params.params.start_time / params.params.end_time):可单独填写一个时间进行查询 -->
<if test="params.params != null and params.params.start_time != null and params.params.end_time != null"> <if test="params.params != null and params.params.start_time != null and params.params.start_time != ''">
AND a.start_time &lt; #{params.params.end_time}
AND a.end_time &gt;= #{params.params.start_time} AND a.end_time &gt;= #{params.params.start_time}
</if> </if>
<if test="params.params != null and params.params.end_time != null and params.params.end_time != ''">
AND a.start_time &lt; #{params.params.end_time}
</if>
<!-- 支持按状态过滤(来自 params.params.status) --> <!-- 支持按状态过滤(来自 params.params.status) -->
<if test="params.params != null and params.params.status != null and params.params.status != ''"> <if test="params.params != null and params.params.status != null and params.params.status != ''">
AND a.status = #{params.params.status} AND a.status = #{params.params.status}
...@@ -146,11 +152,13 @@ ...@@ -146,11 +152,13 @@
<if test="_user != null and _user.id != null and _user.id != ''"> <if test="_user != null and _user.id != null and _user.id != ''">
AND r.approver_id = #{_user.id} AND r.approver_id = #{_user.id}
</if> </if>
<!-- 支持按起止时间区间查询 --> <!-- 支持按起止时间查询:可单独填写一个时间进行查询 -->
<if test="params != null and params.params != null and params.params.start_time != null and params.params.end_time != null"> <if test="params != null and params.params != null and params.params.start_time != null and params.params.start_time != ''">
AND a.start_time &lt; #{params.params.end_time}
AND a.end_time &gt;= #{params.params.start_time} AND a.end_time &gt;= #{params.params.start_time}
</if> </if>
<if test="params != null and params.params != null and params.params.end_time != null and params.params.end_time != ''">
AND a.start_time &lt; #{params.params.end_time}
</if>
<if test="params != null and params.params != null and params.params.status != null and params.params.status != ''"> <if test="params != null and params.params != null and params.params.status != null and params.params.status != ''">
AND a.status = #{params.params.status} AND a.status = #{params.params.status}
</if> </if>
...@@ -187,11 +195,13 @@ ...@@ -187,11 +195,13 @@
And r.is_used = 1 And r.is_used = 1
AND r.id != #{leave_id} AND r.id != #{leave_id}
AND r.leave_id = (select leave_id from jl_key_dm_leave_approval_record where id = #{leave_id} ) AND r.leave_id = (select leave_id from jl_key_dm_leave_approval_record where id = #{leave_id} )
<!-- 可选过滤:按起止时间和状态 --> <!-- 可选过滤:按起止时间和状态,可单独填写一个时间进行查询 -->
<if test="params.start != null and params.end != null"> <if test="params.start != null and params.start != ''">
AND a.start_time &lt; #{params.end}
AND a.end_time &gt;= #{params.start} AND a.end_time &gt;= #{params.start}
</if> </if>
<if test="params.end != null and params.end != ''">
AND a.start_time &lt; #{params.end}
</if>
<if test="params.status != null and params.status != ''"> <if test="params.status != null and params.status != ''">
AND a.status = #{params.status} AND a.status = #{params.status}
</if> </if>
...@@ -277,12 +287,11 @@ ...@@ -277,12 +287,11 @@
<where> <where>
AND is_used = 1 AND is_used = 1
AND status = 9 AND status = 9
<if test="start != null and end != null"> <if test="start != null and start != ''">
And start_time &lt; #{end} AND end_time >= #{start}
AND end_time >= #{start};
</if> </if>
<if test="department != null and department != ''"> <if test="end != null and end != ''">
AND (department_id = #{department} OR department_name LIKE CONCAT('%', #{department}, '%')) And start_time &lt; #{end}
</if> </if>
</where> </where>
GROUP BY user_id, user_name, department_id, department_name GROUP BY user_id, user_name, department_id, department_name
......
...@@ -29,28 +29,23 @@ ...@@ -29,28 +29,23 @@
SELECT a.* SELECT a.*
FROM jl_key_dm_leave_application a FROM jl_key_dm_leave_application a
LEFT JOIN jl_key_dm_leave_approval_record r ON a.id = r.leave_id LEFT JOIN jl_key_dm_leave_approval_record r ON a.id = r.leave_id
LEFT JOIN jl_key_dm_user u ON r.approver_id = u.id
<where> <where>
a.is_used = 1 a.is_used = 1
AND ( AND a.status != 0
(r.node_type = 1 AND u.office_id = #{params._user.company_id}
<if test="params._user.id != null and params._user.id != ''"> AND r.node_type = 1
AND r.approver_id = #{params._user.id} <!-- 支持按起止时间查询:可单独填写一个时间进行查询 -->
</if> <if test="params.params != null and params.params.start_time != null and params.params.start_time != ''">
) AND a.end_time &gt;= #{params.params.start_time}
OR
(r.node_type = 1 AND r.transfer_to_id = #{params._user.id})
)
<if test="params.approver_name != null and params.approver_name != ''">
AND a.approver_name LIKE CONCAT('%', #{params.approver_name}, '%')
</if> </if>
<!-- 支持按起止时间区间查询(来自 params.params.start_time / params.params.end_time):返回与区间有交集的请假记录 --> <if test="params.params != null and params.params.end_time != null and params.params.end_time != ''">
<if test="params.params != null and params.params.start_time != null and params.params.start_time != '' and params.params.end_time != null and params.params.end_time != ''">
AND a.start_time &lt; #{params.params.end_time} AND a.start_time &lt; #{params.params.end_time}
AND a.end_time &gt;= #{params.params.start_time}
</if> </if>
<!-- 支持按状态过滤(来自 params.params.status) --> <!-- 支持按状态过滤(来自 params.params.status) -->
<if test="params.params != null and params.params.status != null and params.params.status != ''"> <if test="params.params != null and params.params.approver_name != null and params.params.approver_name != ''">
AND a.status = #{params.params.status} AND (r.transfer_to_name LIKE CONCAT('%', #{params.params.approver_name}, '%')
OR r.approver_name LIKE CONCAT('%', #{params.params.approver_name}, '%'))
</if> </if>
</where> </where>
ORDER BY FIELD(a.status, 1) DESC, a.submit_time DESC ORDER BY FIELD(a.status, 1) DESC, a.submit_time DESC
...@@ -120,7 +115,8 @@ ...@@ -120,7 +115,8 @@
status = 2, status = 2,
approver_result = 0, approver_result = 0,
update_by = #{_user.id}, update_by = #{_user.id},
update_time = NOW() update_time = NOW(),
approver_time = NOW()
<!-- 条件判断:approver_id 非空时才更新 --> <!-- 条件判断:approver_id 非空时才更新 -->
<if test="approver_id != null and approver_id != ''"> <if test="approver_id != null and approver_id != ''">
,transfer_to_id = #{approver_id} ,transfer_to_id = #{approver_id}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论