|
@@ -1,28 +1,38 @@
|
|
package cn.iocoder.yudao.module.pms.controller.admin.stat;
|
|
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.pojo.Pms;
|
|
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.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.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.controller.admin.vo.DeviceVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.DeviceVO;
|
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDevicePageReqVO;
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO;
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.IotProductClassifyDO;
|
|
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.inspect.IotInspectOrderDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotmainworkorder.IotMainWorkOrderDO;
|
|
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.IotDeviceMapper;
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.IotProductClassifyMapper;
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.TDDeviceMapper;
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.TDDeviceMapper;
|
|
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.inspect.IotInspectOrderMapper;
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotmainworkorder.IotMainWorkOrderMapper;
|
|
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.DeviceServiceImpl;
|
|
import cn.iocoder.yudao.module.pms.service.inspect.IotInspectOrderService;
|
|
import cn.iocoder.yudao.module.pms.service.inspect.IotInspectOrderService;
|
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
|
|
+import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
|
|
|
+import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
|
import com.alibaba.fastjson.JSON;
|
|
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 lombok.Data;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
-import org.jetbrains.annotations.NotNull;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
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;
|
|
@@ -56,6 +66,16 @@ public class IotStaticController {
|
|
private IotInspectOrderService iotInspectOrderService;
|
|
private IotInspectOrderService iotInspectOrderService;
|
|
@Autowired
|
|
@Autowired
|
|
private IotMainWorkOrderMapper iotMainWorkOrderMapper;
|
|
private IotMainWorkOrderMapper iotMainWorkOrderMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private DeviceServiceImpl deviceServiceImpl;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IotDeviceMapper iotDeviceMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IotProductClassifyMapper iotProductClassifyMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private DeptApi deptApi;
|
|
|
|
+ @Autowired
|
|
|
|
+ private AdminUserApi adminUserApi;
|
|
|
|
|
|
@GetMapping("/main/day")
|
|
@GetMapping("/main/day")
|
|
public CommonResult<Map<String, Object>> getMaintainDay() {
|
|
public CommonResult<Map<String, Object>> getMaintainDay() {
|
|
@@ -317,4 +337,93 @@ public class IotStaticController {
|
|
});
|
|
});
|
|
return CommonResult.success(deviceVOS);
|
|
return CommonResult.success(deviceVOS);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @GetMapping("/home/device/count")
|
|
|
|
+ public CommonResult<ImmutableMap<Object, Object>> getHomeDeviceCountStat() {
|
|
|
|
+ Long deviceCount = iotDeviceMapper.selectCount();
|
|
|
|
+ ImmutableMap<String, LocalDateTime> beginEndDay = DateUtils.getBeginEndDay(0);
|
|
|
|
+ IotDevicePageReqVO iotDevicePageReqVO = new IotDevicePageReqVO();
|
|
|
|
+ iotDevicePageReqVO.setCreateTime(new LocalDateTime[]{beginEndDay.get("start"), beginEndDay.get("end")});
|
|
|
|
+ Long deviceToday = iotDeviceMapper.selectCountByTimeAndStatus(iotDevicePageReqVO);
|
|
|
|
+ return CommonResult.success(ImmutableMap.of("total", deviceCount,"today", deviceToday));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/home/maintain/count")
|
|
|
|
+ public CommonResult<ImmutableMap<Object, Object>> getHomeMaintainCountStat() {
|
|
|
|
+ ImmutableMap<String, LocalDateTime> beginEndDay = DateUtils.getBeginEndDay(0);
|
|
|
|
+ Long maintainCount = iotMaintainMapper.selectCount();
|
|
|
|
+ IotMaintainPageReqVO iotMaintainPageReqVO = new IotMaintainPageReqVO();
|
|
|
|
+ iotMaintainPageReqVO.setCreateTime(new LocalDateTime[]{beginEndDay.get("start"), beginEndDay.get("end")});
|
|
|
|
+ Long maintainToday = iotMaintainMapper.selectCountByTimeAndStatus(iotMaintainPageReqVO);
|
|
|
|
+ return CommonResult.success(ImmutableMap.of("total", maintainCount, "today", maintainToday));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/home/work/count")
|
|
|
|
+ public CommonResult<ImmutableMap<Object, Object>> getHomeWorkCountStat() {
|
|
|
|
+ ImmutableMap<String, LocalDateTime> beginEndDay = DateUtils.getBeginEndDay(0);
|
|
|
|
+ Long workCount = iotMainWorkOrderMapper.selectCount();
|
|
|
|
+ IotMainWorkOrderPageReqVO iotMainWorkOrderPageReqVO = new IotMainWorkOrderPageReqVO();
|
|
|
|
+ iotMainWorkOrderPageReqVO.setCreateTime(new LocalDateTime[]{beginEndDay.get("start"), beginEndDay.get("end")});
|
|
|
|
+ Long workToday = iotMainWorkOrderMapper.selectCountByTimeAndStatus(iotMainWorkOrderPageReqVO);
|
|
|
|
+ return CommonResult.success(ImmutableMap.of("total", workCount, "today", workToday));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/home/inspect/count")
|
|
|
|
+ public CommonResult<ImmutableMap<Object, Object>> getHomeInspectCountStat() {
|
|
|
|
+ ImmutableMap<String, LocalDateTime> beginEndDay = DateUtils.getBeginEndDay(0);
|
|
|
|
+ Long inspectCount = iotInspectOrderMapper.selectCount();
|
|
|
|
+ IotInspectOrderPageReqVO iotInspectOrderPageReqVO = new IotInspectOrderPageReqVO();
|
|
|
|
+ iotInspectOrderPageReqVO.setCreateTime(new LocalDateTime[]{beginEndDay.get("start"), beginEndDay.get("end")});
|
|
|
|
+ Long inspectToday = iotInspectOrderMapper.selectCountByTimeAndStatus(iotInspectOrderPageReqVO);
|
|
|
|
+ return CommonResult.success(ImmutableMap.of("total", inspectCount, "today", inspectToday));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private DictDataService dictDataService;
|
|
|
|
+ @GetMapping("/home/device/status")
|
|
|
|
+ public CommonResult<Map<String, Long>> getDeviceStatusStat() {
|
|
|
|
+ List<IotDeviceDO> iotDeviceDOS = iotDeviceMapper.selectList();
|
|
|
|
+ Map<String, Long> order = iotDeviceDOS.stream().collect(Collectors.groupingBy(IotDeviceDO::getDeviceStatus, Collectors.counting()));
|
|
|
|
+ Map<String, Long> resultMap = new HashMap<>(order.size());
|
|
|
|
+ List<DictDataDO> pmsDeviceStatus = dictDataService.getDictDataListByDictType("pms_device_status");
|
|
|
|
+ order.forEach((k,v)->{
|
|
|
|
+ pmsDeviceStatus.stream().filter(e -> e.getValue().equals(k)).findFirst().ifPresent(e -> {
|
|
|
|
+ resultMap.put(e.getLabel(), v);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ return CommonResult.success(resultMap);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/home/device/type")
|
|
|
|
+ public CommonResult<List<Map<String, Object>>> getDeviceTypeStat() {
|
|
|
|
+ List<IotDeviceDO> iotDeviceDOS = iotDeviceMapper.selectList();
|
|
|
|
+ List<Map.Entry<Long, Long>> collect = iotDeviceDOS.stream().collect(Collectors.groupingBy(IotDeviceDO::getAssetClass, Collectors.counting())).entrySet().stream().sorted(Map.Entry.<Long, Long>comparingByValue().reversed())
|
|
|
|
+ .limit(5)
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ List<Map<String, Object>> results = new ArrayList<>(collect.size());
|
|
|
|
+ collect.forEach(e ->{
|
|
|
|
+ IotProductClassifyDO iotProductClassifyDO = iotProductClassifyMapper.selectById(e.getKey());
|
|
|
|
+ Map<String, Object> map = new HashMap<>(4);
|
|
|
|
+ map.put("category", iotProductClassifyDO.getName());
|
|
|
|
+ map.put("value", e.getValue());
|
|
|
|
+ results.add(map);
|
|
|
|
+ });
|
|
|
|
+ return CommonResult.success(results);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Data
|
|
|
|
+ public static class ActiveDept {
|
|
|
|
+ private String deptName;
|
|
|
|
+ private Long active;
|
|
|
|
+ private Long total;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/home/dept")
|
|
|
|
+ public CommonResult<List<Pms.deptStat>> getActiveDeptStat() {
|
|
|
|
+ List<Pms.deptStat> userCountByDeptId = adminUserApi.getUserCountByDeptId(null);
|
|
|
|
+ return CommonResult.success(userCountByDeptId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|