package com.huatek.busi.util;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.ZoneId;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.huatek.busi.vo.*;
import org.springframework.util.StringUtils;

import com.huatek.busi.entity.BusiOutlineGisExperimentData;
import com.huatek.busi.entity.IecBreakerParam;
import com.huatek.busi.entity.RptGisMonitor;
import com.huatek.busi.entity.RptGisMonitorSf6Charts;
import com.huatek.busi.entity.TransformerPdStatistics;

import lombok.extern.slf4j.Slf4j;

/**
 * gis评测工具类
 * @author aaly_lei
 *
 */
@Slf4j
public class GisAssessUtils {

	/**
	 * gis的权重系数转为Map
	 * @param busiParamGises
	 * @return
	 */
	public static Map<String, BusiParamTransformerVo>  busiParamGisList2Map(List<BusiParamTransformerVo> busiParamGisList) {
		Map<String, BusiParamTransformerVo> resuMap = new HashMap<String, BusiParamTransformerVo>();
		for (int i = 0; i < busiParamGisList.size(); i++) {
			resuMap.put(busiParamGisList.get(i).getName(), busiParamGisList.get(i));
		}
		
		return resuMap;
	}
	
	/**
	 * 升降计算方法
	 * @param value 
	 * @param UpOrDown up or down
	 * @param a
	 * @param b
	 * @return
	 */
	public static BigDecimal  formulaForUpAndDown(BigDecimal value, String UpOrDown, BigDecimal a, BigDecimal b) {
		BigDecimal val = createBigD("1");
		BigDecimal def = createBigD("0");
		BigDecimal val_1 = createBigD("1");
		if(null != value) {
			FileMain.writeTxt(" 升降计算: +" + UpOrDown+"  a=" + a + ", b=" + b );
			if("down".equals(UpOrDown)) {
				if(value.compareTo(def)>=0 && value.compareTo(a)<0) {
					val = val_1;
					FileMain.writeTxt("升降计算: (0<=N<a) down:  input_N=" + value + ", 计算结果系数：val=" + val );
				} else if(value.compareTo(a)>=0 && value.compareTo(b)<0) {
					val = (b.subtract(value)).divide(b.subtract(a), 5,BigDecimal.ROUND_HALF_UP);
					FileMain.writeTxt("升降计算: (a<=N<b) down:  input_N=" + value + ", 计算结果系数：val=" + val + "使用年限 a值 5， b值 30，已使用年限：12.775 计算方法：（30 - 12.775）/ （30 - 5）");
				} else {
					val = def;
					FileMain.writeTxt("升降计算: (N>b) down:  input_N=" + value + ", 计算结果系数：val=" + val );
				}
			} else {
				if(value.compareTo(def)>=0 && value.compareTo(a)<0) {
					val = def;
					FileMain.writeTxt("升降计算: (0<=N<a) UP:  input_N=" + value + ", 计算结果系数：val=" + val );
				} else if(value.compareTo(a)>=0 && value.compareTo(b)<0) {
					val = (value.subtract(a)).divide(b.subtract(a), 5,BigDecimal.ROUND_HALF_UP);
					FileMain.writeTxt("升降计算: (a<=N<b) UP:  input_N=" + value + ", 计算结果系数：val=" + val );
				} else {
					val = val_1;
					FileMain.writeTxt("升降计算: (N>b) UP:  input_N=" + value + ", 计算结果系数：val=" + val );
				}
			}
		}
		return val;
	}
	/**
	 * 获取ABC三相最小值
	 * @param value 
	 * @param UpOrDown up or down
	 * @param a
	 * @param b
	 * @return
	 */
	public static BigDecimal  compareABC(BigDecimal aVal, BigDecimal bVal, BigDecimal cVal) {
		BigDecimal val = createBigD("1");
		val = aVal;
		if(bVal.compareTo(val)<0) {
			val = bVal;
		}
		if(cVal.compareTo(val)<0) {
			val = cVal;
		}
		return val;
	}
	/**
	 * 获取ABC三相最大值
	 * @param value 
	 * @param UpOrDown up or down
	 * @param a
	 * @param b
	 * @return
	 */
	public static BigDecimal  compareABCMax(BigDecimal aVal, BigDecimal bVal, BigDecimal cVal) {
		BigDecimal val = createBigD("1");
		val = aVal;
		if(bVal.compareTo(val)>0) {
			val = bVal;
		}
		if(cVal.compareTo(val)>0) {
			val = cVal;
		}
		return val;
	}
	/**
	 * Object 转 BigDecimal
	 * @param obj
	 * @return
	 */
	public static BigDecimal  object2BigDecimal(Object obj) {
		BigDecimal val = createBigD("1");
		if(null != obj) {
			val = new BigDecimal(obj.toString());
		}
		return val;
	}
	/**
	 * String 转 BigDecimal
	 * @param str
	 * @return
	 */
	public static BigDecimal str2BigDecimal(String str) {
		BigDecimal val = createBigD("0");
		if(null != str && !"".equals(str)) {
			val = new BigDecimal(str).setScale(5,BigDecimal.ROUND_HALF_UP);
		}
		return val;
	}
	/**
	 * Long 转 BigDecimal
	 * @param value
	 * @return
	 */
	public static BigDecimal  long2BigDecimal(Long value) {
		BigDecimal val = createBigD("0");
		if(null != value) {
			val = new BigDecimal(value.toString());
		}
		return val;
	}
	/**
	 * 获取系数库  a值
	 * @param busiParamGisMap 系数库
	 * @param key
	 * @return
	 */
	public static BigDecimal getaVal(Map<String, BusiParamTransformerVo> busiParamGisMap, String key) {
		BigDecimal val = createBigD("0");
		if(null != busiParamGisMap && null != busiParamGisMap.get(key)) {
			BusiParamTransformerVo busiParamGis = busiParamGisMap.get(key);
			val = busiParamGis.getAValue();
		}
		return val;
	}
	/**
	 * 获取系数库  b值
	 * @param busiParamGisMap 系数库
	 * @param key
	 * @return
	 */
	public static BigDecimal  getbVal(Map<String, BusiParamTransformerVo> busiParamGisMap, String key) {
		BigDecimal val = createBigD("0");
		if(null != busiParamGisMap && null != busiParamGisMap.get(key)) {
			BusiParamTransformerVo busiParamGis = busiParamGisMap.get(key);
			val = busiParamGis.getBValue();
		}
		return val;
	}
	/**
	 * 获取系数库  权重值
	 * @param busiParamGisMap 系数库
	 * @param key
	 * @return
	 */
	public static BigDecimal  getVal(Map<String, BusiParamTransformerVo> busiParamGisMap, String key) {
		BigDecimal val = createBigD("0");
		if(null != busiParamGisMap && null != busiParamGisMap.get(key)) {
			BusiParamTransformerVo busiParamGis = busiParamGisMap.get(key);
			val = busiParamGis.getValue();
		}
		return val;
	}
	/**
	 * 获取导电回路电阻
	 * @param busiOutlineGisExperimentdata 例行试验
	 * @return
	 */
	public static BigDecimal getDdhldz(BusiOutlineGisExperimentData busiOutlineGisExperimentdata) {
		BigDecimal val = createBigD("0");
		if(null != busiOutlineGisExperimentdata) {
//			val = compareABC(GisAssessUtils.str2BigDecimal(busiOutlineGisExperimentdata.getADdhlResistance()) , GisAssessUtils.str2BigDecimal(busiOutlineGisExperimentdata.getBDdhlResistance()), GisAssessUtils.str2BigDecimal(busiOutlineGisExperimentdata.getCDdhlResistance()));
			val = compareABCMax(GisAssessUtils.str2BigDecimal(busiOutlineGisExperimentdata.getADdhlResistance()) , GisAssessUtils.str2BigDecimal(busiOutlineGisExperimentdata.getBDdhlResistance()), GisAssessUtils.str2BigDecimal(busiOutlineGisExperimentdata.getCDdhlResistance()));
		}
		return val;
	}
	/**
	 * 获取合闸不同期
	 * @param gisMechanical 获取GIS机械特性信息
	 * @return
	 */
	public static BigDecimal getHzbtq(GisMechanicalPropertiesVo gisMechanical) {
		BigDecimal val = createBigD("0");
		if(null != gisMechanical) {
			val = compareABCMax(GisAssessUtils.str2BigDecimal(gisMechanical.getAHzBtq()),GisAssessUtils.str2BigDecimal(gisMechanical.getBHzBtq()),GisAssessUtils.str2BigDecimal(gisMechanical.getCHzBtq()));
		}
		return val;
	}
	/**
	 * 获取分闸不同期
	 * @param gisMechanical 获取GIS机械特性信息
	 * @return
	 */
	public static BigDecimal getFzbtq(GisMechanicalPropertiesVo gisMechanical) {
		BigDecimal val = createBigD("0");
		if(null != gisMechanical) {
			val = compareABCMax(GisAssessUtils.str2BigDecimal(gisMechanical.getAFzBtq()), GisAssessUtils.str2BigDecimal(gisMechanical.getBFzBtq()), GisAssessUtils.str2BigDecimal(gisMechanical.getCFzBtq()));
		}
		return val;
	}
	/**
	 * 获取刚分速度
	 * @param gisMechanical 获取GIS机械特性信息
	 * @return
	 */
	public static BigDecimal getGfSpeend(GisMechanicalPropertiesVo gisMechanical) {
		BigDecimal val = createBigD("0");
		if(null != gisMechanical) {
			val = compareABCMax(GisAssessUtils.str2BigDecimal(gisMechanical.getAGfSpeend()),GisAssessUtils.str2BigDecimal(gisMechanical.getBGfSpeend()),GisAssessUtils.str2BigDecimal(gisMechanical.getCGfSpeend()));
		}
		return val;
	}
	/**
	 * 获取刚和速度
	 * @param gisMechanical 获取GIS机械特性信息
	 * @return
	 */
	public static BigDecimal getGhSpeend(GisMechanicalPropertiesVo gisMechanical) {
		BigDecimal val = createBigD("0");
		if(null != gisMechanical) {
			val = compareABCMax(GisAssessUtils.str2BigDecimal(gisMechanical.getAGhSpeed()), GisAssessUtils.str2BigDecimal(gisMechanical.getBGhSpeed()), GisAssessUtils.str2BigDecimal(gisMechanical.getCGhSpeed()));
		}
		return val;
	}
	/**
	 * 获取气体泄漏数据
	 * 取所有在线监测SF6的数据（气体压力值），计算比较出每个监测点气体泄露率/天，要<0.1%,超过此值，我们
	 * 认为有绝缘问题，要加以注意。（有不同温度的，全部折算到同一的温度下，气体的压力是多少。20度），同时选
	 * 出一个压力最不足的监测数据，作为计算使用的数据。所有开关注意值=0.5，道闸、套管、注意值=0.44，主道
	 * 闸权重=0.35，其他权重均分。每个监测点评估一次，合计评价。
	 * @param eqmCode
	 * @param eqmId
	 * @return
	 */
	public static BigDecimal  getQtxl(String eqmCode,String eqmId, List<RptGisMonitorSf6Charts> rptGisMonitorSf6Chartses) {
		BigDecimal val = createBigD("0");
//		List<GisSf6Pressure> gisSf6Pressures = gisSf6PressureService.findListByeqmid(eqmId);
		RptGisMonitorSf6Charts rptGisMonitorSf6ChartA = getNewRptGisMonitorSf6Charts("A相", rptGisMonitorSf6Chartses);
		RptGisMonitorSf6Charts rptGisMonitorSf6ChartB = getNewRptGisMonitorSf6Charts("B相", rptGisMonitorSf6Chartses);
		RptGisMonitorSf6Charts rptGisMonitorSf6ChartC = getNewRptGisMonitorSf6Charts("C相", rptGisMonitorSf6Chartses);
		BigDecimal aVal = createBigD("0");
		if(null != rptGisMonitorSf6ChartA) {
			aVal = str2BigDecimal(rptGisMonitorSf6ChartA.getPressure());
		}
		BigDecimal bVal = createBigD("0");
		if(null != rptGisMonitorSf6ChartB) {
			bVal = str2BigDecimal(rptGisMonitorSf6ChartB.getPressure());
		}
		BigDecimal cVal = createBigD("0");
		if(null != rptGisMonitorSf6ChartC) {
			cVal = str2BigDecimal(rptGisMonitorSf6ChartC.getPressure());
		}
		val = compareABC(aVal, bVal, cVal);
		return val;
	}
	/**
	 * 微水含量-灭弧室（0.6），其他气室（0.4）
	 * 选出微水含量最大的一个数据，作为计算数据。
	 * @param eqmCode
	 * @param eqmId
	 * @param gisSf6Pressures GIS  SF 6 压力微水温度原始数据
	 * @return
	 */
	public static BigDecimal  getWshl(String eqmCode,String eqmId, List<RptGisMonitorSf6Charts> rptGisMonitorSf6Chartses) {
		BigDecimal val = createBigD("0");
		RptGisMonitorSf6Charts rptGisMonitorSf6ChartA = getNewRptGisMonitorSf6Charts("A", rptGisMonitorSf6Chartses);
		RptGisMonitorSf6Charts rptGisMonitorSf6ChartB = getNewRptGisMonitorSf6Charts("B", rptGisMonitorSf6Chartses);
		RptGisMonitorSf6Charts rptGisMonitorSf6ChartC = getNewRptGisMonitorSf6Charts("C", rptGisMonitorSf6Chartses);
		BigDecimal aVal = createBigD("0");
		if(null != rptGisMonitorSf6ChartA) {
			aVal = str2BigDecimal(rptGisMonitorSf6ChartA.getMoisture());
		}
		BigDecimal bVal = createBigD("0");
		if(null != rptGisMonitorSf6ChartB) {
			bVal = str2BigDecimal(rptGisMonitorSf6ChartB.getMoisture());
		}
		BigDecimal cVal = createBigD("0");
		if(null != rptGisMonitorSf6ChartC) {
			cVal = str2BigDecimal(rptGisMonitorSf6ChartC.getMoisture());
		}
		val = compareABCMax(aVal, bVal, cVal);
		return val;
	}
	/**
	 * 获取A、B、C三相中最新的SF6数据
	 * @param xiangwei
	 * @param rptGisMonitorSf6Chartses
	 * @return
	 */
	private static RptGisMonitorSf6Charts  getNewRptGisMonitorSf6Charts(String position, List<RptGisMonitorSf6Charts> rptGisMonitorSf6Chartses) {
		RptGisMonitorSf6Charts rptGisMonitorSf6Charts = null;
		RptGisMonitorSf6Charts result = null;
		for (int i = 0; i < rptGisMonitorSf6Chartses.size(); i++) {
			rptGisMonitorSf6Charts = rptGisMonitorSf6Chartses.get(i);
			if(position.equals(rptGisMonitorSf6Charts.getPosition())) {
				result = rptGisMonitorSf6Chartses.get(i);
				break;
			}
		}
		return result;
	}
	
	/**
	 * 局放量
	 * @param eqmCode
	 * @param eqmId
	 * @param transformerGisPdStatistics 变压器/GIS 局部放电统计
	 * @return
	 */
	public static BigDecimal  getJfl(String eqmCode,String eqmId, List<TransformerPdStatistics> transformerGisPdStatistics) {
		BigDecimal val = createBigD("0");
		if(transformerGisPdStatistics.size()>0) {
			val = str2BigDecimal(transformerGisPdStatistics.get(0).getElectricQuantity());
		}
		return val;
	}
	/**
	 * 局放次数
	 * @param eqmCode
	 * @param eqmId
	 * @param transformerGisPdStatistics transformerGisPdStatistics 变压器/GIS 局部放电统计
	 * @return
	 */
	public static BigDecimal  getJfcs(String eqmCode,String eqmId, List<TransformerPdStatistics> transformerGisPdStatistics) {
		BigDecimal val = createBigD("0");
		if(transformerGisPdStatistics.size()>0) {
			val = str2BigDecimal(transformerGisPdStatistics.get(0).getCount().toString());
		}
		return val;
	}
	/**
	 * 累计开断次数
	 * @param eqmCode
	 * @param eqmId
	 * @param rptGisMonitor GIS开关--断路器(机械特性)信息
	 * @return
	 */
	public static BigDecimal  getLjdkcs(String eqmCode,String eqmId, RptGisMonitor rptGisMonitor ) {
		
		BigDecimal val = createBigD("0");
		if(null != rptGisMonitor) {
			val = long2BigDecimal(rptGisMonitor.getTurnoffCount());
		}
		return val;
	}
	/**
	 * 触头断开时的断开电流
	 * @param eqmCode
	 * @param eqmId
	 * @param rptGisMonitor rptGisMonitor GIS开关--断路器(机械特性)信息
	 * @return
	 */
	public static BigDecimal  getDkdl(String eqmCode,String eqmId, RptGisMonitor rptGisMonitor ) {
		
		BigDecimal val = createBigD("0");
		if(null != rptGisMonitor && null != rptGisMonitor.getAElectric() && null != rptGisMonitor.getBElectric() && null != rptGisMonitor.getCElectric()) {
			val = rptGisMonitor.getAElectric();
		}
		return val;
	}
	
	/**
	 * 触头额定断开电流
	 * @param busiOfflineGisBrand 标牌信息
	 * @return
	 */
	public static BigDecimal  getEddkdl(BusiOfflineGisBrandVo busiOfflineGisBrandVo) {
		BigDecimal val = createBigD("0");
		if(null != busiOfflineGisBrandVo) {
			val = str2BigDecimal(busiOfflineGisBrandVo.getElectricCurrent());
		}
		return val;
	}
	
	/**
	 * 负荷
	 * @param I_b 触头断开时的断开电流（KA） 
	 * @param I_n 触头额定断开电流（KA）
	 * @return
	 */
	public static BigDecimal  getFh(BigDecimal I_b, BigDecimal  I_n) {
		BigDecimal val = createBigD("0");
		if( isNotZero(I_n)) {
//			val = I_b.divide(I_n.multiply(str2BigDecimal("100")),5,BigDecimal.ROUND_HALF_UP).multiply(str2BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
			val = I_b.divide(I_n,5,BigDecimal.ROUND_HALF_UP).multiply(str2BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
//			FileMain.writeTxt("负荷(P): "+I_b + "/" + I_n +"=" + val);
		}
		return val;
	}
	/**
	 * 获取平均负荷
	 * @param iecBreakerParams
	 * @param eddkdl
	 * @return
	 */
	public static BigDecimal  getFhAvg(List<IecBreakerParam> iecBreakerParams, BigDecimal eddkdl) {
		
		BigDecimal val = createBigD("0");
		IecBreakerParam iecBreakerParam = null;
		BigDecimal fhSum = new BigDecimal("0");//负荷
		BigDecimal fhCount = new BigDecimal("0");//负荷
		if(iecBreakerParams.size()>0) {
			fhCount = new BigDecimal(iecBreakerParams.size());
			for (int i = 0; i < iecBreakerParams.size(); i++) {
				iecBreakerParam = iecBreakerParams.get(i);
				fhSum = fhSum.add(getFh(str2BigDecimal(iecBreakerParam.getAbortCurrent()), eddkdl));
			}
			val = fhSum.divide(fhCount,1,BigDecimal.ROUND_HALF_UP);
		}
		return val;
	}
	/**
	 * 触头累计磨损率(7天)
	 * @param iecBreakerParams 触头所有断开记录（断开一次会有一条断开记录）
	 * @param eddkdl 额定断开电流
	 * @return
	 */
	public static BigDecimal getMslsForFh(List<IecBreakerParam> iecBreakerParams, BigDecimal eddkdl) {
		
		BigDecimal val = createBigD("0");
		IecBreakerParam iecBreakerParam = null;
		BigDecimal fh = null;//负荷
		BigDecimal n = null;//触头可断开次数
		BigDecimal thisMsl = null;//触头断开一次的磨损量
		for (int i = 0; i < iecBreakerParams.size(); i++) {
			iecBreakerParam = iecBreakerParams.get(i);			
			BigDecimal abortCurrent=new BigDecimal(iecBreakerParam.getAbortCurrent()).setScale(5,BigDecimal.ROUND_HALF_UP);
			fh = getFh(abortCurrent, eddkdl);			
			FileMain.writeTxt("Ib断开时的电流A："+abortCurrent);
			FileMain.writeTxt("In触头额定电流A："+eddkdl);
			FileMain.writeTxt("P负荷(%)："+fh+",计算公式：(Ib/In)*100% =("+ abortCurrent + "/" +eddkdl+")*100% = "+fh);
			FileMain.writeTxt("本次负荷(%)："+fh+",  断开电流(A)："+abortCurrent+",  额定断开电流（A）："+eddkdl);
			
			BigDecimal tmpCurrent = abortCurrent.divide(new BigDecimal("1000"), 4, BigDecimal.ROUND_CEILING);
			BigDecimal tmpEddkdl = eddkdl.divide(new BigDecimal("1000"), 4, BigDecimal.ROUND_CEILING);
			n = getEdKdkcs(tmpCurrent, tmpEddkdl, fh);//公式计算
			thisMsl = getMslForFh(fh, n);
			FileMain.writeTxt ("当前断开电流(A)："+ iecBreakerParam.getAbortCurrent()+"， 触头相对断磨损量C:"+thisMsl);
			System.out.println("当前断开电流(A)："+ iecBreakerParam.getAbortCurrent()+"， 触头相对断磨损量C:"+thisMsl);
			
			log.debug("当前断开电流(A)：" + iecBreakerParam.getAbortCurrent()+"， 触头相对断磨损量C:"+thisMsl);
			val = val.add(thisMsl);
		}
		return val;
	}
	/**
	 * 触头相对磨损量（每断开一次）
	 * @param fh 负荷
	 * @param n 为额定断开电流下，触头允许断开次数
	 * @return
	 */
	public static BigDecimal getMslForFh(BigDecimal fh, BigDecimal n) {
		FileMain.writeTxt("-------------------触头相对磨损量( C )计算公式---------------");
		FileMain.writeTxt("P负荷:" + fh + ",  额定断开电流下，触头允许断开次数N:" + n);
		System.out.println("P负荷:" + fh + ",  额定断开电流下，触头允许断开次数N:" + n);
		FileMain.writeTxt("---- 负荷值在附件表2中对应的区间，计算触头相对磨损量C: ---");
//		BigDecimal baseVal = new BigDecimal("0");// 磨损量系数
//		BigDecimal fhC = new BigDecimal("0");// 负荷差值
//		BigDecimal fhN = new BigDecimal("0");// 当前负荷触头相对磨损量
		BigDecimal val = new BigDecimal("0");// 当前断开的磨损量
		if (getIsBetweenO(fh, str2BigDecimal("0"), str2BigDecimal("3"))) {
			val = str2BigDecimal("2").divide(str2BigDecimal("1000").multiply(n), 20, BigDecimal.ROUND_HALF_UP);
		
		} else if (getIsBetweenO(fh, str2BigDecimal("3"), str2BigDecimal("10"))) {
			val = str2BigDecimal("5").divide(str2BigDecimal("1000").multiply(n), 20, BigDecimal.ROUND_HALF_UP);
			
		} else if (getIsBetweenO(fh, str2BigDecimal("10"), str2BigDecimal("25"))) {
			val = str2BigDecimal("88").divide(str2BigDecimal("1000").multiply(n), 20, BigDecimal.ROUND_HALF_UP);
			
		} else if (getIsBetweenO(fh, str2BigDecimal("25"), str2BigDecimal("35"))) {
			val = str2BigDecimal("159").divide(str2BigDecimal("1000").multiply(n), 20, BigDecimal.ROUND_HALF_UP);
		
		} else if (getIsBetweenO(fh, str2BigDecimal("35"), str2BigDecimal("50"))) {
			val = str2BigDecimal("303").divide(str2BigDecimal("1000").multiply(n), 20, BigDecimal.ROUND_HALF_UP);
			
		} else if (getIsBetweenO(fh, str2BigDecimal("50"), str2BigDecimal("75"))) {
			val = str2BigDecimal("606").divide(str2BigDecimal("1000").multiply(n), 20, BigDecimal.ROUND_HALF_UP);
		} else if (getIsBetweenO(fh, str2BigDecimal("75"), str2BigDecimal("100"))) {
			val = str2BigDecimal("1").divide(n, 20, BigDecimal.ROUND_HALF_UP);
		}
		FileMain.writeTxt("------ 触头相对磨损量C计算结果:" + val);
		System.out.println("------触头相对磨损量C计算结果:" + val);
		return val;
	}
	/**
	 * 100%负荷的断开次数
	 * @param iecBreakerParams 触头所有断开记录
	 * @param eddkdl 额定断开电流
	 * @return
	 */
	public static BigDecimal  getDkcsesFor100(List<IecBreakerParam> iecBreakerParams, BigDecimal eddkdl) {
		
		BigDecimal val = new BigDecimal("0");
		IecBreakerParam iecBreakerParam = null;
		BigDecimal fh = null;
		BigDecimal dkcs = null;
		for (int i = 0; i < iecBreakerParams.size(); i++) {
			iecBreakerParam = iecBreakerParams.get(i);
			FileMain.writeTxt("断开电流(A):"+iecBreakerParam.getAbortCurrent() + " 额定断开电流A(标牌):" + eddkdl);
			fh = getFh(str2BigDecimal(iecBreakerParam.getAbortCurrent()), eddkdl);			
			dkcs = getDkcsFor100(fh);
			val = val.add(dkcs);
		}
		FileMain.writeTxt("累计断开次数："+iecBreakerParams.size() + "次， 合计：" + val);
		return val;
	}
	/**
	 * 获取100负荷下的断开次数
	 * @param fh
	 * @return
	 */
	public static BigDecimal  getDkcsFor100(BigDecimal fh) {
		
		BigDecimal val = new BigDecimal("0");
		if(getIsBetween(fh, str2BigDecimal("0"), str2BigDecimal("3"))) {
			val = str2BigDecimal("14").divide(str2BigDecimal("6680"),5,BigDecimal.ROUND_HALF_UP);
			FileMain.writeTxt("折算到100%负荷下的断开次数(查表附件2)： 负荷P(0~3)=" + fh + ", 折算为：14/6680 = "+ val );
		} else if(getIsBetween(fh, str2BigDecimal("3"), str2BigDecimal("10"))) {
			val = str2BigDecimal("14").divide(str2BigDecimal("2786"),5,BigDecimal.ROUND_HALF_UP);
			FileMain.writeTxt("折算到100%负荷下的断开次数(查表附件2)： 负荷P(3~10)=" + fh + ", 折算为：14/2786 = "+ val );
		} else if(getIsBetween(fh, str2BigDecimal("10"), str2BigDecimal("25"))) {
			val = str2BigDecimal("14").divide(str2BigDecimal("160"),5,BigDecimal.ROUND_HALF_UP);
			FileMain.writeTxt("折算到100%负荷下的断开次数(查表附件2)： 负荷P(10~25)=" + fh + ", 折算为：14/160 = "+ val );
		} else if(getIsBetween(fh, str2BigDecimal("25"), str2BigDecimal("35"))) {
			val = str2BigDecimal("14").divide(str2BigDecimal("88"),5,BigDecimal.ROUND_HALF_UP);
			FileMain.writeTxt("折算到100%负荷下的断开次数(查表附件2)： 负荷P(25~35)=" + fh + ", 折算为：14/88 = "+ val );
		} else if(getIsBetween(fh, str2BigDecimal("35"), str2BigDecimal("50"))) {
			val = str2BigDecimal("14").divide(str2BigDecimal("47"),5,BigDecimal.ROUND_HALF_UP);
			FileMain.writeTxt("折算到100%负荷下的断开次数(查表附件2)： 负荷P(35~50)=" + fh + ", 折算为：14/47 = "+ val );
		} else if(getIsBetween(fh, str2BigDecimal("50"), str2BigDecimal("75"))) {
			val = str2BigDecimal("14").divide(str2BigDecimal("23"),5,BigDecimal.ROUND_HALF_UP);
			FileMain.writeTxt("折算到100%负荷下的断开次数(查表附件2)： 负荷P(50~75)=" + fh + ", 折算为：14/23 = "+ val );
		} else if(getIsBetween(fh, str2BigDecimal("75"), str2BigDecimal("100"))) {
			val = str2BigDecimal("14").divide(str2BigDecimal("14"),5,BigDecimal.ROUND_HALF_UP);
			FileMain.writeTxt("折算到100%负荷下的断开次数(查表附件2)： 负荷P(75~100)=" + fh + ", 折算为：14/14 = "+ val );
		}		
		return val;
	}
	/**
	 * 可断开次数
	 * @param fh 负荷
	 * 
	 * @return
	 */
	public static BigDecimal  getKdkcs(BigDecimal fh) {
		
		BigDecimal baseVal = getBaseInfoFordkcs(fh);
		BigDecimal val = new BigDecimal("0");//此项得分
		
		if(getIsBetween(fh, str2BigDecimal("0"), str2BigDecimal("3"))) {
			val = str2BigDecimal("6680");
			
		} else if(getIsBetween(fh, str2BigDecimal("3"), str2BigDecimal("10"))) {
			baseVal = (str2BigDecimal("6680").subtract(str2BigDecimal("2786"))).divide(str2BigDecimal("10").subtract(str2BigDecimal("3")),1,BigDecimal.ROUND_HALF_UP);
			val = str2BigDecimal("6680").subtract((fh.subtract(str2BigDecimal("3"))).multiply(baseVal));
			
		} else if(getIsBetween(fh, str2BigDecimal("10"), str2BigDecimal("25"))) {
			baseVal = (str2BigDecimal("2786").subtract(str2BigDecimal("160"))).divide(str2BigDecimal("25").subtract(str2BigDecimal("10")),1,BigDecimal.ROUND_HALF_UP);
			val = str2BigDecimal("2786").subtract((fh.subtract(str2BigDecimal("10"))).multiply(baseVal));
			
		} else if(getIsBetween(fh, str2BigDecimal("25"), str2BigDecimal("35"))) {
			baseVal = (str2BigDecimal("160").subtract(str2BigDecimal("88"))).divide(str2BigDecimal("35").subtract(str2BigDecimal("25")),1,BigDecimal.ROUND_HALF_UP);
			val = str2BigDecimal("160").subtract((fh.subtract(str2BigDecimal("25"))).multiply(baseVal));
			
		} else if(getIsBetween(fh, str2BigDecimal("35"), str2BigDecimal("50"))) {
			baseVal = (str2BigDecimal("88").subtract(str2BigDecimal("47"))).divide(str2BigDecimal("50").subtract(str2BigDecimal("35")),1,BigDecimal.ROUND_HALF_UP);
			val = str2BigDecimal("88").subtract((fh.subtract(str2BigDecimal("35"))).multiply(baseVal));
			
		} else if(getIsBetween(fh, str2BigDecimal("50"), str2BigDecimal("75"))) {
			baseVal = (str2BigDecimal("47").subtract(str2BigDecimal("23"))).divide(str2BigDecimal("75").subtract(str2BigDecimal("50")),1,BigDecimal.ROUND_HALF_UP);
			val = str2BigDecimal("47").subtract((fh.subtract(str2BigDecimal("50"))).multiply(baseVal));
			
		} else if(getIsBetween(fh, str2BigDecimal("75"), str2BigDecimal("100"))) {
			baseVal = (str2BigDecimal("23").subtract(str2BigDecimal("14"))).divide(str2BigDecimal("100").subtract(str2BigDecimal("75")),1,BigDecimal.ROUND_HALF_UP);
			val = str2BigDecimal("23").subtract((fh.subtract(str2BigDecimal("75"))).multiply(baseVal));
		}
		return val;
	}
	/**
	 * 获取断开次数增长基数信息
	 * @param fh
	 * @return
	 */
	public static BigDecimal  getBaseInfoFordkcs(BigDecimal fh) {
		
		BigDecimal baseVal = new BigDecimal("0");//此项得分
		if(getIsBetween(fh, str2BigDecimal("0"), str2BigDecimal("3"))) {
			baseVal = str2BigDecimal("6680");
		} else if(getIsBetween(fh, str2BigDecimal("3"), str2BigDecimal("10"))) {
			baseVal = (str2BigDecimal("6680").subtract(str2BigDecimal("2786"))).divide(str2BigDecimal("10").subtract(str2BigDecimal("3")),1,BigDecimal.ROUND_HALF_UP);
		} else if(getIsBetween(fh, str2BigDecimal("10"), str2BigDecimal("25"))) {
			baseVal = (str2BigDecimal("2786").subtract(str2BigDecimal("160"))).divide(str2BigDecimal("25").subtract(str2BigDecimal("10")),1,BigDecimal.ROUND_HALF_UP);
		} else if(getIsBetween(fh, str2BigDecimal("25"), str2BigDecimal("35"))) {
			baseVal = (str2BigDecimal("160").subtract(str2BigDecimal("88"))).divide(str2BigDecimal("35").subtract(str2BigDecimal("25")),1,BigDecimal.ROUND_HALF_UP);
		} else if(getIsBetween(fh, str2BigDecimal("35"), str2BigDecimal("50"))) {
			baseVal = (str2BigDecimal("88").subtract(str2BigDecimal("47"))).divide(str2BigDecimal("50").subtract(str2BigDecimal("35")),1,BigDecimal.ROUND_HALF_UP);
		} else if(getIsBetween(fh, str2BigDecimal("50"), str2BigDecimal("75"))) {
			baseVal = (str2BigDecimal("47").subtract(str2BigDecimal("23"))).divide(str2BigDecimal("75").subtract(str2BigDecimal("50")),1,BigDecimal.ROUND_HALF_UP);
		} else if(getIsBetween(fh, str2BigDecimal("75"), str2BigDecimal("100"))) {
			baseVal = (str2BigDecimal("23").subtract(str2BigDecimal("14"))).divide(str2BigDecimal("100").subtract(str2BigDecimal("75")),1,BigDecimal.ROUND_HALF_UP);
		}
		return baseVal;
	}
	/**
	 * 额定电流触头允许次数
	 * @param eddkdl 额定断开电流
	 * @param I_b 触头断开时的断开电流（KA） PMS
	 * @param I_n 触头额定断开电流（KA）标牌数据
	 * @return
	 */
	public static BigDecimal getEdKdkcs(BigDecimal I_b, BigDecimal I_n, BigDecimal fh ) {
		
		FileMain.writeTxt("N计算公式：(49.5/Ib)^3.46   Ib<11  KA");
		FileMain.writeTxt("N计算公式：(223.5/Ib)^1.76  Ib>=11 KA");
		
		BigDecimal val = new BigDecimal("0");
		if(isNotEmptyForBigDecimal(I_b)) {
			if(getIsBetween(I_b, str2BigDecimal("0"), str2BigDecimal("11"))) {
				BigDecimal temp = str2BigDecimal("49.5").divide(I_b,10,BigDecimal.ROUND_HALF_UP);
				double a = Double.valueOf(temp.toString());
				val = new BigDecimal(Math.pow(a,3.46)).setScale(10,BigDecimal.ROUND_HALF_UP);
				FileMain.writeTxt("N计算公式：(49.5/Ib)^3.46 = (" + 49.5 +"/" + I_b + ")^3.46 =" + val );
			} else {
				BigDecimal temp = str2BigDecimal("223.5").divide(I_b,10,BigDecimal.ROUND_HALF_UP);
				double a = Double.valueOf(temp.toString());
				val = new BigDecimal(Math.pow(a,1.76)).setScale(10,BigDecimal.ROUND_HALF_UP);
				FileMain.writeTxt("N计算公式：(223.5/Ib)^1.76 = (" + 223.5 +"/" + I_b + ")^1.76 =" + val );
			}
		}
		return val;
	}
	/**
	 * 
	 * 触头相对磨损量
	 * @param n 为额定断开电流下，触头允许断开次数
	 * @param fh 负荷
	 * @param ljdkcs 累计断开次数
	 * @param kdkcs 当前负荷下可以断开次数
	 * @return
	 */
	public static BigDecimal getCtxdmsl(BigDecimal fh, BigDecimal n, BigDecimal ljdkcs, BigDecimal kdkcs) {
		
		BigDecimal val = new BigDecimal("0");
		if(getIsBetween(fh, str2BigDecimal("0"), str2BigDecimal("3"))) {
			val = str2BigDecimal("2").divide(str2BigDecimal("1000").multiply(n),5, BigDecimal.ROUND_HALF_UP);
		} else if(getIsBetween(fh, str2BigDecimal("3"), str2BigDecimal("10"))) {
			val = str2BigDecimal("5").divide(str2BigDecimal("1000").multiply(n),5, BigDecimal.ROUND_HALF_UP);
		} else if(getIsBetween(fh, str2BigDecimal("10"), str2BigDecimal("25"))) {
			val = str2BigDecimal("88").divide(str2BigDecimal("1000").multiply(n),5, BigDecimal.ROUND_HALF_UP);
		} else if(getIsBetween(fh, str2BigDecimal("25"), str2BigDecimal("35"))) {
			val = str2BigDecimal("159").divide(str2BigDecimal("1000").multiply(n),5, BigDecimal.ROUND_HALF_UP);
		} else if(getIsBetween(fh, str2BigDecimal("35"), str2BigDecimal("50"))) {
			val = str2BigDecimal("303").divide(str2BigDecimal("1000").multiply(n),5, BigDecimal.ROUND_HALF_UP);
		} else if(getIsBetween(fh, str2BigDecimal("50"), str2BigDecimal("75"))) {
			val = str2BigDecimal("606").divide(str2BigDecimal("1000").multiply(n),5, BigDecimal.ROUND_HALF_UP);
		} else if(getIsBetween(fh, str2BigDecimal("75"), str2BigDecimal("100"))) {
			val = str2BigDecimal("1").divide(n,5, BigDecimal.ROUND_HALF_UP);
		}
		return val;
	}
	/**
	 * 转换为100%负荷下的磨损率
	 * @param edKdkcs 额定电流触头允许次数
	 * @param fh 负荷
	 * @param ljdkcs 累计开断次数
	 * @return
	 */
	public static BigDecimal  getMslFor100(BigDecimal edKdkcs, BigDecimal fh,BigDecimal ljdkcs) {
		
		BigDecimal val = new BigDecimal("0");
		BigDecimal val100 = str2BigDecimal("14");
		if(getIsBetween(fh, str2BigDecimal("0"), str2BigDecimal("3"))) {
			
			val = val100.multiply(ljdkcs.divide(str2BigDecimal("6680"),5, BigDecimal.ROUND_HALF_UP)).divide(val100,5, BigDecimal.ROUND_HALF_UP);
		} else if(getIsBetween(fh, str2BigDecimal("3"), str2BigDecimal("10"))) {
			
			val = val100.multiply(ljdkcs.divide(str2BigDecimal("2786"),5, BigDecimal.ROUND_HALF_UP)).divide(val100,5, BigDecimal.ROUND_HALF_UP);
		} else if(getIsBetween(fh, str2BigDecimal("10"), str2BigDecimal("25"))) {
			
			val = val100.multiply(ljdkcs.divide(str2BigDecimal("160"),5, BigDecimal.ROUND_HALF_UP)).divide(val100,5, BigDecimal.ROUND_HALF_UP);
		} else if(getIsBetween(fh, str2BigDecimal("25"), str2BigDecimal("35"))) {
			
			val = val100.multiply(ljdkcs.divide(str2BigDecimal("88"),5, BigDecimal.ROUND_HALF_UP)).divide(val100,5, BigDecimal.ROUND_HALF_UP);
		} else if(getIsBetween(fh, str2BigDecimal("35"), str2BigDecimal("50"))) {
			
			val = val100.multiply(ljdkcs.divide(str2BigDecimal("47"),5, BigDecimal.ROUND_HALF_UP)).divide(val100,5, BigDecimal.ROUND_HALF_UP);
		} else if(getIsBetween(fh, str2BigDecimal("50"), str2BigDecimal("75"))) {
			
			val = val100.multiply(ljdkcs.divide(str2BigDecimal("23"),5, BigDecimal.ROUND_HALF_UP)).divide(val100,5, BigDecimal.ROUND_HALF_UP);
		} else if(getIsBetween(fh, str2BigDecimal("75"), str2BigDecimal("100"))) {
			val = val100.multiply(ljdkcs.divide(str2BigDecimal("14"),5, BigDecimal.ROUND_HALF_UP)).divide(val100,5, BigDecimal.ROUND_HALF_UP);
		}
		return val;
	}
	/**
	 * 触头健康指数
	 * @param c 触头相对磨损量
	 * @return
	 */
	public static BigDecimal getCtxdmsl(BigDecimal c) {
		
		BigDecimal val = new BigDecimal("0");
		val = str2BigDecimal("1").subtract(c);
		return val;
	}
	/**
	 * A 转化为 KA
	 * @param val
	 * @return
	 */
	public static BigDecimal  getA2Ka(BigDecimal val) {
		
		val = val.divide(new BigDecimal("1000"),5,BigDecimal.ROUND_HALF_UP);
		return val;
	}
	/**
	 *  N为额定断开电流下，触头允许断开次数
	 * @param eqmCode
	 * @param eqmId
	 * @param rptGisMonitor rptGisMonitor GIS开关--断路器(机械特性)信息
	 * @return
	 */
//	public static BigDecimal  getCtyxdkcs(String eqmCode,String eqmId, RptGisMonitorSf6 rptGisMonitor ) {
//		
//		BigDecimal val = createBigD("0");
//		if(null != rptGisMonitor) {
//			val = compareABCMax(rptGisMonitor.getBElectric(), rptGisMonitor.getCElectric(), rptGisMonitor.getCElectric());
//		}
//		return val;
//	}
	/**
	 * 使用年限
	 * @param eqmCode
	 * @param eqmId
	 * @param busiOfflineGisBrand GIS 离线标牌数据
	 * @return
	 */
	public static BigDecimal  getSynx(String eqmCode,String eqmId, BusiOfflineGisBrandVo busiOfflineGisBrand) {
		BigDecimal val = createBigD("0");
		if(null != busiOfflineGisBrand && null != busiOfflineGisBrand.getTransportTime()) {
			Date startDate = Date.from( busiOfflineGisBrand.getTransportTime().atZone(ZoneId.systemDefault()).toInstant());
			Date now = new Date();
			long day = timeDifference(startDate, now);
			val = new BigDecimal(day).divide(new BigDecimal("365"),5,BigDecimal.ROUND_HALF_UP);
		}
		return val;
	}
	/**
	 * 使用环境温度
	 * @param eqmCode
	 * @param eqmId
	 * @param substationMicCache 变电站微气象暂存数据
	 * @return
	 */
	public static BigDecimal  getSyhjwd(String eqmCode,String eqmId, SubstationMicGisVo substationMicGis) {
		BigDecimal val = createBigD("0");
		if(null != substationMicGis) {
			val = substationMicGis.getAirTemperature();
		}
		return val;
	}
	/**
	 * 使用环境湿度
	 * @param eqmCode
	 * @param eqmId
	 * @param substationMicCache 变电站微气象暂存数据
	 * @return
	 */
	public static BigDecimal  getSyhjsd(String eqmCode,String eqmId, SubstationMicGisVo substationMicGis) {
		BigDecimal val = createBigD("0");
		if(null != substationMicGis) {
			val = substationMicGis.getHumidity();
		}
		return val;
	}
	/**
	 * 尘埃、腐蚀
	 * @param gisRepair 检修记录
	 * @return
	 */
	public static BigDecimal  getCafs(BusiOfflineGisRepairVo gisRepair) {
		BigDecimal val = createBigD("1");
		if(null != gisRepair) {
			val = str2BigDecimal(gisRepair.getDustCorrosion());
		}
		return val;
	}
	/**
	 * 其他因素
	 * @param busiOfflineGisBrand
	 * @return
	 */
	public static BigDecimal  getQt(BusiOfflineGisBrandVo busiOfflineGisBrand) {
		BigDecimal val = createBigD("1");
		if(null != busiOfflineGisBrand) {
			val = str2BigDecimal(busiOfflineGisBrand.getYxEnvironment());
		}
		return val;
	}
	/**
	 * 操作机构润滑
	 * @param eqmCode
	 * @param eqmId
	 * @param list
	 * @return
	 */
	public static BigDecimal  getCzjgrh(String eqmCode, List<BusiOfflineGisRepairVo> list) {
		BigDecimal val = createBigD("1");
		if(null != list && list.size()>0) {
			for (int i = 0; i < list.size(); i++) {
				if(null != list.get(i).getCzjgLubrication() && !"".equals(list.get(i).getCzjgLubrication())) {
					val.add(str2BigDecimal(list.get(i).getCzjgLubrication()));
				}
			}
			val = getWgxs(val);
		}
		return val;
	}
	/**
	 * 主体、机构外观
	 * @param eqmCode
	 * @param eqmId
	 * @param list
	 * @return
	 */
	public static BigDecimal  getZtjgwg(String eqmCode, List<BusiOfflineGisRepairVo> list) {
		BigDecimal val = createBigD("1");
		if(null != list && list.size()>0) {
			for (int i = 0; i < list.size(); i++) {
				if(null != list.get(i).getZtjgAppearance() && !"".equals(list.get(i).getZtjgAppearance())) {
					val.add(str2BigDecimal(list.get(i).getZtjgAppearance()));
				}
			}
			val = getWgxs(val);
		}
		return val;
	}
	/**
	 * 支持绝缘部分
	 * @param eqmCode
	 * @param eqmId
	 * @param list
	 * @return
	 */
	public static BigDecimal  getZcjybf(String eqmCode, List<BusiOfflineGisRepairVo> list) {
		BigDecimal val = createBigD("1");
		if(null != list && list.size()>0) {
			for (int i = 0; i < list.size(); i++) {
				if(null != list.get(i).getSupportInsulation() && !"".equals(list.get(i).getSupportInsulation())) {
					val.add(str2BigDecimal(list.get(i).getSupportInsulation()));
				}
			}
			val = getWgxs(val);
		}
		return val;
	}
	/**
	 * 主回路端子
	 * @param eqmCode
	 * @param eqmId
	 * @param list
	 * @return
	 */
	public static BigDecimal  getZhldz(String eqmCode, List<BusiOfflineGisRepairVo> list) {
		BigDecimal val = createBigD("1");
		if(null != list && list.size()>0) {
			for (int i = 0; i < list.size(); i++) {
				if(null != list.get(i).getMainLoopTerminal() && !"".equals(list.get(i).getMainLoopTerminal())) {
					val.add(str2BigDecimal(list.get(i).getMainLoopTerminal()));
				}
			}
			val = getWgxs(val);
		}
		return val;
	}
	/**
	 * 同类断路器维护次数(检修记录)
	 * @param gisRepair 检修记录
	 * @return
	 */
	public static BigDecimal  getTldlqwhcs(String eqmCode, List<BusiOfflineGisRepairVo> list) {
		BigDecimal val = createBigD("1");
		if(null != list && list.size()>0) {
			for (int i = 0; i < list.size(); i++) {
				if(null != list.get(i).getTldlqMaintain() && !"".equals(list.get(i).getTldlqMaintain())) {
					val.add(str2BigDecimal(list.get(i).getTldlqMaintain()));
				}
			}
			val = getWgxs(val);
		}
		return val;
	}
	/**
	 * 断路器维护
	 * @param eqmCode
	 * @param list
	 * @return
	 */
	public static BigDecimal  getDlqwh(String eqmCode, List<BusiOfflineGisRepairVo> list) {
		BigDecimal val = createBigD("1");
		if(null != list && list.size()>0) {
			val = new BigDecimal(Math.pow(0.9,25)).setScale(5,BigDecimal.ROUND_HALF_UP);
		}
		return val;
	}
	/**
	 * 获取运行参数外观情况系数信息
	 * @param value
	 * @return
	 */
	public static BigDecimal  getWgxs(BigDecimal value) {
		BigDecimal val = createBigD("1");

		if(getIsBetween(value, str2BigDecimal("0"), str2BigDecimal("1"))) {
			val = str2BigDecimal("0.95");
		} else if(getIsBetween(value, str2BigDecimal("1"), str2BigDecimal("3"))) {
			val = str2BigDecimal("0.9");
		} else if(getIsBetween(value, str2BigDecimal("3"), str2BigDecimal("6"))) {
			val = str2BigDecimal("0.8");
		} else if(getIsBetween(value, str2BigDecimal("6"), str2BigDecimal("12"))) {
			val = str2BigDecimal("0.7");
		} else if(value.compareTo(str2BigDecimal("12"))>0) {
			val = str2BigDecimal("0.6");
		} else {
			val = str2BigDecimal("1");
		}
		return val;
	}
	/**
	 * 厂家设备遗传
	 * @param list 检修记录
	 * @return
	 */
	public static BigDecimal  getCjyc(List<BusiOfflineGisRepairVo> list) {
		BigDecimal val = new BigDecimal("1");
		BigDecimal valFz = new BigDecimal("1");//分子
		if(null != list) {
			val = valFz.subtract(valFz.divide(new BigDecimal(Math.pow(3,list.size())),5,BigDecimal.ROUND_HALF_UP));
		}
		return val;
	}
	/**
	 * 产品成熟度
	 * @param productMaturity
	 * @param eqmCode
	 * @param eqmId
	 * @return
	 */
	public static BigDecimal  getCpcsd(BusiOfflineGisBrandVo busiOfflineGisBrand, String eqmCode) {
		BigDecimal val = new BigDecimal("1");
		BigDecimal val50 = new BigDecimal("50");
		
		if(null != busiOfflineGisBrand) {
			if(!StringUtils.isEmpty(busiOfflineGisBrand.getProductMaturity())) {
				BigDecimal score = str2BigDecimal(busiOfflineGisBrand.getProductMaturity());
//				if(str2BigDecimal(busiOfflineGisBrand.getProductMaturity()).compareTo(val50)<0) {
//					val = new BigDecimal("0.5");
//				}
				if(getIsBetween(score, str2BigDecimal("0"), str2BigDecimal("10"))) {
					val = str2BigDecimal("0.5");
				} else if(getIsBetween(score, str2BigDecimal("10"), str2BigDecimal("20"))) {
					val = str2BigDecimal("0.7");
				} else if(getIsBetween(score, str2BigDecimal("20"), str2BigDecimal("30"))) {
					val = str2BigDecimal("0.92");
				} else if(getIsBetween(score, str2BigDecimal("30"), str2BigDecimal("50"))) {
					val = str2BigDecimal("0.95");
				} else if(str2BigDecimal(busiOfflineGisBrand.getProductMaturity()).compareTo(val50)>=0) {
					val = str2BigDecimal("1");
				}
			}
		}
		return val;
	}
	/**
	 * 知名度（手动录入）标牌
	 * @param productMaturity
	 * @param eqmCode
	 * @param eqmId
	 * @return
	 */
	public static BigDecimal  getZmd(BusiOfflineGisBrandVo busiOfflineGisBrand, String eqmCode) {
		BigDecimal val = new BigDecimal("1");
		if(null != busiOfflineGisBrand) {
			val = str2BigDecimal(busiOfflineGisBrand.getPopularity());
		}
		return val;
	}
	
	/**
	 * BigDecimal非空及非0校验
	 * @param val
	 * @return
	 */
	public static Boolean isNotEmptyForBigDecimal(BigDecimal val) {
		
		Boolean status = true;
		if(null == val || val.compareTo(new BigDecimal("0")) == 0) {
			status = false;
		}
		return status;
	}
	/**
	* 获取两个时间的相差天数
	* @param str
	* @return
	*/
	public static long timeDifference(Date start, Date end) {
		 
		long between = end.getTime() - start.getTime();
		long day = between / (24 * 60 * 60 * 1000);
		return day;
	}
	/**
	 * 数字类型格式化
	 * @param val
	 * @return
	 */
	public static BigDecimal formatNum(BigDecimal val) {
		
		val = val.setScale(5,BigDecimal.ROUND_HALF_UP);
		return val;
	}
	/**
	 * 字符串数字类型格式化
	 * @param val
	 * @return
	 */
	public static BigDecimal formatNumStr(String valStr) {
		
		BigDecimal val = new BigDecimal("0");
		val = str2BigDecimal(valStr);
		val = formatNum(val);
		return val;
	}
	/**
	 * 预期剩余断开次数
	 * @param ljdkcs 累计断开次数
	 * @param ysdkcs 预期断开次数
	 * @return
	 */
	public static BigDecimal formatForSydkcs(BigDecimal ljdkcs, BigDecimal ysdkcs) {
		
		BigDecimal val = new BigDecimal("0");
		if(ysdkcs.compareTo(ljdkcs) > 0) {
			val = ysdkcs.subtract(ljdkcs);
		}
		return val;
	}
	/**
	 * 设置设备状态
	 * @param score
	 * @param gisAssessmentResult
	 * @return
	 */
	public static String getGisStatus(BigDecimal score) {
		String health_level = "";
		if(getIsBetween(score, str2BigDecimal("0"), str2BigDecimal("20"))) {
			health_level = "严重故障";
		} else if(getIsBetween(score, str2BigDecimal("20"), str2BigDecimal("40"))) {
			health_level = "故障";
		} else if(getIsBetween(score, str2BigDecimal("40"), str2BigDecimal("60"))) {
			health_level = "一般";
		} else if(getIsBetween(score, str2BigDecimal("60"), str2BigDecimal("85"))) {
			health_level = "良好";
		} else if(getIsBetween(score, str2BigDecimal("85"), str2BigDecimal("100"))) {
			health_level = "优秀";
		} else {
			health_level = "优秀";
		}
		return health_level;
	}
	
	/**
	 * 设置设备状态
	 * @param score
	 * @param gisAssessmentResult
	 * @return
	 */
	public static String getJxjy(BigDecimal score) {
		String overhaulSuggest = "";
		if(getIsBetween(score, str2BigDecimal("0"), str2BigDecimal("20"))) {
			overhaulSuggest = "立即检修";
		} else if(getIsBetween(score, str2BigDecimal("20"), str2BigDecimal("40"))) {
			overhaulSuggest = "尽快检修";
		} else if(getIsBetween(score, str2BigDecimal("40"), str2BigDecimal("60"))) {
			overhaulSuggest = "计划检修";
		} else if(getIsBetween(score, str2BigDecimal("60"), str2BigDecimal("85"))) {
			overhaulSuggest = "延期检修";
		} else if(getIsBetween(score, str2BigDecimal("85"), str2BigDecimal("100"))) {
			overhaulSuggest = "正常运行";
		} else {
			overhaulSuggest = "正常运行";
		}
		return overhaulSuggest;
	}
	/**
	 * 获取健康水平说明
	 * @param score
	 * @return
	 */
	public static String getJkspsm(BigDecimal score) {
		String overhaulSuggest = "";
		if(getIsBetween(score, str2BigDecimal("0"), str2BigDecimal("20"))) {
			overhaulSuggest = "对运行有严重威胁";
		} else if(getIsBetween(score, str2BigDecimal("20"), str2BigDecimal("40"))) {
			overhaulSuggest = "对运行有现实的威胁";
		} else if(getIsBetween(score, str2BigDecimal("40"), str2BigDecimal("60"))) {
			overhaulSuggest = "对运行存在威胁";
		} else if(getIsBetween(score, str2BigDecimal("60"), str2BigDecimal("85"))) {
			overhaulSuggest = "有一定影响";
		} else if(getIsBetween(score, str2BigDecimal("85"), str2BigDecimal("100"))) {
			overhaulSuggest = "不影响运行";
		} else {
			overhaulSuggest = "不影响运行";
		}
		return overhaulSuggest;
	}
	/**
	 * 创建BigDecimal
	 * @param defVal
	 * @return
	 */
	public static BigDecimal createBigD(String defVal) {
		BigDecimal val = null;
		if(!"".equals(defVal)) {
			val = new BigDecimal(defVal);
		} else {
			val = new BigDecimal("1");
		}
		return val;
	}
	
	/**
	 * BigDecimal数据范围判断
	 * @param val 当前值
	 * @param valMin 
	 * @param valMax
	 * @return
	 */
	private static boolean  getIsBetween(BigDecimal val,BigDecimal valMin,BigDecimal valMax) {
		boolean res = false;
		if(val.compareTo(valMin)>=0 && val.compareTo(valMax)<0) {
			res = true;
		}
		return res;
	}
	/**
	 * BigDecimal数据范围判断(括后不括前)
	 * @param val 当前值
	 * @param valMin 
	 * @param valMax
	 * @return
	 */
	private static boolean  getIsBetweenO(BigDecimal val,BigDecimal valMin,BigDecimal valMax) {
		boolean res = false;
		if(val.compareTo(valMin)>0 && val.compareTo(valMax)<=0) {
			res = true;
		}
		return res;
	}
	/**
	 * 非零判断
	 * @param val
	 * @return
	 */
	private static boolean  isNotZero(BigDecimal val) {
		boolean res = true;
		BigDecimal defVal = createBigD("0");
		if(val.compareTo(defVal)==0) {
			res = false;
		}
		return res;
	}
	//取额定电流
	public static BigDecimal geteddl(BusiOfflineGisBrandVo busiOfflineGisBrand) {
		BigDecimal val = createBigD("0");
		if(null != busiOfflineGisBrand) {
			val = str2BigDecimal(busiOfflineGisBrand.getRatedFrequency()).multiply(new BigDecimal(1000));
		}
		return val;
	}
	
//	/**
//	 * 
//	 * @param v1  排序后的使用年限
//	 * @param v2 断开磨损程度
//	 * @param v3 使用年限权重
//	 * @return
//	 */
//	public static BigDecimal getSynxResult(BigDecimal v1, BigDecimal v2,BigDecimal v3) {
//		BigDecimal tmp = v1.multiply(v2).setScale(4, BigDecimal.ROUND_HALF_UP);
//		return tmp.multiply(v3).setScale(4, BigDecimal.ROUND_HALF_UP);
//	}
	
	/**
	 * 
	 * @param v1  计算值
	 * @param v2 权重1
	 * @param v3 权重2
	 * @return
	 */
	public static BigDecimal calcValue(BigDecimal v1, BigDecimal v2,BigDecimal v3) {
		BigDecimal tmp = v1.multiply(v2).setScale(4, BigDecimal.ROUND_HALF_UP);
		return tmp.multiply(v3).setScale(4, BigDecimal.ROUND_HALF_UP);
	}
	
	/**
	 * 
	 * @param v1  合闸不同期
	 * @param v2
	 * @param v3
	 * @param v4
	 * @param v5
	 * @param v6
	 * @return
	 */
	public static BigDecimal gethzbtqAndfzbtqValue(BigDecimal v1, BigDecimal v2,BigDecimal v3,BigDecimal v4, BigDecimal v5,BigDecimal v6) {
		BigDecimal hzbtq = v1.multiply(v2).setScale(4, BigDecimal.ROUND_HALF_UP);
		BigDecimal fzbtq = v3.multiply(v4).setScale(4, BigDecimal.ROUND_HALF_UP);
		BigDecimal hzbtqresult = hzbtq.add(fzbtq);
		return calcValue(hzbtqresult,v5,v6);
	}
	
	/**
	 * 放电次数计算
	 * @param v1
	 * @param v2
	 * @param v3
	 * @param v4
	 * @param v5
	 * @return
	 */
	public static BigDecimal calcfdcs(BigDecimal v1, BigDecimal v2,BigDecimal v3,BigDecimal v4, BigDecimal v5) {
		BigDecimal hzbtq = v1.multiply(v2).setScale(4, BigDecimal.ROUND_HALF_UP);
		BigDecimal fzbtq = v3.multiply(v4).setScale(4, BigDecimal.ROUND_HALF_UP);
		BigDecimal tmp = hzbtq.add(fzbtq);
		return tmp.multiply(v5).setScale(4, BigDecimal.ROUND_HALF_UP);
	}

	public static BigDecimal calcMultiply(BigDecimal v1, BigDecimal v2) {
		return v1.multiply(v2).setScale(4, BigDecimal.ROUND_HALF_UP);
	}
}
