diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/count/SysTrainnumController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/count/SysTrainnumController.java index b567239..36f1449 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/count/SysTrainnumController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/count/SysTrainnumController.java @@ -1,13 +1,18 @@ package com.ruoyi.web.controller.system.count; +import cn.hutool.core.text.StrPool; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.ObtainLastSixMonthsUtil; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.system.domain.TdTrain; +import com.ruoyi.system.domain.check.TdCheckReport; import com.ruoyi.system.service.ISysUserService; import com.ruoyi.system.service.ITdTrainService; import com.ruoyi.web.controller.manager.SysAreaManager; @@ -19,8 +24,13 @@ import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.time.LocalDate; +import java.time.ZoneId; +import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.Objects; +import java.util.concurrent.atomic.AtomicReference; @Controller @RequestMapping("/system/trainnum") @@ -102,4 +112,78 @@ public class SysTrainnumController extends BaseController { return AjaxResult.success(tdTrainService.selectCountList()); } + /** + * + *检查近6个月审核通过统计 + * @return + */ + @PostMapping("/countTrainMonth") + @ResponseBody + public AjaxResult countTrainMonth() { + List recentlySixMonth = ObtainLastSixMonthsUtil.getRecentlySixMonth(); + List yAxisData = new ArrayList<>(); + recentlySixMonth.forEach(month -> { + // 获取指定月份的最大日期 + String lastDayOfMonth = ObtainLastSixMonthsUtil.getLastDayOfMonth(month); + // 获取指定天的最大时间 + Date date = Date.from(LocalDate.parse(lastDayOfMonth).atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()); + Date maxDayTime = ObtainLastSixMonthsUtil.getEndOfDay(date); + // 获取最小时间 + date = Date.from(LocalDate.parse(month.concat(StrPool.DASHED).concat("01")).atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()); + Date minDayTime = ObtainLastSixMonthsUtil.getStartOfDay(date); + AtomicReference yAxis = new AtomicReference<>(0L); + Integer count = new LambdaQueryChainWrapper<>(tdTrainService.getBaseMapper()) + .ge(TdTrain::getCreateDate, minDayTime) + .le(TdTrain::getCreateDate, maxDayTime) + .eq(TdTrain::getTrainState,0) + .count(); + if(Objects.isNull(count)){ + count = 0; + } + yAxis.set(Long.valueOf(count)); + yAxisData.add(yAxis.get()); + }); + JSONObject obj = new JSONObject(); + obj.put("xAxisData", recentlySixMonth.toArray()); + obj.put("yAxisData", yAxisData); + return AjaxResult.success(obj); + } + + /** + * + *检查近6个月待审核统计 + * @return + */ + @PostMapping("/countTrainNoMonth") + @ResponseBody + public AjaxResult countTrainNoMonth() { + List recentlySixMonth = ObtainLastSixMonthsUtil.getRecentlySixMonth(); + List yAxisData = new ArrayList<>(); + recentlySixMonth.forEach(month -> { + // 获取指定月份的最大日期 + String lastDayOfMonth = ObtainLastSixMonthsUtil.getLastDayOfMonth(month); + // 获取指定天的最大时间 + Date date = Date.from(LocalDate.parse(lastDayOfMonth).atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()); + Date maxDayTime = ObtainLastSixMonthsUtil.getEndOfDay(date); + // 获取最小时间 + date = Date.from(LocalDate.parse(month.concat(StrPool.DASHED).concat("01")).atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()); + Date minDayTime = ObtainLastSixMonthsUtil.getStartOfDay(date); + AtomicReference yAxis = new AtomicReference<>(0L); + Integer count = new LambdaQueryChainWrapper<>(tdTrainService.getBaseMapper()) + .ge(TdTrain::getCreateDate, minDayTime) + .le(TdTrain::getCreateDate, maxDayTime) + .eq(TdTrain::getTrainState,2) + .count(); + if(Objects.isNull(count)){ + count = 0; + } + yAxis.set(Long.valueOf(count)); + yAxisData.add(yAxis.get()); + }); + JSONObject obj = new JSONObject(); + obj.put("xAxisData", recentlySixMonth.toArray()); + obj.put("yAxisData", yAxisData); + return AjaxResult.success(obj); + } + }