|
|
@@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDevicePageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceSimple;
|
|
|
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.mysql.IotDeviceMapper;
|
|
|
@@ -31,7 +32,9 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.annotation.security.PermitAll;
|
|
|
import javax.validation.Valid;
|
|
|
+import java.sql.Array;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
@@ -43,16 +46,19 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
|
|
|
@Validated
|
|
|
@PermitAll
|
|
|
public class IotReportDeviceController {
|
|
|
- private static final ImmutableList<String> jt = ImmutableList.<String>builder()
|
|
|
- .add("提纯撬", "空气处理撬", "膜组", "注水泵", "绞车") // 第二批5个
|
|
|
- .add("井架", "底座", "发动机", "泥浆泵", "连油主车") // 第三批5个
|
|
|
+ private static final ImmutableList<Integer> jt = ImmutableList.<Integer>builder()
|
|
|
+ .add(159, 160, 232, 157, 158) // 第一批5个
|
|
|
+ .add(107, 119, 106, 108, 19)
|
|
|
+ .add(191, 28,30,35)
|
|
|
+ .add(85, 90, 177, 144, 31) // 第三批5个
|
|
|
.build();
|
|
|
- private static final ImmutableList<String> rh = ImmutableList.<String>builder()
|
|
|
- .add("提纯撬", "空气处理撬", "膜组", "注水泵").build();
|
|
|
- private static final ImmutableList<String> ry = ImmutableList.<String>builder()
|
|
|
- .add("井架", "底座", "发动机", "泥浆泵","绞车").build();
|
|
|
- private static final ImmutableList<String> rd = ImmutableList.<String>builder()
|
|
|
- .add("连油主车","混砂车","仪表车","小车").build();
|
|
|
+ private static final ImmutableList<Integer> rh = ImmutableList.<Integer>builder()
|
|
|
+ .add(159, 160, 232, 157, 158) // 第一批5个
|
|
|
+ .add(107, 119, 106, 108,191).build();
|
|
|
+ private static final ImmutableList<Integer> ry = ImmutableList.<Integer>builder()
|
|
|
+ .add(85, 90, 177, 144,19).build();
|
|
|
+ private static final ImmutableList<Integer> rd = ImmutableList.<Integer>builder()
|
|
|
+ .add(31,28,30,35).build();
|
|
|
private final DeptApi deptApi;
|
|
|
private final IotDeviceMapper iotDeviceMapper;
|
|
|
private final IotProductClassifyMapper iotProductClassifyMapper;
|
|
|
@@ -73,7 +79,7 @@ public class IotReportDeviceController {
|
|
|
|
|
|
@Operation(summary = "类别统计")
|
|
|
@GetMapping("/device/type")
|
|
|
- public CommonResult<List<Map<String, Object>>> getDeviceTypeStat(@Valid IotDevicePageReqVO iotDevicePageReqVO) {
|
|
|
+ public CommonResult<List<IotDeviceSimple>> getDeviceTypeStat(@Valid IotDevicePageReqVO iotDevicePageReqVO) {
|
|
|
Set<Long> ids;
|
|
|
String companyCode;
|
|
|
if (Objects.isNull(iotDevicePageReqVO.getDeptId())){
|
|
|
@@ -87,42 +93,97 @@ public class IotReportDeviceController {
|
|
|
}
|
|
|
IotDevicePageReqVO pageReqVO = new IotDevicePageReqVO();
|
|
|
pageReqVO.setDeptIds(new ArrayList<>(ids));
|
|
|
- List<IotDeviceDO> iotDeviceDOS = iotDeviceMapper.selectList(pageReqVO);
|
|
|
- LinkedList<Map<String, Object>> results = new LinkedList<>();
|
|
|
- List<Map.Entry<Long, Long>> collect = iotDeviceDOS.stream().collect(Collectors.groupingBy(IotDeviceDO::getAssetClass, Collectors.counting())).entrySet().stream().sorted(Map.Entry.<Long, Long>comparingByValue().reversed()).collect(Collectors.toList());
|
|
|
- collect.forEach(e->{
|
|
|
- IotProductClassifyDO iotProductClassifyDO = iotProductClassifyMapper.selectById(e.getKey());
|
|
|
- if ("jt".equals(companyCode)) {
|
|
|
- if (jt.contains(iotProductClassifyDO.getName())||"空压机".equals(iotProductClassifyDO.getName())||iotProductClassifyDO.getName().contains("驱增压机")) {
|
|
|
- Map<String, Object> map = new HashMap<>(4);
|
|
|
- map.put("category", iotProductClassifyDO.getName());
|
|
|
- map.put("value", e.getValue());
|
|
|
- results.add(map);
|
|
|
+ if ("jt".equals(companyCode)) {
|
|
|
+ List<IotDeviceSimple> iotDeviceSimples = iotDeviceMapper.selectTypeNumber(pageReqVO, jt);
|
|
|
+ AtomicInteger zyj = new AtomicInteger();
|
|
|
+ AtomicInteger kyj = new AtomicInteger();
|
|
|
+ iotDeviceSimples.forEach(e ->{
|
|
|
+ if ("电驱增压机".equals(e.getCategory())||"柴驱增压机".equals(e.getCategory())||"液驱增压机".equals(e.getCategory())) {
|
|
|
+ zyj.addAndGet(Math.toIntExact(e.getValue()==null?0:e.getValue()));
|
|
|
}
|
|
|
- } else if ("rh".equals(companyCode)) {
|
|
|
- if (rh.contains(iotProductClassifyDO.getName())||"空压机".equals(iotProductClassifyDO.getName())||iotProductClassifyDO.getName().contains("驱增压机")){
|
|
|
- Map<String, Object> map = new HashMap<>(4);
|
|
|
- map.put("category", iotProductClassifyDO.getName());
|
|
|
- map.put("value", e.getValue());
|
|
|
- results.add(map);
|
|
|
+ if ("电驱空压机".equals(e.getCategory())||"柴驱空压机".equals(e.getCategory())||"天然气驱空压机".equals(e.getCategory())) {
|
|
|
+ kyj.addAndGet(Math.toIntExact(e.getValue()==null?0:e.getValue()));
|
|
|
}
|
|
|
- } else if ("ry".equals(companyCode)) {
|
|
|
- if (ry.contains(iotProductClassifyDO.getName())){
|
|
|
- Map<String, Object> map = new HashMap<>(4);
|
|
|
- map.put("category", iotProductClassifyDO.getName());
|
|
|
- map.put("value", e.getValue());
|
|
|
- results.add(map);
|
|
|
+ });
|
|
|
+ List<IotDeviceSimple> result = iotDeviceSimples.stream().filter(e -> !"电驱增压机".equals(e.getCategory()) && !"柴驱增压机".equals(e.getCategory()) && !"液驱增压机".equals(e.getCategory())
|
|
|
+ && !"电驱空压机".equals(e.getCategory()) && !"柴驱空压机".equals(e.getCategory()) && !"天然气驱空压机".equals(e.getCategory())).collect(Collectors.toList());
|
|
|
+ IotDeviceSimple iotDeviceSimple = new IotDeviceSimple();
|
|
|
+ iotDeviceSimple.setCategory("增压机");
|
|
|
+ iotDeviceSimple.setValue(zyj.longValue());
|
|
|
+ result.add(iotDeviceSimple);
|
|
|
+ IotDeviceSimple iotDeviceSimple1 = new IotDeviceSimple();
|
|
|
+ iotDeviceSimple1.setCategory("空压机");
|
|
|
+ iotDeviceSimple1.setValue(kyj.longValue());
|
|
|
+ result.add(iotDeviceSimple1);
|
|
|
+ return CommonResult.success((result.stream().sorted(Comparator.comparing(IotDeviceSimple::getValue).reversed())).collect(Collectors.toList()));
|
|
|
+ } else if ("rh".equals(companyCode)) {
|
|
|
+ List<IotDeviceSimple> iotDeviceSimples = iotDeviceMapper.selectTypeNumber(pageReqVO, rh);
|
|
|
+ AtomicInteger zyj = new AtomicInteger();
|
|
|
+ AtomicInteger kyj = new AtomicInteger();
|
|
|
+ iotDeviceSimples.forEach(e ->{
|
|
|
+ if ("电驱增压机".equals(e.getCategory())||"柴驱增压机".equals(e.getCategory())||"液驱增压机".equals(e.getCategory())) {
|
|
|
+ zyj.addAndGet(Math.toIntExact(e.getValue()==null?0:e.getValue()));
|
|
|
}
|
|
|
- } else if ("rd".equals(companyCode)) {
|
|
|
- if (rd.contains(iotProductClassifyDO.getName())||iotProductClassifyDO.getName().contains("压裂泵车")){
|
|
|
- Map<String, Object> map = new HashMap<>(4);
|
|
|
- map.put("category", iotProductClassifyDO.getName());
|
|
|
- map.put("value", e.getValue());
|
|
|
- results.add(map);
|
|
|
+ if ("电驱空压机".equals(e.getCategory())||"柴驱空压机".equals(e.getCategory())||"天然气驱空压机".equals(e.getCategory())) {
|
|
|
+ kyj.addAndGet(Math.toIntExact(e.getValue()==null?0:e.getValue()));
|
|
|
}
|
|
|
- }
|
|
|
- });
|
|
|
- return CommonResult.success(results);
|
|
|
+ });
|
|
|
+ List<IotDeviceSimple> result = iotDeviceSimples.stream().filter(e -> !"电驱增压机".equals(e.getCategory()) && !"柴驱增压机".equals(e.getCategory()) && !"液驱增压机".equals(e.getCategory())
|
|
|
+ && !"电驱空压机".equals(e.getCategory()) && !"柴驱空压机".equals(e.getCategory()) && !"天然气驱空压机".equals(e.getCategory())).collect(Collectors.toList());
|
|
|
+ IotDeviceSimple iotDeviceSimple = new IotDeviceSimple();
|
|
|
+ iotDeviceSimple.setCategory("增压机");
|
|
|
+ iotDeviceSimple.setValue(zyj.longValue());
|
|
|
+ result.add(iotDeviceSimple);
|
|
|
+ IotDeviceSimple iotDeviceSimple1 = new IotDeviceSimple();
|
|
|
+ iotDeviceSimple1.setCategory("空压机");
|
|
|
+ iotDeviceSimple1.setValue(kyj.longValue());
|
|
|
+ result.add(iotDeviceSimple1);
|
|
|
+ return CommonResult.success((result.stream().sorted(Comparator.comparing(IotDeviceSimple::getValue).reversed())).collect(Collectors.toList()));
|
|
|
+ } else if ("ry".equals(companyCode)) {
|
|
|
+ List<IotDeviceSimple> iotDeviceSimples = iotDeviceMapper.selectTypeNumber(pageReqVO, ry);
|
|
|
+ return CommonResult.success((iotDeviceSimples.stream().sorted(Comparator.comparing(IotDeviceSimple::getValue).reversed())).collect(Collectors.toList()));
|
|
|
+ } else if ("rd".equals(companyCode)) {
|
|
|
+ List<IotDeviceSimple> iotDeviceSimples = iotDeviceMapper.selectTypeNumber(pageReqVO, rd);
|
|
|
+ return CommonResult.success((iotDeviceSimples.stream().sorted(Comparator.comparing(IotDeviceSimple::getValue).reversed())).collect(Collectors.toList()));
|
|
|
+ } else {
|
|
|
+ return CommonResult.success(new ArrayList<>());
|
|
|
+ }
|
|
|
+// List<IotDeviceDO> iotDeviceDOS = iotDeviceMapper.selectList(pageReqVO);
|
|
|
+// LinkedList<Map<String, Object>> results = new LinkedList<>();
|
|
|
+// List<Map.Entry<Long, Long>> collect = iotDeviceDOS.stream().collect(Collectors.groupingBy(IotDeviceDO::getAssetClass, Collectors.counting())).entrySet().stream().sorted(Map.Entry.<Long, Long>comparingByValue().reversed()).collect(Collectors.toList());
|
|
|
+// collect.forEach(e->{
|
|
|
+// IotProductClassifyDO iotProductClassifyDO = iotProductClassifyMapper.selectById(e.getKey());
|
|
|
+// if ("jt".equals(companyCode)) {
|
|
|
+// if (jt.contains(iotProductClassifyDO.getName())||"空压机".equals(iotProductClassifyDO.getName())||iotProductClassifyDO.getName().contains("驱增压机")) {
|
|
|
+// Map<String, Object> map = new HashMap<>(4);
|
|
|
+// map.put("category", iotProductClassifyDO.getName());
|
|
|
+// map.put("value", e.getValue());
|
|
|
+// results.add(map);
|
|
|
+// }
|
|
|
+// } else if ("rh".equals(companyCode)) {
|
|
|
+// if (rh.contains(iotProductClassifyDO.getName())||"空压机".equals(iotProductClassifyDO.getName())||iotProductClassifyDO.getName().contains("驱增压机")){
|
|
|
+// Map<String, Object> map = new HashMap<>(4);
|
|
|
+// map.put("category", iotProductClassifyDO.getName());
|
|
|
+// map.put("value", e.getValue());
|
|
|
+// results.add(map);
|
|
|
+// }
|
|
|
+// } else if ("ry".equals(companyCode)) {
|
|
|
+// if (ry.contains(iotProductClassifyDO.getName())){
|
|
|
+// Map<String, Object> map = new HashMap<>(4);
|
|
|
+// map.put("category", iotProductClassifyDO.getName());
|
|
|
+// map.put("value", e.getValue());
|
|
|
+// results.add(map);
|
|
|
+// }
|
|
|
+// } else if ("rd".equals(companyCode)) {
|
|
|
+// if (rd.contains(iotProductClassifyDO.getName())||iotProductClassifyDO.getName().contains("压裂泵车")){
|
|
|
+// Map<String, Object> map = new HashMap<>(4);
|
|
|
+// map.put("category", iotProductClassifyDO.getName());
|
|
|
+// map.put("value", e.getValue());
|
|
|
+// results.add(map);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// });
|
|
|
+// return CommonResult.success(results);
|
|
|
}
|
|
|
|
|
|
|