Commit f261e857 authored by cq990612's avatar cq990612

优化代码结构

parent 0ac2a96d
...@@ -153,6 +153,16 @@ public class DateUtils { ...@@ -153,6 +153,16 @@ public class DateUtils {
} }
} }
public static Date bigDateToShortDate(Date date) {
String s = dateToShortString(date);
try {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
return simpleDateFormat.parse(s);
} catch (Exception e) {
return null;
}
}
/** /**
* return date value of specified string value in format: HH:mm:ss * return date value of specified string value in format: HH:mm:ss
* *
......
...@@ -417,6 +417,7 @@ ...@@ -417,6 +417,7 @@
<result property="userName" column="user_name"/> <result property="userName" column="user_name"/>
<result property="deptId" column="dept_id"/> <result property="deptId" column="dept_id"/>
<result property="deptName" column="dept_name"/> <result property="deptName" column="dept_name"/>
<result property="createTime" column="create_time"/>
<collection property="workDay" <collection property="workDay"
javaType="ArrayList" javaType="ArrayList"
ofType = "java.util.Date"> ofType = "java.util.Date">
...@@ -426,13 +427,14 @@ ...@@ -426,13 +427,14 @@
<select id="getDeptNotOrderInfo" resultMap="DeptUserCollectDto"> <select id="getDeptNotOrderInfo" resultMap="DeptUserCollectDto">
select d.id as 'dept_id' ,d.dept_name,u.id as 'user_id',u.name as 'user_name',c.work_day select d.id as 'dept_id',d.dept_name,u.id as 'user_id',u.name as 'user_name',u.create_time,c.work_day
from work_user u LEFT JOIN work_collect c ON u.id = c.user_id LEFT JOIN work_dept d on u.dept_id = d.id from work_user u LEFT JOIN work_collect c ON u.id = c.user_id LEFT JOIN work_dept d on u.dept_id = d.id
<where> <where>
u.submit_order = 1 and u.`status` = 1 and c.`status` !=3 and c.total_time = 8 u.submit_order = 1 and u.`status` = 1 and (c.`status` !=3 and c.total_time = 8
<if test=" startDate !=null and endDate !=null"> <if test=" startDate !=null and endDate !=null">
and c.work_day between #{startDate} and #{endDate} and c.work_day between #{startDate} and #{endDate}
</if> </if>
) or (c.work_day is null and u.submit_order = 1 and u.`status` = 1)
<if test="depts !=null and depts.size()>0"> <if test="depts !=null and depts.size()>0">
AND d.id in AND d.id in
<foreach collection="depts" item="dept" open="(" close=")" separator=","> <foreach collection="depts" item="dept" open="(" close=")" separator=",">
......
...@@ -13,6 +13,7 @@ import java.util.List; ...@@ -13,6 +13,7 @@ import java.util.List;
public class DeptUserCollectDto { public class DeptUserCollectDto {
private Integer userId; private Integer userId;
private String userName; private String userName;
private Date createTime;
private Integer deptId; private Integer deptId;
private String deptName; private String deptName;
List<Date> workDay; List<Date> workDay;
......
package cn.wisenergy.service.impl; package cn.wisenergy.service.impl;
import cn.wisenergy.common.utils.DateUtil; import cn.wisenergy.common.utils.DateUtil;
import cn.wisenergy.common.utils.DateUtils;
import cn.wisenergy.common.utils.exception.BASE_RESP_CODE_ENUM; import cn.wisenergy.common.utils.exception.BASE_RESP_CODE_ENUM;
import cn.wisenergy.common.utils.exception.BaseCustomException; import cn.wisenergy.common.utils.exception.BaseCustomException;
import cn.wisenergy.mapper.WorkCollectMapper; import cn.wisenergy.mapper.WorkCollectMapper;
...@@ -97,7 +98,7 @@ public class WorkCollectServiceImpl implements WorkCollectService { ...@@ -97,7 +98,7 @@ public class WorkCollectServiceImpl implements WorkCollectService {
// 如果查询的日期大于本月的日期,则不查询 // 如果查询的日期大于本月的日期,则不查询
if (1 == user.getSubmitOrder() && workMonth.compareTo(new Date())<=0) { if (1 == user.getSubmitOrder() && workMonth.compareTo(new Date())<=0) {
List<Date> notCompletedByMonth = getNotCompletedByMonth(userId, workMonth); List<Date> notCompletedByMonth = getNotCompletedByMonth(user, workMonth);
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
if (!CollectionUtils.isEmpty(notCompletedByMonth)) { if (!CollectionUtils.isEmpty(notCompletedByMonth)) {
notCompletedByMonth.forEach(notComplete -> sb.append(DateUtil.getDay(notComplete)).append("日,") ); notCompletedByMonth.forEach(notComplete -> sb.append(DateUtil.getDay(notComplete)).append("日,") );
...@@ -187,14 +188,16 @@ public class WorkCollectServiceImpl implements WorkCollectService { ...@@ -187,14 +188,16 @@ public class WorkCollectServiceImpl implements WorkCollectService {
/** /**
* 获取当月已经填的并满8小时 * 获取当月已经填的并满8小时
* @param userId 用户id * @param user 用户
* @param month 日期 * @param month 日期
* @return 日期集合 * @return 日期集合
*/ */
private List<Date> getNotCompletedByMonth(Integer userId,Date month) { private List<Date> getNotCompletedByMonth(WorkUser user,Date month) {
boolean flag = DateUtil.isYearAndMonthEqual(month, new Date()); boolean flag = DateUtil.isYearAndMonthEqual(month, new Date());
List<Date> workDays = statisticsService.currentMonthWorkDays(month, flag); List<Date> workDays = statisticsService.currentMonthWorkDays(month, flag);
List<WorkCollect> completedCollect = workCollectMapper.getCompletedByUserIdAndMonth(userId, month); Date createDate = DateUtils.bigDateToShortDate(user.getCreateTime());
workDays.removeIf(date1 -> date1.compareTo(createDate) < 0);
List<WorkCollect> completedCollect = workCollectMapper.getCompletedByUserIdAndMonth(user.getId(), month);
List<Date> completedDays = new ArrayList<>(); List<Date> completedDays = new ArrayList<>();
completedCollect.forEach(collect -> completedDays.add(collect.getWorkDay())); completedCollect.forEach(collect -> completedDays.add(collect.getWorkDay()));
workDays.removeAll(completedDays); workDays.removeAll(completedDays);
......
package cn.wisenergy.service.impl; package cn.wisenergy.service.impl;
import cn.wisenergy.common.utils.DateUtil; import cn.wisenergy.common.utils.DateUtil;
import cn.wisenergy.common.utils.DateUtils;
import cn.wisenergy.common.utils.exception.BASE_RESP_CODE_ENUM; import cn.wisenergy.common.utils.exception.BASE_RESP_CODE_ENUM;
import cn.wisenergy.common.utils.exception.BaseCustomException; import cn.wisenergy.common.utils.exception.BaseCustomException;
import cn.wisenergy.mapper.WorkProjectMapper; import cn.wisenergy.mapper.WorkProjectMapper;
...@@ -1003,6 +1004,8 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService { ...@@ -1003,6 +1004,8 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
for (DeptUserCollectDto deptUserCollectDto : deptNotOrderInfo) { for (DeptUserCollectDto deptUserCollectDto : deptNotOrderInfo) {
UserDto userDto = new UserDto(); UserDto userDto = new UserDto();
List<Date> workDays1 = new ArrayList<>(workDays); List<Date> workDays1 = new ArrayList<>(workDays);
Date createDate = DateUtils.bigDateToShortDate(deptUserCollectDto.getCreateTime());
workDays1.removeIf(date1 -> date1.compareTo(createDate) < 0);
userDto.setId(deptUserCollectDto.getUserId()); userDto.setId(deptUserCollectDto.getUserId());
userDto.setName(deptUserCollectDto.getUserName()); userDto.setName(deptUserCollectDto.getUserName());
workDays1.removeAll(deptUserCollectDto.getWorkDay()); workDays1.removeAll(deptUserCollectDto.getWorkDay());
......
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