package com.hdkj.lt.job.controller;


import com.hdkj.hussar.ApiResponse;
import com.hdkj.lt.job.service.IDealPsrDeviceService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Optional;

/**
 * @Description
 * @Author wcx
 * @Date 2025/6/25 8:59
 * @Version 1.0
 */
@Validated
@RestController
@RequiredArgsConstructor
public class DealPsrDeviceController {

    private final IDealPsrDeviceService dealPsrDeviceService;

    @GetMapping("saveJoinEcTransformer")
    public ApiResponse<String> saveJoinEcTransformerInfo(String cityShort) {
        dealPsrDeviceService.saveJoinEcTransformerInfo(Optional.ofNullable(cityShort).orElse("-"));
        return ApiResponse.success("获取电网资源业务中台中压接入点和专变数据并保存数据操作成功");
    }

    @GetMapping("saveFeederSpanSegment")
    public ApiResponse<String> saveFeederSpanSegmentInfo() {
        dealPsrDeviceService.dealFeederSpanSegmentBak();
        return ApiResponse.success("中台DI同步前备份数据操作成功");
    }

    @GetMapping("updateFeederSpanSegment")
    public ApiResponse<String> updateFeederSpanSegmentInfo() {
        dealPsrDeviceService.dealFeederSpanSegmentSupply();
        return ApiResponse.success("中台DI同步后更新中台缺失字段数据操作成功");
    }

    @GetMapping("saveSegmentPsrDevice")
    public ApiResponse<String> saveSegmentPsrDeviceInfo(String cityShort) {
        dealPsrDeviceService.saveSegmentPsrDeviceInfo(Optional.ofNullable(cityShort).orElse("-"));
        return ApiResponse.success("获取电网资源业务中台导线和电缆段数据并保存数据操作成功");
    }

}
