package com.gyee.alarm.service.realtimelibrary;

import com.gyee.common.contant.Contant;
import com.gyee.common.contant.ContantXk;
import com.gyee.common.model.PointData;
import com.gyee.common.model.StringUtils;
import com.gyee.common.util.DateUtils;
import com.gyee.alarm.init.CacheContext;
import com.gyee.alarm.model.auto.*;
import com.gyee.alarm.util.PointUtil;
import com.gyee.alarm.util.realtimesource.IEdosUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;

/*
@author   谢生杰
@date   2022/11/14-14:00
*/
@Service
public class StatusService {

    @Resource
    private IEdosUtil edosUtil;

    @Value("${AI110}")
    private String AI110;
    @Value("${second}")
    private String second;

    Map<String,Double> powerCache = new HashMap<>();
    /**
     * 判断调度场站限电
     */
    public void powerRationing() throws Exception {

        List<PointData> resultList = new ArrayList<>();
        List<ProBasicSubStation> subwpls = CacheContext.subwpls;
        Map<String, Map<String, ProBasicPowerstationPoint>> subwppointmap = CacheContext.subwppointmap;
        List<ProBasicProject> pjls = CacheContext.pjls;
        Map<String, Map<String, ProBasicPowerstationPoint>> propointmap = CacheContext.propointmap;
        Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
        Map<String, List<ProBasicEquipment>> subWtsMap = CacheContext.subWtsMap;
        Map<String, Double> modelpower = CacheContext.modelpower;

        Date currentDate = DateUtils.getCurrentDate();
        Date fiveDate = DateUtils.addMinutes(currentDate, -5);

        subwpls.stream().forEach(sub->{
            powerCache.put(sub.getId(),-1d);

            //算调度场站自算功率
            Map<String, ProBasicPowerstationPoint> stringProBasicPowerstationPointMap = subwppointmap.get(sub.getId());

            ProBasicPowerstationPoint zsglPoint = stringProBasicPowerstationPointMap.get(ContantXk.TPOINT_WP_ZSGL);
            AtomicReference<Double> zsgl = new AtomicReference<>((double) 0);
            List<ProBasicProject> basicProjects = pjls.stream().filter(p -> p.getWindsubStationId().equals(sub.getId())).collect(Collectors.toList());
            basicProjects.stream().forEach(p->{
                Map<String, ProBasicPowerstationPoint> powerstationPointMap = propointmap.get(p.getId());
                ProBasicPowerstationPoint powerstationPoint = powerstationPointMap.get(ContantXk.SSZNHGLZS);

                zsgl.updateAndGet(v -> {
                    try {
                        return new Double((double) (v + edosUtil.getSectionData(powerstationPoint, currentDate.getTime()).getPointValueInDouble()));
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    return v;
                });
            });
            try {
                edosUtil.sendSinglePoint(PointUtil.createPointData(currentDate,zsgl.get(),zsglPoint.getNemCode(),zsglPoint.getName()));
            } catch (Exception e) {
                e.printStackTrace();
            }
        });




        subwpls.stream().forEach(sub->{
            Map<String, ProBasicPowerstationPoint> stringProBasicPowerstationPointMap = subwppointmap.get(sub.getId());

            ProBasicPowerstationPoint agcPoint = stringProBasicPowerstationPointMap.get(ContantXk.TPOINT_WP_AGC);

            ProBasicPowerstationPoint cxglPoint = stringProBasicPowerstationPointMap.get(ContantXk.TPOINT_WP_CXGL);
            ProBasicPowerstationPoint xdztPoint = stringProBasicPowerstationPointMap.get(ContantXk.TPOINT_WP_XDZT);
            ProBasicPowerstationPoint zsglPoint = stringProBasicPowerstationPointMap.get(ContantXk.TPOINT_WP_ZSGL);
            double agc = 0;
            double xdzt = 0;
            double zsgl5 = 0;
            double zsgl = 0;
            double cxgl = 0;
            double cxgl5 = 0;
            double agc5 = 0;
            try {
                agc = edosUtil.getSectionData(agcPoint,currentDate.getTime()).getPointValueInDouble();
                xdzt = edosUtil.getSectionData(xdztPoint,currentDate.getTime()).getPointValueInDouble();
                Optional<PointData> zsglFirst = edosUtil.getHistStat(zsglPoint, fiveDate.getTime() / 1000, currentDate.getTime() / 1000, 1l, 300l, 2).stream().findFirst();
                Optional<PointData> agcFirst = edosUtil.getHistStat(agcPoint, fiveDate.getTime() / 1000, currentDate.getTime() / 1000, 1l, 300l, 2).stream().findFirst();
                Optional<PointData> cxglFirst = edosUtil.getHistStat(cxglPoint, fiveDate.getTime() / 1000, currentDate.getTime() / 1000, 1l, 300l, 2).stream().findFirst();
                zsgl = edosUtil.getSectionData(zsglPoint,currentDate.getTime()).getPointValueInDouble();
                cxgl = edosUtil.getSectionData(cxglPoint,currentDate.getTime()).getPointValueInDouble();
                if (zsglFirst.isPresent()){
                    zsgl5 = zsglFirst.get().getPointValueInDouble();
                }
                if (agcFirst.isPresent()){
                    agc5 = agcFirst.get().getPointValueInDouble();
                }
                if (cxglFirst.isPresent()){
                    cxgl5 = cxglFirst.get().getPointValueInDouble();
                }

            } catch (Exception e) {
                e.printStackTrace();
            }

            boolean k = false;   //限电一直不变

            //第一次初始化复制实时数据到缓存
            if (powerCache.containsKey(sub.getId())){
                if (powerCache.get(sub.getId()).equals(-1)){
                    powerCache.put(sub.getId(),agc);
                }else if (powerCache.get(sub.getId()) == agc){
                    k = true;
                }else {
                    powerCache.put(sub.getId(),agc);
                }
            }

            boolean b = false;   //默认不限电
            if (xdzt==0){
                if (zsgl5>=sub.getCapacity()*0.4){
                    if (zsgl/agc>=1.2 && agc-cxgl<=2){
                        b = true;
                    }
                    if (agc5<=cxgl5){
                        b = true;
                    }
                }else {
                    if (k){
                        if (agc5<=cxgl5){
                            b = true;
                        }
                        if (zsgl/agc>=1.1 && agc5-cxgl5<=2){
                            b = true;
                        }
                    }
                }
            }else {
                if (zsgl5>=sub.getCapacity()*0.4){
                    if (zsgl/agc>1.15){
                        b = true;
                    }
                    if (agc5<=cxgl5){
                        b = true;
                    }
                    if (zsgl>agc && agc5-cxgl5<4){
                        b = true;
                    }
                }
            }
            double xdValue = 0;

            if (b){
                xdValue = 1;
                //判断风机是否限电
                List<ProBasicEquipment> proBasicEquipments = subWtsMap.get(sub.getId());
                proBasicEquipments.stream().forEach(wt->{
                    double fjxd = 0;
                    Map<String, ProBasicEquipmentPoint> basicEquipmentPointMap = wtpAimap.get(wt.getId());
                    ProBasicEquipmentPoint ssglPoint = basicEquipmentPointMap.get(ContantXk.CJ_SSGL);
                    ProBasicEquipmentPoint ssfsPoint = basicEquipmentPointMap.get(ContantXk.CJ_SSFS);
                    ProBasicEquipmentPoint qfztPoint = basicEquipmentPointMap.get(ContantXk.SSQFZT);
                    ProBasicEquipmentPoint gpztPoint = basicEquipmentPointMap.get(ContantXk.GPZT);
                    ProBasicEquipmentPoint fjxdztPoint = basicEquipmentPointMap.get(ContantXk.XDZT);

                    double ssgl = 0;
                    double ssfs = 0;
                    double qfzt = 0;
                    double gpzt = 0;
                    try {
                        ssgl = edosUtil.getSectionData(ssglPoint,currentDate.getTime()).getPointValueInDouble();
                        ssfs = edosUtil.getSectionData(ssfsPoint,currentDate.getTime()).getPointValueInDouble();
                        qfzt = edosUtil.getSectionData(qfztPoint,currentDate.getTime()).getPointValueInDouble();
                        gpzt = edosUtil.getSectionData(gpztPoint,currentDate.getTime()).getPointValueInDouble();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    Double capacity = modelpower.get(wt.getModelId());
                    if (ssgl<capacity*0.9){
                        if (ssfs>=12 && ssgl<capacity){
                            fjxd = 1;
                        }
                        if (qfzt>=3){
                            fjxd = 1;
                        }
                        boolean jcl = false;
                        try {
                            jcl = isJcl(currentDate,basicEquipmentPointMap);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (jcl){
                            fjxd = 1;
                        }
                        if (gpzt==1){
                            fjxd = 1;
                        }
                    }
                    if (agcPoint.getNemCode().equals("INITIAL")){
                        resultList.add(PointUtil.createPointData(currentDate,0,fjxdztPoint.getNemCode(),fjxdztPoint.getName()));
                    }else{
                        resultList.add(PointUtil.createPointData(currentDate,fjxd,fjxdztPoint.getNemCode(),fjxdztPoint.getName()));
                    }
                });
            }
            if (agcPoint.getNemCode().equals("INITIAL")){
                resultList.add(PointUtil.createPointData(currentDate,0,xdztPoint.getNemCode(),xdztPoint.getName()));
            }else{
                resultList.add(PointUtil.createPointData(currentDate,xdValue,xdztPoint.getNemCode(),xdztPoint.getName()));
            }
        });
        edosUtil.sendMultiPoint(resultList);
    }


    /**
     * 判断是否降出力
     * @param stringWindturbinetestingpointnewMap
     * @return
     * @throws Exception
     */
    private boolean isJcl(Date currentDate, Map<String, ProBasicEquipmentPoint> stringWindturbinetestingpointnewMap) throws Exception {
        boolean isJcl = false;
        ProBasicEquipmentPoint zsgdPoint = stringWindturbinetestingpointnewMap.get(ContantXk.CJ_YLZSGD);
        if (zsgdPoint != null){
            if (!zsgdPoint.getNemCode().equals("INITIAL")){
                Double realData = edosUtil.getSectionData(zsgdPoint,currentDate.getTime()).getPointValueInDouble();
                if (realData<Double.parseDouble(AI110)){
                    isJcl = true;
                }
            }
        }

        return isJcl;
    }

    /**
     * 计算风机状态
     */
    public void statusReal() throws Exception {
        Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
        List<ProBasicEquipment> wtls = CacheContext.wtls;
        Map<String, List<ProBasicStatusPoint>> statusMap = CacheContext.statusMap;
        Map<String, ProEconEquipmentmodel> modelMap = CacheContext.modelMap;
        Map<String, Map<Integer, Integer>> aistateMap = CacheContext.aistateMap;
        Date currentDate = DateUtils.getCurrentDate();

        List<PointData> resultList = new ArrayList<>();

        wtls.stream().forEach(wt->{
            Map<String, ProBasicEquipmentPoint> equipmentPointMap = wtpAimap.get(wt.getId());
            //限电状态点
            ProBasicEquipmentPoint xdztPoint = equipmentPointMap.get(ContantXk.XDZT);
            //挂牌状态点
            ProBasicEquipmentPoint gpztPoint = equipmentPointMap.get(ContantXk.GPZT);
            //设备状态点
            ProBasicEquipmentPoint sbztPoint = equipmentPointMap.get(ContantXk.SBZT);
            //明细状态点
            ProBasicEquipmentPoint mxztPoint = equipmentPointMap.get(ContantXk.MXZT);
            //实时功率点
            ProBasicEquipmentPoint ssglPoint = equipmentPointMap.get(ContantXk.CJ_SSGL);
            //状态持续时间，以秒计算
            ProBasicEquipmentPoint ztcxsjPoint = equipmentPointMap.get(ContantXk.ZTCXSJ);

            String[] interruption = null;
            if (wt.getEquipmentCategory()==-1){
                interruption = ContantXk.INTERRUPTION.split(",");
            }else if (wt.getEquipmentCategory()==-2){
                interruption = ContantXk.INTERRUPTIONGF.split(",");
            }

            List<String> interruptionList = new ArrayList<>();
            Arrays.stream(interruption).forEach(i->{
                ProBasicEquipmentPoint equipmentPoint = equipmentPointMap.get(i);
                if (!equipmentPoint.getNemCode().equals("INITIAL")){
                    interruptionList.add(equipmentPoint.getNemCode());
                }
            });
            double mxzt = 0;
            double ztcxsj = 0;
            try {
                mxzt = edosUtil.getSectionData(mxztPoint,currentDate.getTime()).getPointValueInDouble();
                ztcxsj = edosUtil.getSectionData(ztcxsjPoint,currentDate.getTime()).getPointValueInDouble();
            } catch (Exception e) {
                e.printStackTrace();
            }

            Double status = 1.0;
            Double mxstatus = 2.0;
            try {
                if (StringUtils.isEmpty(interruptionList)){
                    mxstatus = 12.0;
                    status = 6.0;
                }
                else {
                    List<PointData> interruptionRealData = edosUtil.getRealData(interruptionList);
                    long time = currentDate.getTime();
                    List<PointData> collect = interruptionRealData.stream().filter(i -> (currentDate.getTime() - i.getPointTime()) / 1000 > Integer.parseInt(second)).collect(Collectors.toList());
                    if (collect.size()!=interruptionRealData.size()){
                        double ssgl = edosUtil.getSectionData(ssglPoint,currentDate.getTime()).getPointValueInDouble();
                        double gpzt = edosUtil.getSectionData(gpztPoint,currentDate.getTime()).getPointValueInDouble();
                        double xdzt = edosUtil.getSectionData(xdztPoint,currentDate.getTime()).getPointValueInDouble();

                        //  0, "正常状态";1, "限电";2, "场内受累检修";3, "场内受累故障";4, "场外受累电网";5, "场外受累天气";6, "发电限负荷";
                        if(gpzt != 0){
                            //获取挂牌状态给明细状态赋值
                            mxstatus = getGpzt(gpzt,ssgl);
                        }else if (xdzt == 1){
                            mxstatus = getGpzt(1,ssgl);
                        }else {
                            mxstatus = getMxzt(modelMap,aistateMap,statusMap,wt);
                        }
                        if (mxstatus == 2){
                            boolean isJcl = isJcl(currentDate, equipmentPointMap);
                            if (ssgl<=0){
                                mxstatus=0.0;
                            }else if (isJcl){
                                mxstatus = 3.0;
                            }
                        }

                    }else{
                        //离线
                        mxstatus = 12.0;
                    }
                    if (mxstatus == 0 || mxstatus == 1){
                        status = 0.0;
                    }else if(mxstatus == 2 || mxstatus == 3){
                        status = 1.0;
                    }else if(mxstatus == 4 || mxstatus == 5){
                        status = 2.0;
                    }else if(mxstatus == 6 || mxstatus == 7){
                        status = 3.0;
                    }else if(mxstatus == 8 || mxstatus == 9){
                        status = 4.0;
                    }else if(mxstatus == 10 || mxstatus == 11){
                        status = 5.0;
                    }else if(mxstatus == 12 || mxstatus == 13){
                        status = 6.0;
                    }
                }
                if (mxstatus == mxzt){
                    ztcxsj ++;
                }else {
                    ztcxsj = 0;
                }
                resultList.add(PointUtil.createPointData(currentDate,mxstatus,mxztPoint.getNemCode(),mxztPoint.getName()));
                resultList.add(PointUtil.createPointData(currentDate,status,sbztPoint.getNemCode(),sbztPoint.getName()));
                resultList.add(PointUtil.createPointData(currentDate,ztcxsj,ztcxsjPoint.getNemCode(),ztcxsjPoint.getName()));
            } catch (Exception e) {
                e.printStackTrace();
            }

        });
        edosUtil.sendMultiPoint(resultList);
    }

    /**
     * 计算状态台数
     */
    public void calculateStatusNumber() throws Exception {
        List<ProBasicPowerstation> wpls = CacheContext.wpls;
        Map<String, List<ProBasicProject>> wppromap = CacheContext.wppromap;
        Map<String, Map<String, ProBasicPowerstationPoint>> wppointmap = CacheContext.wppointmap;
        Map<String, Map<String, ProBasicPowerstationPoint>> propointmap = CacheContext.propointmap;
        Map<String, Map<String, ProBasicPowerstationPoint>> linepointmap = CacheContext.linepointmap;
        Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
        Map<String, List<ProBasicLine>> prolinemap = CacheContext.prolinemap;
        Map<String, List<ProBasicEquipment>> lnwtmap = CacheContext.lnwtmap;
        List<PointData> resultList = new ArrayList<>();
        Date currentDate = DateUtils.getCurrentDate();
        wpls.stream().forEach(wp->{
            List<ProBasicProject> projects = wppromap.get(wp.getId());
            Map<String, ProBasicPowerstationPoint> wpmap = wppointmap.get(wp.getId());
            AtomicInteger wpdjnum = new AtomicInteger();
            AtomicInteger wptjnum = new AtomicInteger();
            AtomicInteger wpfdnum = new AtomicInteger();
            AtomicInteger wpfdjclnum = new AtomicInteger();
            AtomicInteger wpxdjclnum = new AtomicInteger();
            AtomicInteger wpxdtjnum = new AtomicInteger();
            AtomicInteger wpgznum = new AtomicInteger();
            AtomicInteger wpcngznum = new AtomicInteger();
            AtomicInteger wpjxnum = new AtomicInteger();
            AtomicInteger wpcnjxnum = new AtomicInteger();
            AtomicInteger wpdwslnum = new AtomicInteger();
            AtomicInteger wphjslnum = new AtomicInteger();
            AtomicInteger wplxnum = new AtomicInteger();
            AtomicInteger wpwznum = new AtomicInteger();
            //六种
            AtomicInteger wpdjts = new AtomicInteger();
            AtomicInteger wpgzts = new AtomicInteger();
            AtomicInteger wptxzd = new AtomicInteger();
            AtomicInteger wpwhtj = new AtomicInteger();
            AtomicInteger wpxdts = new AtomicInteger();
            AtomicInteger wpyxts = new AtomicInteger();
            AtomicInteger wpslts = new AtomicInteger();
            projects.stream().forEach(project->{
                List<ProBasicLine> lineList = prolinemap.get(project.getId());
                Map<String, ProBasicPowerstationPoint> projectmap = propointmap.get(project.getId());
                AtomicInteger prodjnum = new AtomicInteger();
                AtomicInteger protjnum = new AtomicInteger();
                AtomicInteger profdnum = new AtomicInteger();
                AtomicInteger profdjclnum = new AtomicInteger();
                AtomicInteger proxdjclnum = new AtomicInteger();
                AtomicInteger proxdtjnum = new AtomicInteger();
                AtomicInteger progznum = new AtomicInteger();
                AtomicInteger procngznum = new AtomicInteger();
                AtomicInteger projxnum = new AtomicInteger();
                AtomicInteger procnjxnum = new AtomicInteger();
                AtomicInteger prodwslnum = new AtomicInteger();
                AtomicInteger prohjslnum = new AtomicInteger();
                AtomicInteger prolxnum = new AtomicInteger();
                AtomicInteger prowznum = new AtomicInteger();

                //六种
                AtomicInteger prodjts = new AtomicInteger();
                AtomicInteger progzts = new AtomicInteger();
                AtomicInteger protxzd = new AtomicInteger();
                AtomicInteger prowhtj = new AtomicInteger();
                AtomicInteger proxdts = new AtomicInteger();
                AtomicInteger proyxts = new AtomicInteger();
                AtomicInteger proslts = new AtomicInteger();

                lineList.stream().forEach(line->{
                    List<ProBasicEquipment> windturbines = lnwtmap.get(line.getId());
                    Map<String, ProBasicPowerstationPoint> linemap = linepointmap.get(line.getId());
                    AtomicInteger djnum = new AtomicInteger();
                    AtomicInteger tjnum = new AtomicInteger();
                    AtomicInteger fdnum = new AtomicInteger();
                    AtomicInteger fdjclnum = new AtomicInteger();
                    AtomicInteger xdjclnum = new AtomicInteger();
                    AtomicInteger xdtjnum = new AtomicInteger();
                    AtomicInteger gznum = new AtomicInteger();
                    AtomicInteger cngznum = new AtomicInteger();
                    AtomicInteger jxnum = new AtomicInteger();
                    AtomicInteger cnjxnum = new AtomicInteger();
                    AtomicInteger dwslnum = new AtomicInteger();
                    AtomicInteger hjslnum = new AtomicInteger();
                    AtomicInteger lxnum = new AtomicInteger();
                    AtomicInteger wznum = new AtomicInteger();
                    //六种
                    AtomicInteger djts = new AtomicInteger();
                    AtomicInteger gzts = new AtomicInteger();
                    AtomicInteger txzd = new AtomicInteger();
                    AtomicInteger whtj = new AtomicInteger();
                    AtomicInteger xdts = new AtomicInteger();
                    AtomicInteger yxts = new AtomicInteger();
                    AtomicInteger slts = new AtomicInteger();
                    windturbines.stream().forEach(wt->{
                        ProBasicEquipmentPoint windturbinetestingpointnew = wtpAimap.get(wt.getId()).get(ContantXk.MXZT);
                        try {
                            double valueInDouble = edosUtil.getSectionData(windturbinetestingpointnew,currentDate.getTime()).getPointValueInDouble();
                            switch ((int) valueInDouble){
                                case 0:
                                    djnum.getAndIncrement();
                                    break;
                                case 1:
                                    tjnum.getAndIncrement();
                                    break;
                                case 2:
                                    fdnum.getAndIncrement();
                                    break;
                                case 3:
                                    fdjclnum.getAndIncrement();
                                    break;
                                case 4:
                                    gznum.getAndIncrement();
                                    break;
                                case 5:
                                    cngznum.getAndIncrement();
                                    break;
                                case 6:
                                    jxnum.getAndIncrement();
                                    break;
                                case 7:
                                    cnjxnum.getAndIncrement();
                                    break;
                                case 8:
                                    xdjclnum.getAndIncrement();
                                    break;
                                case 9:
                                    xdtjnum.getAndIncrement();
                                    break;
                                case 10:
                                    dwslnum.getAndIncrement();
                                    break;
                                case 11:
                                    hjslnum.getAndIncrement();
                                    break;
                                case 12:
                                    lxnum.getAndIncrement();
                                    break;
                                case 13:
                                    wznum.getAndIncrement();
                                    break;
                                default:
                                    fdnum.getAndIncrement();
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    });
                    //待机台数0
                    ProBasicPowerstationPoint djnumPointNew = linemap.get(ContantXk.DJTSMX);
                    PointData djnumPoint = PointUtil.createPointData(currentDate,djnum.get(),djnumPointNew.getNemCode(),djnumPointNew.getName());
                    prodjnum.addAndGet(djnum.intValue());
                    resultList.add(djnumPoint);
                    //停机台数1
                    ProBasicPowerstationPoint tjnumPointNew = linemap.get(ContantXk.SDTJTSMX);
                    PointData tjnumPoint = PointUtil.createPointData(currentDate,tjnum.get(),tjnumPointNew.getNemCode(),tjnumPointNew.getName());
                    protjnum.addAndGet(tjnum.intValue());
                    resultList.add(tjnumPoint);
                    //待机台数6-0
                    djts.addAndGet(djnum.intValue()+tjnum.intValue());
                    ProBasicPowerstationPoint djtsPointNew = linemap.get(ContantXk.DJTS);
                    PointData djtsPoint = PointUtil.createPointData(currentDate,djts.get(),djtsPointNew.getNemCode(),djtsPointNew.getName());
                    resultList.add(djtsPoint);
                    //运行台数2
                    ProBasicPowerstationPoint fdnumPointNew = linemap.get(ContantXk.XNTSMX);
                    PointData fdnumPoint = PointUtil.createPointData(currentDate,fdnum.get(),fdnumPointNew.getNemCode(),fdnumPointNew.getName());
                    profdnum.addAndGet(fdnum.intValue());
                    resultList.add(fdnumPoint);
                    //降出力台数3
                    ProBasicPowerstationPoint fdjclnumPointNew = linemap.get(ContantXk.QXJCLTSMX);
                    PointData fdjclnumPoint = PointUtil.createPointData(currentDate,fdjclnum.get(),fdjclnumPointNew.getNemCode(),fdjclnumPointNew.getName());
                    profdjclnum.addAndGet(fdjclnum.intValue());
                    resultList.add(fdjclnumPoint);
                    //运行台数6-1
                    yxts.addAndGet(fdnum.intValue()+fdjclnum.intValue());
                    ProBasicPowerstationPoint yxtsPointNew = linemap.get(ContantXk.YXTS);
                    PointData yxtsPoint = PointUtil.createPointData(currentDate,yxts.get(),yxtsPointNew.getNemCode(),yxtsPointNew.getName());
                    resultList.add(yxtsPoint);

                    //限电降出力台数4
                    ProBasicPowerstationPoint xdjclnumPointNew = linemap.get(ContantXk.XDJCLTSMX);
                    PointData xdjclnumPoint = PointUtil.createPointData(currentDate,xdjclnum.get(),xdjclnumPointNew.getNemCode(),xdjclnumPointNew.getName());
                    proxdjclnum.addAndGet(xdjclnum.intValue());
                    resultList.add(xdjclnumPoint);
                    //限电停机台数5
                    ProBasicPowerstationPoint xdtjnumPointNew = linemap.get(ContantXk.XDTJTSMX);
                    PointData xdtjnumPoint = PointUtil.createPointData(currentDate,xdtjnum.get(),xdtjnumPointNew.getNemCode(),xdtjnumPointNew.getName());
                    proxdtjnum.addAndGet(xdtjnum.intValue());
                    resultList.add(xdtjnumPoint);
                    //限电台数6-5
                    xdts.addAndGet(xdjclnum.intValue()+xdtjnum.intValue());
                    ProBasicPowerstationPoint xdtsPointNew = linemap.get(ContantXk.XDTS);
                    PointData xdtsPoint = PointUtil.createPointData(currentDate,xdts.get(),xdtsPointNew.getNemCode(),xdtsPointNew.getName());
                    resultList.add(xdtsPoint);

                    //故障台数6
                    ProBasicPowerstationPoint gznumPointNew = linemap.get(ContantXk.GZTSMX);
                    PointData gznumPoint = PointUtil.createPointData(currentDate,gznum.get(),gznumPointNew.getNemCode(),gznumPointNew.getName());
                    progznum.addAndGet(gznum.intValue());
                    resultList.add(gznumPoint);
                    //故障受累台数7
                    ProBasicPowerstationPoint cngznumPointNew = linemap.get(ContantXk.CNSLGZTSMX);
                    PointData cngznumPoint = PointUtil.createPointData(currentDate,cngznum.get(),cngznumPointNew.getNemCode(),cngznumPointNew.getName());
                    procngznum.addAndGet(cngznum.intValue());
                    resultList.add(cngznumPoint);

                    //检修台数8
                    ProBasicPowerstationPoint jxnumPointNew = linemap.get(ContantXk.JXTSMX);
                    PointData jxnumPoint = PointUtil.createPointData(currentDate,jxnum.get(),jxnumPointNew.getNemCode(),jxnumPointNew.getName());
                    projxnum.addAndGet(jxnum.intValue());
                    resultList.add(jxnumPoint);
                    //检修受累台数9
                    ProBasicPowerstationPoint cnjxnumPointNew = linemap.get(ContantXk.CNSLJXTSMX);
                    PointData cnjxnumPoint = PointUtil.createPointData(currentDate,cnjxnum.get(),cnjxnumPointNew.getNemCode(),cnjxnumPointNew.getName());
                    procnjxnum.addAndGet(cnjxnum.intValue());
                    resultList.add(cnjxnumPoint);

                    //检修台数6-4
                    whtj.addAndGet(jxnum.intValue()+cnjxnum.intValue());
                    ProBasicPowerstationPoint whtjPointNew = linemap.get(ContantXk.JXTJTS);
                    PointData whtjPoint = PointUtil.createPointData(currentDate,whtj.get(),whtjPointNew.getNemCode(),whtjPointNew.getName());
                    resultList.add(whtjPoint);
                    //电网受累台数10
                    ProBasicPowerstationPoint dwslnumPointNew = linemap.get(ContantXk.CWSLDWTSMX);
                    PointData dwslnumPoint = PointUtil.createPointData(currentDate,dwslnum.get(),dwslnumPointNew.getNemCode(),dwslnumPointNew.getName());
                    prodwslnum.addAndGet(dwslnum.intValue());
                    resultList.add(dwslnumPoint);
                    //环境受累台数11
                    ProBasicPowerstationPoint hjslnumPointNew = linemap.get(ContantXk.CWSLTQTSMX);
                    PointData hjslnumPoint = PointUtil.createPointData(currentDate,hjslnum.get(),hjslnumPointNew.getNemCode(),hjslnumPointNew.getName());
                    prohjslnum.addAndGet(hjslnum.intValue());
                    resultList.add(hjslnumPoint);

                    //故障台数6-2
                    gzts.addAndGet(gznum.intValue()+cngznum.intValue());
                    ProBasicPowerstationPoint gztsPointNew = linemap.get(ContantXk.GZTJTS);
                    PointData gztjPoint = PointUtil.createPointData(currentDate,gzts.get(),gztsPointNew.getNemCode(),gztsPointNew.getName());
                    resultList.add(gztjPoint);
                    //受累台数6-6
                    slts.addAndGet(dwslnum.intValue()+hjslnum.intValue());
                    ProBasicPowerstationPoint sltsPointNew = linemap.get(ContantXk.SLTS);
                    PointData sltjPoint = PointUtil.createPointData(currentDate,slts.get(),sltsPointNew.getNemCode(),sltsPointNew.getName());
                    resultList.add(sltjPoint);

                    //离线台数12
                    ProBasicPowerstationPoint lxnumPointNew = linemap.get(ContantXk.LXTSMX);
                    PointData lxnumPoint = PointUtil.createPointData(currentDate,lxnum.get(),lxnumPointNew.getNemCode(),lxnumPointNew.getName());
                    prolxnum.addAndGet(lxnum.intValue());
                    resultList.add(lxnumPoint);
                    //未知离线13
                    ProBasicPowerstationPoint wznumPointNew = linemap.get(ContantXk.TXZDTSMX);
                    PointData wznumPoint = PointUtil.createPointData(currentDate,wznum.get(),wznumPointNew.getNemCode(),wznumPointNew.getName());
                    prowznum.addAndGet(wznum.intValue());
                    resultList.add(wznumPoint);

                    //离线台数6
                    txzd.addAndGet(lxnum.intValue()+wznum.intValue());
                    ProBasicPowerstationPoint txzdPointNew = linemap.get(ContantXk.TXZDTS);
                    PointData txzdPoint = PointUtil.createPointData(currentDate,txzd.get(),txzdPointNew.getNemCode(),txzdPointNew.getName());
                    resultList.add(txzdPoint);
                });

                //待机台数0
                ProBasicPowerstationPoint djnumPointNew = projectmap.get(ContantXk.DJTSMX);
                PointData djnumPoint = PointUtil.createPointData(currentDate,prodjnum.get(),djnumPointNew.getNemCode(),djnumPointNew.getName());
                wpdjnum.addAndGet(prodjnum.intValue());
                resultList.add(djnumPoint);
                //停机台数1
                ProBasicPowerstationPoint tjnumPointNew = projectmap.get(ContantXk.SDTJTSMX);
                PointData tjnumPoint = PointUtil.createPointData(currentDate,protjnum.get(),tjnumPointNew.getNemCode(),tjnumPointNew.getName());
                wptjnum.addAndGet(protjnum.intValue());
                resultList.add(tjnumPoint);
                //待机台数6-0
                ProBasicPowerstationPoint djtsPointNew = projectmap.get(ContantXk.DJTS);
                prodjts.addAndGet(prodjnum.intValue()+protjnum.intValue());
                PointData djtsPoint = PointUtil.createPointData(currentDate,prodjts.get(),djtsPointNew.getNemCode(),djtsPointNew.getName());
                resultList.add(djtsPoint);

                //运行台数2
                ProBasicPowerstationPoint fdnumPointNew = projectmap.get(ContantXk.XNTSMX);
                PointData fdnumPoint = PointUtil.createPointData(currentDate,profdnum.get(),fdnumPointNew.getNemCode(),fdnumPointNew.getName());
                wpfdnum.addAndGet(profdnum.intValue());
                resultList.add(fdnumPoint);
                //降出力台数3
                ProBasicPowerstationPoint fdjclnumPointNew = projectmap.get(ContantXk.QXJCLTSMX);
                PointData fdjclnumPoint = PointUtil.createPointData(currentDate,profdjclnum.get(),fdjclnumPointNew.getNemCode(),fdjclnumPointNew.getName());
                wpfdjclnum.addAndGet(profdjclnum.intValue());
                resultList.add(fdjclnumPoint);
                //运行台数6-1
                ProBasicPowerstationPoint yxtsPointNew = projectmap.get(ContantXk.YXTS);
                proyxts.addAndGet(profdnum.intValue()+profdjclnum.intValue());
                PointData yxtsPoint = PointUtil.createPointData(currentDate,proyxts.get(),yxtsPointNew.getNemCode(),yxtsPointNew.getName());
                resultList.add(yxtsPoint);

                //限电降出力台数4
                ProBasicPowerstationPoint xdjclnumPointNew = projectmap.get(ContantXk.XDJCLTSMX);
                PointData xdjclnumPoint = PointUtil.createPointData(currentDate,proxdjclnum.get(),xdjclnumPointNew.getNemCode(),xdjclnumPointNew.getName());
                wpxdjclnum.addAndGet(proxdjclnum.intValue());
                resultList.add(xdjclnumPoint);
                //限电停机台数5
                ProBasicPowerstationPoint xdtjnumPointNew = projectmap.get(ContantXk.XDTJTSMX);
                PointData xdtjnumPoint = PointUtil.createPointData(currentDate,proxdtjnum.get(),xdtjnumPointNew.getNemCode(),xdtjnumPointNew.getName());
                wpxdtjnum.addAndGet(proxdtjnum.intValue());
                resultList.add(xdtjnumPoint);
                //限电台数6-5
                ProBasicPowerstationPoint xdtsPointNew = projectmap.get(ContantXk.XDTS);
                proxdts.addAndGet(proxdjclnum.intValue()+proxdtjnum.intValue());
                PointData xdtsPoint = PointUtil.createPointData(currentDate,proxdts.get(),xdtsPointNew.getNemCode(),xdtsPointNew.getName());
                resultList.add(xdtsPoint);

                //故障台数6
                ProBasicPowerstationPoint gznumPointNew = projectmap.get(ContantXk.GZTSMX);
                PointData gznumPoint = PointUtil.createPointData(currentDate,progznum.get(),gznumPointNew.getNemCode(),gznumPointNew.getName());
                wpgznum.addAndGet(progznum.intValue());
                resultList.add(gznumPoint);
                //故障受累台数7
                ProBasicPowerstationPoint cngznumPointNew = projectmap.get(ContantXk.CNSLGZTSMX);
                PointData cngznumPoint = PointUtil.createPointData(currentDate,procngznum.get(),cngznumPointNew.getNemCode(),cngznumPointNew.getName());
                wpcngznum.addAndGet(procngznum.intValue());
                resultList.add(cngznumPoint);

                //检修台数8
                ProBasicPowerstationPoint jxnumPointNew = projectmap.get(ContantXk.JXTSMX);
                PointData jxnumPoint = PointUtil.createPointData(currentDate,projxnum.get(),jxnumPointNew.getNemCode(),jxnumPointNew.getName());
                wpjxnum.addAndGet(projxnum.intValue());
                resultList.add(jxnumPoint);
                //检修受累台数9
                ProBasicPowerstationPoint cnjxnumPointNew = projectmap.get(ContantXk.CNSLJXTSMX);
                PointData cnjxnumPoint = PointUtil.createPointData(currentDate,procnjxnum.get(),cnjxnumPointNew.getNemCode(),cnjxnumPointNew.getName());
                wpcnjxnum.addAndGet(procnjxnum.intValue());
                resultList.add(cnjxnumPoint);

                //检修台数6-4
                ProBasicPowerstationPoint jxtsPointNew = projectmap.get(ContantXk.JXTJTS);
                prowhtj.addAndGet(projxnum.intValue()+procnjxnum.intValue());
                PointData jxtsPoint = PointUtil.createPointData(currentDate,prowhtj.get(),jxtsPointNew.getNemCode(),jxtsPointNew.getName());
                resultList.add(jxtsPoint);
                //电网受累台数10
                ProBasicPowerstationPoint dwslnumPointNew = projectmap.get(ContantXk.CWSLDWTSMX);
                PointData dwslnumPoint = PointUtil.createPointData(currentDate,prodwslnum.get(),dwslnumPointNew.getNemCode(),dwslnumPointNew.getName());
                wpdwslnum.addAndGet(prodwslnum.intValue());
                resultList.add(dwslnumPoint);
                //环境受累台数11
                ProBasicPowerstationPoint hjslnumPointNew = projectmap.get(ContantXk.CWSLTQTSMX);
                PointData hjslnumPoint = PointUtil.createPointData(currentDate,prohjslnum.get(),hjslnumPointNew.getNemCode(),hjslnumPointNew.getName());
                wphjslnum.addAndGet(prohjslnum.intValue());
                resultList.add(hjslnumPoint);
                //故障台数6-2
                ProBasicPowerstationPoint gztsPointNew = projectmap.get(ContantXk.GZTJTS);
                progzts.addAndGet(progznum.intValue()+procngznum.intValue());
                PointData gztsPoint = PointUtil.createPointData(currentDate,progzts.get(),gztsPointNew.getNemCode(),gztsPointNew.getName());
                resultList.add(gztsPoint);
                //受累台数6-6
                ProBasicPowerstationPoint sltsPointNew = projectmap.get(ContantXk.SLTS);
                proslts.addAndGet(prodwslnum.intValue()+prohjslnum.intValue());
                PointData sltsPoint = PointUtil.createPointData(currentDate,proslts.get(),sltsPointNew.getNemCode(),sltsPointNew.getName());
                resultList.add(sltsPoint);

                //离线台数12
                ProBasicPowerstationPoint lxnumPointNew = projectmap.get(ContantXk.LXTSMX);
                PointData lxnumPoint = PointUtil.createPointData(currentDate,prolxnum.get(),lxnumPointNew.getNemCode(),lxnumPointNew.getName());
                wplxnum.addAndGet(prolxnum.intValue());
                resultList.add(lxnumPoint);
                //未知离线12
                ProBasicPowerstationPoint wznumPointNew = projectmap.get(ContantXk.TXZDTSMX);
                PointData wznumPoint = PointUtil.createPointData(currentDate,prowznum.get(),wznumPointNew.getNemCode(),wznumPointNew.getName());
                wpwznum.addAndGet(prowznum.intValue());
                resultList.add(wznumPoint);
                //离线台数6
                ProBasicPowerstationPoint txzdPointNew = projectmap.get(ContantXk.TXZDTS);
                protxzd.addAndGet(prolxnum.intValue()+prowznum.intValue());
                PointData txzdPoint = PointUtil.createPointData(currentDate,protxzd.get(),txzdPointNew.getNemCode(),txzdPointNew.getName());
                resultList.add(txzdPoint);

            });
            //待机台数0
            ProBasicPowerstationPoint djnumPointNew = wpmap.get(ContantXk.DJTSMX);
            PointData djnumPoint = PointUtil.createPointData(currentDate,wpdjnum.get(),djnumPointNew.getNemCode(),djnumPointNew.getName());
            resultList.add(djnumPoint);
            //停机台数1
            ProBasicPowerstationPoint tjnumPointNew = wpmap.get(ContantXk.SDTJTSMX);
            PointData tjnumPoint = PointUtil.createPointData(currentDate,wptjnum.get(),tjnumPointNew.getNemCode(),tjnumPointNew.getName());
            resultList.add(tjnumPoint);

            //待机台数6-0
            ProBasicPowerstationPoint djtsPointNew = wpmap.get(ContantXk.DJTS);
            wpdjts.addAndGet(wpdjnum.intValue()+wptjnum.intValue());
            PointData djtsPoint = PointUtil.createPointData(currentDate,wpdjts.get(),djtsPointNew.getNemCode(),djtsPointNew.getName());
            resultList.add(djtsPoint);
            //运行台数2
            ProBasicPowerstationPoint fdnumPointNew = wpmap.get(ContantXk.XNTSMX);
            PointData fdnumPoint = PointUtil.createPointData(currentDate,wpfdnum.get(),fdnumPointNew.getNemCode(),fdnumPointNew.getName());
            resultList.add(fdnumPoint);
            //降出力台数3
            ProBasicPowerstationPoint fdjclnumPointNew = wpmap.get(ContantXk.QXJCLTSMX);
            PointData fdjclnumPoint = PointUtil.createPointData(currentDate,wpfdjclnum.get(),fdjclnumPointNew.getNemCode(),fdjclnumPointNew.getName());
            resultList.add(fdjclnumPoint);

            //运行台数6-1
            ProBasicPowerstationPoint yxtsPointNew = wpmap.get(ContantXk.YXTS);
            wpyxts.addAndGet(wpfdnum.intValue()+wpfdjclnum.intValue());
            PointData yxtsPoint = PointUtil.createPointData(currentDate,wpyxts.get(),yxtsPointNew.getNemCode(),yxtsPointNew.getName());
            resultList.add(yxtsPoint);
            //限电降出力台数4
            ProBasicPowerstationPoint xdjclnumPointNew = wpmap.get(ContantXk.XDJCLTSMX);
            PointData xdjclnumPoint = PointUtil.createPointData(currentDate,wpxdjclnum.get(),xdjclnumPointNew.getNemCode(),xdjclnumPointNew.getName());
            resultList.add(xdjclnumPoint);
            //限电停机台数5
            ProBasicPowerstationPoint xdtjnumPointNew = wpmap.get(ContantXk.XDTJTSMX);
            PointData xdtjnumPoint = PointUtil.createPointData(currentDate,wpxdtjnum.get(),xdtjnumPointNew.getNemCode(),xdtjnumPointNew.getName());
            resultList.add(xdtjnumPoint);

            //限电台数6-5
            ProBasicPowerstationPoint xdtsPointNew = wpmap.get(ContantXk.XDTS);
            wpxdts.addAndGet(wpxdjclnum.intValue()+wpxdtjnum.intValue());
            PointData xdtsPoint = PointUtil.createPointData(currentDate,wpxdts.get(),xdtsPointNew.getNemCode(),xdtsPointNew.getName());
            resultList.add(xdtsPoint);
            //故障台数6
            ProBasicPowerstationPoint gznumPointNew = wpmap.get(ContantXk.GZTSMX);
            PointData gznumPoint = PointUtil.createPointData(currentDate,wpgznum.get(),gznumPointNew.getNemCode(),gznumPointNew.getName());
            resultList.add(gznumPoint);
            //故障受累台数7
            ProBasicPowerstationPoint cngznumPointNew = wpmap.get(ContantXk.CNSLGZTSMX);
            PointData cngznumPoint = PointUtil.createPointData(currentDate,wpcngznum.get(),cngznumPointNew.getNemCode(),cngznumPointNew.getName());
            resultList.add(cngznumPoint);
            //检修台数8
            ProBasicPowerstationPoint jxnumPointNew = wpmap.get(ContantXk.JXTSMX);
            PointData jxnumPoint = PointUtil.createPointData(currentDate,wpjxnum.get(),jxnumPointNew.getNemCode(),jxnumPointNew.getName());
            resultList.add(jxnumPoint);
            //检修受累台数9
            ProBasicPowerstationPoint cnjxnumPointNew = wpmap.get(ContantXk.CNSLJXTSMX);
            PointData cnjxnumPoint = PointUtil.createPointData(currentDate,wpcnjxnum.get(),cnjxnumPointNew.getNemCode(),cnjxnumPointNew.getName());
            resultList.add(cnjxnumPoint);
            //检修台数6-4
            ProBasicPowerstationPoint jxtsPointNew = wpmap.get(ContantXk.JXTJTS);
            wpwhtj.addAndGet(wpjxnum.intValue()+wpcnjxnum.intValue());
            PointData jxtsPoint = PointUtil.createPointData(currentDate,wpwhtj.get(),jxtsPointNew.getNemCode(),jxtsPointNew.getName());
            resultList.add(jxtsPoint);
            //电网受累台数10
            ProBasicPowerstationPoint dwslnumPointNew = wpmap.get(ContantXk.CWSLDWTSMX);
            PointData dwslnumPoint = PointUtil.createPointData(currentDate,wpdwslnum.get(),dwslnumPointNew.getNemCode(),dwslnumPointNew.getName());
            resultList.add(dwslnumPoint);
            //环境受累台数11
            ProBasicPowerstationPoint hjslnumPointNew = wpmap.get(ContantXk.CWSLTQTSMX);
            PointData hjslnumPoint = PointUtil.createPointData(currentDate,wphjslnum.get(),hjslnumPointNew.getNemCode(),hjslnumPointNew.getName());
            resultList.add(hjslnumPoint);
            //故障台数6-2
            ProBasicPowerstationPoint gztsPointNew = wpmap.get(ContantXk.GZTJTS);
            wpgzts.addAndGet(wpgznum.intValue()+wpcngznum.intValue());
            PointData gztsPoint = PointUtil.createPointData(currentDate,wpgzts.get(),gztsPointNew.getNemCode(),gztsPointNew.getName());
            resultList.add(gztsPoint);
            //受累台数6-6
            ProBasicPowerstationPoint sltsPointNew = wpmap.get(ContantXk.SLTS);
            wpslts.addAndGet(wpdwslnum.intValue()+wphjslnum.intValue());
            PointData sltsPoint = PointUtil.createPointData(currentDate,wpslts.get(),sltsPointNew.getNemCode(),sltsPointNew.getName());
            resultList.add(sltsPoint);

            //离线台数12
            ProBasicPowerstationPoint lxnumPointNew = wpmap.get(ContantXk.LXTSMX);
            PointData lxnumPoint = PointUtil.createPointData(currentDate,wplxnum.get(),lxnumPointNew.getNemCode(),lxnumPointNew.getName());
            resultList.add(lxnumPoint);
            //未知离线13
            ProBasicPowerstationPoint wznumPointNew = wpmap.get(ContantXk.TXZDTSMX);
            PointData wznumPoint = PointUtil.createPointData(currentDate,wpwznum.get(),wznumPointNew.getNemCode(),wznumPointNew.getName());
            resultList.add(wznumPoint);
            //离线台数12
            ProBasicPowerstationPoint txzdPointNew = wpmap.get(ContantXk.TXZDTS);
            wptxzd.addAndGet(wplxnum.intValue()+wpwznum.intValue());
            PointData txzdPoint = PointUtil.createPointData(currentDate,wptxzd.get(),txzdPointNew.getNemCode(),txzdPointNew.getName());
            resultList.add(txzdPoint);

        });
        edosUtil.sendMultiPoint(resultList);
    }

    private double getMxzt(Map<String, ProEconEquipmentmodel> modelMap,Map<String, Map<Integer, Integer>> aistateMap,Map<String, List<ProBasicStatusPoint>> statusMap,ProBasicEquipment wt) throws Exception {

        double mxstatus = 2;

        String aiordi = modelMap.get(wt.getModelId()).getDescription();
        if (aiordi.equals("AI")){
            Map<Integer, Integer> stateMap = aistateMap.get(wt.getModelId());
            Optional<ProBasicStatusPoint> first = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformCode().equals(Contant.AI422)).findFirst();
            if (first.isPresent()){
                ProBasicStatusPoint windturbinestatusdi = first.get();
                int pointValueInDouble = (int) edosUtil.getRealData(windturbinestatusdi.getNemCode()).getPointValueInDouble();
                mxstatus = (double)stateMap.get(pointValueInDouble);
            }
        }else {
            //每个状态一个状态点
            Map<String,String> stateMap = new HashMap<>();
            List<ProBasicStatusPoint> windturbinestatusdis = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformCode().equals(Contant.MX000) || w.getUniformCode().equals(Contant.MX002) || w.getUniformCode().equals(Contant.MX003) || w.getUniformCode().equals(Contant.MX006) || w.getUniformCode().equals(Contant.MX008)).collect(Collectors.toList());
            for(ProBasicStatusPoint w : windturbinestatusdis){
                PointData realData = edosUtil.getRealData(w.getNemCode());
                if (realData.getPointValueInDouble()==1){
                    stateMap.put(w.getUniformCode(),w.getTypeId());
                    mxstatus = Double.parseDouble(w.getTypeId());
                }
            }
            if (stateMap.containsKey("MX006") && stateMap.containsKey("MX008")){
                mxstatus = Double.parseDouble(stateMap.get("MX008"));
            }
            if (stateMap.containsKey("MX002") && stateMap.containsKey("MX003")){
                mxstatus = Double.parseDouble(stateMap.get("MX003"));
            }
        }


//        //远景
//        if (windturbineManufacturerId.equals("YJNY_MF")){
//            if (wt.getWindpowerstationId().equals("SDL_LYDL_BEIH_FDC_STA") || wt.getWindpowerstationId().equals("SDL_LYDL_YS_FDC_STA")){
//                Optional<ProBasicStatusPoint> first = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformCode().equals(Contant.AI422)).findFirst();
//                if (first.isPresent()){
//                    ProBasicStatusPoint windturbinestatusdi = first.get();
//
//                    int pointValueInDouble = (int) edosUtil.getRealData(windturbinestatusdi.getNemCode()).getPointValueInDouble();
//                    switch (pointValueInDouble){
//                        case 1:
//                            mxstatus = 12.0;
//                            break;
//                        case 2:
//                        case 8:
//                            mxstatus = 6.0;
//                            break;
//                        case 3:
//                        case 4:
//                        case 5:
//                        case 28:
//                            mxstatus = 1.0;
//                            break;
//                        case 6:
//                        case 7:
//                            mxstatus = 4.0;
//                            break;
//                        case 9:
//                            mxstatus = 10.0;
//                            break;
//                        case 10:
//                            mxstatus = 9.0;
//                            break;
//                        case 11:
//                        case 12:
//                        case 13:
//                        case 14:
//                        case 15:
//                        case 29:
//                        case 30:
//                        case 31:
//                        case 32:
//                        case 33:
//                            mxstatus = 11.0;
//                            break;
//                        case 16:
//                        case 18:
//                        case 19:
//                        case 20:
//                        case 21:
//                            mxstatus = 2.0;
//                            break;
//                        case 17:
//                            mxstatus = 0.0;
//                            break;
//                        case 22:
//                            mxstatus = 3.0;
//                            break;
//                        case 23:
//                        case 24:
//                        case 25:
//                        case 26:
//                            mxstatus = 8.0;
//                            break;
//                        case 27:
//                            mxstatus = 13.0;
//                            break;
//                        default:
//                            mxstatus = 2.0;
//                    }
//                }
//            } else {
//                //多状态根据一个点来判断
//                Optional<ProBasicStatusPoint> first = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformCode().equals(Contant.AI422)).findFirst();
//                if (first.isPresent()){
//                    ProBasicStatusPoint windturbinestatusdi = first.get();
//
//                    int pointValueInDouble = (int) edosUtil.getRealData(windturbinestatusdi.getNemCode()).getPointValueInDouble();
//                    switch (pointValueInDouble){
//                        case 1:
//                        case 3:
//                        case 4:
//                            mxstatus = 1.0;
//                            break;
//                        case 2:
//                        case 10:
//                            mxstatus = 4.0;
//                            break;
//                        case 5:
//                        case 6:
//                            mxstatus = 2.0;
//                            break;
//                        case 7:
//                            mxstatus = 8.0;
//                            break;
//                        case 8:
//                            mxstatus = 13.0;
//                            break;
//                        case 9:
//                            mxstatus = 0.0;
//                            break;
//                        case 11:
//                        case 12:
//                            mxstatus = 6.0;
//                            break;
//                        default:
//                            mxstatus = 2.0;
//                    }
//                }
//            }
//
//        }else if (windturbineManufacturerId.equals("JFKJ_MF") && wt.getCompanyId().equals("SDL_LYDL_ZGS")){
//            //多状态根据一个点来判断
//            Optional<ProBasicStatusPoint> first = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformCode().equals(Contant.AI422)).findFirst();
//            if (first.isPresent()){
//                ProBasicStatusPoint windturbinestatusdi = first.get();
//
//                int pointValueInDouble = (int) edosUtil.getRealData(windturbinestatusdi.getNemCode()).getPointValueInDouble();
//                switch (pointValueInDouble){
//                    case 0:
//                    case 3:
//                        mxstatus = 0.0;
//                        break;
//                    case 1:
//                        mxstatus = 1.0;
//                        break;
//                    case 2:
//                        mxstatus = 4.0;
//                        break;
//                    case 4:
//                    case 5:
//                        mxstatus = 2.0;
//                        break;
//                    case 6:
//                    case 8:
//                    case 9:
//                        mxstatus = 6.0;
//                        break;
//                    default:
//                        mxstatus = 2.0;
//                }
//            }
//        }else if (windturbineManufacturerId.equals("LHDL_MF") && wt.getCompanyId().equals("SDL_SXNY_ZGS")){
//            //多状态根据一个点来判断
//            Optional<ProBasicStatusPoint> first = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformCode().equals(Contant.AI422)).findFirst();
//            if (first.isPresent()){
//                ProBasicStatusPoint windturbinestatusdi = first.get();
//
//                int pointValueInDouble = (int) edosUtil.getRealData(windturbinestatusdi.getNemCode()).getPointValueInDouble();
//                switch (pointValueInDouble){
//                    //待机
//                    case 1:
//                    case 2:
//                    case 16:
//                    case 128:
//                    case 256:
//                    case 1024:
//                        mxstatus = 0.0;
//                        break;
//                    case 4:
//                        //故障
//                        mxstatus = 4.0;
//                        break;
//                    case 8:
//                        //维护
//                        mxstatus = 6.0;
//                        break;
//                    case 32://限电
//                        mxstatus = 8.0;
//                        break;
//                    case 64:
//                    case 512://运行
//                        mxstatus = 2.0;
//                        break;
//                    default:
//                        mxstatus = 2.0;
//                }
//            }
//        }else if (windturbineManufacturerId.equals("SHDQ_MF")){   //山东
//            //多状态根据一个点来判断
//            Optional<ProBasicStatusPoint> first = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformCode().equals(Contant.AI422)).findFirst();
//            if (first.isPresent()){
//                ProBasicStatusPoint windturbinestatusdi = first.get();
//
//                int pointValueInDouble = (int) edosUtil.getRealData(windturbinestatusdi.getNemCode()).getPointValueInDouble();
//                switch (pointValueInDouble){
//                    //待机
//                    case 0:
//                    case 3:
//                    case 4:
//                    case 5:
//                    case 6:
//                    case 9:
//                        mxstatus = 0.0;
//                        break;
//                    case 1:
//                        //故障
//                        mxstatus = 4.0;
//                        break;
//                    case 2:
//                        //维护
//                        mxstatus = 6.0;
//                        break;
//                    case 12://限电
//                        mxstatus = 8.0;
//                        break;
//                    case 7:
//                    case 8://运行
//                    case 11:
//                        mxstatus = 2.0;
//                        break;
//                    default:
//                        mxstatus = 2.0;
//                }
//            }
//        }else if (windturbineManufacturerId.equals("SYHC_MF")){   //山东
//            //多状态根据一个点来判断
//            Optional<ProBasicStatusPoint> first = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformCode().equals(Contant.AI422)).findFirst();
//            if (first.isPresent()){
//                ProBasicStatusPoint windturbinestatusdi = first.get();
//
//                int pointValueInDouble = (int) edosUtil.getRealData(windturbinestatusdi.getNemCode()).getPointValueInDouble();
//                switch (pointValueInDouble){
//                    //待机
//                    case 1:
//                    case 3:
//                    case 4:
//                    case 5:
//                    case 6:
//                    case 9:
//                    case 10:
//                    case 11:
//                    case 12:
//                    case 21:
//                    case 22:
//                    case 23:
//                    case 24:
//                    case 25:
//                    case 26:
//                    case 27:
//                    case 50:
//                    case 99:
//                    case 200:
//                        mxstatus = 0.0;
//                        break;
//                    case 30:
//                        //手动停机
//                        mxstatus = 1.0;
//                    case 199:
//                        //故障
//                        mxstatus = 4.0;
//                        break;
//                    case 2:
//                        //维护
//                        mxstatus = 6.0;
//                        break;
//                    case 0://
//                        mxstatus = 12.0;
//                        break;
//                    case 7:
//                    case 8://运行
//                        mxstatus = 2.0;
//                        break;
//                    default:
//                        mxstatus = 2.0;
//                }
//            }
//        }else if (windturbineManufacturerId.equals("LHDL_MF")){//联合动力
//
//            Optional<ProBasicStatusPoint> first = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformCode().equals(Contant.AI422)).findFirst();
//            if(first.isPresent()){
//                ProBasicStatusPoint windturbinestatusdi = first.get();
//
//                int pointValueInDouble = (int) edosUtil.getRealData(windturbinestatusdi.getNemCode()).getPointValueInDouble();
//                switch (pointValueInDouble){
//                    case 0:
//                        mxstatus = 12.0;
//                        break;
//                    case 1:
//                    case 6:
//                        mxstatus = 4.0;
//                        break;
//                    case 2:
//                        mxstatus = 6.0;
//                        break;
//                    case 3:
//                        mxstatus = 0.0;
//                        break;
//                    case 4:
//                    case 5:
//                        mxstatus = 2.0;
//                        break;
//                    case 11:
//                        mxstatus = 1.0;
//                        break;
//                    default:
//                        mxstatus = 2.0;
//                }
//            }
//            //每个状态一个状态点
//            List<ProBasicStatusPoint> windturbinestatusdis = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformCode().equals(Contant.MX000) || w.getUniformCode().equals(Contant.MX002) || w.getUniformCode().equals(Contant.MX004) || w.getUniformCode().equals(Contant.MX006) || w.getUniformCode().equals(Contant.MX008)).collect(Collectors.toList());
//            for(ProBasicStatusPoint w : windturbinestatusdis){
//                PointData realData = edosUtil.getRealData(w.getNemCode());
//                if (realData.getPointValueInDouble()==1){
//                    mxstatus = Double.parseDouble(w.getTypeId());
//                    break;
//                }
//            }
//        }else {
//            //每个状态一个状态点
//            List<ProBasicStatusPoint> windturbinestatusdis = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformCode().equals(Contant.MX000) || w.getUniformCode().equals(Contant.MX002) || w.getUniformCode().equals(Contant.MX004) || w.getUniformCode().equals(Contant.MX006) || w.getUniformCode().equals(Contant.MX008)).collect(Collectors.toList());
//            for(ProBasicStatusPoint w : windturbinestatusdis){
//                PointData realData = edosUtil.getRealData(w.getNemCode());
//                if (realData.getPointValueInDouble()==1){
//                    mxstatus = Double.parseDouble(w.getTypeId());
//                    break;
//                }
//            }
//        }
        return mxstatus;
    }

    private Double getGpzt(double gpzt,double ssgl) {
        ///  0, "正常状态";1, "限电";2, "场内受累检修";3, "场内受累故障";4, "场外受累电网";5, "场外受累天气";6, "发电限负荷";
        double mxzt = 0;
        if (gpzt == 1){
            if (ssgl>0){
                mxzt = 8;
            }else {
                mxzt = 9;
            }
        }else if (gpzt == 2){
            mxzt = 7;
        }else if (gpzt == 3){
            mxzt = 5;
        }else if (gpzt == 4){
            mxzt = 10;
        }else if (gpzt == 5){
            mxzt = 11;
        }else if (gpzt == 6){
            mxzt = 3;
        }else {
            mxzt = 2;
        }
        return mxzt;
    }



}
