|
@@ -3,13 +3,24 @@ package cn.iocoder.yudao.module.pms.controller.admin.stat;
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
|
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.failure.vo.IotFailureReportPageReqVO;
|
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.inspect.order.vo.IotInspectOrderPageReqVO;
|
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.iotmainworkorder.vo.IotMainWorkOrderPageReqVO;
|
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.iotmainworkorder.vo.IotMainWorkOrderSaveReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.maintain.vo.IotMaintainPageReqVO;
|
|
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.failure.IotFailureReportDO;
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.inspect.IotInspectOrderDO;
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotmainworkorder.IotMainWorkOrderDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.maintain.IotMaintainDO;
|
|
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.failure.IotFailureReportMapper;
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.inspect.IotInspectOrderMapper;
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.iotmainworkorder.IotMainWorkOrderMapper;
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.maintain.IotMaintainMapper;
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.maintain.IotMaintainMapper;
|
|
|
|
+import cn.iocoder.yudao.module.pms.service.inspect.IotInspectOrderService;
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
import com.google.common.collect.ImmutableMap;
|
|
import com.google.common.collect.ImmutableMap;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -17,10 +28,13 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.getLastYearMonthRanges;
|
|
|
|
+
|
|
@Tag(name = "统计接口")
|
|
@Tag(name = "统计接口")
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/rq/stat")
|
|
@RequestMapping("/rq/stat")
|
|
@@ -30,10 +44,16 @@ public class IotStaticController {
|
|
private IotFailureReportMapper iotFailureReportMapper;
|
|
private IotFailureReportMapper iotFailureReportMapper;
|
|
@Resource
|
|
@Resource
|
|
private IotMaintainMapper iotMaintainMapper;
|
|
private IotMaintainMapper iotMaintainMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IotInspectOrderMapper iotInspectOrderMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IotInspectOrderService iotInspectOrderService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IotMainWorkOrderMapper iotMainWorkOrderMapper;
|
|
|
|
|
|
@GetMapping("/main/day")
|
|
@GetMapping("/main/day")
|
|
public CommonResult<Map<String, Object>> getMaintainDay() {
|
|
public CommonResult<Map<String, Object>> getMaintainDay() {
|
|
- ImmutableMap<String, LocalDateTime> beginEndDay = DateUtils.getBeginEndDay();
|
|
|
|
|
|
+ ImmutableMap<String, LocalDateTime> beginEndDay = DateUtils.getBeginEndDay(1);
|
|
IotFailureReportPageReqVO iotFailureReportPageReqVO = new IotFailureReportPageReqVO();
|
|
IotFailureReportPageReqVO iotFailureReportPageReqVO = new IotFailureReportPageReqVO();
|
|
iotFailureReportPageReqVO.setCreateTime(new LocalDateTime[]{beginEndDay.get("start"), beginEndDay.get("end")});
|
|
iotFailureReportPageReqVO.setCreateTime(new LocalDateTime[]{beginEndDay.get("start"), beginEndDay.get("end")});
|
|
Long failure = iotFailureReportMapper.selectCountByTimeAndStatus(iotFailureReportPageReqVO);
|
|
Long failure = iotFailureReportMapper.selectCountByTimeAndStatus(iotFailureReportPageReqVO);
|
|
@@ -43,8 +63,12 @@ public class IotStaticController {
|
|
return CommonResult.success(ImmutableMap.of("failureDay", failure, "maintainDay", maintain));
|
|
return CommonResult.success(ImmutableMap.of("failureDay", failure, "maintainDay", maintain));
|
|
}
|
|
}
|
|
|
|
|
|
- public static void main(String[] args) {
|
|
|
|
|
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
|
+ ImmutableMap<String, LocalDateTime> beginEndDay = DateUtils.getBeginEndDay(1);
|
|
|
|
+ System.out.println(JSON.toJSONString(beginEndDay));
|
|
|
|
+ ImmutableMap<String, LocalDateTime> beginEndDay1 = DateUtils.getBeginEndDay(0);
|
|
|
|
+ System.out.println(JSON.toJSONString(beginEndDay1));
|
|
}
|
|
}
|
|
|
|
|
|
@GetMapping("/main/week")
|
|
@GetMapping("/main/week")
|
|
@@ -88,8 +112,185 @@ public class IotStaticController {
|
|
}
|
|
}
|
|
|
|
|
|
@GetMapping("/main/year")
|
|
@GetMapping("/main/year")
|
|
- public void getMaintainYear() {
|
|
|
|
|
|
+ public CommonResult<List<DateUtils.MonthRange>> getMaintainYear() {
|
|
|
|
+ List<DateUtils.MonthRange> lastYearMonths = getLastYearMonthRanges();
|
|
|
|
+ List<DateUtils.MonthRange> collect = lastYearMonths.stream().map(e -> {
|
|
|
|
+ IotFailureReportPageReqVO iotFailureReportPageReqVO = new IotFailureReportPageReqVO();
|
|
|
|
+ iotFailureReportPageReqVO.setCreateTime(new LocalDateTime[]{e.getStart(), e.getEnd()});
|
|
|
|
+ Long l = iotFailureReportMapper.selectCountByTimeAndStatus(iotFailureReportPageReqVO);
|
|
|
|
+ e.setCount(Integer.valueOf(String.valueOf(l)));
|
|
|
|
+ return e;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ return CommonResult.success(collect);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/inspect/day")
|
|
|
|
+ public CommonResult<Map<String, Object>> getInspectDay() {
|
|
|
|
+ ImmutableMap<String, LocalDateTime> beginEndDay = DateUtils.getBeginEndDay(1);
|
|
|
|
+ IotInspectOrderPageReqVO iotInspectOrderPageReqVO = new IotInspectOrderPageReqVO();
|
|
|
|
+ iotInspectOrderPageReqVO.setCreateTime(new LocalDateTime[]{beginEndDay.get("start"), beginEndDay.get("end")});
|
|
|
|
+ Long inspectDayTotal = iotInspectOrderMapper.selectCountByTimeAndStatus(iotInspectOrderPageReqVO);
|
|
|
|
+ iotInspectOrderPageReqVO.setStatus("todo");
|
|
|
|
+ Long inspectDayTodo = iotInspectOrderMapper.selectCountByTimeAndStatus(iotInspectOrderPageReqVO);
|
|
|
|
+
|
|
|
|
+ return CommonResult.success(ImmutableMap.of("total", inspectDayTotal,"todo", inspectDayTodo));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/inspect/week")
|
|
|
|
+ public CommonResult<Map<String, Object>> getInspectWeek() {
|
|
|
|
+ IotInspectOrderPageReqVO iotInspectOrderPageReqVO = new IotInspectOrderPageReqVO();
|
|
|
|
+ ImmutableMap<String, LocalDateTime> beginEndWeek = DateUtils.getBeginEndWeek();
|
|
|
|
+ iotInspectOrderPageReqVO.setCreateTime(new LocalDateTime[]{beginEndWeek.get("start"), beginEndWeek.get("end")});
|
|
|
|
+ Long inspectWeekTotal = iotInspectOrderMapper.selectCountByTimeAndStatus(iotInspectOrderPageReqVO);
|
|
|
|
+ iotInspectOrderPageReqVO.setStatus("todo");
|
|
|
|
+ Long inspectWeekTodo = iotInspectOrderMapper.selectCountByTimeAndStatus(iotInspectOrderPageReqVO);
|
|
|
|
+
|
|
|
|
+ return CommonResult.success(ImmutableMap.of("total", inspectWeekTotal,"todo", inspectWeekTodo));
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ @GetMapping("/inspect/month")
|
|
|
|
+ public CommonResult<Map<String, Object>> getInspectMonth() {
|
|
|
|
+ IotInspectOrderPageReqVO iotInspectOrderPageReqVO = new IotInspectOrderPageReqVO();
|
|
|
|
+ ImmutableMap<String, LocalDateTime> beginEndMonth = DateUtils.getBeginEndMonth();
|
|
|
|
+ iotInspectOrderPageReqVO.setCreateTime(new LocalDateTime[]{beginEndMonth.get("start"), beginEndMonth.get("end")});
|
|
|
|
+ Long inspectWeekTotal = iotInspectOrderMapper.selectCountByTimeAndStatus(iotInspectOrderPageReqVO);
|
|
|
|
+ iotInspectOrderPageReqVO.setStatus("todo");
|
|
|
|
+ Long inspectWeekTodo = iotInspectOrderMapper.selectCountByTimeAndStatus(iotInspectOrderPageReqVO);
|
|
|
|
+
|
|
|
|
+ return CommonResult.success(ImmutableMap.of("total", inspectWeekTotal,"todo", inspectWeekTodo));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/inspect/total")
|
|
|
|
+ public CommonResult<Map<String, Object>> getInspectTotal() {
|
|
|
|
+ Long total = iotInspectOrderMapper.selectCount();
|
|
|
|
+ Long todo = iotInspectOrderMapper.selectCount("status", "todo");
|
|
|
|
+
|
|
|
|
+ return CommonResult.success(ImmutableMap.of("total", total,"todo", todo));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @GetMapping("/inspect/status")
|
|
|
|
+ public CommonResult<Map<String, Long>> getInspectStatusInfo() {
|
|
|
|
+ List<IotInspectOrderDO> iotInspectOrderDOS = iotInspectOrderMapper.selectList();
|
|
|
|
+ Map<String, Long> order = iotInspectOrderDOS.stream().collect(Collectors.groupingBy(IotInspectOrderDO::getStatus, Collectors.counting()));
|
|
|
|
+ return CommonResult.success(order);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/inspect/today/status")
|
|
|
|
+ public CommonResult<Map<String, Long>> getInspectTodayStatusInfo() {
|
|
|
|
+ ImmutableMap<String, LocalDateTime> beginEndDay = DateUtils.getBeginEndDay(0);
|
|
|
|
+ IotInspectOrderPageReqVO iotInspectOrderPageReqVO = new IotInspectOrderPageReqVO();
|
|
|
|
+ iotInspectOrderPageReqVO.setCreateTime(new LocalDateTime[]{beginEndDay.get("start"), beginEndDay.get("end")});
|
|
|
|
+ List<IotInspectOrderDO> iotInspectOrderDOS = iotInspectOrderMapper.selectListByCreateTime(iotInspectOrderPageReqVO);
|
|
|
|
+ Map<String, Long> order = iotInspectOrderDOS.stream().collect(Collectors.groupingBy(IotInspectOrderDO::getStatus, Collectors.counting()));
|
|
|
|
+ return CommonResult.success(order);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/inspect/year")
|
|
|
|
+ public CommonResult<List<DateUtils.MonthRange>> getInspectYear() {
|
|
|
|
+ List<DateUtils.MonthRange> lastYearMonths = getLastYearMonthRanges();
|
|
|
|
+ List<DateUtils.MonthRange> collect = lastYearMonths.stream().map(e -> {
|
|
|
|
+ IotInspectOrderPageReqVO iotInspectOrderPageReqVO = new IotInspectOrderPageReqVO();
|
|
|
|
+ iotInspectOrderPageReqVO.setCreateTime(new LocalDateTime[]{e.getStart(), e.getEnd()});
|
|
|
|
+ Long l = iotInspectOrderMapper.selectCountByTimeAndStatus(iotInspectOrderPageReqVO);
|
|
|
|
+ e.setCount(Integer.valueOf(String.valueOf(l)));
|
|
|
|
+ return e;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ return CommonResult.success(collect);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @GetMapping("/maintenance/day")
|
|
|
|
+ public CommonResult<Map<String, Object>> getMaintenanceDay() {
|
|
|
|
+ ImmutableMap<String, LocalDateTime> beginEndDay = DateUtils.getBeginEndDay(1);
|
|
|
|
+ IotMainWorkOrderPageReqVO iotMainWorkOrderPageReqVO = new IotMainWorkOrderPageReqVO();
|
|
|
|
+ iotMainWorkOrderPageReqVO.setCreateTime(new LocalDateTime[]{beginEndDay.get("start"), beginEndDay.get("end")});
|
|
|
|
+ Long inspectDayTotal = iotMainWorkOrderMapper.selectCountByTimeAndStatus(iotMainWorkOrderPageReqVO);
|
|
|
|
+ iotMainWorkOrderPageReqVO.setStatus(1);
|
|
|
|
+ Long inspectDayTodo = iotMainWorkOrderMapper.selectCountByTimeAndStatus(iotMainWorkOrderPageReqVO);
|
|
|
|
+
|
|
|
|
+ return CommonResult.success(ImmutableMap.of("total", inspectDayTotal,"todo", inspectDayTodo));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/maintenance/week")
|
|
|
|
+ public CommonResult<Map<String, Object>> getMaintenanceWeek() {
|
|
|
|
+ IotMainWorkOrderPageReqVO iotMainWorkOrderPageReqVO = new IotMainWorkOrderPageReqVO();
|
|
|
|
+ ImmutableMap<String, LocalDateTime> beginEndWeek = DateUtils.getBeginEndWeek();
|
|
|
|
+ iotMainWorkOrderPageReqVO.setCreateTime(new LocalDateTime[]{beginEndWeek.get("start"), beginEndWeek.get("end")});
|
|
|
|
+ Long inspectWeekTotal = iotMainWorkOrderMapper.selectCountByTimeAndStatus(iotMainWorkOrderPageReqVO);
|
|
|
|
+ iotMainWorkOrderPageReqVO.setStatus(1);
|
|
|
|
+ Long inspectWeekTodo = iotMainWorkOrderMapper.selectCountByTimeAndStatus(iotMainWorkOrderPageReqVO);
|
|
|
|
+
|
|
|
|
+ return CommonResult.success(ImmutableMap.of("total", inspectWeekTotal,"todo", inspectWeekTodo));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/maintenance/month")
|
|
|
|
+ public CommonResult<Map<String, Object>> getMaintenanceMonth() {
|
|
|
|
+ IotMainWorkOrderPageReqVO iotMainWorkOrderPageReqVO = new IotMainWorkOrderPageReqVO();
|
|
|
|
+ ImmutableMap<String, LocalDateTime> beginEndMonth = DateUtils.getBeginEndMonth();
|
|
|
|
+ iotMainWorkOrderPageReqVO.setCreateTime(new LocalDateTime[]{beginEndMonth.get("start"), beginEndMonth.get("end")});
|
|
|
|
+ Long inspectWeekTotal = iotMainWorkOrderMapper.selectCountByTimeAndStatus(iotMainWorkOrderPageReqVO);
|
|
|
|
+ iotMainWorkOrderPageReqVO.setStatus(1);
|
|
|
|
+ Long inspectWeekTodo = iotMainWorkOrderMapper.selectCountByTimeAndStatus(iotMainWorkOrderPageReqVO);
|
|
|
|
+
|
|
|
|
+ return CommonResult.success(ImmutableMap.of("total", inspectWeekTotal,"todo", inspectWeekTodo));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/maintenance/total")
|
|
|
|
+ public CommonResult<Map<String, Object>> getMaintenanceTotal() {
|
|
|
|
+ Long total = iotMainWorkOrderMapper.selectCount();
|
|
|
|
+ Long todo = iotMainWorkOrderMapper.selectCount("status", "todo");
|
|
|
|
+
|
|
|
|
+ return CommonResult.success(ImmutableMap.of("total", total,"todo", todo));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/maintenance/status")
|
|
|
|
+ public CommonResult<Map<String, Long>> getMaintenanceStatusInfo() {
|
|
|
|
+ List<IotMainWorkOrderDO> iotMainWorkOrderDOS = iotMainWorkOrderMapper.selectList();
|
|
|
|
+ Map<Integer, Long> order = iotMainWorkOrderDOS.stream().collect(Collectors.groupingBy(IotMainWorkOrderDO::getResult, Collectors.counting()));
|
|
|
|
+ Map<String, Long> resultMap = new HashMap<>(order.size());
|
|
|
|
+ order.forEach((k,v)->{
|
|
|
|
+ if (k==1) {
|
|
|
|
+ resultMap.put("todo", v);
|
|
|
|
+ }else if (k==2) {
|
|
|
|
+ resultMap.put("finished", v);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ return CommonResult.success(resultMap);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/maintenance/today/status")
|
|
|
|
+ public CommonResult<Map<String, Long>> getMaintenanceTodayStatusInfo() {
|
|
|
|
+ ImmutableMap<String, LocalDateTime> beginEndDay = DateUtils.getBeginEndDay(0);
|
|
|
|
+ IotMainWorkOrderPageReqVO iotMainWorkOrderPageReqVO = new IotMainWorkOrderPageReqVO();
|
|
|
|
+ iotMainWorkOrderPageReqVO.setCreateTime(new LocalDateTime[]{beginEndDay.get("start"), beginEndDay.get("end")});
|
|
|
|
+ List<IotMainWorkOrderDO> iotInspectOrderDOS = iotMainWorkOrderMapper.selectListByCreateTime(iotMainWorkOrderPageReqVO);
|
|
|
|
+ Map<Integer, Long> order = iotInspectOrderDOS.stream().collect(Collectors.groupingBy(IotMainWorkOrderDO::getResult, Collectors.counting()));
|
|
|
|
+ Map<String, Long> resultMap = new HashMap<>(order.size());
|
|
|
|
+ order.forEach((k,v)->{
|
|
|
|
+ if (k==1) {
|
|
|
|
+ resultMap.put("todo", v);
|
|
|
|
+ }else if (k==2) {
|
|
|
|
+ resultMap.put("finished", v);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ return CommonResult.success(resultMap);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ @GetMapping("/maintenance/type")
|
|
|
|
+ public CommonResult<Map<String, Long>> getMaintenanceType() {
|
|
|
|
+ List<IotMainWorkOrderDO> iotMainWorkOrderDOS = iotMainWorkOrderMapper.selectList();
|
|
|
|
+ Map<Integer, Long> order = iotMainWorkOrderDOS.stream().collect(Collectors.groupingBy(IotMainWorkOrderDO::getType, Collectors.counting()));
|
|
|
|
+ Map<String, Long> resultMap = new HashMap<>(order.size());
|
|
|
|
+ order.forEach((k,v)->{
|
|
|
|
+ if (k==1) {
|
|
|
|
+ resultMap.put("计划生成", v);
|
|
|
|
+ }else if (k==2) {
|
|
|
|
+ resultMap.put("临时新建", v);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ return CommonResult.success(resultMap);
|
|
}
|
|
}
|
|
}
|
|
}
|