sanlin.shi 1 week ago
parent
commit
8d13ba46b7
18 changed files with 951 additions and 3 deletions
  1. 2 0
      src/main/java/cn/hanghui/outapi/platform/common/config/WebSecurityConfig.java
  2. 5 2
      src/main/java/cn/hanghui/outapi/platform/common/utils/AppTokenUtil.java
  3. 141 0
      src/main/java/cn/hanghui/outapi/platform/tenant/controller/HhOmcDeviceController.java
  4. 1 1
      src/main/java/cn/hanghui/outapi/platform/tenant/entity/dto/hhlocal/HhLocalDeviceBase.java
  5. 29 0
      src/main/java/cn/hanghui/outapi/platform/tenant/entity/dto/hhomc/HhOmcDeviceBase.java
  6. 27 0
      src/main/java/cn/hanghui/outapi/platform/tenant/entity/dto/hhomc/HhOmcDeviceDto.java
  7. 38 0
      src/main/java/cn/hanghui/outapi/platform/tenant/entity/dto/hhomc/HhOmcDeviceSearch.java
  8. 26 0
      src/main/java/cn/hanghui/outapi/platform/tenant/entity/dto/hhomc/HhOmcDeviceTemplateDto.java
  9. 25 0
      src/main/java/cn/hanghui/outapi/platform/tenant/entity/dto/hhomc/HhOmcDeviceTemplateLessVo.java
  10. 30 0
      src/main/java/cn/hanghui/outapi/platform/tenant/entity/dto/hhomc/HhOmcDeviceTemplateSearch.java
  11. 38 0
      src/main/java/cn/hanghui/outapi/platform/tenant/entity/dto/hhomc/HhOmcDeviceTemplateVo.java
  12. 41 0
      src/main/java/cn/hanghui/outapi/platform/tenant/entity/dto/hhomc/HhOmcDeviceVo.java
  13. 42 0
      src/main/java/cn/hanghui/outapi/platform/tenant/entity/po/HhOmcDevice.java
  14. 35 0
      src/main/java/cn/hanghui/outapi/platform/tenant/entity/po/HhOmcDeviceTemplate.java
  15. 15 0
      src/main/java/cn/hanghui/outapi/platform/tenant/mapper/HhOmcDeviceMapper.java
  16. 16 0
      src/main/java/cn/hanghui/outapi/platform/tenant/mapper/HhOmcDeviceTemplateMapper.java
  17. 47 0
      src/main/java/cn/hanghui/outapi/platform/tenant/service/HhOmcDeviceService.java
  18. 393 0
      src/main/java/cn/hanghui/outapi/platform/tenant/service/impl/HhOmcDeviceServiceImpl.java

+ 2 - 0
src/main/java/cn/hanghui/outapi/platform/common/config/WebSecurityConfig.java

@@ -154,6 +154,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter implements W
         excludeList.add("/api/v1/fkj/device/sn/**");
         excludeList.add("/api/v1/hh/culture/device/sn/**");
         excludeList.add("/api/v1/hh/local/device/sn/**");
+        excludeList.add("/api/v1/hh/omc/device/config/**");
+
         excludeList.add("/**/v1/proof/**");
         return ArrayUtil.toArray(excludeList, String.class);
     }

+ 5 - 2
src/main/java/cn/hanghui/outapi/platform/common/utils/AppTokenUtil.java

@@ -23,12 +23,15 @@ public class AppTokenUtil {
                 "edcf7741161b70c0813a05a5e4391fdb",
                 //访客机zjy
                 "01f8624317168a4a52fd89f673a3ccbc",
-                //深大临时
+                //深大临时 @Deprecated
 //                "ab051195190b4623ea62f636ae747f53",
                 //临时身份证明
                 "699e04c8460e964d531e9976a0ab51ca",
                 //HHCulture设备
-                "b740583887631e2d713ee16e2bf7acc2"
+                "b740583887631e2d713ee16e2bf7acc2",
+                //HHOmc设备
+                "2915ac041cb759bfdc4968d4fce1c437"
+
         );
     }
 

+ 141 - 0
src/main/java/cn/hanghui/outapi/platform/tenant/controller/HhOmcDeviceController.java

@@ -0,0 +1,141 @@
+package cn.hanghui.outapi.platform.tenant.controller;
+
+import cn.hanghui.outapi.platform.common.controller.BaseController;
+import cn.hanghui.outapi.platform.common.entity.rest.RestCode;
+import cn.hanghui.outapi.platform.common.entity.rest.RestResponse;
+import cn.hanghui.outapi.platform.common.entity.rest.RestResult;
+import cn.hanghui.outapi.platform.common.utils.AppTokenUtil;
+import cn.hanghui.outapi.platform.tenant.entity.dto.TenantDto;
+import cn.hanghui.outapi.platform.tenant.entity.dto.hhomc.HhOmcDeviceDto;
+import cn.hanghui.outapi.platform.tenant.entity.dto.hhomc.HhOmcDeviceSearch;
+import cn.hanghui.outapi.platform.tenant.entity.dto.hhomc.HhOmcDeviceTemplateDto;
+import cn.hanghui.outapi.platform.tenant.entity.dto.hhomc.HhOmcDeviceTemplateLessVo;
+import cn.hanghui.outapi.platform.tenant.entity.dto.hhomc.HhOmcDeviceTemplateSearch;
+import cn.hanghui.outapi.platform.tenant.entity.dto.hhomc.HhOmcDeviceTemplateVo;
+import cn.hanghui.outapi.platform.tenant.entity.dto.hhomc.HhOmcDeviceVo;
+import cn.hanghui.outapi.platform.tenant.service.HhOmcDeviceService;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.validation.Valid;
+import java.util.List;
+
+/**
+ * @author shisl
+ * @package cn.hanghui.outapi.platform.tenant.controller
+ * @class HhOmcDeviceController
+ * @date 2024/12/31 上午10:38
+ * @description
+ */
+@Slf4j
+@Api(tags = "HHOmc设备配置")
+@RestController
+@RequestMapping(value = "/api/v1/hh/omc/device")
+public class HhOmcDeviceController extends BaseController {
+
+    @Autowired
+    private HhOmcDeviceService hhOmcDeviceService;
+
+    @ApiOperation("模版-新增/编辑")
+    @PostMapping("template/edit")
+    @ApiOperationSupport(order = 100)
+    public RestResult<Boolean> templateEdit(@RequestBody @Valid HhOmcDeviceTemplateDto dto) {
+        return RestResponse.ok(hhOmcDeviceService.templateEdit(dto));
+    }
+
+    @ApiOperation("模版列表")
+    @GetMapping("template/list")
+    @ApiOperationSupport(order = 110)
+    public RestResult<List<HhOmcDeviceTemplateLessVo>> templateList() {
+        return RestResponse.ok(hhOmcDeviceService.templateList());
+    }
+
+    @ApiOperation("模版列表(分页)")
+    @PostMapping("template/page")
+    @ApiOperationSupport(order = 120)
+    public RestResult<IPage<HhOmcDeviceTemplateVo>> templatePage(@RequestBody HhOmcDeviceTemplateSearch dto) {
+        return RestResponse.ok(hhOmcDeviceService.templatePage(dto));
+    }
+
+    @ApiOperation("模版-删除")
+    @GetMapping("template/{deviceTemplateId}")
+    @ApiOperationSupport(order = 130)
+    public RestResult<Boolean> templateDelete(@PathVariable(value = "deviceTemplateId") Long deviceTemplateId) {
+        return RestResponse.ok(hhOmcDeviceService.templateDelete(deviceTemplateId));
+    }
+
+    @ApiOperation("模版-模版详情")
+    @GetMapping("template/detail")
+    @ApiOperationSupport(order = 140)
+    public RestResult<HhOmcDeviceTemplateVo> templateDetail(@RequestParam(value = "deviceTemplateId") Long deviceTemplateId) {
+        return RestResponse.ok(hhOmcDeviceService.templateDetail(deviceTemplateId));
+    }
+
+    @ApiOperation(value = "设备配置-添加/编辑")
+    @PostMapping("/add")
+    @ApiOperationSupport(order = 150)
+    public RestResult<Boolean> add(@RequestBody HhOmcDeviceDto dto) {
+        return hhOmcDeviceService.add(dto);
+    }
+
+    @ApiOperation(value = "设备列表(分页)")
+    @PostMapping("/page")
+    @ApiOperationSupport(order = 160)
+    public RestResult<IPage<HhOmcDeviceVo>> page(@RequestBody HhOmcDeviceSearch dto) {
+        return hhOmcDeviceService.page(dto);
+    }
+
+    @ApiOperation(value = "获取设备编号列表")
+    @PostMapping("/sn/list")
+    public RestResult<List<String>> snlist() {
+        return hhOmcDeviceService.snlist();
+    }
+
+    @ApiOperation(value = "设备删除")
+    @PostMapping("/del/{deviceId}")
+    @ApiOperationSupport(order = 170)
+    public RestResult<Boolean> del(@PathVariable(value = "deviceId") @ApiParam(value = "deviceId", required = true) Long deviceId) {
+        return hhOmcDeviceService.del(deviceId);
+    }
+
+    @ApiOperation(value = "设备授权")
+    @GetMapping("/enable")
+    @ApiOperationSupport(order = 180)
+    public RestResult<Boolean> enable(@RequestParam(value = "deviceId") @ApiParam(value = "deviceId", required = true) Long deviceId) {
+        return hhOmcDeviceService.opeDeviceAuth(deviceId, Boolean.TRUE);
+    }
+
+    @ApiOperation(value = "设备取消授权")
+    @GetMapping("/disable")
+    @ApiOperationSupport(order = 190)
+    public RestResult<Boolean> disable(@RequestParam(value = "deviceId") @ApiParam(value = "deviceId", required = true) Long deviceId) {
+        return hhOmcDeviceService.opeDeviceAuth(deviceId, Boolean.FALSE);
+    }
+
+    @ApiOperation(value = "HHOmc设备-获取配置信息")
+    @PostMapping("/config/query")
+    @ApiOperationSupport(order = 200)
+    public RestResult<HhOmcDeviceVo> queryConfig(@RequestBody TenantDto dto) {
+        log.info("--->HHOmc设备-获取配置信息:{}", JSONObject.toJSONString(dto));
+        //HHOmc设备 2915ac041cb759bfdc4968d4fce1c437
+        List<String> tokens = AppTokenUtil.getTokens();
+        if (!tokens.contains(dto.getToken().trim())) {
+            return RestResult.error(RestCode.FORBIDDEN.getMsg());
+        }
+        return hhOmcDeviceService.queryConfig(dto);
+    }
+
+}

+ 1 - 1
src/main/java/cn/hanghui/outapi/platform/tenant/entity/dto/hhlocal/HhLocalDeviceBase.java

@@ -421,7 +421,7 @@ public class HhLocalDeviceBase implements Serializable {
     private Integer sameFaceInterval;
     /** @see cn.hanghui.outapi.platform.tenant.entity.enums.SuccessShowPersenalInfoListEnum */
     @ApiModelProperty(value = "成功显示人员信息列表-枚举")
-    private List<Integer> successShowPersenalInfoList;
+    private List<Integer> successShowPersonalInfoList;
     /** @see cn.hanghui.outapi.platform.tenant.entity.enums.SetPersenalListEnum */
     @ApiModelProperty(value = "“设置——人员列表”【控制设置页里的人员数据的信息】-枚举")
     private List<Integer> setPersonalList;

+ 29 - 0
src/main/java/cn/hanghui/outapi/platform/tenant/entity/dto/hhomc/HhOmcDeviceBase.java

@@ -0,0 +1,29 @@
+package cn.hanghui.outapi.platform.tenant.entity.dto.hhomc;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author shisl
+ * @package cn.hanghui.outapi.platform.tenant.entity.dto.hhomc
+ * @class HhOmcDeviceBase
+ * @date 2024/12/31 上午10:42
+ * @description
+ */
+@Data
+public class HhOmcDeviceBase implements Serializable {
+
+    @ApiModelProperty(value = "应用类型id")
+    private Long applicationTypeId;
+    @ApiModelProperty(value = "设备型号(硬件)id")
+    private Long deviceModelHardwareId;
+    @ApiModelProperty(value = "设备型号(环境)id")
+    private Long deviceModelEnvironmentId;
+    @ApiModelProperty(value = "系统类型 1-蚂蚁OS 2-非蚂蚁OS")
+    private Integer systemTypeCode;
+    @ApiModelProperty(value = "ota平台ws地址")
+    private String websocketSubscribeUrl;
+
+}

+ 27 - 0
src/main/java/cn/hanghui/outapi/platform/tenant/entity/dto/hhomc/HhOmcDeviceDto.java

@@ -0,0 +1,27 @@
+package cn.hanghui.outapi.platform.tenant.entity.dto.hhomc;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author shisl
+ * @package cn.hanghui.outapi.platform.tenant.entity.dto.hhomc
+ * @class HhOmcDeviceDto
+ * @date 2024/9/25 上午9:25
+ * @description
+ */
+@Data
+public class HhOmcDeviceDto extends HhOmcDeviceBase {
+
+    //公共参数
+    private Long id;
+
+    //设备基本配置
+    @ApiModelProperty(value = "设备sn", required = true)
+    private String sn;
+
+    @ApiModelProperty(value = "购买方公司id")
+    private Long purchaserId;
+
+    
+}

+ 38 - 0
src/main/java/cn/hanghui/outapi/platform/tenant/entity/dto/hhomc/HhOmcDeviceSearch.java

@@ -0,0 +1,38 @@
+package cn.hanghui.outapi.platform.tenant.entity.dto.hhomc;
+
+import cn.hanghui.outapi.platform.tenant.entity.config.maintenance.BaseSearch;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author shisl
+ * @package cn.hanghui.outapi.platform.tenant.entity.dto.hhomc
+ * @class HhOmcDeviceSearch
+ * @date 2024/7/19 上午10:58
+ * @description
+ */
+@Data
+public class HhOmcDeviceSearch extends BaseSearch {
+
+    @ApiModelProperty(value = "设备编号")
+    private String sn;
+
+    @ApiModelProperty(value = "购买方Id")
+    private Long purchaserId;
+
+    @ApiModelProperty(value = "应用类型id")
+    private Long applicationTypeId;
+
+    @ApiModelProperty(value = "设备型号(硬件)id")
+    private Long deviceModelHardwareId;
+
+    @ApiModelProperty(value = "设备型号(环境)id")
+    private Long deviceModelEnvironmentId;
+
+    @ApiModelProperty(value = "系统类型 1-蚂蚁OS 2-非蚂蚁OS")
+    private Integer systemTypeCode;
+
+    @ApiModelProperty(value = "授权状态  false:未授权 true:已授权")
+    private Boolean status;
+
+}

+ 26 - 0
src/main/java/cn/hanghui/outapi/platform/tenant/entity/dto/hhomc/HhOmcDeviceTemplateDto.java

@@ -0,0 +1,26 @@
+package cn.hanghui.outapi.platform.tenant.entity.dto.hhomc;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+ * @author shisl
+ * @package cn.hanghui.outapi.platform.tenant.entity.dto.hhomc
+ * @class HhOmcDeviceTemplateDto
+ * @date 2024/9/25 上午9:26
+ * @description
+ */
+@Data
+public class HhOmcDeviceTemplateDto extends HhOmcDeviceBase {
+
+    @ApiModelProperty(value = "设备模版id")
+    private Long deviceTemplateId;
+
+    @ApiModelProperty(value = "模版名称")
+    @NotBlank(message = "请输入模版名称")
+    private String templateName;
+
+
+}

+ 25 - 0
src/main/java/cn/hanghui/outapi/platform/tenant/entity/dto/hhomc/HhOmcDeviceTemplateLessVo.java

@@ -0,0 +1,25 @@
+package cn.hanghui.outapi.platform.tenant.entity.dto.hhomc;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * @author shisl
+ * @package cn.hanghui.outapi.platform.tenant.entity.dto.hhomc
+ * @class HhOmcDeviceTemplateLessVo
+ * @date 2024/9/25 上午9:28
+ * @description
+ */
+@Data
+@Accessors(chain = true)
+public class HhOmcDeviceTemplateLessVo implements Serializable {
+
+    private Long deviceTemplateId;
+
+    @ApiModelProperty(value = "模版名称")
+    private String templateName;
+
+}

+ 30 - 0
src/main/java/cn/hanghui/outapi/platform/tenant/entity/dto/hhomc/HhOmcDeviceTemplateSearch.java

@@ -0,0 +1,30 @@
+package cn.hanghui.outapi.platform.tenant.entity.dto.hhomc;
+
+import cn.hanghui.outapi.platform.tenant.entity.config.maintenance.BaseSearch;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author shisl
+ * @package cn.hanghui.outapi.platform.tenant.entity.dto.hhomc
+ * @class HhOmcDeviceTemplateSearch
+ * @date 2024/9/25 上午9:29
+ * @description
+ */
+@Data
+public class HhOmcDeviceTemplateSearch extends BaseSearch {
+
+    @ApiModelProperty(value = "设备模版id")
+    private Long deviceTemplateId;
+    @ApiModelProperty(value = "应用类型id")
+    private Long applicationTypeId;
+    @ApiModelProperty(value = "设备型号(硬件)id")
+    private Long deviceModelHardwareId;
+    @ApiModelProperty(value = "设备型号(环境)id")
+    private Long deviceModelEnvironmentId;
+    @ApiModelProperty(value = "系统类型 1-蚂蚁OS 2-非蚂蚁OS")
+    private Integer systemTypeCode;
+
+
+
+}

+ 38 - 0
src/main/java/cn/hanghui/outapi/platform/tenant/entity/dto/hhomc/HhOmcDeviceTemplateVo.java

@@ -0,0 +1,38 @@
+package cn.hanghui.outapi.platform.tenant.entity.dto.hhomc;
+
+import cn.hanghui.outapi.platform.tenant.entity.dto.hhlocal.HhLocalDeviceBase;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author shisl
+ * @package cn.hanghui.outapi.platform.tenant.entity.dto.hhomc
+ * @class HhOmcDeviceTemplateVo
+ * @date 2024/9/25 上午9:28
+ * @description
+ */
+@Data
+public class HhOmcDeviceTemplateVo extends HhOmcDeviceBase {
+
+    @ApiModelProperty(value = "设备模版id")
+    private Long deviceTemplateId;
+    @ApiModelProperty(value = "模版名称")
+    private String templateName;
+
+    @ApiModelProperty(value = "应用类型")
+    private String applicationType;
+    @ApiModelProperty(value = "设备型号(硬件)")
+    private String deviceModelHardware;
+    @ApiModelProperty(value = "设备型号(环境)")
+    private String deviceModelEnvironment;
+    @ApiModelProperty(value = "系统类型")
+    private String systemType;
+
+    @ApiModelProperty(value = "创建时间")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+}

+ 41 - 0
src/main/java/cn/hanghui/outapi/platform/tenant/entity/dto/hhomc/HhOmcDeviceVo.java

@@ -0,0 +1,41 @@
+package cn.hanghui.outapi.platform.tenant.entity.dto.hhomc;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author shisl
+ * @package cn.hanghui.outapi.platform.tenant.entity.dto.hhomc
+ * @class HhOmcDeviceVo
+ * @date 2024/12/31 上午10:41
+ * @description
+ */
+@Data
+public class HhOmcDeviceVo extends HhOmcDeviceBase {
+
+    private Long id;
+
+    private String sn;
+    @ApiModelProperty(value = "购买方公司id")
+    private Long purchaserId;
+    @ApiModelProperty("购买方公司名称")
+    private String companyName;
+    @ApiModelProperty(value = "应用类型")
+    private String applicationType;
+    @ApiModelProperty(value = "设备型号(硬件)")
+    private String deviceModelHardware;
+    @ApiModelProperty(value = "设备型号(环境)")
+    private String deviceModelEnvironment;
+    @ApiModelProperty(value = "系统类型")
+    private String systemType;
+
+    @ApiModelProperty(value = "授权状态  false:未授权 true:已授权")
+    private Boolean status;
+
+    @ApiModelProperty(value = "创建时间")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+}

+ 42 - 0
src/main/java/cn/hanghui/outapi/platform/tenant/entity/po/HhOmcDevice.java

@@ -0,0 +1,42 @@
+package cn.hanghui.outapi.platform.tenant.entity.po;
+
+import cn.hanghui.outapi.platform.common.entity.po.Base;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+
+/**
+ * 设备
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@TableName(value = "hh_omc_device", autoResultMap = true)
+public class HhOmcDevice extends Base {
+
+    @ApiModelProperty(value = "授权状态  0:未授权 1:已授权")
+    private Boolean status;
+    @ApiModelProperty(value = "第一次授权时间")
+    private Date firstAuthTime;
+
+    //设备基本配置
+    @ApiModelProperty(value = "设备sn")
+    private String sn;
+    @ApiModelProperty(value = "购买方公司id")
+    private Long purchaserId;
+    @ApiModelProperty(value = "应用类型id")
+    private Long applicationTypeId;
+    @ApiModelProperty(value = "设备型号(硬件)id")
+    private Long deviceModelHardwareId;
+    @ApiModelProperty(value = "设备型号(环境)id")
+    private Long deviceModelEnvironmentId;
+    @ApiModelProperty(value = "系统类型 1-蚂蚁OS 2-非蚂蚁OS")
+    private Integer systemTypeCode;
+    @ApiModelProperty(value = "ota平台ws地址")
+    private String websocketSubscribeUrl;
+
+
+}
+

+ 35 - 0
src/main/java/cn/hanghui/outapi/platform/tenant/entity/po/HhOmcDeviceTemplate.java

@@ -0,0 +1,35 @@
+package cn.hanghui.outapi.platform.tenant.entity.po;
+
+import cn.hanghui.outapi.platform.common.entity.po.Base;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 设备
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@TableName(value = "hh_omc_device_template", autoResultMap = true)
+public class HhOmcDeviceTemplate extends Base {
+
+    @ApiModelProperty(value = "模版名称")
+    @TableField("template_name")
+    private String templateName;
+    @ApiModelProperty(value = "应用类型id")
+    private Long applicationTypeId;
+    @ApiModelProperty(value = "设备型号(硬件)id")
+    private Long deviceModelHardwareId;
+    @ApiModelProperty(value = "设备型号(环境)id")
+    private Long deviceModelEnvironmentId;
+    @ApiModelProperty(value = "系统类型 1-蚂蚁OS 2-非蚂蚁OS")
+    private Integer systemTypeCode;
+    @ApiModelProperty(value = "ota平台ws地址")
+    private String websocketSubscribeUrl;
+
+
+
+}
+

+ 15 - 0
src/main/java/cn/hanghui/outapi/platform/tenant/mapper/HhOmcDeviceMapper.java

@@ -0,0 +1,15 @@
+package cn.hanghui.outapi.platform.tenant.mapper;
+
+import cn.hanghui.outapi.platform.tenant.entity.po.HhOmcDevice;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * @author shisl
+ * @package cn.hanghui.outapi.platform.tenant.mapper
+ * @class HhOmcDeviceMapper
+ * @date 2024/12/31 下午1:57
+ * @description
+ */
+public interface HhOmcDeviceMapper extends BaseMapper<HhOmcDevice> {
+
+}

+ 16 - 0
src/main/java/cn/hanghui/outapi/platform/tenant/mapper/HhOmcDeviceTemplateMapper.java

@@ -0,0 +1,16 @@
+package cn.hanghui.outapi.platform.tenant.mapper;
+
+import cn.hanghui.outapi.platform.tenant.entity.po.HhOmcDeviceTemplate;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * @author shisl
+ * @package cn.hanghui.outapi.platform.tenant.mapper
+ * @class HhOmcDeviceMapper
+ * @date 2024/12/31 下午1:57
+ * @description
+ */
+public interface HhOmcDeviceTemplateMapper extends BaseMapper<HhOmcDeviceTemplate> {
+
+
+}

+ 47 - 0
src/main/java/cn/hanghui/outapi/platform/tenant/service/HhOmcDeviceService.java

@@ -0,0 +1,47 @@
+package cn.hanghui.outapi.platform.tenant.service;
+
+import cn.hanghui.outapi.platform.common.entity.rest.RestResult;
+import cn.hanghui.outapi.platform.tenant.entity.dto.TenantDto;
+import cn.hanghui.outapi.platform.tenant.entity.dto.hhomc.HhOmcDeviceDto;
+import cn.hanghui.outapi.platform.tenant.entity.dto.hhomc.HhOmcDeviceSearch;
+import cn.hanghui.outapi.platform.tenant.entity.dto.hhomc.HhOmcDeviceTemplateDto;
+import cn.hanghui.outapi.platform.tenant.entity.dto.hhomc.HhOmcDeviceTemplateLessVo;
+import cn.hanghui.outapi.platform.tenant.entity.dto.hhomc.HhOmcDeviceTemplateSearch;
+import cn.hanghui.outapi.platform.tenant.entity.dto.hhomc.HhOmcDeviceTemplateVo;
+import cn.hanghui.outapi.platform.tenant.entity.dto.hhomc.HhOmcDeviceVo;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+import java.util.List;
+
+/**
+ * @author shisl
+ * @package cn.hanghui.outapi.platform.tenant.service
+ * @class HhOmcDeviceService
+ * @date 2024/12/31 上午11:24
+ * @description
+ */
+public interface HhOmcDeviceService {
+
+    Boolean templateEdit(HhOmcDeviceTemplateDto dto);
+
+    List<HhOmcDeviceTemplateLessVo> templateList();
+
+    IPage<HhOmcDeviceTemplateVo> templatePage(HhOmcDeviceTemplateSearch dto);
+
+    Boolean templateDelete(Long deviceTemplateId);
+
+    HhOmcDeviceTemplateVo templateDetail(Long deviceTemplateId);
+
+    RestResult<Boolean> add(HhOmcDeviceDto dto);
+
+    RestResult<IPage<HhOmcDeviceVo>> page(HhOmcDeviceSearch dto);
+
+    RestResult<List<String>> snlist();
+
+    RestResult<Boolean> del(Long deviceId);
+
+    RestResult<Boolean> opeDeviceAuth(Long deviceId, Boolean enableflag);
+
+    RestResult<HhOmcDeviceVo> queryConfig(TenantDto dto);
+    
+}

+ 393 - 0
src/main/java/cn/hanghui/outapi/platform/tenant/service/impl/HhOmcDeviceServiceImpl.java

@@ -0,0 +1,393 @@
+package cn.hanghui.outapi.platform.tenant.service.impl;
+
+import cn.hanghui.outapi.platform.common.entity.rest.RestCode;
+import cn.hanghui.outapi.platform.common.entity.rest.RestResult;
+import cn.hanghui.outapi.platform.common.utils.ClassUtil;
+import cn.hanghui.outapi.platform.common.utils.Preconditions;
+import cn.hanghui.outapi.platform.tenant.entity.dto.TenantDto;
+import cn.hanghui.outapi.platform.tenant.entity.dto.hhomc.HhOmcDeviceDto;
+import cn.hanghui.outapi.platform.tenant.entity.dto.hhomc.HhOmcDeviceSearch;
+import cn.hanghui.outapi.platform.tenant.entity.dto.hhomc.HhOmcDeviceTemplateDto;
+import cn.hanghui.outapi.platform.tenant.entity.dto.hhomc.HhOmcDeviceTemplateLessVo;
+import cn.hanghui.outapi.platform.tenant.entity.dto.hhomc.HhOmcDeviceTemplateSearch;
+import cn.hanghui.outapi.platform.tenant.entity.dto.hhomc.HhOmcDeviceTemplateVo;
+import cn.hanghui.outapi.platform.tenant.entity.dto.hhomc.HhOmcDeviceVo;
+import cn.hanghui.outapi.platform.tenant.entity.enums.SystemTypeEnum;
+import cn.hanghui.outapi.platform.tenant.entity.po.ApplicationType;
+import cn.hanghui.outapi.platform.tenant.entity.po.DeviceModel;
+import cn.hanghui.outapi.platform.tenant.entity.po.HhOmcDevice;
+import cn.hanghui.outapi.platform.tenant.entity.po.HhOmcDeviceTemplate;
+import cn.hanghui.outapi.platform.tenant.entity.po.Purchaser;
+import cn.hanghui.outapi.platform.tenant.mapper.ApplicationTypeMapper;
+import cn.hanghui.outapi.platform.tenant.mapper.DeviceModelMapper;
+import cn.hanghui.outapi.platform.tenant.mapper.HhOmcDeviceMapper;
+import cn.hanghui.outapi.platform.tenant.mapper.HhOmcDeviceTemplateMapper;
+import cn.hanghui.outapi.platform.tenant.mapper.PurchaserMapper;
+import cn.hanghui.outapi.platform.tenant.service.HhOmcDeviceService;
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * @author shisl
+ * @package cn.hanghui.outapi.platform.tenant.service.impl
+ * @class HhOmcDeviceServiceImpl
+ * @date 2024/12/31 上午11:24
+ * @description
+ */
+@Service
+public class HhOmcDeviceServiceImpl implements HhOmcDeviceService {
+
+    @Resource
+    private CommonImpl commonImpl;
+
+    @Resource
+    private ApplicationTypeMapper applicationTypeMapper;
+
+    @Resource
+    private PurchaserMapper purchaserMapper;
+
+    @Resource
+    private DeviceModelMapper deviceModelMapper;
+
+    @Resource
+    private HhOmcDeviceMapper hhOmcDeviceMapper;
+
+    @Resource
+    private HhOmcDeviceTemplateMapper hhOmcDeviceTemplateMapper;
+
+    @Override
+    public Boolean templateEdit(HhOmcDeviceTemplateDto dto) {
+        checkTemplateDto(dto);
+        Long templateId = dto.getDeviceTemplateId();
+        if (templateId == null) {
+            HhOmcDeviceTemplate template = BeanUtil.copyProperties(dto, HhOmcDeviceTemplate.class);
+            hhOmcDeviceTemplateMapper.insert(template);
+        } else {
+            HhOmcDeviceTemplate base = hhOmcDeviceTemplateMapper.selectById(templateId);
+            ClassUtil.throwBusinessException(ObjectUtil.isNull(base), RestCode.FAIL.getCode(), "模版不存在");
+            BeanUtil.copyProperties(dto, base);
+            hhOmcDeviceTemplateMapper.updateById(base);
+        }
+        return true;
+    }
+
+    private void checkTemplateDto(HhOmcDeviceTemplateDto dto) {
+        //应用类型
+        if (Preconditions.isNotBlank(dto.getApplicationTypeId())) {
+            ApplicationType applicationType = applicationTypeMapper.selectById(dto.getApplicationTypeId());
+            ClassUtil.throwBusinessException(ObjectUtil.isNull(applicationType), RestCode.FAIL.getCode(), "应用类型不存在");
+            ClassUtil.throwBusinessException(ObjectUtil.isNull(applicationType.getIsDeleted()), RestCode.FAIL.getCode(), "应用类型已删除");
+        }
+        //设备类型(硬件)
+        if (Preconditions.isNotBlank(dto.getDeviceModelHardwareId())) {
+            DeviceModel deviceModelHardware = deviceModelMapper.selectById(dto.getDeviceModelHardwareId());
+            ClassUtil.throwBusinessException(ObjectUtil.isNull(deviceModelHardware), RestCode.FAIL.getCode(), "设备类型(硬件)不存在");
+            ClassUtil.throwBusinessException(ObjectUtil.isNull(deviceModelHardware.getIsDeleted()), RestCode.FAIL.getCode(), "设备类型(硬件)已删除");
+        }
+        //设备类型(环境)
+        if (Preconditions.isNotBlank(dto.getDeviceModelEnvironmentId())) {
+            DeviceModel deviceModelEnvironment = deviceModelMapper.selectById(dto.getDeviceModelEnvironmentId());
+            ClassUtil.throwBusinessException(ObjectUtil.isNull(deviceModelEnvironment), RestCode.FAIL.getCode(), "设备类型(环境)不存在");
+            ClassUtil.throwBusinessException(ObjectUtil.isNull(deviceModelEnvironment.getIsDeleted()), RestCode.FAIL.getCode(), "设备类型(环境)已删除");
+        }
+        //系统类型
+        if (Preconditions.isNotBlank(dto.getSystemTypeCode())) {
+            SystemTypeEnum systemTypeEnum = SystemTypeEnum.getEnumByCode(dto.getSystemTypeCode());
+            ClassUtil.throwBusinessException(ObjectUtil.isNull(systemTypeEnum), RestCode.FAIL.getCode(), "系统类型不存在");
+        }
+
+    }
+
+    @Override
+    public List<HhOmcDeviceTemplateLessVo> templateList() {
+        LambdaQueryWrapper<HhOmcDeviceTemplate> wrapper = new LambdaQueryWrapper<>();
+        //查询的基础条件
+        wrapper.select(HhOmcDeviceTemplate::getId, HhOmcDeviceTemplate::getTemplateName);
+        wrapper.eq(HhOmcDeviceTemplate::getIsDeleted, Boolean.FALSE);
+        wrapper.orderByDesc(HhOmcDeviceTemplate::getId);
+        List<HhOmcDeviceTemplate> templates = hhOmcDeviceTemplateMapper.selectList(wrapper);
+        return templates.stream().map(p -> new HhOmcDeviceTemplateLessVo()
+                .setDeviceTemplateId(p.getId())
+                .setTemplateName(p.getTemplateName())).collect(Collectors.toList());
+    }
+
+    @Override
+    public IPage<HhOmcDeviceTemplateVo> templatePage(HhOmcDeviceTemplateSearch dto) {
+        Page<HhOmcDeviceTemplate> page = new Page<>(dto.getPageNumber(), dto.getPageSize());
+        LambdaQueryWrapper<HhOmcDeviceTemplate> wrapper = this.getWrapper(dto);
+        IPage<HhOmcDeviceTemplate> iPage = hhOmcDeviceTemplateMapper.selectPage(page, wrapper);
+        Map<Long, ApplicationType> applicationTypeMap = commonImpl.getApplicationTypeMap(iPage, HhOmcDeviceTemplate::getApplicationTypeId);
+        Map<Long, DeviceModel> deviceModelHardwareMap = commonImpl.getDeviceModelMap(iPage, HhOmcDeviceTemplate::getDeviceModelHardwareId);
+        Map<Long, DeviceModel> deviceModelEnvironmentMap = commonImpl.getDeviceModelMap(iPage, HhOmcDeviceTemplate::getDeviceModelEnvironmentId);
+
+        return iPage.convert(t -> {
+            HhOmcDeviceTemplateVo item = BeanUtil.copyProperties(t, HhOmcDeviceTemplateVo.class);
+            item.setDeviceTemplateId(t.getId());
+            if (applicationTypeMap.containsKey(t.getApplicationTypeId())) {
+                item.setApplicationType(applicationTypeMap.get(t.getApplicationTypeId()).getApplicationType());
+            }
+            if (deviceModelHardwareMap.containsKey(t.getDeviceModelHardwareId())) {
+                item.setDeviceModelHardware(deviceModelHardwareMap.get(t.getDeviceModelHardwareId()).getDeviceModel());
+            }
+            if (deviceModelEnvironmentMap.containsKey(t.getDeviceModelEnvironmentId())) {
+                item.setDeviceModelEnvironment(deviceModelEnvironmentMap.get(t.getDeviceModelEnvironmentId()).getDeviceModel());
+            }
+            SystemTypeEnum systemTypeEnum = SystemTypeEnum.getEnumByCode(t.getSystemTypeCode());
+            if (ObjectUtil.isNotNull(systemTypeEnum)) {
+                item.setSystemType(systemTypeEnum.getDesc());
+            }
+            return item;
+        });
+    }
+
+    private LambdaQueryWrapper<HhOmcDeviceTemplate> getWrapper(HhOmcDeviceTemplateSearch dto) {
+        LambdaQueryWrapper<HhOmcDeviceTemplate> wrapper = new LambdaQueryWrapper<>();
+        //查询的传参条件
+        wrapper.eq(ObjectUtil.isNotNull(dto.getDeviceTemplateId()), HhOmcDeviceTemplate::getId, dto.getDeviceTemplateId());
+        wrapper.eq(ObjectUtil.isNotNull(dto.getApplicationTypeId()), HhOmcDeviceTemplate::getApplicationTypeId, dto.getApplicationTypeId());
+        wrapper.eq(ObjectUtil.isNotNull(dto.getDeviceModelHardwareId()), HhOmcDeviceTemplate::getDeviceModelHardwareId, dto.getDeviceModelHardwareId());
+        wrapper.eq(ObjectUtil.isNotNull(dto.getDeviceModelEnvironmentId()), HhOmcDeviceTemplate::getDeviceModelEnvironmentId, dto.getDeviceModelEnvironmentId());
+        wrapper.eq(ObjectUtil.isNotNull(dto.getSystemTypeCode()), HhOmcDeviceTemplate::getSystemTypeCode, dto.getSystemTypeCode());
+        //查询的基础条件
+        wrapper.eq(HhOmcDeviceTemplate::getIsDeleted, Boolean.FALSE);
+        wrapper.orderByDesc(HhOmcDeviceTemplate::getId);
+        return wrapper;
+    }
+
+    @Override
+    public Boolean templateDelete(Long deviceTemplateId) {
+        HhOmcDeviceTemplate template = hhOmcDeviceTemplateMapper.selectById(deviceTemplateId);
+        ClassUtil.throwBusinessException(ObjectUtil.isNull(template), RestCode.FAIL.getCode(), "模版不存在");
+        ClassUtil.throwBusinessException(ObjectUtil.isNull(template.getIsDeleted()), RestCode.FAIL.getCode(), "模版已删除");
+        hhOmcDeviceTemplateMapper.deleteById(deviceTemplateId);
+        return Boolean.TRUE;
+    }
+
+    @Override
+    public HhOmcDeviceTemplateVo templateDetail(Long deviceTemplateId) {
+        HhOmcDeviceTemplate deviceTemplate = hhOmcDeviceTemplateMapper.selectById(deviceTemplateId);
+        ClassUtil.throwBusinessException(ObjectUtil.isNull(deviceTemplate), "模版不存在");
+        ClassUtil.throwBusinessException(deviceTemplate.getIsDeleted(), "模版已删除");
+        HhOmcDeviceTemplateVo templateVo = BeanUtil.copyProperties(deviceTemplate, HhOmcDeviceTemplateVo.class);
+        templateVo.setDeviceTemplateId(deviceTemplate.getId());
+        return templateVo;
+    }
+
+    @Override
+    public RestResult<Boolean> add(HhOmcDeviceDto dto) {
+        if (dto.getSn() == null) {
+            return RestResult.error("参数有误");
+        }
+
+        if (checkSn(dto)) { //校验设备是否存在
+            if (dto.getId() != null) {
+                return RestResult.error("数据不存在或已删除");
+            }
+            return RestResult.error("设备已存在");
+        }
+
+        HhOmcDevice device = null;
+        if (dto.getId() != null) {
+            device = hhOmcDeviceMapper.selectById(dto.getId());
+            if (device == null || device.getIsDeleted() == null || device.getIsDeleted()) {
+                return RestResult.error("数据不存在或已删除");
+            }
+        } else {
+            device = new HhOmcDevice();
+            device.setStatus(Boolean.TRUE);
+            device.setCreateTime(new Date());
+            device.setVersion(1);
+            device.setIsDeleted(Boolean.FALSE);
+            device.setFirstAuthTime(new Date());
+        }
+        //处理参数
+        handleParams(device, dto);
+        if (dto.getId() != null) {
+            hhOmcDeviceMapper.updateById(device);
+        } else {
+            hhOmcDeviceMapper.insert(device);
+        }
+        return RestResult.ok(Boolean.TRUE);
+    }
+
+    private void handleParams(HhOmcDevice device, HhOmcDeviceDto dto) {
+        BeanUtil.copyProperties(dto, device);
+        //购买方
+        if (Preconditions.isNotBlank(dto.getPurchaserId())) {
+            Purchaser purchaser = purchaserMapper.selectById(dto.getPurchaserId());
+            ClassUtil.throwBusinessException(ObjectUtil.isNull(purchaser), "购买方不存在");
+            ClassUtil.throwBusinessException(ObjectUtil.isNull(purchaser.getIsDeleted()), "购买方已删除");
+            device.setPurchaserId(purchaser.getId());
+        }
+        //应用类型
+        if (Preconditions.isNotBlank(dto.getApplicationTypeId())) {
+            ApplicationType applicationType = applicationTypeMapper.selectById(dto.getApplicationTypeId());
+            ClassUtil.throwBusinessException(ObjectUtil.isNull(applicationType), "应用类型不存在");
+            ClassUtil.throwBusinessException(ObjectUtil.isNull(applicationType.getIsDeleted()), "购买方已删除");
+            device.setApplicationTypeId(applicationType.getId());
+        }
+        //设备类型(硬件)
+        if (Preconditions.isNotBlank(dto.getDeviceModelHardwareId())) {
+            DeviceModel deviceModelHardware = deviceModelMapper.selectById(dto.getDeviceModelHardwareId());
+            ClassUtil.throwBusinessException(ObjectUtil.isNull(deviceModelHardware), "设备类型(硬件)不存在");
+            ClassUtil.throwBusinessException(ObjectUtil.isNull(deviceModelHardware.getIsDeleted()), "设备类型(硬件)已删除");
+            device.setDeviceModelHardwareId(deviceModelHardware.getId());
+        }
+        //设备类型(环境)
+        if (Preconditions.isNotBlank(dto.getDeviceModelEnvironmentId())) {
+            DeviceModel deviceModelEnvironment = deviceModelMapper.selectById(dto.getDeviceModelEnvironmentId());
+            ClassUtil.throwBusinessException(ObjectUtil.isNull(deviceModelEnvironment), RestCode.FAIL.getCode(), "设备类型(环境)不存在");
+            ClassUtil.throwBusinessException(ObjectUtil.isNull(deviceModelEnvironment.getIsDeleted()), RestCode.FAIL.getCode(), "设备类型(环境)已删除");
+            device.setDeviceModelEnvironmentId(deviceModelEnvironment.getId());
+
+        }
+        //系统类型
+        if (Preconditions.isNotBlank(dto.getSystemTypeCode())) {
+            SystemTypeEnum systemTypeEnum = SystemTypeEnum.getEnumByCode(dto.getSystemTypeCode());
+            ClassUtil.throwBusinessException(ObjectUtil.isNull(systemTypeEnum), RestCode.FAIL.getCode(), "系统类型不存在");
+            device.setSystemTypeCode(systemTypeEnum.getCode());
+        }
+        device.setUpdateTime(new Date());
+    }
+
+    private boolean checkSn(HhOmcDeviceDto dto) {
+        List<HhOmcDevice> devices = hhOmcDeviceMapper.selectList(Wrappers.lambdaQuery(HhOmcDevice.class).eq(HhOmcDevice::getSn, dto.getSn()).eq(HhOmcDevice::getIsDeleted, Boolean.FALSE));
+        if (devices != null && devices.size() > 0) {
+            if (dto.getId() == null) {
+                return Boolean.TRUE;
+            } else {
+                List<Long> ids = devices.stream().map(HhOmcDevice::getId).collect(Collectors.toList());
+                if (!ids.contains(dto.getId())) {
+                    return Boolean.TRUE;
+                }
+            }
+        }
+        return Boolean.FALSE;
+    }
+
+    @Override
+    public RestResult<IPage<HhOmcDeviceVo>> page(HhOmcDeviceSearch dto) {
+        LambdaQueryWrapper<HhOmcDevice> wrapper = this.getDeviceWrapper(dto);
+        Page<HhOmcDevice> page = new Page<>(dto.getPageNumber(), dto.getPageSize());
+        IPage<HhOmcDevice> iPage = hhOmcDeviceMapper.selectPage(page, wrapper);
+
+        Map<Long, Purchaser> purchaserMap = commonImpl.getPurchaserMap(iPage, HhOmcDevice::getPurchaserId);
+        Map<Long, ApplicationType> applicationTypeMap = commonImpl.getApplicationTypeMap(iPage, HhOmcDevice::getApplicationTypeId);
+        Map<Long, DeviceModel> deviceModelHardwareMap = commonImpl.getDeviceModelMap(iPage, HhOmcDevice::getDeviceModelHardwareId);
+        Map<Long, DeviceModel> deviceModelEnvironmentMap = commonImpl.getDeviceModelMap(iPage, HhOmcDevice::getDeviceModelEnvironmentId);
+
+        IPage<HhOmcDeviceVo> convert = iPage.convert(t -> {
+            HhOmcDeviceVo item = BeanUtil.copyProperties(t, HhOmcDeviceVo.class);
+            if (purchaserMap.containsKey(t.getPurchaserId())) {
+                item.setCompanyName(purchaserMap.get(t.getPurchaserId()).getCompanyName());
+            }
+            if (applicationTypeMap.containsKey(t.getApplicationTypeId())) {
+                item.setApplicationType(applicationTypeMap.get(t.getApplicationTypeId()).getApplicationType());
+            }
+            if (deviceModelHardwareMap.containsKey(t.getDeviceModelHardwareId())) {
+                item.setDeviceModelHardware(deviceModelHardwareMap.get(t.getDeviceModelHardwareId()).getDeviceModel());
+            }
+            if (deviceModelEnvironmentMap.containsKey(t.getDeviceModelEnvironmentId())) {
+                item.setDeviceModelEnvironment(deviceModelEnvironmentMap.get(t.getDeviceModelEnvironmentId()).getDeviceModel());
+            }
+            SystemTypeEnum systemTypeEnum = SystemTypeEnum.getEnumByCode(t.getSystemTypeCode());
+            if (ObjectUtil.isNotNull(systemTypeEnum)) {
+                item.setSystemType(systemTypeEnum.getDesc());
+            }
+            return item;
+        });
+        return RestResult.ok(convert);
+    }
+
+    private LambdaQueryWrapper<HhOmcDevice> getDeviceWrapper(HhOmcDeviceSearch dto) {
+        LambdaQueryWrapper<HhOmcDevice> wrapper = new LambdaQueryWrapper<>();
+        //查询的传参条件
+        wrapper.like(StrUtil.isNotBlank(dto.getSn()), HhOmcDevice::getSn, dto.getSn());
+        wrapper.eq(ObjectUtil.isNotNull(dto.getPurchaserId()), HhOmcDevice::getPurchaserId, dto.getPurchaserId());
+        wrapper.eq(ObjectUtil.isNotNull(dto.getApplicationTypeId()), HhOmcDevice::getApplicationTypeId, dto.getApplicationTypeId());
+        wrapper.eq(ObjectUtil.isNotNull(dto.getDeviceModelHardwareId()), HhOmcDevice::getDeviceModelHardwareId, dto.getDeviceModelHardwareId());
+        wrapper.eq(ObjectUtil.isNotNull(dto.getDeviceModelEnvironmentId()), HhOmcDevice::getDeviceModelEnvironmentId, dto.getDeviceModelEnvironmentId());
+        wrapper.eq(ObjectUtil.isNotNull(dto.getSystemTypeCode()), HhOmcDevice::getSystemTypeCode, dto.getSystemTypeCode());
+        wrapper.eq(ObjectUtil.isNotNull(dto.getStatus()), HhOmcDevice::getStatus, dto.getStatus());
+        //基础条件
+        wrapper.eq(HhOmcDevice::getIsDeleted, Boolean.FALSE);
+        wrapper.orderByDesc(HhOmcDevice::getId);
+        return wrapper;
+    }
+
+    @Override
+    public RestResult<List<String>> snlist() {
+        List<HhOmcDevice> devices = hhOmcDeviceMapper.selectList(Wrappers.lambdaQuery(HhOmcDevice.class).select(HhOmcDevice::getSn).eq(HhOmcDevice::getStatus, Boolean.TRUE).eq(HhOmcDevice::getIsDeleted, Boolean.FALSE));
+        List<String> sns = devices.stream().map(HhOmcDevice::getSn).collect(Collectors.toList());
+        return RestResult.ok(sns == null || sns.isEmpty() ? Collections.emptyList() : sns);
+    }
+
+    @Override
+    public RestResult<Boolean> del(Long deviceId) {
+        HhOmcDevice device = hhOmcDeviceMapper.selectById(deviceId);
+        if (device != null && device.getIsDeleted() != null && !device.getIsDeleted()) {
+            hhOmcDeviceMapper.deleteById(device);
+        }
+        return RestResult.ok(Boolean.TRUE);
+    }
+
+    @Override
+    public RestResult<Boolean> opeDeviceAuth(Long deviceId, Boolean enableflag) {
+        HhOmcDevice device = hhOmcDeviceMapper.selectById(deviceId);
+        if (device != null && !device.getIsDeleted()) {
+            device.setStatus(enableflag);
+            device.setUpdateTime(new Date());
+            hhOmcDeviceMapper.updateById(device);
+        }
+        return RestResult.ok(Boolean.TRUE);
+    }
+
+    @Override
+    public RestResult<HhOmcDeviceVo> queryConfig(TenantDto dto) {
+        List<HhOmcDevice> devices = hhOmcDeviceMapper.selectList(Wrappers.lambdaQuery(HhOmcDevice.class).eq(HhOmcDevice::getStatus, Boolean.TRUE).eq(HhOmcDevice::getSn, dto.getSn()).eq(HhOmcDevice::getIsDeleted, Boolean.FALSE));
+        if (devices == null || devices.size() == 0) {
+            return RestResult.error("设备商户平台未授权");
+        }
+        HhOmcDeviceVo vo = BeanUtil.copyProperties(devices, HhOmcDeviceVo.class);
+        return RestResult.ok(vo != null ? completeOthers(vo) : null);
+    }
+
+    private HhOmcDeviceVo completeOthers(HhOmcDeviceVo vo) {
+        List<HhOmcDeviceVo> vos = Arrays.asList(vo);
+        Map<Long, Purchaser> purchaserMap = commonImpl.getPurchaserMap(vos, HhOmcDeviceVo::getPurchaserId);
+        Map<Long, ApplicationType> applicationTypeMap = commonImpl.getApplicationTypeMap(vos, HhOmcDeviceVo::getApplicationTypeId);
+        Map<Long, DeviceModel> deviceModelHardwareMap = commonImpl.getDeviceModelMap(vos, HhOmcDeviceVo::getDeviceModelHardwareId);
+        Map<Long, DeviceModel> deviceModelEnvironmentMap = commonImpl.getDeviceModelMap(vos, HhOmcDeviceVo::getDeviceModelEnvironmentId);
+        if (purchaserMap.containsKey(vo.getPurchaserId())) {
+            vo.setCompanyName(purchaserMap.get(vo.getPurchaserId()).getCompanyName());
+        }
+        if (applicationTypeMap.containsKey(vo.getApplicationTypeId())) {
+            vo.setApplicationType(applicationTypeMap.get(vo.getApplicationTypeId()).getApplicationType());
+        }
+        if (deviceModelHardwareMap.containsKey(vo.getDeviceModelHardwareId())) {
+            vo.setDeviceModelHardware(deviceModelHardwareMap.get(vo.getDeviceModelHardwareId()).getDeviceModel());
+        }
+        if (deviceModelEnvironmentMap.containsKey(vo.getDeviceModelEnvironmentId())) {
+            vo.setDeviceModelEnvironment(deviceModelEnvironmentMap.get(vo.getDeviceModelEnvironmentId()).getDeviceModel());
+        }
+        SystemTypeEnum systemTypeEnum = SystemTypeEnum.getEnumByCode(vo.getSystemTypeCode());
+        if (ObjectUtil.isNotNull(systemTypeEnum)) {
+            vo.setSystemType(systemTypeEnum.getDesc());
+        }
+        return vo;
+    }
+}