package com.keystar.plane.inspection.controller;

/**
 * @Author Lucien
 * @Date 2023-03-02 08:00:00
 * @Describe 报告接口调用测试类
 */

import com.keystar.plane.inspection.bo.PlaneInspectionPicBo;
import com.keystar.plane.inspection.bo.PlaneInspectionResultBo;
import com.keystar.plane.inspection.bo.PlaneInspectionResultDetailBo;
import com.keystar.plane.inspection.service.IReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(value = "/report")
@Slf4j
public class ReportController {

    @Autowired
    private IReportService reportService;

    @GetMapping("/test")
    public void test() {

        Map<String, String> mFlyCountMap = new HashMap<>();
        //下面这些参数是查库得出, 所以不写在Service里面, 生成时候查库生成即可, 下面用到的都是测试数据
        //本月飞行总架次
        mFlyCountMap.put("TotalSortie", "10");
        //有效巡检架次
        mFlyCountMap.put("EffectiveSortie", "10");
        //有效巡检天数
        mFlyCountMap.put("EffectiveInspectionDate", "10");

        Map<String, String> mSummaryMap = new HashMap<>();
        //方阵总数(16不需要修改)
        mSummaryMap.put("TotalFZ", "16");
        //组串总数(4624不需要修改)
        mSummaryMap.put("TotalPVString", "4624");
        //光伏板总数(124848不需要修改)
        mSummaryMap.put("TotalPVPanel", "124848");
        //无人机巡检覆盖方阵数
        mSummaryMap.put("CoveredFZ", "16");
        //无人机巡检覆盖方阵百分比
        mSummaryMap.put("CoveredFZPct", "100%");
        //本月巡检覆盖组串总数
        mSummaryMap.put("CoveredPVString", "4624");
        //本月巡检覆盖组串百分比
        mSummaryMap.put("CoveredPVStringPct", "100%");
        //本月巡检覆盖光伏板总数
        mSummaryMap.put("CoveredPVPanel", "124848");
        //本月巡检覆盖光伏板百分比
        mSummaryMap.put("CoveredPVPanelPct", "100%");
        //无人机未巡检方阵数
        mSummaryMap.put("UncoveredFZ", "0");
        //无人机未巡检方阵百分比
        mSummaryMap.put("UnCoveredFZPct", "0");
        //本月未巡检组串总数
        mSummaryMap.put("UncoveredPVString", "0");
        //本月未巡检组串百分比
        mSummaryMap.put("UncoveredPVStringPct", "0");
        //本月未巡检光伏板总数
        mSummaryMap.put("UncoveredPVPanel", "0");
        //本月未巡检光伏板百分比
        mSummaryMap.put("UncoveredPVPanelPct", "0");
        //存在异常方阵数
        mSummaryMap.put("FltFZ", "1");
        //存在异常方阵百分比
        mSummaryMap.put("FltFZPct", "10%");
        //存在异常组串总数
        mSummaryMap.put("FltPVString", "50");
        //存在异常组串百分比
        mSummaryMap.put("FltPVStringPct", "1%");
        //存在异常光伏板总数
        mSummaryMap.put("FltPVPanel", "12345");
        //存在异常光伏板百分比
        mSummaryMap.put("FltPVPanelPct", "9%");
        //存在二极管故障的方阵数
        mSummaryMap.put("DioFZ", "10");
        //存在二极管故障的方阵百分比
        mSummaryMap.put("DioFZPct", "1%");
        //存在二极管故障的组串总数
        mSummaryMap.put("DioPVString", "10");
        //存在二极管故障的组串百分比
        mSummaryMap.put("DioPVStringPct", "1%");
        //存在二极管故障的光伏板总数
        mSummaryMap.put("DioPVPanel", "10");
        //存在二极管故障的光伏板百分比
        mSummaryMap.put("DioPVPanelPct", "1%");
        //存在热斑的方阵数
        mSummaryMap.put("HtsptFZ", "10");
        //存在热斑的方阵百分比
        mSummaryMap.put("HtsptFZPct", "1%");
        //存在热斑的组串总数
        mSummaryMap.put("HtsptPVString", "10");
        //存在热斑的组串百分比
        mSummaryMap.put("HtsptPVStringPct", "1%");
        //存在热斑的光伏板总数
        mSummaryMap.put("HtsptPVPanel", "10");
        //存在热斑的光伏板百分比
        mSummaryMap.put("HtsptPVPanelPct", "1%");
        //存在掉串的方阵数
        mSummaryMap.put("OcFZ", "10");
        //存在掉串的方阵百分比
        mSummaryMap.put("OcFZPct", "1%");
        //存在掉串的组串总数
        mSummaryMap.put("OcPVString", "10");
        //存在掉串的组串百分比
        mSummaryMap.put("OcPVStringPct", "1%");
        //存在掉串的光伏板总数
        mSummaryMap.put("OcPVPanel", "10");
        //存在掉串的光伏板百分比
        mSummaryMap.put("OcPVPanelPct", "1%");

        //下面这些可能要宇峰那边帮忙算
        //月度损失电量
        mSummaryMap.put("TotalLose", "111");
        //二极管故障损失量
        mSummaryMap.put("DioLose", "222");
        //热斑损失电量
        mSummaryMap.put("HtsptLose", "333");
        //掉串损失电量
        mSummaryMap.put("OcLose", "444");

        //查库组装巡检结果集合传入函数即可
        List<PlaneInspectionResultBo> planeInspectionResultBoList = new ArrayList<>();
        PlaneInspectionResultBo planeInspectionResultBo = new PlaneInspectionResultBo();

        planeInspectionResultBo.setId("1");
        planeInspectionResultBo.setDetails(new ArrayList<>());
        PlaneInspectionResultDetailBo planeInspectionResultDetailBo1 = new PlaneInspectionResultDetailBo();
        planeInspectionResultDetailBo1.setNum("1");
        planeInspectionResultDetailBo1.setName("FZ01-HL03");
        planeInspectionResultDetailBo1.setDioe("1");
        planeInspectionResultDetailBo1.setHtspte("0");
        planeInspectionResultDetailBo1.setOce("1");
        planeInspectionResultBo.getDetails().add(planeInspectionResultDetailBo1);
        PlaneInspectionResultDetailBo planeInspectionResultDetailBo2 = new PlaneInspectionResultDetailBo();
        planeInspectionResultDetailBo2.setNum("2");
        planeInspectionResultDetailBo2.setName("FZ01-HL04");
        planeInspectionResultDetailBo2.setDioe("0");
        planeInspectionResultDetailBo2.setHtspte("1");
        planeInspectionResultDetailBo2.setOce("0");
        planeInspectionResultBo.getDetails().add(planeInspectionResultDetailBo2);

        planeInspectionResultBo.setPics(new ArrayList<>());
        PlaneInspectionPicBo planeInspectionPicBo1 = new PlaneInspectionPicBo();
        planeInspectionPicBo1.setVisible(reportService.pic2Base64FromMinio("/nest/photo/2420/1872/方阵13-16巡检任务0224-2023-02-26-15-18-29-DJI_20230226144300_0006_THRM.jpg"));
        planeInspectionPicBo1.setInfrared(reportService.pic2Base64FromMinio("/nest/photo/2420/1872/方阵13-16巡检任务0224-2023-02-26-15-18-38-DJI_20230226144304_0007_ZOOM.jpg"));
        planeInspectionResultBo.getPics().add(planeInspectionPicBo1);
        PlaneInspectionPicBo planeInspectionPicBo2 = new PlaneInspectionPicBo();
        planeInspectionPicBo2.setVisible(reportService.pic2Base64FromMinio("/nest/photo/2420/1872/方阵13-16巡检任务0224-2023-02-26-15-18-34-DJI_20230226144302_0006_ZOOM.jpg"));
        planeInspectionPicBo2.setInfrared(reportService.pic2Base64FromMinio("/nest/photo/2420/1872/方阵13-16巡检任务0224-2023-02-26-15-18-48-DJI_20230226144308_0010_THRM.jpg"));
        planeInspectionResultBo.getPics().add(planeInspectionPicBo2);

        planeInspectionResultBoList.add(planeInspectionResultBo);

        PlaneInspectionResultBo planeInspectionResultBoNext = new PlaneInspectionResultBo();

        planeInspectionResultBoNext.setId("2x");
        planeInspectionResultBoNext.setDetails(new ArrayList<>());
        PlaneInspectionResultDetailBo planeInspectionResultDetailBo3 = new PlaneInspectionResultDetailBo();
        planeInspectionResultDetailBo3.setNum("3");
        planeInspectionResultDetailBo3.setName("FZ03-HL03");
        planeInspectionResultDetailBo3.setDioe("0");
        planeInspectionResultDetailBo3.setHtspte("0");
        planeInspectionResultDetailBo3.setOce("1");
        planeInspectionResultBoNext.getDetails().add(planeInspectionResultDetailBo3);
        PlaneInspectionResultDetailBo planeInspectionResultDetailBo4 = new PlaneInspectionResultDetailBo();
        planeInspectionResultDetailBo4.setNum("4");
        planeInspectionResultDetailBo4.setName("FZ03-HL04");
        planeInspectionResultDetailBo4.setDioe("0");
        planeInspectionResultDetailBo4.setHtspte("1");
        planeInspectionResultDetailBo4.setOce("1");
        planeInspectionResultBoNext.getDetails().add(planeInspectionResultDetailBo4);

        planeInspectionResultBoNext.setPics(new ArrayList<>());
        PlaneInspectionPicBo planeInspectionPicBo3 = new PlaneInspectionPicBo();
        planeInspectionPicBo3.setInfrared(reportService.pic2Base64FromMinio("/nest/photo/2420/1872/方阵13-16巡检任务0224-2023-02-26-15-18-39-DJI_20230226144304_0008_THRM.jpg"));
        planeInspectionPicBo3.setVisible(reportService.pic2Base64FromMinio("/nest/photo/2420/1872/方阵13-16巡检任务0224-2023-02-26-15-18-52-DJI_20230226144310_0010_ZOOM.jpg"));
        planeInspectionResultBoNext.getPics().add(planeInspectionPicBo3);
        PlaneInspectionPicBo planeInspectionPicBo4 = new PlaneInspectionPicBo();
        planeInspectionPicBo4.setInfrared(reportService.pic2Base64FromMinio("/nest/photo/2420/1872/方阵13-16巡检任务0224-2023-02-26-15-18-35-DJI_20230226144302_0007_THRM.jpg"));
        planeInspectionPicBo4.setVisible(reportService.pic2Base64FromMinio("/nest/photo/2420/1872/方阵13-16巡检任务0224-2023-02-26-15-18-42-DJI_20230226144306_0008_ZOOM.jpg"));
        planeInspectionResultBoNext.getPics().add(planeInspectionPicBo4);

        planeInspectionResultBoList.add(planeInspectionResultBoNext);

        //生成报告主函数
        reportService.createReport(mFlyCountMap, mSummaryMap, planeInspectionResultBoList);
    }
}
