package com.syjy.calculate.conotroller;

import com.syjy.calculate.entity.AssessmentRequest;
import com.syjy.calculate.entity.CalculateRequest;
import com.syjy.calculate.entity.CalculateResult;
import com.syjy.calculate.entity.CalculationInfo;
import com.syjy.calculate.service.AccuracyPassRateCalculateService;
import com.syjy.calculate.service.AssessmentCalculateService;
import com.syjy.calculate.util.CreateAndInsertSqlUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;

@Controller
@RequestMapping("/test")
public class Test {
    @Autowired
    private AccuracyPassRateCalculateService accuracyPassRateCalculateService;
    @Autowired
    private AssessmentCalculateService assessmentCalculateService;
    @Resource
    private CreateAndInsertSqlUtil createAndInsertSqlUtil;

    @RequestMapping(value = "/test")
    @ResponseBody
    public void test() {




        List<CalculationInfo> calculationInfoList = new ArrayList<>();
        CalculationInfo calculationInfo = new CalculationInfo();
        calculationInfo.setAbleValue(new BigDecimal("4"));
        calculationInfo.setRealValue(new BigDecimal("5"));
        calculationInfo.setForecastAbleValue(new BigDecimal("5"));
        calculationInfo.setOpenCapacity(new BigDecimal("4"));
        calculationInfo.setTime(1663084800000L);
        calculationInfoList.add(calculationInfo);

        calculationInfo = new CalculationInfo();
        calculationInfo.setAbleValue(new BigDecimal("3"));
        calculationInfo.setRealValue(new BigDecimal("8"));
        calculationInfo.setForecastAbleValue(new BigDecimal("4"));
        calculationInfo.setOpenCapacity(new BigDecimal("9"));
        calculationInfo.setTime(1663084800000L);
        calculationInfoList.add(calculationInfo);

        calculationInfo = new CalculationInfo();
        calculationInfo.setAbleValue(new BigDecimal("5"));
        calculationInfo.setRealValue(new BigDecimal("6"));
        calculationInfo.setForecastAbleValue(new BigDecimal("9"));
        calculationInfo.setOpenCapacity(new BigDecimal("7"));
        calculationInfo.setTime(1663085700000L);
        calculationInfoList.add(calculationInfo);

        CalculateRequest calculateRequest = new CalculateRequest();
        calculateRequest.setCalculationInfoList(calculationInfoList);

        calculateRequest.setElectricCapacity(new BigDecimal("12"));
        calculateRequest.setFormulaType("DAY_SHORT_ACCURACY");
        calculateRequest.setProvince("E44");
        calculateRequest.setElectricType("E1");
        calculateRequest.setStationCode("J00314");
        calculateRequest.setElectricCapacity(new BigDecimal(20));

        Map<String,Object> resultMap = accuracyPassRateCalculateService.calculate(calculateRequest);
        System.out.println(resultMap.get("msg"));

//        AssessmentRequest assessmentRequest = new AssessmentRequest("E45", "E1", null,new BigDecimal("50"), new BigDecimal("50"), new BigDecimal("0.8"),new BigDecimal("0.81"), new BigDecimal("0.75"), new BigDecimal("0.68"), new BigDecimal("0.78"),new BigDecimal("0.78"), new BigDecimal("0.78"), new BigDecimal("0.68"),new BigDecimal("0.68"),null,new BigDecimal("0.68"),new BigDecimal("0.68"),new BigDecimal("0.68"),new BigDecimal("0.68"),new BigDecimal("0.68"));
//        CalculateResult calculateResult = assessmentCalculateService.calculateAssessment(assessmentRequest);
    }

    @RequestMapping("testExportSql")
    @ResponseBody
    public void testExportSql() {
        createAndInsertSqlUtil.start("test-db-dev", "ipfcst-v3");
    }

}
