package com.njcn.device.pq.controller;

import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.device.biz.pojo.dto.SubGetBase;
import com.njcn.device.biz.pojo.param.SubstationParam;
import com.njcn.device.pq.pojo.po.YwZtSubstation;
import com.njcn.device.pq.service.IYwZtSubstationService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @version 1.0.0
 * @author: chenchao
 * @date: 2022/06/23 11:36
 */
@Validated
@Slf4j
@RestController
@RequestMapping("/ywZt")
@Api(tags = "业务中台数据管理")
@AllArgsConstructor
public class YwZtSubstationController extends BaseController {

    private final IYwZtSubstationService ywZtSubstationService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @GetMapping("/addYwZtSubstation")
    @ApiOperation("业务中台变电站表同步")
    public HttpResult<Boolean> syncYwZtSubstation(){
        String methodDescribe = getMethodDescribe("syncYwZtSubstation");
        Boolean b = ywZtSubstationService.syncYwZtSubstation();
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @GetMapping("/getYwZtSubstation")
    @ApiOperation("获取业务中台变电站")
    public HttpResult<List<YwZtSubstation>> getYwZtSubstation(@RequestParam(required =false )String orgId){
        String methodDescribe = getMethodDescribe("getYwZtSubstation");
        List<YwZtSubstation> ywZtSubstation = ywZtSubstationService.getYwZtSubstation(orgId);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, ywZtSubstation, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/tagOrIdGetYWZtSub")
    @ApiOperation("获取变电站信息")
    public HttpResult<List<SubGetBase>> tagOrIdGetSub(@RequestBody SubstationParam substationParam) {
        String methodDescribe = getMethodDescribe("tagOrIdGetSub");
        List<SubGetBase> subGetBases = ywZtSubstationService.getSubstation(substationParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, subGetBases, methodDescribe);
    }
}
