fix:6个月已登记统计

pg_adapter
wangxy 6 months ago
parent de8aa6d615
commit 8c49954890

@ -1,13 +1,18 @@
package com.ruoyi.web.controller.system.count; 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.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.ObtainLastSixMonthsUtil;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.TdTrain; import com.ruoyi.system.domain.TdTrain;
import com.ruoyi.system.domain.check.TdCheckReport;
import com.ruoyi.system.service.ISysUserService; import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.system.service.ITdTrainService; import com.ruoyi.system.service.ITdTrainService;
import com.ruoyi.web.controller.manager.SysAreaManager; import com.ruoyi.web.controller.manager.SysAreaManager;
@ -19,8 +24,13 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; 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.List;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;
@Controller @Controller
@RequestMapping("/system/trainnum") @RequestMapping("/system/trainnum")
@ -102,4 +112,78 @@ public class SysTrainnumController extends BaseController {
return AjaxResult.success(tdTrainService.selectCountList()); return AjaxResult.success(tdTrainService.selectCountList());
} }
/**
*
*6
* @return
*/
@PostMapping("/countTrainMonth")
@ResponseBody
public AjaxResult countTrainMonth() {
List<String> recentlySixMonth = ObtainLastSixMonthsUtil.getRecentlySixMonth();
List<Long> 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<Long> 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<String> recentlySixMonth = ObtainLastSixMonthsUtil.getRecentlySixMonth();
List<Long> 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<Long> 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);
}
} }

Loading…
Cancel
Save