Commit 0c57737c authored by cq990612's avatar cq990612

Merge branch '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 c85b3042 683120e1
...@@ -19,10 +19,19 @@ public interface WorkProjectTimeCostMapper { ...@@ -19,10 +19,19 @@ public interface WorkProjectTimeCostMapper {
int statisticsTimeOrderByMonth(String date); int statisticsTimeOrderByMonth(String date);
/** /**
* 统计项目总工时和成本,按月统计 * 统计项目和商机总工时和成本,按月统计
* @param map * @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 @@ ...@@ -50,6 +50,7 @@
<insert id="statisticsTimeOrderByMonth" useGeneratedKeys="true"> <insert id="statisticsTimeOrderByMonth" useGeneratedKeys="true">
INSERT INTO work_project_time_cost ( INSERT INTO work_project_time_cost (
`type`,
project_id, project_id,
user_id, user_id,
dept_id, dept_id,
...@@ -60,6 +61,7 @@ ...@@ -60,6 +61,7 @@
create_time create_time
) )
SELECT SELECT
t.type,
project_id, project_id,
t.user_id, t.user_id,
t.dept_id, t.dept_id,
...@@ -73,8 +75,9 @@ ...@@ -73,8 +75,9 @@
LEFT JOIN work_user_salary s ON t.user_id = s.user_id LEFT JOIN work_user_salary s ON t.user_id = s.user_id
WHERE WHERE
t.work_day >= #{date} AND s.create_time &lt;work_day AND s.end_time > work_day 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 GROUP BY
`type`,
project_id, project_id,
t.dept_id, t.dept_id,
t.user_id, t.user_id,
...@@ -84,8 +87,8 @@ ...@@ -84,8 +87,8 @@
</insert> </insert>
<select id="selectList" resultMap="workTimeAndCostCollect"> <select id="selectListByProjectAndBusiness" 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 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 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 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> <where>
...@@ -105,8 +108,8 @@ ...@@ -105,8 +108,8 @@
AND statistics_start >= #{firstDayOfMonth} AND statistics_start >= #{firstDayOfMonth}
</if> </if>
</where> </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 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 p.type<if test="centreId != null">, d.sort</if> ORDER BY ptc.type<if test="centreId != null">, d.sort</if>
</select> </select>
...@@ -167,4 +170,46 @@ ...@@ -167,4 +170,46 @@
</select> </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> </mapper>
\ No newline at end of file
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
<resultMap id="userWorkTimeStatisticsByProject" type="cn.wisenergy.model.dto.UserWorkTimeStatisticsByProject"> <resultMap id="userWorkTimeStatisticsByProject" type="cn.wisenergy.model.dto.UserWorkTimeStatisticsByProject">
<result property="userId" column="user_id"/> <result property="userId" column="user_id"/>
<result property="userName" column="user_name"/> <result property="userName" column="user_name"/>
<result property="userDeptName" column="dept_name"/>
<collection property="projectWorkTimeAndType" ofType="cn.wisenergy.model.dto.ProjectWorkTimeAndType"> <collection property="projectWorkTimeAndType" ofType="cn.wisenergy.model.dto.ProjectWorkTimeAndType">
<result property="projectId" column="project_id"/> <result property="projectId" column="project_id"/>
<result property="workTimeType" column="work_time_type"/> <result property="workTimeType" column="work_time_type"/>
...@@ -207,7 +208,7 @@ ...@@ -207,7 +208,7 @@
</select> </select>
<select id="listByDateAndUserId" resultMap="dayWorkTimeAndType"> <select id="listByDateAndUserId" resultMap="dayWorkTimeAndType">
select user_id,day(work_day),CASE when `type` = 3 then "请假" when `type` = 4 then "调休" else "正常" end AS `type`, select user_id,day(work_day),CASE when `type` = 3 then "请假" when `type` = 4 then "调休" else if(is_overtime = 0,"正常","加班") end AS `type`,
sum(work_time) sum(work_time)
from from
<include refid="table"/> <include refid="table"/>
...@@ -215,7 +216,7 @@ ...@@ -215,7 +216,7 @@
<foreach collection="userIds" separator="," close=")" item="userId" open="("> <foreach collection="userIds" separator="," close=")" item="userId" open="(">
#{userId} #{userId}
</foreach> </foreach>
group by user_id,day(work_day), CASE when `type` = 3 then "请假" when `type` = 4 then "调休" else "正常" end group by user_id,day(work_day), CASE when `type` = 3 then "请假" when `type` = 4 then "调休" else if(is_overtime = 0,"正常","加班") end
order by day(work_day) order by day(work_day)
</select> </select>
...@@ -255,13 +256,11 @@ ...@@ -255,13 +256,11 @@
<select id="getWorkTimeAndCostCollect" resultMap="workTimeAndCostCollect"> <select id="getWorkTimeAndCostCollect" resultMap="workTimeAndCostCollect">
SELECT t.type AS type, d.id AS dept_id,dept_name, 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 '年')) 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 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 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
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())
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"> <if test="firstDayOfMonth != null">
AND work_day >= #{firstDayOfMonth} AND work_day >= #{firstDayOfMonth}
</if> </if>
...@@ -283,10 +282,8 @@ ...@@ -283,10 +282,8 @@
IF (YEAR (work_day) = YEAR (NOW()), concat(YEAR (work_day),'年',MONTH (work_day),'月') , concat(YEAR(work_day), 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 '年')) 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 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 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
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())
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"> <if test="firstDayOfMonth != null">
AND work_day >= #{firstDayOfMonth} AND work_day >= #{firstDayOfMonth}
</if> </if>
...@@ -346,18 +343,13 @@ ...@@ -346,18 +343,13 @@
<select id="getUserProjectWorkTimeStatistics" resultMap="userWorkTimeStatisticsByProject"> <select id="getUserProjectWorkTimeStatistics" resultMap="userWorkTimeStatisticsByProject">
SELECT SELECT <if test="isAll">u.id AS user_id, u.`name` AS user_name, d.dept_name AS dept_name,</if>
<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
<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, AS project_name,
IF(t.is_overtime = 0, IF(t.is_overtime = 0, <if test="!isAll">0</if>
<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 over_time, IF(t.is_overtime=1,
<if test="!isAll">0</if>
<if test="isAll">null</if>, sum(t.work_time)) AS normal_time <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 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
work_type ty on t.type = ty.id
where where
t.status in (2,5) AND t.status in (2,5) AND
t.work_day &lt;= #{endDate} t.work_day &lt;= #{endDate}
...@@ -365,11 +357,9 @@ ...@@ -365,11 +357,9 @@
<if test="startDate != null"> <if test="startDate != null">
AND t.work_day >= #{startDate} AND t.work_day >= #{startDate}
</if> </if>
GROUP BY <if test="isAll">u.id,u.`name`,</if> t.project_id,t.type,p.project_name, t.is_overtime 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 ORDER BY <if test="isAll">convert(u.`name` using gbk) asc</if>
<if test="isAll">convert(u.`name` using gbk) asc</if> <if test="!isAll">ty.sort</if> ,t.project_id
<if test="!isAll">ty.sort</if>
,t.project_id
</select> </select>
<select id="selectCountByTypeAndStatus" resultType="cn.wisenergy.model.dto.MonthlyWorkingHoursStatistics"> <select id="selectCountByTypeAndStatus" resultType="cn.wisenergy.model.dto.MonthlyWorkingHoursStatistics">
...@@ -384,14 +374,10 @@ ...@@ -384,14 +374,10 @@
</select> </select>
<select id="selectListByType" resultMap="userWorkTimeStatisticsByProject"> <select id="selectListByType" resultMap="userWorkTimeStatisticsByProject">
SELECT SELECT <if test="isAll">u.id AS user_id, u.`name` AS user_name,</if>
<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 test="!isAll">'合计' AS user_name,</if> IF(t.is_overtime = 0, <if test="!isAll">0</if>
t.type AS work_time_type, <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 <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 from work_time_order t JOIN work_user u ON t.user_id = u.id
where where
......
...@@ -31,6 +31,12 @@ public class UserWorkTimeStatisticsByProject implements Serializable{ ...@@ -31,6 +31,12 @@ public class UserWorkTimeStatisticsByProject implements Serializable{
@ApiModelProperty(name = "userName", value = "用户名") @ApiModelProperty(name = "userName", value = "用户名")
private String userName; private String userName;
/**
* 用户部门名臣
*/
@ApiModelProperty(name = "userDeptName", value = "用户所在部门名称")
private String userDeptName;
/** /**
* 总工时 * 总工时
*/ */
......
...@@ -18,8 +18,6 @@ import java.util.List; ...@@ -18,8 +18,6 @@ import java.util.List;
public class WorkTimeAndCostCollect implements Serializable { public class WorkTimeAndCostCollect implements Serializable {
private static final long serialVersionUID = 7207732278277982917L; private static final long serialVersionUID = 7207732278277982917L;
// 工单类型展示顺序,存储为类型id
private final static Integer[] TYPE_ORDER = {1, 2, 5, 6, 7, 3, 4};
@ApiModelProperty(name = "type", value = "工时类型主键") @ApiModelProperty(name = "type", value = "工时类型主键")
private Integer type; private Integer type;
......
...@@ -28,6 +28,7 @@ import org.apache.poi.ss.util.CellRangeAddress; ...@@ -28,6 +28,7 @@ import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.RegionUtil; import org.apache.poi.ss.util.RegionUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -295,14 +296,15 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -295,14 +296,15 @@ public class StatisticsServiceImpl implements StatisticsService {
// 获取所有的类型 // 获取所有的类型
List<WorkType> workTypes = workTypeService.getAll(1); List<WorkType> workTypes = workTypeService.getAll(1);
// 存储查询的类型
List<Integer> types = new ArrayList<>(); // // 存储查询的类型
// 只存储项目和商机之外的类型 // List<Integer> types = new ArrayList<>();
for (WorkType workType : workTypes) { // // 只存储项目和商机之外的类型
if (workType.getId() != 1 && workType.getId() != 2) { // for (WorkType workType : workTypes) {
types.add(workType.getId()); // if (workType.getId() != 1 && workType.getId() != 2) {
} // types.add(workType.getId());
} // }
// }
List<WorkTimeAndCostCollect> workTimeAndCostCollects = null; List<WorkTimeAndCostCollect> workTimeAndCostCollects = null;
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
...@@ -314,13 +316,18 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -314,13 +316,18 @@ public class StatisticsServiceImpl implements StatisticsService {
WorkDept userDept = workDeptMapper.getById(user.getDeptId()); WorkDept userDept = workDeptMapper.getById(user.getDeptId());
// 获取中心下的所有项目和商机工单统计 // 获取中心下的所有项目和商机工单统计
map.put("centreId", userDept.getCentreId()); map.put("centreId", userDept.getCentreId());
workTimeAndCostCollects = workProjectTimeCostMapper.selectList(map); workTimeAndCostCollects = workProjectTimeCostMapper.selectListByProjectAndBusiness(map);
// 除项目和项目的类型 // 中心下其他类型的同时统计
map.put("types", types); List<WorkTimeAndCostCollect> workTimeAndCostCollects1 = workProjectTimeCostMapper.selectListByOtherType(map);
// 获取这些类型的所有工单
List<WorkTimeAndCostCollect> workTimeAndCostCollect = workTimeOrderMapper.getWorkTimeAndCostCollect(map); workTimeAndCostCollects.addAll(workTimeAndCostCollects1);
workTimeAndCostCollects.addAll(workTimeAndCostCollect);
// // 除项目和项目的类型
// map.put("types", types);
// // 获取这些类型的所有工单
// List<WorkTimeAndCostCollect> workTimeAndCostCollect = workTimeOrderMapper.getWorkTimeAndCostCollect(map);
// workTimeAndCostCollects.addAll(workTimeAndCostCollect);
} else if (rank.contains(LevelRankEnum.DEPARTMENT_LEVEL.getRank())) { // 如果用户的审批权限的级别最高为部门级别 } else if (rank.contains(LevelRankEnum.DEPARTMENT_LEVEL.getRank())) { // 如果用户的审批权限的级别最高为部门级别
// 如果用户同时为项目级别和部门级别 // 如果用户同时为项目级别和部门级别
...@@ -329,21 +336,27 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -329,21 +336,27 @@ public class StatisticsServiceImpl implements StatisticsService {
} }
// 获取部门下的所有项目和商机的工时统计 // 获取部门下的所有项目和商机的工时统计
map.put("deptId", user.getDeptId()); map.put("deptId", user.getDeptId());
workTimeAndCostCollects = workProjectTimeCostMapper.selectList(map); workTimeAndCostCollects = workProjectTimeCostMapper.selectListByProjectAndBusiness(map);
// 部门下其他类型的同时统计
List<WorkTimeAndCostCollect> workTimeAndCostCollects1 = workProjectTimeCostMapper.selectListByOtherType(map);
// 除项目和项目的类型 workTimeAndCostCollects.addAll(workTimeAndCostCollects1);
map.put("types", types); // // 除项目和项目的类型
// 获取这些类型的所有工单 // map.put("types", types);
List<WorkTimeAndCostCollect> workTimeAndCostCollect = workTimeOrderMapper.getWorkTimeAndCostCollect(map); // // 获取这些类型的所有工单
workTimeAndCostCollects.addAll(workTimeAndCostCollect); // List<WorkTimeAndCostCollect> workTimeAndCostCollect = workTimeOrderMapper.getWorkTimeAndCostCollect(map);
// workTimeAndCostCollects.addAll(workTimeAndCostCollect);
} else if (rank.contains(LevelRankEnum.PROJECT_LEVEL.getRank())) { // 如果用户的审批权限的级别最高为项目/商机级别,与其他两种级别不同的是只汇总项目和商机类型的工单 } else if (rank.contains(LevelRankEnum.PROJECT_LEVEL.getRank())) { // 如果用户的审批权限的级别最高为项目/商机级别,与其他两种级别不同的是只汇总项目和商机类型的工单
map.put("managerId", user.getId()); map.put("managerId", user.getId());
workTimeAndCostCollects = workProjectTimeCostMapper.selectList(map); workTimeAndCostCollects = workProjectTimeCostMapper.selectListByProjectAndBusiness(map);
} }
// 获取查询结果中的类型 // 获取查询结果中的类型
assert workTimeAndCostCollects != null; List<Integer> typeList = new ArrayList<>(workTypes.size());
List<Integer> typeList = workTimeAndCostCollects.stream().map(WorkTimeAndCostCollect::getType).collect(Collectors.toList()); if (!CollectionUtils.isEmpty(workTimeAndCostCollects)) {
typeList = workTimeAndCostCollects.stream().map(WorkTimeAndCostCollect::getType).collect(Collectors.toList());
}
if (typeList.size() < workTypes.size()) { if (typeList.size() < workTypes.size()) {
int j; int j;
// 用户仅为项目商机级别用户,仅展示项目和商机类型 // 用户仅为项目商机级别用户,仅展示项目和商机类型
...@@ -363,6 +376,19 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -363,6 +376,19 @@ public class StatisticsServiceImpl implements StatisticsService {
} }
} }
} }
// 按照类型排序
for (int i = 0; i < workTypes.size(); i++) {
WorkType workType = workTypes.get(i);
for (int i1 = 0; i1 < workTimeAndCostCollects.size(); i1++) {
if (workTimeAndCostCollects.get(i1).getType().equals(workType.getId())) {
WorkTimeAndCostCollect workTimeAndCostCollect ;
workTimeAndCostCollect = workTimeAndCostCollects.get(i1);
workTimeAndCostCollects.remove(i1);
workTimeAndCostCollects.add(i, workTimeAndCostCollect);
}
}
}
// 给类型赋值类型名称 // 给类型赋值类型名称
for (WorkTimeAndCostCollect timeAndCostCollect : workTimeAndCostCollects) { for (WorkTimeAndCostCollect timeAndCostCollect : workTimeAndCostCollects) {
...@@ -770,7 +796,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -770,7 +796,7 @@ public class StatisticsServiceImpl implements StatisticsService {
HSSFWorkbook sheets = new HSSFWorkbook(); HSSFWorkbook sheets = new HSSFWorkbook();
HSSFSheet sheet1 = sheets.createSheet("sheet1"); HSSFSheet sheet1 = sheets.createSheet("sheet1");
sheet1.setColumnWidth(1,EXCEL_WIDTH); sheet1.setColumnWidth(1, EXCEL_WIDTH);
// 第0行,存部门名称和时间 // 第0行,存部门名称和时间
HSSFRow row0 = sheet1.createRow(0); HSSFRow row0 = sheet1.createRow(0);
...@@ -788,12 +814,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -788,12 +814,7 @@ public class StatisticsServiceImpl implements StatisticsService {
// 单位\姓名 // 单位\姓名
HSSFCell row_1Cell2 = row_1.createCell(1); HSSFCell row_1Cell2 = row_1.createCell(1);
row_1Cell2.setCellValue(" 单位(小时)\n 姓名"); row_1Cell2.setCellValue(" 单位(小时)\n 姓名");
// 画斜线 setDrawingPatriarch(sheet1, 0, 0, 1023, 255, (short) 1, 1, (short) 1, 2);
HSSFPatriarch drawingPatriarch = sheet1.createDrawingPatriarch();
HSSFClientAnchor hssfClientAnchor = new HSSFClientAnchor(0, 0, 1023, 255, (short) 1, 1, (short) 1, 2);
HSSFSimpleShape simpleShape = drawingPatriarch.createSimpleShape(hssfClientAnchor);
simpleShape.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE);
simpleShape.setLineStyle(HSSFSimpleShape.LINESTYLE_SOLID);
// 合计行 // 合计行
HSSFRow totalRow1 = sheet1.createRow(userWorkTimeStatisticsReport.size() + 1); HSSFRow totalRow1 = sheet1.createRow(userWorkTimeStatisticsReport.size() + 1);
...@@ -945,7 +966,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -945,7 +966,7 @@ public class StatisticsServiceImpl implements StatisticsService {
HSSFCellStyle ordinaryCellStyle3 = this.createOrdinaryCellStyle(sheets); HSSFCellStyle ordinaryCellStyle3 = this.createOrdinaryCellStyle(sheets);
ordinaryCellStyle3.setAlignment(HorizontalAlignment.LEFT); ordinaryCellStyle3.setAlignment(HorizontalAlignment.LEFT);
row_1Cell2.setCellStyle(ordinaryCellStyle3); row_1Cell2.setCellStyle(ordinaryCellStyle3);
sheet1.setZoom(8,5); sheet1.setZoom(6, 5);
this.closeSheets(sheets); this.closeSheets(sheets);
return sheets; return sheets;
} }
...@@ -1015,7 +1036,6 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -1015,7 +1036,6 @@ public class StatisticsServiceImpl implements StatisticsService {
this.conversionDateFormat(projectStatisticsByMonths2, yearMonthList, null, false); this.conversionDateFormat(projectStatisticsByMonths2, yearMonthList, null, false);
HSSFWorkbook sheets = new HSSFWorkbook(); HSSFWorkbook sheets = new HSSFWorkbook();
for (ProjectStatisticsByMonth projectStatisticsByMonth : projectStatisticsByMonths) { for (ProjectStatisticsByMonth projectStatisticsByMonth : projectStatisticsByMonths) {
// 项目名作为sheet名 // 项目名作为sheet名
...@@ -1023,7 +1043,8 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -1023,7 +1043,8 @@ public class StatisticsServiceImpl implements StatisticsService {
// sheet名不能存在“/” // sheet名不能存在“/”
String s = projectName.replaceAll("/", "_"); String s = projectName.replaceAll("/", "_");
HSSFSheet sheet = sheets.createSheet(s); HSSFSheet sheet = sheets.createSheet(s);
// 单位单元格设置列宽
sheet.setColumnWidth(2, EXCEL_WIDTH);
// 普通样式 // 普通样式
HSSFCellStyle ordinaryCellStyle = this.createOrdinaryCellStyle(sheets); HSSFCellStyle ordinaryCellStyle = this.createOrdinaryCellStyle(sheets);
// 将人员所在部门列宽加宽 // 将人员所在部门列宽加宽
...@@ -1056,11 +1077,16 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -1056,11 +1077,16 @@ public class StatisticsServiceImpl implements StatisticsService {
// 部门的表头 // 部门的表头
row_last.createCell(0).setCellValue("人员所在部门"); row_last.createCell(0).setCellValue("人员所在部门");
row_last.createCell(1).setCellValue("序号"); row_last.createCell(1).setCellValue("序号");
row_last.createCell(2).setCellValue("人员"); row_last.createCell(2).setCellValue(" 单位(人*天)\n 姓名");
// 画斜线
setDrawingPatriarch(sheet, 0, 0, 1023, 255, (short) 2, lastRowNum + 1, (short) 2, lastRowNum + 1);
for (int i = 0; i < 12; i++) { for (int i = 0; i < 12; i++) {
row_last.createCell(i + 3).setCellValue(i + 1 + "月"); row_last.createCell(i + 3).setCellValue(i + 1 + "月");
} }
row_last.createCell(15).setCellValue("合计"); row_last.createCell(15).setCellValue("合计");
// 设置行高
row_last.setHeight((short) 500);
// 部门下的人员的统计 // 部门下的人员的统计
for (int i = 0, k = 0; i < projectStatisticsByMonths2.size(); i++) { for (int i = 0, k = 0; i < projectStatisticsByMonths2.size(); i++) {
...@@ -1361,5 +1387,12 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -1361,5 +1387,12 @@ public class StatisticsServiceImpl implements StatisticsService {
return sheets; return sheets;
} }
// 画斜线
private void setDrawingPatriarch(HSSFSheet sheet1, int dx1, int dy1, int dx2, int dy2, short col1, int row1, short col2, int row2) {
HSSFPatriarch drawingPatriarch = sheet1.createDrawingPatriarch();
HSSFClientAnchor hssfClientAnchor = new HSSFClientAnchor(dx1, dy1, dx2, dy2, col1, row1, col2, row2);
HSSFSimpleShape simpleShape = drawingPatriarch.createSimpleShape(hssfClientAnchor);
simpleShape.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE);
simpleShape.setLineStyle(HSSFSimpleShape.LINESTYLE_SOLID);
}
} }
...@@ -35,8 +35,6 @@ public abstract class BaseController { ...@@ -35,8 +35,6 @@ public abstract class BaseController {
protected Logger log = LoggerFactory.getLogger(this.getClass()); protected Logger log = LoggerFactory.getLogger(this.getClass());
/** /**
* 应用接口异常处理 * 应用接口异常处理
* *
......
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