Jelajahi Sumber

后端在线监控

lipenghui 3 bulan lalu
induk
melakukan
600516a24c
18 mengubah file dengan 746 tambahan dan 15 penghapusan
  1. 5 5
      yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java
  2. 2 0
      yudao-module-pms/yudao-module-pms-api/src/main/java/cn/iocoder/yudao/module/pms/enums/ErrorCodeConstant.java
  3. 12 3
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/IotDeviceController.java
  4. 109 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/yanfan/vo/ThingsModelPageReqVO.java
  5. 139 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/yanfan/vo/ThingsModelRespVO.java
  6. 111 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/yanfan/vo/ThingsModelSaveReqVO.java
  7. 147 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/yanfan/ThingsModelDO.java
  8. 1 2
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/yanfan/YfDeviceDO.java
  9. 1 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/IotDeviceMapper.java
  10. 25 1
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/TDDeviceMapper.java
  11. 55 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/yanfan/ThingsModelMapper.java
  12. 2 2
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/yanfan/YfDeviceMapper.java
  13. 3 1
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotDeviceService.java
  14. 39 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotDeviceServiceImpl.java
  15. 35 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/yanfan/ThingsModelService.java
  16. 52 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/yanfan/ThingsModelServiceImpl.java
  17. 1 1
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/yanfan/YfDeviceService.java
  18. 7 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/yanfan/YfDeviceServiceImpl.java

+ 5 - 5
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java

@@ -394,11 +394,11 @@ public class GlobalExceptionHandler {
                     "[AI 大模型 yudao-module-ai - 表结构未导入][参考 https://cloud.iocoder.cn/ai/build/ 开启]");
         }
         // 9. IoT 物联网
-        if (message.contains("iot_")) {
-            log.error("[IoT 物联网 yudao-module-iot - 表结构未导入][参考 https://doc.iocoder.cn/iot/build/ 开启]");
-            return CommonResult.error(NOT_IMPLEMENTED.getCode(),
-                    "[IoT 物联网 yudao-module-iot - 表结构未导入][参考 https://doc.iocoder.cn/iot/build/ 开启]");
-        }
+//        if (message.contains("iot_")) {
+//            log.error("[IoT 物联网 yudao-module-iot - 表结构未导入][参考 https://doc.iocoder.cn/iot/build/ 开启]");
+//            return CommonResult.error(NOT_IMPLEMENTED.getCode(),
+//                    "[IoT 物联网 yudao-module-iot - 表结构未导入][参考 https://doc.iocoder.cn/iot/build/ 开启]");
+//        }
         return null;
     }
 

+ 2 - 0
yudao-module-pms/yudao-module-pms-api/src/main/java/cn/iocoder/yudao/module/pms/enums/ErrorCodeConstant.java

@@ -54,4 +54,6 @@ public interface ErrorCodeConstant{
     ErrorCode IOT_OPEATION_FILL_NOT_EXISTS = new ErrorCode(136, "运行记录填报不存在");
     ErrorCode IOT_MAINTAIN_MATERIALS_NOT_EXISTS = new ErrorCode(144, "维修工单对应物料不存在");
     ErrorCode IOT_MAINTAIN_BOM_NOT_EXISTS = new ErrorCode(145, "维修工单对应维修项BOM不存在");
+    ErrorCode THINGS_MODEL_NOT_EXISTS = new ErrorCode(146, "物模型不存在");
+
 }

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

@@ -15,6 +15,7 @@ import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceSaveReqVO;
 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.iotbom.IotBomDO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.yanfan.ThingsModelDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.yanfan.YfDeviceDO;
 import cn.iocoder.yudao.module.pms.dal.mysql.TDDeviceMapper;
 import cn.iocoder.yudao.module.pms.service.DeviceServiceImpl;
@@ -102,6 +103,16 @@ public class IotDeviceController {
         return success(true);
     }
 
+    @GetMapping("/get/td")
+    @Operation(summary = "获得设备台账")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('rq:iot-device:query')")
+    public CommonResult<List<ThingsModelDO>> getIotDeviceTd(@RequestParam("id") Long id) {
+        IotDeviceDO iotDevice = iotDeviceService.getIotDevice(id);
+        List<ThingsModelDO> tdParams = iotDeviceService.getTdParams(iotDevice);
+        return success(tdParams);
+    }
+
     @GetMapping("/get")
     @Operation(summary = "获得设备台账")
     @Parameter(name = "id", description = "编号", required = true, example = "1024")
@@ -120,8 +131,6 @@ public class IotDeviceController {
         iotDeviceRespVO.setDeptName(Objects.nonNull(dept)?dept.getName():"");
         IotProductClassifyDO iotProductClassify = iotProductClassifyService.getIotProductClassify(iotDevice.getAssetClass());
         iotDeviceRespVO.setAssetClassName(Objects.nonNull(iotProductClassify)?iotProductClassify.getName():"");
-//        IotModelDO iotModel = iotModelService.getIotModel(iotDevice.getModel());
-//        iotDeviceRespVO.setModelName(Objects.nonNull(iotModel)?iotModel.getName():"");
         List<YfDeviceDO> allDevice = yfDeviceService.getAllDevice();
         allDevice.stream().filter(e -> e.getSerialNumber().equals(iotDevice.getDeviceCode())).findFirst().ifPresent(e -> {
             iotDeviceRespVO.setIfInline(e.getStatus());
@@ -176,7 +185,7 @@ public class IotDeviceController {
             String deviceCode = iotDeviceRespVO.getDeviceCode();
             allDevice.stream().filter(e -> e.getSerialNumber().equals(deviceCode)).findFirst().ifPresent(e -> {
                 iotDeviceRespVO.setIfInline(e.getStatus());
-                List<DeviceVO> deviceVOS = deviceMapper.selectNew(e.getSerialNumber());
+                List<DeviceVO> deviceVOS = deviceMapper.selectLastTime(e.getSerialNumber());
                 if (CollUtil.isNotEmpty(deviceVOS)) {
                     Timestamp ts = deviceVOS.get(0).getTs();
                     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

+ 109 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/yanfan/vo/ThingsModelPageReqVO.java

@@ -0,0 +1,109 @@
+package cn.iocoder.yudao.module.pms.controller.admin.yanfan.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 ThingsModelPageReqVO extends PageParam {
+
+    @Schema(description = "物模型名称", example = "李四")
+    private String modelName;
+
+    @Schema(description = "产品ID", example = "15345")
+    private Long productId;
+
+    @Schema(description = "产品名称", example = "芋艿")
+    private String productName;
+
+    @Schema(description = "租户名称", example = "李四")
+    private String tenantName;
+
+    @Schema(description = "标识符,产品下唯一")
+    private String identifier;
+
+    @Schema(description = "模型类别(1-属性,2-功能,3-事件)", example = "1")
+    private Boolean type;
+
+    @Schema(description = "数据类型(integer、decimal、string、bool、array、enum)", example = "2")
+    private String datatype;
+
+    @Schema(description = "数据定义")
+    private String specs;
+
+    @Schema(description = "是否图表展示(0-否,1-是)")
+    private Boolean isChart;
+
+    @Schema(description = "是否实时监测(0-否,1-是)")
+    private Boolean isMonitor;
+
+    @Schema(description = "是否历史存储(0-否,1-是)")
+    private Boolean isHistory;
+
+    @Schema(description = "是否只读数据(0-否,1-是)")
+    private Boolean isReadonly;
+
+    @Schema(description = "是否设备分享权限(0-否,1-是)")
+    private Boolean isSharePerm;
+
+    @Schema(description = "排序,值越大,排序越靠前")
+    private Integer modelOrder;
+
+    @Schema(description = "删除标志(0代表存在 2代表删除)")
+    private String delFlag;
+
+    @Schema(description = "创建者")
+    private String createBy;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+    @Schema(description = "更新者")
+    private String updateBy;
+
+    @Schema(description = "备注", example = "你说的对")
+    private String remark;
+
+    @Schema(description = "从机id", example = "25392")
+    private Long tempSlaveId;
+
+    @Schema(description = "计算公式")
+    private String formula;
+
+    @Schema(description = "控制公式")
+    private String reverseFormula;
+
+    @Schema(description = "寄存器地址值")
+    private Integer regAddr;
+
+    @Schema(description = "位定义选项")
+    private String bitOption;
+
+    @Schema(description = "解析类型 1.数值 2.选项", example = "1")
+    private String valueType;
+
+    @Schema(description = "是否是计算参数")
+    private Integer isParams;
+
+    @Schema(description = "读取寄存器数量")
+    private Integer quantity;
+
+    @Schema(description = "modbus功能码")
+    private String code;
+
+    @Schema(description = "modbus解析类型", example = "1")
+    private String parseType;
+
+    @Schema(description = "是否在APP显示(0-否,1-是)")
+    private Boolean isApp;
+
+}

+ 139 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/yanfan/vo/ThingsModelRespVO.java

@@ -0,0 +1,139 @@
+package cn.iocoder.yudao.module.pms.controller.admin.yanfan.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 ThingsModelRespVO {
+
+    @Schema(description = "物模型ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "18602")
+    @ExcelProperty("物模型ID")
+    private Long modelId;
+
+    @Schema(description = "物模型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
+    @ExcelProperty("物模型名称")
+    private String modelName;
+
+    @Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "15345")
+    @ExcelProperty("产品ID")
+    private Long productId;
+
+    @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
+    @ExcelProperty("产品名称")
+    private String productName;
+
+    @Schema(description = "租户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
+    @ExcelProperty("租户名称")
+    private String tenantName;
+
+    @Schema(description = "标识符,产品下唯一", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("标识符,产品下唯一")
+    private String identifier;
+
+    @Schema(description = "模型类别(1-属性,2-功能,3-事件)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
+    @ExcelProperty("模型类别(1-属性,2-功能,3-事件)")
+    private Boolean type;
+
+    @Schema(description = "数据类型(integer、decimal、string、bool、array、enum)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
+    @ExcelProperty("数据类型(integer、decimal、string、bool、array、enum)")
+    private String datatype;
+
+    @Schema(description = "数据定义")
+    @ExcelProperty("数据定义")
+    private String specs;
+
+    @Schema(description = "是否图表展示(0-否,1-是)", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("是否图表展示(0-否,1-是)")
+    private Boolean isChart;
+
+    @Schema(description = "是否实时监测(0-否,1-是)", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("是否实时监测(0-否,1-是)")
+    private Boolean isMonitor;
+
+    @Schema(description = "是否历史存储(0-否,1-是)")
+    @ExcelProperty("是否历史存储(0-否,1-是)")
+    private Boolean isHistory;
+
+    @Schema(description = "是否只读数据(0-否,1-是)")
+    @ExcelProperty("是否只读数据(0-否,1-是)")
+    private Boolean isReadonly;
+
+    @Schema(description = "是否设备分享权限(0-否,1-是)")
+    @ExcelProperty("是否设备分享权限(0-否,1-是)")
+    private Boolean isSharePerm;
+
+    @Schema(description = "排序,值越大,排序越靠前")
+    @ExcelProperty("排序,值越大,排序越靠前")
+    private Integer modelOrder;
+
+    @Schema(description = "删除标志(0代表存在 2代表删除)")
+    @ExcelProperty("删除标志(0代表存在 2代表删除)")
+    private String delFlag;
+
+    @Schema(description = "创建者")
+    @ExcelProperty("创建者")
+    private String createBy;
+
+    @Schema(description = "创建时间")
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+
+    @Schema(description = "更新者")
+    @ExcelProperty("更新者")
+    private String updateBy;
+
+    @Schema(description = "备注", example = "你说的对")
+    @ExcelProperty("备注")
+    private String remark;
+
+    @Schema(description = "从机id", example = "25392")
+    @ExcelProperty("从机id")
+    private Long tempSlaveId;
+
+    @Schema(description = "计算公式")
+    @ExcelProperty("计算公式")
+    private String formula;
+
+    @Schema(description = "控制公式")
+    @ExcelProperty("控制公式")
+    private String reverseFormula;
+
+    @Schema(description = "寄存器地址值")
+    @ExcelProperty("寄存器地址值")
+    private Integer regAddr;
+
+    @Schema(description = "位定义选项")
+    @ExcelProperty("位定义选项")
+    private String bitOption;
+
+    @Schema(description = "解析类型 1.数值 2.选项", example = "1")
+    @ExcelProperty("解析类型 1.数值 2.选项")
+    private String valueType;
+
+    @Schema(description = "是否是计算参数")
+    @ExcelProperty("是否是计算参数")
+    private Integer isParams;
+
+    @Schema(description = "读取寄存器数量")
+    @ExcelProperty("读取寄存器数量")
+    private Integer quantity;
+
+    @Schema(description = "modbus功能码")
+    @ExcelProperty("modbus功能码")
+    private String code;
+
+    @Schema(description = "modbus解析类型", example = "1")
+    @ExcelProperty("modbus解析类型")
+    private String parseType;
+
+    @Schema(description = "是否在APP显示(0-否,1-是)")
+    @ExcelProperty("是否在APP显示(0-否,1-是)")
+    private Boolean isApp;
+
+}

+ 111 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/yanfan/vo/ThingsModelSaveReqVO.java

@@ -0,0 +1,111 @@
+package cn.iocoder.yudao.module.pms.controller.admin.yanfan.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 ThingsModelSaveReqVO {
+
+    @Schema(description = "物模型ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "18602")
+    private Long modelId;
+
+    @Schema(description = "物模型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
+    @NotEmpty(message = "物模型名称不能为空")
+    private String modelName;
+
+    @Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "15345")
+    @NotNull(message = "产品ID不能为空")
+    private Long productId;
+
+    @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
+    @NotEmpty(message = "产品名称不能为空")
+    private String productName;
+
+    @Schema(description = "租户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
+    @NotEmpty(message = "租户名称不能为空")
+    private String tenantName;
+
+    @Schema(description = "标识符,产品下唯一", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotEmpty(message = "标识符,产品下唯一不能为空")
+    private String identifier;
+
+    @Schema(description = "模型类别(1-属性,2-功能,3-事件)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
+    @NotNull(message = "模型类别(1-属性,2-功能,3-事件)不能为空")
+    private Boolean type;
+
+    @Schema(description = "数据类型(integer、decimal、string、bool、array、enum)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
+    @NotEmpty(message = "数据类型(integer、decimal、string、bool、array、enum)不能为空")
+    private String datatype;
+
+    @Schema(description = "数据定义")
+    private String specs;
+
+    @Schema(description = "是否图表展示(0-否,1-是)", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotNull(message = "是否图表展示(0-否,1-是)不能为空")
+    private Boolean isChart;
+
+    @Schema(description = "是否实时监测(0-否,1-是)", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotNull(message = "是否实时监测(0-否,1-是)不能为空")
+    private Boolean isMonitor;
+
+    @Schema(description = "是否历史存储(0-否,1-是)")
+    private Boolean isHistory;
+
+    @Schema(description = "是否只读数据(0-否,1-是)")
+    private Boolean isReadonly;
+
+    @Schema(description = "是否设备分享权限(0-否,1-是)")
+    private Boolean isSharePerm;
+
+    @Schema(description = "排序,值越大,排序越靠前")
+    private Integer modelOrder;
+
+    @Schema(description = "删除标志(0代表存在 2代表删除)")
+    private String delFlag;
+
+    @Schema(description = "创建者")
+    private String createBy;
+
+    @Schema(description = "更新者")
+    private String updateBy;
+
+    @Schema(description = "备注", example = "你说的对")
+    private String remark;
+
+    @Schema(description = "从机id", example = "25392")
+    private Long tempSlaveId;
+
+    @Schema(description = "计算公式")
+    private String formula;
+
+    @Schema(description = "控制公式")
+    private String reverseFormula;
+
+    @Schema(description = "寄存器地址值")
+    private Integer regAddr;
+
+    @Schema(description = "位定义选项")
+    private String bitOption;
+
+    @Schema(description = "解析类型 1.数值 2.选项", example = "1")
+    private String valueType;
+
+    @Schema(description = "是否是计算参数")
+    private Integer isParams;
+
+    @Schema(description = "读取寄存器数量")
+    private Integer quantity;
+
+    @Schema(description = "modbus功能码")
+    private String code;
+
+    @Schema(description = "modbus解析类型", example = "1")
+    private String parseType;
+
+    @Schema(description = "是否在APP显示(0-否,1-是)")
+    private Boolean isApp;
+
+}

+ 147 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/yanfan/ThingsModelDO.java

@@ -0,0 +1,147 @@
+package cn.iocoder.yudao.module.pms.dal.dataobject.yanfan;
+
+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("iot_things_model")
+@KeySequence("iot_things_model_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+//@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class ThingsModelDO {
+
+    /**
+     * 物模型ID
+     */
+    @TableId
+    private Long modelId;
+    /**
+     * 物模型名称
+     */
+    private String modelName;
+    /**
+     * 产品ID
+     */
+    private Long productId;
+    /**
+     * 产品名称
+     */
+    private String productName;
+    /**
+     * 租户名称
+     */
+    private String tenantName;
+    /**
+     * 标识符,产品下唯一
+     */
+    private String identifier;
+    /**
+     * 模型类别(1-属性,2-功能,3-事件)
+     */
+    private Boolean type;
+    /**
+     * 数据类型(integer、decimal、string、bool、array、enum)
+     */
+    private String datatype;
+    /**
+     * 数据定义
+     */
+    private String specs;
+    /**
+     * 是否图表展示(0-否,1-是)
+     */
+    private Boolean isChart;
+    /**
+     * 是否实时监测(0-否,1-是)
+     */
+    private Boolean isMonitor;
+    /**
+     * 是否历史存储(0-否,1-是)
+     */
+    private Boolean isHistory;
+    /**
+     * 是否只读数据(0-否,1-是)
+     */
+    private Boolean isReadonly;
+    /**
+     * 是否设备分享权限(0-否,1-是)
+     */
+    private Boolean isSharePerm;
+    /**
+     * 排序,值越大,排序越靠前
+     */
+    private Integer modelOrder;
+    /**
+     * 删除标志(0代表存在 2代表删除)
+     */
+    private String delFlag;
+    /**
+     * 创建者
+     */
+    private String createBy;
+    /**
+     * 更新者
+     */
+    private String updateBy;
+    /**
+     * 备注
+     */
+    private String remark;
+    /**
+     * 从机id
+     */
+    private Long tempSlaveId;
+    /**
+     * 计算公式
+     */
+    private String formula;
+    /**
+     * 控制公式
+     */
+    private String reverseFormula;
+    /**
+     * 寄存器地址值
+     */
+    private Integer regAddr;
+    /**
+     * 位定义选项
+     */
+    private String bitOption;
+    /**
+     * 解析类型 1.数值 2.选项
+     */
+    private String valueType;
+    /**
+     * 是否是计算参数
+     */
+    private Integer isParams;
+    /**
+     * 读取寄存器数量
+     */
+    private Integer quantity;
+    /**
+     * modbus功能码
+     */
+    private String code;
+    /**
+     * modbus解析类型
+     */
+    private String parseType;
+    /**
+     * 是否在APP显示(0-否,1-是)
+     */
+    private Boolean isApp;
+
+}

+ 1 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/yanfan/YfDeviceDO.java

@@ -15,12 +15,11 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
 @TableName("iot_device")
 @KeySequence("iot_device_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
 @Data
-@EqualsAndHashCode(callSuper = true)
 @ToString(callSuper = true)
 @Builder
 @NoArgsConstructor
 @AllArgsConstructor
-public class YfDeviceDO extends BaseDO {
+public class YfDeviceDO  {
 
     /**
      * 设备ID

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

@@ -85,6 +85,7 @@ public interface IotDeviceMapper extends BaseMapperX<IotDeviceDO> {
                 .eqIfPresent(IotDeviceDO::getInfoRemark, reqVO.getInfoRemark())
                 .eqIfPresent(IotDeviceDO::getInfoUrl, reqVO.getInfoUrl())
                 .eqIfPresent(IotDeviceDO::getTemplateJson, reqVO.getTemplateJson())
+                .eqIfPresent(IotDeviceDO::getDeviceCode, reqVO.getDeviceCode())
                 .orderByDesc(IotDeviceDO::getId));
     }
 

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

@@ -32,9 +32,33 @@ public interface TDDeviceMapper extends BaseMapperX<TDDeviceDO> {
     List<DeviceVO> selectNew(@Param("deviceName") String tableName);
 
 
+    @Select("SELECT LAST(ts) as ts FROM iot_log.device_${deviceName} ")
+    @DS("tdengine")
+    @TenantIgnore
+    List<DeviceVO> selectLastTime(@Param("deviceName") String tableName);
+
+//    @Select("SELECT identity, LAST(log_value) as logValue FROM iot_log.device_${deviceName} where identity in ${params} group by identity")
+    @Select({
+            "<script>",
+            "SELECT",
+            "  identity,",
+            "  LAST(log_value) AS logValue",
+
+            "FROM iot_log.device_${deviceName} ",
+            "WHERE identity IN ",
+            "<foreach collection='params' item='value' open='(' close=')' separator=','>",
+            "   #{value}",
+            "</foreach>",
+            "GROUP BY identity",
+            "</script>"
+    })
+    @DS("tdengine")
+    @TenantIgnore
+    List<DeviceVO> selectLastParam(@Param("deviceName") String tableName, @Param("params") List<String> params);
+
 
     @Select("SELECT * FROM iot_log.device_${deviceName} WHERE ts = #{ts}")
     @DS("tdengine")
     @TenantIgnore
     List<DeviceVO> selectByTs(@Param("deviceName") String tableName, @Param("ts") Timestamp ts);
-}
+}

+ 55 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/yanfan/ThingsModelMapper.java

@@ -0,0 +1,55 @@
+package cn.iocoder.yudao.module.pms.dal.mysql.yanfan;
+
+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.yanfan.vo.ThingsModelPageReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.yanfan.ThingsModelDO;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 物模型 Mapper
+ *
+ * @author 李鹏辉
+ */
+@Mapper
+public interface ThingsModelMapper extends BaseMapperX<ThingsModelDO> {
+
+    default PageResult<ThingsModelDO> selectPage(ThingsModelPageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<ThingsModelDO>()
+                .likeIfPresent(ThingsModelDO::getModelName, reqVO.getModelName())
+                .eqIfPresent(ThingsModelDO::getProductId, reqVO.getProductId())
+                .likeIfPresent(ThingsModelDO::getProductName, reqVO.getProductName())
+                .likeIfPresent(ThingsModelDO::getTenantName, reqVO.getTenantName())
+                .eqIfPresent(ThingsModelDO::getIdentifier, reqVO.getIdentifier())
+                .eqIfPresent(ThingsModelDO::getType, reqVO.getType())
+                .eqIfPresent(ThingsModelDO::getDatatype, reqVO.getDatatype())
+                .eqIfPresent(ThingsModelDO::getSpecs, reqVO.getSpecs())
+                .eqIfPresent(ThingsModelDO::getIsChart, reqVO.getIsChart())
+                .eqIfPresent(ThingsModelDO::getIsMonitor, reqVO.getIsMonitor())
+                .eqIfPresent(ThingsModelDO::getIsHistory, reqVO.getIsHistory())
+                .eqIfPresent(ThingsModelDO::getIsReadonly, reqVO.getIsReadonly())
+                .eqIfPresent(ThingsModelDO::getIsSharePerm, reqVO.getIsSharePerm())
+                .eqIfPresent(ThingsModelDO::getModelOrder, reqVO.getModelOrder())
+                .eqIfPresent(ThingsModelDO::getDelFlag, reqVO.getDelFlag())
+                .eqIfPresent(ThingsModelDO::getCreateBy, reqVO.getCreateBy())
+//                .betweenIfPresent(ThingsModelDO::getCreateTime, reqVO.getCreateTime())
+                .eqIfPresent(ThingsModelDO::getUpdateBy, reqVO.getUpdateBy())
+                .eqIfPresent(ThingsModelDO::getRemark, reqVO.getRemark())
+                .eqIfPresent(ThingsModelDO::getTempSlaveId, reqVO.getTempSlaveId())
+                .eqIfPresent(ThingsModelDO::getFormula, reqVO.getFormula())
+                .eqIfPresent(ThingsModelDO::getReverseFormula, reqVO.getReverseFormula())
+                .eqIfPresent(ThingsModelDO::getRegAddr, reqVO.getRegAddr())
+                .eqIfPresent(ThingsModelDO::getBitOption, reqVO.getBitOption())
+                .eqIfPresent(ThingsModelDO::getValueType, reqVO.getValueType())
+                .eqIfPresent(ThingsModelDO::getIsParams, reqVO.getIsParams())
+                .eqIfPresent(ThingsModelDO::getQuantity, reqVO.getQuantity())
+                .eqIfPresent(ThingsModelDO::getCode, reqVO.getCode())
+                .eqIfPresent(ThingsModelDO::getParseType, reqVO.getParseType())
+                .eqIfPresent(ThingsModelDO::getIsApp, reqVO.getIsApp())
+                .orderByDesc(ThingsModelDO::getModelId));
+    }
+
+}

+ 2 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/yanfan/YfDeviceMapper.java

@@ -38,7 +38,7 @@ public interface YfDeviceMapper extends BaseMapperX<YfDeviceDO> {
                 .eqIfPresent(YfDeviceDO::getImgUrl, reqVO.getImgUrl())
                 .eqIfPresent(YfDeviceDO::getDelFlag, reqVO.getDelFlag())
                 .eqIfPresent(YfDeviceDO::getCreateBy, reqVO.getCreateBy())
-                .betweenIfPresent(YfDeviceDO::getCreateTime, reqVO.getCreateTime())
+                //.betweenIfPresent(YfDeviceDO::getCreateTime, reqVO.getCreateTime())
                 .eqIfPresent(YfDeviceDO::getUpdateBy, reqVO.getUpdateBy())
                 .eqIfPresent(YfDeviceDO::getRemark, reqVO.getRemark())
                 .eqIfPresent(YfDeviceDO::getIsSimulate, reqVO.getIsSimulate())
@@ -47,7 +47,7 @@ public interface YfDeviceMapper extends BaseMapperX<YfDeviceDO> {
                 .eqIfPresent(YfDeviceDO::getPostDev, reqVO.getPostDev())
                 .eqIfPresent(YfDeviceDO::getGetDev, reqVO.getGetDev())
                 .eqIfPresent(YfDeviceDO::getMqttstats, reqVO.getMqttstats())
-                .orderByDesc(YfDeviceDO::getCreateTime));
+                .orderByDesc(YfDeviceDO::getDeviceId));
     }
 
 }

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

@@ -2,10 +2,12 @@ package cn.iocoder.yudao.module.pms.service;
 
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
+import cn.iocoder.yudao.module.pms.controller.admin.vo.DeviceVO;
 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.IotDeviceSaveReqVO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.yanfan.ThingsModelDO;
 import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
 import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
 
@@ -20,7 +22,7 @@ import java.util.Map;
  * @author 芋道源码
  */
 public interface IotDeviceService {
-
+    List<ThingsModelDO> getTdParams(IotDeviceDO iotDeviceDO);
     /**
      * 创建设备台账
      *

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

@@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
 import cn.iocoder.yudao.framework.common.exception.ServiceException;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.module.pms.controller.admin.vo.DeviceVO;
 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.IotDeviceSaveReqVO;
@@ -12,11 +13,16 @@ import cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.IotInfoClassifyDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.IotTreeDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotmodel.IotModelDO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.yanfan.ThingsModelDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.yanfan.YfDeviceDO;
 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;
+import cn.iocoder.yudao.module.pms.dal.mysql.TDDeviceMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.iotmodel.IotModelMapper;
+import cn.iocoder.yudao.module.pms.dal.mysql.yanfan.ThingsModelMapper;
+import cn.iocoder.yudao.module.pms.dal.mysql.yanfan.YfDeviceMapper;
+import cn.iocoder.yudao.module.pms.service.yanfan.ThingsModelService;
 import cn.iocoder.yudao.module.pms.service.yanfan.YfDeviceService;
 import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
 import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
@@ -28,12 +34,14 @@ import com.baomidou.dynamic.datasource.annotation.Slave;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.google.common.collect.ImmutableMap;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.annotation.Validated;
 
 import javax.annotation.Resource;
 import java.util.*;
+import java.util.stream.Collectors;
 
 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
 import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstant.IOT_DEVICE_NOT_EXISTS;
@@ -61,6 +69,37 @@ public class IotDeviceServiceImpl implements IotDeviceService {
     private DictDataService dictDataService;
     @Resource
     private YfDeviceService yfDeviceService;
+    @Autowired
+    private ThingsModelService thingsModelService;
+    @Autowired
+    private TDDeviceMapper deviceMapper;
+
+    @Override
+    public List<ThingsModelDO> getTdParams(IotDeviceDO iotDeviceDO) {
+        List<YfDeviceDO> yfDeviceDO = yfDeviceService.getAllDeviceByColumn("serial_number", iotDeviceDO.getDeviceCode());
+        if (CollUtil.isEmpty(yfDeviceDO)) {
+            throw new ServiceException(IOT_DEVICE_NOT_EXISTS);
+        }
+        Long productId = yfDeviceDO.get(0).getProductId();
+        //点位参数
+        List<ThingsModelDO> productId1 = thingsModelService.selectList("product_id", productId.toString());
+        List<String> collect = productId1.stream().map(ThingsModelDO::getIdentifier).collect(Collectors.toList());
+        //td数据
+        List<DeviceVO> deviceVOS = deviceMapper.selectLastParam(iotDeviceDO.getDeviceCode(), collect);
+        productId1.forEach(deviceVO -> {
+            deviceVOS.stream().filter(e -> e.getIdentity().equals(deviceVO.getIdentifier())).findFirst().ifPresent(ab ->{
+                deviceVO.setValueType(ab.getLogValue());
+                deviceVO.setCode(iotDeviceDO.getDeviceCode());
+            });
+        });
+//        deviceVOS.forEach(deviceVO -> {
+//            productId1.stream().filter(e ->e.getIdentifier().equals(deviceVO.getIdentity())).findFirst().ifPresent(deviceVO1 -> {
+//                deviceVO.setProductName(deviceVO1.getModelName());
+//                deviceVO.setDeviceName(iotDeviceDO.getDeviceCode());
+//            });
+//        });
+        return productId1;
+    }
 
     @Override
     @Transactional(rollbackFor = Exception.class)

+ 35 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/yanfan/ThingsModelService.java

@@ -0,0 +1,35 @@
+package cn.iocoder.yudao.module.pms.service.yanfan;
+
+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.yanfan.vo.ThingsModelPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.yanfan.vo.ThingsModelSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.yanfan.ThingsModelDO;
+
+/**
+ * 物模型 Service 接口
+ *
+ * @author 李鹏辉
+ */
+public interface ThingsModelService {
+
+    List<ThingsModelDO> selectList(String column, String value);
+    /**
+     * 获得物模型
+     *
+     * @param id 编号
+     * @return 物模型
+     */
+    ThingsModelDO getThingsModel(Long id);
+
+    /**
+     * 获得物模型分页
+     *
+     * @param pageReqVO 分页查询
+     * @return 物模型分页
+     */
+    PageResult<ThingsModelDO> getThingsModelPage(ThingsModelPageReqVO pageReqVO);
+
+}

+ 52 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/yanfan/ThingsModelServiceImpl.java

@@ -0,0 +1,52 @@
+package cn.iocoder.yudao.module.pms.service.yanfan;
+
+import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
+import cn.iocoder.yudao.module.pms.controller.admin.yanfan.vo.ThingsModelPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.yanfan.vo.ThingsModelSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.yanfan.ThingsModelDO;
+import cn.iocoder.yudao.module.pms.dal.mysql.yanfan.ThingsModelMapper;
+import com.baomidou.dynamic.datasource.annotation.Slave;
+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 ThingsModelServiceImpl implements ThingsModelService {
+
+    @Resource
+    private ThingsModelMapper thingsModelMapper;
+
+
+    @Override
+    @Slave
+    @TenantIgnore
+    public List<ThingsModelDO> selectList(String column, String value) {
+        return thingsModelMapper.selectList(column, value);
+    }
+
+    @Override
+    public ThingsModelDO getThingsModel(Long id) {
+        return thingsModelMapper.selectById(id);
+    }
+
+    @Override
+    public PageResult<ThingsModelDO> getThingsModelPage(ThingsModelPageReqVO pageReqVO) {
+        return thingsModelMapper.selectPage(pageReqVO);
+    }
+
+}

+ 1 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/yanfan/YfDeviceService.java

@@ -30,5 +30,5 @@ public interface YfDeviceService {
     PageResult<YfDeviceDO> getDevicePage(DevicePageReqVO pageReqVO);
 
     List<YfDeviceDO> getAllDevice();
-
+    List<YfDeviceDO> getAllDeviceByColumn(String column, String value);
 }

+ 7 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/yanfan/YfDeviceServiceImpl.java

@@ -35,6 +35,13 @@ public class YfDeviceServiceImpl implements YfDeviceService {
         return yfDeviceMapper.selectPage(pageReqVO);
     }
 
+    @Override
+    @Slave
+    @TenantIgnore
+    public List<YfDeviceDO> getAllDeviceByColumn(String column, String value) {
+        return yfDeviceMapper.selectList(column, value);
+    }
+
     @Override
     @Slave
     @TenantIgnore