|
@@ -36,6 +36,7 @@ import cn.iocoder.yudao.module.pms.service.DeviceServiceImpl;
|
|
|
import cn.iocoder.yudao.module.pms.service.inspect.IotInspectOrderService;
|
|
|
import cn.iocoder.yudao.module.pms.service.maintain.IotMaintainService;
|
|
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
|
|
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.dept.DeptService;
|
|
@@ -55,6 +56,7 @@ import javax.annotation.Resource;
|
|
|
import javax.annotation.security.PermitAll;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.Serializable;
|
|
|
+import java.sql.Array;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
@@ -239,12 +241,21 @@ public class IotStaticController {
|
|
|
return CommonResult.success(order);
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/inspect/statuss/{dept}")
|
|
|
+ public CommonResult<Map<String, Long>> getInspectStatusInfos(@PathVariable("dept") String dept) {
|
|
|
+ Set<Long> ids = getDeptIds(dept);
|
|
|
+ IotCountDataDO vo = new IotCountDataDO();
|
|
|
+ List<IotInspectOrderDO> iotInspectOrderDOS = iotInspectOrderMapper.selectListStat(vo, ids);
|
|
|
+ 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);
|
|
|
+ List<IotInspectOrderDO> iotInspectOrderDOS = iotInspectOrderMapper.selectListByCreateTime(iotInspectOrderPageReqVO, new HashSet<>());
|
|
|
Map<String, Long> order = iotInspectOrderDOS.stream().collect(Collectors.groupingBy(IotInspectOrderDO::getStatus, Collectors.counting()));
|
|
|
return CommonResult.success(order);
|
|
|
}
|
|
@@ -308,9 +319,12 @@ public class IotStaticController {
|
|
|
return CommonResult.success(ImmutableMap.of("total", total,"todo", todo));
|
|
|
}
|
|
|
|
|
|
- @GetMapping("/maintenance/status")
|
|
|
- public CommonResult<Map<String, Long>> getMaintenanceStatusInfo() {
|
|
|
- List<IotMainWorkOrderDO> iotMainWorkOrderDOS = iotMainWorkOrderMapper.selectList();
|
|
|
+ @GetMapping("/maintenance/status/{dept}")
|
|
|
+ public CommonResult<Map<String, Long>> getMaintenanceStatusInfo(@PathVariable("dept") String dept) {
|
|
|
+ Set<Long> ids = getDeptIds(dept);
|
|
|
+ IotMainWorkOrderPageReqVO reqVO = new IotMainWorkOrderPageReqVO();
|
|
|
+ reqVO.setDeptIds(ids);
|
|
|
+ List<IotMainWorkOrderDO> iotMainWorkOrderDOS = iotMainWorkOrderMapper.selectList(reqVO);
|
|
|
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)->{
|
|
@@ -328,7 +342,7 @@ public class IotStaticController {
|
|
|
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);
|
|
|
+ List<IotMainWorkOrderDO> iotInspectOrderDOS = iotMainWorkOrderMapper.selectListByCreateTime(iotMainWorkOrderPageReqVO, new HashSet<>());
|
|
|
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)->{
|
|
@@ -392,10 +406,29 @@ public class IotStaticController {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private Set<Long> getDeptIds(String dept) {
|
|
|
+ Set<Long> ids = new HashSet<>();
|
|
|
+ List<DeptRespDTO> depts = new ArrayList<>();
|
|
|
+ if ("rd".equals(dept)) {
|
|
|
+ depts = deptApi.getDeptByName("四川瑞都");
|
|
|
+ } else if ("rh".equals(dept)) {
|
|
|
+ depts = deptApi.getDeptByName("瑞恒兴域");
|
|
|
+ } else if ("ry".equals(dept)) {
|
|
|
+ depts = deptApi.getDeptByName("瑞鹰国际");
|
|
|
+ }
|
|
|
+ if (CollUtil.isNotEmpty(depts)) {
|
|
|
+ if (Objects.nonNull(depts.get(0).getId())) {
|
|
|
+ ids = deptService.getChildDeptIdListFromCache(depts.get(0).getId());
|
|
|
+ ids.add(depts.get(0).getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ids;
|
|
|
+ }
|
|
|
|
|
|
- @GetMapping("/home/device/count")
|
|
|
- public CommonResult<ImmutableMap<Object, Object>> getHomeDeviceCountStat() {
|
|
|
- Long deviceCount = iotDeviceMapper.selectCount();
|
|
|
+ @GetMapping("/home/device/count/{dept}")
|
|
|
+ public CommonResult<ImmutableMap<Object, Object>> getHomeDeviceCountStat(@PathVariable("dept") String dept) {
|
|
|
+ Set<Long> ids = getDeptIds(dept);
|
|
|
+ Long deviceCount = iotDeviceMapper.selectByDept(ids);
|
|
|
ImmutableMap<String, LocalDateTime> beginEndDay = DateUtils.getBeginEndDay(0);
|
|
|
IotDevicePageReqVO iotDevicePageReqVO = new IotDevicePageReqVO();
|
|
|
iotDevicePageReqVO.setCreateTime(new LocalDateTime[]{beginEndDay.get("start"), beginEndDay.get("end")});
|
|
@@ -403,10 +436,12 @@ public class IotStaticController {
|
|
|
return CommonResult.success(ImmutableMap.of("total", deviceCount,"today", deviceToday));
|
|
|
}
|
|
|
|
|
|
- @GetMapping("/home/maintain/count")
|
|
|
- public CommonResult<ImmutableMap<Object, Object>> getHomeMaintainCountStat() {
|
|
|
+ @GetMapping("/home/maintain/count/{dept}")
|
|
|
+ public CommonResult<ImmutableMap<Object, Object>> getHomeMaintainCountStat(@PathVariable("dept") String dept) {
|
|
|
ImmutableMap<String, LocalDateTime> beginEndDay = DateUtils.getBeginEndDay(0);
|
|
|
- Long maintainCount = iotMaintainMapper.selectCount();
|
|
|
+ Set<Long> ids = getDeptIds(dept);
|
|
|
+
|
|
|
+ Long maintainCount = iotMaintainMapper.selectByDept(ids);
|
|
|
IotMaintainPageReqVO iotMaintainPageReqVO = new IotMaintainPageReqVO();
|
|
|
iotMaintainPageReqVO.setCreateTime(new LocalDateTime[]{beginEndDay.get("start"), beginEndDay.get("end")});
|
|
|
Long maintainToday = iotMaintainMapper.selectCountByTimeAndStatus(iotMaintainPageReqVO);
|
|
@@ -435,9 +470,12 @@ public class IotStaticController {
|
|
|
|
|
|
@Resource
|
|
|
private DictDataService dictDataService;
|
|
|
- @GetMapping("/home/device/status")
|
|
|
- public CommonResult<List<Map<String, Object>>> getDeviceStatusStat() {
|
|
|
- List<IotDeviceDO> iotDeviceDOS = iotDeviceMapper.selectList();
|
|
|
+ @GetMapping("/home/device/status/{dept}")
|
|
|
+ public CommonResult<List<Map<String, Object>>> getDeviceStatusStat(@PathVariable("dept") String dept) {
|
|
|
+ Set<Long> ids = getDeptIds(dept);
|
|
|
+ IotDevicePageReqVO iotDevicePageReqVO = new IotDevicePageReqVO();
|
|
|
+ iotDevicePageReqVO.setDeviceIds(new ArrayList<>(ids));
|
|
|
+ List<IotDeviceDO> iotDeviceDOS = iotDeviceMapper.selectList(iotDevicePageReqVO);
|
|
|
Map<String, Long> order = iotDeviceDOS.stream().collect(Collectors.groupingBy(IotDeviceDO::getDeviceStatus, Collectors.counting()));
|
|
|
List<Map<String, Object>> results = new ArrayList<>();
|
|
|
List<DictDataDO> pmsDeviceStatus = dictDataService.getDictDataListByDictType("pms_device_status");
|
|
@@ -452,9 +490,12 @@ public class IotStaticController {
|
|
|
return CommonResult.success(results);
|
|
|
}
|
|
|
|
|
|
- @GetMapping("/home/device/type")
|
|
|
- public CommonResult<List<Map<String, Object>>> getDeviceTypeStat() {
|
|
|
- List<IotDeviceDO> iotDeviceDOS = iotDeviceMapper.selectList();
|
|
|
+ @GetMapping("/home/device/type/{dept}")
|
|
|
+ public CommonResult<List<Map<String, Object>>> getDeviceTypeStat(@PathVariable("dept") String dept) {
|
|
|
+ Set<Long> ids = getDeptIds(dept);
|
|
|
+ IotDevicePageReqVO iotDevicePageReqVO = new IotDevicePageReqVO();
|
|
|
+ iotDevicePageReqVO.setDeviceIds(new ArrayList<>(ids));
|
|
|
+ List<IotDeviceDO> iotDeviceDOS = iotDeviceMapper.selectList(iotDevicePageReqVO);
|
|
|
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());
|
|
@@ -523,9 +564,10 @@ public class IotStaticController {
|
|
|
return success(ImmutableMap.of("todo", todo.get(),"finished", finished.get()));
|
|
|
}
|
|
|
|
|
|
- @GetMapping("/rh/order")
|
|
|
+ @GetMapping("/rh/order/{dept}")
|
|
|
@PermitAll
|
|
|
- public CommonResult<Map<String, Object>> getOrderNumberStat() {
|
|
|
+ public CommonResult<Map<String, Object>> getOrderNumberStat(@PathVariable("dept") String dept) {
|
|
|
+ Set<Long> ids = getDeptIds(dept);
|
|
|
List<String> lastSevenDays = DateUtils.getLastSevenDays();
|
|
|
String first = lastSevenDays.get(0);
|
|
|
String last = lastSevenDays.get(lastSevenDays.size() - 1);
|
|
@@ -535,6 +577,7 @@ public class IotStaticController {
|
|
|
|
|
|
IotOpeationFillPageReqVO iotOpeationFillPageReqVO = new IotOpeationFillPageReqVO();
|
|
|
iotOpeationFillPageReqVO.setCreateTime(createTime);
|
|
|
+ iotOpeationFillPageReqVO.setDeptIds(new ArrayList<>(ids));
|
|
|
List<Map<String, Object>> fills = iotOpeationFillMapper.selectListByCreateTime(iotOpeationFillPageReqVO).stream().map(e -> {
|
|
|
Map<String, Object> abc = new HashMap<>();
|
|
|
abc.put("id", e.getId());
|
|
@@ -551,7 +594,7 @@ public class IotStaticController {
|
|
|
|
|
|
IotMaintainPageReqVO iotMaintainPageReqVO = new IotMaintainPageReqVO();
|
|
|
iotMaintainPageReqVO.setCreateTime(createTime);
|
|
|
- List<Map<String, Object>> maintains = iotMaintainMapper.selectListByCreateTime(iotMaintainPageReqVO).stream().map(e -> {
|
|
|
+ List<Map<String, Object>> maintains = iotMaintainMapper.selectListByCreateTime(iotMaintainPageReqVO, ids).stream().map(e -> {
|
|
|
Map<String, Object> abc = new HashMap<>();
|
|
|
abc.put("id", e.getId());
|
|
|
abc.put("createTime", e.getCreateTime());
|
|
@@ -565,7 +608,7 @@ public class IotStaticController {
|
|
|
|
|
|
IotMainWorkOrderPageReqVO iotMainWorkOrderPageReqVO = new IotMainWorkOrderPageReqVO();
|
|
|
iotMainWorkOrderPageReqVO.setCreateTime(createTime);
|
|
|
- List<Map<String, Object>> works = iotMainWorkOrderMapper.selectListByCreateTime(iotMainWorkOrderPageReqVO).stream().map(e -> {
|
|
|
+ List<Map<String, Object>> works = iotMainWorkOrderMapper.selectListByCreateTime(iotMainWorkOrderPageReqVO,ids).stream().map(e -> {
|
|
|
Map<String, Object> abc = new HashMap<>();
|
|
|
abc.put("id", e.getId());
|
|
|
abc.put("createTime", e.getCreateTime());
|
|
@@ -580,7 +623,7 @@ public class IotStaticController {
|
|
|
|
|
|
IotInspectOrderPageReqVO iotInspectOrderPageReqVO = new IotInspectOrderPageReqVO();
|
|
|
iotInspectOrderPageReqVO.setCreateTime(createTime);
|
|
|
- List<Map<String, Object>> inspects = iotInspectOrderMapper.selectListByCreateTime(iotInspectOrderPageReqVO).stream().map(e -> {
|
|
|
+ List<Map<String, Object>> inspects = iotInspectOrderMapper.selectListByCreateTime(iotInspectOrderPageReqVO,ids).stream().map(e -> {
|
|
|
Map<String, Object> abc = new HashMap<>();
|
|
|
abc.put("id", e.getId());
|
|
|
abc.put("createTime", e.getCreateTime());
|