package com.huatek.busi.service.impl.gis;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.dubbo.config.annotation.Service;
import com.alibaba.fastjson.JSONArray;
import com.google.common.collect.Maps;
import com.huatek.busi.common.GisAssessEnum;
import com.huatek.busi.common.ParamEnum;
import com.huatek.busi.common.SiteConstants;
import com.huatek.busi.common.TransformerAssessEnum;
import com.huatek.busi.common.util.ComputeUtil;
import com.huatek.busi.dto.BusiOfflineGisRepairDto;
import com.huatek.busi.dto.BusiOutlineGisExperimentDataDto;
import com.huatek.busi.entity.*;
import com.huatek.busi.service.BusiOutlineGisExperimentDataService;
import com.huatek.busi.service.ICalculateStepService;
import com.huatek.busi.service.ILabReportMarkStatisticService;
import com.huatek.busi.service.IecBreakerParamService;
import com.huatek.busi.service.gis.*;
import com.huatek.busi.service.param.BusiParamGisService;
import com.huatek.busi.service.substation.SubstationMicGisService;
import com.huatek.busi.service.transformer.TransformerPdStatisticsService;
import com.huatek.busi.util.*;
import com.huatek.busi.vo.*;
import com.huatek.frame.base.util.Constants;
import com.huatek.torch.util.uuid.Uuid;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.script.ScriptEngine;
import javax.script.ScriptException;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;

@Slf4j
@Component
@Service(interfaceClass = GisAssessService.class)
@Transactional(rollbackFor = Exception.class)
public class GisAssessServiceNewImpl implements GisAssessService {

    @Reference(check = false)
    ICalculateStepService calculateStepService;

    @Autowired
    private BusiParamGisService busiParamGisService;

    @Autowired
    private GisMechanicalPropertiesService gisMechanicalPropertiesService;

    @Autowired
    private BusiOutlineGisExperimentDataService busiOutlineGisExperimentdataService;

    @Autowired
    private BusiOfflineGisBrandService busiOfflineGisBrandService;

    @Autowired
    private BusiOfflineGisRepairService busiOfflineGisRepairService;

    @Autowired
    private IecBreakerParamService iecBreakerParamService;

    @Autowired
    private SubstationMicGisService substationMicGisService;

    @Autowired
    private RptGisMonitorSf6ChartsService rptGisMonitorSf6ChartsService;

    @Autowired
    private TransformerPdStatisticsService transformerPdStatisticsService;

    @Autowired
    private GisAssessmentResultService gisAssessmentResultService;

    @Autowired
    private GisAssessmentResultDataService gisAssessmentResultDataService;

    @Reference(check = false)
    ILabReportMarkStatisticService labReportMarkStatisticService;

    @Value("${dataoutput.base.path}")
    private String basePath2;

    public static GisFormulaCal gisFormulaCalInstance = GisFormulaCal.getInstance();

    @Override
    public GisAssessmentResult assessmentForGis(String siteId, String mainTreeId) {

        // Gis评估结果
        GisAssessmentResult gisAssessmentResult = new GisAssessmentResult();
        FileReader fileReader = null;
        try {
            // 加载js引擎
            String basePath = this.getClass().getResource(GisCreateUtil.PATH).getPath();
            fileReader = ComputeUtil.readerJsFile(basePath);
            ScriptEngine engine = ComputeUtil.loadJsScriptEngine(fileReader);

            // 通过systemCode查找 GIS标牌信息
            BusiOfflineGisBrandVo busiOfflineGisBrandVo = busiOfflineGisBrandService.findBusiOfflineGISBrand(siteId, mainTreeId);
            if(busiOfflineGisBrandVo != null){
                String gisId = busiOfflineGisBrandVo.getId();
                String gisName = busiOfflineGisBrandVo.getGisName();
                String mainEquipmentId = busiOfflineGisBrandVo.getMainEquipmentId();
                // 组织文件名
                DateTimeFormatter dateTimeFormater2 = DateTimeFormatter.ofPattern("yyyy-MM-dd");
                LocalDate localDate = LocalDate.now();
                String date = dateTimeFormater2.format(localDate);
                String fileName = gisName + "_" + date + ".xml";
                log.info("--->> GIS名称：{}, id：{}", gisName, gisId);

                // 获取最新的gis评测数据
                List<IecBreakerParam> iecBreakerParams;
                List<GisAssessmentResultData> gisAssessmentResultDataList = gisAssessmentResultDataService.findGisAssessmentResultDataByGisId(gisId);
                if(CollectionUtil.isEmpty(gisAssessmentResultDataList)){
                    // GIS断开数据
                    iecBreakerParams = iecBreakerParamService.findIecBreakerParam(siteId, mainTreeId);
                }else {
                    //获取前一天的断开数据
                    iecBreakerParams = iecBreakerParamService.findIecBreakerParamNow(siteId, mainTreeId,localDate.plusDays(-1));
                }

                TransformerPdStatistics transformerPdStatistics = new TransformerPdStatistics();
                transformerPdStatistics.setPdType(GisCreateUtil.PD_TYPE);
                transformerPdStatistics.setSiteId(siteId);
                transformerPdStatistics.setMainTreeId(mainTreeId);

                // 获取Gis的权重系数维护表
                Map<String, BusiParamGisVo> busiParamGisMap = new HashMap<>();
                List<BusiParamGisVo> busiParamGisVo = busiParamGisService.findBusiParamGisWeights(siteId, mainTreeId);
                if (!busiParamGisVo.isEmpty()) {
                    busiParamGisMap = GisAssessUtilsNew.busiParamGisList2Map(busiParamGisVo);
                }

                // 权重
                BigDecimal score_a = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.OPERATE_DATA.getKey());
                BigDecimal score_b = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.INSULATION_MEDIUM.getKey());
                BigDecimal score_c = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.DISCONNECTION_WEAR.getKey());
                BigDecimal score_d = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.OPERATE_PARAMETER.getKey());

                int step = 0;

                net.sf.json.JSONArray jsonArray = new net.sf.json.JSONArray();
                CalculateStep calculateStep = new CalculateStep();
                calculateStep.setId(Uuid.getUUID());
                calculateStep.setSiteId(siteId);
                calculateStep.setEquipmentType(SiteConstants.GIS);
                calculateStep.setMainEquipmentId(mainEquipmentId);
                calculateStep.setExecuteMode(Integer.valueOf(Constants.DEFAULT_YES));
                calculateStep.setCreateTime(LocalDateTime.now());

                BigDecimal eddl = new BigDecimal("0");
                IecBreakerParam iecBreakerParam = new IecBreakerParam();
                if (busiOfflineGisBrandVo != null) {
                    // 额定电流
                    String ratedFrequency = busiOfflineGisBrandVo.getRatedFrequency();
                    eddl = gisFormulaCalInstance.getEddl(ratedFrequency);
                    log.info("额定电流(A)-标牌: {}", eddl);
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "额定电流计算", ratedFrequency, String.valueOf(eddl));
                }

                BigDecimal dkdl = new BigDecimal("0");
                List<IecBreakerParam> iecBreakerList = iecBreakerParamService.findIecBreakerParam(siteId, mainTreeId);
                if (CollectionUtil.isNotEmpty(iecBreakerList)) {
                    IecBreakerParam iecBreaker = iecBreakerList.get(0);
                    // 断开电流
                    String abortCurrent = iecBreaker.getAbortCurrent();
                    if (null != iecBreaker && StrUtil.isNotBlank(abortCurrent)) {
                        dkdl = new BigDecimal(abortCurrent);
                        log.info("断开电流（短路器参数表中电流）:" + dkdl);
                    }
                }

                log.info("---------------------------权重数据-------------------------------------------------------------------");
                log.info("运行数据权重：{}", score_a);
                log.info("绝缘介质权重：{}", score_b);
                log.info("断开磨损权重：{}", score_c);
                log.info("运行参数权重：{}", score_d);

                BigDecimal ws_miehushi = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.MICRO_WATER_CONTENT_ARC_EXTINGUISH_CHAMBER.getKey());
                log.info("灭弧室权重：{}", ws_miehushi);

                GisMechanicalPropertiesVo gisMechanical = gisMechanicalPropertiesService.lastGisMechanicalProperties(siteId, mainTreeId);
                SubstationMicGisVo substationMicGis = substationMicGisService.findSubstationMicGis(siteId, mainTreeId);

                BigDecimal yxsj_a = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.CONDUCTIVE_LOOP_RESISTANCE.getKey());

                BusiOutlineGisExperimentDataDto busiOutlineGisExperimentDataDto = new BusiOutlineGisExperimentDataDto();
                busiOutlineGisExperimentDataDto.setSiteId(siteId);
                busiOutlineGisExperimentDataDto.setEquipmentId(mainTreeId);

                BigDecimal gis_yxsj_ddhldz_val = new BigDecimal("0");
                BigDecimal gis_yxsj_ddhldz = new BigDecimal("1");
                com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
                BusiOutlineGisExperimentData busiOutlineGisExperimentdata = busiOutlineGisExperimentdataService.findBusiOutlineDataByEquip(mainTreeId, siteId);
                if (busiOutlineGisExperimentdata != null) {
                    gis_yxsj_ddhldz_val = GisAssessUtilsNew.getDdhldz(busiOutlineGisExperimentdata);
                    log.info("导电回路电阻(微欧)：{}", gis_yxsj_ddhldz_val);
                    jsonObject.put("aDdhlResistance", GisAssessUtils.str2BigDecimal(busiOutlineGisExperimentdata.getADdhlResistance()));
                    jsonObject.put("bDdhlResistance", GisAssessUtils.str2BigDecimal(busiOutlineGisExperimentdata.getBDdhlResistance()));
                    jsonObject.put("cDdhlResistance", GisAssessUtils.str2BigDecimal(busiOutlineGisExperimentdata.getCDdhlResistance()));
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "导电回路电阻(微欧)-ABC三相最大值计算", jsonObject.toJSONString(), String.valueOf(gis_yxsj_ddhldz_val));

                    BigDecimal aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.CONDUCTIVE_LOOP_RESISTANCE.getKey());
                    BigDecimal bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.CONDUCTIVE_LOOP_RESISTANCE.getKey());
                    gis_yxsj_ddhldz = gisFormulaCalInstance.formulaForUpAndDown(gis_yxsj_ddhldz_val, "down", aVal, bVal);
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "导电回路电阻(微欧) - 升降计算", GisAssessUtilsNew.formulaForUpAndDown(jsonObject, gis_yxsj_ddhldz_val, "down", aVal, bVal), String.valueOf(gis_yxsj_ddhldz));
                }

                BigDecimal h1;
                BigDecimal h2;
                BigDecimal h3;
                BigDecimal h4;
                BigDecimal h5;
                BigDecimal h6;
                BigDecimal h7;
                //运行数据-电气试验
                BigDecimal ddhldz_result = gisFormulaCalInstance.calcValue(gis_yxsj_ddhldz, yxsj_a, score_a);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "导电回路电阻计算", GisAssessUtilsNew.calcValue(jsonObject, gis_yxsj_ddhldz, yxsj_a, score_a), String.valueOf(ddhldz_result));

                BigDecimal yxsj_b = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.TIME_PARAMETER.getKey());
                BigDecimal yxsj_c = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.SPEED_PARAMETER_OTHER_ASPECTS.getKey());
                log.info("时间参数权重: {}, 其他方面权重: {}", yxsj_b, yxsj_c);

                String gis_yxsj_sjcs = "1";
                BigDecimal hzbtq_result;
                BigDecimal fzbtq_result;
                BigDecimal hz_btq_val = new BigDecimal(0);
                BigDecimal hz_btq = new BigDecimal(0);
                BigDecimal fz_btq_val = new BigDecimal(0);
                BigDecimal fz_btq = new BigDecimal(0);
                BigDecimal sjcs_a = new BigDecimal(0);
                BigDecimal sjcs_b = new BigDecimal(0);
                BigDecimal FinalResult = new BigDecimal(0);
                BigDecimal yxsj_sudutezheng = new BigDecimal(0);
                if (gisMechanical != null) {
                    // 合闸不同期
                    hz_btq_val = GisAssessUtilsNew.getHzbtq(gisMechanical);
                    BigDecimal aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.DIFFERENT_CLOSE_PERIODS.getKey());
                    BigDecimal bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.DIFFERENT_CLOSE_PERIODS.getKey());
                    hz_btq = gisFormulaCalInstance.formulaForUpAndDown(hz_btq_val, "down", aVal, bVal);
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "合闸不同期升降计算", GisAssessUtilsNew.formulaForUpAndDown(jsonObject, hz_btq_val, "down", aVal, bVal), String.valueOf(hz_btq));

                    sjcs_a = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.DIFFERENT_CLOSE_PERIODS.getKey());
                    log.info("合闸不同期权重值：{}", sjcs_a);
                    hzbtq_result = gisFormulaCalInstance.calcValue(hz_btq,sjcs_a,yxsj_b);
                    jsonObject.clear();
                    jsonObject.put("hz_btq", hz_btq);
                    jsonObject.put("sjcs_a", sjcs_a);
                    jsonObject.put("yxsj_b", yxsj_b);
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "合闸不同期权重值计算", jsonObject.toJSONString(), String.valueOf(hzbtq_result));

                    //分闸不同期
                    fz_btq_val = GisAssessUtilsNew.getFzbtq(gisMechanical);
                    aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.DIFFERENT_OPEN_PERIODS.getKey());
                    bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.DIFFERENT_OPEN_PERIODS.getKey());
                    fz_btq = gisFormulaCalInstance.formulaForUpAndDown(fz_btq_val, "down", aVal, bVal);
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "分闸不同期权重值计算", GisAssessUtilsNew.formulaForUpAndDown(jsonObject, fz_btq_val, "down", aVal, bVal), String.valueOf(fz_btq));

                    sjcs_b = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.DIFFERENT_OPEN_PERIODS.getKey());
                    log.info("分闸不同期权重值：{}", sjcs_b);
                    fzbtq_result = gisFormulaCalInstance.calcValue(fz_btq,sjcs_b,yxsj_b);
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "导电回路电阻计算", GisAssessUtilsNew.calcValue(jsonObject, fz_btq, sjcs_b, yxsj_b), String.valueOf(hzbtq_result));

                    // 速度特性权重
                    yxsj_sudutezheng = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.VELOCITY_CHARACTERISTICS.getKey());

                    // 运行数据-机械实验数据-时间参数
                    FinalResult = hzbtq_result.add(fzbtq_result);
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "运行数据-机械实验数据-时间参数计算", "", String.valueOf(FinalResult));

                    gis_yxsj_sjcs = ComputeUtil.eval(engine, ParamEnum.GIS_YXSJ_SJCS.getKey(), hz_btq, fz_btq, sjcs_a, sjcs_b);
                    log.info("运行时间-时间参数：" + gis_yxsj_sjcs);
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "运行时间-时间参数计算", "", String.valueOf(gis_yxsj_sjcs));
                }

                //刚分速度
                BigDecimal gfSpeend_val = GisAssessUtilsNew.getGfSpeend(gisMechanical);
                log.info("刚分速度：{}", gfSpeend_val);
                step += 1;
                if (gfSpeend_val == null){
                    GisAssessUtilsNew.setStep(jsonArray, step, "刚分速度计算", "", String.valueOf(gfSpeend_val));
                }else {
                    GisAssessUtilsNew.setStep(jsonArray, step, "刚分速度计算", GisAssessUtilsNew.compareABCMax(gisMechanical, jsonObject, "0"), String.valueOf(gfSpeend_val));
                }

                BigDecimal aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.RIGID_PARTIAL_VELOCITY.getKey());
                BigDecimal bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.RIGID_PARTIAL_VELOCITY.getKey());
                BigDecimal gfSpeend = gisFormulaCalInstance.formulaForUpAndDown(gfSpeend_val, "down", aVal, bVal);
                log.info("刚分速度升降计算结果：{}", gfSpeend);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "刚分速度升降计算", GisAssessUtilsNew.formulaForUpAndDown(jsonObject, gfSpeend_val, "down", aVal, bVal), String.valueOf(gfSpeend));

                BigDecimal yxsd_a = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.RIGID_PARTIAL_VELOCITY.getKey());
                log.info("刚分速度权重值：{}", yxsd_a);

                BigDecimal gfSpeend_result = gisFormulaCalInstance.calcValue(gfSpeend, yxsd_a, yxsj_sudutezheng);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "导电回路电阻计算", GisAssessUtilsNew.calcValue(jsonObject, gfSpeend, yxsd_a, yxsj_sudutezheng), String.valueOf(gfSpeend_result));

                //刚合速度
                BigDecimal ghSpeend_val = GisAssessUtilsNew.getGhSpeend(gisMechanical);
                log.info("刚合速度：{}", ghSpeend_val);
                step += 1;
                if(ghSpeend_val == null){
                    GisAssessUtilsNew.setStep(jsonArray, step, "刚合速度(ABC三相最大值)计算", "", String.valueOf(gfSpeend_val));
                }else {
                    GisAssessUtilsNew.setStep(jsonArray, step, "刚合速度(ABC三相最大值)计算", GisAssessUtilsNew.compareABCMax(gisMechanical, jsonObject, "1"), String.valueOf(gfSpeend_val));
                }

                aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.STIFFNESS_AND_SPEED.getKey());
                bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.STIFFNESS_AND_SPEED.getKey());
                BigDecimal ghSpeend = gisFormulaCalInstance.formulaForUpAndDown(ghSpeend_val, "down", aVal, bVal);
                log.info("刚合速度：{}", ghSpeend);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "刚和速度升降计算", GisAssessUtilsNew.formulaForUpAndDown(jsonObject, ghSpeend_val, "down", aVal, bVal), String.valueOf(ghSpeend));

                BigDecimal yxsd_b = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.STIFFNESS_AND_SPEED.getKey());
                log.info("刚合速度权重值：{}", yxsd_b);
                BigDecimal ghSpeend_result = gisFormulaCalInstance.calcValue(ghSpeend,yxsd_b,yxsj_sudutezheng);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "导电回路电阻计算", GisAssessUtilsNew.calcValue(jsonObject, ghSpeend, yxsd_b, yxsj_sudutezheng), String.valueOf(ghSpeend_result));

                // 运行数据-机械实验数据-速度参数
                BigDecimal FinalResult2 = ghSpeend_result.add(gfSpeend_result);
                jsonObject.clear();
                jsonObject.put("ghSpeend_result1", ghSpeend_result);
                jsonObject.put("gfSpeend_result2", gfSpeend_result);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "运行数据-机械实验数据-速度参数", jsonObject.toJSONString(), String.valueOf(FinalResult2));

                // 运行数据-机械实验数据
                h1 = (FinalResult.add(FinalResult2)).multiply(score_a);
                jsonObject.clear();
                jsonObject.put("FinalResult", FinalResult);
                jsonObject.put("FinalResult2", FinalResult2);
                jsonObject.put("score_a", score_a);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "运行数据-机械实验数据", jsonObject.toJSONString(), String.valueOf(FinalResult2));

                BigDecimal yl_val;
                BigDecimal yl;
                BigDecimal wshl_val;
                BigDecimal wshl;
                BigDecimal qtxl_a = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.GAS_LEAKAGE.getKey());
                BigDecimal qtxl_b = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.Micro_water_content.getKey());
                // TODO 3 绝缘介质总和
                String gis_qtxl = "1";
                log.info("绝缘介质 -->> 3.1 气体压力权重：{}", qtxl_a);
                log.info("绝缘介质 -->> 3.2 气体压力微水含量权重：{}", qtxl_b);
                BigDecimal kdms_jfl = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.LOCAL_DISCHARGE.getKey());
                log.info("绝缘介质 -->>3.3 气体压力局放量权重：{}", kdms_jfl);
                BigDecimal kdmo_jfcs = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.PARTIAL_DISCHARGE_TIMES.getKey());
                log.info("绝缘介质 -->>3.4 局放次数权重：{}", kdmo_jfcs);

                List<RptGisMonitorSf6Charts> rptGisMonitorSf6Chartses = rptGisMonitorSf6ChartsService
                        .findRptGisMonitorSf6Chartses(siteId, mainTreeId);

                // 绝缘介质-气体泄漏
                yl_val = GisAssessUtilsNew.getQtxl(rptGisMonitorSf6Chartses);
                jsonObject.clear();
                JSONObject jsonObject1 = GisAssessUtilsNew.getVal(rptGisMonitorSf6Chartses);
                jsonObject.put("aVal", jsonObject1.get("aVal").toString());
                jsonObject.put("bVal", jsonObject1.get("bVal").toString());
                jsonObject.put("cVal", jsonObject1.get("cVal").toString());
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "绝缘介质-气体泄漏", jsonObject.toJSONString(), String.valueOf(yl_val));

                aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.GAS_LEAKAGE.getKey());
                bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.GAS_LEAKAGE.getKey());
                yl = gisFormulaCalInstance.formulaForUpAndDown(yl_val, "up", aVal, bVal);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, ParamEnum.GAS_LEAKAGE.getValue(), GisAssessUtilsNew.formulaForUpAndDown(jsonObject, yl_val, "up", aVal, bVal), String.valueOf(yl));

                BigDecimal j1 = gisFormulaCalInstance.calcValue(yl, qtxl_a, score_b);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "导电回路电阻计算", GisAssessUtilsNew.calcValue(jsonObject, yl, qtxl_a, score_b), String.valueOf(j1));

                // 绝缘介质-微水含量
                BigDecimal jyjz_mhs = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.GAS_LEAKAGE_ARC_EXTINGUISH_CHAMBER.getKey());
                wshl_val = GisAssessUtilsNew.getWshl(rptGisMonitorSf6Chartses);
                jsonObject.clear();
                JSONObject jsonObject2 = GisAssessUtilsNew.getWshlVal(rptGisMonitorSf6Chartses);
                jsonObject.put("aVal", jsonObject2.get("aVal").toString());
                jsonObject.put("bVal", jsonObject2.get("bVal").toString());
                jsonObject.put("cVal", jsonObject2.get("cVal").toString());
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, ParamEnum.GAS_LEAKAGE_ARC_EXTINGUISH_CHAMBER.getValue(), jsonObject.toJSONString(), String.valueOf(wshl_val));

                aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.GAS_LEAKAGE_ARC_EXTINGUISH_CHAMBER.getKey());
                bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.GAS_LEAKAGE_ARC_EXTINGUISH_CHAMBER.getKey());
                wshl = gisFormulaCalInstance.formulaForUpAndDown(wshl_val, "down", aVal, bVal);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, ParamEnum.GAS_LEAKAGE_ARC_EXTINGUISH_CHAMBER.getValue(), GisAssessUtilsNew.formulaForUpAndDown(jsonObject, wshl_val, "down", aVal, bVal), String.valueOf(wshl));

                BigDecimal j2 = gisFormulaCalInstance.calcValue(wshl, jyjz_mhs, qtxl_b);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "导电回路电阻计算", GisAssessUtilsNew.calcValue(jsonObject, wshl, jyjz_mhs, qtxl_b), String.valueOf(wshl));

                BigDecimal j3 = j2.multiply(score_b);
                jsonObject.clear();
                jsonObject.put("j2", j2);
                jsonObject.put("score_b", score_b);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "", jsonObject.toJSONString(), String.valueOf(j3));

                // 绝缘介质-气体压力+微水
                BigDecimal j4 = j1.add(j3);
                jsonObject.clear();
                jsonObject.put("j1", j1);
                jsonObject.put("j3", j3);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "绝缘介质-气体压力+微水", jsonObject.toJSONString(), String.valueOf(j4));

                // 绝缘介质-局放次数
                BigDecimal jfcs_val;
                BigDecimal jfcs;
                BigDecimal jf_b = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.PARTIAL_DISCHARGE_TIMES.getKey());
                BigDecimal jf_c = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.PARTIAL_RELEASE.getKey());
                List<TransformerPdStatistics> transformerGisPdStatistics = transformerPdStatisticsService.findTransformerGisPdStatistics(transformerPdStatistics);
                jfcs_val = GisAssessUtilsNew.getJfcs(transformerGisPdStatistics);

                aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.PARTIAL_DISCHARGE_TIMES.getKey());
                bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.PARTIAL_DISCHARGE_TIMES.getKey());
                jfcs = gisFormulaCalInstance.formulaForUpAndDown(jfcs_val, "down", aVal, bVal);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, ParamEnum.PARTIAL_DISCHARGE_TIMES.getValue(), GisAssessUtilsNew.formulaForUpAndDown(jsonObject, jfcs_val, "down", aVal, bVal), String.valueOf(jfcs));

                BigDecimal k1 = gisFormulaCalInstance.calcValue(jfcs, jf_b, jf_c);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "导电回路电阻计算", GisAssessUtilsNew.calcValue(jsonObject, jfcs, jf_b, jf_c), String.valueOf(k1));

                // 开断磨损-局放量
                BigDecimal jfl;
                BigDecimal jfl_val;
                BigDecimal jf_a = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.LOCAL_DISCHARGE.getKey());
                jfl_val = GisAssessUtilsNew.getJfl(transformerGisPdStatistics);

                aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.LOCAL_DISCHARGE.getKey());
                bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.LOCAL_DISCHARGE.getKey());
                jfl = gisFormulaCalInstance.formulaForUpAndDown(jfl_val, "down", aVal, bVal);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, ParamEnum.LOCAL_DISCHARGE.getValue(), GisAssessUtilsNew.formulaForUpAndDown(jsonObject, jfl_val, "down", aVal, bVal), String.valueOf(jfl));

                BigDecimal k2 = gisFormulaCalInstance.calcValue(jfl, jf_a, jf_c);
                jsonObject.clear();
                jsonObject.put("jfl", jfl);
                jsonObject.put("jf_a", jf_a);
                jsonObject.put("jf_c", jf_c);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "导电回路电阻计算", jsonObject.toJSONString(), String.valueOf(k2));

                // 绝缘介质-局放
                BigDecimal k3 = (k1.add(k2)).multiply(score_b);
                jsonObject.clear();
                jsonObject.put("k1", k1);
                jsonObject.put("k2", k2);
                jsonObject.put("score_b", score_b);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "绝缘介质-局放", jsonObject.toJSONString(), String.valueOf(k3));

                // 绝缘介质-总数据
                h2 = k3.add(j4);
                jsonObject.clear();
                jsonObject.put("k3", k3);
                jsonObject.put("j4", j4);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "绝缘介质-总数据", jsonObject.toJSONString(), String.valueOf(h2));

                // 开断磨损数据
                String gis_kdms = "1";
                BusiOfflineGisRepairVo gisRepair = busiOfflineGisRepairService.findBusiOfflineGisRepair(mainTreeId, siteId);
                BigDecimal kdms_a = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.CUMULATIVE_BREAKING_ACTION_TIME.getKey());
                BigDecimal kdms_b = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.SERVICE_LIFE.getKey());
                BigDecimal kdms_c = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.RELATIVE_ELECTRICAL_WEAR.getKey());

                // 使用年限得分
                BigDecimal shiyongnianxian_total;
                // 累积动作次数得分
                BigDecimal leijidongzuocishu_total;
                // 相对电磨损程度得分
                BigDecimal xiangduidianmosun_total;
                // 开断磨损总得分
                BigDecimal gis_kdmo_total;

                BigDecimal synx_val = new BigDecimal(0);
                BigDecimal synx = new BigDecimal(0);
                if (busiOfflineGisBrandVo != null) {
                    synx_val = GisAssessUtilsNew.getSynx(busiOfflineGisBrandVo);
                    log.info("使用年限时间：{}", synx_val);
                    // synx升降后的计算使用年限
                    aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, "dkms_shiyongnianxian");
                    bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, "dkms_shiyongnianxian");
                    synx = gisFormulaCalInstance.formulaForUpAndDown(synx_val, "down", aVal, bVal);
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "synx升降后的计算使用年限", GisAssessUtilsNew.formulaForUpAndDown(jsonObject, synx_val, "down", aVal, bVal), String.valueOf(synx));
                }

                BigDecimal xdmscd_val = new BigDecimal(0);
                BigDecimal dkcsFor100_val = new BigDecimal(0);
                BigDecimal dkcsFor100 = new BigDecimal(0);
                BigDecimal xdmscd = new BigDecimal(0);
                BigDecimal eddkdl = new BigDecimal("0");
                if (busiOfflineGisBrandVo != null) {
                    eddkdl = GisAssessUtilsNew.getEddkdl(busiOfflineGisBrandVo);
                    eddkdl = eddkdl.multiply(new BigDecimal("1000"));
                    log.info("触头额定断开电流(A)-标牌：{}", eddkdl);
                    jsonObject.clear();
                    jsonObject.put("eddkdl", eddkdl);
                    jsonObject.put("eddkdl1", new BigDecimal("1000"));
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "触头额定断开电流(A)-标牌", jsonObject.toJSONString(), String.valueOf(eddkdl));
                }

                //评测中间结果如果为空取全部数据进行评测
                if(gisAssessmentResultDataList.isEmpty()) {
                    if (!iecBreakerParams.isEmpty()) {
                        // 100%负荷的断开次数
                        dkcsFor100_val = GisAssessUtilsNew.getDkcsesFor100(iecBreakerParams, eddkdl);
                        aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.CUMULATIVE_BREAKING_ACTION_TIME.getKey());
                        bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.CUMULATIVE_BREAKING_ACTION_TIME.getKey());
                        dkcsFor100 = gisFormulaCalInstance.formulaForUpAndDown(dkcsFor100_val, "down", aVal, bVal);
                        step += 1;
                        GisAssessUtilsNew.setStep(jsonArray, step, ParamEnum.CUMULATIVE_BREAKING_ACTION_TIME.getValue(), GisAssessUtilsNew.formulaForUpAndDown(jsonObject, dkcsFor100_val, "down", aVal, bVal), String.valueOf(dkcsFor100));

                        // 触头磨损率
                        xdmscd_val = GisAssessUtilsNew.getMslsForFh(iecBreakerParams, eddkdl);
                        aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.RELATIVE_ELECTRICAL_WEAR.getKey());
                        bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.RELATIVE_ELECTRICAL_WEAR.getKey());
                        xdmscd = gisFormulaCalInstance.formulaForUpAndDown(xdmscd_val, "down", aVal, bVal);
                        step += 1;
                        GisAssessUtilsNew.setStep(jsonArray, step, ParamEnum.RELATIVE_ELECTRICAL_WEAR.getValue(), GisAssessUtilsNew.formulaForUpAndDown(jsonObject, xdmscd_val, "down", aVal, bVal), String.valueOf(xdmscd));

                        gis_kdms = ComputeUtil.eval(engine, ParamEnum.GIS_KDMS.getKey(), dkcsFor100, synx, xdmscd, kdms_a, kdms_b, kdms_c);
                        jsonObject.clear();
                        jsonObject.put("dkcsFor100", dkcsFor100);
                        jsonObject.put("synx", synx);
                        jsonObject.put("xdmscd", xdmscd);
                        jsonObject.put("kdms_a", kdms_a);
                        jsonObject.put("kdms_b", kdms_b);
                        jsonObject.put("kdms_c", kdms_c);
                        step += 1;
                        GisAssessUtilsNew.setStep(jsonArray, step, ParamEnum.GIS_KDMS.getValue(), jsonObject.toJSONString(), String.valueOf(gis_kdms));
                    } else {
                        shiyongnianxian_total = kdms_b;
                        log.info("使用年限得分：{}", shiyongnianxian_total);
                        leijidongzuocishu_total = kdms_a;
                        log.info("累积动作次数得分：{}", leijidongzuocishu_total);
                        xiangduidianmosun_total = kdms_c;
                        log.info("相对电磨损程度得分：{}", xiangduidianmosun_total);
                        gis_kdmo_total = score_c;
                        log.info("开断磨损得分：{}", gis_kdmo_total);
                    }
                } else if(!gisAssessmentResultDataList.isEmpty() && iecBreakerParams.isEmpty()) {
                    //评测中间结果不为空，参数表取得前一天评测数据为空，取评测中间结果数据最为评测
                    GisAssessmentResultData gisAssessmentResultData = gisAssessmentResultDataList.get(0);
                    dkcsFor100_val = new BigDecimal(gisAssessmentResultData.getDkcses());

                    aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.CUMULATIVE_BREAKING_ACTION_TIME.getKey());
                    bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.CUMULATIVE_BREAKING_ACTION_TIME.getKey());
                    dkcsFor100 = gisFormulaCalInstance.formulaForUpAndDown(dkcsFor100_val, "down", aVal, bVal);
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, ParamEnum.CUMULATIVE_BREAKING_ACTION_TIME.getValue(), GisAssessUtilsNew.formulaForUpAndDown(jsonObject, dkcsFor100_val, "down", aVal, bVal), String.valueOf(dkcsFor100));

                    // 触头磨损率
                    xdmscd_val = new BigDecimal(gisAssessmentResultData.getContactWearRate());
                    aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.RELATIVE_ELECTRICAL_WEAR.getKey());
                    bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.RELATIVE_ELECTRICAL_WEAR.getKey());
                    xdmscd = gisFormulaCalInstance.formulaForUpAndDown(xdmscd_val, "down", aVal, bVal);
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, ParamEnum.RELATIVE_ELECTRICAL_WEAR.getValue(), GisAssessUtilsNew.formulaForUpAndDown(jsonObject, xdmscd_val, "down", aVal, bVal), String.valueOf(xdmscd));

                    gis_kdms = ComputeUtil.eval(engine, ParamEnum.GIS_KDMS.getKey(), dkcsFor100, synx, xdmscd, kdms_a, kdms_b, kdms_c);
                    jsonObject.clear();
                    jsonObject.put("dkcsFor100", dkcsFor100);
                    jsonObject.put("synx", synx);
                    jsonObject.put("xdmscd", xdmscd);
                    jsonObject.put("kdms_a", kdms_a);
                    jsonObject.put("kdms_b", kdms_b);
                    jsonObject.put("kdms_c", kdms_c);
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, ParamEnum.GIS_KDMS.getValue(), jsonObject.toJSONString(), String.valueOf(gis_kdms));
                } else {
                    //评测中间结果、参数表中前一天评测数据都不为空，评测数据+断开参数表作为新评测数据。
                    GisAssessmentResultData gisAssessmentResultData = gisAssessmentResultDataList.get(0);
                    aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.CUMULATIVE_BREAKING_ACTION_TIME.getKey());
                    bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.CUMULATIVE_BREAKING_ACTION_TIME.getKey());
                    dkcsFor100 = gisFormulaCalInstance.formulaForUpAndDown(dkcsFor100_val, "down", aVal, bVal);
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, ParamEnum.CUMULATIVE_BREAKING_ACTION_TIME.getValue(), GisAssessUtilsNew.formulaForUpAndDown(jsonObject, dkcsFor100_val, "down", aVal, bVal), String.valueOf(dkcsFor100));

                    // 触头磨损率
                    xdmscd_val =new BigDecimal(gisAssessmentResultData.getDkcses()).add(GisAssessUtilsNew.getDkcsesFor100(iecBreakerParams, eddkdl));
                    aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.RELATIVE_ELECTRICAL_WEAR.getKey());
                    bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.RELATIVE_ELECTRICAL_WEAR.getKey());
                    xdmscd = gisFormulaCalInstance.formulaForUpAndDown(xdmscd_val, "down", aVal, bVal);
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, ParamEnum.RELATIVE_ELECTRICAL_WEAR.getValue(), GisAssessUtilsNew.formulaForUpAndDown(jsonObject, xdmscd_val, "down", aVal, bVal), String.valueOf(xdmscd));

                    gis_kdms = ComputeUtil.eval(engine, ParamEnum.GIS_KDMS.getKey(), dkcsFor100, synx, xdmscd, kdms_a, kdms_b, kdms_c);
                    jsonObject.clear();
                    jsonObject.put("dkcsFor100", dkcsFor100);
                    jsonObject.put("synx", synx);
                    jsonObject.put("xdmscd", xdmscd);
                    jsonObject.put("kdms_a", kdms_a);
                    jsonObject.put("kdms_b", kdms_b);
                    jsonObject.put("kdms_c", kdms_c);
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, ParamEnum.GIS_KDMS.getValue(), jsonObject.toJSONString(), String.valueOf(gis_kdms));
                }

                // 累计断开次数-总得分
                leijidongzuocishu_total = gisFormulaCalInstance.calcValue(dkcsFor100,kdms_a,score_c);
                jsonObject.clear();
                jsonObject.put("dkcsFor100", dkcsFor100);
                jsonObject.put("kdms_a", kdms_a);
                jsonObject.put("score_c", score_c);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "累计断开次数-总得分", jsonObject.toJSONString(), String.valueOf(leijidongzuocishu_total));

                // 使用年限-总得分
                shiyongnianxian_total = gisFormulaCalInstance.calcValue(synx,kdms_b,score_c);
                jsonObject.clear();
                jsonObject.put("synx", synx);
                jsonObject.put("kdms_b", kdms_b);
                jsonObject.put("score_c", score_c);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "使用年限-总得分", jsonObject.toJSONString(), String.valueOf(shiyongnianxian_total));

                // 相对磨损程度-总得分
                xiangduidianmosun_total = gisFormulaCalInstance.calcValue(xdmscd,kdms_c,score_c);
                jsonObject.clear();
                jsonObject.put("xdmscd", xdmscd);
                jsonObject.put("kdms_c", kdms_c);
                jsonObject.put("score_c", score_c);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "相对磨损程度-总得分", jsonObject.toJSONString(), String.valueOf(xiangduidianmosun_total));

                // 开断磨损-总得分
                h3 = leijidongzuocishu_total.add(shiyongnianxian_total).add(xiangduidianmosun_total);
                jsonObject.clear();
                jsonObject.put("leijidongzuocishu_total", leijidongzuocishu_total);
                jsonObject.put("shiyongnianxian_total", shiyongnianxian_total);
                jsonObject.put("xiangduidianmosun_total", xiangduidianmosun_total);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "开断磨损-总得分", jsonObject.toJSONString(), String.valueOf(h3));

                // TODO 4.1 运行参数 --- >工作环境
                BigDecimal syhjwd_val;
                BigDecimal syhjwd;
                BigDecimal gzhj_a;
                BigDecimal syhjsd_val;
                BigDecimal syhjsd;
                BigDecimal gzhj_b;
                BigDecimal syhj;
                BigDecimal qtys;
                BigDecimal gzhj_d;
                BigDecimal gzhj_c;
                String gis_gzhj = "1";
                // 工作环境
                BigDecimal sxcs_a = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.WORK_ENVIRONMENT.getKey());
                // 外观权重
                BigDecimal sxcs_b = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.APPEARANCE.getKey());
                // 厂家权重
                BigDecimal sxcs_c = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.MANUFACTURER.getKey());
                // 断路器维护权重
                BigDecimal wgqk_f = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.CIRCUIT_BREAKER_MAINTENANCE.getKey());

                //使用环境温度
                syhjwd_val = GisAssessUtilsNew.getSyhjwd( substationMicGis);
                log.info("机械特性-使用环境温度：{}", syhjwd_val);

                aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.OPERATING_AMBIENT_TEMPERATURE.getKey());
                bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.OPERATING_AMBIENT_TEMPERATURE.getKey());
                syhjwd = gisFormulaCalInstance.formulaForUpAndDown(syhjwd_val, "down", aVal, bVal);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, ParamEnum.OPERATING_AMBIENT_TEMPERATURE.getValue(), GisAssessUtilsNew.formulaForUpAndDown(jsonObject, syhjwd_val, "down",aVal, bVal), String.valueOf(syhjwd));

                gzhj_a = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.OPERATING_AMBIENT_TEMPERATURE.getKey());

                //使用环境湿度
                syhjsd_val = GisAssessUtilsNew.getSyhjsd(mainTreeId, mainTreeId, substationMicGis);
                log.info("机械特性-使用环境湿度：{}", syhjsd_val);

                aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.OPERATING_AMBIENT_HUMIDITY.getKey());
                bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.OPERATING_AMBIENT_HUMIDITY.getKey());
                syhjsd = gisFormulaCalInstance.formulaForUpAndDown(syhjsd_val, "down", aVal, bVal);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, ParamEnum.OPERATING_AMBIENT_HUMIDITY.getValue(), GisAssessUtilsNew.formulaForUpAndDown(jsonObject, syhjsd_val, "down",aVal, bVal), String.valueOf(syhjsd));

                gzhj_b = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.OPERATING_AMBIENT_HUMIDITY.getKey());

                syhj = GisAssessUtilsNew.getCafs(gisRepair);
                log.info("检修记录-尘埃、腐蚀：{}", syhj);

                qtys = GisAssessUtilsNew.getQt(busiOfflineGisBrandVo);
                gzhj_d = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.ALTITUDE.getKey());
                gzhj_c = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.DUST_CORROSION.getKey());
                log.info("其他因素权重：{}, 尘埃权重: {}", gzhj_d, gzhj_c);

                // syhjwd 使用环境温度 gzhj_a 使用环境温度权重 sxcs_a 工作环境权重 sxcs_a
                BigDecimal wd = gisFormulaCalInstance.calcValue(syhjwd, gzhj_a, sxcs_a);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "导电回路电阻计算", GisAssessUtilsNew.calcValue(jsonObject, syhjwd, gzhj_a, sxcs_a), String.valueOf(wd));
                log.info("---------------------------------使用环境温度begin----------------------------------");
                log.info("  使用环境温度计算公式：(温度参数）*b2*d4");
                log.info("  温度参数(使用环境温度升降序计算结果)：{},使用环境温度权重b2：{}, 工作环境权重 d4：{}", syhjwd, gzhj_a, sxcs_a);
                log.info("  使用环境温度计算结果  = {}", wd);
                log.info("---------------------------------使用环境温度end----------------------------------");

                // syhjwd 使用环境湿度 gzhj_b 使用环境湿度权重 sxcs_a 工作环境权重 sxcs_a
                BigDecimal sd = gisFormulaCalInstance.calcValue(syhjsd, gzhj_b, sxcs_a);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "导电回路电阻计算", GisAssessUtilsNew.calcValue(jsonObject, syhjsd, gzhj_b, sxcs_a), String.valueOf(sd));
                log.info("---------------------------------使用环境湿度begin----------------------------------");
                log.info("  使用环境湿度计算公式：（湿度参数）*b1*d4");
                log.info("  湿度参数(使用环境湿度升降序计算结果)：{},使用环境湿度权重b1：{}, 工作环境权重 d4：{}", syhjsd, gzhj_b, sxcs_a);
                log.info("  使用环境湿度计算结果  = {}", sd);
                log.info("---------------------------------使用环境湿度end----------------------------------");

                // 检修记录-尘埃、腐蚀
                BigDecimal hj = gisFormulaCalInstance.calcValue(syhj, gzhj_c, sxcs_a);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "导电回路电阻计算", GisAssessUtilsNew.calcValue(jsonObject, syhj, gzhj_c, sxcs_a), String.valueOf(hj));
                log.info("---------------------------------空气质量begin----------------------------------");
                log.info("  空气质量计算公式：(尘埃、腐蚀）*b3*d4");
                log.info("  空气质量：{}, 尘埃、腐蚀权重b3：{}, 工作环境权重 d4：{}", syhj, gzhj_c, sxcs_a);
                log.info("  空气质量算结果  = {}", hj);
                log.info("---------------------------------空气质量end----------------------------------");

                // 其他因素
                BigDecimal ys = gisFormulaCalInstance.calcValue(qtys, gzhj_d, sxcs_a);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "导电回路电阻计算", GisAssessUtilsNew.calcValue(jsonObject, qtys, gzhj_d, sxcs_a), String.valueOf(ys));
                log.info("---------------------------------海拔begin----------------------------------");
                log.info("  海拔计算公式：(海拔）*b4*d4}");
                log.info("  海拔：{},海拔权重权重b3：{}, 工作环境权重 d4：{}", qtys, gzhj_d, sxcs_a);
                log.info("  海拔计算结果  = {}", ys);
                log.info("---------------------------------海拔end----------------------------------");

                // 运行参数-其他因素-工作环境总结果
                h4 = wd.add(sd).add(hj).add(ys);
                jsonObject.clear();
                jsonObject.put("wd", wd);
                jsonObject.put("sd", sd);
                jsonObject.put("hj", hj);
                jsonObject.put("ys", ys);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "运行参数-其他因素-工作环境总结果", jsonObject.toJSONString(), String.valueOf(h4));
                log.info("---------------------------------h4  begin----------------------------------");
                log.info("  h4计算公式：h4=w*{（湿度参数）*b1*d4+(温度参数）*b2*d4+(空气质量）*b3*d4+(海拔）*b4*d4}");
                log.info("  w=运行参数-工作环境权重");
                log.info("  湿度：{}, 温度：{}, 空气质量：{}, 海拔：{}", ys, sd, wd, hj);
                log.info("  h4  = {}", h4);
                log.info("---------------------------------h4  end----------------------------------");

                BusiOfflineGisRepairDto busiOfflineGisRepairDto = new BusiOfflineGisRepairDto();
                busiOfflineGisRepairDto.setMainEquipmentId(mainTreeId);
                busiOfflineGisRepairDto.setSiteId(siteId);
                List<BusiOfflineGisRepairVo> list = busiOfflineGisRepairService.findBusiOfflineGisRepairList(busiOfflineGisRepairDto);
                // 运行参数 -->> 4.2 外观情况
                String gis_wgqk = "1";
                BigDecimal czjgLubrication;
                BigDecimal wgqk_a;
                BigDecimal ztjgAppearance;
                BigDecimal wgqk_b;
                BigDecimal supportInsulation;
                BigDecimal wgqk_c;
                BigDecimal mainLoopTerminal;
                BigDecimal wgqk_d;
                BigDecimal tldlqMaintain;
                BigDecimal wgqk_e;
                // 操作机构润滑
                czjgLubrication = GisAssessUtilsNew.getCzjgrh(list, jsonArray);
                wgqk_a = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.OPERATE_MECHANISM_LUBRICATION.getKey());
                // 主体、机构外观
                ztjgAppearance = GisAssessUtilsNew.getZtjgwg(list, jsonArray);
                wgqk_b = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.MAIN_APPEARANCE_MECHANISM.getKey());
                // 支持绝缘部分
                supportInsulation = GisAssessUtilsNew.getZcjybf(list, jsonArray);
                wgqk_c = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.SUPPORT_INSULATION_PART.getKey());
                // 主回路端子
                mainLoopTerminal = GisAssessUtilsNew.getZhldz(list, jsonArray);
                wgqk_d = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.MAIN_CIRCUIT_TERMINAL.getKey());
                // 断路器维护次数(检修记录)
                tldlqMaintain = GisAssessUtilsNew.getTldlqwhcs(list, jsonArray);
                wgqk_e = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.SIMILAR_CIRCUIT_BREAKERS_MAINTENANCE_TIMES.getKey());

                gis_wgqk = ComputeUtil.eval(engine, ParamEnum.GIS_WGQK.getKey(), czjgLubrication, wgqk_a, ztjgAppearance, wgqk_b,
                        supportInsulation, wgqk_c, mainLoopTerminal, wgqk_d, tldlqMaintain, wgqk_e);
                log.info("检修记录-操作机构润滑: {}", wgqk_a);
                log.info("检修记录-主体、机构外观: {}", wgqk_b);
                log.info("检修记录-支持绝缘部分: {}", wgqk_c);
                log.info("检修记录-主回路端子: {}", wgqk_d);
                log.info("检修记录-断路器维护次数(检修记录): {}", wgqk_e);
                log.info("检修记录-运行参数-外观情况: {}", wgqk_e);
                jsonObject.clear();
                jsonObject.put("czjgLubrication", czjgLubrication);
                jsonObject.put("wgqk_a", wgqk_a);
                jsonObject.put("ztjgAppearance", ztjgAppearance);
                jsonObject.put("wgqk_b", wgqk_b);
                jsonObject.put("supportInsulation", supportInsulation);
                jsonObject.put("wgqk_c", wgqk_c);
                jsonObject.put("mainLoopTerminal", mainLoopTerminal);
                jsonObject.put("wgqk_d", wgqk_d);
                jsonObject.put("tldlqMaintain", tldlqMaintain);
                jsonObject.put("wgqk_e", wgqk_e);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, ParamEnum.GIS_WGQK.getValue(), jsonObject.toJSONString(), String.valueOf(gis_wgqk));

                BigDecimal rh = gisFormulaCalInstance.calcValue(czjgLubrication,wgqk_a,sxcs_b);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "导电回路电阻计算", GisAssessUtilsNew.calcValue(jsonObject, czjgLubrication, wgqk_a, sxcs_b), String.valueOf(rh));

                BigDecimal wg = gisFormulaCalInstance.calcValue(ztjgAppearance,wgqk_b,sxcs_b);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "导电回路电阻计算", GisAssessUtilsNew.calcValue(jsonObject, ztjgAppearance, wgqk_b, sxcs_b), String.valueOf(wg));

                BigDecimal dz = gisFormulaCalInstance.calcValue(mainLoopTerminal,wgqk_d,sxcs_b);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "导电回路电阻计算", GisAssessUtilsNew.calcValue(jsonObject, mainLoopTerminal, wgqk_d, sxcs_b), String.valueOf(dz));

                BigDecimal zc = gisFormulaCalInstance.calcValue(supportInsulation,wgqk_c,sxcs_b);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "导电回路电阻计算", GisAssessUtilsNew.calcValue(jsonObject, supportInsulation, wgqk_c, sxcs_b), String.valueOf(zc));

                // 运行参数-其他因素-外观情况总结果
                h5 = rh.add(wg).add(dz).add(zc);
                jsonObject.clear();
                jsonObject.put("rh", rh);
                jsonObject.put("wg", wg);
                jsonObject.put("dz", dz);
                jsonObject.put("zc", zc);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "运行参数-其他因素-外观情况总结果计算", jsonObject.toJSONString(), String.valueOf(h5));
                log.info("---------------------------------操作机构润滑 begin----------------------------------");
                log.info("  操作机构润滑计算公式：(操作机构润滑）*c1");
                log.info("  c1=操作机构权重");
                log.info("  操作机构润滑：{}, 操作机构权重c1：{}", czjgLubrication, wgqk_a);
                log.info("  操作机构润滑海拔计算结果 = {}", rh);
                log.info("---------------------------------操作机构润滑  end----------------------------------");

                log.info("---------------------------------本体外观 begin----------------------------------");
                log.info("  本体外观计算公式：(本体外观）*c2");
                log.info("  c2=机构外观权重");
                log.info("  本体外观：{}, 操作机构权重c2：{}", czjgLubrication, wgqk_b);
                log.info("  本体外观计算结果  = {}", wg);
                log.info("---------------------------------本体外观  end----------------------------------");

                log.info("---------------------------------主回路端子 begin----------------------------------");
                log.info("  主回路端子计算公式：(主回路端子）*c3");
                log.info("  c3=主回路端子权重");
                log.info("  主回路端子：{},主回路端子权重c3：{}", mainLoopTerminal, wgqk_d);
                log.info("  主回路端子计算结果  = {}", wg);
                log.info("---------------------------------主回路端子 end----------------------------------");

                log.info("---------------------------------绝缘支撑 begin----------------------------------");
                log.info("  绝缘支撑计算公式：(绝缘支撑）*c4");
                log.info("  c4=绝缘支撑权重");
                log.info("  绝缘支撑：{},绝缘支撑权重c4：{}", supportInsulation, wgqk_c);
                log.info("  绝缘支撑计算结果  = {}", wg);
                log.info("---------------------------------绝缘支撑 end----------------------------------");

                BigDecimal productMaturity = new BigDecimal("0");
                BigDecimal popularity = new BigDecimal("0");
                if (busiOfflineGisBrandVo != null) {
                    productMaturity = GisAssessUtilsNew.getCpcsd(busiOfflineGisBrandVo, jsonArray);
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "产品成熟度计算", busiOfflineGisBrandVo.getProductMaturity(), String.valueOf(productMaturity));

                    popularity = GisAssessUtilsNew.getZmd(busiOfflineGisBrandVo);
                    log.info("产品成熟度-标牌: {}, 知名度（手动录入）-标牌: {}", productMaturity, popularity);
                }

                BigDecimal cjyc = new BigDecimal("0");
                if (!list.isEmpty()) {
                    cjyc = GisAssessUtilsNew.getCjyc(list);
                    log.info("检修记录-厂家设备遗传: {}", cjyc);
                }

                BigDecimal sccj_a = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.MANUFACTURER_EQUIPMENT_GENETICS.getKey());
                log.info("厂家设备遗传权重: {}", sccj_a);
                // TODO 4.4 运行参数 -->> 断路器维护 dlqMaintenance
                BigDecimal dlqMaintenance = new BigDecimal("1");
                if (!list.isEmpty()) {
                    dlqMaintenance = GisAssessUtilsNew.getDlqwh(list);
                    log.info("断路器维护-断路器维护: {}", dlqMaintenance);
                }

                // TODO 4.3运行参数 -->> 生产厂家 gis_sccj
                // 产品成熟度
                BigDecimal sccj_b = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.PRODUCT_MATURITY.getKey());
                // 知名度（手动录入）标牌
                BigDecimal sccj_c = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.POPULARITY.getKey());
                /// 厂家
                String gis_sccj = ComputeUtil.eval(engine, ParamEnum.GIS_SCCJ.getKey(), cjyc, sccj_a, productMaturity, sccj_b,
                        popularity, sccj_c);
                log.info("产品成熟度权重: {}", sccj_b);
                log.info("知名度（手动录入）标牌: {}", sccj_c);
                log.info("厂家设备遗传权重：{}", sccj_a);
                jsonObject.clear();
                jsonObject.put("cjyc", cjyc);
                jsonObject.put("sccj_a", sccj_a);
                jsonObject.put("productMaturity", productMaturity);
                jsonObject.put("sccj_b", sccj_b);
                jsonObject.put("popularity", popularity);
                jsonObject.put("sccj_c", sccj_c);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, ParamEnum.GIS_SCCJ.getValue(), jsonObject.toJSONString(), String.valueOf(gis_sccj));

                BigDecimal yc = gisFormulaCalInstance.calcValue(cjyc,sccj_a,sxcs_c);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "导电回路电阻计算", GisAssessUtilsNew.calcValue(jsonObject, cjyc, sccj_a, sxcs_c), String.valueOf(yc));

                BigDecimal csd = gisFormulaCalInstance.calcValue(productMaturity,sccj_b,sxcs_c);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "导电回路电阻计算", GisAssessUtilsNew.calcValue(jsonObject, productMaturity, sccj_b, sxcs_c), String.valueOf(csd));

                BigDecimal zmd = gisFormulaCalInstance.calcValue(popularity,sccj_c,sxcs_c);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "导电回路电阻计算", GisAssessUtilsNew.calcValue(jsonObject, popularity, sccj_c, sxcs_c), String.valueOf(zmd));

                // 运行参数-其他因素-生产厂家总结果
                h6 = yc.add(csd).add(zmd);
                jsonObject.clear();
                jsonObject.put("yc", yc);
                jsonObject.put("csd", csd);
                jsonObject.put("zmd", zmd);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "运行参数-其他因素-生产厂家总结果", jsonObject.toJSONString(), String.valueOf(h6));
                log.info("---------------------------------遗传 begin----------------------------------");
                log.info("  遗传计算公式：(遗传）*z1");
                log.info("  z1=遗传权重");
                log.info("  遗传：{}, 遗传权重z1：{}", cjyc, sccj_a);
                log.info("  遗传计算结果  = " + yc);
                log.info("---------------------------------遗传 end----------------------------------");

                log.info("---------------------------------产品知名度 begin----------------------------------");
                log.info("  产品知名度计算公式：(产品知名度）*z2");
                log.info("  z2=产品知名度权重");
                log.info("  产品知名度：{},产品知名度权重z2：{}", popularity, sccj_c);
                log.info("  产品知名度计算结果  = {}", zmd);
                log.info("---------------------------------产品知名度 end----------------------------------");

                log.info("---------------------------------产品成熟度 begin----------------------------------");
                log.info("  产品成熟度计算公式：(产品成熟度）*z3");
                log.info("  z3=产品成熟度权重");
                log.info("  产品成熟度：{},产品成熟度权重z2：{}", productMaturity, sccj_b);
                log.info("  产品成熟度计算结果  = {}", csd);
                log.info("---------------------------------产品成熟度 end----------------------------------");

                BigDecimal yxcs_qt = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.OPERATE_PARAMETER.getKey());
                // 工作环境得分
                BigDecimal yxcs_gongzuohuanjing_total = GisAssessUtilsNew.calcMultiply(yxcs_qt,h4);
                jsonObject.clear();
                jsonObject.put("yxcs_qt", yxcs_qt);
                jsonObject.put("h4", h4);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "工作环境得分计算", jsonObject.toJSONString(), String.valueOf(yxcs_gongzuohuanjing_total));

                // 外观得分
                BigDecimal yxcs_waiguang_total = GisAssessUtilsNew.calcMultiply(yxcs_qt,h5);
                jsonObject.clear();
                jsonObject.put("yxcs_qt", yxcs_qt);
                jsonObject.put("h5", h5);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "外观得分计算", jsonObject.toJSONString(), String.valueOf(yxcs_waiguang_total));

                // 厂家得分
                BigDecimal yxcs_changjia_total = GisAssessUtilsNew.calcMultiply(yxcs_qt,h6);
                jsonObject.clear();
                jsonObject.put("yxcs_qt", yxcs_qt);
                jsonObject.put("h6", h6);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "厂家得分计算", jsonObject.toJSONString(), String.valueOf(yxcs_changjia_total));

                // 断路器维护得分
                BigDecimal yxcs_dlqwh_total = gisFormulaCalInstance.calcValue(dlqMaintenance,wgqk_f,yxcs_qt);
                log.info("工作环境得分：{}", yxcs_gongzuohuanjing_total);
                log.info("外观得分：{}", yxcs_waiguang_total);
                log.info("厂家得分：{}", yxcs_changjia_total);
                log.info("断路器维护得分：{}", yxcs_dlqwh_total);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "断路器维护得分计算", GisAssessUtilsNew.calcValue(jsonObject, dlqMaintenance, wgqk_f, yxcs_qt), String.valueOf(yxcs_dlqwh_total));

                // 4.运行参数
                String gis_yxcs = ComputeUtil.eval(engine, ParamEnum.GIS_YXCS.getKey(), gis_gzhj, sxcs_a, gis_wgqk, sxcs_b, gis_sccj, sxcs_c,
                        dlqMaintenance, wgqk_f);
                jsonObject.clear();
                jsonObject.put("gis_gzhj", gis_gzhj);
                jsonObject.put("sxcs_a", sxcs_a);
                jsonObject.put("gis_wgqk", gis_wgqk);
                jsonObject.put("sxcs_b", sxcs_b);
                jsonObject.put("gis_sccj", gis_sccj);
                jsonObject.put("sxcs_c", sxcs_c);
                jsonObject.put("dlqMaintenance", dlqMaintenance);
                jsonObject.put("wgqk_f", wgqk_f);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "断路器维护得分计算", jsonObject.toJSONString(), String.valueOf(gis_yxcs));

                // 运行参数总得分
                String gis_yxcs_total = yxcs_waiguang_total.add(yxcs_changjia_total).add(yxcs_gongzuohuanjing_total).add(yxcs_dlqwh_total).toString();
                log.info("运行参数：{}, 运行参数总得分: {}", gis_yxcs, gis_yxcs_total);
                jsonObject.clear();
                jsonObject.put("yxcs_waiguang_total", yxcs_waiguang_total);
                jsonObject.put("yxcs_changjia_total", yxcs_changjia_total);
                jsonObject.put("yxcs_gongzuohuanjing_total", yxcs_gongzuohuanjing_total);
                jsonObject.put("yxcs_dlqwh_total", yxcs_dlqwh_total);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "运行参数总得分计算", jsonObject.toJSONString(), String.valueOf(gis_yxcs_total));

                BigDecimal jxjlResult = tldlqMaintain.multiply(wgqk_e).setScale(4, BigDecimal.ROUND_HALF_UP);
                jsonObject.clear();
                jsonObject.put("tldlqMaintain", tldlqMaintain);
                jsonObject.put("wgqk_e", wgqk_e);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "", jsonObject.toJSONString(), String.valueOf(jxjlResult));

                h7 = gisFormulaCalInstance.calcValue(yxcs_qt, yxcs_dlqwh_total, jxjlResult);
                log.info("---------------------------------h7 begin----------------------------------");
                log.info("  h7计算公式：h7=w*(维修记录）*z5");
                log.info("  w=运行参数-工作环境权重，z5=检修次数记录");
                log.info("  运行参数权重w：{}, 维修记录：{}, 检修次数记录z5: {}", yxcs_qt, yxcs_dlqwh_total, jxjlResult);
                log.info("  h7计算结果  = {}", h7);
                log.info("---------------------------------h7 end----------------------------------");
                jsonObject.clear();
                jsonObject.put("yxcs_qt", yxcs_qt);
                jsonObject.put("yxcs_dlqwh_total", yxcs_dlqwh_total);
                jsonObject.put("jxjlResult", jxjlResult);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "h7计算", jsonObject.toJSONString(), String.valueOf(h7));

                String score = "100";
                if (busiParamGisVo.size() > 11) {
                    score = Math.round(Double.parseDouble(ddhldz_result.add(h1).add(h2).add(h3).add((h4.add(h5).add(h6)).multiply(yxcs_qt)).add(yxcs_dlqwh_total).add(h7)
                            .multiply(BigDecimal.valueOf(100)).setScale(4, BigDecimal.ROUND_HALF_UP) + "")) + "";
                    log.info("score::" + score);
                    jsonObject.clear();
                    jsonObject.put("ddhldz_result", ddhldz_result);
                    jsonObject.put("yxcs_qt", yxcs_qt);
                    jsonObject.put("yxcs_dlqwh_total", yxcs_dlqwh_total);
                    jsonObject.put("h1", h1);
                    jsonObject.put("h2", h2);
                    jsonObject.put("h3", h3);
                    jsonObject.put("h4", h4);
                    jsonObject.put("h5", h5);
                    jsonObject.put("h6", h6);
                    jsonObject.put("h7", h7);
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "", jsonObject.toJSONString(), String.valueOf(score));
                }

                // 健康水平
                String gisStatus = gisFormulaCalInstance.getGisStatus(Convert.str2BigDecimal(score));
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "健康水平计算", score, gisStatus);

                // 检修建议
                String jxjy = gisFormulaCalInstance.getJxjy(Convert.str2BigDecimal(score));
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "检修建计算", score, jxjy);

                // 健康水平说明
                String healthLevelExplain = gisFormulaCalInstance.getJkspsm(Convert.str2BigDecimal(score));
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "健康水平说明计算", score, healthLevelExplain);

                String gis_yxsj_sdtx = ComputeUtil.eval(engine, ParamEnum.GIS_YXSJ_SDTX.getKey(), gfSpeend, ghSpeend, yxsd_a, yxsd_b);
                log.info("速度特性得分：" + gis_yxsj_sdtx);
                log.info("健康水平：" + gisStatus);
                log.info("检修建议：" + jxjy);
                log.info("健康水平说明：" + healthLevelExplain);
                jsonObject.clear();
                jsonObject.put("gfSpeend", gfSpeend);
                jsonObject.put("ghSpeend", ghSpeend);
                jsonObject.put("yxsd_a", yxsd_a);
                jsonObject.put("yxsd_b", yxsd_b);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "速度特性得分计算", score, gis_yxsj_sdtx);

                BigDecimal sydkcs;
                Map<String, Object> iecBreakerParamMap = iecBreakerParamService.findYxdl(siteId, mainTreeId);
                BigDecimal yxdl = new BigDecimal("0");
                if (null != iecBreakerParam) {
                    if (null != iecBreakerParamMap) {
                        yxdl = new BigDecimal(iecBreakerParamMap.get("yxdl").toString());
                    }
                }

                // yxdl运行电流 eddl额定电流
                BigDecimal yxfh = gisFormulaCalInstance.getFh(yxdl, eddl);
                jsonObject.clear();
                jsonObject.put("yxdl", yxdl);
                jsonObject.put("eddl", eddl);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "负荷计算", jsonObject.toJSONString(), String.valueOf(yxfh));

                BigDecimal fh = gisFormulaCalInstance.getFh(dkdl, eddkdl);
                log.info("负荷(%):" + fh);
                jsonObject.clear();
                jsonObject.put("dkdl", dkdl);
                jsonObject.put("eddkdl", eddkdl);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "负荷计算", jsonObject.toJSONString(), String.valueOf(fh));

                BigDecimal kdkcs = gisFormulaCalInstance.getKdkcs(fh);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "负荷计算", String.valueOf(fh), String.valueOf(kdkcs));

                String gis_yxsj = ComputeUtil.eval(engine, ParamEnum.GIS_YXSJ.getKey(), gis_yxsj_ddhldz, gis_yxsj_sjcs, gis_yxsj_sdtx,
                        yxsj_a, yxsj_b, yxsj_c);
                jsonObject.clear();
                jsonObject.put("gis_yxsj_ddhldz", gis_yxsj_ddhldz);
                jsonObject.put("gis_yxsj_sjcs", gis_yxsj_sjcs);
                jsonObject.put("gis_yxsj_sdtx", gis_yxsj_sdtx);
                jsonObject.put("yxsj_a", yxsj_a);
                jsonObject.put("yxsj_b", yxsj_b);
                jsonObject.put("yxsj_c", yxsj_c);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, ParamEnum.GIS_YXSJ.getValue(), jsonObject.toJSONString(), String.valueOf(gis_yxsj));

                // TODO运行参数（数据）得分
                String gis_yxcs1_total = GisAssessUtilsNew.calcMultiply(score_a, new BigDecimal(gis_yxsj)).toString();
                jsonObject.clear();
                jsonObject.put("score_a", score_a);
                jsonObject.put("gis_yxsj", gis_yxsj);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "运行参数（数据）得分计算", jsonObject.toJSONString(), String.valueOf(gis_yxcs1_total));

                // TODO 时间参数得分
                String yxsj_shijiacanshu = GisAssessUtilsNew.calcMultiply(yxsj_b, new BigDecimal(gis_yxsj_sjcs)).toString();
                jsonObject.clear();
                jsonObject.put("yxsj_b", yxsj_b);
                jsonObject.put("gis_yxsj_sjcs", gis_yxsj_sjcs);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "时间参数得分计算", jsonObject.toJSONString(), String.valueOf(yxsj_shijiacanshu));

                // TODO 速度特性得分
                String yxsj_sdtz_qitafangmian = GisAssessUtilsNew.calcMultiply(yxsj_c, new BigDecimal(gis_yxsj_sdtx)).toString();
                jsonObject.clear();
                jsonObject.put("yxsj_c", yxsj_c);
                jsonObject.put("gis_yxsj_sdtx", gis_yxsj_sdtx);
                step += 1;
                GisAssessUtilsNew.setStep(jsonArray, step, "速度特性得分计算", jsonObject.toJSONString(), String.valueOf(yxsj_sdtz_qitafangmian));

                // 开断磨损
                List<GisEvaVo> list11 = new ArrayList<>();
                // 运行数据
                List<GisEvaVo> list21 = new ArrayList<>();
                // 绝缘介质
                List<GisEvaVo> list31 = new ArrayList<>();
                // 运行参数
                List<GisEvaVo> list41 = new ArrayList<>();

                GisEvaVo vo21 = new GisEvaVo(GisCreateUtil.TIME_PARAMETER, gis_yxsj_sjcs, "时间参数");
                GisEvaVo vo22 = new GisEvaVo(GisCreateUtil.VELOCITY_CHARACTERISTICS, yxsj_sdtz_qitafangmian, "速度特性");
                GisEvaVo vo23 = new GisEvaVo(GisCreateUtil.CONDUCTING_CIRCUIT_RESISTANCE, ddhldz_result + "", "导电回路电阻");
                list21.add(vo21);
                list21.add(vo22);
                list21.add(vo23);

                GisEvaVo vo31 = new GisEvaVo(GisCreateUtil.GAS_PRESSURE, yxsj_shijiacanshu, "气体压力");
                GisEvaVo vo32 = new GisEvaVo(GisCreateUtil.MICRO_WATER_CONTENT, yxsj_sdtz_qitafangmian, "微水含量");
                GisEvaVo vo33 = new GisEvaVo(GisCreateUtil.PARTIAL_DISCHARGE, jfl + "", "局放量");
                GisEvaVo vo34 = new GisEvaVo(GisCreateUtil.PARTIAL_DISCHARGE_COUNT, jfcs + "", "局放次数");
                GisEvaVo vo35 = new GisEvaVo(GisCreateUtil.JYJZ_WS_MIEHUSHI, ws_miehushi + "", "灭弧室");
                list31.add(vo31);
                list31.add(vo32);
                list31.add(vo33);
                list31.add(vo34);
                list31.add(vo35);

                GisEvaVo vo41 = new GisEvaVo(GisCreateUtil.WORK_ENVIRONMENT, yxcs_gongzuohuanjing_total.toString(), "工作环境");
                GisEvaVo vo42 = new GisEvaVo(GisCreateUtil.APPEARANCE, yxcs_waiguang_total.toString(), "外观情况");
                GisEvaVo vo43 = new GisEvaVo(GisCreateUtil.MAINTENANCE_RECORD, yxcs_dlqwh_total.toString(), "维修记录");
                GisEvaVo vo44 = new GisEvaVo(GisCreateUtil.Manufacturer, yxcs_changjia_total.toString(), "生产厂家");
                list41.add(vo41);
                list41.add(vo42);
                list41.add(vo43);
                list41.add(vo44);

                // 14-累计断开次数
                sydkcs = new BigDecimal("14").subtract(leijidongzuocishu_total);
                log.info("预期剩余断开次数：" + sydkcs);

                String uuid = Uuid.getUUID();
                gisAssessmentResult.setId(uuid);
                gisAssessmentResult.setSiteId(siteId);
                gisAssessmentResult.setMainTreeId(mainTreeId);
                gisAssessmentResult.setAssessTime(LocalDateTime.now());
                gisAssessmentResult.setHealthScore(
                        GisAssessUtilsNew.formatNumStr(score).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
                // 触头磨损率
                gisAssessmentResult.setHealthLevel(gisStatus);
                gisAssessmentResult.setHealthLevelExplain(healthLevelExplain);
                gisAssessmentResult.setContactWearRate(xdmscd_val.toString());
                // 取值待定标牌中数据
                gisAssessmentResult.setExpectedUsageCount(busiOfflineGisBrandVo.getServiceTime());
                gisAssessmentResult.setRemainingUsageCount(sydkcs.toString());
                gisAssessmentResult.setOverhaulSuggest(jxjy);
                gisAssessmentResult.setType("2");
                // 断开时负荷
                gisAssessmentResult.setLoadFactor(yxfh.toString());
                gisAssessmentResultService.saveGisAssessmentResult(gisAssessmentResult);

                GisAssessmentResultData result = new GisAssessmentResultData();
                result.setId(Uuid.getUUID());
                result.setEvaluationId(uuid);
                result.setGisId(gisId);
                result.setGisName(gisName);
                result.setAssessTime(LocalDate.now());
                result.setHealthScore(GisAssessUtilsNew.formatNumStr(score).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
                // 触头磨损率
                result.setHealthLevel(gisStatus);
                result.setContactWearRate(xdmscd_val.toString());
                result.setExpectedUsageCount(kdkcs.toString());
                result.setRemainingUsageCount(sydkcs.toString());
                result.setOverhaulSuggest(jxjy);
                result.setDkcses(dkcsFor100_val + "");

                // 开断磨损
                result.setBreakingWear(xiangduidianmosun_total + "");
                result.setOperationalData(gis_yxcs1_total);
                result.setOperationParameters(gis_yxcs_total);
                result.setInsulatingMedium(h2 + "");

                GisEvaVo vo11 = new GisEvaVo(GisCreateUtil.SERVICE_LIFE, shiyongnianxian_total + "", "使用年限");
                GisEvaVo vo12 = new GisEvaVo(GisCreateUtil.RELATIVE_WEAR_DEGREE, xiangduidianmosun_total + "", "相对磨损程度");
                GisEvaVo vo13 = new GisEvaVo(GisCreateUtil.CUMULATIVE_ACTION_TIMES, leijidongzuocishu_total + "", "累计动作次数");
                list11.add(vo11);
                list11.add(vo12);
                list11.add(vo13);

                String json1 = JSONArray.toJSONString(list11);
                String json2 = JSONArray.toJSONString(list21);
                String json3 = JSONArray.toJSONString(list31);
                String json4 = JSONArray.toJSONString(list41);
                result.setBreakingWearDetails(json1);
                result.setOperationalDataDetails(json2);
                result.setInsulatingMediumDetails(json3);
                result.setOperationParametersDetails(json4);
                gisAssessmentResultDataService.save(result);

                // 临时注释，调测后放开
                GisCreateUtil.createFile(result, true, basePath2, GisCreateUtil.FILE_PATH, fileName, date);

                // 新增算法步骤
                calculateStep.setStepJson(jsonArray.toString());
                calculateStep.setPId(uuid);
                calculateStepService.insert(calculateStep);

                // 开发状态
                /************************** 测试数据 **********************/
                log.info("");
                log.info("");
                log.info("*********************gis评测中间值*************************");
                log.info("站点ID：" + siteId);
                log.info("Gis设备编码：" + mainTreeId);
                log.info("Gis打分：" + GisAssessUtilsNew.formatNumStr(score));
                log.info("设备状态：" + gisStatus);
                log.info("健康水平描述：" + healthLevelExplain);
                log.info("检修建议：" + jxjy);
                log.info("累计断开次数：" + leijidongzuocishu_total);
                log.info("----------------运行数据---------------------");
                log.info("运行数据：" + gis_yxsj + "(" + score_a + ")");
                log.info("\t导电回路电阻" + "(值" + gis_yxsj_ddhldz_val + ")" + "：" + gis_yxsj_ddhldz + "(权重" + yxsj_a + ")");
                log.info("\t运行数据-机械试验数据-时间参数：" + gis_yxsj_sjcs + "(" + yxsj_b + ")");
                log.info("\t\t合闸不同期" + "(值" + hz_btq_val + ")" + "：" + hz_btq + "(权重" + sjcs_a + ")");
                log.info("\t\t分闸不同期" + "(值" + fz_btq_val + ")" + "：" + fz_btq + "(权重" + sjcs_b + ")");
                log.info("\t运行数据-机械试验数据-速度参数：" + gis_yxsj_sdtx + "(" + yxsj_c + ")");
                log.info("\t\t刚分速度" + "(值" + gfSpeend_val + ")" + "：" + gfSpeend + "(权重" + yxsd_a + ")");
                log.info("\t\t刚和速度" + "(值" + ghSpeend_val + ")" + "：" + ghSpeend + "(权重" + yxsd_b + ")");
                log.info("----------------绝缘介质（0.189）-SF6在线数据---------------------");
                log.info("绝缘介质（0.189）-SF6在线数据）：" + gis_qtxl + "(权重" + score_b + ")");
                log.info("\t气室压力" + "(值" + yl_val + ")" + "：" + yl + "(权重" + qtxl_a + ")");
                log.info("\t气室微水" + "(值" + wshl_val + ")" + "：" + wshl + "(权重" + qtxl_b + ")");
                log.info("\t局放量" + "(值" + jfl_val + ")" + "：" + jfl + "(权重" + jf_a + ")");
                log.info("\t局放次数" + "(值" + jfcs_val + ")" + "：" + jfcs + "(权重" + jf_b + ")");
                log.info("----------------开断磨损数据---------------------");
                log.info("开断磨损数据：" + gis_kdms + "(" + score_c + ")");
                log.info("\t100%累计开断次数" + "(值" + dkcsFor100_val + ")" + "：" + dkcsFor100 + "(权重" + kdms_a + ")");
                log.info("\t使用年限" + "(值" + synx_val + ")" + "：" + shiyongnianxian_total + "(权重" + kdms_b + ")");
                log.info("\t相对磨损程度" + "(值" + xdmscd_val + ")" + "：" + xiangduidianmosun_total + "(权重" + kdms_c + ")");
                log.info("----------------运行参数---------------------");
                log.info("运行参数：" + GisAssessUtilsNew.formatNumStr(gis_yxcs) + "(" + score_d + ")");
                log.info("\t运行参数-工作环境：" + GisAssessUtilsNew.formatNumStr(gis_gzhj) + "(权重" + sxcs_a + ")");
                log.info("\t\t使用环境温度" + "(值" + syhjwd_val + ")" + "：" + syhjwd + "(权重" + gzhj_a + ")");
                log.info("\t\t使用环境湿度" + "(值" + syhjsd_val + ")" + "：" + syhjsd + "(权重" + gzhj_b + ")");
                log.info("\t\t尘埃、腐蚀：" + syhj + "(" + gzhj_c + ")");
                log.info("\t\t海拔：" + qtys + "(" + gzhj_d + ")");
                log.info("\t运行参数-外观情况：" + GisAssessUtilsNew.formatNumStr(gis_wgqk) + "(" + sxcs_b + ")");
                log.info("\t\t操作机构润滑(检修记录)：" + czjgLubrication + "(" + wgqk_a + ")");
                log.info("\t\t主体、机构外观(检修记录)：" + ztjgAppearance + "(" + wgqk_b + ")");
                log.info("\t\t支持绝缘部分(检修记录)：" + supportInsulation + "(" + wgqk_c + ")");
                log.info("\t\t主回路端子(检修记录)：" + mainLoopTerminal + "(" + wgqk_d + ")");
                log.info("\t断路器维护(检修记录)：" + dlqMaintenance + "(" + wgqk_f + ")");
                log.info("\t运行参数-生产厂家：" + GisAssessUtilsNew.formatNumStr(gis_sccj) + "(" + sxcs_c + ")");
                log.info("\t\t厂家设备遗传：" + cjyc + "(" + sccj_a + ")");
                log.info("\t\t产品成熟度（手动录入）标牌：" + productMaturity + "(" + sccj_b + ")");
                log.info("\t\t知名度（手动录入）标牌：" + popularity + "(" + sccj_c + ")");
                log.info("*********************gis评测end*************************");
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (ScriptException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } finally {
            try {
                ComputeUtil.close(fileReader);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return gisAssessmentResult;
    }

    @Override
    public GisAssessmentResult assessmentByGis(String siteId, String mainTreeId) {

        // Gis评估结果
        GisAssessmentResult gisAssessmentResult = new GisAssessmentResult();
        FileReader fileReader = null;
        try {
            // 加载js引擎
            String basePath = this.getClass().getResource(GisCreateUtil.PATH).getPath();
            fileReader = ComputeUtil.readerJsFile(basePath);
            ScriptEngine engine = ComputeUtil.loadJsScriptEngine(fileReader);

            // 通过systemCode查找 GIS标牌信息
            BusiOfflineGisBrandVo busiOfflineGisBrandVo = busiOfflineGisBrandService.findBusiOfflineGISBrand(siteId, mainTreeId);
            if(busiOfflineGisBrandVo != null){
                String gisId = busiOfflineGisBrandVo.getId();
                String gisName = busiOfflineGisBrandVo.getGisName();
                // 组织文件名
                DateTimeFormatter dateTimeFormater2 = DateTimeFormatter.ofPattern("yyyy-MM-dd");
                LocalDate localDate = LocalDate.now();
                String date = dateTimeFormater2.format(localDate);
                String fileName = gisName + "_" + date + ".xml";
                log.info("--->> GIS名称：{}, id：{}", gisName, gisId);

                TransformerPdStatistics transformerPdStatistics = new TransformerPdStatistics();
                transformerPdStatistics.setPdType(GisCreateUtil.PD_TYPE);
                transformerPdStatistics.setSiteId(siteId);
                transformerPdStatistics.setMainTreeId(mainTreeId);

                // 获取Gis的权重系数维护表
                Map<String, BusiParamGisVo> busiParamGisMap = new HashMap<>();
                String number = null;
                List<BusiParamGisVo> busiParamGisVo = busiParamGisService.findBusiParamGisManual(siteId, mainTreeId);
                if (!busiParamGisVo.isEmpty()) {
                    busiParamGisMap = GisAssessUtilsNew.busiParamGisList2Map(busiParamGisVo);
                    number = busiParamGisVo.get(0).getNumber().toString();
                }

                // 权重
                BigDecimal score_a = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.OPERATE_DATA.getKey());
                BigDecimal score_b = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.INSULATION_MEDIUM.getKey());
                BigDecimal score_c = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.DISCONNECTION_WEAR.getKey());
                BigDecimal score_d = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.OPERATE_PARAMETER.getKey());

                // 根据主设备编号查询打标信息数据表
                List<LabReportMarkStatistic> labReportMarkStatisticList = labReportMarkStatisticService.findMainTreeId(mainTreeId);
                if(CollectionUtil.isNotEmpty(labReportMarkStatisticList)){

                    int step = 0;

                    net.sf.json.JSONArray jsonArray = new net.sf.json.JSONArray();
                    CalculateStep calculateStep = new CalculateStep();
                    calculateStep.setId(Uuid.getUUID());
                    calculateStep.setSiteId(siteId);
                    calculateStep.setEquipmentType(SiteConstants.GIS);
                    calculateStep.setMainEquipmentId(mainTreeId);
                    calculateStep.setExecuteMode(Integer.valueOf(Constants.DEFAULT_NO));
                    calculateStep.setCreateTime(LocalDateTime.now());
                    calculateStep.setNumber(number);

                    // 获取gis标牌信息
                    BusiOfflineGisBrandVo bl = getBusiOfflineGisBrand(mainTreeId);

                    // 额定电流
                    String ratedFrequency = bl.getRatedFrequency();
                    BigDecimal eddl = gisFormulaCalInstance.getEddl(ratedFrequency);
                    log.info("额定电流(A)-标牌: {}", eddl);

                    log.info("---------------------------权重数据-------------------------------------------------------------------");
                    log.info("运行数据权重：{}", score_a);
                    log.info("绝缘介质权重：{}", score_b);
                    log.info("断开磨损权重：{}", score_c);
                    log.info("运行参数权重：{}", score_d);

                    BigDecimal ws_miehushi = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.MICRO_WATER_CONTENT_ARC_EXTINGUISH_CHAMBER.getKey());
                    log.info("灭弧室权重：{}", ws_miehushi);

                    //导电回路电阻权重
                    BigDecimal yxsj_a = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.CONDUCTIVE_LOOP_RESISTANCE.getKey());

                    BusiOutlineGisExperimentDataDto busiOutlineGisExperimentDataDto = new BusiOutlineGisExperimentDataDto();
                    busiOutlineGisExperimentDataDto.setSiteId(siteId);
                    busiOutlineGisExperimentDataDto.setEquipmentId(mainTreeId);

                    BigDecimal gis_yxsj_ddhldz_val = new BigDecimal("0");
                    BigDecimal gis_yxsj_ddhldz = new BigDecimal("1");

                    com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
                    BusiOutlineGisExperimentData busiOutlineGisExperimentdata = getConductiveLoopResistance(mainTreeId);
                    BigDecimal aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.CONDUCTIVE_LOOP_RESISTANCE.getKey());
                    BigDecimal bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.CONDUCTIVE_LOOP_RESISTANCE.getKey());
                    if (busiOutlineGisExperimentdata != null) {
                        gis_yxsj_ddhldz_val = GisAssessUtilsNew.getDdhldz(busiOutlineGisExperimentdata);
                        log.info("导电回路电阻(μΩ)：{}", gis_yxsj_ddhldz_val);
                        gis_yxsj_ddhldz = gisFormulaCalInstance.formulaForUpAndDown(gis_yxsj_ddhldz_val, "down", aVal, bVal);
                    }

                    BigDecimal h1;
                    BigDecimal h2;
                    BigDecimal h3;
                    BigDecimal h4;
                    BigDecimal h5;
                    BigDecimal h6;
                    //运行数据-电气试验
                    BigDecimal ddhldz_result = gis_yxsj_ddhldz.multiply(yxsj_a);
                    jsonObject.clear();
                    jsonObject.put("导电回路电阻(μΩ)", gis_yxsj_ddhldz_val.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("导电回路a值", aVal.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("导电回路b值", bVal.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("导电回路电阻权重", yxsj_a.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    // step 1
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "导电回路电阻计算", jsonObject.toJSONString(), String.valueOf(ddhldz_result.setScale(4, BigDecimal.ROUND_HALF_UP)));
                    BigDecimal yxsj_b = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.TIME_PARAMETER.getKey());
                    BigDecimal yxsj_c = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.SPEED_PARAMETER_OTHER_ASPECTS.getKey());
                    log.info("时间参数权重: {}, 其他方面权重: {}", yxsj_b, yxsj_c);

                    BigDecimal hzbtq_result;
                    BigDecimal fzbtq_result;
                    BigDecimal hz_btq_val;
                    BigDecimal hz_btq;
                    BigDecimal fz_btq_val;
                    BigDecimal fz_btq;
                    BigDecimal sjcs_a;
                    BigDecimal sjcs_b;
                    BigDecimal FinalResult;
                    BigDecimal yxsj_sudutezheng;

                    // 合闸不同期三相
                    GisMechanicalPropertiesVo gisMechanicalPropertiesVo = getDifferentClosePeriods(mainTreeId);
                    hz_btq_val = GisAssessUtilsNew.getHzbtq(gisMechanicalPropertiesVo);
                    aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.DIFFERENT_CLOSE_PERIODS.getKey());
                    bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.DIFFERENT_CLOSE_PERIODS.getKey());
                    hz_btq = gisFormulaCalInstance.formulaForUpAndDown(hz_btq_val, "down", aVal, bVal);

                    sjcs_a = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.DIFFERENT_CLOSE_PERIODS.getKey());
                    log.info("合闸不同期权重值：{}", sjcs_a);
                    hzbtq_result = gisFormulaCalInstance.calcValue(hz_btq,sjcs_a,yxsj_b);

                    jsonObject.clear();
                    jsonObject.put("合闸不同期(ms)", hz_btq_val.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("合闸不同期a值", aVal.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("合闸不同期b值", bVal.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("合闸不同期权重", sjcs_a.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("时间参数权重", yxsj_b.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "合闸不同期计算", jsonObject.toJSONString(), String.valueOf(hzbtq_result.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    //分闸不同期
                    fz_btq_val = GisAssessUtilsNew.getFzbtq(gisMechanicalPropertiesVo);
                    aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.DIFFERENT_OPEN_PERIODS.getKey());
                    bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.DIFFERENT_OPEN_PERIODS.getKey());
                    fz_btq = gisFormulaCalInstance.formulaForUpAndDown(fz_btq_val, "down", aVal, bVal);

                    sjcs_b = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.DIFFERENT_OPEN_PERIODS.getKey());
                    log.info("分闸不同期权重值：{}", sjcs_b);
                    fzbtq_result = gisFormulaCalInstance.calcValue(fz_btq,sjcs_b,yxsj_b);

                    jsonObject.clear();
                    jsonObject.put("分闸不同期(ms)", fz_btq_val.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("分闸不同期a值", aVal.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("分闸不同期b值", bVal.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("分闸不同期权重", sjcs_a.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("时间参数权重", yxsj_b.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "分闸不同期计算", jsonObject.toJSONString(), String.valueOf(fzbtq_result.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    // 速度特性权重
                    yxsj_sudutezheng = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.VELOCITY_CHARACTERISTICS.getKey());

                    // 运行数据-机械实验数据-时间参数
                    FinalResult = hzbtq_result.add(fzbtq_result);
                    jsonObject.clear();
                    jsonObject.put("合闸不同期", hzbtq_result.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("分闸不同期", fzbtq_result.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    // step 2
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "时间参数计算", jsonObject.toString(), String.valueOf(FinalResult.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    //刚分速度
                    BigDecimal gfSpeend_val = GisAssessUtilsNew.getGfSpeend(gisMechanicalPropertiesVo);
                    log.info("刚分速度：{}", gfSpeend_val);

                    aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.RIGID_PARTIAL_VELOCITY.getKey());
                    bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.RIGID_PARTIAL_VELOCITY.getKey());
                    BigDecimal gfSpeend = gisFormulaCalInstance.formulaForUpAndDown(gfSpeend_val, "down", aVal, bVal);
                    log.info("刚分速度升降计算结果：{}", gfSpeend);

                    BigDecimal yxsd_a = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.RIGID_PARTIAL_VELOCITY.getKey());
                    log.info("刚分速度权重值：{}", yxsd_a);

                    BigDecimal gfSpeend_result = gisFormulaCalInstance.calcValue(gfSpeend, yxsd_a, yxsj_sudutezheng);

                    jsonObject.clear();
                    jsonObject.put("刚分速度(ms)", gfSpeend_val.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("刚分速度a值", aVal.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("刚分速度b值", bVal.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("刚分速度权重", yxsd_a.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("速度特性权重", yxsj_sudutezheng.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "刚分速度计算", jsonObject.toJSONString(), String.valueOf(gfSpeend_result.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    //刚合速度
                    BigDecimal ghSpeend_val = GisAssessUtilsNew.getGhSpeend(gisMechanicalPropertiesVo);
                    log.info("刚合速度：{}", ghSpeend_val);

                    aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.STIFFNESS_AND_SPEED.getKey());
                    bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.STIFFNESS_AND_SPEED.getKey());
                    BigDecimal ghSpeend = gisFormulaCalInstance.formulaForUpAndDown(ghSpeend_val, "down", aVal, bVal);
                    log.info("刚合速度：{}", ghSpeend);

                    BigDecimal yxsd_b = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.STIFFNESS_AND_SPEED.getKey());
                    log.info("刚合速度权重值：{}", yxsd_b);
                    BigDecimal ghSpeend_result = gisFormulaCalInstance.calcValue(ghSpeend,yxsd_b,yxsj_sudutezheng);

                    jsonObject.clear();
                    jsonObject.put("刚合速度(ms)", ghSpeend_val.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("刚合速度a值", aVal.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("刚合速度b值", bVal.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("刚合速度权重", yxsd_b.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("速度特性权重", yxsj_sudutezheng.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "刚合速度计算", jsonObject.toJSONString(), String.valueOf(ghSpeend_result.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    // 运行数据-机械实验数据-速度参数
                    BigDecimal FinalResult2 = ghSpeend_result.add(gfSpeend_result);
                    jsonObject.clear();
                    jsonObject.put("刚合速度", ghSpeend_result.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("刚分速度", gfSpeend_result.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    // step 3
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "速度特征计算", jsonObject.toJSONString(), String.valueOf(FinalResult2.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    // 运行数据-机械实验数据
                    h1 = (FinalResult.add(FinalResult2).add(ddhldz_result)).multiply(score_a);
                    jsonObject.clear();
                    jsonObject.put("时间参数", FinalResult.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("速度特征", FinalResult2.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("导电回路电阻", ddhldz_result.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("运行数据权重", score_a.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    // step 4 一级
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "运行数据", jsonObject.toJSONString(), String.valueOf(h1.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    BigDecimal yl;
                    BigDecimal wshl;
                    BigDecimal qtxl_a = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.GAS_LEAKAGE.getKey());
                    BigDecimal qtxl_b = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.Micro_water_content.getKey());

                    // TODO 3 绝缘介质总和
                    log.info("绝缘介质 -->> 3.1 气体压力权重：{}", qtxl_a);
                    log.info("绝缘介质 -->> 3.2 气体压力微水含量权重：{}", qtxl_b);
                    BigDecimal kdms_jfl = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.LOCAL_DISCHARGE.getKey());
                    log.info("绝缘介质 -->>3.3 气体压力局放量权重：{}", kdms_jfl);
                    BigDecimal kdmo_jfcs = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.PARTIAL_DISCHARGE_TIMES.getKey());
                    log.info("绝缘介质 -->>3.4 局放次数权重：{}", kdmo_jfcs);

                    // 气室压力值
                    Map<String, Object> map = getChamberPressureValue(mainTreeId);
                    BigDecimal chamberPressureValue = Convert.createBigD(map.get("compareABC").toString());

                    // 绝缘介质-气体泄漏
                    aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.GAS_LEAKAGE.getKey());
                    bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.GAS_LEAKAGE.getKey());
                    yl = gisFormulaCalInstance.formulaForUpAndDown(chamberPressureValue, "up", aVal, bVal);

                    BigDecimal j1 = yl.multiply(qtxl_a);
                    jsonObject.clear();
                    jsonObject.put("气室压力(Kpa)",chamberPressureValue.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("气体压力权重", qtxl_a.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    // step 5
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "气体压力计算", jsonObject.toJSONString(), String.valueOf(j1.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    // 微水含量
                    Map<String, Object> map1 = getMicroWaterContentValue(mainTreeId);
                    BigDecimal microWaterContentValue = Convert.createBigD(map1.get("compareABC").toString());

                    // 绝缘介质-微水含量
                    BigDecimal jyjz_mhs = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.GAS_LEAKAGE_ARC_EXTINGUISH_CHAMBER.getKey());

                    aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.GAS_LEAKAGE_ARC_EXTINGUISH_CHAMBER.getKey());
                    bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.GAS_LEAKAGE_ARC_EXTINGUISH_CHAMBER.getKey());
                    wshl = gisFormulaCalInstance.formulaForUpAndDown(microWaterContentValue, "down", aVal, bVal);

                    BigDecimal j2 = gisFormulaCalInstance.calcValue(wshl, jyjz_mhs, qtxl_b);
                    jsonObject.clear();
                    jsonObject.put("微水含量(μl/L)",microWaterContentValue.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("微水含量-灭弧室a值", aVal.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("微水含量-灭弧室b值", bVal.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("微水含量-灭弧室权重",jyjz_mhs.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("气室微水含量权重", qtxl_b.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    // step 6
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "气室微水含量计算", jsonObject.toJSONString(), String.valueOf(j2.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    // 绝缘介质-局放次数
                    BigDecimal jfcs_val;
                    BigDecimal jfcs;
                    BigDecimal jf_b = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.PARTIAL_DISCHARGE_TIMES.getKey());
                    BigDecimal jf_c = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.PARTIAL_RELEASE.getKey());

                    //TODO 修改 局放次数 已修改
                    Double partialDischargeTime = this.getRules(mainTreeId, GisAssessEnum.PARTIAL_DISCHARGE_TIME.getKey());
                    String partialDischargeTimes = String.valueOf(partialDischargeTime != null ? partialDischargeTime : "0.00");
                    jfcs_val = GisAssessUtilsNew.getJfcs(partialDischargeTimes);

                    aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.PARTIAL_DISCHARGE_TIMES.getKey());
                    bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.PARTIAL_DISCHARGE_TIMES.getKey());
                    jfcs = gisFormulaCalInstance.formulaForUpAndDown(jfcs_val, "down", aVal, bVal);

                    BigDecimal k1 = gisFormulaCalInstance.calcValue(jfcs, jf_b, jf_c);

                    jsonObject.clear();
                    jsonObject.put("局放次数",jfcs_val.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("局放次数a值", aVal.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("局放次数b值", bVal.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("局放次数权重",jf_b.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "局放次数计算", jsonObject.toJSONString(), String.valueOf(k1.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    // 开断磨损-局放量
                    BigDecimal jfl;
                    BigDecimal jfl_val;
                    BigDecimal jf_a = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.LOCAL_DISCHARGE.getKey());
                    Double partialDischargeValue = this.getRules(mainTreeId, GisAssessEnum.PARTIAL_DISCHARGE_VALUE.getKey());
                    String partialDischargeValues = String.valueOf(partialDischargeValue != null ? partialDischargeValue : "0.00");
                    jfl_val = GisAssessUtilsNew.getJfcs(partialDischargeValues);

                    aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.LOCAL_DISCHARGE.getKey());
                    bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.LOCAL_DISCHARGE.getKey());
                    jfl = gisFormulaCalInstance.formulaForUpAndDown(jfl_val, "down", aVal, bVal);

                    BigDecimal k2 = gisFormulaCalInstance.calcValue(jfl, jf_a, jf_c);

                    jsonObject.clear();
                    jsonObject.put("局放量",jfl_val.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("局放次数a值", aVal.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("局放次数b值", bVal.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("局放次数权重",jf_a.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "局放量计算", jsonObject.toJSONString(), String.valueOf(k2.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    // 绝缘介质-局放
                    BigDecimal k3 = (k1.add(k2));
                    jsonObject.clear();
                    jsonObject.put("局放量", k2.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("局放次数", k1.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    // step 7
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "局放计算", jsonObject.toJSONString(), String.valueOf(k3.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    // 绝缘介质-总数据
                    h2 = (k3.add(j2).add(j1)).multiply(score_b);
                    jsonObject.clear();
                    jsonObject.put("局放", k3.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("微水含量", j2.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("气体泄露（压力）", j1.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("绝缘介质权重", score_b.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    // step 8 一级
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "绝缘介质计算", jsonObject.toJSONString(), String.valueOf(h2.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    //TODO 修改 报告中的评估算法所需参数替换
                    BigDecimal kdms_a = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.CUMULATIVE_BREAKING_ACTION_TIME.getKey());
                    BigDecimal kdms_b = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.SERVICE_LIFE.getKey());
                    BigDecimal kdms_c = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.RELATIVE_ELECTRICAL_WEAR.getKey());

                    // 使用年限得分
                    BigDecimal shiyongnianxian_total;
                    // 累积动作次数得分
                    BigDecimal leijidongzuocishu_total;
                    // 相对电磨损程度得分
                    BigDecimal xiangduidianmosun_total;
                    // 开断磨损总得分
                    BigDecimal synx_val;
                    BigDecimal synx = new BigDecimal(0);

                    if (busiOfflineGisBrandVo != null) {
                        synx_val = GisAssessUtilsNew.getSynx(busiOfflineGisBrandVo);
                        log.info("使用年限时间：{}", synx_val);

                        // synx升降后的计算使用年限
                        aVal = GisAssessUtilsNew.getaVal(busiParamGisMap, "dkms_shiyongnianxian");
                        bVal = GisAssessUtilsNew.getbVal(busiParamGisMap, "dkms_shiyongnianxian");
                        synx = gisFormulaCalInstance.formulaForUpAndDown(synx_val, "down", aVal, bVal);
                    }

                    BigDecimal aVal_synx = aVal;
                    BigDecimal bVal_synx = bVal;
                    // 触头额定断开电流
                    BigDecimal eddkdl = GisAssessUtilsNew.getEddkdl(bl);

                    eddkdl = eddkdl.multiply(new BigDecimal("1000"));
                    log.info("触头额定断开电流(A)-标牌：{}", eddkdl);

                    // 100%负荷的断开次数
                    Double shortCircuitBreakCurrent = this.getRules(mainTreeId, GisAssessEnum.SHORT_CIRCUIT_BREAK_CURRENT.getKey());
                    String shortCircuitBreakCurrents = String.valueOf(shortCircuitBreakCurrent != null ? shortCircuitBreakCurrent : "0.00");
                    BigDecimal dkcsFor100_val = GisAssessUtilsNew.getDkcsesFor100(shortCircuitBreakCurrents, eddkdl);

                    BigDecimal aVal_kdcs = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.CUMULATIVE_BREAKING_ACTION_TIME.getKey());
                    BigDecimal bVal_kdcs = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.CUMULATIVE_BREAKING_ACTION_TIME.getKey());
                    BigDecimal dkcsFor100 = gisFormulaCalInstance.formulaForUpAndDown(dkcsFor100_val, "down", aVal_kdcs, bVal_kdcs);

                    // 触头磨损率
                    BigDecimal xdmscd_val = GisAssessUtilsNew.getMslsForFh(shortCircuitBreakCurrents, eddkdl);

                    BigDecimal aVal_xdmscd = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.RELATIVE_ELECTRICAL_WEAR.getKey());
                    BigDecimal bVal_xdmscd = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.RELATIVE_ELECTRICAL_WEAR.getKey());
                    BigDecimal xdmscd = gisFormulaCalInstance.formulaForUpAndDown(xdmscd_val, "down", aVal_xdmscd, bVal_xdmscd);

                    // 累计断开次数-总得分
                    leijidongzuocishu_total = gisFormulaCalInstance.calcValue(dkcsFor100,kdms_a,score_c);
                    jsonObject.clear();
                    jsonObject.put("短路断开电流(A)", shortCircuitBreakCurrents);
                    jsonObject.put("触头额定断开电流(A)", eddkdl.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("累计开断(动作)次数a值", aVal_kdcs.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("累计开断(动作)次数b值", bVal_kdcs.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("累计开断(动作)次数权重", kdms_a.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("开断磨损权重", score_c.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    // step 9
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "累计断开次数计算", jsonObject.toJSONString(), String.valueOf(leijidongzuocishu_total.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    // 使用年限-总得分
                    shiyongnianxian_total = gisFormulaCalInstance.calcValue(synx,kdms_b,score_c);
                    jsonObject.clear();
                    jsonObject.put("使用年限", synx.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("使用年限a值", aVal_synx.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("使用年限b值", bVal_synx.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("使用年限权重", kdms_b.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("开断磨损权重", score_c.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    // step 10
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "使用年限计算", jsonObject.toJSONString(), String.valueOf(shiyongnianxian_total.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    // 相对磨损程度-总得分
                    xiangduidianmosun_total = gisFormulaCalInstance.calcValue(xdmscd,kdms_c,score_c);
                    jsonObject.clear();
                    jsonObject.put("短路断开电流(A)", shortCircuitBreakCurrents);
                    jsonObject.put("触头额定断开电流(A)", eddkdl.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("相对电磨损程度a值", aVal_xdmscd.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("相对电磨损程度b值", bVal_xdmscd.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("相对电磨损程度权重", kdms_c.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("开断磨损权重", score_c.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    // step 11
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "相对磨损程度计算", jsonObject.toJSONString(), String.valueOf(xiangduidianmosun_total.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    // 开断磨损-总得分
                    h3 = leijidongzuocishu_total.add(shiyongnianxian_total).add(xiangduidianmosun_total);
                    jsonObject.clear();
                    jsonObject.put("累计断开动作次数", leijidongzuocishu_total.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("使用年限", shiyongnianxian_total.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("相对电磨损", xiangduidianmosun_total.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    // step 12 一级
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "开断磨损计算", jsonObject.toJSONString(), String.valueOf(h3.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    // TODO 4.1 运行参数 --- >工作环境
                    BigDecimal syhjwd_val;
                    BigDecimal syhjwd;
                    BigDecimal gzhj_a;
                    BigDecimal syhjsd_val;
                    BigDecimal syhjsd;
                    BigDecimal gzhj_b;
                    BigDecimal syhj;
                    BigDecimal qtys;
                    BigDecimal gzhj_d;
                    BigDecimal gzhj_c;
                    // 工作环境
                    BigDecimal sxcs_a = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.WORK_ENVIRONMENT.getKey());
                    // 外观权重
                    BigDecimal sxcs_b = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.APPEARANCE.getKey());
                    // 厂家权重
                    BigDecimal sxcs_c = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.MANUFACTURER.getKey());
                    // 断路器维护权重
                    BigDecimal wgqk_f = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.CIRCUIT_BREAKER_MAINTENANCE.getKey());

                    //使用环境温度
                    Double operatingAmbientTemperature = this.getRules(mainTreeId, GisAssessEnum.OPERATING_AMBIENT_TEMPERATURE.getKey());
                    String operatingAmbientTemperatures = String.valueOf(operatingAmbientTemperature != null ? operatingAmbientTemperature : "0.00");
                    syhjwd_val = Convert.str2BigDecimal(operatingAmbientTemperatures);
                    log.info("机械特性-使用环境温度：{}", syhjwd_val);

                    BigDecimal aVal_wd = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.OPERATING_AMBIENT_TEMPERATURE.getKey());
                    BigDecimal bVal_wd = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.OPERATING_AMBIENT_TEMPERATURE.getKey());
                    syhjwd = gisFormulaCalInstance.formulaForUpAndDown(syhjwd_val, "down", aVal_wd, bVal_wd);

                    gzhj_a = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.OPERATING_AMBIENT_TEMPERATURE.getKey());

                    //使用环境湿度
                    Double operateAmbientHumidity = this.getRules(mainTreeId, GisAssessEnum.OPERATE_AMBIENT_HUMIDITY.getKey());
                    String operateAmbientHumiditys = String.valueOf(operateAmbientHumidity != null ? operateAmbientHumidity : "0.00");
                    syhjsd_val = Convert.str2BigDecimal(operateAmbientHumiditys);
                    log.info("机械特性-使用环境湿度：{}", syhjsd_val);

                    BigDecimal aVal_sd = GisAssessUtilsNew.getaVal(busiParamGisMap, ParamEnum.OPERATING_AMBIENT_HUMIDITY.getKey());
                    BigDecimal bVal_sd = GisAssessUtilsNew.getbVal(busiParamGisMap, ParamEnum.OPERATING_AMBIENT_HUMIDITY.getKey());
                    syhjsd = gisFormulaCalInstance.formulaForUpAndDown(syhjsd_val, "down", aVal_sd, bVal_sd);

                    gzhj_b = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.OPERATING_AMBIENT_HUMIDITY.getKey());

                    // TODO 修改环境系数 已修改
                    Double environmentCoefficient = this.getRules(mainTreeId, GisAssessEnum.ENVIRONMENT_COEFFICIENT.getKey());
                    String environmentCoefficients = String.valueOf(environmentCoefficient != null ? environmentCoefficient : "0.00");
                    syhj = GisAssessUtilsNew.getCafs(environmentCoefficients);
                    log.info("检修记录-尘埃、腐蚀：{}", syhj);

                    qtys = GisAssessUtilsNew.getQt(busiOfflineGisBrandVo);
                    gzhj_d = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.ALTITUDE.getKey());
                    gzhj_c = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.DUST_CORROSION.getKey());
                    log.info("其他因素权重：{}, 尘埃权重: {}", gzhj_d, gzhj_c);

                    // syhjwd 使用环境温度 gzhj_a 使用环境温度权重 sxcs_a 工作环境权重
                    BigDecimal wd = gisFormulaCalInstance.calcValue(syhjwd, gzhj_a, sxcs_a);

                    jsonObject.clear();
                    jsonObject.put("使用环境温度(℃)", syhjwd_val);
                    jsonObject.put("使用环境温度a值", aVal_wd.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("使用环境温度b值", bVal_wd.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("使用环境温度权重", gzhj_a.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("工作环境权重", sxcs_a.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "使用环境温度计算", jsonObject.toJSONString(), String.valueOf(wd.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    log.info("---------------------------------使用环境温度begin----------------------------------");
                    log.info("  使用环境温度计算公式：(温度参数）*b2*d4");
                    log.info("  温度参数(使用环境温度升降序计算结果)：{},使用环境温度权重b2：{}, 工作环境权重 d4：{}", syhjwd, gzhj_a, sxcs_a);
                    log.info("  使用环境温度计算结果  = {}", wd);
                    log.info("---------------------------------使用环境温度end----------------------------------");

                    // syhjwd 使用环境湿度 gzhj_b 使用环境湿度权重 sxcs_a 工作环境权重 sxcs_a
                    BigDecimal sd = gisFormulaCalInstance.calcValue(syhjsd, gzhj_b, sxcs_a);

                    jsonObject.clear();
                    jsonObject.put("使用环境湿度", syhjsd_val);
                    jsonObject.put("使用环境湿度a值", aVal_sd.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("使用环境湿度b值", bVal_sd.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("使用环境湿度权重", gzhj_b.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("工作环境权重", sxcs_a.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "使用环境湿度计算", jsonObject.toJSONString(), String.valueOf(sd.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    log.info("---------------------------------使用环境湿度begin----------------------------------");
                    log.info("  使用环境湿度计算公式：（湿度参数）*b1*d4");
                    log.info("  湿度参数(使用环境湿度升降序计算结果)：{},使用环境湿度权重b1：{}, 工作环境权重 d4：{}", syhjsd, gzhj_b, sxcs_a);
                    log.info("  使用环境湿度计算结果  = {}", sd);
                    log.info("---------------------------------使用环境湿度end----------------------------------");

                    // 检修记录-尘埃、腐蚀
                    BigDecimal hj = gisFormulaCalInstance.calcValue(syhj, gzhj_c, sxcs_a);

                    jsonObject.clear();
                    jsonObject.put("环境系数", environmentCoefficients);
                    jsonObject.put("尘埃腐蚀权重", gzhj_c.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("工作环境权重", sxcs_a.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "尘埃腐蚀计算", jsonObject.toJSONString(), String.valueOf(hj.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    log.info("---------------------------------空气质量begin----------------------------------");
                    log.info("  空气质量计算公式：(尘埃、腐蚀）*b3*d4");
                    log.info("  空气质量：{}, 尘埃、腐蚀权重b3：{}, 工作环境权重 d4：{}", syhj, gzhj_c, sxcs_a);
                    log.info("  空气质量算结果  = {}", hj);
                    log.info("---------------------------------空气质量end----------------------------------");

                    // 其他因素
                    BigDecimal ys = gisFormulaCalInstance.calcValue(qtys, gzhj_d, sxcs_a);

                    jsonObject.clear();
                    jsonObject.put("海拔(m)", qtys);
                    jsonObject.put("其他权重", gzhj_d.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("工作环境权重", sxcs_a.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "其他计算", jsonObject.toJSONString(), String.valueOf(ys.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    log.info("---------------------------------海拔begin----------------------------------");
                    log.info("  海拔计算公式：(海拔）*b4*d4}");
                    log.info("  海拔：{},海拔权重权重b3：{}, 工作环境权重 d4：{}", qtys, gzhj_d, sxcs_a);
                    log.info("  海拔计算结果  = {}", ys);
                    log.info("---------------------------------海拔end----------------------------------");

                    // 运行参数-其他因素-工作环境总结果
                    h4 = wd.add(sd).add(hj).add(ys);
                    jsonObject.clear();
                    jsonObject.put("使用环境温度", wd.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("使用环境湿度", sd.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("尘埃、腐蚀", hj.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("其他", ys.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    // step 13
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "工作环境计算", jsonObject.toJSONString(), String.valueOf(h4.setScale(4, BigDecimal.ROUND_HALF_UP)));
                    log.info("---------------------------------h4  begin----------------------------------");
                    log.info("  h4计算公式：h4=w*{（湿度参数）*b1*d4+(温度参数）*b2*d4+(空气质量）*b3*d4+(海拔）*b4*d4}");
                    log.info("  w=运行参数-工作环境权重");
                    log.info("  湿度：{}, 温度：{}, 空气质量：{}, 海拔：{}", ys, sd, wd, hj);
                    log.info("  h4  = {}", h4);
                    log.info("---------------------------------h4  end----------------------------------");

                    BusiOfflineGisRepairDto busiOfflineGisRepairDto = new BusiOfflineGisRepairDto();
                    busiOfflineGisRepairDto.setMainEquipmentId(mainTreeId);
                    busiOfflineGisRepairDto.setSiteId(siteId);
                    // 运行参数 -->> 4.2 外观情况
                    BigDecimal czjgLubrication;
                    BigDecimal wgqk_a;
                    BigDecimal ztjgAppearance;
                    BigDecimal wgqk_b;
                    BigDecimal supportInsulation;
                    BigDecimal wgqk_c;
                    BigDecimal mainLoopTerminal;
                    BigDecimal wgqk_d;
                    BigDecimal wgqk_e;

                    // TODO 修改操作机构润滑 已修改
                    Double operateMechanismLubrication = this.getRules(mainTreeId, GisAssessEnum.OPERATE_MECHANISM_LUBRICATION.getKey());
                    String operateMechanismLubrications = String.valueOf(operateMechanismLubrication != null ? operateMechanismLubrication : "0.00");
                    czjgLubrication = GisAssessUtilsNew.getCzjgrh(operateMechanismLubrications);
                    wgqk_a = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.OPERATE_MECHANISM_LUBRICATION.getKey());

                    // TODO 修改主体、机构外观 已修改
                    Double mainBodyAppearance = this.getRules(mainTreeId, GisAssessEnum.MAIN_BODY_APPEARANCE.getKey());
                    String mainBodyAppearances = String.valueOf(mainBodyAppearance != null ? mainBodyAppearance : "0.00");
                    ztjgAppearance = GisAssessUtilsNew.getZtjgwg(mainBodyAppearances);
                    wgqk_b = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.MAIN_APPEARANCE_MECHANISM.getKey());

                    // TODO 修改支持绝缘部分 已修改
                    Double supportInsulationPart = this.getRules(mainTreeId, GisAssessEnum.SUPPORT_INSULATION_PART.getKey());
                    String supportInsulationParts = String.valueOf(supportInsulationPart != null ? supportInsulationPart : "0.00");
                    supportInsulation = GisAssessUtilsNew.getZcjybf(supportInsulationParts);
                    wgqk_c = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.SUPPORT_INSULATION_PART.getKey());

                    // TODO 修改主回路端子 已修改
                    Double mainCircuitTerminal = this.getRules(mainTreeId, GisAssessEnum.MAIN_CIRCUIT_TERMINAL.getKey());
                    String mainCircuitTerminals = String.valueOf(mainCircuitTerminal != null ? mainCircuitTerminal : "0.00");
                    mainLoopTerminal = GisAssessUtilsNew.getZhldz(mainCircuitTerminals);
                    wgqk_d = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.MAIN_CIRCUIT_TERMINAL.getKey());

                    // TODO 修改同类断路器维护次数 已修改
                    Double circuitBreakerMaintenanceTime = this.getRules(mainTreeId, GisAssessEnum.CIRCUIT_BREAKER_MAINTENANCE_TIME.getKey());
                    String circuitBreakerMaintenanceTimes = String.valueOf(circuitBreakerMaintenanceTime != null ? circuitBreakerMaintenanceTime : "0.00");
                    BigDecimal tldlqMaintain = GisAssessUtilsNew.getTldlqwhcs(circuitBreakerMaintenanceTimes);
                    wgqk_e = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.SIMILAR_CIRCUIT_BREAKERS_MAINTENANCE_TIMES.getKey());
                    log.info("检修记录-操作机构润滑: {}", wgqk_a);
                    log.info("检修记录-主体、机构外观: {}", wgqk_b);
                    log.info("检修记录-支持绝缘部分: {}", wgqk_c);
                    log.info("检修记录-主回路端子: {}", wgqk_d);
                    log.info("检修记录-断路器维护次数(检修记录): {}", wgqk_e);
                    log.info("检修记录-运行参数-外观情况: {}", wgqk_e);

                    BigDecimal rh = gisFormulaCalInstance.calcValue(czjgLubrication,wgqk_a,sxcs_b);

                    jsonObject.clear();
                    jsonObject.put("操作机构润滑", czjgLubrication);
                    jsonObject.put("操作机构润滑权重", wgqk_a.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("外观情况权重", sxcs_b.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "操作机构润滑计算", jsonObject.toJSONString(), String.valueOf(rh.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    BigDecimal wg = gisFormulaCalInstance.calcValue(ztjgAppearance,wgqk_b,sxcs_b);

                    jsonObject.clear();
                    jsonObject.put("主体、机构外观", ztjgAppearance);
                    jsonObject.put("主体、机构外观权重", wgqk_b.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("外观情况权重", sxcs_b.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "主体、机构外观计算", jsonObject.toJSONString(), String.valueOf(wg.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    BigDecimal dz = gisFormulaCalInstance.calcValue(mainLoopTerminal,wgqk_d,sxcs_b);

                    jsonObject.clear();
                    jsonObject.put("主回路端子", mainLoopTerminal);
                    jsonObject.put("主回路端子权重", wgqk_d.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("外观情况权重", sxcs_b.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "主回路端子计算", jsonObject.toJSONString(), String.valueOf(dz.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    BigDecimal zc = gisFormulaCalInstance.calcValue(supportInsulation,wgqk_c,sxcs_b);

                    jsonObject.clear();
                    jsonObject.put("支持绝缘部分", supportInsulation);
                    jsonObject.put("支持绝缘部分权重", wgqk_c.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("外观情况权重", sxcs_b.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "支持绝缘部分计算", jsonObject.toJSONString(), String.valueOf(zc.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    // 运行参数-其他因素-外观情况总结果
                    h5 = rh.add(wg).add(dz).add(zc);
                    jsonObject.clear();
                    jsonObject.put("操作机构润滑", rh.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("主体、机构外观", wg.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("支持绝缘部分", zc.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("主回路端子", dz.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    // step 14
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "外观情况计算", jsonObject.toJSONString(), String.valueOf(h5.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    log.info("---------------------------------操作机构润滑 begin----------------------------------");
                    log.info("  操作机构润滑计算公式：(操作机构润滑）*c1");
                    log.info("  c1=操作机构权重");
                    log.info("  操作机构润滑：{}, 操作机构权重c1：{}", czjgLubrication, wgqk_a);
                    log.info("  操作机构润滑海拔计算结果 = {}", rh);
                    log.info("---------------------------------操作机构润滑  end----------------------------------");

                    log.info("---------------------------------本体外观 begin----------------------------------");
                    log.info("  本体外观计算公式：(本体外观）*c2");
                    log.info("  c2=机构外观权重");
                    log.info("  本体外观：{}, 操作机构权重c2：{}", czjgLubrication, wgqk_b);
                    log.info("  本体外观计算结果  = {}", wg);
                    log.info("---------------------------------本体外观  end----------------------------------");

                    log.info("---------------------------------主回路端子 begin----------------------------------");
                    log.info("  主回路端子计算公式：(主回路端子）*c3");
                    log.info("  c3=主回路端子权重");
                    log.info("  主回路端子：{},主回路端子权重c3：{}", mainLoopTerminal, wgqk_d);
                    log.info("  主回路端子计算结果  = {}", wg);
                    log.info("---------------------------------主回路端子 end----------------------------------");

                    log.info("---------------------------------绝缘支撑 begin----------------------------------");
                    log.info("  绝缘支撑计算公式：(绝缘支撑）*c4");
                    log.info("  c4=绝缘支撑权重");
                    log.info("  绝缘支撑：{},绝缘支撑权重c4：{}", supportInsulation, wgqk_c);
                    log.info("  绝缘支撑计算结果  = {}", wg);
                    log.info("---------------------------------绝缘支撑 end----------------------------------");

                    BigDecimal productMaturity = new BigDecimal("0");
                    BigDecimal popularity = new BigDecimal("0");
                    if (busiOfflineGisBrandVo != null) {

                        productMaturity = GisAssessUtilsNew.getCpcsd(busiOfflineGisBrandVo);

                        popularity = GisAssessUtilsNew.getZmd(busiOfflineGisBrandVo);
                        log.info("产品成熟度-标牌: {}, 知名度（手动录入）-标牌: {}", productMaturity, popularity);
                    }

                    BigDecimal cjyc;
                    Double maintenanceTime = this.getRules(mainTreeId, GisAssessEnum.MAINTENANCE_TIME.getKey());
                    int maintenanceTimes = (int) Math.round(maintenanceTime);
                    cjyc = GisAssessUtilsNew.getCjyc(maintenanceTimes);
                    log.info("检修记录-厂家设备遗传: {}", cjyc);

                    BigDecimal sccj_a = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.MANUFACTURER_EQUIPMENT_GENETICS.getKey());
                    log.info("厂家设备遗传权重: {}", sccj_a);

                    BigDecimal dlqMaintenance = GisAssessUtilsNew.getDlqwh(maintenanceTimes);
                    log.info("断路器维护-断路器维护: {}", dlqMaintenance);

                    // 产品成熟度
                    BigDecimal sccj_b = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.PRODUCT_MATURITY.getKey());
                    // 知名度（手动录入）标牌
                    BigDecimal sccj_c = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.POPULARITY.getKey());

                    log.info("产品成熟度权重: {}", sccj_b);
                    log.info("知名度（手动录入）标牌: {}", sccj_c);
                    log.info("厂家设备遗传权重：{}", sccj_a);

                    BigDecimal yc = gisFormulaCalInstance.calcValue(cjyc,sccj_a,sxcs_c);

                    jsonObject.clear();
                    jsonObject.put("厂家设备遗传", cjyc);
                    jsonObject.put("厂家设备遗传权重", sccj_a.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("生产厂家权重", sxcs_c.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "厂家设备遗传计算", jsonObject.toJSONString(), String.valueOf(yc.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    BigDecimal csd = gisFormulaCalInstance.calcValue(productMaturity,sccj_b,sxcs_c);

                    jsonObject.clear();
                    jsonObject.put("产品成熟度", productMaturity);
                    jsonObject.put("产品成熟度权重", sccj_b.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("生产厂家权重", sxcs_c.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "产品成熟度计算", jsonObject.toJSONString(), String.valueOf(csd.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    BigDecimal zmd = gisFormulaCalInstance.calcValue(popularity,sccj_c,sxcs_c);

                    jsonObject.clear();
                    jsonObject.put("知名度", popularity);
                    jsonObject.put("知名度权重", sccj_c.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("生产厂家权重", sxcs_c.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "知名度计算", jsonObject.toJSONString(), String.valueOf(zmd.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    // 运行参数-其他因素-生产厂家总结果
                    h6 = yc.add(csd).add(zmd);
                    jsonObject.clear();
                    jsonObject.put("厂家设备遗传", yc.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("产品成熟度", csd.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("知名度", zmd.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    // step 15
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "生产厂家计算", jsonObject.toJSONString(), String.valueOf(h6.setScale(4, BigDecimal.ROUND_HALF_UP)));

                    log.info("---------------------------------遗传 begin----------------------------------");
                    log.info("  遗传计算公式：(遗传）*z1");
                    log.info("  z1=遗传权重");
                    log.info("  遗传：{}, 遗传权重z1：{}", cjyc, sccj_a);
                    log.info("  遗传计算结果  = " + yc);
                    log.info("---------------------------------遗传 end----------------------------------");

                    log.info("---------------------------------产品知名度 begin----------------------------------");
                    log.info("  产品知名度计算公式：(产品知名度）*z2");
                    log.info("  z2=产品知名度权重");
                    log.info("  产品知名度：{},产品知名度权重z2：{}", popularity, sccj_c);
                    log.info("  产品知名度计算结果  = {}", zmd);
                    log.info("---------------------------------产品知名度 end----------------------------------");

                    log.info("---------------------------------产品成熟度 begin----------------------------------");
                    log.info("  产品成熟度计算公式：(产品成熟度）*z3");
                    log.info("  z3=产品成熟度权重");
                    log.info("  产品成熟度：{},产品成熟度权重z2：{}", productMaturity, sccj_b);
                    log.info("  产品成熟度计算结果  = {}", csd);
                    log.info("---------------------------------产品成熟度 end----------------------------------");

                    BigDecimal yxcs_qt = GisAssessUtilsNew.getVal(busiParamGisMap, ParamEnum.OPERATE_PARAMETER.getKey());
                    // 工作环境得分
                    BigDecimal yxcs_gongzuohuanjing_total = GisAssessUtilsNew.calcMultiply(yxcs_qt,h4);

                    // 外观得分
                    BigDecimal yxcs_waiguang_total = GisAssessUtilsNew.calcMultiply(yxcs_qt,h5);

                    // 厂家得分
                    BigDecimal yxcs_changjia_total = GisAssessUtilsNew.calcMultiply(yxcs_qt,h6);

                    // 断路器维护得分
                    BigDecimal yxcs_dlqwh = dlqMaintenance.multiply(wgqk_f);
                    jsonObject.clear();
                    jsonObject.put("检修次数", (maintenanceTimes + ""));
                    jsonObject.put("同类断路器维护", dlqMaintenance.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("断路器维护权重", wgqk_f.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    BigDecimal yxcs_dlqwh_total = gisFormulaCalInstance.calcValue(dlqMaintenance,wgqk_f,yxcs_qt);
                    // step 16
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "断路器维护得分计算", jsonObject.toJSONString(), String.valueOf(yxcs_dlqwh.setScale(4, BigDecimal.ROUND_HALF_UP)));
                    log.info("工作环境得分：{}", yxcs_gongzuohuanjing_total);
                    log.info("外观得分：{}", yxcs_waiguang_total);
                    log.info("厂家得分：{}", yxcs_changjia_total);
                    log.info("断路器维护得分：{}", yxcs_dlqwh_total);

                    // 4.运行参数

                    // 运行参数总得分
                    BigDecimal gis_yxcs_total = yxcs_waiguang_total.add(yxcs_changjia_total).add(yxcs_gongzuohuanjing_total).add(yxcs_dlqwh_total);
                    jsonObject.clear();
                    jsonObject.put("外观情况", h5.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("生产厂家", h6.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("工作环境", h4.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("断路器维护", yxcs_dlqwh.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    jsonObject.put("运行参数权重", yxcs_qt.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                    // step 17 一级
                    step += 1;
                    GisAssessUtilsNew.setStep(jsonArray, step, "运行参数总得分计算", jsonObject.toJSONString(), String.valueOf(gis_yxcs_total.setScale(4, BigDecimal.ROUND_HALF_UP)));
                    log.info("运行参数：{}, 运行参数总得分: {}", yxcs_qt, gis_yxcs_total);

                    String score = "100";
                    if (busiParamGisVo.size() > 11) {
                        score = Math.round(Double.parseDouble(h1.add(h2).add(h3).add(yxcs_gongzuohuanjing_total).add(yxcs_waiguang_total).add(yxcs_changjia_total).add(yxcs_dlqwh_total)
                                .multiply(BigDecimal.valueOf(100)).setScale(4, BigDecimal.ROUND_HALF_UP) + "")) + "";
                        jsonObject.clear();
                        jsonObject.put("机械实验数据", h1.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                        jsonObject.put("绝缘介质", h2.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                        jsonObject.put("开断磨损", h3.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                        jsonObject.put("工作环境", yxcs_gongzuohuanjing_total.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                        jsonObject.put("外观情况", yxcs_waiguang_total.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                        jsonObject.put("生产厂家", yxcs_changjia_total.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                        jsonObject.put("断路器维护", yxcs_dlqwh_total.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                        // step 18 结果
                        step += 1;
                        GisAssessUtilsNew.setStep(jsonArray, step, "最终结果计算", jsonObject.toJSONString(), score);
                        log.info("score::" + score);
                    }

                    // 健康水平
                    String gisStatus = gisFormulaCalInstance.getGisStatus(Convert.str2BigDecimal(score));
                    // 检修建议
                    String jxjy = gisFormulaCalInstance.getJxjy(Convert.str2BigDecimal(score));
                    // 健康水平说明
                    String healthLevelExplain = gisFormulaCalInstance.getJkspsm(Convert.str2BigDecimal(score));

                    log.info("速度特性得分：" + FinalResult2);
                    log.info("健康水平：" + gisStatus);
                    log.info("检修建议：" + jxjy);
                    log.info("健康水平说明：" + healthLevelExplain);

                    // 开断磨损
                    List<GisEvaVo> list11 = new ArrayList<>();
                    // 运行数据
                    List<GisEvaVo> list21 = new ArrayList<>();
                    // 绝缘介质
                    List<GisEvaVo> list31 = new ArrayList<>();
                    // 运行参数
                    List<GisEvaVo> list41 = new ArrayList<>();

                    GisEvaVo vo21 = new GisEvaVo(GisCreateUtil.TIME_PARAMETER, FinalResult+ "", "时间参数");
                    GisEvaVo vo22 = new GisEvaVo(GisCreateUtil.VELOCITY_CHARACTERISTICS, FinalResult2+ "", "速度特性");
                    GisEvaVo vo23 = new GisEvaVo(GisCreateUtil.CONDUCTING_CIRCUIT_RESISTANCE, ddhldz_result + "", "导电回路电阻");
                    list21.add(vo21);
                    list21.add(vo22);
                    list21.add(vo23);

                    GisEvaVo vo31 = new GisEvaVo(GisCreateUtil.GAS_PRESSURE, j1+ "", "气体压力");
                    GisEvaVo vo32 = new GisEvaVo(GisCreateUtil.MICRO_WATER_CONTENT, j2+ "", "微水含量");
                    GisEvaVo vo33 = new GisEvaVo(GisCreateUtil.PARTIAL_DISCHARGE, k2 + "", "局放量");
                    GisEvaVo vo34 = new GisEvaVo(GisCreateUtil.PARTIAL_DISCHARGE_COUNT, k1 + "", "局放次数");
                    list31.add(vo31);
                    list31.add(vo32);
                    list31.add(vo33);
                    list31.add(vo34);

                    GisEvaVo vo41 = new GisEvaVo(GisCreateUtil.WORK_ENVIRONMENT, yxcs_gongzuohuanjing_total + "", "工作环境");
                    GisEvaVo vo42 = new GisEvaVo(GisCreateUtil.APPEARANCE, yxcs_waiguang_total+ "", "外观情况");
                    GisEvaVo vo43 = new GisEvaVo(GisCreateUtil.MAINTENANCE_RECORD, yxcs_dlqwh_total+ "", "维修记录");
                    GisEvaVo vo44 = new GisEvaVo(GisCreateUtil.Manufacturer, yxcs_changjia_total+ "", "生产厂家");
                    list41.add(vo41);
                    list41.add(vo42);
                    list41.add(vo43);
                    list41.add(vo44);

                    BigDecimal sydkcs;
                    // 14-累计断开次数
                    sydkcs = new BigDecimal("14").subtract(leijidongzuocishu_total);
                    log.info("预期剩余断开次数：" + sydkcs);

                    String uuid = Uuid.getUUID();
                    gisAssessmentResult.setId(uuid);
                    gisAssessmentResult.setSiteId(siteId);
                    gisAssessmentResult.setMainTreeId(mainTreeId);
                    gisAssessmentResult.setAssessTime(LocalDateTime.now());
                    gisAssessmentResult.setHealthScore(
                            GisAssessUtilsNew.formatNumStr(score).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
                    // 触头磨损率
                    gisAssessmentResult.setHealthLevel(gisStatus);
                    gisAssessmentResult.setHealthLevelExplain(healthLevelExplain);
                    gisAssessmentResult.setContactWearRate(xdmscd_val.multiply(BigDecimal.valueOf(100)).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
                    // 取值待定标牌中数据
                    gisAssessmentResult.setExpectedUsageCount(bl.getServiceTime());
                    gisAssessmentResult.setRemainingUsageCount(sydkcs.toString());
                    gisAssessmentResult.setOverhaulSuggest(jxjy);
                    gisAssessmentResult.setType("1");
                    // 断开时负荷
//                    gisAssessmentResult.setLoadFactor(yxfh.toString());
                    gisAssessmentResultService.saveGisAssessmentResult(gisAssessmentResult);

                    GisAssessmentResultData result = new GisAssessmentResultData();
                    result.setId(Uuid.getUUID());
                    result.setEvaluationId(uuid);
                    result.setGisId(gisId);
                    result.setGisName(gisName);
                    result.setAssessTime(LocalDate.now());
                    result.setHealthScore(GisAssessUtilsNew.formatNumStr(score).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
                    // 触头磨损率
                    result.setHealthLevel(gisStatus);
                    result.setContactWearRate(xdmscd_val.toString());
//                    result.setExpectedUsageCount(kdkcs.toString());
                    result.setRemainingUsageCount(sydkcs.toString());
                    result.setOverhaulSuggest(jxjy);
                    result.setDkcses(dkcsFor100_val + "");

                    // 开断磨损
                    result.setBreakingWear(h3 + "");
                    result.setOperationalData(h1+ "");
                    result.setOperationParameters(gis_yxcs_total.toString());
                    result.setInsulatingMedium(h2 + "");

                    GisEvaVo vo11 = new GisEvaVo(GisCreateUtil.SERVICE_LIFE, shiyongnianxian_total + "", "使用年限");
                    GisEvaVo vo12 = new GisEvaVo(GisCreateUtil.RELATIVE_WEAR_DEGREE, xiangduidianmosun_total + "", "相对磨损程度");
                    GisEvaVo vo13 = new GisEvaVo(GisCreateUtil.CUMULATIVE_ACTION_TIMES, leijidongzuocishu_total + "", "累计动作次数");
                    list11.add(vo11);
                    list11.add(vo12);
                    list11.add(vo13);

                    String json1 = JSONArray.toJSONString(list11);
                    String json2 = JSONArray.toJSONString(list21);
                    String json3 = JSONArray.toJSONString(list31);
                    String json4 = JSONArray.toJSONString(list41);
                    result.setBreakingWearDetails(json1);
                    result.setOperationalDataDetails(json2);
                    result.setInsulatingMediumDetails(json3);
                    result.setOperationParametersDetails(json4);
                    gisAssessmentResultDataService.save(result);

                    // 临时注释，调测后放开
                    GisCreateUtil.createFile(result, true, basePath2, GisCreateUtil.FILE_PATH, fileName, date);

                    // 新增算法步骤
                    calculateStep.setStepJson(jsonArray.toString());
                    calculateStep.setPId(uuid);
                    calculateStepService.insert(calculateStep);
                }
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (ScriptException e) {
            e.printStackTrace();
        } finally {
            try {
                ComputeUtil.close(fileReader);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return gisAssessmentResult;
    }


    /**
     * 获取合闸不同期A、B、C三相
     * @param mainTreeId
     * @return
     */
    private GisMechanicalPropertiesVo getDifferentClosePeriods(String mainTreeId){
        GisMechanicalPropertiesVo gisMechanicalPropertiesVo = new GisMechanicalPropertiesVo();

        Double differentClosePeriodsA = this.getRules(mainTreeId, GisAssessEnum.DIFFERENT_CLOSE_PERIODS_A.getKey());
        gisMechanicalPropertiesVo.setAHzBtq(String.valueOf(differentClosePeriodsA != null ? differentClosePeriodsA : "0.00"));

        Double differentClosePeriodsB = this.getRules(mainTreeId, GisAssessEnum.DIFFERENT_CLOSE_PERIODS_B.getKey());
        gisMechanicalPropertiesVo.setBHzBtq(String.valueOf(differentClosePeriodsB != null ? differentClosePeriodsB : "0.00"));

        Double differentClosePeriodsC = this.getRules(mainTreeId, GisAssessEnum.DIFFERENT_CLOSE_PERIODS_C.getKey());
        gisMechanicalPropertiesVo.setCHzBtq(String.valueOf(differentClosePeriodsC != null ? differentClosePeriodsC : "0.00"));

        Double differentOpenPeriodsA = this.getRules(mainTreeId, GisAssessEnum.DIFFERENT_OPEN_PERIODS_A.getKey());
        gisMechanicalPropertiesVo.setAFzBtq(String.valueOf(differentOpenPeriodsA != null ? differentOpenPeriodsA : "0.00"));

        Double differentOpenPeriodsB = this.getRules(mainTreeId, GisAssessEnum.DIFFERENT_OPEN_PERIODS_B.getKey());
        gisMechanicalPropertiesVo.setBFzBtq(String.valueOf(differentOpenPeriodsB != null ? differentOpenPeriodsB : "0.00"));

        Double differentOpenPeriodsC = this.getRules(mainTreeId, GisAssessEnum.DIFFERENT_OPEN_PERIODS_C.getKey());
        gisMechanicalPropertiesVo.setCFzBtq(String.valueOf(differentOpenPeriodsC != null ? differentOpenPeriodsC : "0.00"));

        Double rigidPartialVelocityA = this.getRules(mainTreeId, GisAssessEnum.RIGID_PARTIAL_VELOCITY_A.getKey());
        gisMechanicalPropertiesVo.setAGfSpeend(String.valueOf(rigidPartialVelocityA != null ? rigidPartialVelocityA : "0.00"));

        Double rigidPartialVelocityB = this.getRules(mainTreeId, GisAssessEnum.RIGID_PARTIAL_VELOCITY_B.getKey());
        gisMechanicalPropertiesVo.setBGfSpeend(String.valueOf(rigidPartialVelocityB != null ? rigidPartialVelocityB : "0.00"));

        Double rigidPartialVelocityC = this.getRules(mainTreeId, GisAssessEnum.RIGID_PARTIAL_VELOCITY_C.getKey());
        gisMechanicalPropertiesVo.setCGfSpeend(String.valueOf(rigidPartialVelocityC != null ? rigidPartialVelocityC : "0.00"));

        Double rigidCloseSpeedA = this.getRules(mainTreeId, GisAssessEnum.RIGID_CLOSE_SPEED_A.getKey());
        gisMechanicalPropertiesVo.setAGhSpeed(String.valueOf(rigidCloseSpeedA != null ? rigidCloseSpeedA : "0.00"));

        Double rigidCloseSpeedB = this.getRules(mainTreeId, GisAssessEnum.RIGID_CLOSE_SPEED_B.getKey());
        gisMechanicalPropertiesVo.setBGhSpeed(String.valueOf(rigidCloseSpeedB != null ? rigidCloseSpeedB : "0.00"));

        Double rigidCloseSpeedC = this.getRules(mainTreeId, GisAssessEnum.RIGID_CLOSE_SPEED_C.getKey());
        gisMechanicalPropertiesVo.setCGhSpeed(String.valueOf(rigidCloseSpeedC != null ? rigidCloseSpeedC : "0.00"));
        return gisMechanicalPropertiesVo;
    }

    /**
     * 获取导电回路三相
     * @param mainTreeId
     * @return
     */
    private BusiOutlineGisExperimentData getConductiveLoopResistance(String mainTreeId){
        BusiOutlineGisExperimentData busiOutlineGisExperimentData = new BusiOutlineGisExperimentData();

        Double conductiveLoopResistanceA = this.getRules(mainTreeId, GisAssessEnum.CONDUCTIVE_LOOP_RESISTANCE_A.getKey());
        busiOutlineGisExperimentData.setADdhlResistance(String.valueOf(conductiveLoopResistanceA != null ? conductiveLoopResistanceA : "0.00"));

        Double conductiveLoopResistanceB = this.getRules(mainTreeId, GisAssessEnum.CONDUCTIVE_LOOP_RESISTANCE_B.getKey());
        busiOutlineGisExperimentData.setBDdhlResistance(String.valueOf(conductiveLoopResistanceB != null ? conductiveLoopResistanceB : "0.00"));

        Double conductiveLoopResistanceC = this.getRules(mainTreeId, GisAssessEnum.CONDUCTIVE_LOOP_RESISTANCE_C.getKey());
        busiOutlineGisExperimentData.setCDdhlResistance(String.valueOf(conductiveLoopResistanceC != null ? conductiveLoopResistanceC : "0.00"));
        return busiOutlineGisExperimentData;
    }

    /**
     * 获取气室压力值
     * @param mainTreeId
     * @return
     */
    private Map<String, Object> getChamberPressureValue(String mainTreeId){
        BigDecimal aVal = Convert.createBigD("0");
        Double chamberPressureValueA = this.getRules(mainTreeId, GisAssessEnum.CHAMBER_PRESSURE_VALUE_A.getKey());
        if(chamberPressureValueA != null){
            aVal = Convert.str2BigDecimal(String.valueOf(chamberPressureValueA));
        }

        BigDecimal bVal = Convert.createBigD("0");
        Double chamberPressureValueB = this.getRules(mainTreeId, GisAssessEnum.CHAMBER_PRESSURE_VALUE_B.getKey());
        if(chamberPressureValueB != null){
            bVal = Convert.str2BigDecimal(String.valueOf(chamberPressureValueB));
        }

        BigDecimal cVal = Convert.createBigD("0");
        Double chamberPressureValueC = this.getRules(mainTreeId, GisAssessEnum.CHAMBER_PRESSURE_VALUE_C.getKey());
        if(chamberPressureValueC != null){
            cVal = Convert.str2BigDecimal(String.valueOf(chamberPressureValueC));
        }

        Map<String, Object> map = Maps.newHashMap();
        map.put("aVal", aVal);
        map.put("bVal", bVal);
        map.put("cVal", cVal);
        map.put("compareABC", gisFormulaCalInstance.compareABC(aVal, bVal, cVal));
        return map;
    }

    /**
     * 获取微水含量值
     * @param mainTreeId
     * @return
     */
    private Map<String, Object> getMicroWaterContentValue(String mainTreeId){
        BigDecimal aVal = Convert.createBigD("0");
        Double microWaterContentValueA = this.getRules(mainTreeId, GisAssessEnum.MICRO_WATER_CONTENT_VALUE_A.getKey());
        if(microWaterContentValueA != null){
            aVal = Convert.str2BigDecimal(String.valueOf(microWaterContentValueA));
        }

        BigDecimal bVal = Convert.createBigD("0");
        Double microWaterContentValueB = this.getRules(mainTreeId, GisAssessEnum.MICRO_WATER_CONTENT_VALUE_B.getKey());
        if(microWaterContentValueB != null){
            bVal = Convert.str2BigDecimal(String.valueOf(microWaterContentValueB));
        }

        BigDecimal cVal = Convert.createBigD("0");
        Double microWaterContentValueC = this.getRules(mainTreeId, GisAssessEnum.MICRO_WATER_CONTENT_VALUE_C.getKey());
        if(microWaterContentValueC != null){
            cVal = Convert.str2BigDecimal(String.valueOf(microWaterContentValueC));
        }

        Map<String, Object> map = Maps.newHashMap();
        map.put("aVal", aVal);
        map.put("bVal", bVal);
        map.put("cVal", cVal);
        map.put("compareABC", gisFormulaCalInstance.compareABC(aVal, bVal, cVal));
        return map;
    }

    /**
     * 根据打标规则获取相关数据
     * @param key
     * @param mainTreeId
     */
    private Double getRules(String mainTreeId,String key){
        labRulesVo rules = labReportMarkStatisticService.findRules(mainTreeId,key);
        Double result = null;
        if(rules != null) {
            if (rules.getTimeRule().equals("X")) {
                if (rules.getECalcualteRule().equals("001")) {
                    result = labReportMarkStatisticService.findMaxValue(mainTreeId, key);
                } else if (rules.getECalcualteRule().equals("002")) {
                    result = labReportMarkStatisticService.findMinValue(mainTreeId, key);
                } else {
                    result = labReportMarkStatisticService.findAverageValue(mainTreeId, key);
                }
            } else {
                if (rules.getECalcualteRule().equals("001")) {
                    result = labReportMarkStatisticService.findMaxValueByLTime(mainTreeId, key);
                } else if (rules.getECalcualteRule().equals("002")) {
                    result = labReportMarkStatisticService.findMinValueByLTime(mainTreeId, key);
                } else {
                    result = labReportMarkStatisticService.findAverageValueByLTime(mainTreeId, key);
                }
            }
        }
        return  result;
    }

    /**
     * 获取gis标牌信息
     * @param mainTreeId
     * @return
     */
    private BusiOfflineGisBrandVo getBusiOfflineGisBrand(String mainTreeId){
        BusiOfflineGisBrandVo busiOfflineGisBrandVo = new BusiOfflineGisBrandVo();

        Double ratedCurrent = this.getRules(mainTreeId, GisAssessEnum.RATED_CURRENT.getKey());
        busiOfflineGisBrandVo.setRatedFrequency(String.valueOf(ratedCurrent != null ? ratedCurrent : "0.00"));

        Double breakCurrent = this.getRules(mainTreeId, GisAssessEnum.BREAK_CURRENT.getKey());
        busiOfflineGisBrandVo.setElectricCurrent(String.valueOf(breakCurrent != null ? breakCurrent : "0.00"));

        Double designServiceLife = this.getRules(mainTreeId, GisAssessEnum.DESIGN_SERVICE_LIFE.getKey());
        busiOfflineGisBrandVo.setServiceTime(String.valueOf(designServiceLife != null ? designServiceLife : "0.00"));
        return busiOfflineGisBrandVo;
    }
}
