Commit 7a2d7c9d authored by nie'hong's avatar nie'hong

Merge remote-tracking branch 'origin/chenqi' into chenqi2.0

# Conflicts:
#	wisenergy-common/src/main/java/cn/wisenergy/common/utils/exception/BASE_RESP_CODE_ENUM.java
#	wisenergy-mapper/src/main/resources/mapper/WorkTimeOrderMapper.xml
#	wisenergy-service/src/main/java/cn/wisenergy/service/impl/WorkProjectServiceImpl.java
#	wisenergy-service/src/main/java/cn/wisenergy/service/impl/WorkTimeOrderServiceImpl.java
parents be4bf05d 08fcfe2c
......@@ -19,10 +19,19 @@ public interface WorkProjectTimeCostMapper {
int statisticsTimeOrderByMonth(String date);
/**
* 统计项目总工时和成本,按月统计
* 统计项目和商机总工时和成本,按月统计
* @param map
*/
List<WorkTimeAndCostCollect> selectList(Map<String, Object> map);
List<WorkTimeAndCostCollect> selectListByProjectAndBusiness(Map<String, Object> map);
/**
* 统计其他类型的总工时,按月统计
* @param map
* @return
*/
List<WorkTimeAndCostCollect> selectListByOtherType(Map<String, Object> map);
/**
* 部门编号不为空,查询部门下所有项目统计。部门主键为空时,查询项目主键参数为主键的项目信息
......
......@@ -50,6 +50,7 @@
<insert id="statisticsTimeOrderByMonth" useGeneratedKeys="true">
INSERT INTO work_project_time_cost (
`type`,
project_id,
user_id,
dept_id,
......@@ -60,6 +61,7 @@
create_time
)
SELECT
t.type,
project_id,
t.user_id,
t.dept_id,
......@@ -73,8 +75,9 @@
LEFT JOIN work_user_salary s ON t.user_id = s.user_id
WHERE
t.work_day >= #{date} AND s.create_time &lt;work_day AND s.end_time > work_day
AND t.`status` IN (2, 5) AND project_id is not null
AND t.`status` IN (2, 5)
GROUP BY
`type`,
project_id,
t.dept_id,
t.user_id,
......@@ -84,8 +87,8 @@
</insert>
<select id="selectList" resultMap="workTimeAndCostCollect">
SELECT p.type ,<if test="centreId == null">'汇总' AS dept_name,</if> <if test="centreId != null"> dept_name,p.dept_id,</if>p.id AS
<select id="selectListByProjectAndBusiness" resultMap="workTimeAndCostCollect">
SELECT ptc.type ,<if test="centreId == null">'汇总' AS dept_name,</if> <if test="centreId != null"> dept_name,p.dept_id,</if>p.id AS
project_id,project_name,concat(min(statistics_start),'~' ,max(statistics_end)) AS statistics_time ,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
<where>
......@@ -105,8 +108,8 @@
AND statistics_start >= #{firstDayOfMonth}
</if>
</where>
GROUP BY p.type, <if test="centreId == null"> dept_name,</if> <if test="centreId != null"> dept_name,p.dept_id,</if>p.id,project_name
ORDER BY p.type<if test="centreId != null">, d.sort</if>
GROUP BY ptc.type, <if test="centreId == null"> dept_name,</if> <if test="centreId != null"> dept_name,p.dept_id,</if>p.id,project_name
ORDER BY ptc.type<if test="centreId != null">, d.sort</if>
</select>
......@@ -167,4 +170,46 @@
</select>
<select id="selectListByOtherType" resultMap="workTimeAndCostCollect">
SELECT ptc.type ,<if test="centreId == null">'汇总' AS dept_name,</if> <if test="centreId != null"> dept_name,u.dept_id,</if>
concat(YEAR(statistics_start),'年') AS statistics_time ,sum(total_time) AS total_time,sum(cost) AS cost,d.sort AS d_sort
from work_project_time_cost ptc join work_user u on u.id=ptc.user_id join work_dept d on ptc.dept_id = d.id
<where>
ptc.type not in(1,2)AND YEAR (statistics_start) &lt; YEAR (NOW())
<if test="deptId != null ">
AND ptc.dept_id = #{deptId}
</if>
<if test="centreId != null">
AND d.centre_id = #{centreId}
</if>
<if test="firstDayOfMonth != null">
AND statistics_start >= #{firstDayOfMonth}
</if>
</where>
GROUP BY ptc.type, dept_name,year(statistics_start) <if test="centreId != null"> ,u.dept_id</if>
union
SELECT ptc.type ,<if test="centreId == null">'汇总' AS dept_name,</if> <if test="centreId != null"> dept_name,u.dept_id,</if>
concat(YEAR (statistics_start),'年',MONTH (statistics_start),'月') AS statistics_time ,sum(total_time) AS total_time,sum(cost) AS cost,d.sort AS d_sort
from work_project_time_cost ptc join work_user u on u.id=ptc.user_id join work_dept d on ptc.dept_id = d.id
<where>
ptc.type not in(1,2) AND YEAR(statistics_start) = YEAR (NOW())
<if test="deptId != null ">
AND ptc.dept_id = #{deptId}
</if>
<if test="centreId != null">
AND d.centre_id = #{centreId}
</if>
<if test="firstDayOfMonth != null">
AND statistics_start >= #{firstDayOfMonth}
</if>
</where>
GROUP BY ptc.type, dept_name,month(statistics_start) <if test="centreId != null"> ,u.dept_id</if>
ORDER BY <if test="centreId != null">d_sort,</if>statistics_time
</select>
</mapper>
\ No newline at end of file
......@@ -24,6 +24,7 @@
<resultMap id="userWorkTimeStatisticsByProject" type="cn.wisenergy.model.dto.UserWorkTimeStatisticsByProject">
<result property="userId" column="user_id"/>
<result property="userName" column="user_name"/>
<result property="userDeptName" column="dept_name"/>
<collection property="projectWorkTimeAndType" ofType="cn.wisenergy.model.dto.ProjectWorkTimeAndType">
<result property="projectId" column="project_id"/>
<result property="workTimeType" column="work_time_type"/>
......@@ -255,13 +256,11 @@
<select id="getWorkTimeAndCostCollect" resultMap="workTimeAndCostCollect">
SELECT t.type AS type, d.id AS dept_id,dept_name,
IF (YEAR (work_day) = YEAR (NOW()), concat(YEAR (work_day),'年',MONTH (work_day),'月') , concat(YEAR(work_day),
IF (YEAR (work_day) &lt; YEAR (NOW()), concat(YEAR (work_day),'年',MONTH (work_day),'月') , concat(YEAR(work_day),
'年')) AS statistics_time ,SUM(t.work_time)/8 AS
total_time, SUM(t.work_time * s.day_salary)/8 AS cost,ty.sort AS ty_sort, d.sort AS d_sort
FROM work_time_order t join work_dept d on d.id = t.dept_id join work_user_salary s on s.user_id = t.user_id
join work_type ty on t.type = ty.id
WHERE t.status IN (2,5) AND s.create_time &lt; t.work_day AND s.end_time > t.work_day AND year(t.work_day) &lt;
year(NOW())
FROM work_time_order t join work_dept d on d.id = t.dept_id join work_user_salary s on s.user_id = t.user_id join work_type ty on t.type = ty.id
WHERE t.status IN (2,5) AND s.create_time &lt; t.work_day AND s.end_time > t.work_day AND year(t.work_day) &lt; year(NOW())
<if test="firstDayOfMonth != null">
AND work_day >= #{firstDayOfMonth}
</if>
......@@ -283,10 +282,8 @@
IF (YEAR (work_day) = YEAR (NOW()), concat(YEAR (work_day),'年',MONTH (work_day),'月') , concat(YEAR(work_day),
'年')) AS statistics_time ,SUM(t.work_time)/8 AS
total_time, SUM(t.work_time * s.day_salary)/8 AS cost,ty.sort AS ty_sort, d.sort AS d_sort
FROM work_time_order t join work_dept d on d.id = t.dept_id join work_user_salary s on s.user_id = t.user_id
join work_type ty on t.type = ty.id
WHERE t.status IN (2,5) AND s.create_time &lt; t.work_day AND s.end_time > t.work_day AND year(t.work_day) =
year(NOW())
FROM work_time_order t join work_dept d on d.id = t.dept_id join work_user_salary s on s.user_id = t.user_id join work_type ty on t.type = ty.id
WHERE t.status IN (2,5) AND s.create_time &lt; t.work_day AND s.end_time > t.work_day AND year(t.work_day) = year(NOW())
<if test="firstDayOfMonth != null">
AND work_day >= #{firstDayOfMonth}
</if>
......@@ -346,18 +343,13 @@
<select id="getUserProjectWorkTimeStatistics" resultMap="userWorkTimeStatisticsByProject">
SELECT
<if test="isAll">u.id AS user_id, u.`name` AS user_name,</if>
<if test="!isAll">'合计' AS user_name ,</if>
t.project_id AS project_id, t.type AS work_time_type, p.project_name
SELECT <if test="isAll">u.id AS user_id, u.`name` AS user_name, d.dept_name AS dept_name,</if>
<if test="!isAll">'合计' AS user_name ,</if> t.project_id AS project_id, t.type AS work_time_type, p.project_name
AS project_name,
IF(t.is_overtime = 0,
<if test="!isAll">0</if>
<if test="isAll">null</if>, sum(t.work_time)) AS over_time, IF(t.is_overtime=1,
<if test="!isAll">0</if>
IF(t.is_overtime = 0, <if test="!isAll">0</if>
<if test="isAll">null</if>, sum(t.work_time)) AS over_time, IF(t.is_overtime=1, <if test="!isAll">0</if>
<if test="isAll">null</if>, sum(t.work_time)) AS normal_time
from work_time_order t left join work_project p on t.project_id = p.id join work_user u on t.user_id = u.id join
work_type ty on t.type = ty.id
from work_time_order t left join work_project p on t.project_id = p.id join work_user u on t.user_id = u.id join work_type ty on t.type = ty.id join work_dept d on u.dept_id = d.id
where
t.status in (2,5) AND
t.work_day &lt;= #{endDate}
......@@ -365,11 +357,9 @@
<if test="startDate != null">
AND t.work_day >= #{startDate}
</if>
GROUP BY <if test="isAll">u.id,u.`name`,</if> t.project_id,t.type,p.project_name, t.is_overtime
ORDER BY
<if test="isAll">convert(u.`name` using gbk) asc</if>
<if test="!isAll">ty.sort</if>
,t.project_id
GROUP BY <if test="isAll">u.id,u.`name`,d.dept_name,</if> t.project_id,t.type,p.project_name, t.is_overtime
ORDER BY <if test="isAll">convert(u.`name` using gbk) asc</if>
<if test="!isAll">ty.sort</if> ,t.project_id
</select>
<select id="selectCountByTypeAndStatus" resultType="cn.wisenergy.model.dto.MonthlyWorkingHoursStatistics">
......@@ -384,14 +374,10 @@
</select>
<select id="selectListByType" resultMap="userWorkTimeStatisticsByProject">
SELECT
<if test="isAll">u.id AS user_id, u.`name` AS user_name,</if>
<if test="!isAll">'合计' AS user_name,</if>
t.type AS work_time_type,
IF(t.is_overtime = 0,
<if test="!isAll">0</if>
<if test="isAll">null</if>, sum(t.work_time)) AS over_time, IF(t.is_overtime=1,
<if test="!isAll">0</if>
SELECT <if test="isAll">u.id AS user_id, u.`name` AS user_name,</if>
<if test="!isAll">'合计' AS user_name,</if> t.type AS work_time_type,
IF(t.is_overtime = 0, <if test="!isAll">0</if>
<if test="isAll">null</if>, sum(t.work_time)) AS over_time, IF(t.is_overtime=1, <if test="!isAll">0</if>
<if test="isAll">null</if>, sum(t.work_time)) AS normal_time
from work_time_order t JOIN work_user u ON t.user_id = u.id
where
......
......@@ -31,6 +31,12 @@ public class UserWorkTimeStatisticsByProject implements Serializable{
@ApiModelProperty(name = "userName", value = "用户名")
private String userName;
/**
* 用户部门名臣
*/
@ApiModelProperty(name = "userDeptName", value = "用户所在部门名称")
private String userDeptName;
/**
* 总工时
*/
......
......@@ -18,8 +18,6 @@ import java.util.List;
public class WorkTimeAndCostCollect implements Serializable {
private static final long serialVersionUID = 7207732278277982917L;
// 工单类型展示顺序,存储为类型id
private final static Integer[] TYPE_ORDER = {1, 2, 5, 6, 7, 3, 4};
@ApiModelProperty(name = "type", value = "工时类型主键")
private Integer type;
......
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