|
@@ -7,7 +7,6 @@ import com.usky.common.security.utils.SecurityUtils;
|
|
|
import com.usky.iot.domain.PmProject;
|
|
|
import com.usky.iot.domain.PmWorkContent;
|
|
|
import com.usky.iot.domain.PmWorkReport;
|
|
|
-import com.usky.iot.mapper.PmProjectMapper;
|
|
|
import com.usky.iot.mapper.PmWorkContentMapper;
|
|
|
import com.usky.iot.mapper.PmWorkReportMapper;
|
|
|
import com.usky.iot.service.PmProjectService;
|
|
@@ -59,7 +58,11 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<PmWorkReport> weekWork(String startDate, String endDate, Integer reportId) {
|
|
|
+ public List<Map<String, List<PmWorkReport>>> weekWork(String startDate, String endDate, Integer reportId) {
|
|
|
+ List<Map<String, List<PmWorkReport>>> returnList = new ArrayList<>();
|
|
|
+ List<PmWorkReport> report = new ArrayList<>();
|
|
|
+ Map<String, List<PmWorkReport>> weekData = new HashMap<>();
|
|
|
+ Map<String, List<PmWorkReport>> newData = new HashMap<>();
|
|
|
LocalDate startDate1 = null;
|
|
|
LocalDate endDate1 = null;
|
|
|
if (startDate == null && endDate == null) {
|
|
@@ -69,19 +72,20 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
|
|
|
startDate1 = LocalDate.parse(startDate);
|
|
|
endDate1 = LocalDate.parse(endDate);
|
|
|
}
|
|
|
- //固定返回七条数据,没有内容也要设置时间给前端渲染
|
|
|
List<LocalDate> dates = new ArrayList<>();
|
|
|
- while (!startDate1.isAfter(endDate1)) {
|
|
|
- dates.add(startDate1);
|
|
|
- startDate1 = startDate1.plusDays(1);
|
|
|
+ LocalDate tempDate = startDate1;
|
|
|
+ while (!tempDate.isAfter(endDate1)) {
|
|
|
+ dates.add(tempDate);
|
|
|
+ tempDate = tempDate.plusDays(1);
|
|
|
}
|
|
|
+ //固定返回七条数据,没有内容也要设置时间给前端渲染
|
|
|
LambdaQueryWrapper<PmWorkReport> queryWrapperR = Wrappers.lambdaQuery();
|
|
|
- queryWrapperR.select(PmWorkReport::getId, PmWorkReport::getReportDate, PmWorkReport::getSubmitDate, PmWorkReport::getTomorrowPlan, PmWorkReport::getCoordinateWork, PmWorkReport::getCcTo)
|
|
|
+ queryWrapperR.select(PmWorkReport::getId, PmWorkReport::getReportDate, PmWorkReport::getSubmitDate, PmWorkReport::getUpdateTime, PmWorkReport::getTomorrowPlan, PmWorkReport::getCoordinateWork, PmWorkReport::getCcTo)
|
|
|
.eq(PmWorkReport::getSubmitterId, SecurityUtils.getUserId())
|
|
|
- .between(PmWorkReport::getReportDate, startDate, endDate)
|
|
|
+ .between(PmWorkReport::getReportDate, startDate1, endDate1)
|
|
|
.orderByAsc(PmWorkReport::getReportDate)
|
|
|
.apply(reportId != 0, "id = " + reportId);
|
|
|
- List<PmWorkReport> reports = this.list(queryWrapperR);
|
|
|
+ List<PmWorkReport> reports = baseMapper.selectList(queryWrapperR);
|
|
|
if (reports.isEmpty()) {
|
|
|
List<PmWorkReport> reports1 = new ArrayList<>();
|
|
|
for (int f = 0; f < dates.size(); f++) {
|
|
@@ -91,14 +95,19 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
|
|
|
report1.setWorkContents(content);
|
|
|
reports1.add(report1);
|
|
|
}
|
|
|
- return reports1;
|
|
|
+ weekData.put("weekData", reports1);
|
|
|
+ newData.put("newData", report);
|
|
|
+ returnList.add(0, newData);
|
|
|
+ returnList.add(1, weekData);
|
|
|
+ return returnList;
|
|
|
}
|
|
|
List<Integer> ids = new ArrayList<>();
|
|
|
for (PmWorkReport pwr : reports) {
|
|
|
ids.add(pwr.getId());
|
|
|
}
|
|
|
LambdaQueryWrapper<PmWorkContent> queryWrapperC = Wrappers.lambdaQuery();
|
|
|
- queryWrapperC.select(PmWorkContent::getId, PmWorkContent::getWorkContent, PmWorkContent::getWorkTime, PmWorkContent::getProjectId, PmWorkContent::getProjectName, PmWorkContent::getReportId)
|
|
|
+ queryWrapperC.select(PmWorkContent::getId, PmWorkContent::getWorkContent, PmWorkContent::getWorkTime, PmWorkContent::getProjectId,
|
|
|
+ PmWorkContent::getProjectName, PmWorkContent::getReportId, PmWorkContent::getCreateTime, PmWorkContent::getUpdateTime)
|
|
|
.in(PmWorkContent::getReportId, ids)
|
|
|
.orderByDesc(PmWorkContent::getWorkTime);
|
|
|
List<PmWorkContent> contents = pmWorkContentMapper.selectList(queryWrapperC);
|
|
@@ -115,7 +124,21 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
|
|
|
reports.get(i).setWorkContents(contentList);
|
|
|
}
|
|
|
if (reports.size() == 7 || reportId != 0) {
|
|
|
- return reports;
|
|
|
+ weekData.put("weekData", reports);
|
|
|
+ LambdaQueryWrapper<PmWorkReport> wrapper1 = Wrappers.lambdaQuery();
|
|
|
+ wrapper1.eq(PmWorkReport::getSubmitterId, SecurityUtils.getUserId())
|
|
|
+ .orderByDesc(PmWorkReport::getReportDate)
|
|
|
+ .last("LIMIT 1");
|
|
|
+ report = this.list(wrapper1);
|
|
|
+ Integer rId = report.get(0).getId();
|
|
|
+ LambdaQueryWrapper<PmWorkContent> wrapperC = Wrappers.lambdaQuery();
|
|
|
+ wrapperC.eq(PmWorkContent::getProjectId, rId);
|
|
|
+ List<PmWorkContent> pmWorkContents = pmWorkContentMapper.selectList(wrapperC);
|
|
|
+ report.get(0).setWorkContents(pmWorkContents);
|
|
|
+ newData.put("newData", report);
|
|
|
+ returnList.add(0, newData);
|
|
|
+ returnList.add(1, weekData);
|
|
|
+ return returnList;
|
|
|
}
|
|
|
List<PmWorkReport> reportList = new ArrayList<>();
|
|
|
for (int d = 0; d < dates.size(); d++) {
|
|
@@ -135,7 +158,41 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
|
|
|
reportList.add(newReport);
|
|
|
}
|
|
|
}
|
|
|
- return reportList;
|
|
|
+ //返回最新的一条数据给前端填充
|
|
|
+ LambdaQueryWrapper<PmWorkReport> wrapper2 = Wrappers.lambdaQuery();
|
|
|
+ wrapper2.eq(PmWorkReport::getSubmitterId, SecurityUtils.getUserId())
|
|
|
+ .orderByDesc(PmWorkReport::getSubmitDate)
|
|
|
+ .last("LIMIT 1");
|
|
|
+ List<PmWorkReport> report2 = baseMapper.selectList(wrapper2);
|
|
|
+ LambdaQueryWrapper<PmWorkReport> wrapper3 = Wrappers.lambdaQuery();
|
|
|
+ wrapper2.eq(PmWorkReport::getSubmitterId, SecurityUtils.getUserId())
|
|
|
+ .orderByDesc(PmWorkReport::getUpdateTime)
|
|
|
+ .last("LIMIT 1");
|
|
|
+ List<PmWorkReport> report3 = baseMapper.selectList(wrapper3);
|
|
|
+ LocalDateTime sbTime = report2.get(0).getSubmitDate();
|
|
|
+ LocalDateTime upTime = report3.get(0).getSubmitDate();
|
|
|
+ int comparisonResult = sbTime.compareTo(upTime);
|
|
|
+ if (comparisonResult < 0) {
|
|
|
+ report = report3;
|
|
|
+ } else if (comparisonResult == 0) {
|
|
|
+ report = report2;
|
|
|
+ } else {
|
|
|
+ report = report2;
|
|
|
+ }
|
|
|
+ Integer pId = report.get(0).getId();
|
|
|
+ List<PmWorkContent> pmWorkContentList = new ArrayList<>();
|
|
|
+ for (PmWorkContent pmWorkContent : contents) {
|
|
|
+ Integer pId2 = pmWorkContent.getReportId();
|
|
|
+ if (pId2 == pId){
|
|
|
+ pmWorkContentList.add(pmWorkContent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ report.get(0).setWorkContents(pmWorkContentList);
|
|
|
+ weekData.put("weekData", reportList);
|
|
|
+ newData.put("newData", report);
|
|
|
+ returnList.add(0, newData);
|
|
|
+ returnList.add(1, weekData);
|
|
|
+ return returnList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -211,7 +268,7 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
|
|
|
rp.setId(pmWorkReport.getId());
|
|
|
rp.setReportDate(pmWorkReport.getReportDate());
|
|
|
rp.setSubmitterId(pmWorkReport.getSubmitterId());
|
|
|
- rp.setSubmitDate(LocalDateTime.now());
|
|
|
+ rp.setSubmitDate(pmWorkReport.getSubmitDate());
|
|
|
rp.setCcTo(pmWorkReport.getCcTo());
|
|
|
rp.setCoordinateWork(pmWorkReport.getCoordinateWork());
|
|
|
rp.setTomorrowPlan(pmWorkReport.getTomorrowPlan());
|
|
@@ -223,6 +280,7 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
|
|
|
rp.setTenantId(pmWorkReport.getTenantId());
|
|
|
rp.setUpdateBy(SecurityUtils.getUsername());
|
|
|
rp.setUpdateTime(LocalDateTime.now());
|
|
|
+ rp.setTotalHours(totalWorkTime);
|
|
|
pmWorkReportMapper.updateById(rp);
|
|
|
|
|
|
LambdaQueryWrapper<PmWorkContent> queryWrapper = Wrappers.lambdaQuery();
|
|
@@ -260,50 +318,69 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
|
|
|
LocalDate today = LocalDate.now();
|
|
|
LocalDate startOfWeek = today.with(TemporalAdjusters.previousOrSame(java.time.DayOfWeek.MONDAY));
|
|
|
LocalDate endOfWeek = today.with(TemporalAdjusters.nextOrSame(java.time.DayOfWeek.SUNDAY));
|
|
|
+ LocalDateTime startOfWeekDateTime = startOfWeek.atStartOfDay();
|
|
|
+ LocalDateTime endOfWeekDateTime = endOfWeek.atTime(23, 59, 59);
|
|
|
LocalDate startOfMonth = today.withDayOfMonth(1);
|
|
|
LocalDate endOfMonth = today.withDayOfMonth(today.lengthOfMonth());
|
|
|
+ LocalDateTime startOfMonthDateTime = startOfMonth.atStartOfDay();
|
|
|
+ LocalDateTime endOfMonthDateTime = endOfMonth.atTime(23, 59, 59);
|
|
|
+
|
|
|
BigDecimal weekTotal = BigDecimal.ZERO;
|
|
|
- LambdaQueryWrapper<PmWorkContent> wrapperW = Wrappers.lambdaQuery();
|
|
|
- wrapperW.eq(PmWorkContent::getSubmitterId,SecurityUtils.getUserId())
|
|
|
- .between(PmWorkContent::getCreateTime,startOfWeek,endOfWeek);
|
|
|
- List<PmWorkContent> week = pmWorkContentMapper.selectList(wrapperW);
|
|
|
- if (week.isEmpty()){
|
|
|
- weekTotalMap.put("WeekWorkTimeTotal",0);
|
|
|
- weekMap.put("WeeklyData",week);
|
|
|
+ List<PmProjectWorkTimeVo> week = pmWorkContentMapper.workTimeCount(startOfWeekDateTime, endOfWeekDateTime, SecurityUtils.getUserId());
|
|
|
+ if (week.isEmpty()) {
|
|
|
+ weekTotalMap.put("WeekWorkTimeTotal", 0);
|
|
|
+ weekMap.put("WeeklyData", week);
|
|
|
}
|
|
|
for (int i = 0; i < week.size(); i++) {
|
|
|
weekTotal = weekTotal.add(week.get(i).getWorkTime());
|
|
|
}
|
|
|
- BigDecimal monthTotal = BigDecimal.ZERO;
|
|
|
- LambdaQueryWrapper<PmWorkContent> wrapperM = Wrappers.lambdaQuery();
|
|
|
- wrapperM.eq(PmWorkContent::getSubmitterId,SecurityUtils.getUserId())
|
|
|
- .between(PmWorkContent::getCreateTime,startOfMonth,endOfMonth);
|
|
|
- List<PmWorkContent> month = pmWorkContentMapper.selectList(wrapperW);
|
|
|
- if (month.isEmpty()){
|
|
|
- monthTotalMap.put("MonthWorkTimeTotal",0);
|
|
|
- monthMap.put("MonthlyData",month);
|
|
|
- }
|
|
|
- for (int j = 0; j < month.size(); j++) {
|
|
|
- monthTotal = monthTotal.add(month.get(j).getWorkTime());
|
|
|
- }
|
|
|
+ BigDecimal totalPercentageW = BigDecimal.ZERO;
|
|
|
for (int a = 0; a < week.size(); a++) {
|
|
|
PmProjectWorkTimeVo workTimeVo = new PmProjectWorkTimeVo();
|
|
|
workTimeVo.setProjectName(week.get(a).getProjectName());
|
|
|
workTimeVo.setWorkTime(week.get(a).getWorkTime());
|
|
|
+ if (a != week.size() - 1) {
|
|
|
+ BigDecimal percentage = week.get(a).getWorkTime().divide(weekTotal, scale, roundingMode);
|
|
|
+ workTimeVo.setPercentage(percentage);
|
|
|
+ totalPercentageW = totalPercentageW.add(percentage);
|
|
|
+ } else {
|
|
|
+ BigDecimal lastPercentage = BigDecimal.ONE.subtract(totalPercentageW);
|
|
|
+ workTimeVo.setPercentage(lastPercentage);
|
|
|
+ }
|
|
|
workTimeVo.setPercentage(week.get(a).getWorkTime().divide(weekTotal, scale, roundingMode));
|
|
|
returnListW.add(workTimeVo);
|
|
|
}
|
|
|
+
|
|
|
+ BigDecimal monthTotal = BigDecimal.ZERO;
|
|
|
+ List<PmProjectWorkTimeVo> month = pmWorkContentMapper.workTimeCount(startOfMonthDateTime, endOfMonthDateTime, SecurityUtils.getUserId());
|
|
|
+ if (month.isEmpty()) {
|
|
|
+ weekTotalMap.put("MonthWorkTimeTotal", 0);
|
|
|
+ weekMap.put("MonthlyData", month);
|
|
|
+ }
|
|
|
+ for (int i = 0; i < month.size(); i++) {
|
|
|
+ monthTotal = monthTotal.add(month.get(i).getWorkTime());
|
|
|
+ }
|
|
|
+ BigDecimal totalPercentageM = BigDecimal.ZERO;
|
|
|
for (int b = 0; b < month.size(); b++) {
|
|
|
PmProjectWorkTimeVo workTimeVo = new PmProjectWorkTimeVo();
|
|
|
workTimeVo.setProjectName(month.get(b).getProjectName());
|
|
|
workTimeVo.setWorkTime(month.get(b).getWorkTime());
|
|
|
- workTimeVo.setPercentage(month.get(b).getWorkTime().divide(weekTotal, scale, roundingMode));
|
|
|
+ if (b != month.size() - 1) {
|
|
|
+ BigDecimal percentage = month.get(b).getWorkTime().divide(monthTotal, scale, roundingMode);
|
|
|
+ workTimeVo.setPercentage(percentage);
|
|
|
+ totalPercentageM = totalPercentageM.add(percentage);
|
|
|
+ } else {
|
|
|
+ BigDecimal lastPercentage = BigDecimal.ONE.subtract(totalPercentageM);
|
|
|
+ workTimeVo.setPercentage(lastPercentage);
|
|
|
+ }
|
|
|
+
|
|
|
returnListM.add(workTimeVo);
|
|
|
}
|
|
|
- weekTotalMap.put("WeekWorkTimeTotal",weekTotal);
|
|
|
- monthTotalMap.put("MonthWorkTimeTotal",monthTotal);
|
|
|
- weekMap.put("WeeklyData",returnListW);
|
|
|
- monthMap.put("MonthlyData",returnListM);
|
|
|
+
|
|
|
+ weekTotalMap.put("WeekWorkTimeTotal", weekTotal);
|
|
|
+ monthTotalMap.put("MonthWorkTimeTotal", monthTotal);
|
|
|
+ weekMap.put("WeeklyData", returnListW);
|
|
|
+ monthMap.put("MonthlyData", returnListM);
|
|
|
returnList.add(weekTotalMap);
|
|
|
returnList.add(monthTotalMap);
|
|
|
returnList.add(weekMap);
|