Procházet zdrojové kódy

监控告警调整

lipenghui před 5 dny
rodič
revize
eee6b260aa
11 změnil soubory, kde provedl 498 přidání a 5 odebrání
  1. 97 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/tdparams/IotTdParamsController.java
  2. 43 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/tdparams/vo/IotTdParamsPageReqVO.java
  3. 51 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/tdparams/vo/IotTdParamsRespVO.java
  4. 41 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/tdparams/vo/IotTdParamsSaveReqVO.java
  5. 59 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/tdparams/IotTdParamsDO.java
  6. 33 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/tdparams/IotTdParamsMapper.java
  7. 11 2
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/job/alarm/AlarmJob.java
  8. 24 2
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotDeviceServiceImpl.java
  9. 8 1
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/alarm/IotAlarmSettingServiceImpl.java
  10. 56 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/tdparams/IotTdParamsService.java
  11. 75 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/tdparams/IotTdParamsServiceImpl.java

+ 97 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/tdparams/IotTdParamsController.java

@@ -0,0 +1,97 @@
+package cn.iocoder.yudao.module.pms.controller.admin.tdparams;
+
+import cn.iocoder.yudao.module.pms.controller.admin.tdparams.vo.IotTdParamsPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.tdparams.vo.IotTdParamsRespVO;
+import cn.iocoder.yudao.module.pms.controller.admin.tdparams.vo.IotTdParamsSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.tdparams.IotTdParamsDO;
+import cn.iocoder.yudao.module.pms.service.tdparams.IotTdParamsService;
+import org.springframework.web.bind.annotation.*;
+import javax.annotation.Resource;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.security.access.prepost.PreAuthorize;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Operation;
+
+import javax.validation.constraints.*;
+import javax.validation.*;
+import javax.servlet.http.*;
+import java.util.*;
+import java.io.IOException;
+
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
+
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
+
+
+@Tag(name = "管理后台 - 设备模型参数")
+@RestController
+@RequestMapping("/rq/iot-td-params")
+@Validated
+public class IotTdParamsController {
+
+    @Resource
+    private IotTdParamsService iotTdParamsService;
+
+    @PostMapping("/create")
+    @Operation(summary = "创建设备模型参数")
+    @PreAuthorize("@ss.hasPermission('rq:iot-td-params:create')")
+    public CommonResult<Long> createIotTdParams(@Valid @RequestBody IotTdParamsSaveReqVO createReqVO) {
+        return success(iotTdParamsService.createIotTdParams(createReqVO));
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "更新设备模型参数")
+    @PreAuthorize("@ss.hasPermission('rq:iot-td-params:update')")
+    public CommonResult<Boolean> updateIotTdParams(@Valid @RequestBody IotTdParamsSaveReqVO updateReqVO) {
+        iotTdParamsService.updateIotTdParams(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @Operation(summary = "删除设备模型参数")
+    @Parameter(name = "id", description = "编号", required = true)
+    @PreAuthorize("@ss.hasPermission('rq:iot-td-params:delete')")
+    public CommonResult<Boolean> deleteIotTdParams(@RequestParam("id") Long id) {
+        iotTdParamsService.deleteIotTdParams(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "获得设备模型参数")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('rq:iot-td-params:query')")
+    public CommonResult<IotTdParamsRespVO> getIotTdParams(@RequestParam("id") Long id) {
+        IotTdParamsDO iotTdParams = iotTdParamsService.getIotTdParams(id);
+        return success(BeanUtils.toBean(iotTdParams, IotTdParamsRespVO.class));
+    }
+
+    @GetMapping("/page")
+    @Operation(summary = "获得设备模型参数分页")
+    @PreAuthorize("@ss.hasPermission('rq:iot-td-params:query')")
+    public CommonResult<PageResult<IotTdParamsRespVO>> getIotTdParamsPage(@Valid IotTdParamsPageReqVO pageReqVO) {
+        PageResult<IotTdParamsDO> pageResult = iotTdParamsService.getIotTdParamsPage(pageReqVO);
+        return success(BeanUtils.toBean(pageResult, IotTdParamsRespVO.class));
+    }
+
+    @GetMapping("/export-excel")
+    @Operation(summary = "导出设备模型参数 Excel")
+    @PreAuthorize("@ss.hasPermission('rq:iot-td-params:export')")
+    @ApiAccessLog(operateType = EXPORT)
+    public void exportIotTdParamsExcel(@Valid IotTdParamsPageReqVO pageReqVO,
+              HttpServletResponse response) throws IOException {
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        List<IotTdParamsDO> list = iotTdParamsService.getIotTdParamsPage(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "设备模型参数.xls", "数据", IotTdParamsRespVO.class,
+                        BeanUtils.toBean(list, IotTdParamsRespVO.class));
+    }
+
+}

+ 43 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/tdparams/vo/IotTdParamsPageReqVO.java

@@ -0,0 +1,43 @@
+package cn.iocoder.yudao.module.pms.controller.admin.tdparams.vo;
+
+import lombok.*;
+import java.util.*;
+import io.swagger.v3.oas.annotations.media.Schema;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.time.LocalDateTime;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@Schema(description = "管理后台 - 设备模型参数分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class IotTdParamsPageReqVO extends PageParam {
+
+    @Schema(description = "设备id", example = "2468")
+    private Long deviceId;
+
+    @Schema(description = "设备名称", example = "赵六")
+    private String deviceName;
+
+    @Schema(description = "油服编码")
+    private String yfCode;
+
+    @Schema(description = "历史编码")
+    private String deviceCode;
+
+    @Schema(description = "属性标识")
+    private String identifier;
+
+    @Schema(description = "模型名称", example = "芋艿")
+    private String modelName;
+
+    @Schema(description = "排序")
+    private Long modelOrder;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+}

+ 51 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/tdparams/vo/IotTdParamsRespVO.java

@@ -0,0 +1,51 @@
+package cn.iocoder.yudao.module.pms.controller.admin.tdparams.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+import java.util.*;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.time.LocalDateTime;
+import com.alibaba.excel.annotation.*;
+
+@Schema(description = "管理后台 - 设备模型参数 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class IotTdParamsRespVO {
+
+    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "5078")
+    @ExcelProperty("主键id")
+    private Long id;
+
+    @Schema(description = "设备id", requiredMode = Schema.RequiredMode.REQUIRED, example = "2468")
+    @ExcelProperty("设备id")
+    private Long deviceId;
+
+    @Schema(description = "设备名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
+    @ExcelProperty("设备名称")
+    private String deviceName;
+
+    @Schema(description = "油服编码")
+    @ExcelProperty("油服编码")
+    private String yfCode;
+
+    @Schema(description = "历史编码", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("历史编码")
+    private String deviceCode;
+
+    @Schema(description = "属性标识", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("属性标识")
+    private String identifier;
+
+    @Schema(description = "模型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
+    @ExcelProperty("模型名称")
+    private String modelName;
+
+    @Schema(description = "排序")
+    @ExcelProperty("排序")
+    private Long modelOrder;
+
+    @Schema(description = "创建时间")
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+
+}

+ 41 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/tdparams/vo/IotTdParamsSaveReqVO.java

@@ -0,0 +1,41 @@
+package cn.iocoder.yudao.module.pms.controller.admin.tdparams.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+import java.util.*;
+import javax.validation.constraints.*;
+
+@Schema(description = "管理后台 - 设备模型参数新增/修改 Request VO")
+@Data
+public class IotTdParamsSaveReqVO {
+
+    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "5078")
+    private Long id;
+
+    @Schema(description = "设备id", requiredMode = Schema.RequiredMode.REQUIRED, example = "2468")
+    @NotNull(message = "设备id不能为空")
+    private Long deviceId;
+
+    @Schema(description = "设备名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
+    @NotEmpty(message = "设备名称不能为空")
+    private String deviceName;
+
+    @Schema(description = "油服编码")
+    private String yfCode;
+
+    @Schema(description = "历史编码", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotEmpty(message = "历史编码不能为空")
+    private String deviceCode;
+
+    @Schema(description = "属性标识", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotEmpty(message = "属性标识不能为空")
+    private String identifier;
+
+    @Schema(description = "模型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
+    @NotEmpty(message = "模型名称不能为空")
+    private String modelName;
+
+    @Schema(description = "排序")
+    private Long modelOrder;
+
+}

+ 59 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/tdparams/IotTdParamsDO.java

@@ -0,0 +1,59 @@
+package cn.iocoder.yudao.module.pms.dal.dataobject.tdparams;
+
+import lombok.*;
+import java.util.*;
+import java.time.LocalDateTime;
+import java.time.LocalDateTime;
+import com.baomidou.mybatisplus.annotation.*;
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+
+/**
+ * 设备模型参数 DO
+ *
+ * @author 超级管理员
+ */
+@TableName("rq_iot_td_params")
+@KeySequence("rq_iot_td_params_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class IotTdParamsDO extends BaseDO {
+
+    /**
+     * 主键id
+     */
+    @TableId
+    private Long id;
+    /**
+     * 设备id
+     */
+    private Long deviceId;
+    /**
+     * 设备名称
+     */
+    private String deviceName;
+    /**
+     * 油服编码
+     */
+    private String yfCode;
+    /**
+     * 历史编码
+     */
+    private String deviceCode;
+    /**
+     * 属性标识
+     */
+    private String identifier;
+    /**
+     * 模型名称
+     */
+    private String modelName;
+    /**
+     * 排序
+     */
+    private Long modelOrder;
+
+}

+ 33 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/tdparams/IotTdParamsMapper.java

@@ -0,0 +1,33 @@
+package cn.iocoder.yudao.module.pms.dal.mysql.tdparams;
+
+import java.util.*;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.module.pms.controller.admin.tdparams.vo.IotTdParamsPageReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.tdparams.IotTdParamsDO;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 设备模型参数 Mapper
+ *
+ * @author 超级管理员
+ */
+@Mapper
+public interface IotTdParamsMapper extends BaseMapperX<IotTdParamsDO> {
+
+    default PageResult<IotTdParamsDO> selectPage(IotTdParamsPageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<IotTdParamsDO>()
+                .eqIfPresent(IotTdParamsDO::getDeviceId, reqVO.getDeviceId())
+                .likeIfPresent(IotTdParamsDO::getDeviceName, reqVO.getDeviceName())
+                .eqIfPresent(IotTdParamsDO::getYfCode, reqVO.getYfCode())
+                .eqIfPresent(IotTdParamsDO::getDeviceCode, reqVO.getDeviceCode())
+                .eqIfPresent(IotTdParamsDO::getIdentifier, reqVO.getIdentifier())
+                .likeIfPresent(IotTdParamsDO::getModelName, reqVO.getModelName())
+                .eqIfPresent(IotTdParamsDO::getModelOrder, reqVO.getModelOrder())
+                .betweenIfPresent(IotTdParamsDO::getCreateTime, reqVO.getCreateTime())
+                .orderByDesc(IotTdParamsDO::getId));
+    }
+
+}

+ 11 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/job/alarm/AlarmJob.java

@@ -15,9 +15,11 @@ 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.alarm.IotAlarmSettingDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotdeviceperson.IotDevicePersonDO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.tdparams.IotTdParamsDO;
 import cn.iocoder.yudao.module.pms.dal.mysql.IotDeviceMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.TDDeviceMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.alarm.IotAlarmSettingMapper;
+import cn.iocoder.yudao.module.pms.dal.mysql.tdparams.IotTdParamsMapper;
 import cn.iocoder.yudao.module.pms.message.PmsMessage;
 import cn.iocoder.yudao.module.pms.service.IotDeviceService;
 import cn.iocoder.yudao.module.pms.service.iotdeviceperson.IotDevicePersonService;
@@ -54,6 +56,8 @@ public class AlarmJob implements JobHandler {
     private IotDevicePersonService iotDevicePersonService;
     @Autowired
     private AdminUserApi adminUserApi;
+    @Autowired
+    private IotTdParamsMapper iotTdParamsMapper;
 
     @Override
     @TenantIgnore
@@ -69,9 +73,14 @@ public class AlarmJob implements JobHandler {
         String now = DateUtil.now();
         Timestamp start = generateTimestamp(tenMinuteString);
         Timestamp end = generateTimestamp(now);
-        list.stream().filter(e -> e.getIfInline()==3).forEach(f ->{
+        List<IotDeviceDO> collect = list.stream().filter(e -> e.getIfInline() == 3).collect(Collectors.toList());
+        collect.forEach(f ->{
+            if ("YF214".equals(f.getDeviceCode())) {
+                System.out.println("333333");
+            }
             //调用延凡接口获取该设备的所有参数
-            List<ThingsModelDTO> tdParams = iotDeviceService.getTdParams(f);
+//            List<ThingsModelDTO> tdParams = iotDeviceService.getTdParams(f);
+            List<IotTdParamsDO> tdParams = iotTdParamsMapper.selectList("device_id", f.getId());
             tdParams.forEach(model ->{
                 //获取设备id与属性标识相同的告警配置
                 alarmSettingDOS.stream().filter(g -> g.getDeviceId().equals(f.getId())&&g.getPropertyCode().equals(model.getIdentifier())).forEach(t -> {

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

@@ -28,6 +28,7 @@ import cn.iocoder.yudao.module.pms.dal.dataobject.iotZHBD.DeviceZHBDDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotdeviceperson.IotDevicePersonDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotmodel.IotModelDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotmodeltemplateattrs.IotModelTemplateAttrsDO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.tdparams.IotTdParamsDO;
 import cn.iocoder.yudao.module.pms.dal.mysql.IotDeviceMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.IotInfoClassifyMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.IotTreeMapper;
@@ -35,6 +36,7 @@ import cn.iocoder.yudao.module.pms.dal.mysql.TDDeviceMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.iotdevicerunlog.IotDeviceRunLogMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.iotmodel.IotModelMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.iotopeationfill.IotOpeationFillMapper;
+import cn.iocoder.yudao.module.pms.dal.mysql.tdparams.IotTdParamsMapper;
 import cn.iocoder.yudao.module.pms.service.iotbom.IotBomService;
 import cn.iocoder.yudao.module.pms.service.iotdevicebom.IotDeviceBomService;
 import cn.iocoder.yudao.module.pms.service.iotdevicematerial.IotDeviceMaterialService;
@@ -72,6 +74,7 @@ import org.springframework.web.client.RestTemplate;
 import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.util.*;
+import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -136,6 +139,8 @@ public class IotDeviceServiceImpl implements IotDeviceService {
     private final static String parameter = "lng~~经度,lat~~纬度,today_distance~~当日里程,distance~~总里程,todayoil~~当日油量,totaloil~~总油量,online~~是否在线,oil1~~1路油量,oil2~~2路油量,oil3~~3路油量,oil4~~4路油量,vehicle_name~~车牌号码";
     @Autowired
     private DeptApi deptApi;
+    @Autowired
+    private IotTdParamsMapper iotTdParamsMapper;
 
 
     @Override
@@ -334,8 +339,25 @@ public class IotDeviceServiceImpl implements IotDeviceService {
 
             });
         }
-
-        return rows.stream().filter(e ->!"lac".equals(e.getIdentifier())&&!"cell_id".equals(e.getIdentifier())&&!"mcc_mnc".equals(e.getIdentifier())).sorted(Comparator.comparing(ThingsModelDTO::getIdentifier)).collect(Collectors.toList());
+        List<ThingsModelDTO> collect = rows.stream().filter(e -> !"lac".equals(e.getIdentifier()) && !"cell_id".equals(e.getIdentifier()) && !"mcc_mnc".equals(e.getIdentifier())).sorted(Comparator.comparing(ThingsModelDTO::getIdentifier)).collect(Collectors.toList());
+        CompletableFuture.runAsync(()->{
+            collect.forEach(thingsModelDTO -> {
+                List<IotTdParamsDO> paramsDOS = iotTdParamsMapper.selectByMap(ImmutableMap.of("device_id", iotDeviceDO.getId(), "identifier", thingsModelDTO.getIdentifier()));
+                if (CollUtil.isEmpty(paramsDOS)) {
+                    IotTdParamsDO iotTdParamsDO = new IotTdParamsDO();
+                    iotTdParamsDO.setDeviceId(iotDeviceDO.getId());
+                    iotTdParamsDO.setDeviceCode(iotDeviceDO.getDeviceCode());
+                    iotTdParamsDO.setDeviceName(iotDeviceDO.getDeviceName());
+                    iotTdParamsDO.setYfCode(iotDeviceDO.getYfDeviceCode());
+                    iotTdParamsDO.setIdentifier(thingsModelDTO.getIdentifier());
+                    iotTdParamsDO.setModelName(thingsModelDTO.getModelName());
+                    iotTdParamsDO.setModelOrder(Long.valueOf(thingsModelDTO.getModelOrder()));
+                    iotTdParamsDO.setDeleted(false);
+                    iotTdParamsMapper.insert(iotTdParamsDO);
+                }
+            });
+        });
+        return collect;
     }
 
     @Override

+ 8 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/alarm/IotAlarmSettingServiceImpl.java

@@ -16,6 +16,8 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.*;
+import java.util.stream.Collectors;
+
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.pojo.PageParam;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
@@ -50,7 +52,12 @@ public class IotAlarmSettingServiceImpl implements IotAlarmSettingService {
         if (CollUtil.isNotEmpty(deviceSettings)) {
             return deviceSettings.get(0);
         } else if (CollUtil.isNotEmpty(classSettings)) {
-            return classSettings.get(0);
+            List<IotAlarmSettingDO> collect = classSettings.stream().filter(e -> Objects.isNull(e.getDeviceId())).collect(Collectors.toList());
+            if (CollUtil.isNotEmpty(collect)) {
+                return classSettings.get(0);
+            } else {
+                return new IotAlarmSettingDO();
+            }
         } else {
             return null;
         }

+ 56 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/tdparams/IotTdParamsService.java

@@ -0,0 +1,56 @@
+package cn.iocoder.yudao.module.pms.service.tdparams;
+
+import java.util.*;
+import javax.validation.*;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import cn.iocoder.yudao.module.pms.controller.admin.tdparams.vo.IotTdParamsPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.tdparams.vo.IotTdParamsSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.tdparams.IotTdParamsDO;
+
+/**
+ * 设备模型参数 Service 接口
+ *
+ * @author 超级管理员
+ */
+public interface IotTdParamsService {
+
+    /**
+     * 创建设备模型参数
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long createIotTdParams(@Valid IotTdParamsSaveReqVO createReqVO);
+
+    /**
+     * 更新设备模型参数
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updateIotTdParams(@Valid IotTdParamsSaveReqVO updateReqVO);
+
+    /**
+     * 删除设备模型参数
+     *
+     * @param id 编号
+     */
+    void deleteIotTdParams(Long id);
+
+    /**
+     * 获得设备模型参数
+     *
+     * @param id 编号
+     * @return 设备模型参数
+     */
+    IotTdParamsDO getIotTdParams(Long id);
+
+    /**
+     * 获得设备模型参数分页
+     *
+     * @param pageReqVO 分页查询
+     * @return 设备模型参数分页
+     */
+    PageResult<IotTdParamsDO> getIotTdParamsPage(IotTdParamsPageReqVO pageReqVO);
+
+}

+ 75 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/tdparams/IotTdParamsServiceImpl.java

@@ -0,0 +1,75 @@
+package cn.iocoder.yudao.module.pms.service.tdparams;
+
+import cn.iocoder.yudao.framework.common.exception.ErrorCode;
+import cn.iocoder.yudao.module.pms.controller.admin.tdparams.vo.IotTdParamsPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.tdparams.vo.IotTdParamsSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.tdparams.IotTdParamsDO;
+import cn.iocoder.yudao.module.pms.dal.mysql.tdparams.IotTdParamsMapper;
+import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.*;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+
+
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+
+/**
+ * 设备模型参数 Service 实现类
+ *
+ * @author 超级管理员
+ */
+@Service
+@Validated
+public class IotTdParamsServiceImpl implements IotTdParamsService {
+
+    @Resource
+    private IotTdParamsMapper iotTdParamsMapper;
+
+    @Override
+    public Long createIotTdParams(IotTdParamsSaveReqVO createReqVO) {
+        // 插入
+        IotTdParamsDO iotTdParams = BeanUtils.toBean(createReqVO, IotTdParamsDO.class);
+        iotTdParamsMapper.insert(iotTdParams);
+        // 返回
+        return iotTdParams.getId();
+    }
+
+    @Override
+    public void updateIotTdParams(IotTdParamsSaveReqVO updateReqVO) {
+        // 校验存在
+        validateIotTdParamsExists(updateReqVO.getId());
+        // 更新
+        IotTdParamsDO updateObj = BeanUtils.toBean(updateReqVO, IotTdParamsDO.class);
+        iotTdParamsMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void deleteIotTdParams(Long id) {
+        // 校验存在
+        validateIotTdParamsExists(id);
+        // 删除
+        iotTdParamsMapper.deleteById(id);
+    }
+
+    private void validateIotTdParamsExists(Long id) {
+        if (iotTdParamsMapper.selectById(id) == null) {
+            throw exception(new ErrorCode(333,"不存在模型参数"));
+        }
+    }
+
+    @Override
+    public IotTdParamsDO getIotTdParams(Long id) {
+        return iotTdParamsMapper.selectById(id);
+    }
+
+    @Override
+    public PageResult<IotTdParamsDO> getIotTdParamsPage(IotTdParamsPageReqVO pageReqVO) {
+        return iotTdParamsMapper.selectPage(pageReqVO);
+    }
+
+}