package com.gyee.runeconomy.service.Application;

import com.gyee.common.contant.ContantXk;
import com.gyee.runeconomy.model.auto.ProBasicPowerstationPoint;
import com.gyee.runeconomy.service.auto.IProBasicPowerstationPointService;
import com.gyee.runeconomy.util.MathUtil;
import com.gyee.runeconomy.util.realtimesource.IEdosUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Service
public class CompanylossesService {

    @Resource
    private IEdosUtil edosUtil;

    @Resource
    private IProBasicPowerstationPointService proBasicPowerstationPointService;


    public Map<String, Double> shutdownczjx(String wpId) throws Exception {

        Map<String, Double> map = new HashMap<>();

        double rgzss = 0.0;
        double rcnsl = 0.0;
        double rjxss = 0.0;
        double rcnsljx = 0.0;
        double rdjss = 0.0;
        double rqxjclss = 0.0;
        double rsdtjss = 0.0;
        double rxnssdl = 0.0;
        double rxdtjss = 0.0;
        double rxdjclss = 0.0;
        double rcwsldwss = 0.0;
        double rcwsltqss = 0.0;
        ProBasicPowerstationPoint rgzssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.RGZSSDL);
        rgzss = edosUtil.getRealData(rgzssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint rcnslgzvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.RCNSLGZSSDL);
        rcnsl = edosUtil.getRealData(rcnslgzvalue).getPointValueInDouble();

        ProBasicPowerstationPoint rjxssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.RJXSSDL);
        rjxss = edosUtil.getRealData(rjxssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint rcnsljxvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.RCNSLJXSSDL);
        rcnsljx = edosUtil.getRealData(rcnsljxvalue).getPointValueInDouble();

        ProBasicPowerstationPoint rdjssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.RDJSSDL);
        rdjss = edosUtil.getRealData(rdjssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint rqxjclssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.RQXJCLSSDL);
        rqxjclss = edosUtil.getRealData(rqxjclssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint rsdtjssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.RSDTJSSDL);
        rsdtjss = edosUtil.getRealData(rsdtjssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint rxnssdlvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.RXNSSDL);
        rxnssdl = edosUtil.getRealData(rxnssdlvalue).getPointValueInDouble();

        ProBasicPowerstationPoint rxdtjssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.RXDTJSSDL);
        rxdtjss = edosUtil.getRealData(rxdtjssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint rxdjclssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.RXDJCLSSDL);
        rxdjclss = edosUtil.getRealData(rxdjclssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint rcwsldwssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.RCWSLDWSSDL);
        rcwsldwss = edosUtil.getRealData(rcwsldwssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint rcwsltqssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.RCWSLTQSSDL);
        rcwsltqss = edosUtil.getRealData(rcwsltqssvalue).getPointValueInDouble();

        double rgzssdl = rgzss + rcnsl;
        double rwhssdl = rjxss + rcnsljx;
        double rxnssdl1 = rdjss + rqxjclss + rsdtjss + rxnssdl;
        double rxdssdl = rxdtjss + rxdjclss;
        double rslssdl = rcwsldwss + rcwsltqss;

        map.put("rgzssdl", MathUtil.twoBit(rgzssdl / 10000));
        map.put("rwhssdl", MathUtil.twoBit(rwhssdl / 10000));
        map.put("rxnssdl", MathUtil.twoBit(rxnssdl1 / 10000));
        map.put("rxdssdl", MathUtil.twoBit(rxdssdl / 10000));
        map.put("rslssdl", MathUtil.twoBit(rslssdl / 10000));

        double ygzss = 0.0;
        double ycnslgzss = 0.0;
        double ycnsljxss = 0.0;
        double yjxss = 0.0;
        double ydjss = 0.0;
        double yqxjclss = 0.0;
        double ysdtjss = 0.0;
        double yxnss = 0.0;
        double yxdtjss = 0.0;
        double yxdjclss = 0.0;
        double ycwsldwss = 0.0;
        double ycwsltqss = 0.0;

        ProBasicPowerstationPoint ygzssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.YGZSSDL);
        ygzss = edosUtil.getRealData(ygzssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint ycnslgzssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.YCNSLGZSSDL);
        ycnslgzss = edosUtil.getRealData(ycnslgzssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint yjxssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.YJXSSDL);
        yjxss = edosUtil.getRealData(yjxssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint ycnsljxssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.YCNSLJXSSDL);
        ycnsljxss = edosUtil.getRealData(ycnsljxssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint ydjssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.YDJSSDL);
        ydjss = edosUtil.getRealData(ydjssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint yqxjclssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.YQXJCLSSDL);
        yqxjclss = edosUtil.getRealData(yqxjclssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint ysdtjssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.YSDTJSSDL);
        ysdtjss = edosUtil.getRealData(ysdtjssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint yxnssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.YXNSSDL);
        yxnss = edosUtil.getRealData(yxnssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint yxdtjssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.YXDTJSSDL);
        yxdtjss = edosUtil.getRealData(yxdtjssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint yxdjclssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.YXDJCLSSDL);
        yxdjclss = edosUtil.getRealData(yxdjclssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint ycwsldwssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.YCWSLDWSSDL);
        ycwsldwss = edosUtil.getRealData(ycwsldwssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint ycwsltqssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.YCWSLTQSSDL);
        ycwsltqss = edosUtil.getRealData(ycwsltqssvalue).getPointValueInDouble();

        double ygzssdl = ygzss + ycnslgzss;
        double ywhssdl = yjxss + ycnsljxss;
        double yxnssdl = ydjss + yqxjclss + ysdtjss + yxnss;
        double yxdssdl = yxdtjss + yxdjclss;
        double yslssdl = ycwsldwss + ycwsltqss;
        map.put("ygzssdl", MathUtil.twoBit(ygzssdl / 10000));
        map.put("ywhssdl", MathUtil.twoBit(ywhssdl / 10000));
        map.put("yxnssdl", MathUtil.twoBit(yxnssdl / 10000));
        map.put("yxdssdl", MathUtil.twoBit(yxdssdl / 10000));
        map.put("yslssdl", MathUtil.twoBit(yslssdl / 10000));
        double ngzss = 0.0;
        double ncnsslgzss = 0.0;
        double njxss = 0.0;
        double ncnsljxss = 0.0;
        double ndjss = 0.0;
        double nqxjclss = 0.0;
        double nsdtjssdl = 0.0;
        double nxnss = 0.0;
        double nxdjclss = 0.0;
        double nxdtjss = 0.0;
        double ncwsldwss = 0.0;
        double ncwsltqss = 0.0;
        ProBasicPowerstationPoint ngzssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.NGZSSDL);
        ngzss = edosUtil.getRealData(ngzssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint ncnsslgzssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.NCNSLGZSSDL);
        ncnsslgzss = edosUtil.getRealData(ncnsslgzssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint njxssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.NJXSSDL);
        njxss = edosUtil.getRealData(njxssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint ncnsljxssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.NCNSLJXSSDL);
        ncnsljxss = edosUtil.getRealData(ncnsljxssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint ndjssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.NDJSSDL);
        ndjss = edosUtil.getRealData(ndjssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint nqxjclssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.NQXJCLSSDL);
        nqxjclss = edosUtil.getRealData(nqxjclssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint nsdtjssdlvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.NSDTJSSDL);
        nsdtjssdl = edosUtil.getRealData(nsdtjssdlvalue).getPointValueInDouble();

        ProBasicPowerstationPoint nxnssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.NXNSSDL);
        nxnss = edosUtil.getRealData(nxnssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint nxdtjssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.NXDTJSSDL);
        nxdtjss = edosUtil.getRealData(nxdtjssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint nxdjclssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.NXDJCLSSDL);
        nxdjclss = edosUtil.getRealData(nxdjclssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint ncwsldwssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.NCWSLDWSSDL);
        ncwsldwss = edosUtil.getRealData(ncwsldwssvalue).getPointValueInDouble();

        ProBasicPowerstationPoint ncwsltqssvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.NCWSLTQSSDL);
        ncwsltqss = edosUtil.getRealData(ncwsltqssvalue).getPointValueInDouble();

        double ngzssdl = ngzss + ncnsslgzss;
        double nwhssdl = njxss + ncnsljxss;
        double nxnssdl = ndjss + nqxjclss + nsdtjssdl + nxnss;
        double nxdssdl = nxdjclss + nxdtjss;
        double nslssdl = ncwsldwss + ncwsltqss;
        map.put("ngzssdl", MathUtil.twoBit(ngzssdl / 10000));
        map.put("nwhssdl", MathUtil.twoBit(nwhssdl / 10000));
        map.put("nxnssdl", MathUtil.twoBit(nxnssdl / 10000));
        map.put("nxdssdl", MathUtil.twoBit(nxdssdl / 10000));
        map.put("nslssdl", MathUtil.twoBit(nslssdl / 10000));

        return map;
    }
}
