diff --git a/structure.txt b/structure.txt deleted file mode 100644 index d2123b66..00000000 Binary files a/structure.txt and /dev/null differ diff --git a/WebSocket订阅机制审计报告.md b/zlt-business/device-center/src/main/resources/doc/WebSocket订阅机制审计报告.md similarity index 100% rename from WebSocket订阅机制审计报告.md rename to zlt-business/device-center/src/main/resources/doc/WebSocket订阅机制审计报告.md diff --git a/zlt-business/msg-center/src/main/resources/application.yml b/zlt-business/msg-center/src/main/resources/application.yml index 9c375267..6d9445ea 100644 --- a/zlt-business/msg-center/src/main/resources/application.yml +++ b/zlt-business/msg-center/src/main/resources/application.yml @@ -1,64 +1,65 @@ + 已配置在nacos中,此配置文件作废 # 消息中心配置文件 -spring: - datasource: - url: jdbc:mysql://${zlt.datasource.ip}/msg-center?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai - username: ${zlt.datasource.username} - password: ${zlt.datasource.password} - driver-class-name: com.mysql.cj.jdbc.Driver - -mybatis-plus: - mapper-locations: classpath:/mapper/*Mapper.xml - type-aliases-package: com.central.msg.model.entity - global-config: - db-config: - id-type: auto - -springdoc: - group-configs: - - group: 'default' - paths-to-match: '/**' - packages-to-scan: com.central.msg.controller - -knife4j: - enable: true - setting: - swagger-model-name: 消息中心接口文档 - -# 短信服务配置 -sms: - # 短信服务提供商: TENCENT(腾讯云) 或 ALIYUN(阿里云) - # 默认提供商,用于未指定提供商的接口 - provider: ${SMS_PROVIDER:TENCENT} - - # 腾讯云短信配置 - tencent: - # 腾讯云短信应用ID (在腾讯云短信控制台获取) - app-id: ${SMS_TENCENT_APP_ID:} - # 腾讯云SecretId (在腾讯云控制台获取) - secret-id: ${SMS_TENCENT_SECRET_ID:} - # 腾讯云SecretKey (在腾讯云控制台获取) - secret-key: ${SMS_TENCENT_SECRET_KEY:} - # 短信签名 (在腾讯云短信控制台配置) - sign-name: ${SMS_TENCENT_SIGN_NAME:} - # 验证码模板ID - verify-code-template-id: ${SMS_TENCENT_VERIFY_CODE_TEMPLATE_ID:} - - # 阿里云短信配置 - aliyun: - # 阿里云AccessKeyId (在阿里云控制台获取) - access-key-id: ${SMS_ALIYUN_ACCESS_KEY_ID:} - # 阿里云AccessKeySecret (在阿里云控制台获取) - access-key-secret: ${SMS_ALIYUN_ACCESS_KEY_SECRET:} - # 短信签名 (在阿里云短信控制台配置) - sign-name: ${SMS_ALIYUN_SIGN_NAME:} - # 验证码模板ID - verify-code-template-id: ${SMS_ALIYUN_VERIFY_CODE_TEMPLATE_ID:} - - # 是否保存短信发送记录到数据库 - save-log: ${SMS_SAVE_LOG:true} - -# 多租户配置 -zlt: - tenant: - enable: true +#spring: +# datasource: +# url: jdbc:mysql://${zlt.datasource.ip}/msg-center?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai +# username: ${zlt.datasource.username} +# password: ${zlt.datasource.password} +# driver-class-name: com.mysql.cj.jdbc.Driver +# +#mybatis-plus: +# mapper-locations: classpath:/mapper/*Mapper.xml +# type-aliases-package: com.central.msg.model.entity +# global-config: +# db-config: +# id-type: auto +# +#springdoc: +# group-configs: +# - group: 'default' +# paths-to-match: '/**' +# packages-to-scan: com.central.msg.controller +# +#knife4j: +# enable: true +# setting: +# swagger-model-name: 消息中心接口文档 +# +## 短信服务配置 +#sms: +# # 短信服务提供商: TENCENT(腾讯云) 或 ALIYUN(阿里云) +# # 默认提供商,用于未指定提供商的接口 +# provider: ${SMS_PROVIDER :TENCENT} +# +# # 腾讯云短信配置 +# tencent: +# # 腾讯云短信应用ID (在腾讯云短信控制台获取) +# app-id: 1401077992 +# # 腾讯云SecretId (在腾讯云控制台获取) +# secret-id: AKIDuiNrAF7mETXO5au1vgFbjfOuCIG3cx62 +# # 腾讯云SecretKey (在腾讯云控制台获取) +# secret-key: nMkvsb6OSJwQjphLlxxmQsAGF6kBGF3d +# # 短信签名 (在腾讯云短信控制台配置) +# sign-name: 北京高飞智航科技 +# # 验证码模板ID +# verify-code-template-id: 2589777 +# +# # 阿里云短信配置 +# aliyun: +# # 阿里云AccessKeyId (在阿里云控制台获取) +# access-key-id: LTAI5tS3aRqJ4Et55s1g3Bkw +# # 阿里云AccessKeySecret (在阿里云控制台获取) +# access-key-secret: 0A7SumjhpzRmHEhK5aOkcysLu3zAcq +# # 短信签名 (在阿里云短信控制台配置) +# sign-name: 阿里云短信测试 +# # 验证码模板ID +# verify-code-template-id: SMS_154950909 +# +# # 是否保存短信发送记录到数据库 +# save-log: ${SMS_SAVE_LOG:true} +# +## 多租户配置 +#zlt: +# tenant: +# enable: true diff --git a/zlt-business/user-center/src/main/java/com/central/user/controller/SysUserController.java b/zlt-business/user-center/src/main/java/com/central/user/controller/SysUserController.java index 0d4f8a41..9c3ea295 100644 --- a/zlt-business/user-center/src/main/java/com/central/user/controller/SysUserController.java +++ b/zlt-business/user-center/src/main/java/com/central/user/controller/SysUserController.java @@ -120,6 +120,18 @@ public class SysUserController { return appUserService.findByOpenId(openId); } + /** + * 通过手机号注册用户 + * + * @param mobile 手机号 + * @return 注册后的用户信息(包含openId) + */ + @PostMapping(value = "/users-anon/register/mobile") + @Operation(summary = "通过手机号注册用户") + public SysUser registerByMobile(@RequestParam("mobile") String mobile) throws Exception { + return appUserService.registerByMobile(mobile); + } + /** * 根据WxOpenId查询用户信息 * diff --git a/zlt-business/user-center/src/main/java/com/central/user/service/ISysUserService.java b/zlt-business/user-center/src/main/java/com/central/user/service/ISysUserService.java index 0540606f..d3800bea 100644 --- a/zlt-business/user-center/src/main/java/com/central/user/service/ISysUserService.java +++ b/zlt-business/user-center/src/main/java/com/central/user/service/ISysUserService.java @@ -116,4 +116,12 @@ public interface ISysUserService extends ISuperService { * @return 删除结果 */ boolean completelyDeleteUser(Long userId); + + /** + * 通过手机号注册用户 + * @param mobile 手机号 + * @return 注册后的用户信息(包含openId) + * @throws Exception 注册异常 + */ + SysUser registerByMobile(String mobile) throws Exception; } diff --git a/zlt-business/user-center/src/main/java/com/central/user/service/impl/SysUserServiceImpl.java b/zlt-business/user-center/src/main/java/com/central/user/service/impl/SysUserServiceImpl.java index 2cff3106..72687f37 100644 --- a/zlt-business/user-center/src/main/java/com/central/user/service/impl/SysUserServiceImpl.java +++ b/zlt-business/user-center/src/main/java/com/central/user/service/impl/SysUserServiceImpl.java @@ -449,4 +449,41 @@ public class SysUserServiceImpl extends SuperServiceImpl } return sysUserExcels; } + + @Override + @Transactional(rollbackFor = Exception.class) + public SysUser registerByMobile(String mobile) throws Exception { + // 先检查手机号是否已注册 + SysUser existUser = this.selectByMobile(mobile); + if (existUser != null) { + // 已存在,直接返回 + return existUser; + } + + // 生成openId(使用UUID) + String openId = java.util.UUID.randomUUID().toString().replace("-", ""); + + // 创建新用户 + SysUser sysUser = new SysUser(); + sysUser.setMobile(mobile); + sysUser.setUsername(mobile); // 使用手机号作为用户名 + sysUser.setOpenId(openId); + sysUser.setType(UserType.APP.name()); + sysUser.setPassword(passwordEncoder.encode(openId)); // 使用openId作为初始密码 + sysUser.setEnabled(Boolean.TRUE); + + String username = sysUser.getUsername(); + boolean result = super.saveOrUpdateIdempotency(sysUser, lock, + LOCK_KEY_USERNAME + username, + new QueryWrapper().eq("username", username), + username + "已存在"); + + if (result) { + log.info("通过手机号注册用户成功,mobile:{}, openId:{}", mobile, openId); + return sysUser; + } else { + log.error("通过手机号注册用户失败,mobile:{}", mobile); + return null; + } + } } diff --git a/zlt-commons/zlt-common-core/src/main/java/com/central/common/constant/ServiceNameConstants.java b/zlt-commons/zlt-common-core/src/main/java/com/central/common/constant/ServiceNameConstants.java index 4ce7a657..81acfbb4 100644 --- a/zlt-commons/zlt-common-core/src/main/java/com/central/common/constant/ServiceNameConstants.java +++ b/zlt-commons/zlt-common-core/src/main/java/com/central/common/constant/ServiceNameConstants.java @@ -24,4 +24,9 @@ public interface ServiceNameConstants { String FILE_SERVICE = "file-center"; String ORDER_SERVICE = "order-center"; + + /** + * 消息中心服务 + */ + String MSG_SERVICE = "msg-center"; } diff --git a/zlt-commons/zlt-common-core/src/main/java/com/central/common/feign/MsgCenterService.java b/zlt-commons/zlt-common-core/src/main/java/com/central/common/feign/MsgCenterService.java new file mode 100644 index 00000000..6cd02d04 --- /dev/null +++ b/zlt-commons/zlt-common-core/src/main/java/com/central/common/feign/MsgCenterService.java @@ -0,0 +1,45 @@ +package com.central.common.feign; + +import com.central.common.constant.ServiceNameConstants; +import com.central.common.feign.fallback.MsgCenterServiceFallbackFactory; +import com.central.common.model.Result; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * 消息中心服务 Feign客户端 + */ +@FeignClient(name = ServiceNameConstants.MSG_SERVICE, fallbackFactory = MsgCenterServiceFallbackFactory.class, dismiss404 = true) +public interface MsgCenterService { + + /** + * 发送验证码短信(使用默认服务商) + * + * @param phone 手机号 + * @param code 验证码 + * @return 发送结果 + */ + @PostMapping("/sms/send-verify-code") + Result sendVerifyCode(@RequestParam("phone") String phone, @RequestParam("code") String code); + + /** + * 发送验证码短信(使用腾讯云) + * + * @param phone 手机号 + * @param code 验证码 + * @return 发送结果 + */ + @PostMapping("/sms/tencent/send-verify-code") + Result sendTencentVerifyCode(@RequestParam("phone") String phone, @RequestParam("code") String code); + + /** + * 发送验证码短信(使用阿里云) + * + * @param phone 手机号 + * @param code 验证码 + * @return 发送结果 + */ + @PostMapping("/sms/aliyun/send-verify-code") + Result sendAliyunVerifyCode(@RequestParam("phone") String phone, @RequestParam("code") String code); +} diff --git a/zlt-commons/zlt-common-core/src/main/java/com/central/common/feign/UserService.java b/zlt-commons/zlt-common-core/src/main/java/com/central/common/feign/UserService.java index 67629ab4..2928f83c 100644 --- a/zlt-commons/zlt-common-core/src/main/java/com/central/common/feign/UserService.java +++ b/zlt-commons/zlt-common-core/src/main/java/com/central/common/feign/UserService.java @@ -8,6 +8,7 @@ import com.central.common.model.SysUser; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import java.util.List; @@ -91,4 +92,13 @@ public interface UserService { */ @GetMapping(value = "/tenant/hierarchy/son/tenantId", params = "tenantId") List getSonTenantIds(@RequestParam("tenantId") String tenantId); + + /** + * 通过手机号注册用户(返回用户信息,包含openId) + * + * @param mobile 手机号 + * @return 注册后的用户信息 + */ + @PostMapping(value = "/users-anon/register/mobile") + SysUser registerByMobile(@RequestParam("mobile") String mobile); } diff --git a/zlt-commons/zlt-common-core/src/main/java/com/central/common/feign/fallback/MsgCenterServiceFallbackFactory.java b/zlt-commons/zlt-common-core/src/main/java/com/central/common/feign/fallback/MsgCenterServiceFallbackFactory.java new file mode 100644 index 00000000..68cfb9d3 --- /dev/null +++ b/zlt-commons/zlt-common-core/src/main/java/com/central/common/feign/fallback/MsgCenterServiceFallbackFactory.java @@ -0,0 +1,35 @@ +package com.central.common.feign.fallback; + +import com.central.common.feign.MsgCenterService; +import com.central.common.model.Result; +import lombok.extern.slf4j.Slf4j; +import org.springframework.cloud.openfeign.FallbackFactory; + +/** + * MsgCenterService降级工厂 + */ +@Slf4j +public class MsgCenterServiceFallbackFactory implements FallbackFactory { + @Override + public MsgCenterService create(Throwable throwable) { + return new MsgCenterService() { + @Override + public Result sendVerifyCode(String phone, String code) { + log.error("发送验证码短信异常, phone:{}", phone, throwable); + return Result.failed("短信服务不可用"); + } + + @Override + public Result sendTencentVerifyCode(String phone, String code) { + log.error("发送腾讯云验证码短信异常, phone:{}", phone, throwable); + return Result.failed("腾讯云短信服务不可用"); + } + + @Override + public Result sendAliyunVerifyCode(String phone, String code) { + log.error("发送阿里云验证码短信异常, phone:{}", phone, throwable); + return Result.failed("阿里云短信服务不可用"); + } + }; + } +} diff --git a/zlt-commons/zlt-common-core/src/main/java/com/central/common/feign/fallback/UserServiceFallbackFactory.java b/zlt-commons/zlt-common-core/src/main/java/com/central/common/feign/fallback/UserServiceFallbackFactory.java index 0c5025aa..0aa96f07 100644 --- a/zlt-commons/zlt-common-core/src/main/java/com/central/common/feign/fallback/UserServiceFallbackFactory.java +++ b/zlt-commons/zlt-common-core/src/main/java/com/central/common/feign/fallback/UserServiceFallbackFactory.java @@ -89,6 +89,12 @@ public class UserServiceFallbackFactory implements FallbackFactory log.error("获取自己以及子孙租户列表异常:{}", tenantId, throwable); return Collections.emptyList(); } + + @Override + public SysUser registerByMobile(String mobile) { + log.error("通过手机号注册用户异常:{}", mobile, throwable); + return null; + } }; } } diff --git a/zlt-commons/zlt-common-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/zlt-commons/zlt-common-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 1d4b07f4..cbfb568f 100644 --- a/zlt-commons/zlt-common-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/zlt-commons/zlt-common-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1,2 +1,3 @@ com.central.common.feign.fallback.UserServiceFallbackFactory +com.central.common.feign.fallback.MsgCenterServiceFallbackFactory com.central.common.lock.LockAspect \ No newline at end of file diff --git a/third-party-aerial-photography-flow.md b/zlt-doc/third-party-aerial-photography-flow.md similarity index 100% rename from third-party-aerial-photography-flow.md rename to zlt-doc/third-party-aerial-photography-flow.md diff --git a/zlt-uaa/src/main/java/com/central/oauth/controller/LoginController.java b/zlt-uaa/src/main/java/com/central/oauth/controller/LoginController.java index 923832a3..67080f0a 100644 --- a/zlt-uaa/src/main/java/com/central/oauth/controller/LoginController.java +++ b/zlt-uaa/src/main/java/com/central/oauth/controller/LoginController.java @@ -1,8 +1,10 @@ package com.central.oauth.controller; import com.central.common.constant.SecurityConstants; +import com.central.common.feign.MsgCenterService; import com.central.common.model.CodeEnum; import com.central.common.model.Result; +import com.central.common.model.SysUser; import com.central.common.utils.RSAUtil; import com.central.common.utils.StringUtils; import com.central.oauth.model.Client; @@ -21,11 +23,14 @@ import com.central.oauth2.common.properties.SecurityProperties; import com.central.oauth2.common.token.OpenIdAuthenticationToken; import com.central.oauth2.common.token.TencentAuthenticationToken; import com.central.oauth2.common.util.AuthUtils; +import com.central.common.feign.UserService; +import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequestWrapper; import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Lazy; +import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.oauth2.core.AuthorizationGrantType; import org.springframework.security.oauth2.core.ClientAuthenticationMethod; @@ -48,6 +53,8 @@ import java.time.temporal.ChronoUnit; import java.util.HashMap; import java.util.Map; import java.util.Objects; +import java.util.Random; +import java.util.concurrent.TimeUnit; @Tag(name = "登录接口") @RestController @@ -86,6 +93,31 @@ public class LoginController { @Resource private UnifiedLogoutService unifiedLogoutService; + @Resource + private StringRedisTemplate stringRedisTemplate; + + @Resource + private MsgCenterService msgCenterService; + + @Resource + private UserService userService; + + /** + * 短信验证码Redis Key前缀 + */ + private static final String SMS_CODE_PREFIX = "sms:code:"; + + /** + * 短信验证码有效期(分钟) + */ + private static final long SMS_CODE_EXPIRE_MINUTES = 5; + + /** + * 短信服务商类型:tencent-腾讯云, aliyun-阿里云 + */ + @org.springframework.beans.factory.annotation.Value("${sms.provider:tencent}") + private String smsProvider; + @PostMapping(value = "/login") public Result> login(@RequestBody LoginReq req) { try { @@ -133,6 +165,148 @@ public class LoginController { } } + /** + * 发送手机验证码 + * + * @param mobile 手机号 + * @return 发送结果 + */ + @Operation(summary = "发送手机验证码") + @PostMapping(value = "/sendSmsCode") + public Result sendSmsCode(@RequestParam("mobile") String mobile) { + try { + // 1) 校验手机号格式 + if (StringUtils.isBlank(mobile) || !mobile.matches("^1[3-9]\\d{9}$")) { + return Result.failed("手机号格式不正确"); + } + + // 2) 检查是否频繁发送(防刷) + String redisKey = SMS_CODE_PREFIX + mobile; + String existCode = stringRedisTemplate.opsForValue().get(redisKey); + if (StringUtils.isNotBlank(existCode)) { + Long ttl = stringRedisTemplate.getExpire(redisKey, TimeUnit.SECONDS); + if (ttl != null && ttl > (SMS_CODE_EXPIRE_MINUTES - 1) * 60) { + return Result.failed("验证码发送过于频繁,请稍后再试"); + } + } + + // 3) 生成4位随机验证码 + String code = String.format("%04d", new Random().nextInt(10000)); + + // 4) 根据配置选择短信服务商发送短信 + Result sendResult; + if ("aliyun".equalsIgnoreCase(smsProvider)) { + log.info("使用阿里云发送验证码,mobile:{}", mobile); + sendResult = msgCenterService.sendAliyunVerifyCode(mobile, code); + } else { + // 默认使用腾讯云 + log.info("使用腾讯云发送验证码,mobile:{}", mobile); + sendResult = msgCenterService.sendTencentVerifyCode(mobile, code); + } + if (sendResult == null || sendResult.getResp_code() != 0) { + log.error("发送短信验证码失败,mobile:{}, result:{}", mobile, sendResult); + return Result.failed("短信发送失败,请稍后重试"); + } + + // 5) 发送成功后存入Redis,设置有效期 + stringRedisTemplate.opsForValue().set(redisKey, code, SMS_CODE_EXPIRE_MINUTES, TimeUnit.MINUTES); + log.info("短信验证码发送成功,mobile:{}", mobile); + + return Result.succeed("验证码发送成功"); + } catch (Exception e) { + log.error("发送短信验证码异常,mobile:{}", mobile, e); + return Result.failed("短信发送失败:" + e.getMessage()); + } + } + + /** + * 手机号验证码登录 + * + * @param mobile 手机号 + * @param smsCode 短信验证码 + * @param clientId 客户端ID + * @return 登录结果(token) + */ + @Operation(summary = "手机号验证码登录") + @PostMapping(value = "/loginBySmsCode") + public Result> loginBySmsCode( + @RequestParam("mobile") String mobile, + @RequestParam("smsCode") String smsCode, + @RequestParam("clientId") String clientId) { + try { + // 1) 校验参数 + if (StringUtils.isBlank(mobile) || !mobile.matches("^1[3-9]\\d{9}$")) { + return Result.failed("手机号格式不正确"); + } + if (StringUtils.isBlank(smsCode)) { + return Result.failed("验证码不能为空"); + } + if (StringUtils.isBlank(clientId)) { + return Result.failed("客户端ID不能为空"); + } + + // 2) 从Redis获取验证码并校验 + String redisKey = SMS_CODE_PREFIX + mobile; + String cachedCode = stringRedisTemplate.opsForValue().get(redisKey); + if (StringUtils.isBlank(cachedCode)) { + return Result.failed("验证码已过期,请重新获取"); + } + if (!cachedCode.equals(smsCode)) { + return Result.failed("验证码错误"); + } + + // 3) 验证码校验成功后删除 + stringRedisTemplate.delete(redisKey); + + // 4) 查询用户是否已注册 + SysUser sysUser = userService.findByMobile(mobile); + String openId; + if (sysUser == null || sysUser.getId() == null) { + // 用户不存在,先注册 + log.info("用户不存在,进行注册,mobile:{}", mobile); + SysUser newUser = userService.registerByMobile(mobile); + if (newUser == null || StringUtils.isBlank(newUser.getOpenId())) { + return Result.failed("用户注册失败,请重试"); + } + openId = newUser.getOpenId(); + log.info("用户注册成功,mobile:{}, openId:{}", mobile, openId); + } else { + // 用户已存在 + openId = sysUser.getOpenId(); + if (StringUtils.isBlank(openId)) { + return Result.failed("用户信息异常,缺少openId"); + } + log.info("用户已存在,直接登录,mobile:{}, openId:{}", mobile, openId); + } + + // 5) 使用openId进行登录 + LoginReq loginReq = new LoginReq(); + loginReq.setGrantType("openId"); + loginReq.setOpenId(openId); + loginReq.setClientId(clientId); + + // 6) 客户端校验 + Client client = clientService.loadClientByClientId(clientId); + if (client == null) { + return Result.failed("所属客户端不存在"); + } + RegisteredClient registeredClient = registeredClientRepository.findByClientId(client.getClientId()); + if (registeredClient == null) { + return Result.failed("未注册的客户端"); + } + AuthorizationGrantType grantTypeToUse = new AuthorizationGrantType("openId"); + if (!registeredClient.getAuthorizationGrantTypes().contains(grantTypeToUse)) { + return Result.failed("客户端未开通openId授权类型"); + } + + // 7) 颁发令牌 + return issueTokenInternally(loginReq, registeredClient, null); + } catch (Exception e) { + log.error("手机号验证码登录异常,mobile:{}", mobile, e); + return Result.failed("登录失败:" + e.getMessage()); + } + } + @PostMapping(value = "/logout") public Result logOut(HttpServletRequest request) { String token = AuthUtils.extractHeaderToken(request); diff --git a/zlt-uaa/src/main/resources/application.yml b/zlt-uaa/src/main/resources/application.yml index 37f321ae..9c9f3c8d 100644 --- a/zlt-uaa/src/main/resources/application.yml +++ b/zlt-uaa/src/main/resources/application.yml @@ -63,3 +63,5 @@ zlt: # 鍏煎榛樿琛ㄥ崟鐧诲綍涓庡唴缃櫥鍑? - /user/login - /oauth/remove/token + - /oauth/sendSmsCode + - /oauth/loginBySmsCode diff --git a/zlt-web/yingyan/REFACTOR_PLAN.md b/zlt-web/yingyan/REFACTOR_PLAN.md deleted file mode 100644 index c4927f8b..00000000 --- a/zlt-web/yingyan/REFACTOR_PLAN.md +++ /dev/null @@ -1,69 +0,0 @@ -# 通用大屏 → 无人机智慧城市管控平台(重构计划表) - -> 目标:在不改变现有功能与数据接口的前提下,把 `/dashboard` 的“通用监控大屏”升级为更符合“无人机赋能智慧城市”的首页大屏:维度更丰富、信息架构更清晰、视觉更高级、交互更顺手。 - -## 0. 约束与边界(必须遵守) -- 不改路由与入口:仍然使用 `/dashboard`,`进入监控视图` 仍然跳转 `/map3d?from=dashboard`。 -- 不改现有接口/聚合逻辑:继续使用 `src/services/dashboard.ts` 的 `getDeviceStats/getTaskStats/getTrendData` 等(允许新增“可选增强”接口或派生数据)。 -- 不影响海事行业:`/maritime` 不做联动修改(仅做必要的“命名展示”区分时除外)。 -- 无数据也要好看:任何新模块在数据缺失时要有优雅的“空态/占位”,避免空白或布局塌陷。 - -## 1. 目标体验(验收口径) -1. 首页一眼看懂:顶部为“城市态势总览”,中间为“数字孪生/空域态势”,两侧为“运行体征/事件处置”。 -2. 统计维度丰富:至少覆盖「设备运行」「任务执行」「城市网格治理」「AI识别事件」「环境/交通态势(可派生/可模拟)」五大类。 -3. 视觉统一:同一套色板、间距、描边、阴影、字体层级,避免“拼贴感”。 -4. 交互轻快:鼠标悬停、点击、筛选都有明确反馈;滚动区域可控且不抢焦点。 - -## 2. 信息架构与模块清单(Dashboard) - -### 2.1 顶部(Header) -- 平台命名:`无人机智慧城市管控平台` -- 状态条:当前租户/范围、在线率、告警等级概览、当前时间(若页面本身不显示则放入大屏 Header) -- 快捷入口:进入 3D 监控、任务/设备(保持现有入口,不新增强绑定) - -### 2.2 左侧(城市运行体征) -- 城市网格治理(Radar):巡检覆盖、问题发现、处置效率、复核通过、重点区域关注 -- 环境感知(Line/Gauge/Liquid):PM2.5、噪声、热源异常趋势(允许派生/模拟,但要“稳定”) -- 交通与人流(Area/Heatmap):拥堵指数趋势、重点区域热度 TopN - -### 2.3 中间(全域态势 / 数字孪生入口) -- 核心态势 KPI(数字+发光强调):城市安全指数、今日识别事件、平均响应时长、闭环率 -- 数字孪生入口卡(保留进入 `/map3d`):升级为更“城市中枢”风格,增加图层提示文案(电子围栏/事件点位/航线) -- AI抓拍与隐患快照(Carousel/卡片流):违停、烟火、占道、河道漂浮物、工地未戴帽等(点击可弹出详情抽屉/弹窗) - -### 2.4 右侧(事件处置与运行调度) -- 事件类型分布(Pie/RadialBar):按“城市治理事件”分类统计(与告警/任务派生映射) -- 实时事件流(List):分级(一般/重要/紧急)+ 来源(无人机/摄像头/机库)+ 处理状态(待确认/已派单/处理中/已闭环) -- 任务执行(保留原筛选逻辑):日/月/年切换 + 状态占比 + 近 7 日趋势 + 异常原因分析(原模块“换皮+换语义”) - -## 3. 数据策略(不改功能前提下“做出新维度”) - -### 3.1 直接复用(已有) -- 设备:`DeviceStats.total/online/offline/fault/byType/onlineRate` -- 任务:`TaskStats.pending/running/completed/failed/successRate/todayNew` -- 趋势:`getTrendData(7)`(现为模拟,后续可接真实接口) -- 告警:`getMockAlerts()`(现为模拟) - -### 3.2 派生增强(推荐落地) -- 城市安全指数:由 `告警数量/等级` + `任务成功率` + `在线率` 计算得到(可解释、可复现)。 -- 事件类型分布:把告警/任务映射到“城市治理事件”类别(如:离线→关键设施告警、低电→保障能力风险)。 -- 网格治理/环境/交通:使用“可复现的稳定模拟”(基于 tenantId + 日期 hash),保证刷新时不跳变、截图时稳定。 - -## 4. 设计系统(落地规则) -- 色板:以 `--accent-blue/green/yellow/red` 为主,新增 1~2 个辅助色(紫/青)但必须有统一用途。 -- 卡片:统一玻璃拟态 + 细描边 + 角落高光;标题区高度统一;内容区保持最小可视高度。 -- 字体层级:KPI 数字使用等宽/半等宽(更有“仪表感”);正文保持 12~13px,标题 14~15px。 -- 动效:只用“微动效”(呼吸光、扫光、hover 抬升),避免大幅炫技影响可读性。 - -## 5. 实施里程碑(建议按顺序做) - -| 里程碑 | 目标 | 产出 | 涉及文件(示例) | 验收点 | -|---|---|---|---|---| -| M1 | 结构拆分 + 新布局骨架 | `Dashboard` 拆组件、三栏网格稳定 | `src/pages/dashboard/index.tsx`、`src/pages/dashboard/index.less`、`src/pages/dashboard/components/*` | 1920×1080 无挤压、无滚动条乱跳 | -| M2 | 智慧城市模块落地 | 城市 KPI/网格治理/环境交通/AI快照 | `src/services/dashboard.ts`(新增派生/稳定模拟)、`src/pages/dashboard/components/*` | 统计维度明显增加,空态不丑 | -| M3 | 视觉与交互精修 | 统一色板、排版、hover、空态、细节 | `src/global.less`(少量)、`src/pages/dashboard/*` | 一致性强、截图“像产品” | -| M4(可选) | 设备操控页 HUD 化 | 不改控制逻辑,只换布局与皮肤 |(按现有控制页位置确定)| 操控入口/功能不变、观感升级 | - -## 6. 风险与回退 -- 风险:新增模块依赖“模拟/派生数据”可能被误认为真实数据;处理:在不显眼处提供“数据口径说明”(抽屉/帮助提示)。 -- 回退:保留原统计卡片/图表配置为独立组件,可随时切回(通过组件替换,不删代码)。 diff --git a/zlt-web/yingyan/dist.zip b/zlt-web/yingyan/dist.zip index 4e88893f..718a0582 100644 Binary files a/zlt-web/yingyan/dist.zip and b/zlt-web/yingyan/dist.zip differ diff --git a/zlt-web/yingyan/src/layouts/BlankLayout.less b/zlt-web/yingyan/src/layouts/BlankLayout.less index abe9ff75..1fca8654 100644 --- a/zlt-web/yingyan/src/layouts/BlankLayout.less +++ b/zlt-web/yingyan/src/layouts/BlankLayout.less @@ -601,6 +601,7 @@ } .blank-content--maritime { + /* 参考智慧城市大屏:用明确高度约束内容区,保证子 Grid 的 fr 高度计算为“确定值”,避免卡片把容器撑高导致后续面板被裁剪 */ height: calc(100vh - 88px); height: calc(100dvh - 88px); overflow: hidden; diff --git a/zlt-web/yingyan/src/pages/maritime/dashboard/components/AnnualTrendCard.tsx b/zlt-web/yingyan/src/pages/maritime/dashboard/components/AnnualTrendCard.tsx new file mode 100644 index 00000000..2e7192d2 --- /dev/null +++ b/zlt-web/yingyan/src/pages/maritime/dashboard/components/AnnualTrendCard.tsx @@ -0,0 +1,186 @@ +import React from 'react'; +import { Card } from 'antd'; +import { BarChartOutlined } from '@ant-design/icons'; +import { Area, Column } from '@ant-design/plots'; + +interface AnnualTrendCardProps { + annualData: any[]; + taskTypeData: any[]; +} + +const AnnualTrendCard: React.FC = ({ annualData, taskTypeData }) => { + const areaConfig: any = { + data: annualData, + xField: 'month', + yField: 'value', + seriesField: 'type', + color: ['#00b4d8', '#00e5a0'], + areaStyle: { fillOpacity: 0.3 }, + line: { + style: { lineWidth: 2 }, + }, + point: { + size: 3, + shape: 'circle', + style: { + fill: '#fff', + stroke: '#00b4d8', + lineWidth: 2, + }, + }, + xAxis: { + label: { + style: { fill: 'rgba(200,230,255,0.75)', fontSize: 11 }, + }, + line: { + style: { stroke: 'rgba(0,180,216,0.2)' }, + }, + tickLine: null, + }, + yAxis: { + label: { + style: { fill: 'rgba(200,230,255,0.75)', fontSize: 11 }, + }, + grid: { + line: { style: { stroke: 'rgba(0,150,200,0.15)', lineDash: [4, 4] } }, + }, + line: null, + tickLine: null, + }, + legend: { + position: 'top', + itemName: { + style: { fill: 'rgba(200,230,255,0.85)', fontSize: 12, fontWeight: 600 }, + }, + marker: { + symbol: 'circle', + style: { r: 4 }, + }, + itemSpacing: 16, + }, + smooth: true, + animation: { + appear: { + animation: 'wave-in', + duration: 1000, + }, + }, + tooltip: { + showMarkers: true, + marker: { + fill: '#00b4d8', + }, + domStyles: { + 'g2-tooltip': { + background: 'rgba(10, 30, 50, 0.95)', + boxShadow: '0 4px 12px rgba(0,0,0,0.3)', + border: '1px solid rgba(0,180,216,0.3)', + }, + 'g2-tooltip-title': { + color: 'rgba(200,230,255,0.95)', + }, + 'g2-tooltip-list-item': { + color: 'rgba(200,230,255,0.85)', + }, + }, + }, + autoFit: true, + }; + + const columnConfig: any = { + data: taskTypeData, + xField: 'type', + yField: 'value', + seriesField: 'type', + color: ({ type }: any) => { + if (type === '航线巡检') return '#00b4d8'; + if (type === '定点监测') return '#00e5a0'; + return '#ff9f43'; + }, + columnStyle: { + radius: [6, 6, 0, 0], + }, + label: { + text: (datum: any) => datum?.value?.toString() || '0', + style: { + fill: '#fff', + fontSize: 12, + fontWeight: 600, + textAlign: 'center', + }, + position: 'top', + offset: 8, + }, + xAxis: { + label: { + style: { fill: 'rgba(200,230,255,0.75)', fontSize: 11 }, + }, + line: { + style: { stroke: 'rgba(0,180,216,0.2)' }, + }, + tickLine: null, + }, + yAxis: { + label: { + style: { fill: 'rgba(200,230,255,0.75)', fontSize: 11 }, + }, + grid: { + line: { style: { stroke: 'rgba(0,150,200,0.15)', lineDash: [4, 4] } }, + }, + line: null, + tickLine: null, + }, + legend: false, + animation: { + appear: { + animation: 'scale-in-y', + duration: 800, + }, + }, + tooltip: { + domStyles: { + 'g2-tooltip': { + background: 'rgba(10, 30, 50, 0.95)', + boxShadow: '0 4px 12px rgba(0,0,0,0.3)', + border: '1px solid rgba(0,180,216,0.3)', + }, + 'g2-tooltip-title': { + color: 'rgba(200,230,255,0.95)', + }, + 'g2-tooltip-list-item': { + color: 'rgba(200,230,255,0.85)', + }, + }, + }, + autoFit: true, + }; + + return ( + + 年度巡检任务趋势与任务类型 + + } + className="maritime-card" + size="small" + > +
+
+
年度巡检趋势
+
+ +
+
+
+
任务类型统计
+
+ +
+
+
+
+ ); +}; + +export default AnnualTrendCard; diff --git a/zlt-web/yingyan/src/pages/maritime/dashboard/components/AnnualTrendChart.tsx b/zlt-web/yingyan/src/pages/maritime/dashboard/components/AnnualTrendChart.tsx new file mode 100644 index 00000000..eecc1743 --- /dev/null +++ b/zlt-web/yingyan/src/pages/maritime/dashboard/components/AnnualTrendChart.tsx @@ -0,0 +1,116 @@ +import React from 'react'; +import { Card } from 'antd'; +import { LineChartOutlined } from '@ant-design/icons'; +import { Area } from '@ant-design/plots'; + +interface AnnualTrendChartProps { + annualData: any[]; +} + +const AnnualTrendChart: React.FC = ({ annualData }) => { + const areaConfig: any = { + data: annualData, + xField: 'month', + yField: 'value', + seriesField: 'type', + color: ['#00b4d8', '#00e5a0'], + appendPadding: [20, 10, 10, 10], + areaStyle: { fillOpacity: 0.25 }, + line: { + style: { lineWidth: 2 }, + }, + point: { + size: 2, + shape: 'circle', + style: { + fill: '#fff', + stroke: '#00b4d8', + lineWidth: 1.5, + }, + }, + xAxis: { + label: { + style: { fill: 'rgba(200,230,255,0.75)', fontSize: 10 }, + autoRotate: false, + autoHide: true, + }, + line: { + style: { stroke: 'rgba(0,180,216,0.2)' }, + }, + tickLine: null, + }, + yAxis: { + label: { + style: { fill: 'rgba(200,230,255,0.75)', fontSize: 10 }, + }, + grid: { + line: { style: { stroke: 'rgba(0,150,200,0.15)', lineDash: [4, 4] } }, + }, + line: null, + tickLine: null, + }, + legend: { + position: 'top-left', + offsetY: -5, + itemName: { + style: { fill: 'rgba(200,230,255,0.85)', fontSize: 11, fontWeight: 600 }, + }, + marker: { + symbol: 'circle', + style: { r: 3 }, + }, + itemSpacing: 12, + }, + smooth: true, + animation: { + appear: { + animation: 'wave-in', + duration: 1000, + }, + }, + tooltip: { + showMarkers: true, + marker: { + fill: '#00b4d8', + }, + domStyles: { + 'g2-tooltip': { + background: 'rgba(10, 30, 50, 0.95)', + boxShadow: '0 4px 12px rgba(0,0,0,0.3)', + border: '1px solid rgba(0,180,216,0.3)', + }, + 'g2-tooltip-title': { + color: 'rgba(200,230,255,0.95)', + }, + 'g2-tooltip-list-item': { + color: 'rgba(200,230,255,0.85)', + }, + }, + }, + autoFit: true, + }; + + return ( + + 年度巡检任务趋势 + + } + className="maritime-card" + size="small" + styles={{ + body: { + padding: '8px 8px 4px 8px', + overflow: 'visible', + }, + }} + > +
+ +
+
+ ); +}; + +export default AnnualTrendChart; diff --git a/zlt-web/yingyan/src/pages/maritime/dashboard/components/DeviceTypeCard.tsx b/zlt-web/yingyan/src/pages/maritime/dashboard/components/DeviceTypeCard.tsx new file mode 100644 index 00000000..94678a14 --- /dev/null +++ b/zlt-web/yingyan/src/pages/maritime/dashboard/components/DeviceTypeCard.tsx @@ -0,0 +1,106 @@ +import React from 'react'; +import { Card } from 'antd'; +import { AppstoreOutlined } from '@ant-design/icons'; +import { Pie } from '@ant-design/plots'; +import type { DeviceStats } from '@/services/dashboard'; + +interface DeviceTypeCardProps { + deviceStats: DeviceStats | null; +} + +const DeviceTypeCard: React.FC = ({ deviceStats }) => { + const usvTypeData = (deviceStats?.byType || [ + { name: '巡检型', count: 12 }, + { name: '监测型', count: 8 }, + { name: '救援型', count: 5 }, + { name: '测量型', count: 3 }, + ]).map(item => ({ name: item.name, count: item.count })); + + const pieConfig: any = { + data: usvTypeData, + angleField: 'count', + colorField: 'name', + radius: 0.7, + innerRadius: 0.5, + color: ['#00b4d8', '#0096c7', '#00e5a0', '#48cae4'], + appendPadding: [20, 10, 5, 10], + label: { + text: (datum: any) => { + const name = datum?.name || ''; + const count = datum?.count ?? 0; + const total = usvTypeData.reduce((sum, d) => sum + (d.count || 0), 0); + const percent = total > 0 ? ((count / total) * 100).toFixed(1) : 0; + return `${name}\n${percent}%`; + }, + style: { + fill: 'rgba(200,230,255,0.95)', + fontSize: 10, + fontWeight: 600, + textAlign: 'center', + }, + offset: 20, + }, + legend: { + position: 'bottom', + offsetY: -10, + itemValue: { + style: { fill: 'rgba(200,230,255,0.75)', fontSize: 10 } + }, + itemName: { + style: { fill: 'rgba(200,230,255,0.75)', fontSize: 10 } + }, + itemSpacing: 6, + layout: 'horizontal', + }, + statistic: { + title: { + style: { fontSize: 11, fill: 'rgba(200,230,255,0.65)' }, + content: '设备总数', + }, + content: { + style: { fontSize: 16, fontWeight: 'bold', fill: '#00e5a0' }, + formatter: () => { + const total = usvTypeData.reduce((sum, d) => sum + (d.count || 0), 0); + return `${total}`; + }, + }, + }, + autoFit: true, + }; + + return ( + + 设备类型分布 + + } + className="maritime-card" + size="small" + styles={{ + body: { + padding: 0, + display: 'flex', + flexDirection: 'column', + alignItems: 'center', + justifyContent: 'flex-start', + overflow: 'visible', + height: '100%', + }, + }} + > +
+ +
+
+ ); +}; + +export default DeviceTypeCard; diff --git a/zlt-web/yingyan/src/pages/maritime/dashboard/components/MaritimeAlertCard.tsx b/zlt-web/yingyan/src/pages/maritime/dashboard/components/MaritimeAlertCard.tsx new file mode 100644 index 00000000..08f205e8 --- /dev/null +++ b/zlt-web/yingyan/src/pages/maritime/dashboard/components/MaritimeAlertCard.tsx @@ -0,0 +1,58 @@ +import React from 'react'; +import { Card, List, Tag } from 'antd'; +import { WarningOutlined } from '@ant-design/icons'; +import dayjs from 'dayjs'; +import type { AlertItem } from '@/services/dashboard'; + +interface MaritimeAlertCardProps { + alerts: AlertItem[]; +} + +const getAlertColor = (level: string) => { + switch (level) { + case 'critical': return '#ff4757'; + case 'error': return '#ff9f43'; + case 'warning': return '#feca57'; + default: return '#54a0ff'; + } +}; + +const MaritimeAlertCard: React.FC = ({ alerts }) => { + return ( + + 实时告警 + + } + extra={LIVE} + className="maritime-card" + size="small" + > +
+ ( + +
+
+ {item.level.toUpperCase().slice(0, 1)} +
+
+
+ {item.deviceName || item.taskName} + {dayjs(item.timestamp).format('HH:mm')} +
+
{item.message}
+
+
+
+ )} + /> +
+
+ ); +}; + +export default MaritimeAlertCard; diff --git a/zlt-web/yingyan/src/pages/maritime/dashboard/components/MaritimeInsightCard.tsx b/zlt-web/yingyan/src/pages/maritime/dashboard/components/MaritimeInsightCard.tsx new file mode 100644 index 00000000..e79dd668 --- /dev/null +++ b/zlt-web/yingyan/src/pages/maritime/dashboard/components/MaritimeInsightCard.tsx @@ -0,0 +1,146 @@ +import React from 'react'; +import { Card, Tabs } from 'antd'; +import { FundOutlined } from '@ant-design/icons'; +import { Line, Pie, Rose } from '@ant-design/plots'; +import type { TaskStats, TrendItem } from '@/services/dashboard'; + +interface MaritimeInsightCardProps { + taskStats: TaskStats | null; + taskTrend: TrendItem[]; + violationAnalysisData: any[]; +} + +const MaritimeInsightCard: React.FC = ({ + taskStats, + taskTrend, + violationAnalysisData, +}) => { + // 任务趋势配置 + const taskTrendSeriesData = taskTrend.flatMap((t) => [ + { date: t.date, type: '下发', value: t.created || 0 }, + { date: t.date, type: '完成', value: t.completed || 0 }, + { date: t.date, type: '失败', value: t.failed || 0 }, + ]); + + const taskTrendConfig: any = { + data: taskTrendSeriesData, + xField: 'date', + yField: 'value', + seriesField: 'type', + smooth: true, + color: ['#00b4d8', '#00e5a0', '#ff9f43'], + areaStyle: { + fill: 'l(270) 0:#ffffff 0.5:#7ec2f3 1:#0077b6', + fillOpacity: 0.1, + }, + xAxis: { label: { style: { fill: 'rgba(200,230,255,0.65)' } }, grid: null }, + yAxis: { + label: { style: { fill: 'rgba(200,230,255,0.65)' } }, + grid: { line: { style: { stroke: 'rgba(0,150,200,0.1)' } } }, + }, + tooltip: { showMarkers: true }, + autoFit: true, + }; + + // 任务状态饼图配置 + const taskStatusPieConfig: any = { + data: [ + { name: '待执行', value: taskStats?.pending || 0 }, + { name: '执行中', value: taskStats?.running || 0 }, + { name: '已完成', value: taskStats?.completed || 0 }, + { name: '已失败', value: taskStats?.failed || 0 }, + ], + angleField: 'value', + colorField: 'name', + radius: 0.85, + innerRadius: 0.55, + color: ['#ffa502', '#00b4d8', '#00e5a0', '#ff6b6b'], + label: { + text: (datum: any) => { + const name = datum?.name || ''; + const value = datum?.value ?? 0; + const total = + (taskStats?.pending || 0) + + (taskStats?.running || 0) + + (taskStats?.completed || 0) + + (taskStats?.failed || 0); + const percent = total > 0 ? ((value / total) * 100).toFixed(1) : 0; + return `${name} ${percent}%`; + }, + style: { fill: 'rgba(200,230,255,0.85)', fontSize: 12, fontWeight: 600 }, + }, + legend: { + position: 'bottom', + itemValue: { style: { fill: 'rgba(200,230,255,0.75)' } }, + itemName: { style: { fill: 'rgba(200,230,255,0.75)' } }, + }, + autoFit: true, + }; + + // 违规分析玫瑰图配置 + const roseConfig: any = { + data: violationAnalysisData, + xField: 'type', + yField: 'value', + seriesField: 'type', + radius: 0.9, + color: ['#ff6b6b', '#ffa502', '#ff9f43', '#00b4d8', '#48cae4', '#90e0ef'], + label: { + text: (datum: any) => datum?.type || '', + style: { fill: '#fff', fontSize: 10 }, + }, + legend: { + position: 'bottom', + itemName: { style: { fill: 'rgba(200,230,255,0.75)' } }, + }, + autoFit: true, + }; + + return ( + + 综合分析洞察 + + } + className="maritime-card maritime-insight-card" + size="small" + > + + + + ), + }, + { + key: 'status', + label: '任务状态占比', + children: ( +
+ +
+ ), + }, + { + key: 'violation', + label: '违规类型分析', + children: ( +
+ +
+ ), + }, + ]} + /> +
+ ); +}; + +export default MaritimeInsightCard; diff --git a/zlt-web/yingyan/src/pages/maritime/dashboard/components/MaritimeKpiStrip.tsx b/zlt-web/yingyan/src/pages/maritime/dashboard/components/MaritimeKpiStrip.tsx new file mode 100644 index 00000000..9639e339 --- /dev/null +++ b/zlt-web/yingyan/src/pages/maritime/dashboard/components/MaritimeKpiStrip.tsx @@ -0,0 +1,77 @@ +import React from 'react'; +import { EnvironmentOutlined, RocketOutlined, PieChartOutlined } from '@ant-design/icons'; +import './maritime-card.less'; + +// 无人船图标组件 +const USVIcon = () => ( + + + +); + +interface MaritimeKpiStripProps { + deviceTotal: number; + seaAreaCount: number; + todayNew: number; + successRate: number; + taskNewLabel?: string; +} + +const MaritimeKpiStrip: React.FC = ({ + deviceTotal, + seaAreaCount, + todayNew, + successRate, + taskNewLabel = '当日任务', +}) => { + const kpis = [ + { + key: 'ship', + label: '设备总数', + value: deviceTotal, + icon: , + accent: 'ship', + }, + { + key: 'area', + label: '海域总数', + value: seaAreaCount, + icon: , + accent: 'anchor', + }, + { + key: 'task', + label: taskNewLabel, + value: todayNew, + icon: , + accent: 'alert', + }, + { + key: 'rate', + label: '执行成功率', + value: successRate, + unit: '%', + icon: , + accent: 'route', + }, + ]; + + return ( +
+ {kpis.map((kpi) => ( +
+
{kpi.icon}
+
+
{kpi.label}
+
+ {kpi.value} + {kpi.unit && {kpi.unit}} +
+
+
+ ))} +
+ ); +}; + +export default MaritimeKpiStrip; diff --git a/zlt-web/yingyan/src/pages/maritime/dashboard/components/PortStatusCard.tsx b/zlt-web/yingyan/src/pages/maritime/dashboard/components/PortStatusCard.tsx new file mode 100644 index 00000000..e18227a8 --- /dev/null +++ b/zlt-web/yingyan/src/pages/maritime/dashboard/components/PortStatusCard.tsx @@ -0,0 +1,81 @@ +import React, { useMemo } from 'react'; +import { Card } from 'antd'; +import { AimOutlined } from '@ant-design/icons'; +import type { DeviceStats, TaskStats, AlertItem } from '@/services/dashboard'; + +interface PortStatusCardProps { + deviceStats: DeviceStats | null; + taskStats: TaskStats | null; + alerts: AlertItem[]; +} + +const PortStatusCard: React.FC = ({ + deviceStats, + taskStats, + alerts, +}) => { + const portStatusData = useMemo(() => { + const totalShips = deviceStats?.total || 24; + const pendingTasks = taskStats?.pending || 6; + const runningTasks = taskStats?.running || 3; + const alertBase = alerts.length || 4; + const baseShips = Math.max(6, Math.round(totalShips / 3)); + + return [ + { + name: '东港枢纽', + ships: baseShips + 3, + tasks: pendingTasks + 2, + alerts: Math.max(1, Math.round(alertBase * 0.4)), + }, + { + name: '西湾港区', + ships: baseShips + 1, + tasks: Math.max(1, pendingTasks + 1), + alerts: Math.max(1, Math.round(alertBase * 0.3)), + }, + { + name: '南航道', + ships: Math.max(4, baseShips - 1), + tasks: Math.max(1, runningTasks + 1), + alerts: Math.max(0, Math.round(alertBase * 0.2)), + }, + ]; + }, [alerts.length, deviceStats, taskStats]); + + return ( + + 重点港口状态 + + } + className="maritime-card" + size="small" + > +
+ {portStatusData.map((item) => ( +
+
{item.name}
+
+
+
{item.ships}
+
在线船只
+
+
+
{item.tasks}
+
巡检任务
+
+
+
{item.alerts}
+
告警
+
+
+
+ ))} +
+
+ ); +}; + +export default PortStatusCard; diff --git a/zlt-web/yingyan/src/pages/maritime/dashboard/components/SeaAreaPortal.tsx b/zlt-web/yingyan/src/pages/maritime/dashboard/components/SeaAreaPortal.tsx new file mode 100644 index 00000000..3471c781 --- /dev/null +++ b/zlt-web/yingyan/src/pages/maritime/dashboard/components/SeaAreaPortal.tsx @@ -0,0 +1,28 @@ +import React from 'react'; +import { Button } from 'antd'; +import { CompassOutlined } from '@ant-design/icons'; +import { history } from 'umi'; + +const SeaAreaPortal: React.FC = () => { + const goTo3D = () => { + history.push('/map3d?from=maritime'); + }; + + return ( +
+
+
+
+
+ +

海域智慧巡检监控中心

+ +
+
+
+ ); +}; + +export default SeaAreaPortal; diff --git a/zlt-web/yingyan/src/pages/maritime/dashboard/components/TaskOverviewCard.tsx b/zlt-web/yingyan/src/pages/maritime/dashboard/components/TaskOverviewCard.tsx new file mode 100644 index 00000000..0da4c723 --- /dev/null +++ b/zlt-web/yingyan/src/pages/maritime/dashboard/components/TaskOverviewCard.tsx @@ -0,0 +1,185 @@ +import React, { useMemo } from 'react'; +import { Card, DatePicker, Segmented, Space, Progress } from 'antd'; +import { LineChartOutlined, RiseOutlined, FallOutlined } from '@ant-design/icons'; +import type { Dayjs } from 'dayjs'; +import type { TaskStats } from '@/services/dashboard'; + +interface TaskOverviewCardProps { + taskStats: TaskStats | null; + taskStatType: 'day' | 'month' | 'year'; + taskStatDate: Dayjs; + onStatTypeChange: (type: 'day' | 'month' | 'year') => void; + onDateChange: (date: Dayjs) => void; +} + +const TaskOverviewCard: React.FC = ({ + taskStats, + taskStatType, + taskStatDate, + onStatTypeChange, + onDateChange, +}) => { + const taskPeriodText = useMemo(() => { + if (taskStatType === 'day') return '当日'; + if (taskStatType === 'month') return '当月'; + return '当年'; + }, [taskStatType]); + + const datePickerFormat = useMemo(() => { + if (taskStatType === 'day') return 'YYYY-MM-DD'; + if (taskStatType === 'month') return 'YYYY-MM'; + return 'YYYY'; + }, [taskStatType]); + + // 计算额外统计数据 + const extraStats = useMemo(() => { + const total = (taskStats?.pending || 0) + (taskStats?.running || 0) + + (taskStats?.completed || 0) + (taskStats?.failed || 0); + const completed = taskStats?.completed || 0; + const failed = taskStats?.failed || 0; + const running = taskStats?.running || 0; + + // 模拟同比增长率 + const growthRate = Math.floor(Math.random() * 30) - 10; // -10% ~ +20% + + // 计算完成率 + const completionRate = total > 0 ? Math.round((completed / total) * 100) : 0; + + // 计算失败率 + const failureRate = total > 0 ? Math.round((failed / total) * 100) : 0; + + // 计算平均响应时间(分钟) + const avgResponseTime = Math.floor(Math.random() * 20) + 10; // 10-30分钟 + + return { + total, + growthRate, + completionRate, + failureRate, + avgResponseTime, + }; + }, [taskStats]); + + return ( + + {taskPeriodText}巡检任务概览 + + } + extra={ + + onStatTypeChange(v as any)} + /> + v && onDateChange(v)} + picker={taskStatType === 'day' ? 'date' : taskStatType} + allowClear={false} + format={datePickerFormat} + /> + + } + className="maritime-card" + size="small" + > + {/* 主要状态网格 */} +
+
+
{taskStats?.pending || 0}
+
待执行
+
+
+
{taskStats?.running || 0}
+
执行中
+
+
+
{taskStats?.completed || 0}
+
已完成
+
+
+
{taskStats?.failed || 0}
+
已失败
+
+
+ + {/* 成功率展示 */} +
+
{taskStats?.successRate || 0}%
+
{taskPeriodText}成功率
+
+ + {/* 新增:详细统计信息 */} +
+
+
+
+ 任务总量 + {extraStats.growthRate >= 0 ? ( + + ) : ( + + )} +
+
{extraStats.total}
+
= 0 ? '#00e5a0' : '#ff6b6b' }}> + 同比 {extraStats.growthRate >= 0 ? '+' : ''}{extraStats.growthRate}% +
+
+
+
平均响应
+
{extraStats.avgResponseTime}分
+
任务平均响应时间
+
+
+ + {/* 完成率和失败率进度条 */} +
+
+
+ 完成率 + {extraStats.completionRate}% +
+ +
+
+
+ 失败率 + {extraStats.failureRate}% +
+ +
+
+
+
+ ); +}; + +export default TaskOverviewCard; diff --git a/zlt-web/yingyan/src/pages/maritime/dashboard/components/TaskTypeChart.tsx b/zlt-web/yingyan/src/pages/maritime/dashboard/components/TaskTypeChart.tsx new file mode 100644 index 00000000..c92c9a68 --- /dev/null +++ b/zlt-web/yingyan/src/pages/maritime/dashboard/components/TaskTypeChart.tsx @@ -0,0 +1,105 @@ +import React from 'react'; +import { Card } from 'antd'; +import { BarChartOutlined } from '@ant-design/icons'; +import { Column } from '@ant-design/plots'; + +interface TaskTypeChartProps { + taskTypeData: any[]; +} + +const TaskTypeChart: React.FC = ({ taskTypeData }) => { + const columnConfig: any = { + data: taskTypeData, + xField: 'type', + yField: 'value', + seriesField: 'type', + appendPadding: [20, 10, 10, 10], + color: ({ type }: any) => { + if (type === '航线巡检') return '#00b4d8'; + if (type === '定点监测') return '#00e5a0'; + return '#ff9f43'; + }, + columnStyle: { + radius: [6, 6, 0, 0], + }, + label: { + text: (datum: any) => datum?.value?.toString() || '0', + style: { + fill: '#fff', + fontSize: 11, + fontWeight: 600, + textAlign: 'center', + }, + position: 'top', + offset: 6, + }, + xAxis: { + label: { + style: { fill: 'rgba(200,230,255,0.75)', fontSize: 10 }, + autoRotate: false, + autoHide: false, + }, + line: { + style: { stroke: 'rgba(0,180,216,0.2)' }, + }, + tickLine: null, + }, + yAxis: { + label: { + style: { fill: 'rgba(200,230,255,0.75)', fontSize: 10 }, + }, + grid: { + line: { style: { stroke: 'rgba(0,150,200,0.15)', lineDash: [4, 4] } }, + }, + line: null, + tickLine: null, + }, + legend: false, + animation: { + appear: { + animation: 'scale-in-y', + duration: 800, + }, + }, + tooltip: { + domStyles: { + 'g2-tooltip': { + background: 'rgba(10, 30, 50, 0.95)', + boxShadow: '0 4px 12px rgba(0,0,0,0.3)', + border: '1px solid rgba(0,180,216,0.3)', + }, + 'g2-tooltip-title': { + color: 'rgba(200,230,255,0.95)', + }, + 'g2-tooltip-list-item': { + color: 'rgba(200,230,255,0.85)', + }, + }, + }, + autoFit: true, + }; + + return ( + + 任务类型统计 + + } + className="maritime-card" + size="small" + styles={{ + body: { + padding: '8px 8px 4px 8px', + overflow: 'visible', + }, + }} + > +
+ +
+
+ ); +}; + +export default TaskTypeChart; diff --git a/zlt-web/yingyan/src/pages/maritime/dashboard/components/WeatherCard.tsx b/zlt-web/yingyan/src/pages/maritime/dashboard/components/WeatherCard.tsx new file mode 100644 index 00000000..b0b65d28 --- /dev/null +++ b/zlt-web/yingyan/src/pages/maritime/dashboard/components/WeatherCard.tsx @@ -0,0 +1,41 @@ +import React, { useMemo } from 'react'; +import { Card } from 'antd'; +import { + CloudOutlined, + CompassOutlined, + DashboardOutlined, + RiseOutlined, +} from '@ant-design/icons'; + +const WeatherCard: React.FC = () => { + const weatherMetrics = useMemo(() => ([ + { label: '风速', value: '4.6 m/s', icon: }, + { label: '浪高', value: '1.2 m', icon: }, + { label: '能见度', value: '7.8 km', icon: }, + { label: '潮位', value: '2.4 m', icon: }, + ]), []); + + return ( + + 海况与气象 + + } + className="maritime-card" + size="small" + > +
+ {weatherMetrics.map((item) => ( +
+
{item.icon}
+
{item.value}
+
{item.label}
+
+ ))} +
+
+ ); +}; + +export default WeatherCard; diff --git a/zlt-web/yingyan/src/pages/maritime/dashboard/components/index.tsx b/zlt-web/yingyan/src/pages/maritime/dashboard/components/index.tsx new file mode 100644 index 00000000..a0e6e179 --- /dev/null +++ b/zlt-web/yingyan/src/pages/maritime/dashboard/components/index.tsx @@ -0,0 +1,10 @@ +export { default as MaritimeKpiStrip } from './MaritimeKpiStrip'; +export { default as DeviceTypeCard } from './DeviceTypeCard'; +export { default as PortStatusCard } from './PortStatusCard'; +export { default as MaritimeAlertCard } from './MaritimeAlertCard'; +export { default as WeatherCard } from './WeatherCard'; +export { default as SeaAreaPortal } from './SeaAreaPortal'; +export { default as AnnualTrendChart } from './AnnualTrendChart'; +export { default as TaskTypeChart } from './TaskTypeChart'; +export { default as TaskOverviewCard } from './TaskOverviewCard'; +export { default as MaritimeInsightCard } from './MaritimeInsightCard'; diff --git a/zlt-web/yingyan/src/pages/maritime/dashboard/components/maritime-card.less b/zlt-web/yingyan/src/pages/maritime/dashboard/components/maritime-card.less new file mode 100644 index 00000000..63baa6a7 --- /dev/null +++ b/zlt-web/yingyan/src/pages/maritime/dashboard/components/maritime-card.less @@ -0,0 +1,623 @@ +/* 海事大屏组件样式 */ + +.maritime-card { + height: 100%; + min-height: 0; + max-height: 100%; + display: flex; + flex-direction: column; + background: rgba(14, 34, 64, 0.75) !important; + border: 1px solid rgba(0, 180, 216, 0.2) !important; + border-radius: 8px; + overflow: hidden; + backdrop-filter: blur(8px); + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); + + &::before { + content: ''; + position: absolute; + inset: 0; + pointer-events: none; + background: + linear-gradient(90deg, rgba(0, 180, 216, 0.5), transparent 50px) top left / 50px 2px no-repeat, + linear-gradient(180deg, rgba(0, 180, 216, 0.5), transparent 50px) top left / 2px 50px no-repeat, + linear-gradient(270deg, rgba(0, 180, 216, 0.5), transparent 50px) top right / 50px 2px no-repeat, + linear-gradient(180deg, rgba(0, 180, 216, 0.5), transparent 50px) top right / 2px 50px no-repeat, + linear-gradient(90deg, rgba(0, 180, 216, 0.5), transparent 50px) bottom left / 50px 2px no-repeat, + linear-gradient(0deg, rgba(0, 180, 216, 0.5), transparent 50px) bottom left / 2px 50px no-repeat, + linear-gradient(270deg, rgba(0, 180, 216, 0.5), transparent 50px) bottom right / 50px 2px no-repeat, + linear-gradient(0deg, rgba(0, 180, 216, 0.5), transparent 50px) bottom right / 2px 50px no-repeat; + opacity: 0.4; + } + + :global(.ant-card-head) { + min-height: 40px; + padding: 0 12px; + border-bottom: 1px solid rgba(0, 180, 216, 0.15); + flex: 0 0 auto; + } + + :global(.ant-card-body) { + flex: 1; + padding: 12px; + overflow: hidden; + position: relative; + display: flex; + flex-direction: column; + min-height: 0; + } +} + +/* KPI 指标条样式 */ +.maritime-kpi-strip { + display: grid; + grid-template-columns: repeat(4, 1fr); + gap: 12px; + width: 100%; + padding: 0; +} + +.maritime-kpi-tile { + display: flex; + align-items: center; + gap: 12px; + padding: 12px 16px; + border-radius: 8px; + background: rgba(14, 34, 64, 0.7); + border: 1px solid rgba(0, 180, 216, 0.18); + transition: all 0.3s ease; + + &:hover { + transform: translateY(-2px); + border-color: rgba(0, 180, 216, 0.35); + box-shadow: 0 6px 16px rgba(0, 180, 216, 0.15); + } + + &--ship .maritime-kpi-tile__icon { + color: #00b4d8; + background: rgba(0, 180, 216, 0.15); + } + + &--anchor .maritime-kpi-tile__icon { + color: #00e5a0; + background: rgba(0, 229, 160, 0.15); + } + + &--alert .maritime-kpi-tile__icon { + color: #ff9f43; + background: rgba(255, 159, 67, 0.15); + } + + &--route .maritime-kpi-tile__icon { + color: #48cae4; + background: rgba(72, 202, 228, 0.15); + } +} + +.maritime-kpi-tile__icon { + flex: 0 0 auto; + width: 40px; + height: 40px; + display: flex; + align-items: center; + justify-content: center; + font-size: 20px; + border-radius: 8px; +} + +.maritime-kpi-tile__info { + flex: 1; + min-width: 0; +} + +.maritime-kpi-tile__label { + font-size: 13px; + color: rgba(200, 230, 255, 0.75); + line-height: 1.3; +} + +.maritime-kpi-tile__value { + font-size: 24px; + font-weight: 800; + color: rgba(255, 255, 255, 0.95); + font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; + margin-top: 2px; + + small { + font-size: 16px; + font-weight: 700; + margin-left: 2px; + } +} + +/* 图表容器样式 */ +.maritime-chart-wrapper { + flex: 1; + width: 100%; + min-height: 0; + overflow: hidden; + + > div { + width: 100%; + height: 100%; + } + + :global(canvas) { + max-width: 100%; + max-height: 100%; + } +} + +/* 港口状态列表样式 */ +.port-status-list { + display: flex; + flex-direction: column; + gap: 12px; +} + +.port-item { + padding: 12px; + border-radius: 8px; + background: rgba(255, 255, 255, 0.03); + border: 1px solid rgba(0, 180, 216, 0.12); +} + +.port-name { + font-size: 14px; + font-weight: 600; + color: rgba(200, 230, 255, 0.92); + margin-bottom: 10px; +} + +.port-stats { + display: grid; + grid-template-columns: repeat(3, 1fr); + gap: 8px; + + .stat { + text-align: center; + + .num { + font-size: 20px; + font-weight: 800; + color: #00b4d8; + font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; + } + + .txt { + font-size: 11px; + color: rgba(200, 230, 255, 0.65); + margin-top: 4px; + } + } +} + +/* 告警列表样式 */ +.alert-list-container { + flex: 1; + min-height: 0; + overflow-y: auto; + overflow-x: hidden; + padding-right: 4px; + + &::-webkit-scrollbar { + width: 4px; + } + + &::-webkit-scrollbar-thumb { + background: rgba(0, 180, 216, 0.3); + border-radius: 2px; + } +} + +.maritime-alert-item { + padding: 10px 0 !important; + border-bottom: 1px solid rgba(0, 180, 216, 0.08) !important; + + .alert-row { + display: flex; + gap: 10px; + align-items: flex-start; + width: 100%; + } + + .alert-badge { + flex: 0 0 auto; + } + + .alert-content { + flex: 1; + min-width: 0; + } + + .alert-head { + display: flex; + justify-content: space-between; + gap: 10px; + margin-bottom: 4px; + } + + .alert-name { + font-size: 13px; + font-weight: 600; + color: rgba(200, 230, 255, 0.92); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + + .alert-time { + font-size: 12px; + color: rgba(200, 230, 255, 0.55); + font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; + } + + .alert-msg { + font-size: 12px; + color: rgba(200, 230, 255, 0.65); + line-height: 1.4; + } +} + +/* 天气面板样式 */ +.weather-panel { + display: grid; + grid-template-columns: repeat(2, 1fr); + gap: 12px; +} + +.weather-item { + display: flex; + flex-direction: column; + align-items: center; + padding: 16px 12px; + border-radius: 8px; + background: rgba(255, 255, 255, 0.03); + border: 1px solid rgba(0, 180, 216, 0.12); + transition: all 0.3s ease; + + &:hover { + background: rgba(255, 255, 255, 0.05); + border-color: rgba(0, 180, 216, 0.25); + } + + .weather-icon { + font-size: 28px; + color: #00b4d8; + margin-bottom: 8px; + } + + .weather-value { + font-size: 18px; + font-weight: 800; + color: rgba(255, 255, 255, 0.95); + font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; + margin-bottom: 4px; + } + + .weather-label { + font-size: 12px; + color: rgba(200, 230, 255, 0.65); + } +} + +/* 海域门户样式 */ +.sea-area-portal { + position: relative; + height: 100%; + min-height: 0; + background: rgba(14, 34, 64, 0.75); + border: 1px solid rgba(0, 180, 216, 0.2); + border-radius: 8px; + overflow: hidden; + display: flex; + align-items: center; + justify-content: center; + + .nautical-grid { + position: absolute; + inset: 0; + background-image: + linear-gradient(rgba(0, 180, 216, 0.12) 1px, transparent 1px), + linear-gradient(90deg, rgba(0, 180, 216, 0.12) 1px, transparent 1px); + background-size: 40px 40px; + opacity: 0.4; + } + + .compass-sweep { + position: absolute; + inset: 0; + background: radial-gradient(circle at center, rgba(0, 180, 216, 0.18), transparent 60%); + animation: pulse 3s ease-in-out infinite; + } + + .portal-content { + position: relative; + z-index: 2; + text-align: center; + } + + .portal-center { + display: flex; + flex-direction: column; + align-items: center; + } + + .portal-title { + font-size: 22px; + font-weight: 700; + color: rgba(255, 255, 255, 0.92); + margin-bottom: 20px; + text-shadow: 0 2px 8px rgba(0, 180, 216, 0.3); + } + + .portal-btn { + background: linear-gradient(135deg, #00b4d8, #0096c7); + border: none; + box-shadow: 0 4px 16px rgba(0, 180, 216, 0.3); + transition: all 0.3s ease; + + &:hover { + transform: translateY(-2px); + box-shadow: 0 6px 20px rgba(0, 180, 216, 0.4); + } + } +} + +@keyframes pulse { + 0%, 100% { opacity: 0.3; } + 50% { opacity: 0.5; } +} + +/* 面板分割样式 */ +.panel-split { + flex: 1; + min-height: 0; + display: grid; + grid-template-columns: 1fr 1fr; + gap: 12px; + overflow: hidden; +} + +.panel-section { + min-height: 0; + display: flex; + flex-direction: column; + overflow: hidden; +} + +.panel-subtitle { + margin: 0 0 8px; + font-size: 12px; + color: rgba(200, 230, 255, 0.65); + letter-spacing: 0.2px; + flex: 0 0 auto; +} + +/* 任务筛选器样式 */ +.task-filter { + :global(.ant-segmented) { + background: rgba(0, 180, 216, 0.08); + border: 1px solid rgba(0, 180, 216, 0.2); + } + + :global(.ant-segmented-item-label) { + color: rgba(200, 230, 255, 0.85); + font-size: 12px; + } + + :global(.ant-segmented-item-selected) { + background: rgba(0, 180, 216, 0.25) !important; + } + + :global(.ant-picker) { + background: rgba(0, 180, 216, 0.08); + border: 1px solid rgba(0, 180, 216, 0.2); + color: rgba(200, 230, 255, 0.85); + } + + :global(.ant-picker-input > input) { + color: rgba(200, 230, 255, 0.85); + font-size: 12px; + } + + :global(.ant-picker-suffix) { + color: rgba(200, 230, 255, 0.65); + } +} + +/* 船只状态网格 */ +.ship-status-grid { + display: grid; + grid-template-columns: repeat(4, 1fr); + gap: 12px; + margin-bottom: 16px; +} + +.ship-stat-box { + padding: 12px; + border-radius: 8px; + background: rgba(255, 255, 255, 0.03); + border: 1px solid rgba(0, 180, 216, 0.12); + text-align: center; + + .val { + font-size: 24px; + font-weight: 800; + font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; + margin-bottom: 4px; + + &.sailing { color: #ffa502; } + &.anchored { color: #00b4d8; } + &.docked { color: #00e5a0; } + &.warning { color: #ff6b6b; } + } + + .lbl { + font-size: 12px; + color: rgba(200, 230, 255, 0.65); + } +} + +/* 任务成功率 */ +.task-success { + padding: 16px; + border-radius: 8px; + background: linear-gradient(135deg, rgba(0, 229, 160, 0.12), rgba(0, 180, 216, 0.08)); + border: 1px solid rgba(0, 229, 160, 0.2); + text-align: center; + margin-bottom: 16px; + + .rate { + font-size: 32px; + font-weight: 900; + color: #00e5a0; + font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; + text-shadow: 0 2px 8px rgba(0, 229, 160, 0.3); + } + + .label { + font-size: 13px; + color: rgba(200, 230, 255, 0.75); + margin-top: 4px; + } +} + +/* 任务详细统计 */ +.task-detail-stats { + display: flex; + flex-direction: column; + gap: 12px; + + .stat-row { + display: grid; + grid-template-columns: 1fr 1fr; + gap: 12px; + } + + .stat-item { + padding: 12px; + border-radius: 8px; + background: rgba(255, 255, 255, 0.03); + border: 1px solid rgba(0, 180, 216, 0.12); + text-align: center; + + .stat-label { + font-size: 12px; + color: rgba(200, 230, 255, 0.65); + margin-bottom: 6px; + display: flex; + align-items: center; + justify-content: center; + } + + .stat-value { + font-size: 22px; + font-weight: 800; + color: #00b4d8; + font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; + margin-bottom: 4px; + + .stat-unit { + font-size: 12px; + margin-left: 2px; + color: rgba(200, 230, 255, 0.75); + } + } + + .stat-sub { + font-size: 11px; + color: rgba(200, 230, 255, 0.55); + } + } + + .progress-row { + display: flex; + flex-direction: column; + gap: 12px; + } + + .progress-item { + padding: 12px; + border-radius: 8px; + background: rgba(255, 255, 255, 0.03); + border: 1px solid rgba(0, 180, 216, 0.12); + + .progress-label { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 8px; + font-size: 12px; + color: rgba(200, 230, 255, 0.75); + + .progress-percent { + font-size: 13px; + font-weight: 700; + color: rgba(255, 255, 255, 0.85); + } + } + + :global(.ant-progress-bg) { + border-radius: 4px; + } + } +} + +/* Tabs 样式 */ +.maritime-tabs { + height: 100%; + min-height: 0; + display: flex; + flex-direction: column; + overflow: hidden; + + :global(.ant-tabs-nav) { + margin: 0 0 8px; + flex: 0 0 auto; + } + + :global(.ant-tabs-nav::before) { + border-bottom-color: rgba(0, 180, 216, 0.15); + } + + :global(.ant-tabs-tab) { + color: rgba(200, 230, 255, 0.65); + } + + :global(.ant-tabs-tab.ant-tabs-tab-active .ant-tabs-tab-btn) { + color: rgba(200, 230, 255, 0.95); + } + + :global(.ant-tabs-ink-bar) { + background: #00b4d8; + } + + :global(.ant-tabs-content-holder) { + flex: 1; + min-height: 0; + overflow: hidden; + } + + :global(.ant-tabs-content) { + height: 100%; + min-height: 0; + } + + :global(.ant-tabs-tabpane) { + height: 100%; + min-height: 0; + padding: 0; + overflow: hidden; + display: flex; + flex-direction: column; + } +} + +.maritime-insight-card { + :global(.ant-card-body) { + display: flex; + flex-direction: column; + min-height: 0; + } +} diff --git a/zlt-web/yingyan/src/pages/maritime/dashboard/index.less b/zlt-web/yingyan/src/pages/maritime/dashboard/index.less index 52b29ae8..de622f9d 100644 --- a/zlt-web/yingyan/src/pages/maritime/dashboard/index.less +++ b/zlt-web/yingyan/src/pages/maritime/dashboard/index.less @@ -1,6 +1,9 @@ /* 海事智慧监控服务平台 - 主题样式 */ /* 采用深海蓝色调 + 波浪动效 + 海事元素 - 区别于通用大屏 */ +/* 导入组件样式 */ +@import './components/maritime-card.less'; + .maritime-dashboard { position: relative; width: 100%; @@ -8,16 +11,17 @@ min-height: 0; min-width: 0; flex: 1; - font-size: clamp(12px, 1.1vh, 14px); - --mar-pad-x: clamp(12px, 1.4vw, 18px); - --mar-pad-y: clamp(10px, 1.2vh, 16px); - --mar-gap: clamp(10px, 1.2vh, 14px); - --mar-kpi-h: clamp(70px, 9vh, 85px); - --mar-card-head-h: clamp(36px, 4.4vh, 42px); - --mar-card-body-pad: clamp(8px, 1.1vh, 12px); - --mar-frame-h: clamp(18px, 2.6vh, 28px); - --mar-frame-gap: clamp(6px, 0.9vh, 12px); - --mar-map-min: clamp(240px, 33vh, 360px); + font-size: clamp(11px, 1.0vh, 13px); + --mar-pad-x: clamp(10px, 1.1vw, 14px); + --mar-pad-y: clamp(8px, 0.9vh, 12px); + --mar-gap: clamp(8px, 0.9vh, 12px); + --mar-kpi-h: clamp(62px, 7.2vh, 78px); + --mar-card-head-h: clamp(32px, 3.6vh, 38px); + --mar-card-body-pad: clamp(6px, 0.9vh, 10px); + --mar-frame-h: clamp(14px, 2.0vh, 20px); + --mar-frame-gap: clamp(4px, 0.6vh, 8px); + /* 重要:避免中心入口的 min-height 撑破网格,导致底部卡片被挤出屏幕 */ + --mar-map-min: 0px; background: linear-gradient(180deg, #020c1b 0%, #051525 25%, @@ -121,47 +125,50 @@ } .maritime-dashboard--compact-1 { - --mar-pad-x: clamp(10px, 1.1vw, 16px); - --mar-pad-y: clamp(8px, 1.0vh, 12px); - --mar-gap: clamp(8px, 1.0vh, 12px); - --mar-kpi-h: clamp(64px, 8vh, 78px); - --mar-card-head-h: clamp(34px, 4.0vh, 40px); - --mar-card-body-pad: clamp(6px, 0.9vh, 10px); - --mar-frame-h: clamp(16px, 2.2vh, 24px); - --mar-frame-gap: clamp(4px, 0.7vh, 10px); - --mar-map-min: clamp(220px, 30vh, 320px); + --mar-pad-x: clamp(8px, 0.95vw, 12px); + --mar-pad-y: clamp(6px, 0.75vh, 10px); + --mar-gap: clamp(6px, 0.75vh, 10px); + --mar-kpi-h: clamp(56px, 6.4vh, 70px); + --mar-card-head-h: clamp(30px, 3.2vh, 36px); + --mar-card-body-pad: clamp(6px, 0.75vh, 9px); + --mar-frame-h: clamp(12px, 1.8vh, 18px); + --mar-frame-gap: clamp(3px, 0.5vh, 7px); + --mar-map-min: 0px; } .maritime-dashboard--compact-2 { - --mar-pad-x: clamp(8px, 1.0vw, 14px); - --mar-pad-y: clamp(6px, 0.8vh, 10px); - --mar-gap: clamp(6px, 0.9vh, 10px); - --mar-kpi-h: clamp(58px, 7vh, 70px); - --mar-card-head-h: clamp(32px, 3.6vh, 38px); - --mar-card-body-pad: clamp(6px, 0.8vh, 9px); - --mar-frame-h: clamp(14px, 2.0vh, 22px); - --mar-frame-gap: clamp(4px, 0.6vh, 8px); - --mar-map-min: clamp(200px, 28vh, 300px); + --mar-pad-x: clamp(6px, 0.85vw, 10px); + --mar-pad-y: clamp(4px, 0.65vh, 8px); + --mar-gap: clamp(5px, 0.65vh, 8px); + --mar-kpi-h: clamp(52px, 6vh, 64px); + --mar-card-head-h: clamp(28px, 3.0vh, 34px); + --mar-card-body-pad: clamp(5px, 0.65vh, 8px); + --mar-frame-h: clamp(10px, 1.6vh, 16px); + --mar-frame-gap: clamp(3px, 0.45vh, 6px); + --mar-map-min: 0px; } /* 主内容区域 */ .maritime-spin { height: 100%; min-height: 0; - display: flex; + display: block; flex: 1; + width: 100%; :global(.ant-spin-container) { height: 100%; display: flex; flex-direction: column; min-height: 0; + width: 100%; } } .maritime-content { flex: 1; padding: var(--mar-pad-y) var(--mar-pad-x); - padding-bottom: calc(var(--mar-pad-y) + var(--mar-frame-h) + var(--mar-frame-gap)); + /* 参考智慧城市:底部装饰条保留但尽量少占内容区高度 */ + padding-bottom: calc(var(--mar-pad-y) + var(--mar-frame-h)); overflow: hidden; position: relative; z-index: 1; @@ -169,6 +176,8 @@ min-height: 0; display: flex; flex-direction: column; + width: 100%; + box-sizing: border-box; } .maritime-bottom-frame { @@ -212,23 +221,47 @@ .maritime-grid { display: grid; - grid-template-columns: minmax(0, 25%) minmax(0, 50%) minmax(0, 25%); + grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: var(--mar-gap); - height: 100%; + /* 只用 flex 约束高度,避免百分比高度在某些容器链路下变成不确定值 */ + flex: 1; width: 100%; min-height: 0; min-width: 0; - flex: 1; + justify-items: stretch; + align-items: stretch; } -.grid-col { - display: flex; - flex-direction: column; +.maritime-dashboard .grid-col { + display: grid; gap: var(--mar-gap); height: 100%; overflow: hidden; min-height: 0; + min-width: 0; + width: 100%; +} + +.maritime-dashboard .grid-col > * { + min-height: 0; + max-height: 100%; + overflow: hidden; +} + +.maritime-dashboard .grid-col.left-col { + /* 4张卡片:上两张偏“静态概览”稍矮,告警为主要信息流更高,海况为补充更矮 */ + grid-template-rows: minmax(0, 0.9fr) minmax(0, 0.85fr) minmax(0, 1.35fr) minmax(0, 0.55fr); +} + +.maritime-dashboard .grid-col.right-col { + /* 4张卡片:概览较高,其余三张均衡 */ + grid-template-rows: minmax(0, 1.15fr) minmax(0, 0.95fr) minmax(0, 1fr) minmax(0, 0.9fr); +} + +.maritime-dashboard .grid-col.center-col { + /* 参考智慧城市:固定 KPI + 其余区域按比例分配,避免底部卡片被挤出屏幕 */ + grid-template-rows: var(--mar-kpi-h) minmax(0, 1.35fr) minmax(0, 0.85fr); } /* 海事风格玻璃面板 */ @@ -269,14 +302,14 @@ :global(.ant-card-head) { min-height: var(--mar-card-head-h); - padding: 0 14px; + padding: 0 12px; border-bottom: 1px solid rgba(0, 180, 230, 0.15); background: linear-gradient(90deg, rgba(0, 100, 150, 0.2), transparent); .ant-card-head-title { - font-size: 15px; + font-size: 13px; color: #e0f7ff; - padding: 10px 0; + padding: 8px 0; letter-spacing: 1px; } } @@ -291,6 +324,49 @@ } } +.panel-block { + height: 100%; + min-height: 0; +} + +.panel-split { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: var(--mar-gap); + height: 100%; + min-height: 0; +} + +.panel-split--ratio { + grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr); +} + +.panel-stack { + display: grid; + grid-template-rows: repeat(2, minmax(0, 1fr)); + gap: var(--mar-gap); + height: 100%; + min-height: 0; +} + +.panel-stack--alert { + grid-template-rows: minmax(0, 1.3fr) minmax(0, 0.7fr); +} + +.panel-section { + display: flex; + flex-direction: column; + min-height: 0; + overflow: hidden; +} + +.panel-subtitle { + font-size: 12px; + color: rgba(200, 230, 255, 0.7); + letter-spacing: 1px; + margin-bottom: 6px; +} + .chart-wrapper { flex: 1; width: 100%; @@ -320,7 +396,7 @@ border-radius: 8px; display: flex; align-items: center; - padding: 0 16px; + padding: 0 12px; position: relative; overflow: hidden; @@ -336,10 +412,10 @@ } .kpi-icon { - font-size: 26px; - margin-right: 14px; - width: 46px; - height: 46px; + font-size: 22px; + margin-right: 10px; + width: 40px; + height: 40px; border-radius: 50%; display: flex; align-items: center; @@ -355,7 +431,7 @@ .kpi-info { .label { font-size: 12px; color: rgba(200, 230, 255, 0.7); } .value { - font-size: 26px; + font-size: 22px; font-weight: bold; color: #fff; font-family: 'Segoe UI', sans-serif; @@ -370,6 +446,7 @@ .map-portal-wrapper { flex: 2; min-height: var(--mar-map-min); + height: 100%; position: relative; background: linear-gradient(180deg, rgba(0, 40, 80, 0.5) 0%, rgba(0, 60, 100, 0.3) 100%); border: 1px solid rgba(0, 180, 230, 0.35); @@ -442,8 +519,8 @@ .portal-center { text-align: center; - width: 320px; - height: 320px; + width: clamp(240px, 16vw, 300px); + height: clamp(240px, 16vw, 300px); display: flex; flex-direction: column; align-items: center; @@ -474,16 +551,16 @@ .portal-title { color: #e0f7ff; - margin-bottom: 20px; - font-size: 20px; + margin-bottom: 14px; + font-size: 18px; letter-spacing: 3px; text-shadow: 0 0 15px rgba(0, 200, 255, 0.5); } .portal-btn { - height: 46px; - padding: 0 36px; - font-size: 15px; + height: 42px; + padding: 0 30px; + font-size: 14px; background: linear-gradient(135deg, #0096c7 0%, #0077b6 100%); border: none; box-shadow: 0 4px 20px rgba(0, 150, 200, 0.4); @@ -501,6 +578,8 @@ /* 告警列表 - 海事风格 */ .alert-list-container { + flex: 1; + min-height: 0; height: 100%; overflow-y: auto; @@ -576,11 +655,31 @@ } } +.task-success { + margin-top: 16px; + text-align: center; + + .rate { + font-size: 32px; + font-weight: bold; + color: #00e5a0; + } + + .label { + font-size: 14px; + color: #e0f7ff; + margin-top: 4px; + } +} + /* 气象信息面板 */ .weather-panel { display: flex; flex-wrap: wrap; gap: 12px; + flex: 1; + min-height: 0; + align-content: flex-start; .weather-item { flex: 1; @@ -613,6 +712,13 @@ /* 港口状态 */ .port-status-list { + display: flex; + flex-direction: column; + gap: 8px; + flex: 1; + min-height: 0; + overflow-y: auto; + .port-item { display: flex; align-items: center; @@ -620,7 +726,7 @@ padding: 10px 12px; background: rgba(0, 80, 120, 0.25); border-radius: 6px; - margin-bottom: 8px; + margin-bottom: 0; border-left: 3px solid #00b4d8; .port-name { @@ -724,9 +830,19 @@ } /* 响应式布局 */ -@media (max-width: 1400px) { +@media (max-width: 1680px) { .maritime-grid { - grid-template-columns: 28% 44% 28%; + grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.8fr) minmax(0, 1.1fr); + } +} + + + + + +@media (max-width: 1440px) { + .maritime-grid { + grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.6fr) minmax(0, 1.2fr); } } @@ -746,7 +862,10 @@ grid-template-rows: auto; } - .grid-col { + .maritime-dashboard .grid-col { + display: flex; + flex-direction: column; + gap: var(--mar-gap); height: auto; min-height: 400px; } diff --git a/zlt-web/yingyan/src/pages/maritime/dashboard/index.tsx b/zlt-web/yingyan/src/pages/maritime/dashboard/index.tsx index 322e279c..a90113f8 100644 --- a/zlt-web/yingyan/src/pages/maritime/dashboard/index.tsx +++ b/zlt-web/yingyan/src/pages/maritime/dashboard/index.tsx @@ -1,34 +1,22 @@ import React, { useState, useEffect, useCallback, useMemo } from 'react'; -import { Card, Button, List, Tag, Spin, message, DatePicker, Segmented, Space } from 'antd'; -import { - WarningOutlined, - RocketOutlined, - CompassOutlined, - PieChartOutlined, - EnvironmentOutlined, -} from '@ant-design/icons'; -import { Line, Pie, Column, Area, Rose } from '@ant-design/plots'; -import { history } from 'umi'; +import { Spin, message } from 'antd'; import dayjs from 'dayjs'; +import type { AlertItem, DeviceStats, TaskStats, TrendItem } from '@/services/dashboard'; +import { getDeviceStats, getTaskStats, getTrendData } from '@/services/dashboard'; import { - getDeviceStats, - getTaskStats, - getTrendData, - getMockAlerts, - DeviceStats, - TaskStats, - TrendItem, - AlertItem, -} from '@/services/dashboard'; + MaritimeKpiStrip, + DeviceTypeCard, + PortStatusCard, + MaritimeAlertCard, + WeatherCard, + SeaAreaPortal, + AnnualTrendChart, + TaskTypeChart, + TaskOverviewCard, + MaritimeInsightCard, +} from './components'; import './index.less'; -// 无人船图标组件 -const USVIcon = () => ( - - - -); - const MaritimeDashboard: React.FC = () => { const [loading, setLoading] = useState(true); const [deviceStats, setDeviceStats] = useState(null); @@ -42,19 +30,19 @@ const MaritimeDashboard: React.FC = () => { const [taskStatDate, setTaskStatDate] = useState(dayjs()); const [tenantId, setTenantId] = useState(); const [includeChildren, setIncludeChildren] = useState(true); - const [compactLevel, setCompactLevel] = useState<0 | 1 | 2>(0); - useEffect(() => { - const calc = () => { - const height = window?.innerHeight || 0; - const next: 0 | 1 | 2 = height <= 760 ? 2 : height <= 900 ? 1 : 0; - setCompactLevel(next); - }; - calc(); - window.addEventListener('resize', calc); - return () => window.removeEventListener('resize', calc); + // 海事专用告警数据 + const getMaritimeAlerts = useCallback((): AlertItem[] => { + return [ + { id: '1', type: 'device_fault', level: 'critical', deviceName: '巡检船-01', message: '检测到船只超速航行,航速28节', timestamp: new Date(Date.now() - 120000).toISOString() }, + { id: '2', type: 'device_offline', level: 'error', deviceName: '巡检船-03', message: '设备信号丢失超过10分钟', timestamp: new Date(Date.now() - 300000).toISOString() }, + { id: '3', type: 'task_failed', level: 'warning', taskName: '巡检任务#1024', message: '发现违规锚泊船只1艘', timestamp: new Date(Date.now() - 600000).toISOString() }, + { id: '4', type: 'low_battery', level: 'warning', deviceName: '巡检船-02', message: '电池电量低于20%', timestamp: new Date(Date.now() - 900000).toISOString() }, + { id: '5', type: 'task_failed', level: 'warning', taskName: '巡检任务#1023', message: '巡检完成,未发现违规', timestamp: new Date(Date.now() - 1200000).toISOString() }, + ]; }, []); + // 初始化模拟数据 useEffect(() => { // 模拟年度数据 const mockAnnual: any[] = []; @@ -90,6 +78,7 @@ const MaritimeDashboard: React.FC = () => { ]); }, []); + // 监听租户变化 useEffect(() => { const handler = (e: any) => { const nextTenantId = e?.detail?.tenantId as string | undefined; @@ -101,6 +90,7 @@ const MaritimeDashboard: React.FC = () => { return () => window.removeEventListener('tenant-change', handler as any); }, []); + // 获取数据 const fetchData = useCallback(async () => { setLoading(true); try { @@ -122,7 +112,6 @@ const MaritimeDashboard: React.FC = () => { setDeviceStats(deviceRes); setTaskStats(taskRes); setTaskTrend(trendRes.taskTrend); - // 模拟海事告警数据 setAlerts(getMaritimeAlerts()); } catch (error) { console.error('获取数据失败:', error); @@ -130,258 +119,36 @@ const MaritimeDashboard: React.FC = () => { } finally { setLoading(false); } - }, [includeChildren, taskStatDate, taskStatType, tenantId]); - - // 海事专用告警数据 - const getMaritimeAlerts = (): AlertItem[] => { - return [ - { id: '1', type: 'device_fault', level: 'critical', deviceName: '巡检船-01', message: '检测到船只超速航行,航速28节', timestamp: new Date(Date.now() - 120000).toISOString() }, - { id: '2', type: 'device_offline', level: 'error', deviceName: '巡检船-03', message: '设备信号丢失超过10分钟', timestamp: new Date(Date.now() - 300000).toISOString() }, - { id: '3', type: 'task_failed', level: 'warning', taskName: '巡检任务#1024', message: '发现违规锚泊船只1艘', timestamp: new Date(Date.now() - 600000).toISOString() }, - { id: '4', type: 'low_battery', level: 'warning', deviceName: '巡检船-02', message: '电池电量低于20%', timestamp: new Date(Date.now() - 900000).toISOString() }, - { id: '5', type: 'task_failed', level: 'warning', taskName: '巡检任务#1023', message: '巡检完成,未发现违规', timestamp: new Date(Date.now() - 1200000).toISOString() }, - ]; - }; + }, [getMaritimeAlerts, includeChildren, taskStatDate, taskStatType, tenantId]); + // 初始化和定时刷新数据 useEffect(() => { - if (!tenantId) return; fetchData(); - }, [fetchData]); - - // 定时刷新 - useEffect(() => { const dataTimer = setInterval(fetchData, 30000); return () => { clearInterval(dataTimer); }; }, [fetchData]); - const goTo3D = () => { - // 传递来源页面,以便从map3d返回时能回到正确的大屏 - history.push('/map3d?from=maritime'); - }; - - // --- 图表配置 --- - - const taskTrendSeriesData = useMemo(() => { - return taskTrend.flatMap((t) => [ - { date: t.date, type: '下发', value: t.created || 0 }, - { date: t.date, type: '完成', value: t.completed || 0 }, - { date: t.date, type: '失败', value: t.failed || 0 }, - ]); - }, [taskTrend]); - - // 近7日任务完成数趋势数据 - const taskCompleteTrendData = useMemo(() => { - return taskTrend.map((t) => ({ - date: t.date, - value: t.completed || 0, - })); - }, [taskTrend]); - - const chartHeights = useMemo(() => { - if (compactLevel === 2) { - return { - taskTrend: 140, - pie: 160, - column: 140, - taskComplete: 120, - area: 170, - rose: 160, - taskStatus: 150, - }; - } - if (compactLevel === 1) { - return { - taskTrend: 160, - pie: 180, - column: 160, - taskComplete: 140, - area: 190, - rose: 180, - taskStatus: 170, - }; - } - return { - taskTrend: 180, - pie: 200, - column: 180, - taskComplete: 160, - area: 220, - rose: 200, - taskStatus: 190, - }; - }, [compactLevel]); - - const taskTrendConfig: any = { - data: taskTrendSeriesData, - xField: 'date', - yField: 'value', - seriesField: 'type', - smooth: true, - color: ['#00b4d8', '#00e5a0', '#ff9f43'], - areaStyle: { - fill: 'l(270) 0:#ffffff 0.5:#7ec2f3 1:#0077b6', - fillOpacity: 0.1, - }, - xAxis: { label: { style: { fill: 'rgba(200,230,255,0.65)' } }, grid: null }, - yAxis: { label: { style: { fill: 'rgba(200,230,255,0.65)' } }, grid: { line: { style: { stroke: 'rgba(0,150,200,0.1)' } } } }, - tooltip: { showMarkers: true }, - height: chartHeights.taskTrend, - }; - - // 设备类型分布 - 模拟数据 - const usvTypeData: { name: string; count: number }[] = useMemo(() => { - return (deviceStats?.byType || [ - { name: '巡检型', count: 12 }, - { name: '监测型', count: 8 }, - { name: '救援型', count: 5 }, - { name: '测量型', count: 3 }, - ]).map(item => ({ name: item.name, count: item.count })); - }, [deviceStats]); - - const pieConfig: any = { - data: usvTypeData, - angleField: 'count', - colorField: 'name', - radius: 0.7, - innerRadius: 0.5, - color: ['#00b4d8', '#0096c7', '#00e5a0', '#48cae4'], - label: { - text: (datum: any) => { - const name = datum?.name || ''; - const count = datum?.count ?? 0; - const data = usvTypeData as { name: string; count: number }[]; - const total = data.reduce((sum, d) => sum + (d.count || 0), 0); - const percent = total > 0 ? ((count / total) * 100).toFixed(1) : 0; - return `${name} ${percent}%`; - }, - style: { fill: 'rgba(200,230,255,0.65)' }, - }, - legend: { position: 'bottom', itemValue: { style: { fill: 'rgba(200,230,255,0.65)' } }, itemName: { style: { fill: 'rgba(200,230,255,0.65)' } } }, - height: chartHeights.pie, - }; - - const columnConfig: any = { - data: taskTypeData, - xField: 'type', - yField: 'value', - seriesField: 'type', - color: ({ type }: any) => { - if (type === '航线巡检') return '#00b4d8'; - if (type === '定点监测') return '#00e5a0'; - return '#ff9f43'; - }, - label: { - text: (datum: any) => datum?.value?.toString() || '0', - style: { fill: '#fff' }, - }, - xAxis: { label: { style: { fill: 'rgba(200,230,255,0.65)' } } }, - yAxis: { label: { style: { fill: 'rgba(200,230,255,0.65)' } }, grid: { line: { style: { stroke: 'rgba(0,150,200,0.1)' } } } }, - legend: false, - height: chartHeights.column, - }; - - const taskCompleteTrendConfig: any = { - data: taskCompleteTrendData, - xField: 'date', - yField: 'value', - smooth: true, - color: '#00e5a0', - areaStyle: { fillOpacity: 0.2 }, - xAxis: { label: { style: { fill: 'rgba(200,230,255,0.65)' } }, grid: null }, - yAxis: { - label: { style: { fill: 'rgba(200,230,255,0.65)' } }, - grid: { line: { style: { stroke: 'rgba(0,150,200,0.08)' } } }, - }, - tooltip: { showMarkers: true }, - height: chartHeights.taskComplete, - }; - - const areaConfig: any = { - data: annualData, - xField: 'month', - yField: 'value', - seriesField: 'type', - color: ['#00b4d8', '#00e5a0'], - areaStyle: { fillOpacity: 0.25 }, - xAxis: { label: { style: { fill: 'rgba(200,230,255,0.65)' } } }, - yAxis: { label: { style: { fill: 'rgba(200,230,255,0.65)' } }, grid: { line: { style: { stroke: 'rgba(0,150,200,0.1)' } } } }, - legend: { position: 'top-right', itemName: { style: { fill: 'rgba(200,230,255,0.8)' } } }, - smooth: true, - height: chartHeights.area, - }; - - const roseConfig: any = { - data: violationAnalysisData, - xField: 'type', - yField: 'value', - seriesField: 'type', - radius: 0.9, - color: ['#ff6b6b', '#ffa502', '#ff9f43', '#00b4d8', '#48cae4', '#90e0ef'], - label: { - text: (datum: any) => datum?.type || '', - style: { fill: '#fff', fontSize: 10 }, - }, - legend: { position: 'bottom', itemName: { style: { fill: 'rgba(200,230,255,0.65)' } } }, - height: chartHeights.rose, - }; - - const taskStatusPieConfig: any = { - data: [ - { name: '待执行', value: taskStats?.pending || 0 }, - { name: '执行中', value: taskStats?.running || 0 }, - { name: '已完成', value: taskStats?.completed || 0 }, - { name: '已失败', value: taskStats?.failed || 0 }, - ], - angleField: 'value', - colorField: 'name', - radius: 0.85, - innerRadius: 0.55, - color: ['#ffa502', '#00b4d8', '#00e5a0', '#ff6b6b'], - label: { - text: (datum: any) => { - const name = datum?.name || ''; - const value = datum?.value ?? 0; - const total = (taskStats?.pending || 0) + (taskStats?.running || 0) + (taskStats?.completed || 0) + (taskStats?.failed || 0); - const percent = total > 0 ? ((value / total) * 100).toFixed(1) : 0; - return `${name} ${percent}%`; - }, - style: { fill: 'rgba(200,230,255,0.65)' }, - }, - legend: { position: 'bottom', itemValue: { style: { fill: 'rgba(200,230,255,0.65)' } }, itemName: { style: { fill: 'rgba(200,230,255,0.65)' } } }, - height: chartHeights.taskStatus, - }; - - const getAlertColor = (level: string) => { - switch (level) { - case 'critical': return '#ff4757'; - case 'error': return '#ff9f43'; - case 'warning': return '#feca57'; - default: return '#54a0ff'; - } - }; - - const taskPeriodText = useMemo(() => { - if (taskStatType === 'day') return '当日'; - if (taskStatType === 'month') return '当月'; - return '当年'; - }, [taskStatType]); - const taskNewLabel = useMemo(() => { if (taskStatType === 'day') return '当日任务'; if (taskStatType === 'month') return '当月任务'; return '当年任务'; }, [taskStatType]); - const datePickerFormat = useMemo(() => { - if (taskStatType === 'day') return 'YYYY-MM-DD'; - if (taskStatType === 'month') return 'YYYY-MM'; - return 'YYYY'; - }, [taskStatType]); + // 使用 CSS Grid 强制分配高度(类似智慧城市首页) + const gap = 12; return ( -
+
+ {/* 保留海事背景装饰 */}
@@ -389,194 +156,104 @@ const MaritimeDashboard: React.FC = () => {