Commit 6f8bfd20 by yubin

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/resources/mybatis/mappers/standard/jilinsscgsdp/KeyDmUserDao.xml
parents 6063f48a adb0ad83
...@@ -32,8 +32,10 @@ public class KeyDmBorrowServiceImpl { ...@@ -32,8 +32,10 @@ public class KeyDmBorrowServiceImpl {
private final String detailNamespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmBorrowDetail."; private final String detailNamespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmBorrowDetail.";
private final String materialNamespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmMaterialLog."; private final String materialNamespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmMaterialLog.";
@ApiOperation(value = "领用申请列表", desc = "分页查询") @ApiOperation(value = "领用申请列表", desc = "分页查询")
public Page<Map<String, Object>> selectList(Page<Map<String, Object>> map) { public Page<Map<String, Object>> selectList(Map<String, Object> map) {
if (map == null) map = new Page<>(); if (map == null) map = new HashMap<>();
Map<String, Object> user = (Map<String, Object>) map.get("_user");
map.put("user", user);
return commonService.findPage(namespace + "selectList", map); return commonService.findPage(namespace + "selectList", map);
} }
...@@ -50,6 +52,7 @@ public class KeyDmBorrowServiceImpl { ...@@ -50,6 +52,7 @@ public class KeyDmBorrowServiceImpl {
if (map == null) map = new HashMap<>(); if (map == null) map = new HashMap<>();
return commonService.findPage(namespace + "selectHistoryList", map); return commonService.findPage(namespace + "selectHistoryList", map);
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@ApiOperation(value = "保存申请(含明细)", desc = "新增或修改申请") @ApiOperation(value = "保存申请(含明细)", desc = "新增或修改申请")
public String save(Map<String, Object> map) { public String save(Map<String, Object> map) {
......
package com.scpyun.platform.jilinsscgsdp.service.impl;
import com.scpyun.base.core.annotation.Api;
import com.scpyun.base.core.annotation.ApiOperation;
import com.scpyun.base.core.exception.CustomException;
import com.scpyun.base.db.service.CommonService;
import com.scpyun.platform.jilinsscgsdp.utils.DataScopeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Api("统计服务")
@Service("keyDmStats")
public class KeyDmStatsServiceImpl {
@Autowired
private CommonService commonService;
private final String namespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmStats.";
@ApiOperation(value = "使用统计", desc = "统计各部门领用量")
public List<Map<String, Object>> selectUsageStats(Map<String, Object> map) {
if (map == null) map = new HashMap<>();
Map<String, Object> user = (Map<String, Object>) map.get("_user");
Map<String, String> pos = DataScopeUtil.getPosition(user);
return commonService.findList(namespace + "selectUsageStats", map);
}
@ApiOperation(value = "使用明细", desc = "查询使用明细")
public List<Map<String, Object>> selectUsageDetails(Map<String, Object> map) {
if (map == null) map = new HashMap<>();
return commonService.findList(namespace + "selectUsageDetails", map);
}
@ApiOperation(value = "工作量统计", desc = "统计人员工作量")
public List<Map<String, Object>> selectWorkloadStats(Map<String, Object> map) {
if (map == null) map = new HashMap<>();
return commonService.findList(namespace + "selectWorkloadStats", map);
}
@ApiOperation(value = "工作量明细", desc = "工作量明细")
public List<Map<String, Object>> selectWorkloadDetails(Map<String, Object> map) {
if (map == null) map = new HashMap<>();
return commonService.findList(namespace + "selectWorkloadDetails", map);
}
}
...@@ -370,4 +370,31 @@ public class KeyDmUserCategoryServiceImpl { ...@@ -370,4 +370,31 @@ public class KeyDmUserCategoryServiceImpl {
return SUCCESS; return SUCCESS;
} }
// ===== 统计服务 =====
@ApiOperation(value = "使用统计", desc = "统计各部门领用量")
public List<Map<String, Object>> selectUsageStats(Map<String, Object> map) {
if (map == null) map = new HashMap<>();
// Map<String, Object> user = (Map<String, Object>) map.get("_user");
// Map<String, String> pos = DataScopeUtil.getPosition(user);
return commonService.findList(namespace + "selectUsageStats", map);
}
@ApiOperation(value = "使用明细", desc = "查询使用明细")
public List<Map<String, Object>> selectUsageDetails(Map<String, Object> map) {
if (map == null) map = new HashMap<>();
return commonService.findList(namespace + "selectUsageDetails", map);
}
@ApiOperation(value = "工作量统计", desc = "统计人员工作量")
public List<Map<String, Object>> selectWorkloadStats(Map<String, Object> map) {
if (map == null) map = new HashMap<>();
return commonService.findList(namespace + "selectWorkloadStats", map);
}
@ApiOperation(value = "工作量明细", desc = "工作量明细")
public List<Map<String, Object>> selectWorkloadDetails(Map<String, Object> map) {
if (map == null) map = new HashMap<>();
return commonService.findList(namespace + "selectWorkloadDetails", map);
}
} }
...@@ -6,15 +6,22 @@ ...@@ -6,15 +6,22 @@
SELECT * FROM jl_key_dm_borrow_application SELECT * FROM jl_key_dm_borrow_application
<where> <where>
is_used = 1 is_used = 1
and applicant_id = #{params.user.id}
<if test="params.params.applicant_name != null and params.params.applicant_name != ''"> <if test="params.params.applicant_name != null and params.params.applicant_name != ''">
AND applicant_name LIKE CONCAT('%', #{params.params.applicant_name}, '%') AND applicant_name LIKE CONCAT('%', #{params.params.applicant_name}, '%')
</if> </if>
<if test="params.params.application_no != null and params.params.application_no != ''"> <if test="params.params.department_name != null and params.params.department_name != ''">
AND application_no LIKE CONCAT('%', #{params.params.application_no}, '%') AND department_name LIKE CONCAT('%', #{params.params.department_name}, '%')
</if> </if>
<if test="params.params.approval_status != null"> <if test="params.params.approval_status != null">
AND approval_status = #{params.params.approval_status} AND approval_status = #{params.params.approval_status}
</if> </if>
<if test="params.params.startDate != null">
AND submit_time &gt;= #{params.params.startDate}
</if>
<if test="params.params.endDate != null">
AND submit_time &lt;= #{params.params.endDate}
</if>
</where> </where>
ORDER BY create_time DESC ORDER BY create_time DESC
</select> </select>
...@@ -29,21 +36,27 @@ ...@@ -29,21 +36,27 @@
ORDER BY submit_time DESC ORDER BY submit_time DESC
</select> </select>
<select id="selectHistoryList" parameterType="page" resultType="map"> <select id="selectHistoryList" parameterType="map" resultType="map">
SELECT * FROM jl_key_dm_borrow_application SELECT * FROM jl_key_dm_borrow_application
<where> <where>
is_used = 1 is_used = 1
<if test="params.applicant_name != null and params.applicant_name != ''"> <if test="params.params.applicant_name != null and params.params.applicant_name != ''">
AND applicant_name LIKE CONCAT('%', #{params.applicant_name}, '%') AND applicant_name LIKE CONCAT('%', #{params.params.applicant_name}, '%')
</if> </if>
<if test="params.application_no != null and params.application_no != ''"> <if test="params.params.department_name != null and params.params.department_name != ''">
AND application_no LIKE CONCAT('%', #{params.application_no}, '%') AND department_name LIKE CONCAT('%', #{params.params.department_name}, '%')
</if> </if>
<if test="params.approval_status != null and params.approval_status != ''"> <if test="params.params.approval_status != null">
AND approval_status = #{params.approval_status} AND approval_status = #{params.params.approval_status}
</if>
<if test="params.params.startDate != null">
AND submit_time &gt;= #{params.params.startDate}
</if>
<if test="params.params.endDate != null">
AND submit_time &lt;= #{params.params.endDate}
</if> </if>
</where> </where>
ORDER BY approval_complete_time DESC ORDER BY create_time DESC
</select> </select>
<select id="getById" parameterType="map" resultType="map"> <select id="getById" parameterType="map" resultType="map">
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//oos.juyouhx.com//DTD Mapper 3.0//EN" "http://oss.juyouhx.com/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.scpyun.platform.standard.jilinsscgsdp.keyDmStats" name="统计">
<!-- 使用统计:按部门、物料统计领用数量 -->
<select id="selectUsageStats" parameterType="map" resultType="map">
SELECT
ba.department_id,
ba.department_name,
ad.material_id,
ad.material_name,
sum(ad.apply_quantity)-sum(ad.returned_quantity) as total_quantity
from jl_key_dm_borrow_application_detail ad
LEFT JOIN jl_key_dm_borrow_application ba on ad.application_id = ba.id
LEFT JOIN jl_key_dm_material m on ad.material_id = m.id
LEFT JOIN sys_office so on so.id = ba.department_id
<where>
AND ba.is_used=1 and ad.is_used=1 and ba.approval_status = 9
<if test="start != null and start != ''">
AND ba.create_time &gt; #{start}
</if>
<if test="end != null and end != ''">
AND ba.create_time &lt; #{end}
</if>
<if test="material != null and material != ''">
AND (ad.material_name LIKE CONCAT('%', #{material}, '%') OR ad.material_code LIKE CONCAT('%', #{material}, '%'))
</if>
<if test="dep != null and dep != ''">
AND ad.department_name LIKE CONCAT('%', #{dep}, '%')
</if>
</where>
GROUP BY ba.department_id, ba.department_name, ad.material_id,ad.material_name
ORDER BY total_quantity DESC
</select>
<!-- 使用明细 -->
<select id="selectUsageDetails" parameterType="map" resultType="map">
SELECT
ba.applicant_name user_name,
ba.department_id,
ba.department_name,
ad.material_id,
ad.material_name,
ad.apply_quantity,
ad.returned_quantity
from jl_key_dm_borrow_application_detail ad
LEFT JOIN jl_key_dm_borrow_application ba on ad.application_id = ba.id
LEFT JOIN jl_key_dm_material m on ad.material_id = m.id
LEFT JOIN sys_office so on so.id = ba.department_id
<where>
AND ba.is_used=1 and ad.is_used=1 and ba.approval_status = 9
<if test="start != null and start != ''">
AND ba.create_time &gt; #{start}
</if>
<if test="end != null and end != ''">
AND ba.create_time &lt; #{end}
</if>
<if test="material != null and material != ''">
AND ad.material_id = #{material}
</if>
<if test="department != null and department != ''">
AND ba.department_id = #{department}
</if>
</where>
GROUP BY ba.department_id, ba.department_name, ad.material_id,ad.material_name
ORDER BY apply_quantity DESC
</select>
<!-- 工作量统计:合并多表数据后按人员统计 -->
<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
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>
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
</select>
<!-- 工作量明细:按类型返回对应明细 -->
<select id="selectWorkloadDetails" parameterType="map" resultType="map">
<choose>
<when test="type == 'leave'">
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 STATUS != 0
<if test="start != null and start != ''">
AND create_time &gt; #{start}
</if>
<if test="end != null and end != ''">
AND create_time &lt; #{end}
</if>
</where>
ORDER BY create_time DESC
</when>
<when test="type == 'inventory'">
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>
AND b.is_used = 1 AND b.approval_status != 0 AND b.applicant_id = #{user_id}
<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>
ORDER BY b.submit_time DESC
</when>
<otherwise>
SELECT 1 AS dummy
</otherwise>
</choose>
</select>
</mapper>
...@@ -360,7 +360,7 @@ ...@@ -360,7 +360,7 @@
AND m.category_id = #{params.category_id} AND m.category_id = #{params.category_id}
</if> </if>
</where> </where>
ORDER BY m.order_no ASC, m.create_time DESC ORDER BY c.order_no,m.order_no ASC, m.create_time DESC
</select> </select>
<select id="findMaterialList" parameterType="map" resultType="map"> <select id="findMaterialList" parameterType="map" resultType="map">
...@@ -723,5 +723,169 @@ ...@@ -723,5 +723,169 @@
<select id="findLeader" parameterType="String" resultType="String"> <select id="findLeader" parameterType="String" resultType="String">
select leader from jl_key_dm_user where id = #{param} select leader from jl_key_dm_user where id = #{param}
</select> </select>
<!-- //统计部分 -->
<!-- 使用统计:按部门、物料统计领用数量 -->
<select id="selectUsageStats" parameterType="map" resultType="map">
SELECT
ba.department_id,
ba.department_name,
ad.material_id,
ad.material_name,
sum(ad.apply_quantity)-sum(ad.returned_quantity) as total_quantity
from jl_key_dm_borrow_application_detail ad
LEFT JOIN jl_key_dm_borrow_application ba on ad.application_id = ba.id
LEFT JOIN jl_key_dm_material m on ad.material_id = m.id
LEFT JOIN sys_office so on so.id = ba.department_id
<where>
AND ba.is_used=1 and ad.is_used=1 and ba.approval_status = 9
<if test="start != null and start != ''">
AND ba.create_time &gt; #{start}
</if>
<if test="end != null and end != ''">
AND ba.create_time &lt; #{end}
</if>
<if test="material != null and material != ''">
AND (ad.material_name LIKE CONCAT('%', #{material}, '%') OR ad.material_code LIKE CONCAT('%', #{material}, '%'))
</if>
<if test="dep != null and dep != ''">
AND ad.department_name LIKE CONCAT('%', #{dep}, '%')
</if>
</where>
GROUP BY ba.department_id, ba.department_name, ad.material_id,ad.material_name
ORDER BY total_quantity DESC
</select>
<!-- 使用明细 -->
<select id="selectUsageDetails" parameterType="map" resultType="map">
SELECT
ba.applicant_name user_name,
ba.department_id,
ba.department_name,
ad.material_id,
ad.material_name,
ad.apply_quantity,
ad.returned_quantity
from jl_key_dm_borrow_application_detail ad
LEFT JOIN jl_key_dm_borrow_application ba on ad.application_id = ba.id
LEFT JOIN jl_key_dm_material m on ad.material_id = m.id
LEFT JOIN sys_office so on so.id = ba.department_id
<where>
AND ba.is_used=1 and ad.is_used=1 and ba.approval_status = 9
<if test="start != null and start != ''">
AND ba.create_time &gt; #{start}
</if>
<if test="end != null and end != ''">
AND ba.create_time &lt; #{end}
</if>
<if test="material != null and material != ''">
AND ad.material_id = #{material}
</if>
<if test="department != null and department != ''">
AND ba.department_id = #{department}
</if>
</where>
GROUP BY ba.department_id, ba.department_name, ad.material_id,ad.material_name
ORDER BY apply_quantity DESC
</select>
<!-- 工作量统计:合并多表数据后按人员统计 -->
<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
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>
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
</select>
<!-- 工作量明细:按类型返回对应明细 -->
<select id="selectWorkloadDetails" parameterType="map" resultType="map">
<choose>
<when test="type == 'leave'">
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 STATUS != 0
<if test="start != null and start != ''">
AND create_time &gt; #{start}
</if>
<if test="end != null and end != ''">
AND create_time &lt; #{end}
</if>
</where>
ORDER BY create_time DESC
</when>
<when test="type == 'inventory'">
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>
AND b.is_used = 1 AND b.approval_status != 0 AND b.applicant_id = #{user_id}
<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>
ORDER BY b.submit_time DESC
</when>
<otherwise>
SELECT 1 AS dummy
</otherwise>
</choose>
</select>
</mapper> </mapper>
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
u.phone, u.phone,
u.mobile, u.mobile,
u.birthday, u.birthday,
u.in_work_time,
u.leave_time, u.leave_time,
DATE_FORMAT(u.in_work_time,'%Y-%m-%d') in_work_time,
u.leader, u.leader,
u.leader_name, u.leader_name,
u.is_used, u.is_used,
...@@ -112,13 +112,14 @@ ...@@ -112,13 +112,14 @@
ORDER BY o.grade DESC ORDER BY o.grade DESC
</select> </select>
<!-- 从 sys_user 查询指定机构(及下属机构)的用户,office_code 为机构 code 字段 --> <!-- 从 sys_user 查询指定机构(及下属机构)的用户,office_code 为机构 code 字段, 注:内部控制只有长春市由此功能,功能只覆盖长春市范围 -->
<select id="selectSysUserByOfficeCode" parameterType="map" resultType="map"> <select id="selectSysUserByOfficeCode" parameterType="map" resultType="map">
SELECT su.* SELECT su.*
FROM sys_user su FROM sys_user su
WHERE su.office_id IN ( WHERE su.office_id IN (
SELECT so.id FROM sys_office so SELECT so.id FROM sys_office so
WHERE so.parent_ids LIKE CONCAT(#{parentIds}, '%') OR so.id = #{_user.company_id} WHERE del_flag=0 AND so.parent_ids LIKE CONCAT(#{parentIds}, '%') OR so.id = #{_user.company_id}
AND (id='220100000000' OR parent_ids like '0,220000000000,220100000000%')
) )
AND (su.del_flag IS NULL OR su.del_flag = '0') AND (su.del_flag IS NULL OR su.del_flag = '0')
</select> </select>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论