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

完善小程序工时统计

parent f8dd35c0
......@@ -20,4 +20,6 @@ public interface WorkDeptMapper extends BaseMapper<WorkDept> {
List<WorkDept> getDeptByCondition(Map<String, Object> map);
List<OrganizationStructureDto> getAllDeptByAllCentre();
WorkDept getById(Integer deptId);
}
......@@ -80,10 +80,11 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> {
/**
* 获取上班日期集合
*
* @param firstDayOfMonth
* @param date
* @param userId
* @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);
......@@ -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> {
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 @@
</sql>
<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 id="criteria">
......@@ -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
</select>
<select id="getById" resultMap="BaseResultMap">
select <include refid="cols_all"/>
from <include refid="table"/>
where id =#{deptId}
</select>
</mapper>
......@@ -164,7 +164,8 @@ ORDER BY p.is_conclusion DESC
<select id="getListByDeptAndIsConclusion" resultType="cn.wisenergy.model.app.WorkProject">
select <include refid="Base_Column_List"/>
from <include refid="table"/>
where dept=#{deptId} AND isConclusion=#{isConclusion}
where dept_id = #{deptId}
<if test="isConclusion !=null ">AND is_conclusion=#{isConclusion}</if>
</select>
......
......@@ -84,7 +84,7 @@
<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
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
......@@ -95,14 +95,19 @@
<if test="deptId != null">
AND dept_id = #{deptId}
</if>
<if test="types != null">
AND type in
<foreach collection="types" open="(" close=")" separator="," item="type">
#{type}
</foreach>
</if>
<if test="centreId != null">
AND centre_id = #{centreId}
</if>
<if test="firstDayOfMonth != null">
AND statistics_start >= #{firstDayOfMonth}
</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>
......
......@@ -185,7 +185,7 @@
<select id="statisticsByProjectType" resultMap="monthlyWorkHourStatistics">
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
where user_id = #{userId} AND work_day >= #{currentMonthFirstDay}
where user_id = #{userId} AND work_day >= #{currentMonthFirstDay} AND t.status != 3
group by type
</select>
......@@ -232,9 +232,9 @@
</select>
<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
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
WHERE status IN (2,5) AND s.create_time &lt; t.work_day AND s.end_time > t.work_day
<if test="projectIds != null">
......@@ -254,7 +254,7 @@
<foreach collection="types" item="type" open="(" close=")" separator=",">
#{type}
</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
</select>
......@@ -262,8 +262,9 @@
select distinct(work_day)
from
<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 id="geByMonth" resultType="cn.wisenergy.model.app.WorkTimeOrder">
SELECT
<include refid="Base_Column_List"/>
......@@ -303,9 +304,6 @@
where
t.status in (2,5) AND
t.work_day &lt;= #{endDate}
<if test="isConclusion != null">
AND p.is_conclusion = #{isConclusion}
</if>
<if test="startDate != null">
AND t.work_day > #{startDate}
</if>
......@@ -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
where
(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">
AND (t.work_day > #{startDate} or t.work_day is null)
</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