Commit c0e3cb96 authored by cq990612's avatar cq990612

优化代码结构

parent 37ce4902
......@@ -836,14 +836,17 @@ public class DateUtil {
public static Date getLastDayByMonth2(Date date)
{
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(Calendar.MONTH,cal.get(Calendar.MONTH)+1);
cal.set(Calendar.DATE,0);
//设置年份
cal.set(Calendar.YEAR,getYear(date));
/*cal.set(Calendar.YEAR,getYear(date));
//设置月份
cal.set(Calendar.MONTH, getMonth(date));
//获取某月最大天数
int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
//设置日历中月份的最大天数
cal.set(Calendar.DAY_OF_MONTH, lastDay);
cal.set(Calendar.DAY_OF_MONTH, lastDay);*/
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
......
......@@ -1138,7 +1138,9 @@ public class StatisticsServiceImpl implements StatisticsService {
return sheets;
}
//获取一个月应上班日期,如果是当月,时间截至到当天
@Override
public List<Date> currentMonthWorkDays(Date date, boolean toToday) {
log.info("StatisticsServiceImpl[]currentMonthWorkDays[]input.method");
// 时间为本月,起始时间为参数时间当月第一天,截至时间为当天。否则,截至时间为当月最后一天
......@@ -1150,6 +1152,7 @@ public class StatisticsServiceImpl implements StatisticsService {
endDate = DateUtil.getStartOfDay(now);
System.out.println("endDate1 = " + DateUtils.dateToStringWithPattern(endDate, "yyyy-MM-dd"));
} else {
System.out.println(DateUtils.dateToShortString(date));
endDate = DateUtil.getLastDayByMonth2(date);
System.out.println("endDate2 = " + DateUtils.dateToStringWithPattern(endDate, "yyyy-MM-dd"));
}
......
......@@ -196,6 +196,8 @@ public class WorkCollectServiceImpl implements WorkCollectService {
*/
private List<Date> getNotCompletedByMonth(WorkUser user,Date month) {
boolean flag = DateUtil.isYearAndMonthEqual(month, new Date());
System.out.println("month" + DateUtils.dateToShortString(month));
System.out.println("flag = " + flag);
List<Date> workDays = statisticsService.currentMonthWorkDays(month, flag);
Date createDate = DateUtils.bigDateToShortDate(user.getCreateTime());
workDays.removeIf(workDay -> workDay.compareTo(createDate) < 0);
......
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