|
|
@@ -12,8 +12,10 @@ import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceSimple;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotReportDeviceRespVO;
|
|
|
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.yfclass.IotYfClassifyDO;
|
|
|
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.yfclass.IotYfClassifyMapper;
|
|
|
import cn.iocoder.yudao.module.pms.service.IotProductClassifyService;
|
|
|
import cn.iocoder.yudao.module.pms.util.IotDeviceConvert;
|
|
|
import cn.iocoder.yudao.module.supplier.dal.dataobject.product.SupplierDO;
|
|
|
@@ -28,6 +30,7 @@ import com.google.common.collect.ImmutableList;
|
|
|
import com.google.common.collect.ImmutableMap;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
@@ -81,6 +84,8 @@ public class IotReportDeviceController {
|
|
|
private IotProductClassifyService iotProductClassifyService;
|
|
|
@Resource
|
|
|
private SupplierService supplierService;
|
|
|
+ @Autowired
|
|
|
+ private IotYfClassifyMapper iotYfClassifyMapper;
|
|
|
|
|
|
public IotReportDeviceController(DeptApi deptApi, IotDeviceMapper iotDeviceMapper, IotProductClassifyMapper iotProductClassifyMapper, DeptUtil deptUtil) {
|
|
|
this.deptApi = deptApi;
|
|
|
@@ -155,8 +160,47 @@ public class IotReportDeviceController {
|
|
|
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()));
|
|
|
+ // 设置 新设备分类 数量统计
|
|
|
+ List<IotDeviceDO> devices = iotDeviceMapper.selectListAlone(pageReqVO);
|
|
|
+ Map<String, Long> assetCountMap = devices.stream()
|
|
|
+ .filter(device -> StringUtils.isNotBlank(device.getYfClass()))
|
|
|
+ .collect(Collectors.groupingBy(IotDeviceDO::getYfClass, Collectors.counting()));
|
|
|
+
|
|
|
+ // 获取新分类字典(主设备类别)
|
|
|
+ List<DictDataDO> newClassifyDictData = dictDataService.getDictDataListByDictType("rq_iot_rd_device_new_classify");
|
|
|
+ Set<String> mainClassifyCodes = newClassifyDictData.stream()
|
|
|
+ .map(DictDataDO::getValue)
|
|
|
+ .filter(StringUtils::isNotBlank)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+
|
|
|
+ List<IotDeviceSimple> result = assetCountMap.entrySet().stream()
|
|
|
+ .filter(e -> StringUtils.isNotBlank(e.getKey()))
|
|
|
+ .map(e -> {
|
|
|
+ String code = StringUtils.substringAfterLast(e.getKey(), ",");
|
|
|
+ List<IotYfClassifyDO> yfClassList = iotYfClassifyMapper.selectList("code", code);
|
|
|
+ if (CollUtil.isEmpty(yfClassList)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ IotDeviceSimple simple = new IotDeviceSimple();
|
|
|
+ simple.setCategory(yfClassList.get(0).getName());
|
|
|
+ simple.setValue(e.getValue());
|
|
|
+ simple.setDeviceCode(mainClassifyCodes.contains(code) ? "top" : "");
|
|
|
+ return simple;
|
|
|
+ })
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .sorted((a, b) -> {
|
|
|
+ boolean aTop = "top".equals(a.getDeviceCode());
|
|
|
+ boolean bTop = "top".equals(b.getDeviceCode());
|
|
|
+ if (aTop != bTop) {
|
|
|
+ return aTop ? -1 : 1;
|
|
|
+ }
|
|
|
+ return Long.compare(b.getValue(), a.getValue());
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ return CommonResult.success(result);
|
|
|
+ // 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<>());
|
|
|
}
|