zhaowenyu
2026-04-01 b8b5a3895e741d5348ecdd39ad2e5cbd443f8e89
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.ard.work.util;
 
import com.alibaba.fastjson2.JSONObject;
import com.ard.system.authorize.service.AuthorizeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
 
/**
 * @author: 共方法类
 * @date: 2025/3/4
 * @description:
 */
@Service
public class UtilMethod {
 
    @Autowired
    private AuthorizeService authorizeService;
 
    /**
     * 根据授权数量,验证授权信息是否合规
     */
    public void authorizationVerification(int ls){
 
        JSONObject authInfo = authorizeService.getAuthorizationInfo();
        String authType = authInfo.getString("Type");
 
        switch (authType) {
            case "normal":
                int allowedDroneNum = authInfo.getIntValue("droneNum");
                if (ls > allowedDroneNum) {
                    throw new RuntimeException(String.format(
                            "授权数量%d,当前操作将导致总数达到%d,超过授权限制",
                            allowedDroneNum, ls));
                }
                break;
            case "expired":
                throw new RuntimeException("授权文件已过期");
            case "mismatch":
                throw new RuntimeException("授权文件不匹配");
            default:
                throw new RuntimeException("未知的授权类型: " + authType);
        }
    }
 
}