#update
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -8,6 +8,7 @@ target/
|
|||||||
.idea/modules.xml
|
.idea/modules.xml
|
||||||
.idea/jarRepositories.xml
|
.idea/jarRepositories.xml
|
||||||
.idea/compiler.xml
|
.idea/compiler.xml
|
||||||
|
.idea/workspace.xml
|
||||||
.idea/libraries/
|
.idea/libraries/
|
||||||
*.iws
|
*.iws
|
||||||
*.iml
|
*.iml
|
||||||
@@ -41,4 +42,5 @@ build/
|
|||||||
/logs
|
/logs
|
||||||
.idea/*
|
.idea/*
|
||||||
|
|
||||||
|
|
||||||
*.log
|
*.log
|
||||||
@@ -3,37 +3,20 @@ package com.maibu.web.controller.system;
|
|||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.maibu.annotation.Log;
|
import com.maibu.annotation.Log;
|
||||||
import com.maibu.core.business.Device;
|
import com.maibu.core.business.DeviceModel;
|
||||||
import com.maibu.core.business.DeviceModel;import com.maibu.core.business.DeviceRunStatistics;
|
|
||||||
import com.maibu.core.controller.BaseController;
|
import com.maibu.core.controller.BaseController;
|
||||||
import com.maibu.core.domain.AjaxResult;
|
import com.maibu.core.domain.AjaxResult;
|
||||||
import com.maibu.core.enums.ConnectType;
|
import com.maibu.core.enums.ConnectType;
|
||||||
import com.maibu.core.page.TableDataInfo;
|
import com.maibu.core.page.TableDataInfo;
|
||||||
import com.maibu.enums.BusinessType;
|
import com.maibu.enums.BusinessType;
|
||||||
import com.maibu.mapper.DeviceRunStatisticsMapper;
|
import com.maibu.service.impl.SysDeviceModelService;
|
||||||
import com.maibu.mybatis.LambdaQueryWrapperX;
|
|
||||||
import com.maibu.service.IDeviceService;
|
|
||||||
import com.maibu.service.SysDeviceModelService;
|
|
||||||
import com.maibu.utils.ServletUtils;
|
import com.maibu.utils.ServletUtils;
|
||||||
import com.maibu.utils.StringUtils;
|
|
||||||
import com.maibu.utils.poi.ExcelUtil;
|
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
|
||||||
import org.apache.poi.ss.usermodel.Sheet;
|
|
||||||
import org.apache.poi.ss.usermodel.Workbook;
|
|
||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|||||||
@@ -1,25 +1,19 @@
|
|||||||
package com.maibu.web.controller.system;
|
package com.maibu.web.controller.system;
|
||||||
|
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.maibu.core.business.IoTCommonDevice;
|
import com.maibu.core.business.IoTCommonDevice;
|
||||||
import com.maibu.core.business.Product;
|
|
||||||
import com.maibu.core.business.dto.DeviceConfigDTO;
|
import com.maibu.core.business.dto.DeviceConfigDTO;
|
||||||
import com.maibu.core.business.dto.ProductDTO;
|
|
||||||
import com.maibu.core.controller.BaseController;
|
import com.maibu.core.controller.BaseController;
|
||||||
import com.maibu.core.domain.AjaxResult;
|
import com.maibu.core.domain.AjaxResult;
|
||||||
import com.maibu.core.page.TableDataInfo;
|
import com.maibu.core.page.TableDataInfo;
|
||||||
import com.maibu.memory.GlobalMemory;
|
import com.maibu.memory.GlobalMemory;
|
||||||
import com.maibu.service.DeviceProductService;
|
import com.maibu.service.impl.IotDeviceCommonService;
|
||||||
import com.maibu.service.IotDeviceCommonService;
|
|
||||||
import com.maibu.utils.ServletUtils;
|
import com.maibu.utils.ServletUtils;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -84,10 +78,11 @@ public class SysIotCommDeviceController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 删除设备
|
* 删除设备
|
||||||
*/
|
*/
|
||||||
@DeleteMapping("/{id}")
|
@PostMapping("/delete")
|
||||||
@ApiOperation("删除设备")
|
@ApiOperation("删除设备")
|
||||||
public AjaxResult remove(@PathVariable Long id) {
|
public AjaxResult remove(@RequestBody List<Long> ids) {
|
||||||
return toAjax(deviceService.removeById(id) ? 1 : 0);
|
deviceService.removeByIds(ids);
|
||||||
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -119,4 +114,5 @@ public class SysIotCommDeviceController extends BaseController {
|
|||||||
return AjaxResult.success("缓存更新成功");
|
return AjaxResult.success("缓存更新成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,16 @@
|
|||||||
package com.maibu.web.controller.system;
|
package com.maibu.web.controller.system;
|
||||||
|
|
||||||
import cn.hutool.core.convert.Convert;
|
|
||||||
import com.maibu.core.business.DeviceModel;
|
|
||||||
import com.maibu.core.business.Product;
|
import com.maibu.core.business.Product;
|
||||||
import com.maibu.core.business.dto.ProductDTO;
|
import com.maibu.core.business.dto.ProductDTO;
|
||||||
import com.maibu.core.controller.BaseController;
|
import com.maibu.core.controller.BaseController;
|
||||||
import com.maibu.core.domain.AjaxResult;
|
import com.maibu.core.domain.AjaxResult;
|
||||||
import com.maibu.core.page.TableDataInfo;
|
import com.maibu.core.page.TableDataInfo;
|
||||||
import com.maibu.service.DeviceProductService;
|
import com.maibu.service.impl.DeviceProductService;
|
||||||
import com.maibu.service.SysDeviceModelService;
|
|
||||||
import com.maibu.utils.ServletUtils;
|
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,92 +30,30 @@ public class SysProductController extends BaseController {
|
|||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@ApiOperation("查询产品列表")
|
@ApiOperation("查询产品列表")
|
||||||
public TableDataInfo list(ProductDTO productDTO) {
|
public TableDataInfo list(ProductDTO productDTO) {
|
||||||
Integer pageNum = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
|
List<Product> resultPage = productService.selectProductPage(productDTO);
|
||||||
Integer pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
|
return getDataTable(resultPage);
|
||||||
|
|
||||||
Page<Product> page = new Page<>(pageNum, pageSize);
|
|
||||||
|
|
||||||
// DTO 转 Entity 用于查询筛选
|
|
||||||
Product product = new Product();
|
|
||||||
BeanUtils.copyProperties(productDTO, product);
|
|
||||||
|
|
||||||
Page<Product> resultPage = productService.selectProductPage(page, product);
|
|
||||||
return getDataTable(resultPage.getRecords(), resultPage.getTotal());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增产品
|
* 新增产品/修改
|
||||||
*/
|
*/
|
||||||
//@PreAuthorize("@ss.hasPermi('iot:product:add')")
|
//@PreAuthorize("@ss.hasPermi('iot:product:add')")
|
||||||
@PostMapping("/add")
|
@PostMapping("/save")
|
||||||
@ApiOperation("新增产品")
|
@ApiOperation("新增产品")
|
||||||
public AjaxResult add(@RequestBody ProductDTO productDTO) {
|
public AjaxResult add(@RequestBody Product product) {
|
||||||
if (productDTO.getName() == null || productDTO.getName().isEmpty()) {
|
return AjaxResult.success(productService.save(product));
|
||||||
return AjaxResult.error("产品名称不能为空");
|
|
||||||
}
|
|
||||||
if (productDTO.getCode() == null || productDTO.getCode().isEmpty()) {
|
|
||||||
return AjaxResult.error("产品编码不能为空");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查编码是否重复
|
|
||||||
Product existProduct = productService.selectByCode(productDTO.getCode());
|
|
||||||
if (existProduct != null) {
|
|
||||||
return AjaxResult.error("产品编码已存在");
|
|
||||||
}
|
|
||||||
|
|
||||||
// DTO 转 Entity
|
|
||||||
Product product = new Product();
|
|
||||||
BeanUtils.copyProperties(productDTO, product);
|
|
||||||
product.setCreateTime(LocalDateTime.now());
|
|
||||||
product.setDelFlag(false);
|
|
||||||
|
|
||||||
boolean success = productService.save(product);
|
|
||||||
return toAjax(success ? 1 : 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改产品
|
|
||||||
*/
|
|
||||||
@PostMapping("/update")
|
|
||||||
@ApiOperation("修改产品")
|
|
||||||
public AjaxResult edit(@RequestBody ProductDTO productDTO) {
|
|
||||||
if (productDTO.getId() == null) {
|
|
||||||
return AjaxResult.error("产品 ID 不能为空");
|
|
||||||
}
|
|
||||||
|
|
||||||
Product existProduct = productService.getById(productDTO.getId());
|
|
||||||
if (existProduct == null) {
|
|
||||||
return AjaxResult.error("产品不存在");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果修改了编码,检查是否重复
|
|
||||||
if (productDTO.getCode() != null && !productDTO.getCode().equals(existProduct.getCode())) {
|
|
||||||
Product duplicate = productService.selectByCode(productDTO.getCode());
|
|
||||||
if (duplicate != null) {
|
|
||||||
return AjaxResult.error("产品编码已存在");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// DTO 转 Entity
|
|
||||||
Product product = new Product();
|
|
||||||
BeanUtils.copyProperties(productDTO, product);
|
|
||||||
product.setUpdateTime(LocalDateTime.now());
|
|
||||||
|
|
||||||
boolean success = productService.updateById(product);
|
|
||||||
return toAjax(success ? 1 : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除产品
|
* 删除产品
|
||||||
*/
|
*/
|
||||||
//@PreAuthorize("@ss.hasPermi('iot:product:remove')")
|
//@PreAuthorize("@ss.hasPermi('iot:product:remove')")
|
||||||
@DeleteMapping("delete/{id}")
|
@PostMapping("delete")
|
||||||
@ApiOperation("删除产品")
|
@ApiOperation("删除产品")
|
||||||
public AjaxResult remove(@PathVariable Long id) {
|
public AjaxResult remove(@RequestBody List<Long> ids) {
|
||||||
boolean success = productService.removeById(id);
|
return AjaxResult.success(productService.removeByIds(ids));
|
||||||
return toAjax(success ? 1 : 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,6 +102,11 @@ public class DeviceTask {
|
|||||||
return builder(FastBeeConstant.TASK.DEVICE_TASK_HANDLER);
|
return builder(FastBeeConstant.TASK.DEVICE_TASK_HANDLER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean(FastBeeConstant.TASK.COMMON_DEVICE_MONITOR)
|
||||||
|
public Executor commonDeviceMonitor() {
|
||||||
|
return builder(FastBeeConstant.TASK.COMMON_DEVICE_MONITOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*组装线程池*/
|
/*组装线程池*/
|
||||||
private ThreadPoolTaskExecutor builder(String threadNamePrefix) {
|
private ThreadPoolTaskExecutor builder(String threadNamePrefix) {
|
||||||
|
|||||||
@@ -105,6 +105,11 @@ public interface FastBeeConstant {
|
|||||||
*/
|
*/
|
||||||
String DEVICE_TASK_HANDLER = "deviceTaskHandler";
|
String DEVICE_TASK_HANDLER = "deviceTaskHandler";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 其他设备接入 数据状态
|
||||||
|
*/
|
||||||
|
String COMMON_DEVICE_MONITOR = "commonDeviceMonitor";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MQTT {
|
interface MQTT {
|
||||||
|
|||||||
@@ -3,49 +3,40 @@ package com.maibu.core.business.dto;
|
|||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.maibu.core.domain.BaseEntity;
|
||||||
import com.maibu.core.business.ProductInterface;
|
|
||||||
import com.maibu.core.domain.BaseDO;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class ProductDTO extends BaseDO {
|
public class ProductDTO extends BaseEntity {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@TableId(type = IdType.AUTO)
|
@TableId(type = IdType.AUTO)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
private String code;
|
private String code;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private String manufacturer;
|
private String manufacturer;
|
||||||
|
|
||||||
private Long categoryId;
|
private Long categoryId;
|
||||||
|
|
||||||
private String protocolCode;
|
private String protocolCode;
|
||||||
|
|
||||||
private String transport;
|
private String transport;
|
||||||
|
|
||||||
private String uploadTopic;
|
private String uploadTopic;
|
||||||
|
|
||||||
private String subscribeTopic;
|
|
||||||
|
|
||||||
private Integer status;
|
|
||||||
|
|
||||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
|
||||||
private Map<String, Object> thingsModels;
|
|
||||||
|
|
||||||
|
private String subscribeTopic;
|
||||||
|
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||||
|
private Map<String, Object> thingsModels;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,12 +56,36 @@ public class SiteMemory {
|
|||||||
deviceMap.put(device.getSerialNumber(), device);
|
deviceMap.put(device.getSerialNumber(), device);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeDevice(String deviceId) {
|
public void removeDevice(String deviceId) {
|
||||||
if (!StringUtils.isEmpty(deviceId)) {
|
if (!StringUtils.isEmpty(deviceId)) {
|
||||||
deviceMap.remove(deviceId);
|
deviceMap.remove(deviceId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void saveCommonDevice(IoTCommonDevice device) {
|
||||||
|
commonDeviceMap.put(device.getSn(), device);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IoTCommonDevice getCommonDevice(String sn) {
|
||||||
|
if (!StringUtils.isEmpty(sn)) {
|
||||||
|
return commonDeviceMap.get(sn);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<IoTCommonDevice> getAllCommonDevice() {
|
||||||
|
if (!CollectionUtils.isEmpty(commonDeviceMap)) {
|
||||||
|
return (List<IoTCommonDevice>) commonDeviceMap.values();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeCommonDevice(String sn) {
|
||||||
|
if (!StringUtils.isEmpty(sn)) {
|
||||||
|
commonDeviceMap.remove(sn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void saveDeviceRunParam(DeviceRunParam deviceRunParam) {
|
public void saveDeviceRunParam(DeviceRunParam deviceRunParam) {
|
||||||
deviceRunParamMap.put(deviceRunParam.getDeviceId(), deviceRunParam);
|
deviceRunParamMap.put(deviceRunParam.getDeviceId(), deviceRunParam);
|
||||||
}
|
}
|
||||||
@@ -90,7 +114,7 @@ public class SiteMemory {
|
|||||||
// 替换已存在的记录,兼容后续保存
|
// 替换已存在的记录,兼容后续保存
|
||||||
int index = -1;
|
int index = -1;
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
if (Objects.equals(list.get(i).getErrorCode(), errorIdentificationStandard.getErrorCode())){
|
if (Objects.equals(list.get(i).getErrorCode(), errorIdentificationStandard.getErrorCode())) {
|
||||||
index = i;
|
index = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import java.util.concurrent.Executor;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import com.maibu.service.impl.IotDeviceCommonService;
|
||||||
import org.eclipse.paho.client.mqttv3.MqttException;
|
import org.eclipse.paho.client.mqttv3.MqttException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.ApplicationArguments;
|
import org.springframework.boot.ApplicationArguments;
|
||||||
@@ -49,6 +50,9 @@ public class InitThread implements ApplicationRunner {
|
|||||||
@Resource(name = FastBeeConstant.TASK.DEVICE_ERROR_MONITOR)
|
@Resource(name = FastBeeConstant.TASK.DEVICE_ERROR_MONITOR)
|
||||||
private Executor deviceErrorMonitorExecutor;
|
private Executor deviceErrorMonitorExecutor;
|
||||||
|
|
||||||
|
@Resource(name = FastBeeConstant.TASK.COMMON_DEVICE_MONITOR)
|
||||||
|
private Executor commonDeviceMonitorExecutor;
|
||||||
|
|
||||||
@Resource(name = FastBeeConstant.TASK.DEVICE_TASK_HANDLER)
|
@Resource(name = FastBeeConstant.TASK.DEVICE_TASK_HANDLER)
|
||||||
private Executor deviceTaskHandlerExecutor;
|
private Executor deviceTaskHandlerExecutor;
|
||||||
|
|
||||||
@@ -76,6 +80,9 @@ public class InitThread implements ApplicationRunner {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private AlarmOrderConfigMapper alarmOrderConfigMapper;
|
private AlarmOrderConfigMapper alarmOrderConfigMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IotDeviceCommonService commonService;
|
||||||
|
|
||||||
@Value("${influxdb.url}")
|
@Value("${influxdb.url}")
|
||||||
private String influxDBUrl;
|
private String influxDBUrl;
|
||||||
|
|
||||||
@@ -138,6 +145,9 @@ public class InitThread implements ApplicationRunner {
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
commonDeviceMonitorExecutor.execute(() -> {
|
||||||
|
commonService.commonDeviceMonitor();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,18 +1,13 @@
|
|||||||
package com.maibu.mapper;
|
package com.maibu.mapper;
|
||||||
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.maibu.core.business.Product;
|
import com.maibu.core.business.Product;
|
||||||
|
import com.maibu.mybatis.mapper.BaseMapperX;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jsmbz
|
|
||||||
* @description 针对表【device_product(产品表)】的数据库操作Mapper
|
|
||||||
* @createDate 2026-05-08 13:45:57
|
|
||||||
* @Entity abbc.domain.DeviceProduct
|
|
||||||
*/
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface DeviceProductMapper extends BaseMapper<Product> {
|
public interface DeviceProductMapper extends BaseMapperX<Product> {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,10 @@
|
|||||||
package com.maibu.mapper;
|
package com.maibu.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.maibu.core.business.IoTCommonDevice;
|
import com.maibu.core.business.IoTCommonDevice;
|
||||||
|
import com.maibu.mybatis.mapper.BaseMapperX;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jsmbz
|
public interface IotDeviceCommonMapper extends BaseMapperX<IoTCommonDevice> {
|
||||||
* @description 针对表【iot_device_common(通用设备表)】的数据库操作Mapper
|
|
||||||
* @createDate 2026-05-09 14:38:50
|
|
||||||
* @Entity abbc.domain.IotDeviceCommon
|
|
||||||
*/
|
|
||||||
public interface IotDeviceCommonMapper extends BaseMapper<IoTCommonDevice> {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.maibu.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.maibu.core.business.ProductInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jsmbz
|
|
||||||
* @description 针对表【device_product_interface(产品接口表)】的数据库操作Service
|
|
||||||
* @createDate 2026-05-08 15:37:53
|
|
||||||
*/
|
|
||||||
public interface DeviceProductInterfaceService extends IService<ProductInterface> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
package com.maibu.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.maibu.core.business.Product;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
/**
|
|
||||||
* @author jsmbz
|
|
||||||
* @description 针对表【device_product(产品表)】的数据库操作Service
|
|
||||||
* @createDate 2026-05-08 13:45:57
|
|
||||||
*/
|
|
||||||
public interface DeviceProductService extends IService<Product> {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页查询产品列表
|
|
||||||
*/
|
|
||||||
Page<Product> selectProductPage(Page<Product> page, Product product);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据编码查询产品
|
|
||||||
*/
|
|
||||||
Product selectByCode(String code);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增产品(含接口表入库)
|
|
||||||
*/
|
|
||||||
boolean insertProduct(Product product);
|
|
||||||
/**
|
|
||||||
* 修改产品(含接口表入库)
|
|
||||||
*/
|
|
||||||
boolean updateProduct(Product product);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
package com.maibu.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.maibu.core.business.IoTCommonDevice;
|
|
||||||
import com.maibu.core.business.dto.DeviceConfigDTO;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jsmbz
|
|
||||||
* @description 针对表【iot_device_common(通用设备表)】的数据库操作Service
|
|
||||||
* @createDate 2026-05-09 14:38:50
|
|
||||||
*/
|
|
||||||
public interface IotDeviceCommonService extends IService<IoTCommonDevice> {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设备录入:连接测试成功后放入未注册缓存
|
|
||||||
*/
|
|
||||||
void addDeviceToUnRegisterCache(DeviceConfigDTO deviceDTO) throws Exception;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询未注册设备列表
|
|
||||||
*/
|
|
||||||
List<IoTCommonDevice> getUnRegisterDevices();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页查询已注册设备列表
|
|
||||||
*/
|
|
||||||
Page<IoTCommonDevice> selectDevicePage(Page<IoTCommonDevice> page, IoTCommonDevice device);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据 SN 查询设备
|
|
||||||
*/
|
|
||||||
IoTCommonDevice getBySn(String sn);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从未注册缓存注册到组织/场站,并落库
|
|
||||||
*/
|
|
||||||
void registerDevice(Long deviceId, Long orgId, Long siteId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编辑设备
|
|
||||||
* @param deviceDTO
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
|
|
||||||
boolean updateDevice(DeviceConfigDTO deviceDTO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param sn
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
IoTCommonDevice getFromUnRegisterCache(String sn);
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param cacheDevice
|
|
||||||
*/
|
|
||||||
void updateUnRegisterCache(IoTCommonDevice cacheDevice);
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.maibu.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.maibu.core.business.DeviceAction;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jsmbz
|
|
||||||
* @description 针对表【iot_device_action(设备动作定义表)】的数据库操作Service
|
|
||||||
* @createDate 2026-05-07 12:33:48
|
|
||||||
*/
|
|
||||||
public interface SysDeviceActionService extends IService<DeviceAction> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
package com.maibu.service;
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
package com.maibu.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.maibu.core.business.DeviceModel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jsmbz
|
|
||||||
* @description 针对表【iot_device_model(设备模型表)】的数据库操作Service
|
|
||||||
* @createDate 2026-05-07 11:36:11
|
|
||||||
*/
|
|
||||||
public interface SysDeviceModelService {
|
|
||||||
/**
|
|
||||||
* 新增设备模型
|
|
||||||
*
|
|
||||||
* @param deviceModel
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
int insertDeviceModel(DeviceModel deviceModel);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页查询设备模型列表
|
|
||||||
*
|
|
||||||
* @param page 分页对象
|
|
||||||
* @param deviceModel 查询条件
|
|
||||||
* @return 分页结果
|
|
||||||
*/
|
|
||||||
Page<DeviceModel> selectDeviceModelPage(Page<DeviceModel> page, DeviceModel deviceModel);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* selectDeviceModelById
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
DeviceModel selectDeviceModelById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* updateDeviceModel
|
|
||||||
*
|
|
||||||
* @param deviceModel
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
int updateDeviceModel(DeviceModel deviceModel);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除(逻辑删除模型)
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
int deleteDeviceModelById(Long id);
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package com.maibu.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.maibu.core.business.DeviceModelProperty;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jsmbz
|
|
||||||
* @description 针对表【iot_device_property(设备属性定义表)】的数据库操作Service
|
|
||||||
* @createDate 2026-05-07 12:33:48
|
|
||||||
*/
|
|
||||||
public interface SysDevicePropertyService extends IService<DeviceModelProperty> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<DeviceModelProperty> selectByModelId(Long id);
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.maibu.service.impl;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class DeviceProductInterfaceService {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.maibu.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.maibu.core.business.ProductInterface;
|
|
||||||
import com.maibu.mapper.DeviceProductInterfaceMapper;
|
|
||||||
import com.maibu.service.DeviceProductInterfaceService;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jsmbz
|
|
||||||
* @description 针对表【device_product_interface(产品接口表)】的数据库操作Service实现
|
|
||||||
* @createDate 2026-05-08 15:37:53
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class DeviceProductInterfaceServiceImpl extends ServiceImpl<DeviceProductInterfaceMapper, ProductInterface>
|
|
||||||
implements DeviceProductInterfaceService {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -2,14 +2,12 @@ package com.maibu.service.impl;
|
|||||||
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.maibu.core.business.Product;
|
import com.maibu.core.business.Product;
|
||||||
import com.maibu.core.business.ProductInterface;
|
import com.maibu.core.business.ProductInterface;
|
||||||
|
import com.maibu.core.business.dto.ProductDTO;
|
||||||
import com.maibu.exception.ServiceException;
|
import com.maibu.exception.ServiceException;
|
||||||
import com.maibu.mapper.DeviceProductInterfaceMapper;
|
import com.maibu.mapper.DeviceProductInterfaceMapper;
|
||||||
import com.maibu.mapper.DeviceProductMapper;
|
import com.maibu.mapper.DeviceProductMapper;
|
||||||
import com.maibu.service.DeviceProductService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -28,8 +26,7 @@ import java.util.stream.Collectors;
|
|||||||
* @createDate 2026-05-08 13:45:57
|
* @createDate 2026-05-08 13:45:57
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class DeviceProductServiceImpl extends ServiceImpl<DeviceProductMapper, Product>
|
public class DeviceProductService {
|
||||||
implements DeviceProductService {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -41,8 +38,12 @@ public class DeviceProductServiceImpl extends ServiceImpl<DeviceProductMapper, P
|
|||||||
@Autowired
|
@Autowired
|
||||||
private DeviceProductMapper productMapper;
|
private DeviceProductMapper productMapper;
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<Product> selectProductPage(Page<Product> page, Product product) {
|
public boolean save(Product product){
|
||||||
|
return productMapper.saveOrUpdate(product);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Product> selectProductPage(ProductDTO product) {
|
||||||
LambdaQueryWrapper<Product> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<Product> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
// 精确查询产品编码
|
// 精确查询产品编码
|
||||||
@@ -57,7 +58,7 @@ public class DeviceProductServiceImpl extends ServiceImpl<DeviceProductMapper, P
|
|||||||
|
|
||||||
// 精确查询厂商
|
// 精确查询厂商
|
||||||
if (StringUtils.hasText(product.getManufacturer())) {
|
if (StringUtils.hasText(product.getManufacturer())) {
|
||||||
wrapper.eq(Product::getManufacturer, product.getManufacturer());
|
wrapper.like(Product::getManufacturer, product.getManufacturer());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 精确查询分类ID
|
// 精确查询分类ID
|
||||||
@@ -86,20 +87,20 @@ public class DeviceProductServiceImpl extends ServiceImpl<DeviceProductMapper, P
|
|||||||
// 按创建时间倒序
|
// 按创建时间倒序
|
||||||
wrapper.orderByDesc(Product::getCreateTime);
|
wrapper.orderByDesc(Product::getCreateTime);
|
||||||
|
|
||||||
return this.page(page, wrapper);
|
return productMapper.selectList(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Product selectByCode(String code) {
|
public Product selectByCode(String code) {
|
||||||
LambdaQueryWrapper<Product> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<Product> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(Product::getCode, code)
|
wrapper.eq(Product::getCode, code)
|
||||||
.eq(Product::getDelFlag, 0);
|
.eq(Product::getDelFlag, 0);
|
||||||
return this.getOne(wrapper);
|
return productMapper.selectOne(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public boolean insertProduct(Product product) {
|
public boolean insertProduct(Product product) {
|
||||||
// 1. 插入产品主表
|
// 1. 插入产品主表
|
||||||
@@ -108,7 +109,7 @@ public class DeviceProductServiceImpl extends ServiceImpl<DeviceProductMapper, P
|
|||||||
product.setDelFlag(false);
|
product.setDelFlag(false);
|
||||||
product.setStatus(1); // 默认启用
|
product.setStatus(1); // 默认启用
|
||||||
|
|
||||||
int rows = this.baseMapper.insert(product);
|
int rows = productMapper.insert(product);
|
||||||
if (rows <= 0) {
|
if (rows <= 0) {
|
||||||
throw new ServiceException("产品创建失败");
|
throw new ServiceException("产品创建失败");
|
||||||
}
|
}
|
||||||
@@ -130,7 +131,7 @@ public class DeviceProductServiceImpl extends ServiceImpl<DeviceProductMapper, P
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public boolean updateProduct(Product product) {
|
public boolean updateProduct(Product product) {
|
||||||
// 1. 更新产品主表
|
// 1. 更新产品主表
|
||||||
@@ -198,4 +199,10 @@ public class DeviceProductServiceImpl extends ServiceImpl<DeviceProductMapper, P
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int removeByIds(List<Long> ids) {
|
||||||
|
if (CollectionUtils.isEmpty(ids)) return 0;
|
||||||
|
return productMapper.deleteBatchIds(ids);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,16 +2,17 @@ package com.maibu.service.impl;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.maibu.core.business.IoTCommonDevice;
|
import com.maibu.core.business.IoTCommonDevice;
|
||||||
import com.maibu.core.business.dto.DeviceConfigDTO;
|
import com.maibu.core.business.dto.DeviceConfigDTO;
|
||||||
|
import com.maibu.core.enums.ConnectType;
|
||||||
import com.maibu.mapper.IotDeviceCommonMapper;
|
import com.maibu.mapper.IotDeviceCommonMapper;
|
||||||
import com.maibu.memory.GlobalMemory;
|
import com.maibu.memory.GlobalMemory;
|
||||||
import com.maibu.service.IotDeviceCommonService;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -24,11 +25,12 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class IotDeviceCommonServiceImpl extends ServiceImpl<IotDeviceCommonMapper, IoTCommonDevice>
|
public class IotDeviceCommonService {
|
||||||
implements IotDeviceCommonService {
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Autowired
|
||||||
|
private IotDeviceCommonMapper iotDeviceCommonMapper;
|
||||||
|
|
||||||
public void addDeviceToUnRegisterCache(DeviceConfigDTO deviceDTO) throws Exception {
|
public void addDeviceToUnRegisterCache(DeviceConfigDTO deviceDTO) throws Exception {
|
||||||
// 1. 检查 SN 是否已存在(缓存 + 数据库)
|
// 1. 检查 SN 是否已存在(缓存 + 数据库)
|
||||||
if (GlobalMemory.unRegisterCommonDeviceMap.containsKey(deviceDTO.getSn())) {
|
if (GlobalMemory.unRegisterCommonDeviceMap.containsKey(deviceDTO.getSn())) {
|
||||||
@@ -64,12 +66,12 @@ public class IotDeviceCommonServiceImpl extends ServiceImpl<IotDeviceCommonMappe
|
|||||||
log.info("设备 {} 已加入未注册缓存", deviceDTO.getSn());
|
log.info("设备 {} 已加入未注册缓存", deviceDTO.getSn());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IoTCommonDevice> getUnRegisterDevices() {
|
public List<IoTCommonDevice> getUnRegisterDevices() {
|
||||||
return new ArrayList<>(GlobalMemory.unRegisterCommonDeviceMap.values());
|
return new ArrayList<>(GlobalMemory.unRegisterCommonDeviceMap.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<IoTCommonDevice> selectDevicePage(Page<IoTCommonDevice> page, IoTCommonDevice device) {
|
public Page<IoTCommonDevice> selectDevicePage(Page<IoTCommonDevice> page, IoTCommonDevice device) {
|
||||||
LambdaQueryWrapper<IoTCommonDevice> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<IoTCommonDevice> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
@@ -88,18 +90,18 @@ public class IotDeviceCommonServiceImpl extends ServiceImpl<IotDeviceCommonMappe
|
|||||||
wrapper.eq(IoTCommonDevice::getDelFlag, false);
|
wrapper.eq(IoTCommonDevice::getDelFlag, false);
|
||||||
wrapper.orderByDesc(IoTCommonDevice::getCreateTime);
|
wrapper.orderByDesc(IoTCommonDevice::getCreateTime);
|
||||||
|
|
||||||
return this.page(page, wrapper);
|
return iotDeviceCommonMapper.selectPage(page, wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public IoTCommonDevice getBySn(String sn) {
|
public IoTCommonDevice getBySn(String sn) {
|
||||||
LambdaQueryWrapper<IoTCommonDevice> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<IoTCommonDevice> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(IoTCommonDevice::getDeviceId, sn)
|
wrapper.eq(IoTCommonDevice::getDeviceId, sn)
|
||||||
.eq(IoTCommonDevice::getDelFlag, false);
|
.eq(IoTCommonDevice::getDelFlag, false);
|
||||||
return this.getOne(wrapper);
|
return iotDeviceCommonMapper.selectOne(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void registerDevice(Long deviceId, Long orgId, Long siteId) {
|
public void registerDevice(Long deviceId, Long orgId, Long siteId) {
|
||||||
// TODO: 从未注册缓存取出设备,绑定组织/场站,落库
|
// TODO: 从未注册缓存取出设备,绑定组织/场站,落库
|
||||||
@@ -107,12 +109,10 @@ public class IotDeviceCommonServiceImpl extends ServiceImpl<IotDeviceCommonMappe
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public boolean updateDevice(DeviceConfigDTO deviceDTO) {
|
public boolean updateDevice(DeviceConfigDTO deviceDTO) {
|
||||||
// 1. 查询设备是否存在
|
// 1. 查询设备是否存在
|
||||||
IoTCommonDevice existDevice = this.getById(deviceDTO.getId());
|
IoTCommonDevice existDevice = iotDeviceCommonMapper.selectById(deviceDTO.getId());
|
||||||
if (existDevice == null) {
|
if (existDevice == null) {
|
||||||
throw new RuntimeException("设备不存在");
|
throw new RuntimeException("设备不存在");
|
||||||
}
|
}
|
||||||
@@ -142,23 +142,10 @@ public class IotDeviceCommonServiceImpl extends ServiceImpl<IotDeviceCommonMappe
|
|||||||
BeanUtils.copyProperties(deviceDTO, device);
|
BeanUtils.copyProperties(deviceDTO, device);
|
||||||
device.setUpdateTime(LocalDateTime.now());
|
device.setUpdateTime(LocalDateTime.now());
|
||||||
|
|
||||||
return this.updateById(device);
|
return iotDeviceCommonMapper.saveOrUpdate(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备连接测试(根据协议类型)
|
* 设备连接测试(根据协议类型)
|
||||||
*/
|
*/
|
||||||
@@ -179,13 +166,11 @@ public class IotDeviceCommonServiceImpl extends ServiceImpl<IotDeviceCommonMappe
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IoTCommonDevice getFromUnRegisterCache(String sn) {
|
public IoTCommonDevice getFromUnRegisterCache(String sn) {
|
||||||
return GlobalMemory.unRegisterCommonDeviceMap.get(sn);
|
return GlobalMemory.unRegisterCommonDeviceMap.get(sn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateUnRegisterCache(IoTCommonDevice device) {
|
public void updateUnRegisterCache(IoTCommonDevice device) {
|
||||||
if (device.getDeviceId() == null) {
|
if (device.getDeviceId() == null) {
|
||||||
throw new RuntimeException("设备 ID (SN) 不能为空");
|
throw new RuntimeException("设备 ID (SN) 不能为空");
|
||||||
@@ -196,8 +181,6 @@ public class IotDeviceCommonServiceImpl extends ServiceImpl<IotDeviceCommonMappe
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MQTT 连接测试
|
* MQTT 连接测试
|
||||||
*/
|
*/
|
||||||
@@ -240,5 +223,26 @@ public class IotDeviceCommonServiceImpl extends ServiceImpl<IotDeviceCommonMappe
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void removeByIds(List<Long> ids) {
|
||||||
|
if (CollectionUtils.isEmpty(ids)) return;
|
||||||
|
iotDeviceCommonMapper.deleteBatchIds(ids);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void commonDeviceMonitor() {
|
||||||
|
//先初始化 外部设备连接
|
||||||
|
GlobalMemory.getAllSiteMemory().forEach(x -> {
|
||||||
|
List<IoTCommonDevice> list = x.getAllCommonDevice();
|
||||||
|
if (!CollectionUtils.isEmpty(list)) {
|
||||||
|
list.forEach(y -> {
|
||||||
|
if (ConnectType.MQTT.equals(y.getConnectType())) {
|
||||||
|
String ip = y.getNetworkIp();
|
||||||
|
Integer port = y.getPort();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,10 @@
|
|||||||
package com.maibu.service.impl;
|
package com.maibu.service.impl;
|
||||||
|
|
||||||
import com.maibu.annotation.DataSource;
|
|
||||||
import com.maibu.constant.CacheConstants;
|
import com.maibu.constant.CacheConstants;
|
||||||
import com.maibu.constant.UserConstants;
|
import com.maibu.constant.UserConstants;
|
||||||
import com.maibu.core.redis.RedisCache;
|
import com.maibu.core.redis.RedisCache;
|
||||||
import com.maibu.core.text.Convert;
|
import com.maibu.core.text.Convert;
|
||||||
import com.maibu.domain.SysConfig;
|
import com.maibu.domain.SysConfig;
|
||||||
import com.maibu.enums.DataSourceType;
|
|
||||||
import com.maibu.exception.ServiceException;
|
import com.maibu.exception.ServiceException;
|
||||||
import com.maibu.mapper.SysConfigMapper;
|
import com.maibu.mapper.SysConfigMapper;
|
||||||
import com.maibu.service.ISysConfigService;
|
import com.maibu.service.ISysConfigService;
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
package com.maibu.service.impl;
|
||||||
@@ -1 +0,0 @@
|
|||||||
package com.maibu.service.impl;
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.maibu.service.impl;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jsmbz
|
||||||
|
* @description 针对表【iot_device_model_property_mapping(设备模型属性映射表)】的数据库操作Service实现
|
||||||
|
* @createDate 2026-05-07 12:33:48
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SysDeviceModelPropertyMappingService {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.maibu.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.maibu.core.business.DeviceModelPropertyMapping;
|
|
||||||
import com.maibu.mapper.SysDeviceModelPropertyMappingMapper;
|
|
||||||
import com.maibu.service.SysDeviceModelPropertyMappingService;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jsmbz
|
|
||||||
* @description 针对表【iot_device_model_property_mapping(设备模型属性映射表)】的数据库操作Service实现
|
|
||||||
* @createDate 2026-05-07 12:33:48
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class SysDeviceModelPropertyMappingServiceImpl extends ServiceImpl<SysDeviceModelPropertyMappingMapper, DeviceModelPropertyMapping>
|
|
||||||
implements SysDeviceModelPropertyMappingService {
|
|
||||||
|
|
||||||
}
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
|||||||
|
package com.maibu.service.impl;
|
||||||
@@ -1 +0,0 @@
|
|||||||
package com.maibu.service.impl;
|
|
||||||
Reference in New Issue
Block a user