|
|
@@ -539,10 +539,13 @@ public class AdminStatisticsServiceImpl implements AdminStatisticsService {
|
|
|
public Map<String,Object> monthData(String dateStr) {
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
LocalDate localDate =LocalDate.parse(dateStr,formatter);
|
|
|
- LocalDate newDate = localDate.plusMonths(1);
|
|
|
- List<PublicRelease> publicReleases = publicReleaseMapper.selectByMonth(localDate, newDate);
|
|
|
+ LocalDate endDate = localDate.plusMonths(1);
|
|
|
+ List<PublicRelease> publicReleases = publicReleaseMapper.selectByMonth(localDate, endDate,null);
|
|
|
+ List<PublicRelease> publicReleases2 = publicReleaseMapper.selectByMonth(localDate, endDate,1);
|
|
|
List<AdminPublicDuration> list=new ArrayList<>();
|
|
|
+ List<String> errors=new ArrayList<>();
|
|
|
for (PublicRelease e : publicReleases) {
|
|
|
+ String adminName = getAdminName(e.getAid());
|
|
|
//计算时间差,再加一天就是一共多少天
|
|
|
long daysBetween = DateUtils.getDaysBetween(e.getReleaseStart(), e.getReleaseEnd());
|
|
|
daysBetween+=1;
|
|
|
@@ -551,22 +554,48 @@ public class AdminStatisticsServiceImpl implements AdminStatisticsService {
|
|
|
a.setId(e.getAid());
|
|
|
a.setDate(e.getReleaseStart());
|
|
|
a.setDuration(e.getDuration());
|
|
|
-
|
|
|
- a.setName(getAdminName(e.getAid()));
|
|
|
+ a.setName(adminName);
|
|
|
list.add(a);
|
|
|
}else if(daysBetween>0){
|
|
|
double v = e.getDuration() / daysBetween;
|
|
|
for (int i = 0; i < daysBetween; i++) {
|
|
|
- AdminPublicDuration a = new AdminPublicDuration();
|
|
|
- a.setId(e.getAid());
|
|
|
LocalDate localDate1 = e.getReleaseStart().toInstant().atZone(ZoneId.systemDefault()).toLocalDate().plusDays(i);
|
|
|
- a.setDate(Date.from(localDate1.atStartOfDay(ZoneId.systemDefault()).toInstant()));
|
|
|
- a.setDuration(v);
|
|
|
- a.setName(getAdminName(e.getAid()));
|
|
|
- list.add(a);
|
|
|
+ if (localDate1.isBefore(endDate)){
|
|
|
+ AdminPublicDuration a = new AdminPublicDuration();
|
|
|
+ a.setId(e.getAid());
|
|
|
+ a.setDate(Date.from(localDate1.atStartOfDay(ZoneId.systemDefault()).toInstant()));
|
|
|
+ a.setDuration(v);
|
|
|
+ a.setName(adminName);
|
|
|
+ list.add(a);
|
|
|
+ }else{
|
|
|
+ errors.add(String.format("用户[%s]公出时间[%s]超出[%s],不计入本月公出",adminName,localDate1.format(formatter),endDate.format(formatter)));
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ for (PublicRelease e : publicReleases2) {
|
|
|
+ String adminName = getAdminName(e.getAid());
|
|
|
+ long daysBetween = DateUtils.getDaysBetween(e.getReleaseStart(), e.getReleaseEnd());
|
|
|
+ if(daysBetween>0){
|
|
|
+ double v = e.getDuration() / daysBetween;
|
|
|
+ for (int i = 0; i < daysBetween; i++) {
|
|
|
+ LocalDate localDate1 = e.getReleaseStart().toInstant().atZone(ZoneId.systemDefault()).toLocalDate().plusDays(i);
|
|
|
+ if (localDate1.isAfter(localDate)){
|
|
|
+ AdminPublicDuration a = new AdminPublicDuration();
|
|
|
+ a.setId(e.getAid());
|
|
|
+ a.setDate(Date.from(localDate1.atStartOfDay(ZoneId.systemDefault()).toInstant()));
|
|
|
+ a.setDuration(v);
|
|
|
+ a.setName(adminName);
|
|
|
+ list.add(a);
|
|
|
+ }else{
|
|
|
+ errors.add(String.format("用户[%s]公出时间[%s]小于[%s],不计入本月公出",adminName,localDate1.format(formatter),endDate.format(formatter)));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
//将数据统计到人
|
|
|
Map<String, BigDecimal> durationMap = new HashMap<>();
|
|
|
Map<String, String> nameMap = new HashMap<>();
|
|
|
@@ -590,6 +619,7 @@ public class AdminStatisticsServiceImpl implements AdminStatisticsService {
|
|
|
Map<String,Object> map=new HashMap<>();
|
|
|
map.put("date",list);
|
|
|
map.put("count",list2);
|
|
|
+ map.put("errors",errors);
|
|
|
return map;
|
|
|
}
|
|
|
|