package com.njcn.process.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.process.pojo.param.SendParam;
import com.njcn.process.service.SupvPushGwService;
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 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.io.IOException;
import java.util.List;

/**
 * pqs
 * 上送国网接口
 * @author cdf
 * @date 2023/6/28
 */
@RestController
@RequestMapping("/supv/push")
@Api(tags = "技术监督上送国网接口")
@RequiredArgsConstructor
public class SupvPushGwController extends BaseController {

    private final SupvPushGwService supvPushGwService;

    /**
     * 接收电能质量技术监督工作计划数据接口
     * @author cdf
     * @date 2023/6/28
     */
    @PostMapping("pushPlan")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("推送技术监督工作计划")
    @ApiImplicitParam(name = "planIds",value = "请求体",required = true)
    public HttpResult<String> pushPlan(@RequestBody List<String> planIds){
        String methodDescribe = getMethodDescribe("pushPlan");
        String s = supvPushGwService.pushPlan(planIds);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
    }

    /**
     * 推送技术监督实施问题
     * @author cdf
     * @date 2023/6/28
     */
    @PostMapping("pushQuestion")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("推送技术监督实施问题")
    @ApiImplicitParam(name = "problemIds",value = "请求体",required = true)
    public HttpResult<String> pushQuestion(@RequestBody List<String> problemIds){
        String methodDescribe = getMethodDescribe("pushQuestion");
        String s = supvPushGwService.pushQuestion(problemIds,0);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
    }


    /**
     * 实施问题整改数据接口
     * @author cdf
     * @date 2023/6/28
     */
    @PostMapping("pushQuestionUpdate")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("实施问题整改数据")
    @ApiImplicitParam(name = "problemIds",value = "请求体",required = true)
    public HttpResult<String> pushQuestionUpdate(@RequestBody List<String> problemIds){
        String methodDescribe = getMethodDescribe("pushQuestionUpdate");
        String s = supvPushGwService.pushQuestion(problemIds,1);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
    }


    /**
     * 推送附件接口
     * @author cdf
     * @date 2023/6/28
     */
    @PostMapping("pushFile")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("推送附件接口")
    @ApiImplicitParam(name = "busIds",value = "请求体",required = true)
    public HttpResult<String> pushFile(@RequestBody List<String> busIds) throws IOException {
        String methodDescribe = getMethodDescribe("pushFile");
        String s = supvPushGwService.pushFile(busIds);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
    }


    /**
     * 推送技术监督月报统计数据接口
     * @author cdf
     * @date 2023/6/28
     */
    @PostMapping("pushMonthReportStatistic")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("推送技术监督月报统计数据接口")
    @ApiImplicitParam(name = "monthReportId",value = "请求体",required = true)
    public HttpResult<String> pushMonthReportStatistic(@RequestBody List<String> monthReportId){
        String methodDescribe = getMethodDescribe("pushMonthReportStatistic");
        String s = supvPushGwService.pushMonthReportStatistic(monthReportId);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
    }

    /**
     * 删除电能质量技术监督工作计划接口
     * @author cdf
     * @date 2023/6/28
     */
    @PostMapping("delPushPlan")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("取消电能质量技术监督工作计划接口")
    @ApiImplicitParam(name = "planIds",value = "请求体",required = true)
    public HttpResult<String> delPushPlan(@RequestBody List<String> planIds){
        String methodDescribe = getMethodDescribe("delPushPlan");
        String s = supvPushGwService.deletePlan(planIds);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
    }


    @PostMapping("pushPlanHis")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("推送工作计划变更历史数据接口")
    public HttpResult<String> pushPlanHis(@RequestBody List<String> ids){
        String methodDescribe = getMethodDescribe("pushPlanHis");
        String s = supvPushGwService.pushPlanHis(ids);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
    }

    @PostMapping("pushAlarm")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("推送电能质量技术监督预告警单数据接口")
    public HttpResult<String> pushAlarm(@RequestBody List<String> ids){
        String methodDescribe = getMethodDescribe("pushAlarm");
        String s = supvPushGwService.pushAlarm(ids);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
    }

    @PostMapping("pushAlarmHis")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("推送电能质量技术监督预告警单反馈数据接口")
    public HttpResult<String> pushAlarmHis(@RequestBody List<String> ids){
        String methodDescribe = getMethodDescribe("pushAlarmHis");
        String s = supvPushGwService.pushAlarmHis(ids);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
    }


    @PostMapping("/reject")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("接收总部技术监督工作计划数据回退接口")
    public HttpResult<String> reject(@RequestBody SendParam.Extend param){
        String methodDescribe = getMethodDescribe("reject");
        String s = supvPushGwService.reject(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
    }

}
