src/main/java/com/dji/sample/droneairport/service/impl/RegistServiceImpl.java
@@ -47,6 +47,7 @@
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
@@ -54,9 +55,9 @@
import java.util.*;
import java.util.stream.Collectors;
import static com.dji.sample.droneairport.utils.AuthUtil.getToken;
import static com.dji.sample.droneairport.utils.TaskAllocator.assignTasks;
import static com.dji.sample.patches.utils.TimerUtil.getCurrentTimestampPlus8Hours;
import static com.dji.sample.patches.utils.TimerUtil.getNextDayEightAMTimestamp;
import static com.dji.sample.patches.utils.TimerUtil.*;
@Service
public class RegistServiceImpl implements RegistService {
@@ -84,26 +85,39 @@
    public String registPort(DeviceExpanSionEntity airport) {
        try {
            RegistDto registDto = airportEntityToDto(airport);
            String secret = SM4Util.generateSM4Key();
            String jsonBody = buildRequestBody(registDto);
            String base64 = SM4Util.encrypt("jsimjrby3wqb7dbq", jsonBody);
            String base64 = SM4Util.encrypt(secret, jsonBody);
            String keys=Utils.encrypt(secret,"04225AACF606D800EA3C2C31FCF8FB161B15F7A8D0460DEB91013D4F228C455E76A2ED8D71BC6525B5DC5CC015C155479D8839950344AEE438A3A6305C90F8269F");
            String enSM2=Utils.hexToBase64(keys);
            // 设置请求头
            HttpHeaders headers = new HttpHeaders();
            headers.setContentType(MediaType.APPLICATION_JSON);
            headers.setAccept(List.of(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN, MediaType.ALL));
            headers.set("Accept-Language", "zh-CN,zh;q=0.9");
            headers.setConnection("keep-alive");
            headers.set("x-auth-token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ3b3Jrc3BhY2VfaWQiOiJlM2RlYTBmNS0zN2YyLTRkNzktYWU1OC00OTBhZjMyMjgwNjkiLCJzdWIiOiJDbG91ZEFwaVNhbXBsZSIsInVzZXJfdHlwZSI6IjEiLCJuYmYiOjE3MjA2NTg3NDMsImxvZyI6IkxvZ2dlcltjb20uZGppLnNhbXBsZS5jb21tb24ubW9kZWwuQ3VzdG9tQ2xhaW1dIiwiaXNzIjoiREpJIiwiaWQiOiI5Y2MwMGY3Zi0yODMwLTRmM2UtYjdmNC1lN2E1ZjIzYjNjNGYiLCJleHAiOjE4MDcwNTg3NDMsImlhdCI6MTcyMDY1ODc0MywidXNlcm5hbWUiOiJhZG1pbkRQIn0.CrRFYUTK357HleqrrfL7nLdwFJw5Bcv3ms33n_Or8eM");
            headers.set("x-lc-token", "");
            headers.set("x-lc-token", getToken());
            headers.set("x-auth-token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ3b3Jrc3BhY2VfaWQiOiJlM2RlYTBmNS0zN2YyLTRkNzktYWU1OC00OTBhZjMyMjgwNjkiLCJzdWIiOiJDbG91ZEFwaVNhbXBsZSIsInVzZXJfdHlwZSI6IjEiLCJuYmYiOjE3MTg1ODUxNTQsImxvZyI6IkxvZ2dlcltjb20uZGppLnNhbXBsZS5jb21tb24ubW9kZWwuQ3VzdG9tQ2xhaW1dIiwiaXNzIjoiREpJIiwiaWQiOiI5Y2MwMGY3Zi0yODMwLTRmM2UtYjdmNC1lN2E1ZjIzYjNjNGYiLCJleHAiOjE4MDQ5ODUxNTQsImlhdCI6MTcxODU4NTE1NCwidXNlcm5hbWUiOiJhZG1pbkRQIn0.eTi9DTYGwcTvnIZasKTFq9OHQgMFS1-m840terb7ss0");
            headers.set("x-lc-secret", enSM2);
            // 构建请求实体
            HttpEntity<String> requestEntity = new HttpEntity<>(base64, headers);
            // 发送请求
            ResponseEntity<String> response = restTemplate.exchange(
                    "http://localhost:6789/droneAirport/test",
                    "https://xcx.geoway.com.cn:8033/v1/droneAirport/RegistService",
                    HttpMethod.POST,
                    requestEntity,
                    String.class);
            return response.getBody();
            HttpHeaders responseHeaders = response.getHeaders();
            String responseSecret = responseHeaders.getFirst("x-lc-secret");
            String data=deSM2(responseSecret, "00D631FD5615416EAB63D33A9E66E801F95DE840567504210080006081DE877AE3");
            // 使用 Hutool 的 JSONUtil 解析 JSON 字符串
            JSONObject jsonObject = JSONUtil.parseObj(response.getBody());
            // 提取 data 字段的值
            String dataValue = jsonObject.getStr("data");
            return SM4Util.decrypt(data,dataValue);
        } catch (Exception e) {
            // 异常处理
            throw new IllegalArgumentException("无人机机场注册失败: " + e.getMessage());
@@ -136,41 +150,57 @@
                    .eq(DeviceExpanSionEntity::getWorkspaceId, workspaceId)
                    .eq(DeviceExpanSionEntity::getType, 1));
            AddDeviceDto dto = deviceEntityToDto(drone);
            String secret = SM4Util.generateSM4Key();
            // 构建请求体
            String jsonBody = buildRequestBody(dto);
            String base64 = SM4Util.encrypt("jsimjrby3wqb7dbq", jsonBody);
            String base64 = SM4Util.encrypt(secret, jsonBody);
            String keys=Utils.encrypt(secret,"04225AACF606D800EA3C2C31FCF8FB161B15F7A8D0460DEB91013D4F228C455E76A2ED8D71BC6525B5DC5CC015C155479D8839950344AEE438A3A6305C90F8269F");
            String enSM2=Utils.hexToBase64(keys);
//            registPort(airport);
            // 设置请求头
            HttpHeaders headers = new HttpHeaders();
            headers.setContentType(MediaType.APPLICATION_JSON);
            headers.setAccept(List.of(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN, MediaType.ALL));
            headers.set("Accept-Language", "zh-CN,zh;q=0.9");
            headers.setConnection("keep-alive");
            headers.set("x-auth-token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ3b3Jrc3BhY2VfaWQiOiJlM2RlYTBmNS0zN2YyLTRkNzktYWU1OC00OTBhZjMyMjgwNjkiLCJzdWIiOiJDbG91ZEFwaVNhbXBsZSIsInVzZXJfdHlwZSI6IjEiLCJuYmYiOjE3MjA2NTg3NDMsImxvZyI6IkxvZ2dlcltjb20uZGppLnNhbXBsZS5jb21tb24ubW9kZWwuQ3VzdG9tQ2xhaW1dIiwiaXNzIjoiREpJIiwiaWQiOiI5Y2MwMGY3Zi0yODMwLTRmM2UtYjdmNC1lN2E1ZjIzYjNjNGYiLCJleHAiOjE4MDcwNTg3NDMsImlhdCI6MTcyMDY1ODc0MywidXNlcm5hbWUiOiJhZG1pbkRQIn0.CrRFYUTK357HleqrrfL7nLdwFJw5Bcv3ms33n_Or8eM");
            headers.set("x-lc-token", "");
            headers.set("x-auth-token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ3b3Jrc3BhY2VfaWQiOiJlM2RlYTBmNS0zN2YyLTRkNzktYWU1OC00OTBhZjMyMjgwNjkiLCJzdWIiOiJDbG91ZEFwaVNhbXBsZSIsInVzZXJfdHlwZSI6IjEiLCJuYmYiOjE3MTg1ODUxNTQsImxvZyI6IkxvZ2dlcltjb20uZGppLnNhbXBsZS5jb21tb24ubW9kZWwuQ3VzdG9tQ2xhaW1dIiwiaXNzIjoiREpJIiwiaWQiOiI5Y2MwMGY3Zi0yODMwLTRmM2UtYjdmNC1lN2E1ZjIzYjNjNGYiLCJleHAiOjE4MDQ5ODUxNTQsImlhdCI6MTcxODU4NTE1NCwidXNlcm5hbWUiOiJhZG1pbkRQIn0.eTi9DTYGwcTvnIZasKTFq9OHQgMFS1-m840terb7ss0");
            headers.set("x-lc-token", getToken());
            headers.set("x-lc-secret", (enSM2));
            // 构建请求实体
            HttpEntity<String> requestEntity = new HttpEntity<>(base64, headers);
            // 发送请求
            ResponseEntity<String> response = restTemplate.exchange(
                    "http://localhost:6789/droneAirport/test",
                    "https://xcx.geoway.com.cn:8033/v1/droneAirport/addDevice",
                    HttpMethod.POST,
                    requestEntity,
                    String.class);
            registPort(airport);
            return response.getBody();
            HttpHeaders responseHeaders = response.getHeaders();
            String responseSecret = responseHeaders.getFirst("x-lc-secret");
            String data=deSM2(responseSecret, "00D631FD5615416EAB63D33A9E66E801F95DE840567504210080006081DE877AE3");
            // 使用 Hutool 的 JSONUtil 解析 JSON 字符串
            JSONObject jsonObject = JSONUtil.parseObj(response.getBody());
            // 提取 data 字段的值
            String dataValue = jsonObject.getStr("data");
            return SM4Util.decrypt(data,dataValue);
        } catch (Exception e) {
            // 异常处理
            throw new IllegalArgumentException("无人机机场设备注册失败: " + e.getMessage());
            return ("无人机机场设备注册失败: " + e.getMessage());
        }
    }
    @Override
    public String getDroneState(String deviceId) throws Exception {
    public Map<String, String> getDroneState(String deviceId) throws Exception {
        String key = SM4Util.generateSM4Key();
        String secret = Utils.encrypt(key, "04225AACF606D800EA3C2C31FCF8FB161B15F7A8D0460DEB91013D4F228C455E76A2ED8D71BC6525B5DC5CC015C155479D8839950344AEE438A3A6305C90F8269F");
        DroneStateDto data = getAirportFromCache(deviceId);
        String json = JSON.toJSONString(data);
        String SM4Screct = SM4Util.encrypt("jsimjrby3wqb7dbq", json);
        return SM4Screct;
        String SM4Screct = SM4Util.encrypt(key, json);
        Map<String, String> info = new HashMap<>();
        info.put("text", SM4Screct);
        info.put("serect", secret);
        return info;
    }
    //    @Override
@@ -191,20 +221,20 @@
        dto.setSn(sn);
        dto.setStatus(0);
        String jsonBody = buildRequestBody(dto);
        String base64 = SM4Util.encrypt("jsimjrby3wqb7dbq", jsonBody);
        String base64 = SM4Util.encrypt(SM4Util.generateSM4Key(), jsonBody);
        // 设置请求头
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON);
        headers.setAccept(List.of(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN, MediaType.ALL));
        headers.set("Accept-Language", "zh-CN,zh;q=0.9");
        headers.setConnection("keep-alive");
        headers.set("x-auth-token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ3b3Jrc3BhY2VfaWQiOiJlM2RlYTBmNS0zN2YyLTRkNzktYWU1OC00OTBhZjMyMjgwNjkiLCJzdWIiOiJDbG91ZEFwaVNhbXBsZSIsInVzZXJfdHlwZSI6IjEiLCJuYmYiOjE3MjA2NTg3NDMsImxvZyI6IkxvZ2dlcltjb20uZGppLnNhbXBsZS5jb21tb24ubW9kZWwuQ3VzdG9tQ2xhaW1dIiwiaXNzIjoiREpJIiwiaWQiOiI5Y2MwMGY3Zi0yODMwLTRmM2UtYjdmNC1lN2E1ZjIzYjNjNGYiLCJleHAiOjE4MDcwNTg3NDMsImlhdCI6MTcyMDY1ODc0MywidXNlcm5hbWUiOiJhZG1pbkRQIn0.CrRFYUTK357HleqrrfL7nLdwFJw5Bcv3ms33n_Or8eM");
        headers.set("x-lc-token", "");
        headers.set("x-lc-token", "eyJvcmdjb2RlIjoiMDAwMDAwMDAwMDAwMDAwMDAwIiwib3JnbmFtZSI6IuWbveWcn+iwg+afpeS6keaXoOS6uuacuuaOpeWPo+a1i+ivleivgeS5puS4peemgeeUqOS6juato+W8j+eOr+WigyIsImNlcnRjb2RlIjoiVUFWMzJfV0hSNEUzVUFKWlRFM0tFNUlaRkRHTDdDQlUiLCJjZXJ0b3JnY29kZSI6IjEyMTAwMDAwNDAwMDEwMzk4UCIsImNlcnRvcmduYW1lIjoi5Lit5Zu95Zu95Zyf5YuY5rWL6KeE5YiS6ZmiIiwiZXhwaXJhdGlvbiI6IjIwMjQtMTItMzEgMTU6NDY6MzIiLCJwdWJsaWNrZXkiOiIwNDIyNUFBQ0Y2MDZEODAwRUEzQzJDMzFGQ0Y4RkIxNjFCMTVGN0E4RDA0NjBERUI5MTAxM0Q0RjIyOEM0NTVFNzZBMkVEOEQ3MUJDNjUyNUI1REM1Q0MwMTVDMTU1NDc5RDg4Mzk5NTAzNDRBRUU0MzhBM0E2MzA1QzkwRjgyNjlGIiwic2lnbiI6IkI4OTVGQUM1Qzk4NzM5RURGNzFBRkE2QjM4NDEzQUIzNDRCRTBDQjE1RTk3MDQ3Nzk5QTczNUM0MjBEMkZFMzdENkE1NjJFQTlFMUFBRjFBNjhBRDJERjE0QzhEMThBOEY5N0JENzUyOUE2NDRERDA3NkI2NDM1OTg5QkQxREIwIiwiY2VydHR5cGUiOiLml6DkurrmnLrkuL7or4Hor4HkuaYiLCJyZWdpb25jb2RlIjoiMDAwMDAwIn0=");
        headers.set("x-lc-secret", "00D631FD5615416EAB63D33A9E66E801F95DE840567504210080006081DE877AE3");
        // 构建请求实体
        HttpEntity<String> requestEntity = new HttpEntity<>(base64, headers);
        // 发送请求
        ResponseEntity<String> response = restTemplate.exchange(
                "http://localhost:6789/droneAirport/test",
                "https://xcx.geoway.com.cn:8033/v1/droneAirport/authorization",
                HttpMethod.POST,
                requestEntity,
                String.class);
@@ -216,31 +246,33 @@
        dto.setSn(sn);
        dto.setStatus(1);
        String jsonBody = buildRequestBody(dto);
        String base64 = SM4Util.encrypt("jsimjrby3wqb7dbq", jsonBody);
        String base64 = SM4Util.encrypt(SM4Util.generateSM4Key(), jsonBody);
        // 设置请求头
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON);
        headers.setAccept(List.of(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN, MediaType.ALL));
        headers.set("Accept-Language", "zh-CN,zh;q=0.9");
        headers.setConnection("keep-alive");
        headers.set("x-auth-token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ3b3Jrc3BhY2VfaWQiOiJlM2RlYTBmNS0zN2YyLTRkNzktYWU1OC00OTBhZjMyMjgwNjkiLCJzdWIiOiJDbG91ZEFwaVNhbXBsZSIsInVzZXJfdHlwZSI6IjEiLCJuYmYiOjE3MjA2NTg3NDMsImxvZyI6IkxvZ2dlcltjb20uZGppLnNhbXBsZS5jb21tb24ubW9kZWwuQ3VzdG9tQ2xhaW1dIiwiaXNzIjoiREpJIiwiaWQiOiI5Y2MwMGY3Zi0yODMwLTRmM2UtYjdmNC1lN2E1ZjIzYjNjNGYiLCJleHAiOjE4MDcwNTg3NDMsImlhdCI6MTcyMDY1ODc0MywidXNlcm5hbWUiOiJhZG1pbkRQIn0.CrRFYUTK357HleqrrfL7nLdwFJw5Bcv3ms33n_Or8eM");
        headers.set("x-lc-token", "");
        headers.set("x-lc-token", "eyJvcmdjb2RlIjoiMDAwMDAwMDAwMDAwMDAwMDAwIiwib3JnbmFtZSI6IuWbveWcn+iwg+afpeS6keaXoOS6uuacuuaOpeWPo+a1i+ivleivgeS5puS4peemgeeUqOS6juato+W8j+eOr+WigyIsImNlcnRjb2RlIjoiVUFWMzJfV0hSNEUzVUFKWlRFM0tFNUlaRkRHTDdDQlUiLCJjZXJ0b3JnY29kZSI6IjEyMTAwMDAwNDAwMDEwMzk4UCIsImNlcnRvcmduYW1lIjoi5Lit5Zu95Zu95Zyf5YuY5rWL6KeE5YiS6ZmiIiwiZXhwaXJhdGlvbiI6IjIwMjQtMTItMzEgMTU6NDY6MzIiLCJwdWJsaWNrZXkiOiIwNDIyNUFBQ0Y2MDZEODAwRUEzQzJDMzFGQ0Y4RkIxNjFCMTVGN0E4RDA0NjBERUI5MTAxM0Q0RjIyOEM0NTVFNzZBMkVEOEQ3MUJDNjUyNUI1REM1Q0MwMTVDMTU1NDc5RDg4Mzk5NTAzNDRBRUU0MzhBM0E2MzA1QzkwRjgyNjlGIiwic2lnbiI6IkI4OTVGQUM1Qzk4NzM5RURGNzFBRkE2QjM4NDEzQUIzNDRCRTBDQjE1RTk3MDQ3Nzk5QTczNUM0MjBEMkZFMzdENkE1NjJFQTlFMUFBRjFBNjhBRDJERjE0QzhEMThBOEY5N0JENzUyOUE2NDRERDA3NkI2NDM1OTg5QkQxREIwIiwiY2VydHR5cGUiOiLml6DkurrmnLrkuL7or4Hor4HkuaYiLCJyZWdpb25jb2RlIjoiMDAwMDAwIn0=");
        headers.set("x-lc-secret", "00D631FD5615416EAB63D33A9E66E801F95DE840567504210080006081DE877AE3");
        // 构建请求实体
        HttpEntity<String> requestEntity = new HttpEntity<>(base64, headers);
        // 发送请求
        ResponseEntity<String> response = restTemplate.exchange(
                "http://localhost:6789/droneAirport/test",
                "https://xcx.geoway.com.cn:8033/v1/droneAirport/authorization",
                HttpMethod.POST,
                requestEntity,
                String.class);
    }
    @Override
    public ReturnTaskParam AddTask(String base64, String Secret, String username) throws Exception {
    public Map<String, String> AddTask(String base64, String Secret, String username) throws Exception {
        ReturnTaskParam param = new ReturnTaskParam();
        String secret = SM4Util.generateSM4Key();
        String retse = Utils.encrypt(secret, "04225AACF606D800EA3C2C31FCF8FB161B15F7A8D0460DEB91013D4F228C455E76A2ED8D71BC6525B5DC5CC015C155479D8839950344AEE438A3A6305C90F8269F");
        String taskId = UUID.randomUUID().toString();
        String traceid = UUID.randomUUID().toString();
        String sm4Secrect = deSM2(Secret, "23E57DA1E4AB865CCBC325B668762207DEF74345B782237808AE0BABDF26734D");
        String sm4Secrect = deSM2(Secret, "00D631FD5615416EAB63D33A9E66E801F95DE840567504210080006081DE877AE3");
        String decryptedJson = SM4Util.decrypt(sm4Secrect, base64);
        JSONObject jsonObject = new JSONObject(decryptedJson);
        AddTaskDto addTaskDto = jsonToDto(jsonObject);
@@ -283,7 +315,8 @@
                String waylineName = TimerUtil.getTimeName();
                MultipartFile multipartFile = timerUtil.getFile(waylineName, lotInfosForAirport, airport.getLat(), airport.getLon());
                WaylineFileEntity waylineFile = timerUtil.backWayline(multipartFile, waylineName, airport.getWorkspaceId(), username);
                Long time = getNextDayEightAMTimestamp(getDistinctTaskIdCount(airport.getWorkspaceId()));
//                Long time = getNextDayEightAMTimestamp(getDistinctTaskIdCount(airport.getWorkspaceId()));
                Long time = getAdjustedTimestamp(50);
                List<List<Long>> listOfLists = new ArrayList<>();
                List<Long> sublist = new ArrayList<>();
                sublist.add(time);
@@ -291,21 +324,26 @@
                List<Long> lists1 = new ArrayList<>();
                lists1.add(time);
                String times = TimerUtil.convertTimestampToFormattedString(time);
                param.setJobId(SM4Util.encrypt("jsimjrby3wqb7dbq", taskId));
                param.setJobId(SM4Util.encrypt(secret, taskId));
                timerUtil.sendPostWithParameters(waylineName, waylineFile.getWaylineId(), times, lists1, listOfLists, taskId + "~" + airport.getWorkspaceId(), airport.getDockSn());
                timerUtil.updatePatchesStatu(lotInfosForAirport);
            }
        }
        return param;
        Map<String, String> info = new HashMap<>();
        info.put("taskid", param.getJobId());
        info.put("traceid", param.getTraceId());
        info.put("serect", retse);
        return info;
    }
    @Override
    public ReturnTaskParam updateTask(String base64, String Secret, String username) throws Exception {
    public Map<String, String>  updateTask(String base64, String Secret, String username) throws Exception {
        ReturnTaskParam param = new ReturnTaskParam();
        String secret = SM4Util.generateSM4Key();
        String retse = Utils.encrypt(secret, "04225AACF606D800EA3C2C31FCF8FB161B15F7A8D0460DEB91013D4F228C455E76A2ED8D71BC6525B5DC5CC015C155479D8839950344AEE438A3A6305C90F8269F");
        String traceid = UUID.randomUUID().toString();
        String sm4Secrect = deSM2(Secret, "23E57DA1E4AB865CCBC325B668762207DEF74345B782237808AE0BABDF26734D");
        String sm4Secrect = deSM2(Secret, "00D631FD5615416EAB63D33A9E66E801F95DE840567504210080006081DE877AE3");
        String decryptedJson = SM4Util.decrypt(sm4Secrect, base64);
        JSONObject jsonObject = new JSONObject(decryptedJson);
        UpdataTaskDto addTaskDto = UpjsonToDto(jsonObject);
@@ -363,13 +401,16 @@
                List<Long> lists1 = new ArrayList<>();
                lists1.add(time);
                String times = TimerUtil.convertTimestampToFormattedString(time);
                param.setJobId(taskId);
                param.setJobId(SM4Util.encrypt(secret, taskId));
                timerUtil.sendPostWithParameters(waylineName, waylineFile.getWaylineId(), times, lists1, listOfLists, airport.getWorkspaceId() + "~" + taskId, airport.getDockSn());
                timerUtil.updatePatchesStatu(lotInfosForAirport);
            }
        }
        return param;
        Map<String, String> info = new HashMap<>();
        info.put("taskid", param.getJobId());
        info.put("traceid", param.getTraceId());
        info.put("serect", retse);
        return info;
    }
    @Override
@@ -425,34 +466,28 @@
     * @param taskId 任务 ID
     * @return 匹配的 DB 文件路径列表
     */
    public String findDbFilesByTaskId(String taskId) {
    public Map<String,String> findDbFilesByTaskId(String taskId) throws InvalidCipherTextException, IOException {
        DbUploadEntity entity = dbUploadMapper.selectOne(new LambdaQueryWrapper<DbUploadEntity>()
                .eq(DbUploadEntity::getTaskId, taskId));
        String secret = SM4Util.generateSM4Key();
        String traceId = UUID.randomUUID().toString();
        Map<String,String> info =new HashMap<>();
        String retse = Utils.encrypt(secret, "04225AACF606D800EA3C2C31FCF8FB161B15F7A8D0460DEB91013D4F228C455E76A2ED8D71BC6525B5DC5CC015C155479D8839950344AEE438A3A6305C90F8269F");
        if (entity != null) {
            DbUploadDto dto = DbEntityToDto(entity);
            return SM4Util.encrypt("jsimjrby3wqb7dbq", buildRequestBody(dto));
            String data=buildRequestBody(dto);
            String text=SM4Util.encrypt(secret,data);
            info.put("data", text);
            info.put("serect", retse);
            info.put("traceId",traceId);
            return info;
        }
        return null;
//        File baseDir = new File(BASE_DIR);
//
//        // 检查基础目录是否存在并且是目录
//        if (!baseDir.exists() || !baseDir.isDirectory()) {
//            throw new IllegalStateException("Base directory does not exist or is not a directory.");
//        }
//
//        // 构建文件路径
//        File targetDir = new File(baseDir, taskId);
//        File dbFile = new File(targetDir, ".db");
//
//        // 如果文件存在,则返回文件路径
//        if (dbFile.exists()) {
//            return dbFile.getAbsolutePath();
//        }
//
//        return null; // 或者抛出异常,视需求而定
    }
    public static void main(String[] args) {
        getToken();
    }
    public void delPatchesByTaskId(String taskId) {
        patchesMapper.delete(new LambdaUpdateWrapper<LotInfo>().eq(LotInfo::getTaskId, taskId));