lipenghui 2 долоо хоног өмнө
parent
commit
dab7d255e4

+ 1 - 1
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/utils/FileTypeUtils.java

@@ -63,9 +63,9 @@ public class FileTypeUtils {
         response.setHeader("Content-Disposition", "attachment;filename=" + HttpUtils.encodeUtf8(filename));
         String contentType = getMineType(content, filename);
         response.setContentType(contentType);
+        response.setHeader("Content-Length", String.valueOf(content.length - 1));
         // 针对 video 的特殊处理,解决视频地址在移动端播放的兼容性问题
         if (StrUtil.containsIgnoreCase(contentType, "video")) {
-            response.setHeader("Content-Length", String.valueOf(content.length - 1));
             response.setHeader("Content-Range", String.valueOf(content.length - 1));
             response.setHeader("Accept-Ranges", "bytes");
         }

+ 8 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/IotDeviceController.java

@@ -143,8 +143,8 @@ public class IotDeviceController {
         IotDeviceDO iotDevice = iotDeviceService.getIotDevice(id);
         IotDeviceRespVO iotDeviceRespVO = new IotDeviceRespVO();
         BeanUtils.copyProperties(iotDevice, iotDeviceRespVO);
-        DictDataDO dictData = dictDataService.getDictData(iotDevice.getBrand());
-        iotDeviceRespVO.setBrandName(Objects.nonNull(dictData)?dictData.getLabel():"");
+//        DictDataDO dictData = dictDataService.getDictData(iotDevice.getBrand());
+//        iotDeviceRespVO.setBrandName(Objects.nonNull(dictData)?dictData.getLabel():"");
         SupplierDO supplierDO = supplierService.get(iotDevice.getSupplierId());
         iotDeviceRespVO.setSupplierName(Objects.nonNull(supplierDO)?supplierDO.getName():"");
         SupplierDO supplierDO1 = supplierService.get(iotDevice.getManufacturerId());
@@ -466,4 +466,10 @@ public class IotDeviceController {
     public void init() {
         iotDeviceService.updateSort();
     }
+
+    @PermitAll
+    @GetMapping("/init/brand")
+    public void initBrandName() {
+        iotDeviceService.updateBrandName();
+    }
 }

+ 27 - 11
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/stat/IotStaticController.java

@@ -509,17 +509,33 @@ public class IotStaticController {
         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());
-        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);
-        });
+        LinkedList<Map<String, Object>> results = new LinkedList<>();
+        if ("rh".equals(dept)) {
+            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 ("电驱增压机".equals(iotProductClassifyDO.getName())||"柴驱增压机".equals(iotProductClassifyDO.getName())||"电驱空压机".equals(iotProductClassifyDO.getName())||"柴驱空压机".equals(iotProductClassifyDO.getName())
+                        ||"空气处理撬".equals(iotProductClassifyDO.getName())||"提纯撬".equals(iotProductClassifyDO.getName()) ||"膜组".equals(iotProductClassifyDO.getName())||"注水泵".equals(iotProductClassifyDO.getName())
+                        ||"箱变".equals(iotProductClassifyDO.getName())) {
+                    Map<String, Object> map = new HashMap<>(4);
+                    map.put("category", iotProductClassifyDO.getName());
+                    map.put("value", e.getValue());
+                    results.add(map);
+                }
+            });
+        }else {
+            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());
+            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);
     }
 

+ 2 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/vo/IotDevicePageReqVO.java

@@ -135,4 +135,6 @@ public class IotDevicePageReqVO extends PageParam {
     private Long carId;
     @Schema(description = "是否在线")
     private Integer ifInline;
+
+    private String brandName;
 }

+ 1 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/vo/IotDeviceRespVO.java

@@ -211,4 +211,5 @@ public class IotDeviceRespVO {
 
     @Schema(description = "设备对应的 BOM分组 最短保养距离集合")
     private List<IotMaintenanceBomRespVO> groupBomDistances;
+
 }

+ 2 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/IotDeviceDO.java

@@ -164,4 +164,6 @@ public class IotDeviceDO extends BaseDO {
     private String chargeName;
 
     private LocalDateTime enableDate;
+
+    private String brandName;
 }

+ 1 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/IotDeviceMapper.java

@@ -33,6 +33,7 @@ public interface IotDeviceMapper extends BaseMapperX<IotDeviceDO> {
                 .likeIfPresent(IotDeviceDO::getDeviceName, reqVO.getDeviceName())
                 .eqIfPresent(IotDeviceDO::getBrand, reqVO.getBrand())
                 .eqIfPresent(IotDeviceDO::getModel, reqVO.getModel())
+                        .likeIfPresent(IotDeviceDO::getBrandName, reqVO.getBrandName())
                 //.eqIfPresent(IotDeviceDO::getOrgId, reqVO.getOrgId())
                 .inIfPresent(IotDeviceDO::getDeptId, deptIds)
                 .eqIfPresent(IotDeviceDO::getDeviceStatus, reqVO.getDeviceStatus())

+ 1 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotmainworkorder/IotMainWorkOrderMapper.java

@@ -55,7 +55,7 @@ public interface IotMainWorkOrderMapper extends BaseMapperX<IotMainWorkOrderDO>
                 .inIfPresent(IotMainWorkOrderDO::getId, reqVO.getWorkOrderIds())
                 .eqIfPresent(IotMainWorkOrderDO::getPlanId, reqVO.getPlanId())
                 .eqIfPresent(IotMainWorkOrderDO::getPlanSerialNumber, reqVO.getPlanSerialNumber())
-                .eqIfPresent(IotMainWorkOrderDO::getDeptId, reqVO.getDeptIds())
+                .inIfPresent(IotMainWorkOrderDO::getDeptId, reqVO.getDeptIds())
                 .eqIfPresent(IotMainWorkOrderDO::getOrderNumber, reqVO.getOrderNumber())
                 .likeIfPresent(IotMainWorkOrderDO::getName, reqVO.getName())
                 .eqIfPresent(IotMainWorkOrderDO::getType, reqVO.getType())

+ 1 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotDeviceService.java

@@ -62,6 +62,7 @@ public interface IotDeviceService {
     PageResult<IotDeviceDO> getIotDevicePage(IotDevicePageReqVO pageReqVO, SortablePageParam sortablePageParam);
     PageResult<IotDeviceDO> getIotDevicePageApp(IotDevicePageReqVO pageReqVO, SortablePageParam sortablePageParam);
     void updateSort();
+    void updateBrandName();
     /**
      * 获得设备精简列表
      *

+ 24 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotDeviceServiceImpl.java

@@ -174,6 +174,12 @@ public class IotDeviceServiceImpl implements IotDeviceService {
         IotDeviceDO iotDevice = BeanUtils.toBean(createReqVO, IotDeviceDO.class);
         iotDevice.setSortColumn(NumberUtils.extractNumber(iotDevice.getDeviceCode()));
         iotDevice.setDeleted(false);
+        if (Objects.nonNull(createReqVO.getBrand())) {
+            DictDataDO dictData = dictDataService.getDictData(createReqVO.getBrand());
+            if (Objects.nonNull(dictData)) {
+                iotDevice.setBrandName(dictData.getLabel());
+            }
+        }
         iotDeviceMapper.insert(iotDevice);
         //插入资料
         IotInfoClassifyDO infoClassifyDO = new IotInfoClassifyDO();
@@ -218,6 +224,12 @@ public class IotDeviceServiceImpl implements IotDeviceService {
         validateIotDeviceExists(updateReqVO.getId());
         // 更新
         IotDeviceDO updateObj = BeanUtils.toBean(updateReqVO, IotDeviceDO.class);
+        if (Objects.nonNull(updateReqVO.getBrand())) {
+            DictDataDO dictData = dictDataService.getDictData(updateReqVO.getBrand());
+            if (Objects.nonNull(dictData)) {
+                updateObj.setBrandName(dictData.getLabel());
+            }
+        }
         iotDeviceMapper.updateById(updateObj);
         //更新pms树
         List<IotTreeDO> iotTreeDOS = iotTreeMapper.selectListByOriginId(updateObj.getId(), "device");
@@ -284,6 +296,18 @@ public class IotDeviceServiceImpl implements IotDeviceService {
         iotDeviceMapper.updateBatch(deviceDOS);
     }
 
+    @Override
+    public void updateBrandName() {
+        List<IotDeviceDO> deviceDOS = iotDeviceMapper.selectList();
+        deviceDOS.forEach(deviceDO -> {
+            DictDataDO dictData = dictDataService.getDictData(deviceDO.getBrand());
+            if (Objects.nonNull(dictData)) {
+                deviceDO.setBrandName(dictData.getLabel());
+            }
+        });
+        iotDeviceMapper.updateBatch(deviceDOS);
+    }
+
     @Override
     public List<IotDeviceDO> getSimpleDeviceList(IotDevicePageReqVO reqVO) {
         Set<Long> ids = new HashSet<>();