package com.njcn.prepare.harmonic.controller.area;

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.prepare.harmonic.pojo.param.PrimaryGridParam;
import com.njcn.prepare.harmonic.service.mysql.area.RStatAbnormalDPOService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * Description:
 * 接口文档访问地址：http://serverIP:port/swagger-ui.html
 * Date: 2022/11/28  19:27【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
@Slf4j
@Api(tags = "主网单位数据统计(r_stat_abnormal_d表数据)")
@RestController
@RequestMapping("AbnormalData")
@RequiredArgsConstructor
public class RStatAbnormalDDataHanlderController  extends BaseController {

    private @Autowired
    RStatAbnormalDPOService rStatAbnormalDPOService;

    @ApiOperation("主网单位数据同步(r_stat_abnormal_d表数据)")
    @ApiImplicitParam(value = "primaryGridParam",name = "primaryGridParam",required = true)
    @PostMapping("(rStatAbnormalDDataHanlder")
    @OperateInfo(info = LogEnum.BUSINESS_MEDIUM)
    public HttpResult<Boolean> rStatAbnormalDDataHanlder(@RequestBody PrimaryGridParam primaryGridParam ){
        log.info(LocalDateTime.now()+"rStatAbnormalDDataHanlder开始执行");
        String methodDescribe = getMethodDescribe("rStatAbnormalDDataHanlder");
        Boolean result = true;
        List<String> orgIdList = new ArrayList<> ();
        if(CollectionUtils.isEmpty (primaryGridParam.getOrgIdList ())){
            /*todo 不知道是否需要补招*/
            //orgIdList = lineFeignClient.getLineList ( ).getData ( );
        }else{
            orgIdList = primaryGridParam.getOrgIdList ();
        }
        primaryGridParam.setOrgIdList (orgIdList);
        rStatAbnormalDPOService.rStatAbnormalDDataHanlder(primaryGridParam);
        if (result){
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
        } else {
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
        }
    }
}
