|
@@ -31,45 +31,43 @@ public class TBDingStatisticByPersonServiceImpl extends ServiceImpl<TBDingStatis
|
|
@Override
|
|
@Override
|
|
public void buildStatisticByPerson(List<TBDingStatistic> datasource) {
|
|
public void buildStatisticByPerson(List<TBDingStatistic> datasource) {
|
|
List<TBDingStatisticByPerson> result = new ArrayList<>();
|
|
List<TBDingStatisticByPerson> result = new ArrayList<>();
|
|
- List<Long> userIdList = datasource.stream().map(TBDingStatistic::getUserId).distinct().collect(Collectors.toList());
|
|
|
|
|
|
+ List<Long> serviceIdList = datasource.stream().map(TBDingStatistic::getServiceId).distinct().collect(Collectors.toList());
|
|
|
|
+ for (Long serviceId : serviceIdList) {
|
|
|
|
+ List<TBDingStatistic> serviceStatisticList = datasource.stream().filter(e -> serviceId.equals(e.getServiceId())).collect(Collectors.toList());
|
|
|
|
+ List<Long> userIdList = serviceStatisticList.stream().map(TBDingStatistic::getUserId).distinct().collect(Collectors.toList());
|
|
|
|
|
|
- for (Long userId : userIdList) {
|
|
|
|
|
|
+ for (Long userId : userIdList) {
|
|
|
|
+ List<TBDingStatistic> tbDingStatisticList = serviceStatisticList.stream().filter(e -> userId.equals(e.getUserId())).collect(Collectors.toList());
|
|
|
|
+ String serviceName = "";
|
|
|
|
+ int actualDays = 0;
|
|
|
|
+ int weekdays = 0;
|
|
|
|
+ int weekends = 0;
|
|
|
|
+ int legalHolidays = 0;
|
|
|
|
+ BigDecimal workHours = new BigDecimal(0);
|
|
|
|
+ int violationDays = 0;
|
|
|
|
|
|
- List<TBDingStatistic> tbDingStatisticList = datasource.stream().filter(e -> userId.equals(e.getUserId())).collect(Collectors.toList());
|
|
|
|
- Long serviceId = null;
|
|
|
|
- String serviceName = "";
|
|
|
|
- String userName = "";
|
|
|
|
- String userArchivesCode = "";
|
|
|
|
- int actualDays = 0;
|
|
|
|
- int weekdays = 0;
|
|
|
|
- int weekends = 0;
|
|
|
|
- int legalHolidays = 0;
|
|
|
|
- BigDecimal workHours = new BigDecimal(0);
|
|
|
|
- int violationDays = 0;
|
|
|
|
-
|
|
|
|
- for (TBDingStatistic tbDingStatistic : tbDingStatisticList) {
|
|
|
|
- userName = tbDingStatistic.getUserArchivesName();
|
|
|
|
- userArchivesCode = tbDingStatistic.getUserArchivesCode();
|
|
|
|
- serviceId = tbDingStatistic.getServiceId();
|
|
|
|
- serviceName = tbDingStatistic.getServiceName();
|
|
|
|
- actualDays = actualDays + tbDingStatistic.getActualDays();
|
|
|
|
- weekdays = weekdays + tbDingStatistic.getWeekdays();
|
|
|
|
- weekends = weekends + tbDingStatistic.getWeekends();
|
|
|
|
- legalHolidays = legalHolidays + tbDingStatistic.getLegalHolidays();
|
|
|
|
- workHours = workHours.add(tbDingStatistic.getWorkHours());
|
|
|
|
- violationDays = violationDays + tbDingStatistic.getViolationDays();
|
|
|
|
|
|
+ for (TBDingStatistic tbDingStatistic : tbDingStatisticList) {
|
|
|
|
+ serviceName = tbDingStatistic.getServiceName();
|
|
|
|
+ actualDays = actualDays + tbDingStatistic.getActualDays();
|
|
|
|
+ weekdays = weekdays + tbDingStatistic.getWeekdays();
|
|
|
|
+ weekends = weekends + tbDingStatistic.getWeekends();
|
|
|
|
+ legalHolidays = legalHolidays + tbDingStatistic.getLegalHolidays();
|
|
|
|
+ workHours = workHours.add(tbDingStatistic.getWorkHours());
|
|
|
|
+ violationDays = violationDays + tbDingStatistic.getViolationDays();
|
|
|
|
+ }
|
|
|
|
+ TBDingStatisticByPerson tbDingStatisticByPerson = new TBDingStatisticByPerson();
|
|
|
|
+ tbDingStatisticByPerson.setServiceId(serviceId);
|
|
|
|
+ tbDingStatisticByPerson.setServiceName(serviceName);
|
|
|
|
+ tbDingStatisticByPerson.setUserInfo(
|
|
|
|
+ tbDingStatisticList.get(0).getUserArchivesName() + "(" + tbDingStatisticList.get(0).getUserArchivesCode() + ")");
|
|
|
|
+ tbDingStatisticByPerson.setActualDays(actualDays);
|
|
|
|
+ tbDingStatisticByPerson.setWeekdays(weekdays);
|
|
|
|
+ tbDingStatisticByPerson.setWeekends(weekends);
|
|
|
|
+ tbDingStatisticByPerson.setLegalHolidays(legalHolidays);
|
|
|
|
+ tbDingStatisticByPerson.setWorkHours(workHours);
|
|
|
|
+ tbDingStatisticByPerson.setViolationDays(violationDays);
|
|
|
|
+ result.add(tbDingStatisticByPerson);
|
|
}
|
|
}
|
|
- TBDingStatisticByPerson tbDingStatisticByPerson = new TBDingStatisticByPerson();
|
|
|
|
- tbDingStatisticByPerson.setServiceId(serviceId);
|
|
|
|
- tbDingStatisticByPerson.setServiceName(serviceName);
|
|
|
|
- tbDingStatisticByPerson.setUserInfo(userName + "(" + userArchivesCode + ")");
|
|
|
|
- tbDingStatisticByPerson.setActualDays(actualDays);
|
|
|
|
- tbDingStatisticByPerson.setWeekdays(weekdays);
|
|
|
|
- tbDingStatisticByPerson.setWeekends(weekends);
|
|
|
|
- tbDingStatisticByPerson.setLegalHolidays(legalHolidays);
|
|
|
|
- tbDingStatisticByPerson.setWorkHours(workHours);
|
|
|
|
- tbDingStatisticByPerson.setViolationDays(violationDays);
|
|
|
|
- result.add(tbDingStatisticByPerson);
|
|
|
|
}
|
|
}
|
|
this.baseMapper.truncateTable();
|
|
this.baseMapper.truncateTable();
|
|
this.saveBatch(result);
|
|
this.saveBatch(result);
|