Commit c5829391 by yubin

Merge remote-tracking branch 'origin/master'

parents 4830f5a8 eb21f58e
......@@ -38,6 +38,11 @@ public class KeyDmUserCategoryServiceImpl {
return commonService.findList(namespace + "selectPermissionConfigList", null);
}
@ApiOperation(value = "获取人员权限配置列表", desc = "从字典获取权限并关联用户")
public List<Map<String, Object>> selectUserDmPermissionList(Map<String, Object> map) {
return commonService.findList(namespace + "selectUserDmPermissionList", map);
}
@ApiOperation(value = "保存权限用户配置", desc = "保存权限对应的用户配置")
public String savePermissionUsers(Map<String, Object> map) {
if (map == null || map.get("permission_code") == null) {
......
......@@ -12,7 +12,7 @@
<if test="params.params.application_no != null and params.params.application_no != ''">
AND application_no LIKE CONCAT('%', #{params.params.application_no}, '%')
</if>
<if test="params.params.approval_status != null and params.params.approval_status != ''">
<if test="params.params.approval_status != null">
AND approval_status = #{params.params.approval_status}
</if>
</where>
......@@ -74,7 +74,7 @@
</update>
<update id="approve" parameterType="map">
UPDATE jl_key_dm_borrow_application SET approval_status = 9, approval_time = NOW(), issue_status = 1, update_by = #{_user.id}, update_time = NOW() WHERE id = #{id}
UPDATE jl_key_dm_borrow_application SET approval_status = 9, approval_time = NOW(), issue_time = NOW(), issue_status = 1, update_by = #{_user.id}, update_time = NOW() WHERE id = #{id}
</update>
<update id="reject" parameterType="map">
......@@ -94,16 +94,37 @@
FROM jl_key_dm_borrow_application WHERE id = #{id}
</insert>
<select id="selectInventoryByMaterialId" parameterType="map" resultType="map">
select i.*,m.can_borrow
from jl_key_dm_inventory as i
left join jl_key_dm_material as m
on m.id = i.material_id
where material_id = #{material_id}
</select>
<!-- 更新库存:根据申请明细扣减可用库存(mapper 内部实现以事务执行) -->
<update id="updateInventoryTotalQuantity" parameterType="map">
<!-- 简化:调用存储过程或在 mapper 中实现逐条更新 -->
<!-- 实际实现依赖于业务,留给 mapper/服务调用具体 SQL -->
update jl_key_dm_inventory
set total_quantity = total_quantity - #{apply_quantity}
where material_id = #{material_id}
</update>
<!-- 更新库存:根据申请明细扣减可用库存(mapper 内部实现以事务执行) -->
<update id="updateInventoryByApplication" parameterType="map">
<update id="updateInventoryBorrowedQuantity" parameterType="map">
<!-- 简化:调用存储过程或在 mapper 中实现逐条更新 -->
<!-- 实际实现依赖于业务,留给 mapper/服务调用具体 SQL -->
update jl_key_dm_inventory set
update jl_key_dm_inventory
set borrowed_quantity = borrowed_quantity + #{apply_quantity}
where material_id = #{material_id}
</update>
<!-- 插入日志 -->
<insert id="insertMaterialLogByApplication" parameterType="map">
<!-- 简化:实现者可在业务层调用单条插入,此处为占位 -->
insert into jl_key_dm_material_log()
</insert>
<select id="selectLogsByApplicationId" parameterType="map">
......
......@@ -11,7 +11,11 @@
</insert>
<select id="selectDetailsByApplicationId" parameterType="map" resultType="map">
SELECT * FROM jl_key_dm_borrow_application_detail WHERE application_id = #{id} AND is_used = 1 ORDER BY create_time ASC
SELECT bd.*,m.category_id
FROM jl_key_dm_borrow_application_detail as bd
left join jl_key_dm_material as m
on m.id = bd.material_id
WHERE bd.application_id = #{id} AND bd.is_used = 1 ORDER BY bd.create_time ASC
</select>
</mapper>
......
......@@ -111,7 +111,11 @@
</insert>
<select id="selectLogsByInboundId" parameterType="map" resultType="map">
SELECT * FROM jl_key_dm_material_log WHERE relation_id = #{id} AND is_used = 1 ORDER BY create_time ASC
SELECT ml.*,m.material_name
FROM jl_key_dm_material_log as ml
left join jl_key_dm_material as m
on m.id = ml.material_id
WHERE ml.relation_id = #{id} AND ml.is_used = 1 ORDER BY ml.create_time ASC
</select>
</mapper>
......
......@@ -8,13 +8,18 @@
) VALUES
<foreach collection="details" item="item" separator=",">
(
UUID(),#{item.category_id},#{item.id},1,#{item.inbound_id},#{item.id},#{item.inbound_quantity},#{item.unit_price},#{item.total_amount},1,#{_user.id},NOW()
UUID(),#{item.category_id},#{item.material_id},#{op_type},#{id},#{item.material_id},#{item.apply_quantity},#{item.unit_price},#{item.total_amount},1,#{create_by},NOW()
)
</foreach>
</insert>
<select id="selectLogsByApplicationId" parameterType="map" resultType="map">
SELECT * FROM jl_key_dm_material_log WHERE relation_id = #{id} AND is_used = 1 ORDER BY create_time ASC
SELECT ml.*,m.material_name
FROM jl_key_dm_material_log as ml
left join jl_key_dm_material as m
on ml.material_id = m.id
WHERE relation_id = #{id}
AND ml.is_used = 1 ORDER BY ml.create_time ASC
</select>
</mapper>
......
......@@ -69,55 +69,59 @@
<!-- 工作量统计:合并多表数据后按人员统计 -->
<select id="selectWorkloadStats" parameterType="map" resultType="map">
SELECT uid AS user_id, uname AS user_name,
SUM(leave_app) AS leave_applications,
SUM(leave_approve) AS leave_approvals,
SUM(borrow_app) AS borrow_applications,
SUM(inbound_cnt) AS inbound_count,
SUM(leave_duration) AS leave_duration
SUM(leave_app) AS leave_applications,
SUM(leave_approve) AS leave_approvals,
SUM(borrow_app) AS borrow_applications,
SUM(inbound_cnt) AS inbound_count,
SUM(leave_duration) AS leave_duration
FROM (
SELECT l.user_id AS uid, l.user_name AS uname, 1 AS leave_app, 0 AS leave_approve, 0 AS borrow_app, 0 AS inbound_cnt, COALESCE(l.duration,0) AS leave_duration
FROM jl_key_dm_leave_application l
<where>
<if test="start != null and start != ''">
AND l.create_time &gt; #{start}
</if>
<if test="end != null and end != ''">
AND l.create_time &lt; #{end}
</if>
</where>
UNION ALL
SELECT r.approver_id AS uid, r.approver_name AS uname, 0, CASE WHEN r.approver_result = 1 THEN 1 ELSE 0 END, 0, 0, 0
FROM jl_key_dm_leave_approval_record r
<where>
<if test="start != null and start != ''">
AND r.approver_time &gt; #{start}
</if>
<if test="end != null and end != ''">
AND r.approver_time &lt; #{end}
</if>
</where>
UNION ALL
SELECT b.applicant_id AS uid, b.applicant_name AS uname, 0, 0, 1, 0, 0
FROM jl_key_dm_borrow_application b
<where>
<if test="start != null and start != ''">
AND b.create_time &gt; #{start}
</if>
<if test="end != null and end != ''">
AND b.create_time &lt; #{end}
</if>
</where>
UNION ALL
SELECT o.receiver_id AS uid, o.receiver_name AS uname, 0, 0, 0, 1, 0
FROM jl_key_dm_outbound_record o
<where>
<if test="start != null and start != ''">
AND o.create_time &gt; #{start}
</if>
<if test="end != null and end != ''">
AND o.create_time &lt; #{end}
</if>
</where>
SELECT l.user_id AS uid, l.user_name AS uname, 1 AS leave_app, 0 AS leave_approve, 0 AS borrow_app, 0 AS inbound_cnt, COALESCE(l.duration,0) AS leave_duration
FROM jl_key_dm_leave_application l
<where>
AND l.is_used = 1 AND l.STATUS != 0
<if test="start != null and start != ''">
AND l.start_time &gt; #{start}
</if>
<if test="end != null and end != ''">
AND l.start_time &lt; #{end}
</if>
</where>
UNION ALL
SELECT r.approver_id AS uid, r.approver_name AS uname, 0, CASE WHEN r.approver_result = 1 THEN 1 ELSE 0 END, 0, 0, 0
FROM jl_key_dm_leave_approval_record r
<where>
AND r.is_used = 1 AND r.STATUS = 2
<if test="start != null and start != ''">
AND r.approver_time &gt; #{start}
</if>
<if test="end != null and end != ''">
AND r.approver_time &lt; #{end}
</if>
</where>
UNION ALL
SELECT b.applicant_id AS uid, b.applicant_name AS uname, 0, 0, 1, 0, 0
FROM jl_key_dm_borrow_application b
<where>
AND b.is_used = 1 AND b.approval_status != 0
<if test="start != null and start != ''">
AND b.submit_time &gt; #{start}
</if>
<if test="end != null and end != ''">
AND b.submit_time &lt; #{end}
</if>
</where>
UNION ALL
SELECT ir.create_by AS uid, du.`name` AS uname, 0, 0, 0, 1, 0
FROM jl_key_dm_inbound_record ir LEFT JOIN jl_key_dm_user du on ir.create_by = du.id
<where>
AND ir.is_used = 1
<if test="start != null and start != ''">
AND ir.create_time &gt; #{start}
</if>
<if test="end != null and end != ''">
AND ir.create_time &lt; #{end}
</if>
</where>
) t
GROUP BY uid, uname
ORDER BY leave_applications DESC, borrow_applications DESC
......@@ -127,9 +131,9 @@
<select id="selectWorkloadDetails" parameterType="map" resultType="map">
<choose>
<when test="type == 'leave'">
SELECT id, user_id, user_name, start_time, end_time, duration, reason FROM jl_key_dm_leave_application
SELECT id, user_id, user_name, start_time, end_time, duration, reason, `status` FROM jl_key_dm_leave_application
<where>
AND user_id = #{user_id}
AND user_id = #{user_id} AND STATUS != 0
<if test="start != null and start != ''">
AND create_time &gt; #{start}
</if>
......@@ -140,19 +144,19 @@
ORDER BY create_time DESC
</when>
<when test="type == 'inventory'">
SELECT b.application_no, b.applicant_id, b.applicant_name, d.material_name, d.apply_quantity
SELECT b.application_no, b.applicant_id, b.applicant_name, d.material_name, b.approval_status, d.apply_quantity, d.returned_quantity,b.submit_time
FROM jl_key_dm_borrow_application_detail d
LEFT JOIN jl_key_dm_borrow_application b ON b.id = d.application_id
<where>
b.applicant_id = #{user_id}
AND b.is_used = 1 AND b.approval_status != 0 AND b.applicant_id = #{user_id}
<if test="start != null and start != ''">
AND b.create_time &gt; #{start}
AND b.submit_time &gt; #{start}
</if>
<if test="end != null and end != ''">
AND b.create_time &lt; #{end}
AND b.submit_time &lt; #{end}
</if>
</where>
ORDER BY b.create_time DESC
ORDER BY b.submit_time DESC
</when>
<otherwise>
SELECT 1 AS dummy
......
......@@ -48,6 +48,14 @@
)
</insert>
<!-- 获取人员日常管理权限列表 -->
<select id="selectUserDmPermissionList" resultType="map">
SELECT
pu.permission_code as code
FROM jl_key_dm_permission_user pu
WHERE pu.user_id = #{_user.id}
</select>
<!-- ===== 请假类型管理 ===== -->
<select id="selectLeaveTypeList" parameterType="page" resultType="map">
SELECT
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论