package com.ho.business.util.region;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ho.business.entity.IndustrialElecPrice;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Region7 implements  Region{

    public  List<IndustrialElecPrice> getList(JSONArray array,Integer regionId, String spikePriceInterval,
                                              String peakPriceInterval, String regularPriceInterval, String lowValleyPriceInterval,
                                              String deepValleyPriceInterval,String executionTime) {
        /**
         * 湖北省的电价是按公式计算出来的
         */
        List<IndustrialElecPrice> list = new ArrayList<>();
        JSONObject jsonObject = array.getJSONObject(array.size() - 1);
        Integer rowStart = jsonObject.getInteger("row_start");
        IndustrialElecPrice industrialElecPrice = new IndustrialElecPrice();

        industrialElecPrice.setVoltageLevel(VoltageLevel.getVoltageLevel(array.getJSONObject(0).getString("words")));
        industrialElecPrice.setNonTimePrice(new BigDecimal(array.getJSONObject(1).getString("words")));

        String proxyPrice=array.getJSONObject(2).getString("words");

        industrialElecPrice.setProxyPrice(new BigDecimal(proxyPrice));

        industrialElecPrice.setTransmissionPrice(new BigDecimal(array.getJSONObject(4).getString("words")));
        String lineLossPrice=array.getJSONObject(3).getString("words");
        industrialElecPrice.setLineLossPrice(new BigDecimal(lineLossPrice));

        String addPrice=array.getJSONObject(5).getString("words");
        industrialElecPrice.setAddPrice(new BigDecimal(addPrice));

        String runningPrice=array.getJSONObject(6).getString("words");
        industrialElecPrice.setRunningPrice(new BigDecimal(runningPrice));

        industrialElecPrice.setSpikePriceInterval(spikePriceInterval);
        industrialElecPrice.setPeakPriceInterval(peakPriceInterval);
        industrialElecPrice.setRegularPriceInterval(regularPriceInterval);
        industrialElecPrice.setLowValleyPriceInterval(lowValleyPriceInterval);
        industrialElecPrice.setDeepValleyPriceInterval(deepValleyPriceInterval);
        industrialElecPrice.setExecutionTime(executionTime);
        industrialElecPrice.setSpikePrice(new BigDecimal(array.getJSONObject(7).getString("words")));
        industrialElecPrice.setPeakPrice(new BigDecimal(array.getJSONObject(8).getString("words")));
        industrialElecPrice.setRegularPrice(new BigDecimal(array.getJSONObject(9).getString("words")));
        industrialElecPrice.setLowValleyPrice(new BigDecimal(array.getJSONObject(10).getString("words")));

        industrialElecPrice.setCreateTime(new Date());
        industrialElecPrice.setRegionId(regionId);
        list.add(industrialElecPrice);

        int a = 0;
        for (int i = 0; i < 2; i++) {
            IndustrialElecPrice industrialElecPrice1 = new IndustrialElecPrice();
            industrialElecPrice1.setVoltageLevel(VoltageLevel.getVoltageLevel(array.getJSONObject(12+a).getString("words")));

            String nonTimePrice = array.getJSONObject(13 + a).getString("words");
            if (VoltageLevel.isNumeric(nonTimePrice)) {
                industrialElecPrice1.setNonTimePrice(new BigDecimal(nonTimePrice));
            }
            industrialElecPrice1.setRegionId(regionId);
            industrialElecPrice1.setProxyPrice(new BigDecimal(proxyPrice));


            String transmissionPrice = array.getJSONObject(14 + a).getString("words");
            if (VoltageLevel.isNumeric(transmissionPrice)) {
                industrialElecPrice1.setTransmissionPrice(new BigDecimal(transmissionPrice));
            }

            industrialElecPrice1.setLineLossPrice(new BigDecimal(lineLossPrice));

            industrialElecPrice1.setAddPrice(new BigDecimal(addPrice));

            industrialElecPrice1.setRunningPrice(new BigDecimal(runningPrice));

            industrialElecPrice1.setSpikePrice(new BigDecimal(array.getJSONObject(15 + a).getString("words")));
            industrialElecPrice1.setPeakPrice(new BigDecimal(array.getJSONObject(16 + a).getString("words")));

            industrialElecPrice1.setRegularPrice(new BigDecimal(array.getJSONObject(17 + a).getString("words")));
            industrialElecPrice1.setLowValleyPrice(new BigDecimal(array.getJSONObject(18 + a).getString("words")));

            industrialElecPrice1.setSpikePriceInterval(spikePriceInterval);
            industrialElecPrice1.setPeakPriceInterval(peakPriceInterval);
            industrialElecPrice1.setRegularPriceInterval(regularPriceInterval);
            industrialElecPrice1.setLowValleyPriceInterval(lowValleyPriceInterval);
            industrialElecPrice1.setDeepValleyPriceInterval(deepValleyPriceInterval);
            industrialElecPrice1.setExecutionTime(executionTime);

            industrialElecPrice1.setCreateTime(new Date());
            a = a + 7;
            list.add(industrialElecPrice1);
        }
        IndustrialElecPrice industrialElecPrice2 = new IndustrialElecPrice();
        industrialElecPrice2.setVoltageLevel(VoltageLevel.getVoltageLevel(array.getJSONObject(26).getString("words")));
        industrialElecPrice2.setNonTimePrice(new BigDecimal(array.getJSONObject(27 ).getString("words")));
        industrialElecPrice2.setProxyPrice(new BigDecimal(proxyPrice));
        industrialElecPrice2.setLineLossPrice(new BigDecimal(lineLossPrice));
        industrialElecPrice2.setAddPrice(new BigDecimal(addPrice));
        industrialElecPrice2.setRunningPrice(new BigDecimal(runningPrice));
        industrialElecPrice2.setTransmissionPrice(new BigDecimal(array.getJSONObject(28 ).getString("words")));
        industrialElecPrice2.setSpikePrice(new BigDecimal(array.getJSONObject(29 ).getString("words")));
        industrialElecPrice2.setPeakPrice(new BigDecimal(array.getJSONObject(30 ).getString("words")));
        industrialElecPrice2.setRegularPrice(new BigDecimal(array.getJSONObject(31 ).getString("words")));
        industrialElecPrice2.setLowValleyPrice(new BigDecimal(array.getJSONObject(32 ).getString("words")));
        industrialElecPrice2.setDemandPrice(new BigDecimal(array.getJSONObject(33 ).getString("words")));
        industrialElecPrice2.setCapacityPrice(new BigDecimal(array.getJSONObject(34 ).getString("words")));
        list.add(industrialElecPrice2);

        IndustrialElecPrice industrialElecPrice3 = new IndustrialElecPrice();
        industrialElecPrice3.setVoltageLevel(VoltageLevel.getVoltageLevel(array.getJSONObject(35).getString("words")));
        industrialElecPrice3.setNonTimePrice(new BigDecimal(array.getJSONObject(36 ).getString("words")));
        industrialElecPrice3.setProxyPrice(new BigDecimal(proxyPrice));
        industrialElecPrice3.setLineLossPrice(new BigDecimal(lineLossPrice));
        industrialElecPrice3.setAddPrice(new BigDecimal(addPrice));
        industrialElecPrice3.setRunningPrice(new BigDecimal(runningPrice));
        industrialElecPrice3.setTransmissionPrice(new BigDecimal(array.getJSONObject(37 ).getString("words")));
        industrialElecPrice3.setSpikePrice(new BigDecimal(array.getJSONObject(38 ).getString("words")));
        industrialElecPrice3.setPeakPrice(new BigDecimal(array.getJSONObject(39 ).getString("words")));
        industrialElecPrice3.setRegularPrice(new BigDecimal(array.getJSONObject(40 ).getString("words")));
        industrialElecPrice3.setLowValleyPrice(new BigDecimal(array.getJSONObject(41 ).getString("words")));


        industrialElecPrice3.setDemandPrice(new BigDecimal(array.getJSONObject(33 ).getString("words")));
        industrialElecPrice3.setCapacityPrice(new BigDecimal(array.getJSONObject(34 ).getString("words")));
        list.add(industrialElecPrice3);

        IndustrialElecPrice industrialElecPrice4 = new IndustrialElecPrice();
        industrialElecPrice4.setVoltageLevel(VoltageLevel.getVoltageLevel(array.getJSONObject(42).getString("words")));
        industrialElecPrice4.setNonTimePrice(new BigDecimal(array.getJSONObject(43 ).getString("words")));
        industrialElecPrice4.setProxyPrice(new BigDecimal(proxyPrice));
        industrialElecPrice4.setLineLossPrice(new BigDecimal(lineLossPrice));
        industrialElecPrice4.setAddPrice(new BigDecimal(addPrice));
        industrialElecPrice4.setRunningPrice(new BigDecimal(runningPrice));
        industrialElecPrice4.setTransmissionPrice(new BigDecimal(array.getJSONObject(44 ).getString("words")));
        industrialElecPrice4.setSpikePrice(new BigDecimal(array.getJSONObject(45 ).getString("words")));
        industrialElecPrice4.setPeakPrice(new BigDecimal(array.getJSONObject(46 ).getString("words")));
        industrialElecPrice4.setRegularPrice(new BigDecimal(array.getJSONObject(47 ).getString("words")));
        industrialElecPrice4.setLowValleyPrice(new BigDecimal(array.getJSONObject(48 ).getString("words")));
        industrialElecPrice4.setDemandPrice(new BigDecimal(array.getJSONObject(49 ).getString("words")));
        industrialElecPrice4.setCapacityPrice(new BigDecimal(array.getJSONObject(50 ).getString("words")));
        list.add(industrialElecPrice4);


        IndustrialElecPrice industrialElecPrice5 = new IndustrialElecPrice();
        industrialElecPrice5.setVoltageLevel(VoltageLevel.getVoltageLevel(array.getJSONObject(51).getString("words")));
        industrialElecPrice5.setNonTimePrice(new BigDecimal(proxyPrice));
        industrialElecPrice5.setLineLossPrice(new BigDecimal(lineLossPrice));
        industrialElecPrice5.setAddPrice(new BigDecimal(addPrice));
        industrialElecPrice5.setRunningPrice(new BigDecimal(runningPrice));
        industrialElecPrice5.setProxyPrice(new BigDecimal(array.getJSONObject(56).getString("words")));
        industrialElecPrice5.setTransmissionPrice(new BigDecimal(array.getJSONObject(53 ).getString("words")));
        industrialElecPrice5.setSpikePrice(new BigDecimal(array.getJSONObject(54 ).getString("words")));
        industrialElecPrice5.setPeakPrice(new BigDecimal(array.getJSONObject(55 ).getString("words")));
        industrialElecPrice5.setRegularPrice(new BigDecimal(array.getJSONObject(56 ).getString("words")));
        industrialElecPrice5.setLowValleyPrice(new BigDecimal(array.getJSONObject(57 ).getString("words")));
        industrialElecPrice5.setDemandPrice(new BigDecimal(array.getJSONObject(49 ).getString("words")));
        industrialElecPrice5.setCapacityPrice(new BigDecimal(array.getJSONObject(50 ).getString("words")));
        list.add(industrialElecPrice5);

        return list;
    }
}
