|
@@ -0,0 +1,95 @@
|
|
|
|
+package cn.iocoder.yudao.module.pms.controller.admin.stat;
|
|
|
|
+
|
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
|
+import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.failure.vo.IotFailureReportPageReqVO;
|
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.maintain.vo.IotMaintainPageReqVO;
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.failure.IotFailureReportDO;
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.maintain.IotMaintainDO;
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.failure.IotFailureReportMapper;
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.maintain.IotMaintainMapper;
|
|
|
|
+import com.google.common.collect.ImmutableMap;
|
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
+
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
|
|
+@Tag(name = "统计接口")
|
|
|
|
+@RestController
|
|
|
|
+@RequestMapping("/rq/stat")
|
|
|
|
+@Validated
|
|
|
|
+public class IotStaticController {
|
|
|
|
+ @Resource
|
|
|
|
+ private IotFailureReportMapper iotFailureReportMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private IotMaintainMapper iotMaintainMapper;
|
|
|
|
+
|
|
|
|
+ @GetMapping("/main/day")
|
|
|
|
+ public CommonResult<Map<String, Object>> getMaintainDay() {
|
|
|
|
+ ImmutableMap<String, LocalDateTime> beginEndDay = DateUtils.getBeginEndDay();
|
|
|
|
+ IotFailureReportPageReqVO iotFailureReportPageReqVO = new IotFailureReportPageReqVO();
|
|
|
|
+ iotFailureReportPageReqVO.setCreateTime(new LocalDateTime[]{beginEndDay.get("start"), beginEndDay.get("end")});
|
|
|
|
+ Long failure = iotFailureReportMapper.selectCountByTimeAndStatus(iotFailureReportPageReqVO);
|
|
|
|
+ IotMaintainPageReqVO iotMaintainPageReqVO = new IotMaintainPageReqVO();
|
|
|
|
+ iotMaintainPageReqVO.setCreateTime(new LocalDateTime[]{beginEndDay.get("start"), beginEndDay.get("end")});
|
|
|
|
+ Long maintain = iotMaintainMapper.selectCountByTimeAndStatus(iotMaintainPageReqVO);
|
|
|
|
+ return CommonResult.success(ImmutableMap.of("failureDay", failure, "maintainDay", maintain));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static void main(String[] args) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/main/week")
|
|
|
|
+ public CommonResult<Map<String, Object>> getMaintainWeek() {
|
|
|
|
+ ImmutableMap<String, LocalDateTime> beginEndWeek = DateUtils.getBeginEndWeek();
|
|
|
|
+ IotFailureReportPageReqVO iotFailureReportPageReqVO = new IotFailureReportPageReqVO();
|
|
|
|
+ iotFailureReportPageReqVO.setCreateTime(new LocalDateTime[]{beginEndWeek.get("start"), beginEndWeek.get("end")});
|
|
|
|
+ Long failure = iotFailureReportMapper.selectCountByTimeAndStatus(iotFailureReportPageReqVO);
|
|
|
|
+ IotMaintainPageReqVO iotMaintainPageReqVO = new IotMaintainPageReqVO();
|
|
|
|
+ iotMaintainPageReqVO.setCreateTime(new LocalDateTime[]{beginEndWeek.get("start"), beginEndWeek.get("end")});
|
|
|
|
+ Long maintain = iotMaintainMapper.selectCountByTimeAndStatus(iotMaintainPageReqVO);
|
|
|
|
+ return CommonResult.success(ImmutableMap.of("failureWeek", failure, "maintainWeek", maintain));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/main/month")
|
|
|
|
+ public CommonResult<Map<String, Object>> getMaintainMonth() {
|
|
|
|
+ ImmutableMap<String, LocalDateTime> beginEndMonth = DateUtils.getBeginEndMonth();
|
|
|
|
+ IotFailureReportPageReqVO iotFailureReportPageReqVO = new IotFailureReportPageReqVO();
|
|
|
|
+ iotFailureReportPageReqVO.setCreateTime(new LocalDateTime[]{beginEndMonth.get("start"), beginEndMonth.get("end")});
|
|
|
|
+ Long failure = iotFailureReportMapper.selectCountByTimeAndStatus(iotFailureReportPageReqVO);
|
|
|
|
+ IotMaintainPageReqVO iotMaintainPageReqVO = new IotMaintainPageReqVO();
|
|
|
|
+ iotMaintainPageReqVO.setCreateTime(new LocalDateTime[]{beginEndMonth.get("start"), beginEndMonth.get("end")});
|
|
|
|
+ Long maintain = iotMaintainMapper.selectCountByTimeAndStatus(iotMaintainPageReqVO);
|
|
|
|
+ return CommonResult.success(ImmutableMap.of("failureMonth", failure, "maintainMonth", maintain));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/main/total")
|
|
|
|
+ public CommonResult<Map<String, Object>> getMaintainTotal() {
|
|
|
|
+ Long failure = iotFailureReportMapper.selectCount();
|
|
|
|
+ Long maintain = iotMaintainMapper.selectCount();
|
|
|
|
+ return CommonResult.success(ImmutableMap.of("failureTotal", failure, "maintainTotal", maintain));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/main/status")
|
|
|
|
+ public CommonResult<Map<String, Object>> getMaintainStatusInfo() {
|
|
|
|
+ List<IotFailureReportDO> iotFailureReportDOS = iotFailureReportMapper.selectList();
|
|
|
|
+ Map<String, Long> failure = iotFailureReportDOS.stream().collect(Collectors.groupingBy(IotFailureReportDO::getStatus, Collectors.counting()));
|
|
|
|
+ List<IotMaintainDO> iotMaintainDOS = iotMaintainMapper.selectList();
|
|
|
|
+ Map<String, Long> maintain = iotMaintainDOS.stream().collect(Collectors.groupingBy(IotMaintainDO::getStatus, Collectors.counting()));
|
|
|
|
+ return CommonResult.success(ImmutableMap.of("failureStatus", failure, "maintainStatus", maintain));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/main/year")
|
|
|
|
+ public void getMaintainYear() {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+}
|