package com.njcn.device.pms.controller.ledgerManger;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.param.StatisticsBizBaseParam;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.device.pms.pojo.dto.PmsLedgerStaticDTO;
import com.njcn.device.pms.pojo.param.SubstationExpendParam;
import com.njcn.device.pms.pojo.vo.StationExpendMonitorVO;
import com.njcn.device.pms.pojo.vo.SubstationExpendVO;
import com.njcn.device.pms.pojo.po.SubstationExpend;
import com.njcn.device.pms.service.ISubstationExpendService;
import com.njcn.device.pq.pojo.param.CommunicateParam;
import com.njcn.device.pq.pojo.vo.CommunicateVO;
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.web.bind.annotation.*;

import com.njcn.web.controller.BaseController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhuxinyu
 * @since 2023-05-08
 */
@Slf4j
@Api(tags = "冀北变电站地图信息")
@RestController
@RequestMapping("/pms/substationExpend")
@RequiredArgsConstructor
public class SubstationExpendController extends BaseController {

    private final ISubstationExpendService substationExpendService;


    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getSubstationExpendInfo")
    @ApiOperation("冀北变电站地图信息")
    @ApiImplicitParam(name = "param", value = "冀北变电站地图信息参数", required = true)
    public HttpResult<Map<String, List<SubstationExpendVO>>> getSubstationExpendInfo(@RequestBody StatisticsBizBaseParam param) {
        String methodDescribe = getMethodDescribe("getSubstationExpendInfo");
        Map<String, List<SubstationExpendVO>> result = substationExpendService.getSubstationExpendInfo(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getLedgerStatic")
    @ApiOperation("冀北主网监测点台账统计")
    @ApiImplicitParam(name = "param", value = "冀北主网监测点台账统计参数", required = true)
    public HttpResult<PmsLedgerStaticDTO> getLedgerStatic(@RequestBody StatisticsBizBaseParam param) {
        String methodDescribe = getMethodDescribe("getLedgerStatic");
        PmsLedgerStaticDTO result = substationExpendService.getLedgerStatistics(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getPVCommunicationStatus")
    @ApiOperation("冀北主网监测点pms:通讯状态统计")
    @ApiImplicitParam(name = "param", value = "冀北主网监测点台账统计参数", required = true)
    public HttpResult<List<CommunicateVO.PVCommunicateVO>> getPVCommunicationStatus(@RequestBody CommunicateParam param) {
        String methodDescribe = getMethodDescribe("getPVCommunicationStatus");
        List<CommunicateVO.PVCommunicateVO> communicationStatus = substationExpendService.getCommunicationStatus(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, communicationStatus, methodDescribe);
    }




//    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
//    @PostMapping("/insert")
//    @ApiOperation("变电站信息")
//    @ApiImplicitParam(name = "insert", value = "变电站信息", required = true)
//    public HttpResult<Boolean> insert(@RequestBody StatisticsBizBaseParam insert) {
//        String methodDescribe = getMethodDescribe("insert");
//        List<SubstationExpend> list = Arrays.asList(
//                new SubstationExpend("500kV天马变电站", "1fa650685c77db1656c70f9db4a2edc6",new BigDecimal(119.292327),new BigDecimal(40.215015),"17439407bfee299b7e38f2e54a8f6d28"),
//                new SubstationExpend("500kV昌黎变电站", "1fa650685c77db1656c70f9db4a2edc6",new BigDecimal(118.990809),new BigDecimal(40.016014),"17439407bfee299b7e38f2e54a8f6d28"),
//                new SubstationExpend("220kV陈官屯变电站", "1b7b58ed8fcc2992b95334eaa9010c41",new BigDecimal(118.998356),new BigDecimal(39.990971),"17439407bfee299b7e38f2e54a8f6d28"),
//                new SubstationExpend("220kV小营变电站", "1b7b58ed8fcc2992b95334eaa9010c41",new BigDecimal(119.298044),new BigDecimal(39.814401),"17439407bfee299b7e38f2e54a8f6d28"),
//                new SubstationExpend("220kV深河变电站", "1b7b58ed8fcc2992b95334eaa9010c41",new BigDecimal(119.453054),new BigDecimal(39.940208),"17439407bfee299b7e38f2e54a8f6d28"),
//                new SubstationExpend("220kV杜庄变电站", "1b7b58ed8fcc2992b95334eaa9010c41",new BigDecimal(119.540182),new BigDecimal(40.026883),"17439407bfee299b7e38f2e54a8f6d28"),
//                new SubstationExpend("220kV平方变电站", "1b7b58ed8fcc2992b95334eaa9010c41",new BigDecimal(119.173903),new BigDecimal(39.730601),"17439407bfee299b7e38f2e54a8f6d28"),
//                new SubstationExpend("220kV肖营子变电站", "1b7b58ed8fcc2992b95334eaa9010c41",new BigDecimal(118.866099),new BigDecimal(40.279209),"17439407bfee299b7e38f2e54a8f6d28"),
//                new SubstationExpend("220kV丰钢变电站", "1b7b58ed8fcc2992b95334eaa9010c41",new BigDecimal(118.913885),new BigDecimal(39.663569),"17439407bfee299b7e38f2e54a8f6d28"),
//                new SubstationExpend("220kV碣石变电站", "1b7b58ed8fcc2992b95334eaa9010c41",new BigDecimal(119.191153),new BigDecimal(39.723464),"17439407bfee299b7e38f2e54a8f6d28"),
//                new SubstationExpend("220kV龙家店变电站", "1b7b58ed8fcc2992b95334eaa9010c41",new BigDecimal(119.062243),new BigDecimal(39.719279),"17439407bfee299b7e38f2e54a8f6d28"),
//                new SubstationExpend("220kV仙螺岛变电站", "1b7b58ed8fcc2992b95334eaa9010c41",new BigDecimal(119.446926),new BigDecimal(39.792502),"17439407bfee299b7e38f2e54a8f6d28")
//        );
//
//        boolean b = substationExpendService.saveBatch(list);
//        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b, methodDescribe);
//    }


    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/list")
    @ApiOperation("查询变电站信息")
    public HttpResult< Page<SubstationExpend>> list(@RequestBody SubstationExpendParam param) {
        String methodDescribe = getMethodDescribe("list");
        Page<SubstationExpend> page = substationExpendService.getSubstationExpend(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,page, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/insert")
    @ApiOperation("添加变电站信息")
    public HttpResult<Boolean> addSubstation(@RequestBody SubstationExpend param) {
        String methodDescribe = getMethodDescribe("addSubstation");
        boolean save = substationExpendService.addSubstation(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,save, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/update")
    @ApiOperation("修改变电站信息")
    public HttpResult<Boolean> updateSubstation(@RequestBody SubstationExpend param) {
        String methodDescribe = getMethodDescribe("updateSubstation");
        boolean save = substationExpendService.updateSubstation(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,save, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/delete")
    @ApiOperation("删除变电站信息")
    public HttpResult<Boolean> removeSubstation(@RequestBody List<String> ids) {
        String methodDescribe = getMethodDescribe("removeSubstation");
        boolean save = substationExpendService.removeByIds(ids);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,save, methodDescribe);
    }

    /**
     * 点击电站展示所属监测点信息
     * @author cdf
     * @date 2023/9/27
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getSubStationMonitor")
    @ApiOperation("点击电站展示所属监测点信息")
    public HttpResult<List<StationExpendMonitorVO>> getSubStationMonitor(@RequestParam("stationId") String stationId) {
        String methodDescribe = getMethodDescribe("getSubStationMonitor");
        List<StationExpendMonitorVO> list = substationExpendService.getSubStationMonitor(stationId);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list, methodDescribe);
    }

}

