diff --git a/intc-admin/src/main/java/com/intc/IntcUltraApplication.java b/intc-admin/src/main/java/com/intc/IntcUltraApplication.java index 2479cb9..65688eb 100644 --- a/intc-admin/src/main/java/com/intc/IntcUltraApplication.java +++ b/intc-admin/src/main/java/com/intc/IntcUltraApplication.java @@ -3,6 +3,7 @@ package com.intc; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup; +import org.springframework.scheduling.annotation.EnableScheduling; /** * 启动程序 @@ -11,6 +12,7 @@ import org.springframework.boot.context.metrics.buffering.BufferingApplicationSt */ @SpringBootApplication +@EnableScheduling public class IntcUltraApplication { public static void main(String[] args) { diff --git a/intc-admin/src/main/resources/application-dev.yml b/intc-admin/src/main/resources/application-dev.yml index 7f1baa1..d75435f 100644 --- a/intc-admin/src/main/resources/application-dev.yml +++ b/intc-admin/src/main/resources/application-dev.yml @@ -224,6 +224,19 @@ aliyun: app-key: 334224397 # App Secret app-secret: 70de3018ec39423e9ca1e1b6a6a84ad6 + # VMS 语音通知配置 + vms: + # 是否启用 MNS 回扇消费(true 时自动启动 MNS 消费线程接收 VMS 回扇) + mns-enabled: true + # VMS 语音服务对应的 AccessKey ID(如果与上面 IoT 平台的 AK 相同可不填) + access-key-id: LTAI5tKh6fEKJJESaTdnChkh + # VMS 语音服务对应的 AccessKey Secret + access-key-secret: 6oa6t91ReT2YYSp3puuLA4FYtOyqDo + # MNS 账号 Endpoint(格式:https://{AccountId}.mns.cn-hangzhou.aliyuncs.com/) + # 在阿里云控制台 > 语音服务 > 回扇配置 中查看对应的 MNS Endpoint + endpoint: https://1943695596114318.mns.cn-hangzhou.aliyuncs.com/ + # MNS 队列名称(保持默认即可) + queue-name: Alicom-Queue-1572610294777992-VoiceReport # AMQP 服务端订阅配置(使用数据同步的 AppKey + AppSecret) amqp: # 是否启用 diff --git a/intc-modules/intc-iot/pom.xml b/intc-modules/intc-iot/pom.xml index b37a80a..15c8e07 100644 --- a/intc-modules/intc-iot/pom.xml +++ b/intc-modules/intc-iot/pom.xml @@ -60,13 +60,33 @@ 1.1.9.2 - + + + javax.xml.bind + jaxb-api + 2.3.1 + + + + com.sun.xml.bind + jaxb-impl + 2.3.9 + + + com.aliyun aliyun-java-sdk-dyvmsapi 1.1.0 + + + com.aliyun + aliyun-java-sdk-dybaseapi + 1.1.1 + + com.squareup.okhttp3 diff --git a/intc-modules/intc-iot/src/main/java/com/intc/iot/config/AliyunIotProperties.java b/intc-modules/intc-iot/src/main/java/com/intc/iot/config/AliyunIotProperties.java index a1b4888..ee54dd9 100644 --- a/intc-modules/intc-iot/src/main/java/com/intc/iot/config/AliyunIotProperties.java +++ b/intc-modules/intc-iot/src/main/java/com/intc/iot/config/AliyunIotProperties.java @@ -47,6 +47,16 @@ public class AliyunIotProperties { */ private String categoryKey; + /** + * VMS 语音通知 TTS 模板编码 + */ + private String vmsTtsCode; + + /** + * VMS 语音通知主叫显号 + */ + private String vmsShowNumber; + /** * MQTT 配置(可选,用于设备直连) */ @@ -57,6 +67,40 @@ public class AliyunIotProperties { */ private AmqpConfig amqp = new AmqpConfig(); + /** + * VMS MNS 回执消费配置 + */ + private VmsMnsConfig vms = new VmsMnsConfig(); + + @Data + public static class VmsMnsConfig { + /** + * 是否启用 MNS 回扇消费 + */ + private Boolean mnsEnabled = false; + + /** + * MNS AccessKey ID(语音服务对应账号的 AK,可能与 IoT 平台不同) + */ + private String accessKeyId; + + /** + * MNS AccessKey Secret + */ + private String accessKeySecret; + + /** + * MNS 账号内网 Endpoint + * 示例:https://{AccountId}.mns.cn-hangzhou.aliyuncs.com/ + */ + private String endpoint; + + /** + * MNS 队列名称 + */ + private String queueName = "Alicom-Queue-1572610294777992-VoiceReport"; + } + @Data public static class MqttConfig { /** diff --git a/intc-modules/intc-iot/src/main/java/com/intc/iot/controller/IotController.java b/intc-modules/intc-iot/src/main/java/com/intc/iot/controller/IotController.java index e5abc90..6053d93 100644 --- a/intc-modules/intc-iot/src/main/java/com/intc/iot/controller/IotController.java +++ b/intc-modules/intc-iot/src/main/java/com/intc/iot/controller/IotController.java @@ -38,6 +38,7 @@ import com.intc.iot.service.IotDeviceService; import com.intc.iot.service.MqttService; import com.intc.iot.service.VmsMnsConsumerService; import com.intc.iot.service.VmsNoticeService; +import com.intc.iot.handler.DeviceDataHandler; import com.intc.iot.service.WarnCallNoticeService; import com.intc.iot.utils.AliyunAmqpSignUtil; import com.intc.iot.utils.ControllerHelper; @@ -95,6 +96,9 @@ public class IotController extends BaseController { @Autowired(required = false) private WarnCallNoticeService warnCallNoticeService; + @Autowired(required = false) + private DeviceDataHandler deviceDataHandler; + @Autowired(required = false) private javax.jms.Connection amqpConnection; @@ -588,6 +592,66 @@ public class IotController extends BaseController { } } + // ======================== 模拟报警触发接口 ======================== + + /** + * 模拟设备数据上报,触发报警和打电话流程。 + * 接口会伪造一条 MQTT 属性上报消息,携带你指定的传感器值, + * 走完整的「数据解析 → 阈值判断 → 告警记录 → VMS语音呼叫」链路。 + * + * @param deviceName 设备序列号(需在数据库中存在,且已配置手机号和告警阈值) + * @param dissolvedOxygen 溶解氧值(mg/L),不传则使用默认值 1.0(低于通常阈值,触发告警) + * @param temperature 水温值(°C),不传则不设置 + * @param battery 电量(%),不传则不设置 + */ + @Operation(summary = "模拟告警触发(测试打电话)", + description = "构造超阈值传感器数据,走完整告警→VMS语音呼叫链路") + @PostMapping("/alarm/simulate") + public R> simulateAlarm( + @Parameter(description = "设备序列号(serialNum)") @RequestParam String deviceName, + @Parameter(description = "溶解氧值,默认1.0触发低溶解氧告警") @RequestParam(required = false) Double dissolvedOxygen, + @Parameter(description = "水温值,可选") @RequestParam(required = false) Double temperature, + @Parameter(description = "电池电量%,可选") @RequestParam(required = false) Double battery) { + try { + if (deviceDataHandler == null) { + return R.fail("DeviceDataHandler 未启用(IDeviceSensorDataService 未加载)"); + } + + // 默认溶解氧给一个极低值,保证能触发告警 + double doValue = dissolvedOxygen != null ? dissolvedOxygen : 1.0; + + // 构造飞燕平台属性上报的标准 payload + // Topic 格式: /sys/{productKey}/{deviceName}/thing/event/property/post + // 这里 productKey 随便填一个非控制器的值,让它走普通传感器处理分支 + String mockProductKey = "simulate"; + String mockTopic = "/sys/" + mockProductKey + "/" + deviceName + "/thing/event/property/post"; + + // 构造 params JSON,字段数 > 3 以通过过滤条件 + cn.hutool.json.JSONObject params = new cn.hutool.json.JSONObject(); + params.set("dissolvedOxygen", doValue); + params.set("temperature", temperature != null ? temperature : 25.0); + params.set("battery", battery != null ? battery : 80.0); + params.set("saturability", 50.0); // 补足字段数 > 3 + + cn.hutool.json.JSONObject payload = new cn.hutool.json.JSONObject(); + payload.set("params", params); + + log.info("[模拟告警] deviceName={}, topic={}, payload={}", deviceName, mockTopic, payload); + + // 调用真实的属性处理方法,走完整链路 + deviceDataHandler.handlePropertyPost(mockTopic, payload.toString()); + + Map result = new java.util.HashMap<>(); + result.put("mockTopic", mockTopic); + result.put("mockPayload", payload.toString()); + result.put("message", "模拟消息已发送,请查看日志确认告警和呼叫是否触发"); + return R.ok(result); + } catch (Exception e) { + log.error("模拟告警触发失败: {}", e.getMessage(), e); + return R.fail("模拟告警触发失败: " + e.getMessage()); + } + } + // ======================== VMS 语音通知相关接口 ======================== @Operation(summary = "发送语音通知(测试接口)") diff --git a/intc-modules/intc-iot/src/main/java/com/intc/iot/domain/AquMapMessageWarnCallNotice.java b/intc-modules/intc-iot/src/main/java/com/intc/iot/domain/AquMapMessageWarnCallNotice.java new file mode 100644 index 0000000..5fcad8f --- /dev/null +++ b/intc-modules/intc-iot/src/main/java/com/intc/iot/domain/AquMapMessageWarnCallNotice.java @@ -0,0 +1,41 @@ +package com.intc.iot.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.intc.common.tenant.core.TenantEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serial; + +/** + * 报警消息与通知记录关联表 aqu_map_message_warn_call_notice + * + * @author intc + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("aqu_map_message_warn_call_notice") +public class AquMapMessageWarnCallNotice extends TenantEntity { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 主键ID + */ + @TableId(type = IdType.ASSIGN_ID) + private Long id; + + /** + * 报警消息ID(关联 aqu_message_warn.id) + */ + private Long messageWarnId; + + /** + * 通知记录ID(关联 aqu_call_notice.id) + */ + private Long callNoticeId; + +} diff --git a/intc-modules/intc-iot/src/main/java/com/intc/iot/domain/AquWarnCallNotice.java b/intc-modules/intc-iot/src/main/java/com/intc/iot/domain/AquWarnCallNotice.java index 8acdf65..325920e 100644 --- a/intc-modules/intc-iot/src/main/java/com/intc/iot/domain/AquWarnCallNotice.java +++ b/intc-modules/intc-iot/src/main/java/com/intc/iot/domain/AquWarnCallNotice.java @@ -3,27 +3,30 @@ package com.intc.iot.domain; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.intc.common.tenant.core.TenantEntity; import lombok.Data; +import lombok.EqualsAndHashCode; -import java.io.Serializable; +import java.io.Serial; import java.time.LocalDateTime; /** - * 告警电话通知记录 - * 对应 C# DbAquWarnCallNotice + * 告警电话通知记录 aqu_call_notice * - * @author intc-iot + * @author intc */ @Data +@EqualsAndHashCode(callSuper = true) @TableName("aqu_call_notice") -public class AquWarnCallNotice implements Serializable { +public class AquWarnCallNotice extends TenantEntity { + @Serial private static final long serialVersionUID = 1L; /** * 主键ID */ - @TableId(type = IdType.AUTO) + @TableId(type = IdType.ASSIGN_ID) private Long id; /** @@ -131,14 +134,4 @@ public class AquWarnCallNotice implements Serializable { */ private String tollType; - /** - * 创建时间 - */ - private LocalDateTime createdTime; - - /** - * 更新时间 - */ - private LocalDateTime updatedTime; - } diff --git a/intc-modules/intc-iot/src/main/java/com/intc/iot/handler/DeviceDataHandler.java b/intc-modules/intc-iot/src/main/java/com/intc/iot/handler/DeviceDataHandler.java index 57691c7..3f6346e 100644 --- a/intc-modules/intc-iot/src/main/java/com/intc/iot/handler/DeviceDataHandler.java +++ b/intc-modules/intc-iot/src/main/java/com/intc/iot/handler/DeviceDataHandler.java @@ -3,16 +3,22 @@ package com.intc.iot.handler; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; -import com.intc.iot.domain.AquAlarmHistory; +import com.intc.iot.domain.AquMapMessageWarnCallNotice; import com.intc.iot.domain.AquWarnCallNotice; import com.intc.iot.domain.VmsNoticeResponse; -import com.intc.iot.mapper.AquAlarmHistoryMapper; +import com.intc.iot.mapper.AquMapMessageWarnCallNoticeMapper; import com.intc.iot.mapper.AquWarnCallNoticeMapper; import com.intc.iot.mapper.IotDeviceMapper; import com.intc.iot.service.VmsNoticeService; +import com.intc.fishery.domain.AquUser; import com.intc.fishery.domain.Device; +import com.intc.fishery.domain.MessageWarn; +import com.intc.fishery.domain.Pond; +import com.intc.fishery.mapper.AquUserMapper; import com.intc.fishery.mapper.DeviceMapper; import com.intc.fishery.mapper.DeviceSwitchMapper; +import com.intc.fishery.mapper.MessageWarnMapper; +import com.intc.fishery.mapper.PondMapper; import com.intc.tdengine.domain.DeviceSensorData; import com.intc.tdengine.service.IDeviceSensorDataService; import lombok.RequiredArgsConstructor; @@ -49,10 +55,14 @@ public class DeviceDataHandler { private final AquWarnCallNoticeMapper warnCallNoticeMapper; /** - * 告警历史记录 Mapper + * 报警消息与通知记录关联 Mapper */ - private final AquAlarmHistoryMapper alarmHistoryMapper; + private final AquMapMessageWarnCallNoticeMapper mapMessageWarnCallNoticeMapper; + /** + * 报警消息 Mapper + */ + private final MessageWarnMapper messageWarnMapper; /** * 设备 Mapper @@ -64,6 +74,16 @@ public class DeviceDataHandler { */ private final DeviceSwitchMapper deviceSwitchMapper; + /** + * 用户 Mapper + */ + private final AquUserMapper aquUserMapper; + + /** + * 塘口 Mapper + */ + private final PondMapper pondMapper; + /** * VMS 语音通知服务 */ @@ -82,15 +102,7 @@ public class DeviceDataHandler { */ private static final int CALL_STATUS_NO_CALL = 0; - /** - * 告警状态:未处理 - */ - private static final int ALARM_STATUS_PENDING = 0; - /** - * 告警状态:已恢复 - */ - private static final int ALARM_STATUS_RECOVERED = 2; /** * 告警间隔时间(分钟)- 同一设备同一类型告警在此时间内不重复发送 @@ -98,7 +110,14 @@ public class DeviceDataHandler { private static final int ALARM_NOTIFICATION_INTERVAL = 30; /** - * 告警类型常量 + * 告警类型常量(对应 warn_type 字段) + */ + private static final int WARN_TYPE_DISSOLVED_OXYGEN = 2; // 溶解氧 + private static final int WARN_TYPE_TEMPERATURE = 2; // 温度 + private static final int WARN_TYPE_BATTERY = 2; // 电池电量 + + /** + * 告警类型名称 */ private static final String ALARM_TYPE_DISSOLVED_OXYGEN = "溶解氧"; private static final String ALARM_TYPE_TEMPERATURE = "温度"; @@ -111,6 +130,11 @@ public class DeviceDataHandler { private static final int ALARM_LEVEL_IMPORTANT = 2; // 重要 private static final int ALARM_LEVEL_URGENT = 3; // 紧急 + /** + * 消息未读状态 + */ + private static final int MSG_IS_READ_NO = 0; + /** * 处理设备属性上报数据 * @@ -190,10 +214,10 @@ public class DeviceDataHandler { } } // -// // 检查是否触发报警 -// if (params != null && sensorData != null) { -// checkAndTriggerAlarm(productKey, deviceName, sensorData); -// } + // 检查是否触发报警 + if (params != null && sensorData != null) { + checkAndTriggerAlarm(productKey, deviceName, sensorData); + } } catch (Exception e) { log.error("处理设备属性数据失败", e); @@ -313,9 +337,20 @@ public class DeviceDataHandler { } Long deviceId = device.getId(); + Long userId = device.getUserId(); + + // 查询塘口名称 + String pondName = null; + if (device.getPondId() != null) { + Pond pond = pondMapper.selectById(device.getPondId()); + if (pond != null) { + pondName = pond.getPondName(); + } + } + StringBuilder alarmMessage = new StringBuilder(); boolean hasAlarm = false; - java.util.List alarmList = new java.util.ArrayList<>(); + java.util.List warnList = new java.util.ArrayList<>(); // 1. 检查溶解氧(使用设备配置的阈值) if (sensorData.getDissolvedOxygen() != null && device.getOxyWarnCallOpen() != null && device.getOxyWarnCallOpen() == 1) { @@ -323,13 +358,12 @@ public class DeviceDataHandler { Double oxyWarnLower = device.getOxyWarnLower(); if (oxyWarnLower != null && dissolvedOxygen < oxyWarnLower) { - String content = String.format("溶解氧过低: %.2f mg/L (最低: %.2f)", + String message = String.format("溶解氧过低: %.2f mg/L (最低: %.2f)", dissolvedOxygen, oxyWarnLower); - alarmMessage.append(content).append("; "); + alarmMessage.append(message).append("; "); - AquAlarmHistory alarm = createAlarmHistory(deviceId, deviceName, ALARM_TYPE_DISSOLVED_OXYGEN, - ALARM_LEVEL_URGENT, content, dissolvedOxygen, oxyWarnLower); - alarmList.add(alarm); + warnList.add(createMessageWarn(deviceId, userId, pondName, + ALARM_TYPE_DISSOLVED_OXYGEN, WARN_TYPE_DISSOLVED_OXYGEN, message)); hasAlarm = true; } } @@ -341,22 +375,20 @@ public class DeviceDataHandler { Double tempWarnUpper = device.getTempWarnUpper(); if (tempWarnLower != null && temperature < tempWarnLower) { - String content = String.format("水温过低: %.2f °C (最低: %.2f)", + String message = String.format("水温过低: %.2f °C (最低: %.2f)", temperature, tempWarnLower); - alarmMessage.append(content).append("; "); + alarmMessage.append(message).append("; "); - AquAlarmHistory alarm = createAlarmHistory(deviceId, deviceName, ALARM_TYPE_TEMPERATURE, - ALARM_LEVEL_IMPORTANT, content, temperature, tempWarnLower); - alarmList.add(alarm); + warnList.add(createMessageWarn(deviceId, userId, pondName, + ALARM_TYPE_TEMPERATURE, WARN_TYPE_TEMPERATURE, message)); hasAlarm = true; } else if (tempWarnUpper != null && temperature > tempWarnUpper) { - String content = String.format("水温过高: %.2f °C (最高: %.2f)", + String message = String.format("水温过高: %.2f °C (最高: %.2f)", temperature, tempWarnUpper); - alarmMessage.append(content).append("; "); + alarmMessage.append(message).append("; "); - AquAlarmHistory alarm = createAlarmHistory(deviceId, deviceName, ALARM_TYPE_TEMPERATURE, - ALARM_LEVEL_IMPORTANT, content, temperature, tempWarnUpper); - alarmList.add(alarm); + warnList.add(createMessageWarn(deviceId, userId, pondName, + ALARM_TYPE_TEMPERATURE, WARN_TYPE_TEMPERATURE, message)); hasAlarm = true; } } @@ -367,36 +399,27 @@ public class DeviceDataHandler { Double batteryWarnLower = device.getBatteryWarnLower() != null ? device.getBatteryWarnLower().doubleValue() : null; if (batteryWarnLower != null && battery < batteryWarnLower) { - String content = String.format("电池电量低: %.2f%% (最低: %.2f%%)", + String message = String.format("电池电量低: %.2f%% (最低: %.2f%%)", battery, batteryWarnLower); - alarmMessage.append(content).append("; "); + alarmMessage.append(message).append("; "); - AquAlarmHistory alarm = createAlarmHistory(deviceId, deviceName, ALARM_TYPE_BATTERY, - ALARM_LEVEL_NORMAL, content, battery, batteryWarnLower); - alarmList.add(alarm); + warnList.add(createMessageWarn(deviceId, userId, pondName, + ALARM_TYPE_BATTERY, WARN_TYPE_BATTERY, message)); hasAlarm = true; } } - // 如果有告警,保存告警历史并触发通知 + // 如果有告警,保存报警消息并触发通知 if (hasAlarm) { log.warn("[告警] {} - {}", deviceName, alarmMessage); - // 保存告警历史 - for (AquAlarmHistory alarm : alarmList) { - alarmHistoryMapper.insert(alarm); + // 批量保存报警消息 + for (MessageWarn warn : warnList) { + messageWarnMapper.insert(warn); } - // 触发通知(只对紧急和重要告警发送通知) - boolean shouldNotify = alarmList.stream() - .anyMatch(alarm -> alarm.getAlarmLevel() >= ALARM_LEVEL_IMPORTANT); - - if (shouldNotify) { - triggerAlarmNotification(device, alarmMessage.toString(), sensorData, alarmList); - } - } else { - // 没有告警,检查是否有未恢复的告警需要标记为已恢复 - checkAndRecoverAlarms(deviceId, device, sensorData); + // 触发电话通知 + triggerAlarmNotification(device, alarmMessage.toString(), sensorData, warnList); } } catch (Exception e) { @@ -411,28 +434,28 @@ public class DeviceDataHandler { * @param device 设备信息 * @param alarmMessage 告警信息 * @param sensorData 传感器数据 - * @param alarmList 告警列表 + * @param warnList 报警消息列表 */ private void triggerAlarmNotification(Device device, String alarmMessage, - DeviceSensorData sensorData, java.util.List alarmList) { + DeviceSensorData sensorData, java.util.List warnList) { try { Long deviceId = device.getId(); String deviceName = device.getDeviceName(); // 检查设备的免打扰设置 boolean shouldSkip = false; - for (AquAlarmHistory alarm : alarmList) { - if (ALARM_TYPE_DISSOLVED_OXYGEN.equals(alarm.getAlarmType()) && + for (MessageWarn warn : warnList) { + if (WARN_TYPE_DISSOLVED_OXYGEN == warn.getWarnType() && device.getOxyWarnCallNoDis() != null && device.getOxyWarnCallNoDis() == 1) { shouldSkip = true; break; } - if (ALARM_TYPE_TEMPERATURE.equals(alarm.getAlarmType()) && + if (WARN_TYPE_TEMPERATURE == warn.getWarnType() && device.getTempWarnCallNoDis() != null && device.getTempWarnCallNoDis() == 1) { shouldSkip = true; break; } - if (ALARM_TYPE_BATTERY.equals(alarm.getAlarmType()) && + if (WARN_TYPE_BATTERY == warn.getWarnType() && device.getBatteryWarnCallNoDis() != null && device.getBatteryWarnCallNoDis() == 1) { shouldSkip = true; break; @@ -454,23 +477,21 @@ public class DeviceDataHandler { ); if (recentNoticeCount > 0) { - log.debug("[告警] {} - {}分钟内已通知", deviceName, ALARM_NOTIFICATION_INTERVAL); - - // 更新告警历史为已通知,但不发送实际通知 - for (AquAlarmHistory alarm : alarmList) { - alarm.setNotified(1); - alarm.setUpdatedTime(LocalDateTime.now()); - alarmHistoryMapper.updateById(alarm); - } + log.debug("[告警] {} - {}分钟内已通知,跳过电话通知", deviceName, ALARM_NOTIFICATION_INTERVAL); return; } // 从设备信息获取用户信息 Long userId = device.getUserId(); - // TODO: 从用户表查询手机号 - String mobilePhone = sensorData.getMobilePhone(); // 临时使用传感器数据中的手机号 - // TODO: 从塘口表查询塘口名称 - String pondName = deviceName; // 临时使用设备名 + // 从 aqu_user 表查询手机号 + String mobilePhone = null; + if (userId != null) { + AquUser aquUser = aquUserMapper.selectById(userId); + if (aquUser != null) { + mobilePhone = aquUser.getMobilePhone(); + } + } + String pondName = warnList.isEmpty() ? deviceName : warnList.get(0).getPondName(); // 验证必要信息 if (userId == null || StrUtil.isBlank(mobilePhone)) { @@ -486,22 +507,22 @@ public class DeviceDataHandler { callNotice.setPondName(pondName); callNotice.setCallTime(LocalDateTime.now()); callNotice.setCallStatus(CALL_STATUS_NO_CALL); - callNotice.setCreatedTime(LocalDateTime.now()); - callNotice.setUpdatedTime(LocalDateTime.now()); // 保存到数据库 warnCallNoticeMapper.insert(callNotice); - // 更新告警历史中的通知ID - for (AquAlarmHistory alarm : alarmList) { - alarm.setNoticeId(callNotice.getId()); - alarm.setNotified(1); - alarm.setUpdatedTime(LocalDateTime.now()); - alarmHistoryMapper.updateById(alarm); + // 保存报警消息与通知记录的关联关系 + for (MessageWarn warn : warnList) { + if (warn.getId() != null) { + AquMapMessageWarnCallNotice mapRecord = new AquMapMessageWarnCallNotice(); + mapRecord.setMessageWarnId(warn.getId()); + mapRecord.setCallNoticeId(callNotice.getId()); + mapMessageWarnCallNoticeMapper.insert(mapRecord); + } } // 发送语音通知 - sendVoiceNotification(callNotice, alarmMessage); + sendVoiceNotification(callNotice, deviceName, alarmMessage); } catch (Exception e) { log.error("[告警通知] 触发告警通知失败: {}", e.getMessage(), e); @@ -509,16 +530,22 @@ public class DeviceDataHandler { } /** - // 发送语音通知 - * @param callNotice 通知记录 - * @param alarmMessage 告警信息 + * 发送语音通知 + * + * @param callNotice 通知记录 + * @param deviceName 设备名称 + * @param warnMessage 告警内容 */ - private void sendVoiceNotification(AquWarnCallNotice callNotice, String alarmMessage) { + private void sendVoiceNotification(AquWarnCallNotice callNotice, String deviceName, String warnMessage) { try { - // 构建语音通知参数 + // 构建语音通知参数(与模板变量名保持一致) Map ttsParams = new HashMap<>(); - ttsParams.put("pond_name", callNotice.getPondName() != null ? callNotice.getPondName() : "未知塘口"); - ttsParams.put("alarm_info", alarmMessage); + ttsParams.put("pondName", callNotice.getPondName() != null ? callNotice.getPondName() : "未知塘口"); + ttsParams.put("deviceName", deviceName != null ? deviceName : "未知设备"); + String warnMessageShort = warnMessage != null && warnMessage.contains(":") + ? warnMessage.substring(0, warnMessage.indexOf(":")).trim() + : (warnMessage != null ? warnMessage : "异常"); + ttsParams.put("warnMessage", warnMessageShort); // 生成业务标识(用于回执关联) String outId = "ALARM_" + callNotice.getId() + "_" + System.currentTimeMillis(); @@ -535,7 +562,6 @@ public class DeviceDataHandler { callNotice.setCallStatus(1); // 呼叫成功,等待结果反馈 callNotice.setCallId(response.getCallId()); callNotice.setOutId(outId); - callNotice.setUpdatedTime(LocalDateTime.now()); warnCallNoticeMapper.updateById(callNotice); log.info("[告警] 呼叫成功: {}", callNotice.getMobilePhone()); @@ -543,7 +569,6 @@ public class DeviceDataHandler { // 呼叫失败 callNotice.setCallStatus(2); // 呼叫失败 callNotice.setStatusMsg(response != null ? response.getMessage() : "呼叫失败"); - callNotice.setUpdatedTime(LocalDateTime.now()); warnCallNoticeMapper.updateById(callNotice); log.error("[告警] 呼叫失败: {} - {}", callNotice.getMobilePhone(), callNotice.getStatusMsg()); @@ -556,7 +581,6 @@ public class DeviceDataHandler { try { callNotice.setCallStatus(2); callNotice.setStatusMsg("发送异常: " + e.getMessage()); - callNotice.setUpdatedTime(LocalDateTime.now()); warnCallNoticeMapper.updateById(callNotice); } catch (Exception ex) { log.error("[告警] 更新失败: {}", ex.getMessage()); @@ -588,34 +612,27 @@ public class DeviceDataHandler { } /** - * 创建告警历史记录 + * 创建报警消息记录(写入 aqu_message_warn) * - * @param deviceId 设备ID - * @param deviceName 设备名称 - * @param alarmType 告警类型 - * @param alarmLevel 告警级别 - * @param alarmContent 告警内容 - * @param alarmValue 告警值 - * @param thresholdValue 阈值 - * @return 告警历史对象 + * @param deviceId 设备ID + * @param userId 用户ID + * @param pondName 塘口名称 + * @param title 消息标题(告警类型名称) + * @param warnType 告警类型编码 + * @param message 消息内容 + * @return MessageWarn 对象 */ - private AquAlarmHistory createAlarmHistory(Long deviceId, String deviceName, String alarmType, - int alarmLevel, String alarmContent, - Double alarmValue, Double thresholdValue) { - AquAlarmHistory alarm = new AquAlarmHistory(); - alarm.setDeviceId(deviceId); - alarm.setDeviceName(deviceName); - alarm.setAlarmType(alarmType); - alarm.setAlarmLevel(alarmLevel); - alarm.setAlarmContent(alarmContent); - alarm.setAlarmValue(alarmValue); - alarm.setThresholdValue(thresholdValue); - alarm.setAlarmStatus(ALARM_STATUS_PENDING); - alarm.setAlarmTime(LocalDateTime.now()); - alarm.setNotified(0); - alarm.setCreatedTime(LocalDateTime.now()); - alarm.setUpdatedTime(LocalDateTime.now()); - return alarm; + private MessageWarn createMessageWarn(Long deviceId, Long userId, String pondName, + String title, int warnType, String message) { + MessageWarn warn = new MessageWarn(); + warn.setDeviceId(deviceId); + warn.setUserId(userId); + warn.setPondName(pondName); + warn.setTitle(title); + warn.setWarnType(warnType); + warn.setMessage(message); + warn.setIsRead(MSG_IS_READ_NO); + return warn; } /** @@ -627,64 +644,7 @@ public class DeviceDataHandler { * @param sensorData 传感器数据 */ private void checkAndRecoverAlarms(Long deviceId, Device device, DeviceSensorData sensorData) { - try { - // 查询该设备所有未恢复的告警 - java.util.List pendingAlarms = alarmHistoryMapper.selectList( - new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper() - .eq(AquAlarmHistory::getDeviceId, deviceId) - .ne(AquAlarmHistory::getAlarmStatus, ALARM_STATUS_RECOVERED) - ); - - if (pendingAlarms.isEmpty()) { - return; - } - - LocalDateTime now = LocalDateTime.now(); - - for (AquAlarmHistory alarm : pendingAlarms) { - boolean recovered = false; - - // 根据告警类型检查是否已恢复(使用设备配置的阈值) - switch (alarm.getAlarmType()) { - case ALARM_TYPE_DISSOLVED_OXYGEN: - if (sensorData.getDissolvedOxygen() != null) { - Double value = sensorData.getDissolvedOxygen(); - Double oxyWarnLower = device.getOxyWarnLower(); - recovered = oxyWarnLower != null && value >= oxyWarnLower; - } - break; - - case ALARM_TYPE_TEMPERATURE: - if (sensorData.getTemperature() != null) { - Double value = sensorData.getTemperature(); - Double tempWarnLower = device.getTempWarnLower(); - Double tempWarnUpper = device.getTempWarnUpper(); - recovered = (tempWarnLower == null || value >= tempWarnLower) && - (tempWarnUpper == null || value <= tempWarnUpper); - } - break; - - case ALARM_TYPE_BATTERY: - if (sensorData.getBattery() != null) { - Double batteryWarnLower = device.getBatteryWarnLower() != null ? device.getBatteryWarnLower().doubleValue() : null; - recovered = batteryWarnLower != null && sensorData.getBattery() >= batteryWarnLower; - } - break; - } - - // 如果告警已恢复,更新状态 - if (recovered) { - alarm.setAlarmStatus(ALARM_STATUS_RECOVERED); - alarm.setRecoveryTime(now); - alarm.setUpdatedTime(now); - alarmHistoryMapper.updateById(alarm); - log.info("[恢复] {} - {}", alarm.getDeviceName(), alarm.getAlarmType()); - } - } - - } catch (Exception e) { - log.error("检查告警恢复失败: {}", e.getMessage(), e); - } + // aqu_message_warn 表为消息通知,暂无需要恢复标记逻辑 } /** diff --git a/intc-modules/intc-iot/src/main/java/com/intc/iot/mapper/AquMapMessageWarnCallNoticeMapper.java b/intc-modules/intc-iot/src/main/java/com/intc/iot/mapper/AquMapMessageWarnCallNoticeMapper.java new file mode 100644 index 0000000..895cd30 --- /dev/null +++ b/intc-modules/intc-iot/src/main/java/com/intc/iot/mapper/AquMapMessageWarnCallNoticeMapper.java @@ -0,0 +1,14 @@ +package com.intc.iot.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.intc.iot.domain.AquMapMessageWarnCallNotice; +import org.apache.ibatis.annotations.Mapper; + +/** + * 报警消息与通知记录关联表 Mapper + * + * @author intc + */ +@Mapper +public interface AquMapMessageWarnCallNoticeMapper extends BaseMapper { +} diff --git a/intc-modules/intc-iot/src/main/java/com/intc/iot/service/impl/VmsMnsConsumerServiceImpl.java b/intc-modules/intc-iot/src/main/java/com/intc/iot/service/impl/VmsMnsConsumerServiceImpl.java index 823dbac..5d3a65c 100644 --- a/intc-modules/intc-iot/src/main/java/com/intc/iot/service/impl/VmsMnsConsumerServiceImpl.java +++ b/intc-modules/intc-iot/src/main/java/com/intc/iot/service/impl/VmsMnsConsumerServiceImpl.java @@ -5,6 +5,11 @@ import com.aliyun.mns.client.CloudAccount; import com.aliyun.mns.client.CloudQueue; import com.aliyun.mns.client.MNSClient; import com.aliyun.mns.model.Message; +import com.aliyuncs.DefaultAcsClient; +import com.aliyuncs.IAcsClient; +import com.aliyuncs.dybaseapi.model.v20170525.QueryTokenForMnsQueueRequest; +import com.aliyuncs.dybaseapi.model.v20170525.QueryTokenForMnsQueueResponse; +import com.aliyuncs.profile.DefaultProfile; import com.intc.iot.config.AliyunIotProperties; import com.intc.iot.domain.VmsCallback; import com.intc.iot.mapper.VmsCallbackMapper; @@ -17,15 +22,18 @@ import org.springframework.stereotype.Service; import java.nio.charset.StandardCharsets; import java.time.LocalDateTime; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.locks.ReentrantLock; /** * VMS MNS 回执消费服务实现 - * 注意:直接使用 AccessKey/Secret 访问 MNS,不再依赖 dybaseapi + * 使用 STS 临时凭证(QueryTokenForMnsQueue)动态获取 Token,对应 C# 的 MNSHandle 实现逻辑 * * @author intc-iot */ @@ -39,66 +47,72 @@ public class VmsMnsConsumerServiceImpl implements VmsMnsConsumerService { private final AliyunIotProperties aliyunIotProperties; private final VmsCallbackMapper vmsCallbackMapper; - /** - * MNS 配置常量 - * 注意:这些值需要根据你的实际阿里云账户配置 - */ - private static final String VMS_MNS_QUEUE_NAME = "Alicom-Queue-1572610294777992-VoiceReport"; - private static final String MNS_ACCOUNT_ENDPOINT = "https://1943695596114318.mns.cn-hangzhou.aliyuncs.com/"; + /** MNS 消息类型(固定值) */ + private static final String VMS_MNS_MESSAGE_TYPE = "VoiceReport"; + + /** MNS 默认线程数 */ private static final int MNS_THREAD_COUNT = 2; private static final int POLL_WAIT_SECONDS = 30; - /** - * 应用标识(用于过滤 out_id) - */ - private String appName; + /** Token 过期缓冲时间(120秒),小于此值则重新获取,防止服务器时间差异 */ + private static final long TOKEN_BUFFER_SECONDS = 120; - /** - * MNS 客户端 - */ + /** 线程安全的 Token 缓存 */ + private final ReentrantLock tokenLock = new ReentrantLock(); + private QueryTokenForMnsQueueResponse.MessageTokenDTO cachedToken; + private CloudQueue cachedQueue; + + /** ACS 客户端(用于获取 STS Token) */ + private IAcsClient acsClient; + + /** MNS 客户端(临时凭证建立) */ private MNSClient mnsClient; - /** - * 线程池 - */ + /** 线程池 */ private ExecutorService executorService; - /** - * 运行状态标志 - */ + /** 运行状态标志 */ private final AtomicBoolean running = new AtomicBoolean(false); @Override public void start() throws Exception { if (running.compareAndSet(false, true)) { - log.info("启动 VMS MNS 回执消费服务..."); + log.info("启动 VMS MNS 回执消费服务(STS 临时凭证模式)..."); - // 从配置读取应用名称 - appName = aliyunIotProperties.getAppKey() != null && !aliyunIotProperties.getAppKey().isEmpty() - ? aliyunIotProperties.getAppKey() - : "fishery-backend"; - log.info("VMS 回执过滤应用名称: {}", appName); + AliyunIotProperties.VmsMnsConfig vmsMns = aliyunIotProperties.getVms(); + String mnsEndpoint = vmsMns.getEndpoint(); + String mnsQueueName = vmsMns.getQueueName(); - // 直接使用 AccessKey/Secret 创建 MNS 客户端 - CloudAccount account = new CloudAccount( - aliyunIotProperties.getAccessKeyId(), - aliyunIotProperties.getAccessKeySecret(), - MNS_ACCOUNT_ENDPOINT - ); - mnsClient = account.getMNSClient(); - log.info("MNS 客户端初始化成功,Endpoint: {}", MNS_ACCOUNT_ENDPOINT); + if (mnsEndpoint == null || mnsEndpoint.isEmpty()) { + log.error("VMS MNS Endpoint 未配置,请在 aliyun.living-iot.vms.endpoint 中配置"); + running.set(false); + return; + } + + // 使用主 AK 创建 ACS 客户端(用于调用 QueryTokenForMnsQueue 接口) + String akId = vmsMns.getAccessKeyId() != null && !vmsMns.getAccessKeyId().isEmpty() + ? vmsMns.getAccessKeyId() : aliyunIotProperties.getAccessKeyId(); + String akSecret = vmsMns.getAccessKeySecret() != null && !vmsMns.getAccessKeySecret().isEmpty() + ? vmsMns.getAccessKeySecret() : aliyunIotProperties.getAccessKeySecret(); + String regionId = aliyunIotProperties.getRegionId() != null + ? aliyunIotProperties.getRegionId() : "cn-hangzhou"; + + DefaultProfile profile = DefaultProfile.getProfile(regionId, akId, akSecret); + DefaultProfile.addEndpoint(regionId, regionId, "Dybaseapi", "dybaseapi.aliyuncs.com"); + acsClient = new DefaultAcsClient(profile); + log.info("ACS 客户端创建成功,region: {}", regionId); // 创建线程池 executorService = Executors.newFixedThreadPool(MNS_THREAD_COUNT); - // 启动消费线程(对应 C# 的 MNSHandle 循环) + // 启动消费线程 for (int i = 0; i < MNS_THREAD_COUNT; i++) { - executorService.submit(this::mnsConsumeLoop); + executorService.submit(() -> mnsConsumeLoop(mnsEndpoint, mnsQueueName)); } - log.info("VMS MNS 回执消费服务启动成功,线程数: {}", MNS_THREAD_COUNT); + log.info("VMS MNS 回扇消费服务启动成功,线程数: {}", MNS_THREAD_COUNT); } else { - log.warn("VMS MNS 回执消费服务已在运行中,无需重复启动"); + log.warn("VMS MNS 回扇消费服务已在运行中,无需重复启动"); } } @@ -119,9 +133,9 @@ public class VmsMnsConsumerServiceImpl implements VmsMnsConsumerService { } } - // 关闭 MNS 客户端 if (mnsClient != null) { mnsClient.close(); + mnsClient = null; } log.info("VMS MNS 回执消费服务已停止"); @@ -134,23 +148,93 @@ public class VmsMnsConsumerServiceImpl implements VmsMnsConsumerService { } /** - * MNS 消费循环 + * 获取或刷新 STS Token 并返回对应的 CloudQueue + * 对应 C# 的 Token 过期检查 + 自动刷新逻辑 + * + * @param mnsEndpoint MNS endpoint + * @param queueName 队列名称 + * @return 可用的 CloudQueue */ - private void mnsConsumeLoop() { - log.info("MNS 消费线程 {} 启动", Thread.currentThread().getName()); - - CloudQueue queue = null; + private CloudQueue getOrRefreshQueue(String mnsEndpoint, String queueName) throws Exception { + tokenLock.lock(); try { - // 获取队列引用 - queue = mnsClient.getQueueRef(VMS_MNS_QUEUE_NAME); - log.info("获取 MNS Queue 成功: {}", VMS_MNS_QUEUE_NAME); - } catch (Exception e) { - log.error("获取 MNS Queue 失败: {}", e.getMessage(), e); - return; + // 检查 Token 是否将要过期(小于缓冲时间则重新获取) + if (cachedToken != null && cachedQueue != null) { + long remainSeconds = getTokenRemainSeconds(cachedToken.getExpireTime()); + if (remainSeconds >= TOKEN_BUFFER_SECONDS) { + return cachedQueue; + } + log.info("STS Token 将于 {}s 内过期,重新获取...", remainSeconds); + } else { + log.info("首次获取 MNS STS Token..."); + } + + // 调用 QueryTokenForMnsQueue 获取临时凭证 + QueryTokenForMnsQueueRequest request = new QueryTokenForMnsQueueRequest(); + request.setMessageType(VMS_MNS_MESSAGE_TYPE); + QueryTokenForMnsQueueResponse response = acsClient.getAcsResponse(request); + QueryTokenForMnsQueueResponse.MessageTokenDTO token = + response.getMessageTokenDTO(); + + log.info("STS Token 获取成功,过期时间: {}", token.getExpireTime()); + + // 关闭旧的 MNS 客户端 + if (mnsClient != null) { + mnsClient.close(); + } + + // 使用 STS 临时凭证创建新的 MNS 客户端 + CloudAccount account = new CloudAccount( + token.getAccessKeyId(), + token.getAccessKeySecret(), + mnsEndpoint, + token.getSecurityToken() + ); + mnsClient = account.getMNSClient(); + cachedQueue = mnsClient.getQueueRef(queueName); + cachedToken = token; + + log.info("MNS 客户端刷新成功,Queue: {}", queueName); + return cachedQueue; + + } finally { + tokenLock.unlock(); } + } + + /** + * 计算 Token 剩余有效秒数 + * SDK 返回的 expireTime 格式为 "yyyy-MM-dd HH:mm:ss",时区为 UTC+8 + */ + private long getTokenRemainSeconds(String expireTime) { + try { + java.time.LocalDateTime expire = java.time.LocalDateTime.parse( + expireTime, + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss") + ); + // SDK 返回的时间为 UTC+8 + long expireEpoch = expire.toEpochSecond(java.time.ZoneOffset.ofHours(8)); + return expireEpoch - System.currentTimeMillis() / 1000; + } catch (Exception e) { + log.warn("解析 Token 过期时间失败: {}", expireTime); + return 0; + } + } + + /** + * MNS 消费循环(每个线程执行) + * + * @param mnsEndpoint MNS endpoint + * @param queueName 队列名称 + */ + private void mnsConsumeLoop(String mnsEndpoint, String queueName) { + log.info("MNS 消费线程 {} 启动", Thread.currentThread().getName()); while (running.get()) { try { + // 获取(或刷新)有效的 CloudQueue + CloudQueue queue = getOrRefreshQueue(mnsEndpoint, queueName); + // 批量接收消息 List messages = queue.batchPopMessage(16, POLL_WAIT_SECONDS); @@ -160,7 +244,6 @@ public class VmsMnsConsumerServiceImpl implements VmsMnsConsumerService { log.debug("接收到 {} 条 VMS 回执消息", messages.size()); - // 处理消息 for (Message message : messages) { try { processMessage(message, queue); @@ -170,14 +253,28 @@ public class VmsMnsConsumerServiceImpl implements VmsMnsConsumerService { } } catch (Exception e) { - // 检查是否为中断异常 if (e instanceof InterruptedException || e.getCause() instanceof InterruptedException) { Thread.currentThread().interrupt(); log.info("MNS 消费线程被中断"); break; } - - log.error("MNS 消费循环异常: {}", e.getMessage(), e); + + // MessageNotExist 表示队列为空,属于正常现象,静默处理(使用长轮询时不应出现,出现时不报错) + String errMsg = e.getMessage(); + if (errMsg != null && errMsg.contains("MessageNotExist")) { + log.debug("MNS 队列暂无消息"); + continue; + } + + log.error("MNS 消费循环异常: {}", errMsg, e); + // 异常后清除缓存,下次循环重新获取 Token + tokenLock.lock(); + try { + cachedToken = null; + cachedQueue = null; + } finally { + tokenLock.unlock(); + } try { TimeUnit.SECONDS.sleep(5); } catch (InterruptedException ie) { @@ -192,64 +289,59 @@ public class VmsMnsConsumerServiceImpl implements VmsMnsConsumerService { /** * 处理单条消息 - * - * @param message MNS 消息 - * @param queue MNS 队列 + * 注意:MNS 回执消息体可能是明文 JSON,也可能是 Base64 编码的 JSON,需要尝试两种解析方式 */ private void processMessage(Message message, CloudQueue queue) { try { - // 解码消息体(对应 C# 的 Base64 解码) String body = message.getMessageBodyAsString(); - byte[] decoded = Base64.getDecoder().decode(body); - String jsonStr = new String(decoded, StandardCharsets.UTF_8); + + // 尝试 Base64 解码,如果失败则直接当明文 JSON 处理 + String jsonStr; + try { + byte[] decoded = Base64.getDecoder().decode(body.trim()); + jsonStr = new String(decoded, StandardCharsets.UTF_8); + } catch (IllegalArgumentException e) { + // 消息体本身就是 JSON 明文,无需 Base64 解码 + jsonStr = body; + } log.debug("收到 VMS 回执消息: {}", jsonStr); - // 解析为实体(对应 C# 的 JSON.Deserialize) Map callbackMap = JSONUtil.toBean(jsonStr, Map.class); String outId = (String) callbackMap.get("out_id"); - // 过滤不属于当前系统的消息(对应 C# 的 out_id 判断) if (outId == null || outId.isEmpty()) { log.debug("跳过无效 out_id 的消息"); queue.deleteMessage(message.getReceiptHandle()); return; } - // 验证 out_id 是否属于本系统(对应 C# 的 out_id.Equals(DefineValue.AppName)) - if (!outId.equals(appName)) { - log.debug("收到语音通知回执不属于当前系统, outId={}, 期望={}", outId, appName); - queue.deleteMessage(message.getReceiptHandle()); + // 验证 out_id 是否属于本系统(out_id 格式为 "ALARM_{callNoticeId}_{timestamp}") + if (!outId.startsWith("ALARM_")) { + log.debug("收到语音通知回执不属于当前系统, outId={}", outId); + // 与 C# 一致:不属于本系统的消息不删除,保留在队列 return; } - // 构建实体 VmsCallback vmsCallback = buildVmsCallback(callbackMap); - // 入库(对应 C# 的 CacheData.sListVmsCallback.Add) try { vmsCallbackMapper.insert(vmsCallback); log.info("VMS 回执入库成功 - CallId: {}, StatusCode: {}", vmsCallback.getCallId(), vmsCallback.getStatusCode()); - - // 成功处理后删除消息 queue.deleteMessage(message.getReceiptHandle()); } catch (org.springframework.dao.DuplicateKeyException e) { log.warn("VMS 回执已存在,跳过 - CallId: {}", vmsCallback.getCallId()); - // 重复数据也删除消息 queue.deleteMessage(message.getReceiptHandle()); } } catch (Exception e) { log.error("处理 VMS 回执消息异常: {}", e.getMessage(), e); - // 注意:不删除消息,让它重新回到队列,等待下次处理 + // 不删除消息,等待重试 } } /** * 构建 VmsCallback 实体 - * - * @param map 回执 Map - * @return VmsCallback */ private VmsCallback buildVmsCallback(Map map) { VmsCallback callback = new VmsCallback(); @@ -260,56 +352,29 @@ public class VmsMnsConsumerServiceImpl implements VmsMnsConsumerService { callback.setHangupDirection((String) map.get("hangup_direction")); callback.setCaller((String) map.get("caller")); callback.setVoiceType((String) map.get("voice_type")); - - // 时间戳字段 callback.setOriginateTime(getLongValue(map, "originate_time")); callback.setStartTime(getLongValue(map, "start_time")); callback.setEndTime(getLongValue(map, "end_time")); - - // 整数字段 callback.setRingTime(getIntValue(map, "ring_time")); callback.setDuration(getIntValue(map, "duration")); - callback.setTollType((String) map.get("toll_type")); - callback.setProcessed(0); // 初始为未处理 + callback.setProcessed(0); callback.setCreatedTime(LocalDateTime.now()); - return callback; } - /** - * 从 Map 中获取 Long 值 - */ private Long getLongValue(Map map, String key) { Object value = map.get(key); - if (value == null) { - return null; - } - if (value instanceof Number) { - return ((Number) value).longValue(); - } - try { - return Long.parseLong(value.toString()); - } catch (NumberFormatException e) { - return null; - } + if (value == null) return null; + if (value instanceof Number) return ((Number) value).longValue(); + try { return Long.parseLong(value.toString()); } catch (NumberFormatException e) { return null; } } - /** - * 从 Map 中获取 Integer 值 - */ private Integer getIntValue(Map map, String key) { Object value = map.get(key); - if (value == null) { - return null; - } - if (value instanceof Number) { - return ((Number) value).intValue(); - } - try { - return Integer.parseInt(value.toString()); - } catch (NumberFormatException e) { - return null; - } + if (value == null) return null; + if (value instanceof Number) return ((Number) value).intValue(); + try { return Integer.parseInt(value.toString()); } catch (NumberFormatException e) { return null; } } } + diff --git a/intc-modules/intc-iot/src/main/java/com/intc/iot/service/impl/VmsNoticeServiceImpl.java b/intc-modules/intc-iot/src/main/java/com/intc/iot/service/impl/VmsNoticeServiceImpl.java index 24770b8..fe842ed 100644 --- a/intc-modules/intc-iot/src/main/java/com/intc/iot/service/impl/VmsNoticeServiceImpl.java +++ b/intc-modules/intc-iot/src/main/java/com/intc/iot/service/impl/VmsNoticeServiceImpl.java @@ -30,10 +30,10 @@ public class VmsNoticeServiceImpl implements VmsNoticeService { private static final String CALL_SHOW_NUMBER = "0571000013978"; /** 默认 TTS 模板编码(当前取 C# 版本中的正式模板编码,可按环境调整) */ - private static final String TTS_CODE = "TTS_299550017"; + private static final String TTS_CODE = "TTS_328610196"; private final AliyunIotProperties aliyunIotProperties; - + /** * VMS 客户端单例,避免重复创建 */ @@ -68,7 +68,7 @@ public class VmsNoticeServiceImpl implements VmsNoticeService { request.setSysDomain("dyvmsapi.aliyuncs.com"); request.setSysVersion("2017-05-25"); request.setSysAction("SingleCallByTts"); - + // 设置请求参数 request.putQueryParameter("CalledNumber", phoneNum); request.putQueryParameter("CalledShowNumber", CALL_SHOW_NUMBER); @@ -83,7 +83,7 @@ public class VmsNoticeServiceImpl implements VmsNoticeService { try { CommonResponse response = client.getCommonResponse(request); - + if (response == null || response.getData() == null) { log.error("[VmsNoticeService] 语音呼叫请求异常, response 为空"); VmsNoticeResponse result = new VmsNoticeResponse(); @@ -95,7 +95,7 @@ public class VmsNoticeServiceImpl implements VmsNoticeService { // 解析响应 String responseData = response.getData(); cn.hutool.json.JSONObject jsonResponse = JSONUtil.parseObj(responseData); - + String code = jsonResponse.getStr("Code"); String message = jsonResponse.getStr("Message"); String callId = jsonResponse.getStr("CallId"); @@ -107,7 +107,7 @@ public class VmsNoticeServiceImpl implements VmsNoticeService { result.setSuccess("OK".equalsIgnoreCase(code)); if (!result.isSuccess()) { - log.warn("[VmsNoticeService] 语音呼叫失败, phoneNum={}, code={}, message={}, callId={}", + log.warn("[VmsNoticeService] 语音呼叫失败, phoneNum={}, code={}, message={}, callId={}", phoneNum, code, message, callId); } diff --git a/intc-modules/intc-iot/src/main/java/com/intc/iot/service/impl/WarnCallNoticeServiceImpl.java b/intc-modules/intc-iot/src/main/java/com/intc/iot/service/impl/WarnCallNoticeServiceImpl.java index 70e7a22..e01b964 100644 --- a/intc-modules/intc-iot/src/main/java/com/intc/iot/service/impl/WarnCallNoticeServiceImpl.java +++ b/intc-modules/intc-iot/src/main/java/com/intc/iot/service/impl/WarnCallNoticeServiceImpl.java @@ -25,7 +25,6 @@ import java.util.List; */ @Service @RequiredArgsConstructor -@ConditionalOnBean({AquWarnCallNoticeMapper.class, VmsCallbackMapper.class}) @Slf4j public class WarnCallNoticeServiceImpl implements WarnCallNoticeService { @@ -61,17 +60,44 @@ public class WarnCallNoticeServiceImpl implements WarnCallNoticeService { return false; } - log.debug("[告警通知] 处理回执信息 - 呼叫ID: {}, 状态码: {}", callback.getCallId(), callback.getStatusCode()); + log.debug("[告警通知] 处理回执信息 - 呼叫ID: {}, outId: {}, 状态码: {}", + callback.getCallId(), callback.getOutId(), callback.getStatusCode()); - // 根据 CallId 查找对应的通知记录 - AquWarnCallNotice callNotice = warnCallNoticeMapper.selectOne( - new LambdaQueryWrapper() - .eq(AquWarnCallNotice::getCallId, callback.getCallId()) - .eq(AquWarnCallNotice::getCallStatus, CALL_STATUS_CALL_SUCCESS) // 只处理呼叫成功等待反馈的记录 - ); + // 优先从 outId(格式:ALARM_{callNoticeId}_{timestamp})中解析主键直接查询 + // 若解析失败则回退到 callId 匹配 + AquWarnCallNotice callNotice = null; + String outId = callback.getOutId(); + if (outId != null && outId.startsWith("ALARM_")) { + try { + // outId 格式:ALARM_{id}_{timestamp},取第二段 + String[] parts = outId.split("_"); + if (parts.length >= 2) { + Long noticeId = Long.parseLong(parts[1]); + callNotice = warnCallNoticeMapper.selectOne( + new LambdaQueryWrapper() + .eq(AquWarnCallNotice::getId, noticeId) + .eq(AquWarnCallNotice::getCallStatus, CALL_STATUS_CALL_SUCCESS) + ); + if (callNotice != null) { + log.debug("[告警通知] 通过 outId 找到通知记录 - 记录ID: {}", noticeId); + } + } + } catch (NumberFormatException e) { + log.warn("[告警通知] outId 解析失败,回退到 callId 匹配 - outId: {}", outId); + } + } + + // 回退:通过 callId 匹配 + if (callNotice == null) { + callNotice = warnCallNoticeMapper.selectOne( + new LambdaQueryWrapper() + .eq(AquWarnCallNotice::getCallId, callback.getCallId()) + .eq(AquWarnCallNotice::getCallStatus, CALL_STATUS_CALL_SUCCESS) + ); + } if (callNotice == null) { - log.warn("[告警通知] 未找到对应的通知记录 - 呼叫ID: {}", callback.getCallId()); + log.warn("[告警通知] 未找到对应的通知记录 - 呼叫ID: {}, outId: {}", callback.getCallId(), outId); return false; } @@ -183,7 +209,6 @@ public class WarnCallNoticeServiceImpl implements WarnCallNoticeService { // 更新状态为回执失败 notice.setCallStatus(CALL_STATUS_CALLBACK_FAIL); notice.setStatusMsg("回执超时,未在规定时间内收到回执"); - notice.setUpdatedTime(now); warnCallNoticeMapper.updateById(notice); cleanedCount++; @@ -222,7 +247,6 @@ public class WarnCallNoticeServiceImpl implements WarnCallNoticeService { callNotice.setStatusMsg(callback.getStatusMsg()); callNotice.setOutId(callback.getOutId()); callNotice.setTollType(callback.getTollType()); - callNotice.setUpdatedTime(now); // 根据状态码判断通话结果(对应 C# 的状态码判断逻辑) if (VMS_STATUS_CODE_SUCCESS.equals(callback.getStatusCode()) || diff --git a/intc-modules/intc-iot/src/main/java/com/intc/iot/task/VmsCallbackProcessTask.java b/intc-modules/intc-iot/src/main/java/com/intc/iot/task/VmsCallbackProcessTask.java index 57aa4b9..dd24617 100644 --- a/intc-modules/intc-iot/src/main/java/com/intc/iot/task/VmsCallbackProcessTask.java +++ b/intc-modules/intc-iot/src/main/java/com/intc/iot/task/VmsCallbackProcessTask.java @@ -15,7 +15,6 @@ import org.springframework.stereotype.Component; */ @Component @RequiredArgsConstructor -@ConditionalOnBean(WarnCallNoticeService.class) @Slf4j public class VmsCallbackProcessTask { diff --git a/script/sql/ry_vue_5.X.sql b/script/sql/ry_vue_5.X.sql deleted file mode 100644 index dae4792..0000000 --- a/script/sql/ry_vue_5.X.sql +++ /dev/null @@ -1,976 +0,0 @@ --- ---------------------------- --- 第三方平台授权表 --- ---------------------------- -create table sys_social -( - id bigint not null comment '主键', - user_id bigint not null comment '用户ID', - tenant_id varchar(20) default '000000' comment '租户id', - auth_id varchar(255) not null comment '平台+平台唯一id', - source varchar(255) not null comment '用户来源', - open_id varchar(255) default null comment '平台编号唯一id', - user_name varchar(30) not null comment '登录账号', - nick_name varchar(30) default '' comment '用户昵称', - email varchar(255) default '' comment '用户邮箱', - avatar varchar(500) default '' comment '头像地址', - access_token varchar(2000) not null comment '用户的授权令牌', - expire_in int default null comment '用户的授权令牌的有效期,部分平台可能没有', - refresh_token varchar(255) default null comment '刷新令牌,部分平台可能没有', - access_code varchar(2000) default null comment '平台的授权信息,部分平台可能没有', - union_id varchar(255) default null comment '用户的 unionid', - scope varchar(255) default null comment '授予的权限,部分平台可能没有', - token_type varchar(255) default null comment '个别平台的授权信息,部分平台可能没有', - id_token varchar(2000) default null comment 'id token,部分平台可能没有', - mac_algorithm varchar(255) default null comment '小米平台用户的附带属性,部分平台可能没有', - mac_key varchar(255) default null comment '小米平台用户的附带属性,部分平台可能没有', - code varchar(255) default null comment '用户的授权code,部分平台可能没有', - oauth_token varchar(255) default null comment 'Twitter平台用户的附带属性,部分平台可能没有', - oauth_token_secret varchar(255) default null comment 'Twitter平台用户的附带属性,部分平台可能没有', - create_dept bigint(20) comment '创建部门', - create_by bigint(20) comment '创建者', - create_time datetime comment '创建时间', - update_by bigint(20) comment '更新者', - update_time datetime comment '更新时间', - del_flag char(1) default '0' comment '删除标志(0代表存在 1代表删除)', - PRIMARY KEY (id) -) engine=innodb comment = '社会化关系表'; - - --- ---------------------------- --- 租户表 --- ---------------------------- -create table sys_tenant -( - id bigint(20) not null comment 'id', - tenant_id varchar(20) not null comment '租户编号', - contact_user_name varchar(20) comment '联系人', - contact_phone varchar(20) comment '联系电话', - company_name varchar(30) comment '企业名称', - license_number varchar(30) comment '统一社会信用代码', - address varchar(200) comment '地址', - intro varchar(200) comment '企业简介', - domain varchar(200) comment '域名', - remark varchar(200) comment '备注', - package_id bigint(20) comment '租户套餐编号', - expire_time datetime comment '过期时间', - account_count int default -1 comment '用户数量(-1不限制)', - status char(1) default '0' comment '租户状态(0正常 1停用)', - del_flag char(1) default '0' comment '删除标志(0代表存在 1代表删除)', - create_dept bigint(20) comment '创建部门', - create_by bigint(20) comment '创建者', - create_time datetime comment '创建时间', - update_by bigint(20) comment '更新者', - update_time datetime comment '更新时间', - primary key (id) -) engine=innodb comment = '租户表'; - - --- ---------------------------- --- 初始化-租户表数据 --- ---------------------------- - -insert into sys_tenant values(1, '000000', '管理组', '15888888888', 'XXX有限公司', null, null, '多租户通用后台管理管理系统', null, null, null, null, -1, '0', '0', 103, 1, sysdate(), null, null); - - --- ---------------------------- --- 租户套餐表 --- ---------------------------- -create table sys_tenant_package ( - package_id bigint(20) not null comment '租户套餐id', - package_name varchar(20) comment '套餐名称', - menu_ids varchar(3000) comment '关联菜单id', - remark varchar(200) comment '备注', - menu_check_strictly tinyint(1) default 1 comment '菜单树选择项是否关联显示', - status char(1) default '0' comment '状态(0正常 1停用)', - del_flag char(1) default '0' comment '删除标志(0代表存在 1代表删除)', - create_dept bigint(20) comment '创建部门', - create_by bigint(20) comment '创建者', - create_time datetime comment '创建时间', - update_by bigint(20) comment '更新者', - update_time datetime comment '更新时间', - primary key (package_id) -) engine=innodb comment = '租户套餐表'; - - --- ---------------------------- --- 1、部门表 --- ---------------------------- -create table sys_dept ( - dept_id bigint(20) not null comment '部门id', - tenant_id varchar(20) default '000000' comment '租户编号', - parent_id bigint(20) default 0 comment '父部门id', - ancestors varchar(500) default '' comment '祖级列表', - dept_name varchar(30) default '' comment '部门名称', - dept_category varchar(100) default null comment '部门类别编码', - order_num int(4) default 0 comment '显示顺序', - leader bigint(20) default null comment '负责人', - phone varchar(11) default null comment '联系电话', - email varchar(50) default null comment '邮箱', - status char(1) default '0' comment '部门状态(0正常 1停用)', - del_flag char(1) default '0' comment '删除标志(0代表存在 1代表删除)', - create_dept bigint(20) default null comment '创建部门', - create_by bigint(20) default null comment '创建者', - create_time datetime comment '创建时间', - update_by bigint(20) default null comment '更新者', - update_time datetime comment '更新时间', - primary key (dept_id) -) engine=innodb comment = '部门表'; - --- ---------------------------- --- 初始化-部门表数据 --- ---------------------------- - - -insert into sys_dept values(100, '000000', 0, '0', 'XXX科技', null,0, null, '15888888888', 'xxx@qq.com', '0', '0', 103, 1, sysdate(), null, null); -insert into sys_dept values(101, '000000', 100, '0,100', '深圳总公司', null,1, null, '15888888888', 'xxx@qq.com', '0', '0', 103, 1, sysdate(), null, null); -insert into sys_dept values(102, '000000', 100, '0,100', '长沙分公司', null,2, null, '15888888888', 'xxx@qq.com', '0', '0', 103, 1, sysdate(), null, null); -insert into sys_dept values(103, '000000', 101, '0,100,101', '研发部门', null,1, 1, '15888888888', 'xxx@qq.com', '0', '0', 103, 1, sysdate(), null, null); -insert into sys_dept values(104, '000000', 101, '0,100,101', '市场部门', null,2, null, '15888888888', 'xxx@qq.com', '0', '0', 103, 1, sysdate(), null, null); -insert into sys_dept values(105, '000000', 101, '0,100,101', '测试部门', null,3, null, '15888888888', 'xxx@qq.com', '0', '0', 103, 1, sysdate(), null, null); -insert into sys_dept values(106, '000000', 101, '0,100,101', '财务部门', null,4, null, '15888888888', 'xxx@qq.com', '0', '0', 103, 1, sysdate(), null, null); -insert into sys_dept values(107, '000000', 101, '0,100,101', '运维部门', null,5, null, '15888888888', 'xxx@qq.com', '0', '0', 103, 1, sysdate(), null, null); -insert into sys_dept values(108, '000000', 102, '0,100,102', '市场部门', null,1, null, '15888888888', 'xxx@qq.com', '0', '0', 103, 1, sysdate(), null, null); -insert into sys_dept values(109, '000000', 102, '0,100,102', '财务部门', null,2, null, '15888888888', 'xxx@qq.com', '0', '0', 103, 1, sysdate(), null, null); - - --- ---------------------------- --- 2、用户信息表 --- ---------------------------- -create table sys_user ( - user_id bigint(20) not null comment '用户ID', - tenant_id varchar(20) default '000000' comment '租户编号', - dept_id bigint(20) default null comment '部门ID', - user_name varchar(30) not null comment '用户账号', - nick_name varchar(30) not null comment '用户昵称', - user_type varchar(10) default 'sys_user' comment '用户类型(sys_user系统用户)', - email varchar(50) default '' comment '用户邮箱', - phonenumber varchar(11) default '' comment '手机号码', - sex char(1) default '0' comment '用户性别(0男 1女 2未知)', - avatar bigint(20) comment '头像地址', - password varchar(100) default '' comment '密码', - status char(1) default '0' comment '帐号状态(0正常 1停用)', - del_flag char(1) default '0' comment '删除标志(0代表存在 1代表删除)', - login_ip varchar(128) default '' comment '最后登录IP', - login_date datetime comment '最后登录时间', - create_dept bigint(20) default null comment '创建部门', - create_by bigint(20) default null comment '创建者', - create_time datetime comment '创建时间', - update_by bigint(20) default null comment '更新者', - update_time datetime comment '更新时间', - remark varchar(500) default null comment '备注', - primary key (user_id) -) engine=innodb comment = '用户信息表'; - --- ---------------------------- --- 初始化-用户信息表数据 --- ---------------------------- -insert into sys_user values(1, '000000', 103, 'admin', '疯狂的狮子Li', 'sys_user', 'crazyLionLi@163.com', '15888888888', '1', null, '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '0', '0', '127.0.0.1', sysdate(), 103, 1, sysdate(), null, null, '管理员'); -insert into sys_user values(3, '000000', 108, 'test', '本部门及以下 密码666666', 'sys_user', '', '', '0', null, '$2a$10$b8yUzN0C71sbz.PhNOCgJe.Tu1yWC3RNrTyjSQ8p1W0.aaUXUJ.Ne', '0', '0', '127.0.0.1', sysdate(), 103, 1, sysdate(), 3, sysdate(), null); -insert into sys_user values(4, '000000', 102, 'test1', '仅本人 密码666666', 'sys_user', '', '', '0', null, '$2a$10$b8yUzN0C71sbz.PhNOCgJe.Tu1yWC3RNrTyjSQ8p1W0.aaUXUJ.Ne', '0', '0', '127.0.0.1', sysdate(), 103, 1, sysdate(), 4, sysdate(), null); - --- ---------------------------- --- 3、岗位信息表 --- ---------------------------- -create table sys_post -( - post_id bigint(20) not null comment '岗位ID', - tenant_id varchar(20) default '000000' comment '租户编号', - dept_id bigint(20) not null comment '部门id', - post_code varchar(64) not null comment '岗位编码', - post_category varchar(100) default null comment '岗位类别编码', - post_name varchar(50) not null comment '岗位名称', - post_sort int(4) not null comment '显示顺序', - status char(1) not null comment '状态(0正常 1停用)', - create_dept bigint(20) default null comment '创建部门', - create_by bigint(20) default null comment '创建者', - create_time datetime comment '创建时间', - update_by bigint(20) default null comment '更新者', - update_time datetime comment '更新时间', - remark varchar(500) default null comment '备注', - primary key (post_id) -) engine=innodb comment = '岗位信息表'; - --- ---------------------------- --- 初始化-岗位信息表数据 --- ---------------------------- -insert into sys_post values(1, '000000', 103, 'ceo', null, '董事长', 1, '0', 103, 1, sysdate(), null, null, ''); -insert into sys_post values(2, '000000', 100, 'se', null, '项目经理', 2, '0', 103, 1, sysdate(), null, null, ''); -insert into sys_post values(3, '000000', 100, 'hr', null, '人力资源', 3, '0', 103, 1, sysdate(), null, null, ''); -insert into sys_post values(4, '000000', 100, 'user', null, '普通员工', 4, '0', 103, 1, sysdate(), null, null, ''); - - --- ---------------------------- --- 4、角色信息表 --- ---------------------------- -create table sys_role ( - role_id bigint(20) not null comment '角色ID', - tenant_id varchar(20) default '000000' comment '租户编号', - role_name varchar(30) not null comment '角色名称', - role_key varchar(100) not null comment '角色权限字符串', - role_sort int(4) not null comment '显示顺序', - data_scope char(1) default '1' comment '数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限 5:仅本人数据权限 6:部门及以下或本人数据权限)', - menu_check_strictly tinyint(1) default 1 comment '菜单树选择项是否关联显示', - dept_check_strictly tinyint(1) default 1 comment '部门树选择项是否关联显示', - status char(1) not null comment '角色状态(0正常 1停用)', - del_flag char(1) default '0' comment '删除标志(0代表存在 1代表删除)', - create_dept bigint(20) default null comment '创建部门', - create_by bigint(20) default null comment '创建者', - create_time datetime comment '创建时间', - update_by bigint(20) default null comment '更新者', - update_time datetime comment '更新时间', - remark varchar(500) default null comment '备注', - primary key (role_id) -) engine=innodb comment = '角色信息表'; - --- ---------------------------- --- 初始化-角色信息表数据 --- ---------------------------- -insert into sys_role values(1, '000000', '超级管理员', 'superadmin', 1, 1, 1, 1, '0', '0', 103, 1, sysdate(), null, null, '超级管理员'); -insert into sys_role values(3, '000000', '本部门及以下', 'test1', 3, 4, 1, 1, '0', '0', 103, 1, sysdate(), null, null, ''); -insert into sys_role values(4, '000000', '仅本人', 'test2', 4, 5, 1, 1, '0', '0', 103, 1, sysdate(), null, null, ''); - --- ---------------------------- --- 5、菜单权限表 --- ---------------------------- -create table sys_menu ( - menu_id bigint(20) not null comment '菜单ID', - menu_name varchar(50) not null comment '菜单名称', - parent_id bigint(20) default 0 comment '父菜单ID', - order_num int(4) default 0 comment '显示顺序', - path varchar(200) default '' comment '路由地址', - component varchar(255) default null comment '组件路径', - query_param varchar(255) default null comment '路由参数', - is_frame int(1) default 1 comment '是否为外链(0是 1否)', - is_cache int(1) default 0 comment '是否缓存(0缓存 1不缓存)', - menu_type char(1) default '' comment '菜单类型(M目录 C菜单 F按钮)', - visible char(1) default 0 comment '显示状态(0显示 1隐藏)', - status char(1) default 0 comment '菜单状态(0正常 1停用)', - perms varchar(100) default null comment '权限标识', - icon varchar(100) default '#' comment '菜单图标', - create_dept bigint(20) default null comment '创建部门', - create_by bigint(20) default null comment '创建者', - create_time datetime comment '创建时间', - update_by bigint(20) default null comment '更新者', - update_time datetime comment '更新时间', - remark varchar(500) default '' comment '备注', - primary key (menu_id) -) engine=innodb comment = '菜单权限表'; - --- ---------------------------- --- 初始化-菜单信息表数据 --- ---------------------------- --- 一级菜单 -insert into sys_menu values('1', '系统管理', '0', '1', 'system', null, '', 1, 0, 'M', '0', '0', '', 'system', 103, 1, sysdate(), null, null, '系统管理目录'); -insert into sys_menu values('6', '租户管理', '0', '2', 'tenant', null, '', 1, 0, 'M', '0', '0', '', 'chart', 103, 1, sysdate(), null, null, '租户管理目录'); -insert into sys_menu values('2', '系统监控', '0', '3', 'monitor', null, '', 1, 0, 'M', '0', '0', '', 'monitor', 103, 1, sysdate(), null, null, '系统监控目录'); -insert into sys_menu values('3', '系统工具', '0', '4', 'tool', null, '', 1, 0, 'M', '0', '0', '', 'tool', 103, 1, sysdate(), null, null, '系统工具目录'); -insert into sys_menu values('4', 'PLUS官网', '0', '5', 'https://gitee.com/dromara/RuoYi-Vue-Plus', null, '', 0, 0, 'M', '0', '0', '', 'guide', 103, 1, sysdate(), null, null, 'RuoYi-Vue-Plus官网地址'); -insert into sys_menu values('5', '测试菜单', '0', '5', 'demo', null, '', 1, 0, 'M', '0', '0', '', 'star', 103, 1, sysdate(), null, null, '测试菜单'); --- 二级菜单 -insert into sys_menu values('100', '用户管理', '1', '1', 'user', 'system/user/index', '', 1, 0, 'C', '0', '0', 'system:user:list', 'user', 103, 1, sysdate(), null, null, '用户管理菜单'); -insert into sys_menu values('101', '角色管理', '1', '2', 'role', 'system/role/index', '', 1, 0, 'C', '0', '0', 'system:role:list', 'peoples', 103, 1, sysdate(), null, null, '角色管理菜单'); -insert into sys_menu values('102', '菜单管理', '1', '3', 'menu', 'system/menu/index', '', 1, 0, 'C', '0', '0', 'system:menu:list', 'tree-table', 103, 1, sysdate(), null, null, '菜单管理菜单'); -insert into sys_menu values('103', '部门管理', '1', '4', 'dept', 'system/dept/index', '', 1, 0, 'C', '0', '0', 'system:dept:list', 'tree', 103, 1, sysdate(), null, null, '部门管理菜单'); -insert into sys_menu values('104', '岗位管理', '1', '5', 'post', 'system/post/index', '', 1, 0, 'C', '0', '0', 'system:post:list', 'post', 103, 1, sysdate(), null, null, '岗位管理菜单'); -insert into sys_menu values('105', '字典管理', '1', '6', 'dict', 'system/dict/index', '', 1, 0, 'C', '0', '0', 'system:dict:list', 'dict', 103, 1, sysdate(), null, null, '字典管理菜单'); -insert into sys_menu values('106', '参数设置', '1', '7', 'config', 'system/config/index', '', 1, 0, 'C', '0', '0', 'system:config:list', 'edit', 103, 1, sysdate(), null, null, '参数设置菜单'); -insert into sys_menu values('107', '通知公告', '1', '8', 'notice', 'system/notice/index', '', 1, 0, 'C', '0', '0', 'system:notice:list', 'message', 103, 1, sysdate(), null, null, '通知公告菜单'); -insert into sys_menu values('108', '日志管理', '1', '9', 'log', '', '', 1, 0, 'M', '0', '0', '', 'log', 103, 1, sysdate(), null, null, '日志管理菜单'); -insert into sys_menu values('109', '在线用户', '2', '1', 'online', 'monitor/online/index', '', 1, 0, 'C', '0', '0', 'monitor:online:list', 'online', 103, 1, sysdate(), null, null, '在线用户菜单'); -insert into sys_menu values('113', '缓存监控', '2', '5', 'cache', 'monitor/cache/index', '', 1, 0, 'C', '0', '0', 'monitor:cache:list', 'redis', 103, 1, sysdate(), null, null, '缓存监控菜单'); -insert into sys_menu values('115', '代码生成', '3', '2', 'gen', 'tool/gen/index', '', 1, 0, 'C', '0', '0', 'tool:gen:list', 'code', 103, 1, sysdate(), null, null, '代码生成菜单'); -insert into sys_menu values('121', '租户管理', '6', '1', 'tenant', 'system/tenant/index', '', 1, 0, 'C', '0', '0', 'system:tenant:list', 'list', 103, 1, sysdate(), null, null, '租户管理菜单'); -insert into sys_menu values('122', '租户套餐管理', '6', '2', 'tenantPackage', 'system/tenantPackage/index', '', 1, 0, 'C', '0', '0', 'system:tenantPackage:list', 'form', 103, 1, sysdate(), null, null, '租户套餐管理菜单'); -insert into sys_menu values('123', '客户端管理', '1', '11', 'client', 'system/client/index', '', 1, 0, 'C', '0', '0', 'system:client:list', 'international', 103, 1, sysdate(), null, null, '客户端管理菜单'); -insert into sys_menu values('116', '修改生成配置', '3', '2', 'gen-edit/index/:tableId', 'tool/gen/editTable', '', 1, 1, 'C', '1', '0', 'tool:gen:edit', '#', 103, 1, sysdate(), null, null, '/tool/gen'); -insert into sys_menu values('130', '分配用户', '1', '2', 'role-auth/user/:roleId', 'system/role/authUser', '', 1, 1, 'C', '1', '0', 'system:role:edit', '#', 103, 1, sysdate(), null, null, '/system/role'); -insert into sys_menu values('131', '分配角色', '1', '1', 'user-auth/role/:userId', 'system/user/authRole', '', 1, 1, 'C', '1', '0', 'system:user:edit', '#', 103, 1, sysdate(), null, null, '/system/user'); -insert into sys_menu values('132', '字典数据', '1', '6', 'dict-data/index/:dictId', 'system/dict/data', '', 1, 1, 'C', '1', '0', 'system:dict:list', '#', 103, 1, sysdate(), null, null, '/system/dict'); -insert into sys_menu values('133', '文件配置管理', '1', '10', 'oss-config/index', 'system/oss/config', '', 1, 1, 'C', '1', '0', 'system:ossConfig:list', '#', 103, 1, sysdate(), null, null, '/system/oss'); - --- springboot-admin监控 -insert into sys_menu values('117', 'Admin监控', '2', '5', 'Admin', 'monitor/admin/index', '', 1, 0, 'C', '0', '0', 'monitor:admin:list', 'dashboard', 103, 1, sysdate(), null, null, 'Admin监控菜单'); --- oss菜单 -insert into sys_menu values('118', '文件管理', '1', '10', 'oss', 'system/oss/index', '', 1, 0, 'C', '0', '0', 'system:oss:list', 'upload', 103, 1, sysdate(), null, null, '文件管理菜单'); --- snail-job server控制台 -insert into sys_menu values('120', '任务调度中心', '2', '6', 'snailjob', 'monitor/snailjob/index', '', 1, 0, 'C', '0', '0', 'monitor:snailjob:list', 'job', 103, 1, sysdate(), null, null, 'SnailJob控制台菜单'); - --- 三级菜单 -insert into sys_menu values('500', '操作日志', '108', '1', 'operlog', 'monitor/operlog/index', '', 1, 0, 'C', '0', '0', 'monitor:operlog:list', 'form', 103, 1, sysdate(), null, null, '操作日志菜单'); -insert into sys_menu values('501', '登录日志', '108', '2', 'logininfor', 'monitor/logininfor/index', '', 1, 0, 'C', '0', '0', 'monitor:logininfor:list', 'logininfor', 103, 1, sysdate(), null, null, '登录日志菜单'); --- 用户管理按钮 -insert into sys_menu values('1001', '用户查询', '100', '1', '', '', '', 1, 0, 'F', '0', '0', 'system:user:query', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1002', '用户新增', '100', '2', '', '', '', 1, 0, 'F', '0', '0', 'system:user:add', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1003', '用户修改', '100', '3', '', '', '', 1, 0, 'F', '0', '0', 'system:user:edit', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1004', '用户删除', '100', '4', '', '', '', 1, 0, 'F', '0', '0', 'system:user:remove', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1005', '用户导出', '100', '5', '', '', '', 1, 0, 'F', '0', '0', 'system:user:export', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1006', '用户导入', '100', '6', '', '', '', 1, 0, 'F', '0', '0', 'system:user:import', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1007', '重置密码', '100', '7', '', '', '', 1, 0, 'F', '0', '0', 'system:user:resetPwd', '#', 103, 1, sysdate(), null, null, ''); --- 角色管理按钮 -insert into sys_menu values('1008', '角色查询', '101', '1', '', '', '', 1, 0, 'F', '0', '0', 'system:role:query', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1009', '角色新增', '101', '2', '', '', '', 1, 0, 'F', '0', '0', 'system:role:add', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1010', '角色修改', '101', '3', '', '', '', 1, 0, 'F', '0', '0', 'system:role:edit', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1011', '角色删除', '101', '4', '', '', '', 1, 0, 'F', '0', '0', 'system:role:remove', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1012', '角色导出', '101', '5', '', '', '', 1, 0, 'F', '0', '0', 'system:role:export', '#', 103, 1, sysdate(), null, null, ''); --- 菜单管理按钮 -insert into sys_menu values('1013', '菜单查询', '102', '1', '', '', '', 1, 0, 'F', '0', '0', 'system:menu:query', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1014', '菜单新增', '102', '2', '', '', '', 1, 0, 'F', '0', '0', 'system:menu:add', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1015', '菜单修改', '102', '3', '', '', '', 1, 0, 'F', '0', '0', 'system:menu:edit', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1016', '菜单删除', '102', '4', '', '', '', 1, 0, 'F', '0', '0', 'system:menu:remove', '#', 103, 1, sysdate(), null, null, ''); --- 部门管理按钮 -insert into sys_menu values('1017', '部门查询', '103', '1', '', '', '', 1, 0, 'F', '0', '0', 'system:dept:query', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1018', '部门新增', '103', '2', '', '', '', 1, 0, 'F', '0', '0', 'system:dept:add', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1019', '部门修改', '103', '3', '', '', '', 1, 0, 'F', '0', '0', 'system:dept:edit', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1020', '部门删除', '103', '4', '', '', '', 1, 0, 'F', '0', '0', 'system:dept:remove', '#', 103, 1, sysdate(), null, null, ''); --- 岗位管理按钮 -insert into sys_menu values('1021', '岗位查询', '104', '1', '', '', '', 1, 0, 'F', '0', '0', 'system:post:query', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1022', '岗位新增', '104', '2', '', '', '', 1, 0, 'F', '0', '0', 'system:post:add', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1023', '岗位修改', '104', '3', '', '', '', 1, 0, 'F', '0', '0', 'system:post:edit', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1024', '岗位删除', '104', '4', '', '', '', 1, 0, 'F', '0', '0', 'system:post:remove', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1025', '岗位导出', '104', '5', '', '', '', 1, 0, 'F', '0', '0', 'system:post:export', '#', 103, 1, sysdate(), null, null, ''); --- 字典管理按钮 -insert into sys_menu values('1026', '字典查询', '105', '1', '#', '', '', 1, 0, 'F', '0', '0', 'system:dict:query', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1027', '字典新增', '105', '2', '#', '', '', 1, 0, 'F', '0', '0', 'system:dict:add', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1028', '字典修改', '105', '3', '#', '', '', 1, 0, 'F', '0', '0', 'system:dict:edit', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1029', '字典删除', '105', '4', '#', '', '', 1, 0, 'F', '0', '0', 'system:dict:remove', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1030', '字典导出', '105', '5', '#', '', '', 1, 0, 'F', '0', '0', 'system:dict:export', '#', 103, 1, sysdate(), null, null, ''); --- 参数设置按钮 -insert into sys_menu values('1031', '参数查询', '106', '1', '#', '', '', 1, 0, 'F', '0', '0', 'system:config:query', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1032', '参数新增', '106', '2', '#', '', '', 1, 0, 'F', '0', '0', 'system:config:add', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1033', '参数修改', '106', '3', '#', '', '', 1, 0, 'F', '0', '0', 'system:config:edit', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1034', '参数删除', '106', '4', '#', '', '', 1, 0, 'F', '0', '0', 'system:config:remove', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1035', '参数导出', '106', '5', '#', '', '', 1, 0, 'F', '0', '0', 'system:config:export', '#', 103, 1, sysdate(), null, null, ''); --- 通知公告按钮 -insert into sys_menu values('1036', '公告查询', '107', '1', '#', '', '', 1, 0, 'F', '0', '0', 'system:notice:query', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1037', '公告新增', '107', '2', '#', '', '', 1, 0, 'F', '0', '0', 'system:notice:add', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1038', '公告修改', '107', '3', '#', '', '', 1, 0, 'F', '0', '0', 'system:notice:edit', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1039', '公告删除', '107', '4', '#', '', '', 1, 0, 'F', '0', '0', 'system:notice:remove', '#', 103, 1, sysdate(), null, null, ''); --- 操作日志按钮 -insert into sys_menu values('1040', '操作查询', '500', '1', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:operlog:query', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1041', '操作删除', '500', '2', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:operlog:remove', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1042', '日志导出', '500', '4', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:operlog:export', '#', 103, 1, sysdate(), null, null, ''); --- 登录日志按钮 -insert into sys_menu values('1043', '登录查询', '501', '1', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:logininfor:query', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1044', '登录删除', '501', '2', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:logininfor:remove', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1045', '日志导出', '501', '3', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:logininfor:export', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1050', '账户解锁', '501', '4', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:logininfor:unlock', '#', 103, 1, sysdate(), null, null, ''); --- 在线用户按钮 -insert into sys_menu values('1046', '在线查询', '109', '1', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:online:query', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1047', '批量强退', '109', '2', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:online:batchLogout', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1048', '单条强退', '109', '3', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:online:forceLogout', '#', 103, 1, sysdate(), null, null, ''); --- 代码生成按钮 -insert into sys_menu values('1055', '生成查询', '115', '1', '#', '', '', 1, 0, 'F', '0', '0', 'tool:gen:query', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1056', '生成修改', '115', '2', '#', '', '', 1, 0, 'F', '0', '0', 'tool:gen:edit', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1057', '生成删除', '115', '3', '#', '', '', 1, 0, 'F', '0', '0', 'tool:gen:remove', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1058', '导入代码', '115', '2', '#', '', '', 1, 0, 'F', '0', '0', 'tool:gen:import', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1059', '预览代码', '115', '4', '#', '', '', 1, 0, 'F', '0', '0', 'tool:gen:preview', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1060', '生成代码', '115', '5', '#', '', '', 1, 0, 'F', '0', '0', 'tool:gen:code', '#', 103, 1, sysdate(), null, null, ''); --- oss相关按钮 -insert into sys_menu values('1600', '文件查询', '118', '1', '#', '', '', 1, 0, 'F', '0', '0', 'system:oss:query', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1601', '文件上传', '118', '2', '#', '', '', 1, 0, 'F', '0', '0', 'system:oss:upload', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1602', '文件下载', '118', '3', '#', '', '', 1, 0, 'F', '0', '0', 'system:oss:download', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1603', '文件删除', '118', '4', '#', '', '', 1, 0, 'F', '0', '0', 'system:oss:remove', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1620', '配置列表', '118', '5', '#', '', '', 1, 0, 'F', '0', '0', 'system:ossConfig:list', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1621', '配置添加', '118', '6', '#', '', '', 1, 0, 'F', '0', '0', 'system:ossConfig:add', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1622', '配置编辑', '118', '6', '#', '', '', 1, 0, 'F', '0', '0', 'system:ossConfig:edit', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1623', '配置删除', '118', '6', '#', '', '', 1, 0, 'F', '0', '0', 'system:ossConfig:remove', '#', 103, 1, sysdate(), null, null, ''); - --- 租户管理相关按钮 -insert into sys_menu values ('1606', '租户查询', '121', '1', '#', '', '', 1, 0, 'F', '0', '0', 'system:tenant:query', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values ('1607', '租户新增', '121', '2', '#', '', '', 1, 0, 'F', '0', '0', 'system:tenant:add', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values ('1608', '租户修改', '121', '3', '#', '', '', 1, 0, 'F', '0', '0', 'system:tenant:edit', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values ('1609', '租户删除', '121', '4', '#', '', '', 1, 0, 'F', '0', '0', 'system:tenant:remove', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values ('1610', '租户导出', '121', '5', '#', '', '', 1, 0, 'F', '0', '0', 'system:tenant:export', '#', 103, 1, sysdate(), null, null, ''); --- 租户套餐管理相关按钮 -insert into sys_menu values ('1611', '租户套餐查询', '122', '1', '#', '', '', 1, 0, 'F', '0', '0', 'system:tenantPackage:query', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values ('1612', '租户套餐新增', '122', '2', '#', '', '', 1, 0, 'F', '0', '0', 'system:tenantPackage:add', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values ('1613', '租户套餐修改', '122', '3', '#', '', '', 1, 0, 'F', '0', '0', 'system:tenantPackage:edit', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values ('1614', '租户套餐删除', '122', '4', '#', '', '', 1, 0, 'F', '0', '0', 'system:tenantPackage:remove', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values ('1615', '租户套餐导出', '122', '5', '#', '', '', 1, 0, 'F', '0', '0', 'system:tenantPackage:export', '#', 103, 1, sysdate(), null, null, ''); --- 客户端管理按钮 -insert into sys_menu values('1061', '客户端管理查询', '123', '1', '#', '', '', 1, 0, 'F', '0', '0', 'system:client:query', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1062', '客户端管理新增', '123', '2', '#', '', '', 1, 0, 'F', '0', '0', 'system:client:add', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1063', '客户端管理修改', '123', '3', '#', '', '', 1, 0, 'F', '0', '0', 'system:client:edit', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1064', '客户端管理删除', '123', '4', '#', '', '', 1, 0, 'F', '0', '0', 'system:client:remove', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1065', '客户端管理导出', '123', '5', '#', '', '', 1, 0, 'F', '0', '0', 'system:client:export', '#', 103, 1, sysdate(), null, null, ''); --- 测试菜单 -insert into sys_menu values('1500', '测试单表', '5', '1', 'demo', 'demo/demo/index', '', 1, 0, 'C', '0', '0', 'demo:demo:list', '#', 103, 1, sysdate(), null, null, '测试单表菜单'); -insert into sys_menu values('1501', '测试单表查询', '1500', '1', '#', '', '', 1, 0, 'F', '0', '0', 'demo:demo:query', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1502', '测试单表新增', '1500', '2', '#', '', '', 1, 0, 'F', '0', '0', 'demo:demo:add', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1503', '测试单表修改', '1500', '3', '#', '', '', 1, 0, 'F', '0', '0', 'demo:demo:edit', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1504', '测试单表删除', '1500', '4', '#', '', '', 1, 0, 'F', '0', '0', 'demo:demo:remove', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1505', '测试单表导出', '1500', '5', '#', '', '', 1, 0, 'F', '0', '0', 'demo:demo:export', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1506', '测试树表', '5', '1', 'tree', 'demo/tree/index', '', 1, 0, 'C', '0', '0', 'demo:tree:list', '#', 103, 1, sysdate(), null, null, '测试树表菜单'); -insert into sys_menu values('1507', '测试树表查询', '1506', '1', '#', '', '', 1, 0, 'F', '0', '0', 'demo:tree:query', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1508', '测试树表新增', '1506', '2', '#', '', '', 1, 0, 'F', '0', '0', 'demo:tree:add', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1509', '测试树表修改', '1506', '3', '#', '', '', 1, 0, 'F', '0', '0', 'demo:tree:edit', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1510', '测试树表删除', '1506', '4', '#', '', '', 1, 0, 'F', '0', '0', 'demo:tree:remove', '#', 103, 1, sysdate(), null, null, ''); -insert into sys_menu values('1511', '测试树表导出', '1506', '5', '#', '', '', 1, 0, 'F', '0', '0', 'demo:tree:export', '#', 103, 1, sysdate(), null, null, ''); - --- ---------------------------- --- 6、用户和角色关联表 用户N-1角色 --- ---------------------------- -create table sys_user_role ( - user_id bigint(20) not null comment '用户ID', - role_id bigint(20) not null comment '角色ID', - primary key(user_id, role_id) -) engine=innodb comment = '用户和角色关联表'; - --- ---------------------------- --- 初始化-用户和角色关联表数据 --- ---------------------------- -insert into sys_user_role values ('1', '1'); -insert into sys_user_role values ('3', '3'); -insert into sys_user_role values ('4', '4'); - --- ---------------------------- --- 7、角色和菜单关联表 角色1-N菜单 --- ---------------------------- -create table sys_role_menu ( - role_id bigint(20) not null comment '角色ID', - menu_id bigint(20) not null comment '菜单ID', - primary key(role_id, menu_id) -) engine=innodb comment = '角色和菜单关联表'; - --- ---------------------------- --- 初始化-角色和菜单关联表数据 --- ---------------------------- -insert into sys_role_menu values ('3', '1'); -insert into sys_role_menu values ('3', '5'); -insert into sys_role_menu values ('3', '100'); -insert into sys_role_menu values ('3', '101'); -insert into sys_role_menu values ('3', '102'); -insert into sys_role_menu values ('3', '103'); -insert into sys_role_menu values ('3', '104'); -insert into sys_role_menu values ('3', '105'); -insert into sys_role_menu values ('3', '106'); -insert into sys_role_menu values ('3', '107'); -insert into sys_role_menu values ('3', '108'); -insert into sys_role_menu values ('3', '118'); -insert into sys_role_menu values ('3', '123'); -insert into sys_role_menu values ('3', '130'); -insert into sys_role_menu values ('3', '131'); -insert into sys_role_menu values ('3', '132'); -insert into sys_role_menu values ('3', '133'); -insert into sys_role_menu values ('3', '500'); -insert into sys_role_menu values ('3', '501'); -insert into sys_role_menu values ('3', '1001'); -insert into sys_role_menu values ('3', '1002'); -insert into sys_role_menu values ('3', '1003'); -insert into sys_role_menu values ('3', '1004'); -insert into sys_role_menu values ('3', '1005'); -insert into sys_role_menu values ('3', '1006'); -insert into sys_role_menu values ('3', '1007'); -insert into sys_role_menu values ('3', '1008'); -insert into sys_role_menu values ('3', '1009'); -insert into sys_role_menu values ('3', '1010'); -insert into sys_role_menu values ('3', '1011'); -insert into sys_role_menu values ('3', '1012'); -insert into sys_role_menu values ('3', '1013'); -insert into sys_role_menu values ('3', '1014'); -insert into sys_role_menu values ('3', '1015'); -insert into sys_role_menu values ('3', '1016'); -insert into sys_role_menu values ('3', '1017'); -insert into sys_role_menu values ('3', '1018'); -insert into sys_role_menu values ('3', '1019'); -insert into sys_role_menu values ('3', '1020'); -insert into sys_role_menu values ('3', '1021'); -insert into sys_role_menu values ('3', '1022'); -insert into sys_role_menu values ('3', '1023'); -insert into sys_role_menu values ('3', '1024'); -insert into sys_role_menu values ('3', '1025'); -insert into sys_role_menu values ('3', '1026'); -insert into sys_role_menu values ('3', '1027'); -insert into sys_role_menu values ('3', '1028'); -insert into sys_role_menu values ('3', '1029'); -insert into sys_role_menu values ('3', '1030'); -insert into sys_role_menu values ('3', '1031'); -insert into sys_role_menu values ('3', '1032'); -insert into sys_role_menu values ('3', '1033'); -insert into sys_role_menu values ('3', '1034'); -insert into sys_role_menu values ('3', '1035'); -insert into sys_role_menu values ('3', '1036'); -insert into sys_role_menu values ('3', '1037'); -insert into sys_role_menu values ('3', '1038'); -insert into sys_role_menu values ('3', '1039'); -insert into sys_role_menu values ('3', '1040'); -insert into sys_role_menu values ('3', '1041'); -insert into sys_role_menu values ('3', '1042'); -insert into sys_role_menu values ('3', '1043'); -insert into sys_role_menu values ('3', '1044'); -insert into sys_role_menu values ('3', '1045'); -insert into sys_role_menu values ('3', '1050'); -insert into sys_role_menu values ('3', '1061'); -insert into sys_role_menu values ('3', '1062'); -insert into sys_role_menu values ('3', '1063'); -insert into sys_role_menu values ('3', '1064'); -insert into sys_role_menu values ('3', '1065'); -insert into sys_role_menu values ('3', '1500'); -insert into sys_role_menu values ('3', '1501'); -insert into sys_role_menu values ('3', '1502'); -insert into sys_role_menu values ('3', '1503'); -insert into sys_role_menu values ('3', '1504'); -insert into sys_role_menu values ('3', '1505'); -insert into sys_role_menu values ('3', '1506'); -insert into sys_role_menu values ('3', '1507'); -insert into sys_role_menu values ('3', '1508'); -insert into sys_role_menu values ('3', '1509'); -insert into sys_role_menu values ('3', '1510'); -insert into sys_role_menu values ('3', '1511'); -insert into sys_role_menu values ('3', '1600'); -insert into sys_role_menu values ('3', '1601'); -insert into sys_role_menu values ('3', '1602'); -insert into sys_role_menu values ('3', '1603'); -insert into sys_role_menu values ('3', '1620'); -insert into sys_role_menu values ('3', '1621'); -insert into sys_role_menu values ('3', '1622'); -insert into sys_role_menu values ('3', '1623'); -insert into sys_role_menu values ('3', '11616'); -insert into sys_role_menu values ('3', '11618'); -insert into sys_role_menu values ('3', '11619'); -insert into sys_role_menu values ('3', '11622'); -insert into sys_role_menu values ('3', '11623'); -insert into sys_role_menu values ('3', '11629'); -insert into sys_role_menu values ('3', '11632'); -insert into sys_role_menu values ('3', '11633'); -insert into sys_role_menu values ('3', '11638'); -insert into sys_role_menu values ('3', '11639'); -insert into sys_role_menu values ('3', '11640'); -insert into sys_role_menu values ('3', '11641'); -insert into sys_role_menu values ('3', '11642'); -insert into sys_role_menu values ('3', '11643'); -insert into sys_role_menu values ('3', '11701'); -insert into sys_role_menu values ('4', '5'); -insert into sys_role_menu values ('4', '1500'); -insert into sys_role_menu values ('4', '1501'); -insert into sys_role_menu values ('4', '1502'); -insert into sys_role_menu values ('4', '1503'); -insert into sys_role_menu values ('4', '1504'); -insert into sys_role_menu values ('4', '1505'); -insert into sys_role_menu values ('4', '1506'); -insert into sys_role_menu values ('4', '1507'); -insert into sys_role_menu values ('4', '1508'); -insert into sys_role_menu values ('4', '1509'); -insert into sys_role_menu values ('4', '1510'); -insert into sys_role_menu values ('4', '1511'); - --- ---------------------------- --- 8、角色和部门关联表 角色1-N部门 --- ---------------------------- -create table sys_role_dept ( - role_id bigint(20) not null comment '角色ID', - dept_id bigint(20) not null comment '部门ID', - primary key(role_id, dept_id) -) engine=innodb comment = '角色和部门关联表'; - --- ---------------------------- --- 9、用户与岗位关联表 用户1-N岗位 --- ---------------------------- -create table sys_user_post -( - user_id bigint(20) not null comment '用户ID', - post_id bigint(20) not null comment '岗位ID', - primary key (user_id, post_id) -) engine=innodb comment = '用户与岗位关联表'; - --- ---------------------------- --- 初始化-用户与岗位关联表数据 --- ---------------------------- -insert into sys_user_post values ('1', '1'); - --- ---------------------------- --- 10、操作日志记录 --- ---------------------------- -create table sys_oper_log ( - oper_id bigint(20) not null comment '日志主键', - tenant_id varchar(20) default '000000' comment '租户编号', - title varchar(50) default '' comment '模块标题', - business_type int(2) default 0 comment '业务类型(0其它 1新增 2修改 3删除)', - method varchar(100) default '' comment '方法名称', - request_method varchar(10) default '' comment '请求方式', - operator_type int(1) default 0 comment '操作类别(0其它 1后台用户 2手机端用户)', - oper_name varchar(50) default '' comment '操作人员', - dept_name varchar(50) default '' comment '部门名称', - oper_url varchar(255) default '' comment '请求URL', - oper_ip varchar(128) default '' comment '主机地址', - oper_location varchar(255) default '' comment '操作地点', - oper_param varchar(4000) default '' comment '请求参数', - json_result varchar(4000) default '' comment '返回参数', - status int(1) default 0 comment '操作状态(0正常 1异常)', - error_msg varchar(4000) default '' comment '错误消息', - oper_time datetime comment '操作时间', - cost_time bigint(20) default 0 comment '消耗时间', - primary key (oper_id), - key idx_sys_oper_log_bt (business_type), - key idx_sys_oper_log_s (status), - key idx_sys_oper_log_ot (oper_time) -) engine=innodb comment = '操作日志记录'; - - --- ---------------------------- --- 11、字典类型表 --- ---------------------------- -create table sys_dict_type -( - dict_id bigint(20) not null comment '字典主键', - tenant_id varchar(20) default '000000' comment '租户编号', - dict_name varchar(100) default '' comment '字典名称', - dict_type varchar(100) default '' comment '字典类型', - create_dept bigint(20) default null comment '创建部门', - create_by bigint(20) default null comment '创建者', - create_time datetime comment '创建时间', - update_by bigint(20) default null comment '更新者', - update_time datetime comment '更新时间', - remark varchar(500) default null comment '备注', - primary key (dict_id), - unique (tenant_id, dict_type) -) engine=innodb comment = '字典类型表'; - -insert into sys_dict_type values(1, '000000', '用户性别', 'sys_user_sex', 103, 1, sysdate(), null, null, '用户性别列表'); -insert into sys_dict_type values(2, '000000', '菜单状态', 'sys_show_hide', 103, 1, sysdate(), null, null, '菜单状态列表'); -insert into sys_dict_type values(3, '000000', '系统开关', 'sys_normal_disable', 103, 1, sysdate(), null, null, '系统开关列表'); -insert into sys_dict_type values(6, '000000', '系统是否', 'sys_yes_no', 103, 1, sysdate(), null, null, '系统是否列表'); -insert into sys_dict_type values(7, '000000', '通知类型', 'sys_notice_type', 103, 1, sysdate(), null, null, '通知类型列表'); -insert into sys_dict_type values(8, '000000', '通知状态', 'sys_notice_status', 103, 1, sysdate(), null, null, '通知状态列表'); -insert into sys_dict_type values(9, '000000', '操作类型', 'sys_oper_type', 103, 1, sysdate(), null, null, '操作类型列表'); -insert into sys_dict_type values(10, '000000', '系统状态', 'sys_common_status', 103, 1, sysdate(), null, null, '登录状态列表'); -insert into sys_dict_type values(11, '000000', '授权类型', 'sys_grant_type', 103, 1, sysdate(), null, null, '认证授权类型'); -insert into sys_dict_type values(12, '000000', '设备类型', 'sys_device_type', 103, 1, sysdate(), null, null, '客户端设备类型'); - - --- ---------------------------- --- 12、字典数据表 --- ---------------------------- -create table sys_dict_data -( - dict_code bigint(20) not null comment '字典编码', - tenant_id varchar(20) default '000000' comment '租户编号', - dict_sort int(4) default 0 comment '字典排序', - dict_label varchar(100) default '' comment '字典标签', - dict_value varchar(100) default '' comment '字典键值', - dict_type varchar(100) default '' comment '字典类型', - css_class varchar(100) default null comment '样式属性(其他样式扩展)', - list_class varchar(100) default null comment '表格回显样式', - is_default char(1) default 'N' comment '是否默认(Y是 N否)', - create_dept bigint(20) default null comment '创建部门', - create_by bigint(20) default null comment '创建者', - create_time datetime comment '创建时间', - update_by bigint(20) default null comment '更新者', - update_time datetime comment '更新时间', - remark varchar(500) default null comment '备注', - primary key (dict_code) -) engine=innodb comment = '字典数据表'; - -insert into sys_dict_data values(1, '000000', 1, '男', '0', 'sys_user_sex', '', '', 'Y', 103, 1, sysdate(), null, null, '性别男'); -insert into sys_dict_data values(2, '000000', 2, '女', '1', 'sys_user_sex', '', '', 'N', 103, 1, sysdate(), null, null, '性别女'); -insert into sys_dict_data values(3, '000000', 3, '未知', '2', 'sys_user_sex', '', '', 'N', 103, 1, sysdate(), null, null, '性别未知'); -insert into sys_dict_data values(4, '000000', 1, '显示', '0', 'sys_show_hide', '', 'primary', 'Y', 103, 1, sysdate(), null, null, '显示菜单'); -insert into sys_dict_data values(5, '000000', 2, '隐藏', '1', 'sys_show_hide', '', 'danger', 'N', 103, 1, sysdate(), null, null, '隐藏菜单'); -insert into sys_dict_data values(6, '000000', 1, '正常', '0', 'sys_normal_disable', '', 'primary', 'Y', 103, 1, sysdate(), null, null, '正常状态'); -insert into sys_dict_data values(7, '000000', 2, '停用', '1', 'sys_normal_disable', '', 'danger', 'N', 103, 1, sysdate(), null, null, '停用状态'); -insert into sys_dict_data values(12, '000000', 1, '是', 'Y', 'sys_yes_no', '', 'primary', 'Y', 103, 1, sysdate(), null, null, '系统默认是'); -insert into sys_dict_data values(13, '000000', 2, '否', 'N', 'sys_yes_no', '', 'danger', 'N', 103, 1, sysdate(), null, null, '系统默认否'); -insert into sys_dict_data values(14, '000000', 1, '通知', '1', 'sys_notice_type', '', 'warning', 'Y', 103, 1, sysdate(), null, null, '通知'); -insert into sys_dict_data values(15, '000000', 2, '公告', '2', 'sys_notice_type', '', 'success', 'N', 103, 1, sysdate(), null, null, '公告'); -insert into sys_dict_data values(16, '000000', 1, '正常', '0', 'sys_notice_status', '', 'primary', 'Y', 103, 1, sysdate(), null, null, '正常状态'); -insert into sys_dict_data values(17, '000000', 2, '关闭', '1', 'sys_notice_status', '', 'danger', 'N', 103, 1, sysdate(), null, null, '关闭状态'); -insert into sys_dict_data values(29, '000000', 99, '其他', '0', 'sys_oper_type', '', 'info', 'N', 103, 1, sysdate(), null, null, '其他操作'); -insert into sys_dict_data values(18, '000000', 1, '新增', '1', 'sys_oper_type', '', 'info', 'N', 103, 1, sysdate(), null, null, '新增操作'); -insert into sys_dict_data values(19, '000000', 2, '修改', '2', 'sys_oper_type', '', 'info', 'N', 103, 1, sysdate(), null, null, '修改操作'); -insert into sys_dict_data values(20, '000000', 3, '删除', '3', 'sys_oper_type', '', 'danger', 'N', 103, 1, sysdate(), null, null, '删除操作'); -insert into sys_dict_data values(21, '000000', 4, '授权', '4', 'sys_oper_type', '', 'primary', 'N', 103, 1, sysdate(), null, null, '授权操作'); -insert into sys_dict_data values(22, '000000', 5, '导出', '5', 'sys_oper_type', '', 'warning', 'N', 103, 1, sysdate(), null, null, '导出操作'); -insert into sys_dict_data values(23, '000000', 6, '导入', '6', 'sys_oper_type', '', 'warning', 'N', 103, 1, sysdate(), null, null, '导入操作'); -insert into sys_dict_data values(24, '000000', 7, '强退', '7', 'sys_oper_type', '', 'danger', 'N', 103, 1, sysdate(), null, null, '强退操作'); -insert into sys_dict_data values(25, '000000', 8, '生成代码', '8', 'sys_oper_type', '', 'warning', 'N', 103, 1, sysdate(), null, null, '生成操作'); -insert into sys_dict_data values(26, '000000', 9, '清空数据', '9', 'sys_oper_type', '', 'danger', 'N', 103, 1, sysdate(), null, null, '清空操作'); -insert into sys_dict_data values(27, '000000', 1, '成功', '0', 'sys_common_status', '', 'primary', 'N', 103, 1, sysdate(), null, null, '正常状态'); -insert into sys_dict_data values(28, '000000', 2, '失败', '1', 'sys_common_status', '', 'danger', 'N', 103, 1, sysdate(), null, null, '停用状态'); -insert into sys_dict_data values(30, '000000', 0, '密码认证', 'password', 'sys_grant_type', 'el-check-tag', 'default', 'N', 103, 1, sysdate(), null, null, '密码认证'); -insert into sys_dict_data values(31, '000000', 0, '短信认证', 'sms', 'sys_grant_type', 'el-check-tag', 'default', 'N', 103, 1, sysdate(), null, null, '短信认证'); -insert into sys_dict_data values(32, '000000', 0, '邮件认证', 'email', 'sys_grant_type', 'el-check-tag', 'default', 'N', 103, 1, sysdate(), null, null, '邮件认证'); -insert into sys_dict_data values(33, '000000', 0, '小程序认证', 'xcx', 'sys_grant_type', 'el-check-tag', 'default', 'N', 103, 1, sysdate(), null, null, '小程序认证'); -insert into sys_dict_data values(34, '000000', 0, '三方登录认证', 'social', 'sys_grant_type', 'el-check-tag', 'default', 'N', 103, 1, sysdate(), null, null, '三方登录认证'); -insert into sys_dict_data values(35, '000000', 0, 'PC', 'pc', 'sys_device_type', '', 'default', 'N', 103, 1, sysdate(), null, null, 'PC'); -insert into sys_dict_data values(36, '000000', 0, '安卓', 'android', 'sys_device_type', '', 'default', 'N', 103, 1, sysdate(), null, null, '安卓'); -insert into sys_dict_data values(37, '000000', 0, 'iOS', 'ios', 'sys_device_type', '', 'default', 'N', 103, 1, sysdate(), null, null, 'iOS'); -insert into sys_dict_data values(38, '000000', 0, '小程序', 'xcx', 'sys_device_type', '', 'default', 'N', 103, 1, sysdate(), null, null, '小程序'); - - --- ---------------------------- --- 13、参数配置表 --- ---------------------------- -create table sys_config ( - config_id bigint(20) not null comment '参数主键', - tenant_id varchar(20) default '000000' comment '租户编号', - config_name varchar(100) default '' comment '参数名称', - config_key varchar(100) default '' comment '参数键名', - config_value varchar(500) default '' comment '参数键值', - config_type char(1) default 'N' comment '系统内置(Y是 N否)', - create_dept bigint(20) default null comment '创建部门', - create_by bigint(20) default null comment '创建者', - create_time datetime comment '创建时间', - update_by bigint(20) default null comment '更新者', - update_time datetime comment '更新时间', - remark varchar(500) default null comment '备注', - primary key (config_id) -) engine=innodb comment = '参数配置表'; - -insert into sys_config values(1, '000000', '主框架页-默认皮肤样式名称', 'sys.index.skinName', 'skin-blue', 'Y', 103, 1, sysdate(), null, null, '蓝色 skin-blue、绿色 skin-green、紫色 skin-purple、红色 skin-red、黄色 skin-yellow' ); -insert into sys_config values(2, '000000', '用户管理-账号初始密码', 'sys.user.initPassword', '123456', 'Y', 103, 1, sysdate(), null, null, '初始化密码 123456' ); -insert into sys_config values(3, '000000', '主框架页-侧边栏主题', 'sys.index.sideTheme', 'theme-dark', 'Y', 103, 1, sysdate(), null, null, '深色主题theme-dark,浅色主题theme-light' ); -insert into sys_config values(5, '000000', '账号自助-是否开启用户注册功能', 'sys.account.registerUser', 'false', 'Y', 103, 1, sysdate(), null, null, '是否开启注册用户功能(true开启,false关闭)'); -insert into sys_config values(11, '000000', 'OSS预览列表资源开关', 'sys.oss.previewListResource', 'true', 'Y', 103, 1, sysdate(), null, null, 'true:开启, false:关闭'); - - --- ---------------------------- --- 14、系统访问记录 --- ---------------------------- -create table sys_logininfor ( - info_id bigint(20) not null comment '访问ID', - tenant_id varchar(20) default '000000' comment '租户编号', - user_name varchar(50) default '' comment '用户账号', - client_key varchar(32) default '' comment '客户端', - device_type varchar(32) default '' comment '设备类型', - ipaddr varchar(128) default '' comment '登录IP地址', - login_location varchar(255) default '' comment '登录地点', - browser varchar(50) default '' comment '浏览器类型', - os varchar(50) default '' comment '操作系统', - status char(1) default '0' comment '登录状态(0成功 1失败)', - msg varchar(255) default '' comment '提示消息', - login_time datetime comment '访问时间', - primary key (info_id), - key idx_sys_logininfor_s (status), - key idx_sys_logininfor_lt (login_time) -) engine=innodb comment = '系统访问记录'; - - --- ---------------------------- --- 17、通知公告表 --- ---------------------------- -create table sys_notice ( - notice_id bigint(20) not null comment '公告ID', - tenant_id varchar(20) default '000000' comment '租户编号', - notice_title varchar(50) not null comment '公告标题', - notice_type char(1) not null comment '公告类型(1通知 2公告)', - notice_content longblob default null comment '公告内容', - status char(1) default '0' comment '公告状态(0正常 1关闭)', - create_dept bigint(20) default null comment '创建部门', - create_by bigint(20) default null comment '创建者', - create_time datetime comment '创建时间', - update_by bigint(20) default null comment '更新者', - update_time datetime comment '更新时间', - remark varchar(255) default null comment '备注', - primary key (notice_id) -) engine=innodb comment = '通知公告表'; - --- ---------------------------- --- 初始化-公告信息表数据 --- ---------------------------- -insert into sys_notice values('1', '000000', '温馨提醒:2018-07-01 新版本发布啦', '2', '新版本内容', '0', 103, 1, sysdate(), null, null, '管理员'); -insert into sys_notice values('2', '000000', '维护通知:2018-07-01 系统凌晨维护', '1', '维护内容', '0', 103, 1, sysdate(), null, null, '管理员'); - - --- ---------------------------- --- 18、代码生成业务表 --- ---------------------------- -create table gen_table ( - table_id bigint(20) not null comment '编号', - data_name varchar(200) default '' comment '数据源名称', - table_name varchar(200) default '' comment '表名称', - table_comment varchar(500) default '' comment '表描述', - sub_table_name varchar(64) default null comment '关联子表的表名', - sub_table_fk_name varchar(64) default null comment '子表关联的外键名', - class_name varchar(100) default '' comment '实体类名称', - tpl_category varchar(200) default 'crud' comment '使用的模板(crud单表操作 tree树表操作)', - package_name varchar(100) comment '生成包路径', - module_name varchar(30) comment '生成模块名', - business_name varchar(30) comment '生成业务名', - function_name varchar(50) comment '生成功能名', - function_author varchar(50) comment '生成功能作者', - gen_type char(1) default '0' comment '生成代码方式(0zip压缩包 1自定义路径)', - gen_path varchar(200) default '/' comment '生成路径(不填默认项目路径)', - options varchar(1000) comment '其它生成选项', - create_dept bigint(20) default null comment '创建部门', - create_by bigint(20) default null comment '创建者', - create_time datetime comment '创建时间', - update_by bigint(20) default null comment '更新者', - update_time datetime comment '更新时间', - remark varchar(500) default null comment '备注', - primary key (table_id) -) engine=innodb comment = '代码生成业务表'; - - --- ---------------------------- --- 19、代码生成业务表字段 --- ---------------------------- -create table gen_table_column ( - column_id bigint(20) not null comment '编号', - table_id bigint(20) comment '归属表编号', - column_name varchar(200) comment '列名称', - column_comment varchar(500) comment '列描述', - column_type varchar(100) comment '列类型', - java_type varchar(500) comment 'JAVA类型', - java_field varchar(200) comment 'JAVA字段名', - is_pk char(1) comment '是否主键(1是)', - is_increment char(1) comment '是否自增(1是)', - is_required char(1) comment '是否必填(1是)', - is_insert char(1) comment '是否为插入字段(1是)', - is_edit char(1) comment '是否编辑字段(1是)', - is_list char(1) comment '是否列表字段(1是)', - is_query char(1) comment '是否查询字段(1是)', - query_type varchar(200) default 'EQ' comment '查询方式(等于、不等于、大于、小于、范围)', - html_type varchar(200) comment '显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件)', - dict_type varchar(200) default '' comment '字典类型', - sort int comment '排序', - create_dept bigint(20) default null comment '创建部门', - create_by bigint(20) default null comment '创建者', - create_time datetime comment '创建时间', - update_by bigint(20) default null comment '更新者', - update_time datetime comment '更新时间', - primary key (column_id) -) engine=innodb comment = '代码生成业务表字段'; - --- ---------------------------- --- OSS对象存储表 --- ---------------------------- -create table sys_oss ( - oss_id bigint(20) not null comment '对象存储主键', - tenant_id varchar(20) default '000000' comment '租户编号', - file_name varchar(255) not null default '' comment '文件名', - original_name varchar(255) not null default '' comment '原名', - file_suffix varchar(10) not null default '' comment '文件后缀名', - url varchar(500) not null comment 'URL地址', - ext1 text default null comment '扩展字段', - create_dept bigint(20) default null comment '创建部门', - create_time datetime default null comment '创建时间', - create_by bigint(20) default null comment '上传人', - update_time datetime default null comment '更新时间', - update_by bigint(20) default null comment '更新人', - service varchar(20) not null default 'minio' comment '服务商', - primary key (oss_id) -) engine=innodb comment ='OSS对象存储表'; - --- ---------------------------- --- OSS对象存储动态配置表 --- ---------------------------- -create table sys_oss_config ( - oss_config_id bigint(20) not null comment '主键', - tenant_id varchar(20) default '000000'comment '租户编号', - config_key varchar(20) not null default '' comment '配置key', - access_key varchar(255) default '' comment 'accessKey', - secret_key varchar(255) default '' comment '秘钥', - bucket_name varchar(255) default '' comment '桶名称', - prefix varchar(255) default '' comment '前缀', - endpoint varchar(255) default '' comment '访问站点', - domain varchar(255) default '' comment '自定义域名', - is_https char(1) default 'N' comment '是否https(Y=是,N=否)', - region varchar(255) default '' comment '域', - access_policy char(1) not null default '1' comment '桶权限类型(0=private 1=public 2=custom)', - status char(1) default '1' comment '是否默认(0=是,1=否)', - ext1 varchar(255) default '' comment '扩展字段', - create_dept bigint(20) default null comment '创建部门', - create_by bigint(20) default null comment '创建者', - create_time datetime default null comment '创建时间', - update_by bigint(20) default null comment '更新者', - update_time datetime default null comment '更新时间', - remark varchar(500) default null comment '备注', - primary key (oss_config_id) -) engine=innodb comment='对象存储配置表'; - -insert into sys_oss_config values (1, '000000', 'minio', 'ruoyi', 'ruoyi123', 'ruoyi', '', '127.0.0.1:9000', '','N', '', '1' ,'0', '', 103, 1, sysdate(), 1, sysdate(), null); -insert into sys_oss_config values (2, '000000', 'qiniu', 'XXXXXXXXXXXXXXX', 'XXXXXXXXXXXXXXX', 'ruoyi', '', 's3-cn-north-1.qiniucs.com', '','N', '', '1' ,'1', '', 103, 1, sysdate(), 1, sysdate(), null); -insert into sys_oss_config values (3, '000000', 'aliyun', 'XXXXXXXXXXXXXXX', 'XXXXXXXXXXXXXXX', 'ruoyi', '', 'oss-cn-beijing.aliyuncs.com', '','N', '', '1' ,'1', '', 103, 1, sysdate(), 1, sysdate(), null); -insert into sys_oss_config values (4, '000000', 'qcloud', 'XXXXXXXXXXXXXXX', 'XXXXXXXXXXXXXXX', 'ruoyi-1240000000', '', 'cos.ap-beijing.myqcloud.com', '','N', 'ap-beijing', '1' ,'1', '', 103, 1, sysdate(), 1, sysdate(), null); -insert into sys_oss_config values (5, '000000', 'image', 'ruoyi', 'ruoyi123', 'ruoyi', 'image', '127.0.0.1:9000', '','N', '', '1' ,'1', '', 103, 1, sysdate(), 1, sysdate(), null); - --- ---------------------------- --- 系统授权表 --- ---------------------------- -create table sys_client ( - id bigint(20) not null comment 'id', - client_id varchar(64) default null comment '客户端id', - client_key varchar(32) default null comment '客户端key', - client_secret varchar(255) default null comment '客户端秘钥', - grant_type varchar(255) default null comment '授权类型', - device_type varchar(32) default null comment '设备类型', - active_timeout int(11) default 1800 comment 'token活跃超时时间', - timeout int(11) default 604800 comment 'token固定超时', - status char(1) default '0' comment '状态(0正常 1停用)', - del_flag char(1) default '0' comment '删除标志(0代表存在 1代表删除)', - create_dept bigint(20) default null comment '创建部门', - create_by bigint(20) default null comment '创建者', - create_time datetime default null comment '创建时间', - update_by bigint(20) default null comment '更新者', - update_time datetime default null comment '更新时间', - primary key (id) -) engine=innodb comment='系统授权表'; - -insert into sys_client values (1, 'e5cd7e4891bf95d1d19206ce24a7b32e', 'pc', 'pc123', 'password,social', 'pc', 1800, 604800, 0, 0, 103, 1, sysdate(), 1, sysdate()); -insert into sys_client values (2, '428a8310cd442757ae699df5d894f051', 'app', 'app123', 'password,sms,social', 'android', 1800, 604800, 0, 0, 103, 1, sysdate(), 1, sysdate()); - - -CREATE TABLE test_demo -( - id bigint(0) NOT NULL COMMENT '主键', - tenant_id varchar(20) NULL DEFAULT '000000' COMMENT '租户编号', - dept_id bigint(0) NULL DEFAULT NULL COMMENT '部门id', - user_id bigint(0) NULL DEFAULT NULL COMMENT '用户id', - order_num int(0) NULL DEFAULT 0 COMMENT '排序号', - test_key varchar(255) NULL DEFAULT NULL COMMENT 'key键', - value varchar(255) NULL DEFAULT NULL COMMENT '值', - version int(0) NULL DEFAULT 0 COMMENT '版本', - create_dept bigint(0) NULL DEFAULT NULL COMMENT '创建部门', - create_time datetime(0) NULL DEFAULT NULL COMMENT '创建时间', - create_by bigint(0) NULL DEFAULT NULL COMMENT '创建人', - update_time datetime(0) NULL DEFAULT NULL COMMENT '更新时间', - update_by bigint(0) NULL DEFAULT NULL COMMENT '更新人', - del_flag int(0) NULL DEFAULT 0 COMMENT '删除标志', - PRIMARY KEY (id) USING BTREE -) ENGINE = InnoDB COMMENT = '测试单表'; - -CREATE TABLE test_tree -( - id bigint(0) NOT NULL COMMENT '主键', - tenant_id varchar(20) NULL DEFAULT '000000' COMMENT '租户编号', - parent_id bigint(0) NULL DEFAULT 0 COMMENT '父id', - dept_id bigint(0) NULL DEFAULT NULL COMMENT '部门id', - user_id bigint(0) NULL DEFAULT NULL COMMENT '用户id', - tree_name varchar(255) NULL DEFAULT NULL COMMENT '值', - version int(0) NULL DEFAULT 0 COMMENT '版本', - create_dept bigint(0) NULL DEFAULT NULL COMMENT '创建部门', - create_time datetime(0) NULL DEFAULT NULL COMMENT '创建时间', - create_by bigint(0) NULL DEFAULT NULL COMMENT '创建人', - update_time datetime(0) NULL DEFAULT NULL COMMENT '更新时间', - update_by bigint(0) NULL DEFAULT NULL COMMENT '更新人', - del_flag int(0) NULL DEFAULT 0 COMMENT '删除标志', - PRIMARY KEY (id) USING BTREE -) ENGINE = InnoDB COMMENT = '测试树表'; - -INSERT INTO test_demo VALUES (1, '000000', 102, 4, 1, '测试数据权限', '测试', 0, 103, sysdate(), 1, NULL, NULL, 0); -INSERT INTO test_demo VALUES (2, '000000', 102, 3, 2, '子节点1', '111', 0, 103, sysdate(), 1, NULL, NULL, 0); -INSERT INTO test_demo VALUES (3, '000000', 102, 3, 3, '子节点2', '222', 0, 103, sysdate(), 1, NULL, NULL, 0); -INSERT INTO test_demo VALUES (4, '000000', 108, 4, 4, '测试数据', 'demo', 0, 103, sysdate(), 1, NULL, NULL, 0); -INSERT INTO test_demo VALUES (5, '000000', 108, 3, 13, '子节点11', '1111', 0, 103, sysdate(), 1, NULL, NULL, 0); -INSERT INTO test_demo VALUES (6, '000000', 108, 3, 12, '子节点22', '2222', 0, 103, sysdate(), 1, NULL, NULL, 0); -INSERT INTO test_demo VALUES (7, '000000', 108, 3, 11, '子节点33', '3333', 0, 103, sysdate(), 1, NULL, NULL, 0); -INSERT INTO test_demo VALUES (8, '000000', 108, 3, 10, '子节点44', '4444', 0, 103, sysdate(), 1, NULL, NULL, 0); -INSERT INTO test_demo VALUES (9, '000000', 108, 3, 9, '子节点55', '5555', 0, 103, sysdate(), 1, NULL, NULL, 0); -INSERT INTO test_demo VALUES (10, '000000', 108, 3, 8, '子节点66', '6666', 0, 103, sysdate(), 1, NULL, NULL, 0); -INSERT INTO test_demo VALUES (11, '000000', 108, 3, 7, '子节点77', '7777', 0, 103, sysdate(), 1, NULL, NULL, 0); -INSERT INTO test_demo VALUES (12, '000000', 108, 3, 6, '子节点88', '8888', 0, 103, sysdate(), 1, NULL, NULL, 0); -INSERT INTO test_demo VALUES (13, '000000', 108, 3, 5, '子节点99', '9999', 0, 103, sysdate(), 1, NULL, NULL, 0); - -INSERT INTO test_tree VALUES (1, '000000', 0, 102, 4, '测试数据权限', 0, 103, sysdate(), 1, NULL, NULL, 0); -INSERT INTO test_tree VALUES (2, '000000', 1, 102, 3, '子节点1', 0, 103, sysdate(), 1, NULL, NULL, 0); -INSERT INTO test_tree VALUES (3, '000000', 2, 102, 3, '子节点2', 0, 103, sysdate(), 1, NULL, NULL, 0); -INSERT INTO test_tree VALUES (4, '000000', 0, 108, 4, '测试树1', 0, 103, sysdate(), 1, NULL, NULL, 0); -INSERT INTO test_tree VALUES (5, '000000', 4, 108, 3, '子节点11', 0, 103, sysdate(), 1, NULL, NULL, 0); -INSERT INTO test_tree VALUES (6, '000000', 4, 108, 3, '子节点22', 0, 103, sysdate(), 1, NULL, NULL, 0); -INSERT INTO test_tree VALUES (7, '000000', 4, 108, 3, '子节点33', 0, 103, sysdate(), 1, NULL, NULL, 0); -INSERT INTO test_tree VALUES (8, '000000', 5, 108, 3, '子节点44', 0, 103, sysdate(), 1, NULL, NULL, 0); -INSERT INTO test_tree VALUES (9, '000000', 6, 108, 3, '子节点55', 0, 103, sysdate(), 1, NULL, NULL, 0); -INSERT INTO test_tree VALUES (10, '000000', 7, 108, 3, '子节点66', 0, 103, sysdate(), 1, NULL, NULL, 0); -INSERT INTO test_tree VALUES (11, '000000', 7, 108, 3, '子节点77', 0, 103, sysdate(), 1, NULL, NULL, 0); -INSERT INTO test_tree VALUES (12, '000000', 10, 108, 3, '子节点88', 0, 103, sysdate(), 1, NULL, NULL, 0); -INSERT INTO test_tree VALUES (13, '000000', 10, 108, 3, '子节点99', 0, 103, sysdate(), 1, NULL, NULL, 0);