|
@@ -1,7 +1,5 @@
|
|
|
package com.qmth.sop.business.service.impl;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -10,12 +8,13 @@ import com.qmth.sop.business.entity.TBDingStatistic;
|
|
|
import com.qmth.sop.business.entity.TBDingStatisticByPerson;
|
|
|
import com.qmth.sop.business.mapper.TBDingStatisticByPersonMapper;
|
|
|
import com.qmth.sop.business.service.TBDingStatisticByPersonService;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -32,11 +31,44 @@ public class TBDingStatisticByPersonServiceImpl extends ServiceImpl<TBDingStatis
|
|
|
@Override
|
|
|
public void buildStatisticByPerson(List<TBDingStatistic> datasource) {
|
|
|
List<TBDingStatisticByPerson> result = new ArrayList<>();
|
|
|
- for (TBDingStatistic tbDingStatistic : datasource) {
|
|
|
+ List<Long> userIdList = datasource.stream().map(TBDingStatistic::getUserId).distinct().collect(Collectors.toList());
|
|
|
+
|
|
|
+ for (Long userId : userIdList) {
|
|
|
+
|
|
|
+ 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();
|
|
|
+ }
|
|
|
TBDingStatisticByPerson tbDingStatisticByPerson = new TBDingStatisticByPerson();
|
|
|
- BeanUtils.copyProperties(tbDingStatistic, tbDingStatisticByPerson);
|
|
|
- tbDingStatisticByPerson.setUserInfo(
|
|
|
- tbDingStatistic.getUserArchivesName() + "(" + tbDingStatistic.getUserArchivesCode() + ")");
|
|
|
+ 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();
|