Commit 145e31b8 authored by nie'hong's avatar nie'hong

完善小程序工时统计

parent f8dd35c0
...@@ -20,4 +20,6 @@ public interface WorkDeptMapper extends BaseMapper<WorkDept> { ...@@ -20,4 +20,6 @@ public interface WorkDeptMapper extends BaseMapper<WorkDept> {
List<WorkDept> getDeptByCondition(Map<String, Object> map); List<WorkDept> getDeptByCondition(Map<String, Object> map);
List<OrganizationStructureDto> getAllDeptByAllCentre(); List<OrganizationStructureDto> getAllDeptByAllCentre();
WorkDept getById(Integer deptId);
} }
...@@ -80,10 +80,11 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> { ...@@ -80,10 +80,11 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> {
/** /**
* 获取上班日期集合 * 获取上班日期集合
* *
* @param firstDayOfMonth * @param date
* @param userId
* @return * @return
*/ */
List<Date> getDaysByDateAndStatus(@Param("firstDayOfMonth") Date firstDayOfMonth, @Param("userId") Integer userId); List<Date> getDaysByDateAndStatus(@Param("userId") Integer userId, @Param("date") Date date);
List<WorkTimeOrder> getAutoOrder(Integer autoExamine); List<WorkTimeOrder> getAutoOrder(Integer autoExamine);
...@@ -93,7 +94,7 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> { ...@@ -93,7 +94,7 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> {
/** /**
* 获取人员项目工时 * 获取人员项目工时
*/ */
List<UserWorkTimeStatisticsByProject> getUserProjectWorkTimeStatistics(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("isConclusion") Integer isConclusion, @Param("projectIds") List<Integer> projectIds, @Param("isAll") Boolean isAll); List<UserWorkTimeStatisticsByProject> getUserProjectWorkTimeStatistics(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projectIds") List<Integer> projectIds, @Param("isAll") Boolean isAll);
/** /**
* 根据工单状态获取填报条数 * 根据工单状态获取填报条数
...@@ -106,5 +107,5 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> { ...@@ -106,5 +107,5 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> {
List<MonthlyWorkingHoursStatistics> selectCountByTypeAndStatus(@Param("userId") Integer userId, @Param("firstDayOfMonth") Date firstDayOfMonth, @Param("status") Integer[] status); List<MonthlyWorkingHoursStatistics> selectCountByTypeAndStatus(@Param("userId") Integer userId, @Param("firstDayOfMonth") Date firstDayOfMonth, @Param("status") Integer[] status);
List<UserWorkTimeStatisticsByProject> selectListByType(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("isConclusion") Integer isConclusion, @Param("queryType") List<Integer> queryType, @Param("userIds") List<Integer> userIds, @Param("isAll") Boolean isAll); List<UserWorkTimeStatisticsByProject> selectListByType(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("queryType") List<Integer> queryType, @Param("userIds") List<Integer> userIds, @Param("isAll") Boolean isAll);
} }
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
</sql> </sql>
<sql id="cols_exclude_id"> <sql id="cols_exclude_id">
dept_name, create_time, modify_time dept_name,oa_dept_id,dept_manager_id,centre_id, create_time, modify_time
</sql> </sql>
<sql id="criteria"> <sql id="criteria">
...@@ -64,5 +64,11 @@ from work_centre c LEFT JOIN work_dept d ON c.id = d.centre_id ...@@ -64,5 +64,11 @@ from work_centre c LEFT JOIN work_dept d ON c.id = d.centre_id
ORDER BY c.id,d.id ORDER BY c.id,d.id
</select> </select>
<select id="getById" resultMap="BaseResultMap">
select <include refid="cols_all"/>
from <include refid="table"/>
where id =#{deptId}
</select>
</mapper> </mapper>
...@@ -164,7 +164,8 @@ ORDER BY p.is_conclusion DESC ...@@ -164,7 +164,8 @@ ORDER BY p.is_conclusion DESC
<select id="getListByDeptAndIsConclusion" resultType="cn.wisenergy.model.app.WorkProject"> <select id="getListByDeptAndIsConclusion" resultType="cn.wisenergy.model.app.WorkProject">
select <include refid="Base_Column_List"/> select <include refid="Base_Column_List"/>
from <include refid="table"/> from <include refid="table"/>
where dept=#{deptId} AND isConclusion=#{isConclusion} where dept_id = #{deptId}
<if test="isConclusion !=null ">AND is_conclusion=#{isConclusion}</if>
</select> </select>
......
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
<select id="selectList" resultMap="workTimeAndCostCollect"> <select id="selectList" resultMap="workTimeAndCostCollect">
SELECT type ,dept_name,ptc.dept_id,ptc.project_id AS SELECT type ,<if test="centreId == null">'汇总' AS dept_name,</if> <if test="centreId != null"> dept_name,ptc.dept_id,</if>ptc.project_id AS
project_id,project_name,min(statistics_start) AS statistics_start,max(statistics_end) AS project_id,project_name,min(statistics_start) AS statistics_start,max(statistics_end) AS
statistics_end,sum(total_time) AS total_time,sum(cost) AS cost statistics_end,sum(total_time) AS total_time,sum(cost) AS cost
from work_project_time_cost ptc join work_project p on ptc.project_id=p.id join work_dept d on p.dept_id=d.id from work_project_time_cost ptc join work_project p on ptc.project_id=p.id join work_dept d on p.dept_id=d.id
...@@ -95,14 +95,19 @@ ...@@ -95,14 +95,19 @@
<if test="deptId != null"> <if test="deptId != null">
AND dept_id = #{deptId} AND dept_id = #{deptId}
</if> </if>
AND type in <if test="types != null">
<foreach collection="types" open="(" close=")" separator="," item="type"> AND type in
#{type} <foreach collection="types" open="(" close=")" separator="," item="type">
</foreach> #{type}
</foreach>
</if>
<if test="centreId != null">
AND centre_id = #{centreId}
</if>
<if test="firstDayOfMonth != null"> <if test="firstDayOfMonth != null">
AND statistics_start >= #{firstDayOfMonth} AND statistics_start >= #{firstDayOfMonth}
</if> </if>
GROUP BY type,dept_name,dept_id,ptc.project_id,project_name GROUP BY type, <if test="centreId == null"> dept_name,</if> <if test="centreId != null"> dept_name,ptc.dept_id,</if>ptc.project_id,project_name
</select> </select>
......
...@@ -185,7 +185,7 @@ ...@@ -185,7 +185,7 @@
<select id="statisticsByProjectType" resultMap="monthlyWorkHourStatistics"> <select id="statisticsByProjectType" resultMap="monthlyWorkHourStatistics">
select t2.id AS id , t2.name AS name ,count(1),sum(work_time) select t2.id AS id , t2.name AS name ,count(1),sum(work_time)
from work_time_order t join work_type t2 on t.type = t2.id from work_time_order t join work_type t2 on t.type = t2.id
where user_id = #{userId} AND work_day >= #{currentMonthFirstDay} where user_id = #{userId} AND work_day >= #{currentMonthFirstDay} AND t.status != 3
group by type group by type
</select> </select>
...@@ -232,9 +232,9 @@ ...@@ -232,9 +232,9 @@
</select> </select>
<select id="getWorkTimeAndCostCollect" resultMap="workTimeAndCostCollect" > <select id="getWorkTimeAndCostCollect" resultMap="workTimeAndCostCollect" >
SELECT t.type AS type,t.dept_id AS dept_id, SELECT t.type AS type, t.dept_id AS dept_id,dept_name,
t.project_id AS project_id ,MIN(t.work_day) AS first_time,MAX(t.work_day) AS last_time,ROUND(SUM(t.work_time)/8,2) AS t.project_id AS project_id ,MIN(t.work_day) AS first_time,MAX(t.work_day) AS last_time,ROUND(SUM(t.work_time)/8,2) AS
total_time, SUM(t.work_time * s.day_salary)/8 AS cost,dept_name AS dept_name,project_name total_time, SUM(t.work_time * s.day_salary)/8 AS cost ,project_name
FROM work_time_order t LEFT JOIN work_project p ON t.project_id=p.id LEFT JOIN work_dept d ON t.dept_id=d.id LEFT JOIN work_user_salary s ON s.user_id = t.user_id FROM work_time_order t LEFT JOIN work_project p ON t.project_id=p.id LEFT JOIN work_dept d ON t.dept_id=d.id LEFT JOIN work_user_salary s ON s.user_id = t.user_id
WHERE status IN (2,5) AND s.create_time &lt; t.work_day AND s.end_time > t.work_day WHERE status IN (2,5) AND s.create_time &lt; t.work_day AND s.end_time > t.work_day
<if test="projectIds != null"> <if test="projectIds != null">
...@@ -254,16 +254,17 @@ ...@@ -254,16 +254,17 @@
<foreach collection="types" item="type" open="(" close=")" separator=","> <foreach collection="types" item="type" open="(" close=")" separator=",">
#{type} #{type}
</foreach> </foreach>
group by t.type,t.dept_id, t.project_id,dept_name,p.project_name group by t.type,t.dept_id, dept_name, t.project_id,p.project_name
order by t.dept_id order by t.dept_id
</select> </select>
<select id="getDaysByDateAndStatus" resultType="date"> <select id="getDaysByDateAndStatus" resultType="date">
select distinct(work_day) select distinct(work_day)
from from
<include refid="table"/> <include refid="table"/>
where work_day >= #{firstDayOfMonth} AND user_id = #{userId} where year(#{date}) = year(work_day) AND month(#{date}) = month(work_day) AND user_id = #{userId} AND status != 3
</select> </select>
<select id="geByMonth" resultType="cn.wisenergy.model.app.WorkTimeOrder"> <select id="geByMonth" resultType="cn.wisenergy.model.app.WorkTimeOrder">
SELECT SELECT
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
...@@ -303,9 +304,6 @@ ...@@ -303,9 +304,6 @@
where where
t.status in (2,5) AND t.status in (2,5) AND
t.work_day &lt;= #{endDate} t.work_day &lt;= #{endDate}
<if test="isConclusion != null">
AND p.is_conclusion = #{isConclusion}
</if>
<if test="startDate != null"> <if test="startDate != null">
AND t.work_day > #{startDate} AND t.work_day > #{startDate}
</if> </if>
...@@ -331,9 +329,6 @@ ...@@ -331,9 +329,6 @@
from work_type ty left join work_time_order t on t.type = ty.id left join work_user u on t.user_id = u.id from work_type ty left join work_time_order t on t.type = ty.id left join work_user u on t.user_id = u.id
where where
(t.work_day &lt;= #{endDate} or t.work_day is null) AND (t.status IN (2, 5) or t.status is null) (t.work_day &lt;= #{endDate} or t.work_day is null) AND (t.status IN (2, 5) or t.status is null)
<if test="isConclusion != null">
AND (p.is_conclusion = #{isConclusion} or p.is_conclusion is null)
</if>
<if test="startDate != null"> <if test="startDate != null">
AND (t.work_day > #{startDate} or t.work_day is null) AND (t.work_day > #{startDate} or t.work_day is null)
</if> </if>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment