|
|
|
@ -8,12 +8,17 @@ import org.springframework.validation.annotation.Validated;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
|
|
import java.time.DayOfWeek;
|
|
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
|
|
|
import java.time.LocalTime;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.baogongrecord.vo.*;
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.baogongrecord.vo.*;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.baogongrecord.BaogongRecordDO;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.baogongrecord.BaogongRecordDO;
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.mes.enums.BaogongTrendTypeEnum;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.mysql.baogongrecord.BaogongRecordMapper;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.mysql.baogongrecord.BaogongRecordMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@ -85,6 +90,7 @@ public class BaogongRecordServiceImpl implements BaogongRecordService {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public BaogongRecordTrendRespVO getBaogongRecordTrend(BaogongRecordTrendReqVO reqVO) {
|
|
|
|
public BaogongRecordTrendRespVO getBaogongRecordTrend(BaogongRecordTrendReqVO reqVO) {
|
|
|
|
|
|
|
|
fillTrendTimeRange(reqVO);
|
|
|
|
BaogongRecordTrendRespVO respVO = baogongRecordMapper.selectTrendSummary(reqVO);
|
|
|
|
BaogongRecordTrendRespVO respVO = baogongRecordMapper.selectTrendSummary(reqVO);
|
|
|
|
if (respVO == null) {
|
|
|
|
if (respVO == null) {
|
|
|
|
respVO = new BaogongRecordTrendRespVO();
|
|
|
|
respVO = new BaogongRecordTrendRespVO();
|
|
|
|
@ -93,10 +99,59 @@ public class BaogongRecordServiceImpl implements BaogongRecordService {
|
|
|
|
respVO.setNoPassNum(0L);
|
|
|
|
respVO.setNoPassNum(0L);
|
|
|
|
respVO.setPassRate(BigDecimal.ZERO);
|
|
|
|
respVO.setPassRate(BigDecimal.ZERO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<BaogongRecordTrendDayRespVO> dayTrend = baogongRecordMapper.selectTrendByDay(reqVO);
|
|
|
|
List<BaogongRecordTrendDayRespVO> dayTrend = buildTrend(reqVO);
|
|
|
|
respVO.setDayTrend(dayTrend);
|
|
|
|
respVO.setDayTrend(dayTrend);
|
|
|
|
return respVO;
|
|
|
|
return respVO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<BaogongRecordTrendDayRespVO> buildTrend(BaogongRecordTrendReqVO reqVO) {
|
|
|
|
|
|
|
|
BaogongTrendTypeEnum trendType = BaogongTrendTypeEnum.valueOf(reqVO.getTrendType());
|
|
|
|
|
|
|
|
if (trendType == BaogongTrendTypeEnum.CUSTOM) {
|
|
|
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (trendType == BaogongTrendTypeEnum.YEAR) {
|
|
|
|
|
|
|
|
return baogongRecordMapper.selectTrendByMonth(reqVO);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (trendType == BaogongTrendTypeEnum.WEEK) {
|
|
|
|
|
|
|
|
return baogongRecordMapper.selectTrendByWeekday(reqVO);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (trendType == BaogongTrendTypeEnum.TODAY) {
|
|
|
|
|
|
|
|
return baogongRecordMapper.selectTrendByHour(reqVO);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return baogongRecordMapper.selectTrendByDay(reqVO);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void fillTrendTimeRange(BaogongRecordTrendReqVO reqVO) {
|
|
|
|
|
|
|
|
BaogongTrendTypeEnum trendType = BaogongTrendTypeEnum.valueOf(reqVO.getTrendType());
|
|
|
|
|
|
|
|
if (trendType == null) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
|
|
|
if (trendType == BaogongTrendTypeEnum.YEAR) {
|
|
|
|
|
|
|
|
reqVO.setBeginBaogongTime(now.minusMonths(11).withDayOfMonth(1).toLocalDate().atStartOfDay());
|
|
|
|
|
|
|
|
reqVO.setEndBaogongTime(now.withDayOfMonth(now.toLocalDate().lengthOfMonth()).toLocalDate().atTime(LocalTime.MAX));
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (trendType == BaogongTrendTypeEnum.MONTH) {
|
|
|
|
|
|
|
|
LocalDate currentDate = now.toLocalDate();
|
|
|
|
|
|
|
|
reqVO.setBeginBaogongTime(currentDate.withDayOfMonth(1).atStartOfDay());
|
|
|
|
|
|
|
|
reqVO.setEndBaogongTime(currentDate.withDayOfMonth(currentDate.lengthOfMonth()).atTime(LocalTime.MAX));
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (trendType == BaogongTrendTypeEnum.WEEK) {
|
|
|
|
|
|
|
|
LocalDate currentDate = now.toLocalDate();
|
|
|
|
|
|
|
|
LocalDate weekStart = currentDate.with(DayOfWeek.MONDAY);
|
|
|
|
|
|
|
|
LocalDate weekEnd = currentDate.with(DayOfWeek.SUNDAY);
|
|
|
|
|
|
|
|
reqVO.setBeginBaogongTime(weekStart.atStartOfDay());
|
|
|
|
|
|
|
|
reqVO.setEndBaogongTime(weekEnd.atTime(LocalTime.MAX));
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (trendType == BaogongTrendTypeEnum.TODAY) {
|
|
|
|
|
|
|
|
LocalDate currentDate = now.toLocalDate();
|
|
|
|
|
|
|
|
reqVO.setBeginBaogongTime(currentDate.atStartOfDay());
|
|
|
|
|
|
|
|
reqVO.setEndBaogongTime(now.minusHours(1).withMinute(59).withSecond(59).withNano(999999999));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|