小久哥 3 years ago
parent
commit
d4dc0a25c7
  1. 18
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/statistical/StatisticalController.java
  2. 3
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/statistical/dto/RequestDTO.java

18
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/statistical/StatisticalController.java

@ -52,26 +52,10 @@ public class StatisticalController {
@PostMapping("/statisticalInformation")
@ApiOperation("农场数据统计接口")
public CommonResult<StatisticalVo> statisticalInformation(@RequestBody RequestDTO searchDTO){
LocalDateTime currentTime = LocalDateTime.now();
LocalDateTime beforeTime ;
if (searchDTO.getTimeSearch() == 1){
//本周
DateTime time = DateUtil.beginOfWeek(new Date());
String timeStr = DateUtil.format(time, DatePattern.NORM_DATETIME_PATTERN);
beforeTime = LocalDateTimeUtil.parse(timeStr, DatePattern.NORM_DATETIME_PATTERN);
}else if (searchDTO.getTimeSearch() == 2){
//前一个月
beforeTime = LocalDateTimeUtil.offset(currentTime, -30, ChronoUnit.DAYS);
}else{
//前三个月
beforeTime = LocalDateTimeUtil.offset(currentTime, -90, ChronoUnit.DAYS);
}
TimeLimitDTO time = FarmTimeUtil.getStartTimeAndEndTime(searchDTO.getTimeEnum());
StatisticalVo vo = new StatisticalVo();
//获取时间内的所有工时记录
List<WorkHourDO> workList = workHourMapper.selectList(Wrappers.<WorkHourDO>lambdaQuery().ge(WorkHourDO::getCreateTime, beforeTime).le(WorkHourDO::getCreateTime, currentTime));
List<WorkHourDO> workList = workHourMapper.selectList(Wrappers.<WorkHourDO>lambdaQuery().ge(WorkHourDO::getCreateTime, time.getStartTime()).le(WorkHourDO::getCreateTime, time.getEndTime()));
//工时的userId
List<Long> workUserIdList = workList.stream().map(WorkHourDO::getUserId).collect(Collectors.toList());
//获取工时所有人信息

3
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/statistical/dto/RequestDTO.java

@ -9,9 +9,6 @@ public class RequestDTO {
private static final long serialVersionUID = 1L;
@ApiModelProperty("统计查询时间 1本周 2一个月 3三个月")
private Integer timeSearch;
@ApiModelProperty("便捷时间查询 3本周 6一个月 7三个月")
private FarmTimeEnum timeEnum;
}
Loading…
Cancel
Save