Sfoglia il codice sorgente

设备新增运管资源ID,站点省份改为模糊查询

Co-authored-by: Cursor <cursoragent@cursor.com>
fuyuchuan 6 giorni fa
parent
commit
a463e328fc

+ 5 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppDevice.java

@@ -42,6 +42,11 @@ public class VppDevice implements Serializable {
     private LocalDateTime lastOnlineAt;
     @TableField("gateway_id")
     private String gatewayId;
+    /**
+     * 运管资源ID,全局唯一
+     */
+    @TableField("un_resource_id")
+    private String unResourceId;
     private String remark;
     @TableField("tenant_id")
     private Integer tenantId;

+ 7 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/impl/VppDeviceServiceImpl.java

@@ -172,6 +172,9 @@ public class VppDeviceServiceImpl implements VppDeviceService {
         if (params.get("deviceType") != null) {
             wrapper.eq(VppDevice::getDeviceType, params.get("deviceType").toString());
         }
+        if (params.get("unResourceId") != null && StringUtils.hasText(params.get("unResourceId").toString())) {
+            wrapper.eq(VppDevice::getUnResourceId, params.get("unResourceId").toString().trim());
+        }
         applyRunStatusFilter(wrapper, params);
         return wrapper;
     }
@@ -228,6 +231,9 @@ public class VppDeviceServiceImpl implements VppDeviceService {
             throw new BusinessException("设备名称不能为空");
         }
         ensureUniqueField(VppDevice::getDeviceCode, request.getDeviceCode(), excludeId, "设备编号已存在");
+        if (StringUtils.hasText(request.getUnResourceId())) {
+            ensureUniqueField(VppDevice::getUnResourceId, request.getUnResourceId().trim(), excludeId, "运管资源ID已存在");
+        }
     }
 
     private void ensureUniqueField(com.baomidou.mybatisplus.core.toolkit.support.SFunction<VppDevice, ?> field,
@@ -252,6 +258,7 @@ public class VppDeviceServiceImpl implements VppDeviceService {
         device.setRatedPowerKw(request.getRatedPowerKw());
         device.setFirmwareVersion(request.getFirmwareVersion());
         device.setGatewayId(request.getGatewayId());
+        device.setUnResourceId(StringUtils.hasText(request.getUnResourceId()) ? request.getUnResourceId().trim() : null);
         device.setRemark(request.getRemark());
     }
 

+ 2 - 2
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/impl/VppSiteServiceImpl.java

@@ -171,8 +171,8 @@ public class VppSiteServiceImpl implements VppSiteService {
             if (params.get("siteCode") != null) {
                 wrapper.eq(VppSite::getSiteCode, params.get("siteCode").toString());
             }
-            if (params.get("province") != null) {
-                wrapper.eq(VppSite::getProvince, params.get("province").toString());
+            if (params.get("province") != null && StringUtils.hasText(params.get("province").toString())) {
+                wrapper.like(VppSite::getProvince, params.get("province").toString());
             }
             if (params.get("city") != null) {
                 wrapper.eq(VppSite::getCity, params.get("city").toString());

+ 4 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/vo/DeviceRequest.java

@@ -20,6 +20,10 @@ public class DeviceRequest {
     private Integer runStatus;
     private String firmwareVersion;
     private String gatewayId;
+    /**
+     * 运管资源ID,全局唯一
+     */
+    private String unResourceId;
     private String remark;
 
     private String productCode;

+ 6 - 0
service-vpp/service-vpp-biz/src/main/resources/sql/vpp_schema.sql

@@ -224,6 +224,7 @@ CREATE TABLE `vpp_device` (
     `firmware_version` VARCHAR(50) NULL COMMENT '固件版本',
     `last_online_at` DATETIME(3) NULL COMMENT '最后在线时间',
     `gateway_id` VARCHAR(64) NULL COMMENT 'IoT网关标识',
+    `un_resource_id` VARCHAR(64) NULL COMMENT '运管资源ID',
     `remark` VARCHAR(500) NULL COMMENT '备注',
     `tenant_id` INT NULL COMMENT '租户ID',
     `create_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
@@ -234,6 +235,7 @@ CREATE TABLE `vpp_device` (
     `deleted_at` DATETIME(3) NULL COMMENT '软删除时间',
     PRIMARY KEY (`id`),
     UNIQUE KEY `uk_device_code` (device_code),
+    UNIQUE KEY `uk_device_un_resource_id` (`un_resource_id`),
     KEY `idx_device_uuid` (device_uuid),
     KEY `idx_device_site` (site_id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='设备';
@@ -768,3 +770,7 @@ CREATE TABLE `vpp_bidding_config` (
     KEY `idx_bidding_config_effective` (effective_start, effective_end),
     KEY `idx_bidding_config_name` (config_name)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='竞价配置';
+
+-- 已有库升级:设备表新增运管资源ID(全局唯一,NULL 不参与唯一冲突)
+-- ALTER TABLE `vpp_device` ADD COLUMN `un_resource_id` VARCHAR(64) NULL COMMENT '运管资源ID' AFTER `gateway_id`;
+-- ALTER TABLE `vpp_device` ADD UNIQUE KEY `uk_device_un_resource_id` (`un_resource_id`);