Explorar el Código

设备维护代码部分提交

jingyuanchao hace 11 meses
padre
commit
f8ce68a116

+ 21 - 0
project_data/sql/1.0.11/soc.sql

@@ -84,6 +84,16 @@ BEGIN
                 ADD COLUMN `enable` int(11) NULL DEFAULT 0 COMMENT '0:启用,1:禁用' AFTER `update_by`;
         end if;
 
+    IF NOT EXISTS(SELECT *
+                  FROM information_schema.columns
+                  WHERE table_schema = DATABASE()
+                    AND table_name = 'iot_device_info'
+                    AND column_name = 'sync_status') THEN
+        ALTER TABLE `iot_device_info`
+            ADD COLUMN `sync_status` int(0) NULL DEFAULT 0 COMMENT '下发状态;0未下发,1下发中,2下发成功,3下发失败' AFTER `enable`;
+        update iot_device_info set sync_status = 2;
+    end if;
+
 
         IF NOT EXISTS(SELECT *
                       FROM information_schema.columns
@@ -122,6 +132,17 @@ BEGIN
 
 
 
+
+
     END ??
 DELIMITER ;
 CALL schema_change();
+
+-- 新增设备同步状态字典
+delete from sys_dict_type where dict_type='sync_status';
+delete from sys_dict_data where dict_type='sync_status';
+INSERT INTO sys_dict_type(`dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ('设备同步状态', 'sync_status', '0', '超级管理员', '2024-11-13 16:21:39', '', NULL, NULL);
+INSERT INTO sys_dict_data(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ( 0, '未下发', '9', 'sync_status', NULL, 'default', 'N', '0', '超级管理员', '2024-11-13 16:22:05', '', NULL, NULL);
+INSERT INTO sys_dict_data(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ( 1, '下发中', '1', 'sync_status', NULL, 'default', 'N', '0', '超级管理员', '2024-11-13 16:22:18', '', NULL, NULL);
+INSERT INTO sys_dict_data(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ( 2, '下发成功', '2', 'sync_status', NULL, 'default', 'N', '0', '超级管理员', '2024-11-13 16:22:52', '', NULL, NULL);
+INSERT INTO sys_dict_data(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ( 3, '下发失败', '3', 'sync_status', NULL, 'default', 'N', '0', '超级管理员', '2024-11-13 16:23:01', '', NULL, NULL);

+ 3 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/iot/domain/IotServerProduct.java

@@ -40,5 +40,8 @@ public class IotServerProduct implements Serializable {
     @TableField("categories")
     private String categories;
 
+    @TableField("models")
+    private String Models;
+
 
 }

+ 6 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/controller/IotDeviceInfoController.java

@@ -35,5 +35,11 @@ public class IotDeviceInfoController {
         return AjaxResult.success(deviceInfoService.getAlarmHostDetail(id));
     }
 
+    @ApiOperation("根据设备类型获取产品名称")
+    @GetMapping({"/getProductDisplayName/{type}"})
+    AjaxResult getProductDisplayName(@PathVariable String type) {
+        return AjaxResult.success(deviceInfoService.getProductDisplayName(type));
+    }
+
 
 }

+ 16 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/mapper/IotServerProductMapper.java

@@ -0,0 +1,16 @@
+package com.xunmei.iot.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.xunmei.common.core.domain.iot.domain.IotServerProduct;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author jingYuanChao
+ * @since 2024-09-19
+ */
+public interface IotServerProductMapper extends BaseMapper<IotServerProduct> {
+
+}

+ 3 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/IIotDeviceInfoService.java

@@ -1,6 +1,7 @@
 package com.xunmei.iot.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.xunmei.common.core.domain.iot.domain.IotServerProduct;
 import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.iot.dto.deviceInfo.IotDeviceInfoPageDto;
 import com.xunmei.iot.vo.deviceInfo.DeviceDetailInfoVo;
@@ -23,4 +24,6 @@ public interface IIotDeviceInfoService extends IService<IotDeviceInfo> {
     IotDeviceInfo selectDevice(String iotCode, String deviceProduct, String deviceCode);
 
     List<DeviceDetailInfoVo> getByProductTypesAndOrgId(List<String> productTypes,Long orgId);
+
+    List<IotServerProduct> getProductDisplayName(String type);
 }

+ 22 - 9
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotDeviceInfoServiceImpl.java

@@ -6,12 +6,14 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.xunmei.common.core.constant.Constants;
 import com.xunmei.common.core.constant.SecurityConstants;
+import com.xunmei.common.core.domain.iot.domain.IotServerProduct;
 import com.xunmei.common.core.enums.iot.BaseDeviceTypeEnum;
 import com.xunmei.common.core.utils.StringUtils;
 import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.iot.dto.deviceInfo.IotDeviceInfoPageDto;
 import com.xunmei.iot.mapper.IotAlarmSubsystemMapper;
 import com.xunmei.iot.mapper.IotDeviceInfoMapper;
+import com.xunmei.iot.mapper.IotServerProductMapper;
 import com.xunmei.iot.service.IIotDeviceInfoService;
 import com.xunmei.iot.vo.deviceInfo.DeviceDetailInfoVo;
 import com.xunmei.iot.vo.deviceInfo.IotDeviceInfoPageVo;
@@ -19,6 +21,7 @@ import com.xunmei.system.api.RemoteOrgService;
 import com.xunmei.system.api.domain.SysOrg;
 import com.xunmei.system.api.domain.iot.IotDeviceInfo;
 import org.springframework.stereotype.Service;
+
 import javax.annotation.Resource;
 import java.io.Serializable;
 import java.util.List;
@@ -31,18 +34,21 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
     @Resource
     private IotAlarmSubsystemMapper subsystemMapper;
 
+    @Resource
+    private IotServerProductMapper productMapper;
+
     @Override
     public TableDataInfo<IotDeviceInfoPageVo> deviceInfoPage(IotDeviceInfoPageDto request) {
         if (request.getCheckSub()) {
             SysOrg sysOrg = orgService.selectOrgById(request.getOrgId(), SecurityConstants.INNER);
             request.setOrgPath(sysOrg.getPath());
         }
-        if (StringUtils.isNotEmpty(request.getDeviceType())){
+        if (StringUtils.isNotEmpty(request.getDeviceType())) {
             request.setDeviceTypeList(null);
         }
         Page<IotDeviceInfoPageVo> page = baseMapper.selectDeviceInfoPage(request.getPageRequest(), request);
         List<IotDeviceInfoPageVo> records = page.getRecords();
-        if (records != null && records.size() > 0){
+        if (records != null && records.size() > 0) {
             for (IotDeviceInfoPageVo record : records) {
                 record.setDeviceTypeName(BaseDeviceTypeEnum.getDescByCode(record.getDeviceType()));
             }
@@ -53,18 +59,18 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
     @Override
     public DeviceDetailInfoVo getDetail(Serializable id) {
         DeviceDetailInfoVo detailInfoVo = baseMapper.getDetailById(id);
-        if (detailInfoVo != null){
+        if (detailInfoVo != null) {
             detailInfoVo.setDeviceTypeName(BaseDeviceTypeEnum.getDescByCode(detailInfoVo.getDeviceType()));
             //动环主机和dvs有子设备(门禁主机和对讲主机无子设备)
-            if (ObjectUtil.equal(BaseDeviceTypeEnum.Dvs.getCode(),detailInfoVo.getDeviceType())
-                    || ObjectUtil.equal(BaseDeviceTypeEnum.FSU.getCode(),detailInfoVo.getDeviceType())){
+            if (ObjectUtil.equal(BaseDeviceTypeEnum.Dvs.getCode(), detailInfoVo.getDeviceType())
+                    || ObjectUtil.equal(BaseDeviceTypeEnum.FSU.getCode(), detailInfoVo.getDeviceType())) {
                 String deviceProduct = null;
                 //监控主机需要查询deviceProduct
-                if (ObjectUtil.equal(BaseDeviceTypeEnum.Dvs.getCode(),detailInfoVo.getDeviceType())){
+                if (ObjectUtil.equal(BaseDeviceTypeEnum.Dvs.getCode(), detailInfoVo.getDeviceType())) {
                     deviceProduct = detailInfoVo.getDeviceProduct();
                 }
                 List<DeviceDetailInfoVo> infoList = baseMapper.getChildrenInfoList(deviceProduct, detailInfoVo.getIotToken(), detailInfoVo.getDeviceCode());
-                if (infoList !=null && infoList.size() > 0){
+                if (infoList != null && infoList.size() > 0) {
                     for (DeviceDetailInfoVo infoVo : infoList) {
                         infoVo.setDeviceTypeName(BaseDeviceTypeEnum.getDescByCode(infoVo.getDeviceType()));
                     }
@@ -78,7 +84,7 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
     @Override
     public DeviceDetailInfoVo getAlarmHostDetail(Serializable id) {
         DeviceDetailInfoVo detailInfoVo = baseMapper.getDetailById(id);
-        if (detailInfoVo != null){
+        if (detailInfoVo != null) {
             detailInfoVo.setDeviceTypeName(BaseDeviceTypeEnum.getDescByCode(detailInfoVo.getDeviceType()));
             //查询报警控制器列表(报警子系统)
             List<DeviceDetailInfoVo> list = subsystemMapper.getByDeviceCodeAndIotToken(detailInfoVo.getDeviceCode(), detailInfoVo.getIotToken());
@@ -104,6 +110,13 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
 
     @Override
     public List<DeviceDetailInfoVo> getByProductTypesAndOrgId(List<String> productTypes, Long orgId) {
-        return baseMapper.getByProductTypesAndOrgId(productTypes,orgId);
+        return baseMapper.getByProductTypesAndOrgId(productTypes, orgId);
+    }
+
+    @Override
+    public List<IotServerProduct> getProductDisplayName(String type) {
+        final LambdaQueryWrapper<IotServerProduct> wrapper = new LambdaQueryWrapper<>();
+        wrapper.like(IotServerProduct::getName, type);
+        return productMapper.selectList(wrapper);
     }
 }