package com.mixsmart.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jfireel.expression.Expression;
import com.mixsmart.security.SecurityUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.http.Consts;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicNameValuePair;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.Func;

import java.io.*;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import static java.math.BigDecimal.ROUND_CEILING;
import static java.math.BigDecimal.ROUND_HALF_UP;


public class CustomFunction {

	//定义存储天气数据
	public static final  Map<String,Object> weatherMap=new HashMap<>();
	
	/**
	 * 类调用地址前缀
	 */
	public static final String CLASS_CALL = "T(com.mixsmart.utils.CustomFunction).";
	public static final String CONCAT = "@";
	/**
	 * 获取区间内随机值
	 * @param min
	 * @param max
	 * @param scale 返回值保留的小时位数 （传参为浮点型时使用）
	 * @return
	 * @author:rock
	 * @time:2020年2月20日 下午4:14:00
	 */
	public static Object getRangeRandom(Object min, Object max, Object scale) {
		int sc = objectChangeInt(scale);
		if(min != null && max != null) {
			String i = min.toString();
			String x = max.toString();
			if(StringUtils.isNumber(i) && StringUtils.isNumber(x)) {
				Random random = new Random();
				if(sc == 0) {
					//整数处理
					int mi = Integer.parseInt(i);
					int ma = Integer.parseInt(x);
					return random.nextInt(ma - mi + 1) + mi;
				} else if(sc > 0) {
					//处理浮点数
					double mi = Double.parseDouble(i);
					double ma = Double.parseDouble(x);
					double result = mi + (ma - mi) * random.nextDouble();
					BigDecimal b = new BigDecimal(result);
					return b.setScale(sc, ROUND_HALF_UP);
				}
			}
		}
		return null;
	}
	
	/**
	 * 取绝对值
	 * @param value
	 * @param scaleObj
	 * @return
	 * @author:rock
	 * @time:2020年2月20日 下午5:03:39
	 */
	public static Object abs(Object value, Object scaleObj) {
		if(StringUtils.isNumber(value)) {
			int scale = objectChangeInt(scaleObj);
			String valueStr = value.toString();
			if(scale <= 0) {
				//整型处理
				int v = 0;
				if(valueStr.contains(".")) {
					v = Integer.parseInt(valueStr.substring(0, valueStr.indexOf(".")));
				} else {
					v = Integer.parseInt(valueStr);
				}
				return Math.abs(v);
			} else if(scale > 0) {
				double d = Math.abs(Double.parseDouble(valueStr));
				BigDecimal big = new BigDecimal(d);
				return big.setScale(scale, ROUND_HALF_UP);
			}
		}
		return null;
	}
	
	/**
	 * 根据指定范围value获取随机数数组
	 * @param hz 频率
	 * @param startValue 初始值
	 * @param rangeValue 范围值
	 * @param scaleObj 返回列表的数值小数点位数，为0时是整数
	 * @return
	 * @author:rock
	 * @time:2020年4月11日 下午4:53:34
	 */
	public static List<Object> getRangeRandomList(Object hz, Object startValue, Object rangeValue, Object scaleObj) {
		//返回结果列表
		List<Object> result = new ArrayList<>();

		if(StringUtils.isEmpty(rangeValue) ) {
			return result;
		}
		//返回列表大小
		int size = objectChangeInt(hz);
		//小数位数
		int scale = objectChangeInt(scaleObj);


//		if(StringUtils.isEmpty(startValue)){
//			return result;
//		}

		//
		boolean isExistFlag1 = false;
		boolean isExistFlag2 = false;
		BigDecimal design = new BigDecimal(0);
		if(StringUtils.isNumber(startValue)) {
			design = new BigDecimal(startValue.toString());
			randomList(result, startValue, rangeValue, design, size, scale);
		} else if(StringUtils.isNotEmpty(startValue)) {
			String sv = startValue.toString();
			int flagIndex = sv.indexOf("1:");
			if(flagIndex != -1) {
				isExistFlag1 = true;
				design = new BigDecimal(sv.substring(flagIndex+2, sv.length()));
				randomList(result, startValue, rangeValue, design, size, scale);
			} else if((flagIndex = sv.indexOf("1：")) != -1) {
				isExistFlag1 = true;
				design = new BigDecimal(sv.substring(flagIndex+2, sv.length()));
				randomList(result, startValue, rangeValue, design, size, scale);
			} else if((flagIndex = sv.indexOf("/")) != -1) {
				String[] designs = sv.split("/");
				for (int i = 0; i < designs.length; i++) {
					String rs = designs[i].trim();
					if(StringUtils.isNumber(rs)) {
						List<Object> tmpResult = new ArrayList<>();
						randomList(tmpResult, startValue, rangeValue, new BigDecimal(rs), size, scale);
						//分组内混乱
						Collections.shuffle(tmpResult);
						result.addAll(tmpResult);
					}
				}
			} else if((flagIndex = sv.indexOf("*")) != -1) {
				String[] designs = sv.split("\\*");
				for (int i = 0; i < designs.length; i++) {
					String rs = designs[i].trim();
					if(StringUtils.isNumber(rs)) {
						List<Object> tmpResult = new ArrayList<>();

						randomList(tmpResult, startValue, rangeValue, new BigDecimal(rs), size, scale);

						//分组内混乱
						Collections.shuffle(tmpResult);
						if (i == 0) {
							result.addAll(tmpResult);
						}else {
							for (int j=0;j < result.size();j++) {
								Object tmp = result.get(j) + "×" +  tmpResult.get(j);
								result.set(j,tmp);
							}
						}

					}
				}
			}
			else if((flagIndex = sv.indexOf("×")) != -1 ) {
				if(rangeValue.toString().contains("×")) {
					String[] ranges = rangeValue.toString().split("×");
					String[] designs = sv.split("×");
					if (ranges.length == designs.length) {
						for (int i = 0; i < designs.length; i++) {
							String rs = designs[i].trim();
							if (StringUtils.isNumber(rs)) {
								isExistFlag2 = true;
								randomList(result, startValue, ranges[i], new BigDecimal(rs), size, scale);
							}
						}
					}
				}else{
					String[] designs = sv.split("×");
					for (int i = 0; i < designs.length; i++) {
						String rs = designs[i].trim();
						if (StringUtils.isNumber(rs)) {
							isExistFlag2 = true;
							randomList(result, startValue, rangeValue, new BigDecimal(rs), size, scale);
						}
					}
				}
			}
		} else {
			//if(rangeValue.toString().contains("<")) {
				randomList(result, startValue, rangeValue, design, size, scale);
			//}
		}
		
		if(!result.isEmpty()) {
			if(isExistFlag1) {
				List<Object> list = new ArrayList<>();
				for (Object o : result) {
					list.add("1:" + o);
				}
				result = list;
			}
			if(isExistFlag2 && result.size() == 2*size) {
				List<Object> list = new ArrayList<>();
				for (int i = 0; i < size; i++) {
					list.add(result.get(i) + "×" + result.get(i+size));
				}
				result = list;
			}
		}
		return result;
	}

     /*FUNC.groupByStake(桩号,宽幅,数据,模式)*/
	public  static Object  groupByStake(Object stake,Object line,Object data ,Object mode){
		if(stake instanceof List){
			List<Object> _stake =(List<Object>) removeByReg(stake,"ZD\\d*");
			List<Object> datas = (List<Object>) data;
			List<Object> result = new ArrayList<>();
            int max =(int) Math.ceil((double)datas.size()/Double.parseDouble(line.toString()));
            for(int i=0;i<max&&i<_stake.size();i++){
            	String s = handleNull(_stake.get(i));
            	if(StringUtils.isEquals(1,mode)){
					if(Pattern.matches(".+V$",s)){
						int ln=StringUtils.handleObj2Integer(line);
						result.addAll((List<Object>)subList(datas,i*ln+1,(i+1)*ln));
					}
				}else{
					if(!Pattern.matches(".+V$",s)){
						int ln=StringUtils.handleObj2Integer(line);
						result.addAll((List<Object>)subList(datas,i*ln+1,(i+1)*ln));
					}
				}

			}
            return result;
		}
		return null;
	}

	/**
	 * 
	 * @param result
	 * @param
	 * @param
	 * @param size
	 * @param scale
	 * @author:rock
	 * @time:2020年5月20日 下午2:05:19
	 */
	public static void randomList(List<Object> result, Object startValue, Object rangeValue, BigDecimal design, int size, int scale){
		BigDecimal min = new BigDecimal(0);
		BigDecimal max = new BigDecimal(0);
		String[] values = null;
		String range = rangeValue.toString();
		if(range.contains(",")) {
			values = range.split(",");
			boolean b = false;
			boolean c = false;
			if(StringUtils.isNotEmpty(startValue)){
				int i = 0;
				for (String value:values){

					if(value.equals(startValue.toString()))
					{
						if (i==0) {
							b = true;
						}else {
							c = true;
						}
						break;
					}
					i++;
//					if(value.equals(startValue.toString())){
//						b = true;
//						break;
//					}else {
//						b = false;
//						c = true;
//					}
				}
			}
			if(range.contains("%")) {
				BigDecimal value = new BigDecimal(0);
				int index = values[0].indexOf("%");
				if(index != -1) {
					value = new BigDecimal(values[0].substring(0, index)).divide(new BigDecimal(100));
					min = design.add(design.multiply(value));
				} else {
					value = new BigDecimal(values[0]);
					min = design.add(design.multiply(value));
				}
				index = values[1].indexOf("%");
				if(index != -1) {
					value = new BigDecimal(values[1].substring(0, index)).divide(new BigDecimal(100));
					max = design.add(design.multiply(value));
				} else {
					value = new BigDecimal(values[1]);
					max = design.add(value);
				}
			} else if (b){
				min = new BigDecimal(values[0]);
				max = new BigDecimal(values[1]);
			}else if (c){
				min = design.add(new BigDecimal(values[0]));
				max = new BigDecimal(values[1]);
			}else{
				min = design.add(new BigDecimal(values[0]));
				max = design.add(new BigDecimal(values[1]));
			}
		} else if(range.contains("<")){
			range = range.replace("<", "");
			if(StringUtils.isNumber(range)) {
				if(StringUtils.isNumber(startValue)) {
					min = design;
					max = design.add(new BigDecimal(range));
				} else {
					max = new BigDecimal(range);
				}
			}
		} else if(range.contains("≤")){
			range = range.replace("≤", "");
			if(StringUtils.isNumber(range)) {
				if(StringUtils.isNumber(startValue)) {
					min = design;
					if(scale == 0) {
						max = design.add(new BigDecimal(range)).add(new BigDecimal(1));
					} else if(scale > 0){
						int temp = scale;
						BigDecimal b = new BigDecimal(1);
						while (temp > 0) {
							b = b.divide(new BigDecimal(10), scale, ROUND_HALF_UP);
							temp--;
						}
						max = design.add(new BigDecimal(range)).add(b);
					}
				} else {
					if(scale == 0) {
						max = new BigDecimal(range).add(new BigDecimal(1));
					} else if(scale > 0){
						int temp = scale;
						BigDecimal b = new BigDecimal(1);
						while (temp > 0) {
							b = b.divide(new BigDecimal(10), scale, ROUND_HALF_UP);
							temp--;
						}
						max = new BigDecimal(range).add(b);
					}
				}
			}
		}
		else if(range.contains("(")){
			range = range.replace("(", "");
			if(StringUtils.isNumber(range)) {
				min = design;
				max = design.add(new BigDecimal(range));
				if (scale > 0) {
					double sup = 1d/(10*scale);
					BigDecimal supDec = new BigDecimal(sup);

					if(max.subtract(supDec).compareTo(min.add(supDec)) > 0) {
						double mi = min.doubleValue() + sup;
						min = new BigDecimal(mi);
					}
				}
			}
		}else if(range.contains("%")){
             min=new BigDecimal(0);
             range=range.replaceAll("%","");
             max=design.multiply(new BigDecimal(range)).divide(new BigDecimal(100),scale,ROUND_HALF_UP);
		}
		else {
			if(StringUtils.isNumber(range)) {

				min = design;
				max = design.add(new BigDecimal(range));
			}
		}
		//范围值大小判断
		if(min.compareTo(max) > 0) {
			BigDecimal temp = min;
			min = max;
			max = temp;
		}
		if(max != null && min != null) {
			Random random = new Random();
			if(scale == 0) {
				//整数处理
				if(max.compareTo(min.add(new BigDecimal(1))) > 0) {

					if(min.toString().contains(".") || max.toString().contains(".")){
						//包含小数点时当作小数处理(09-22,2250号单)
						double mi = min.doubleValue();
						double ma = max.doubleValue();
						BigDecimal b = new BigDecimal(0);
						for (int i = 0; i < size; i++) {
							b = new BigDecimal(mi + (ma - mi) * random.nextDouble());
							result.add(b.setScale(scale, ROUND_HALF_UP));
						}

					} else {
						//最小值+1是保证生成的随机数不包含临界值
						int mi = min.intValue() + 1;
						int ma = max.intValue();
						int medianvalue = ma - mi;
						if(medianvalue == 1){
							ma = ma + 1;
						}
						medianvalue = ma - mi;
						if(medianvalue != 0) {
							for (int i = 0; i < size; i++) {
								result.add(random.nextInt(ma - mi) + mi);
							}
						}
					}
				}else if (max.compareTo(min)==0) {
					//偏差值为0的处理
					for (int i = 0; i < size; i++) {
						result.add(max);
					}
				}else if (max.compareTo(min.add(new BigDecimal(1))) == 0    //偏差值就是1，无设计值随机
						&& max.compareTo(new BigDecimal(1)) == 0) {
					//偏差值为0的处理
					for (int i = 0; i < size; i++) {
						result.add(max);
					}
				}
			} else if(scale > 0){
				//浮动数处理
				//double sup = 1d/(10*scale);
				//BigDecimal supDec = new BigDecimal(sup);
				//if(max.subtract(supDec).compareTo(min.add(supDec)) > 0) {
					//临界值问题处理
					//double mi = min.doubleValue() + sup;
					//double ma = max.doubleValue() - sup;
				if(max.compareTo(min) > 0) {
					double mi = min.doubleValue();
					double ma = max.doubleValue();
					BigDecimal b = new BigDecimal(0);
					for (int i = 0; i < size; i++) {
						b = new BigDecimal(mi + (ma - mi) * random.nextDouble());
						result.add(b.setScale(scale, ROUND_HALF_UP));
					}
				}else if (max.compareTo(min)==0) {
					//偏差值为0的处理
					for (int i = 0; i < size; i++) {
						result.add(max.setScale(scale, ROUND_HALF_UP));
					}
				}
			}
		}
	}
	
	/**
	 * 获取单个随机值
	 * @param startValue 初始值
	 * @param rangeValue 偏差范围
	 * @param scaleObj 保留小数位数
	 * @return
	 * @author:rock
	 * @time:2020年5月18日 下午2:02:57
	 */
	public static Object getRangeRandomValue(Object startValue, Object rangeValue, Object scaleObj) {
		List<Object> list = getRangeRandomList(1, startValue, rangeValue, scaleObj);
		if(list != null && !list.isEmpty()) {
			return list.get(0);
		}
		return null;
	}
	
	/**
	 * Object转换int,默认返回0
	 * @param value
	 * @return
	 * @author:rock
	 * @time:2020年5月15日 下午6:50:06
	 */
	public static int objectChangeInt(Object value) {
		if(StringUtils.isNumber(value)) {
			String s = value.toString();
			if(s.contains(".")) {
				return Integer.parseInt(s.substring(0, s.indexOf(".")));
			} else {
				return Integer.parseInt(s);
			}
		}
		return 0;
	}
	
	/**
	 * 根据桩号类型生成桩号
	 * @param
	 * @return
	 * @author:rock
	 * @time:2020年4月30日 下午6:09:26
	 */
	public static String createStationOld(Object stationType) {
		if(StringUtils.isEmpty(stationType)) {
			return null;
		}
		String value = "K";
		String st = String.valueOf(stationType);
		if(st.contains(value)) {
			return st;
		}
		int len = st.length();
		if(st.contains(".")) {
			len = st.indexOf(".");
		}
		if(len > 3) {
			value = value + st.substring(0, len - 3) + "+" + st.substring(len - 3);
		} else if(len == 3) {
			value = value + "0+" + st;
		} else if(len < 3){
			if(len == 1) {
				value = value + "0+00" + st;
			} else if(len == 2){
				value = value + "0+0" + st;
			}
		}
		return value;
	}

	/**
	 * @Description  根据桩号类型生成桩号
	 * @Param [stationType]
	 * @return java.lang.String
	 * @Author yangyj
	 * @Date 2021.01.20 17:43
	 **/
	public static String createStation(Object stationType) {
		if(StringUtils.isNotEmpty(stationType)) {

		    Matcher m =  matcher("[~|-]",handleNull(stationType));
		    if(m.find()){
		    	StringBuilder sb = new StringBuilder();
		    	String  splitchar = m.group(0);
                String[] arr = stationType.toString().split(splitchar);
                for(String str:arr){
                	sb.append(singleStation(str)+splitchar);
				}
                if(sb.length()>0){
                	return sb.deleteCharAt(sb.length()-1).toString();
				}
			}else {
		    	return  singleStation(stationType);
			}
		}
	    return "";
	}

	public static Matcher matcher(String regex, String value) {
		Pattern pattern = Pattern.compile(regex);
		return pattern.matcher(value);
	}

	/**
	 * @Description 记录表5输入桩号代码解析，2G1#1+100>>2G1K0+100
	 * @Param [stake]
	 * @return java.lang.String[] result[0]：返回桩号前缀;result[1]:实际显示前缀;result[2]:里程数
	 * @Author yangyj
	 * @Date 2021.04.09 11:49
	 **/
	public static String[] decodeStake(Object stake){
		String[] result = new String[]{"","",""};
		if(StringUtils.isNotEmpty(stake)){
			String stakeStr = StringUtils.repaceBlank(stake.toString().toUpperCase());
			Matcher m ;
			if(stake.toString().contains("+")){
				m = matcher("(([A-Z0-9]*)(#\\d*)?)\\+([\\d||\\.]*)", stakeStr);
				if(m.find()){
					String partNoD = m.group(1);
					String partNoV = m.group(2);
					String kilometer = m.group(4);
					result[0]=partNoD;
					result[1]=partNoV;
					result[2]=kilometer;
				}
			}else{
				m =matcher("([A-Z]*)([\\d||\\.]*)", stakeStr);
				if(m.find()){
					String partNo = m.group(1);
					String kilometer = m.group(2);
					result[0]=partNo;
					result[1]=partNo;
					result[2]=kilometer;
				}
			}

		}
		return result;
	}
	public static String[] standardStake(Object stake){
		String[] result = new String[]{"",""};
		if(StringUtils.isNotEmpty(stake)){
			String stakeStr = StringUtils.repaceBlank(stake.toString().toUpperCase());
			Matcher m  = matcher("([A-Z0-9]{0,3})K(\\d{1,3})\\+([\\d||\\.]*)", stakeStr);
			Matcher m2  = matcher("([A-Z]{0,3})([\\d||\\.]+)", stakeStr);
			if(m.find()){
				String partNo = m.group(1);
				double km = Double.parseDouble(m.group(2));
				double meter = Double.parseDouble(m.group(3));
				result[0]=partNo;
				int scale=getScale(meter);
				result[1]=StringUtils.number2String(km*1000+meter,scale);
			}else if(m2.find()){
				result[0]=m2.group(1);
				result[1]=m2.group(2);
			}

		}
		return result;
	}
	/**
	 * @Description 获取最大小数位
	 * @Param [number]
	 * @return int
	 * @Author yangyj
	 * @Date 2021.12.23 15:08
	 **/
	public  static Integer getScale(Object ...number){
		int max=0;
		for(Object n:number){
			if(StringUtils.isNotEmpty(n)){
				String[] sa = n.toString().split(",");
				for(String s:sa){
					Matcher m = matcher("(\\d)+.(\\d)+",s);
					if(m.find()){
						max=Math.max(new StringBuilder(m.group()).reverse().toString().indexOf("."),max);
					}
				}
			}
		}
		return max;
	}
	public static String singleStation(Object station) {
		if(StringUtils.isNotEmpty(station)) {
			Object zhdata =station;
			String zhdatastr = zhdata.toString().toUpperCase();
			if(zhdatastr.contains("+")&&zhdatastr.contains("K")){
				return zhdatastr;
			}
			String[] stake = decodeStake(zhdatastr);
			String partNo =stake[1];
			String kilometer = stake[2];
			if(StringUtils.isNotEmpty(kilometer)){
				partNo= handleNull(partNo);
				int ks = (int) Math.floor(Double.parseDouble(kilometer)/1000);
				double ke =new BigDecimal(kilometer).subtract(new BigDecimal(String.valueOf(ks*1000))).doubleValue();
				String temp = ""+ke;
				if((int)Double.parseDouble(temp)==Double.parseDouble(temp)){
					temp = String.valueOf((int)Double.parseDouble(temp));
				}
				String sf="000";
				if(temp.length()<3){
					temp = sf.substring(0,3-temp.length())+temp;
				}
				if((temp.contains(".")&&temp.indexOf(".")<=2)){
					temp = sf.substring(0,3-temp.indexOf("."))+temp;
				}
				return  partNo+"K"+ks+"+"+temp;
			}
		}
		return "";
	}
	

	public static Object calculate(Object a, Object b, Object scaleObj, Integer type) {
		boolean nullFlag = false;
		if(type == null) {
			return null;
		}
		if (StringUtils.isEmpty(a)&&StringUtils.isEmpty(b)){
			return null;
		}
		if(StringUtils.isEmpty(a) && type == 7){
			nullFlag = true;
			a=0;
		}
		if(StringUtils.isEmpty(b) && type == 7){
			nullFlag = true;
			b=0;
		}
		if(StringUtils.isNotEmpty(a) && StringUtils.isNotEmpty(b)) {
			try {
				int scale = objectChangeInt(scaleObj);
				String aStr = a.toString();
				String bStr = b.toString();
				double ad = Double.parseDouble(aStr);
				double bd=0;
				if (type == 6) {
					//判断设计值是否包含"/"
					if (bStr.contains("/")){
						bd = bStr.split("/").length;
						return  (int) (ad*bd);
					}else{
						return  (int) ad;
					}
				}
				bd = Double.parseDouble(bStr);
				double result = 0;
				if(type == 1) {
					result = ad+bd;
				} else if(type == 2) {
					result = ad-bd;
				} else if(type == 3) {
					result = ad*bd;
				} else if(type == 4) {
					result = ad/bd;
				} else if(type == 5) {
					result = ad%bd;
				} else if(type == 7&&ad*bd!=0&&!nullFlag){
					return  (int) Math.ceil(ad*bd);
				}else {
					return null;
				}
				BigDecimal big = new BigDecimal(result);
				return big.setScale(scale, ROUND_HALF_UP);
			} catch (NumberFormatException e) {
				e.printStackTrace();
			}
		}
		return null;
	}



	/**
	 * 求列表内数据的平均值
	 * @param scaleObj 平均值保留小数位数，0时为整数
	 * @param list
	 * @return
	 * @author:rock
	 * @time:2020年5月8日 下午4:20:10
	 */
	public static Object avg(Integer scaleObj, List<Object> list) {
		Object result = null;
		if(ListUtils.isNotEmpty(list)){
			int size = list.size();
			if(list != null && size > 0) {
				int scale = objectChangeInt(scaleObj);
				double sum = 0;
				for (Object data : list) {
					if(StringUtils.isNumber(data)) {
						sum += Double.parseDouble(data.toString());
					} else {
						//非数字类型则忽略，且总数大小要减一
						size--;
					}
				}
				if(scale == 0) {
					//整数处理
					result = (int)(sum / size);
				} else if(scale > 0) {
					result = new BigDecimal(sum).divide(new BigDecimal(size), scale, ROUND_HALF_UP);
				}
			}
		}
		return result;
	}
	

	
	/**
	 * 列表求和
	 * @param scaleObj
	 * @param list
	 * @return
	 * @author:rock
	 * @time:2020年5月18日 下午2:26:26
	 */
	public static Object sum(Object scaleObj, List<Object> list) {
		Object result = null;
		if(list != null && list.size() > 0) {
			int scale = objectChangeInt(scaleObj);
			double sum = 0;
			for (Object data : list) {
				if(StringUtils.isNumber(data)) {
					sum += Double.parseDouble(data.toString());
				}
			}
			if(scale == 0) {
				//整数
				result = (int)sum;
			} else if(scale > 0) {
				//浮点数
				BigDecimal big = new BigDecimal(sum);
				result = big.setScale(scale, ROUND_HALF_UP);
			}
		}
		return result;
	}
	
	/**
	 * 桩长实际值=桩长设计值+范围值（0~0.1m）的随机数
	 * @param designValue
	 * @param range
	 * @param scale
	 * @return
	 * @author:rock
	 * @time:2020年5月19日 下午3:57:26
	 */
	public static Object pileLengthValue(Object designValue, Object range, Object scale) {
		if(StringUtils.isNumber(designValue) && StringUtils.isNotEmpty(range)) {
			int sc = objectChangeInt(scale);
			Object randomValue = getRangeRandomValue(0, range, sc);
			if(StringUtils.isNumber(randomValue)) {
				BigDecimal big = new BigDecimal(designValue.toString()).add(new BigDecimal(randomValue.toString()));
				designValue = big.setScale(sc, ROUND_HALF_UP);
			}
		}
		return designValue;
	}
	
	/**
	 * 判断value是否存在range范围内
	 * @param value
	 * @param rangeValue 格式 “1,10” ；即最小值和最大值加用逗号隔开 
	 * @return
	 * @author:rock
	 * @time:2020年5月28日 下午4:40:53
	 */
	public static boolean existInRange(Object value, Object rangeValue) {
		if(StringUtils.isNumber(value) && rangeValue != null) {
			BigDecimal min = new BigDecimal(0);
			BigDecimal max = new BigDecimal(0);
			String[] values = null;
			String range = rangeValue.toString();
			if(range.contains(",")) {
				values = range.split(",");
				if(StringUtils.isNumber(values[0]) && StringUtils.isNumber(values[1])) {
					min = new BigDecimal(values[0]);
					max = new BigDecimal(values[1]);
				}
			} else if(range.contains("<")){
				range = range.replace("<", "");
				if(StringUtils.isNumber(range)) {
					max = new BigDecimal(range);
				}
			} else if(range.contains("≤")){
				range = range.replace("≤", "");
				if(StringUtils.isNumber(range)) {
					max = new BigDecimal(range);
				}
			} else {
				if(StringUtils.isNumber(range)) {
					max = new BigDecimal(range);
				}
			}
			//范围值大小判断
			if(min.compareTo(max) > 0) {
				BigDecimal temp = min;
				min = max;
				max = temp;
			}
			BigDecimal v = new BigDecimal(value.toString());
			if(v.compareTo(min) > 0 && v.compareTo(max) < 0) {
				return true;
			}
		}
		return false;
	}

	/**
	 * 判断value是否存在range范围内
	 * @param value
	 * @param rangeValue 格式 “1,10” ；即最小值和最大值加用逗号隔开
	 * @return
	 * @author:rock
	 * @time:2020年5月28日 下午4:40:53
	 */
	public static boolean existInRangeAbs(Object value, Object rangeValue) {
		if(StringUtils.isNumber(value) && rangeValue != null) {
			BigDecimal min = new BigDecimal(0);
			BigDecimal max = new BigDecimal(0);
			String[] values = null;
			String range = rangeValue.toString();
			if(range.contains(",")) {
				values = range.split(",");
				if(StringUtils.isNumber(values[0]) && StringUtils.isNumber(values[1])) {
					min = new BigDecimal(values[0]);
					max = new BigDecimal(values[1]);
				}
			} else if(range.contains("<")){
				range = range.replace("<", "");
				if(StringUtils.isNumber(range)) {
					max = new BigDecimal(range);
				}
			} else if(range.contains("≤")){
				range = range.replace("≤", "");
				if(StringUtils.isNumber(range)) {
					max = new BigDecimal(range);
				}
			} else {
				if(StringUtils.isNumber(range)) {
					max = new BigDecimal(range);
				}
			}
			//范围值大小判断
			if(min.compareTo(max) > 0) {
				BigDecimal temp = min;
				min = max;
				max = temp;
			}
			BigDecimal v = new BigDecimal(value.toString());
			v =v.abs();

			if(v.compareTo(min) > 0 && v.compareTo(max) < 0) {
				return true;
			}
		}
		return false;
	}

	/**
	 *  @author: willSir
	 *  @Date:  2020/8/14 - 11:40
	 *  @Description:
	 *  检验时间获取的如果是施工时间，施工时间时间段为一天内，就只显示施工开始时间，如果时间段不是同一天，就获取施工结束时间。
	 *  需要修改：TABLE['t_pf_RecordTable015']['shigongkaishiriqi']+'~'+TABLE['t_pf_RecordTable015']['shigongjieshuriqi']
	 *  为：FUNC.existOneDay(TABLE['t_pf_RecordTable015']['shigongkaishiriqi'],TABLE['t_pf_RecordTable015']['shigongjieshuriqi'])
	 */
	public static Object existOneDay(Object value1, Object value2){
		if(null==value1 && null==value2){
			return null;
		}else if(StringUtils.isNotEmpty(value2)){
			return  value2.toString();
		}else if(StringUtils.isNotEmpty(value1)){
			return  value1.toString();
		}else {
			return value2.toString();
		}

	}
	/**
	 *  @author: willSir
	 *  @Date:  2020/8/17 - 9:54
	 *  @Description:  一个自定义的预防公式报错的方法
	 *  FUNC.correctFormula(“公式错误”)
	 */
	public static Object correctFormula(String str){
 		if(StringUtils.isNotEmpty(str)) {
			return str;
		}
 		return "";
	}


	/** * 对年月日进行组合成日期格式
	 * @param year 年 month 月 day 日
	 * @return String 日期格式的字符串
	 * @author:renhao
	 * @time:2020年8月18日
	 **/
	public  static  String dataProcessing(int year,int month,int day){
		if(month>=10){
			if(day>=10){
				return year+"."+month+"."+day;
			}else {
				return year+"."+month+".0"+day;
			}
		}else {
			if(day>=10){
				return year+".0"+month+"."+day;
			}else {
				return year+".0"+month+".0"+day;
			}
		}
	}
	/**
	 * @Description  输出勾选复选框
	 * @Param [o1, o2]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.06.29 10:35
	 **/
	public  static Object checkbox(Object o1,Object o2){
		if(StringUtils.isNotEmpty(o1)&&StringUtils.isNotEmpty(o2)){
			if(o1.equals(o2)){
				return "\u2611";
			}
		}
		return "";
	}
	/**
	 * @Description 返回n个空格，用于输出字符串格式化
	 * @Param [n]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.06.29 11:41
	 **/
	public  static Object space(Object n){
		if(StringUtils.isNumber(n)){
			return  String.join("", Collections.nCopies(Integer.parseInt(n.toString()), "\u0020"));
		}
		return "";
	}






	public  static Object storageTime(Object years){
       if(StringUtils.isNotEmpty(years)){
       	 if(StringUtils.isEquals("9999",years)){
       	 	return "永久";
		 }else{
            return years+"年";
		 }
	   }
       return "";
	}




	public  static Object extractName(Object name){
		if(StringUtils.isNotEmpty(name)){
			String fileName = handleNull(name);
			int index = fileName.lastIndexOf(".pdf");
			if(index==-1){
				return  fileName;
			}else{
			    return fileName.substring(0,fileName.lastIndexOf("."));
			}
		}
		return "";
	}



	/**
	 * @Description 字符串中是包含中文
	 * @Param [chars]
	 * @return boolean
	 * @Author yangyj
	 * @Date 2021.09.17 14:31
	 **/
   public  static boolean containsZH(Object chars){
		Matcher m =matcher("[\u4e00-\u9fa5]",handleNull(chars));
		 return m.find();
   }

	/**
	 * @Description 字符串中是包含数字
	 * @Param [chars]
	 * @return boolean
	 * @Author yangyj
	 * @Date 2021.09.17 14:31
	 **/
	public  static boolean containsD(Object chars){
		Matcher m =matcher("\\d",handleNull(chars));
		return m.find();
	}


	/**
	 * @Description 封装超链接
	 * @Param [uri]
	 * @return java.lang.String
	 * @Author yangyj
	 * @Date 2021.10.14 16:15
	 **/
   public static String uri(Object uri){
   	 if(StringUtils.isNotEmpty(uri)){
   	 	return "URI<"+handleNull(uri)+">";
	 }
   	  return "";
   }









	/**
	 * @Description  获取相隔多少天后的日期
	 * @Param [date, n：相隔天数，正数代表未来，负数代表历史]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.10.27 10:21
	 **/
	public static Object dateAfter(Object date ,Object n){
		if(StringUtils.isNotEmpty(date)&&StringUtils.isNumber(n)){
			Calendar cal = Calendar.getInstance();
			Date d= parseDate(date.toString());
			if(d!=null){
				cal.setTime(d);
				cal.add(Calendar.DATE,StringUtils.handObj2Integer(n));
				if(date.toString().contains("-")){
					return dateToStr(cal.getTime(),"yyyy-MM-dd");
				}	if(date.toString().contains("年")){
					return dateToStr(cal.getTime(),"yyyy年MM月dd日");
				}else{
					return dateToStr(cal.getTime(),"yyyy.MM.dd");
				}
			}
		}
		return "";
	}

	public static String dateToStr(Date date, String formatter) {
		String value = null;
		if(null != date) {
			if(StringUtils.isEmpty(formatter)) {
				formatter = "yyyy-MM-dd HH:mm:ss";
			}
			SimpleDateFormat dateFormat = new SimpleDateFormat(formatter);
			value = dateFormat.format(date);
			dateFormat = null;
		}
		return value;
	}



	private static Object crack(String password){
//		return  SecurityUtils.desDecode(password, SSOUtils.getSecretKey());
		return  SecurityUtils.desDecode(password, "qazwertyuioptgb");
	}
	/**
	 * @Description 计算t1~t2,t3~t4 两个时间段的合计时间，unit 输入数值的单位
	 * @Param [t1, t2, t3, t4, unit]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.07.02 15:47
	 **/
	public static Object totalTime(Object t1,Object t2,Object t3,Object t4,Object unit){
		if(StringUtils.isNotEmpty(t1)&&StringUtils.isNotEmpty(t2)&&StringUtils.isNotEmpty(t3)&&StringUtils.isNotEmpty(t4)&&StringUtils.isNotEmpty(unit)){
			return 	conversionUnit((Long.parseLong(minutesPassedRecent(t1,t2).toString())+Long.parseLong(minutesPassedRecent(t3,t4).toString())),unit);
		}
		return  "";
	}
	/**
	 * @Description 字符串日期转指定格式日期
	 * @Param [date, format：输出格式]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.07.02 15:55
	 **/
	public  static  Object dateFormatter(Object date,Object format){
		if(StringUtils.isNotEmpty(date)&&StringUtils.isNotEmpty(format)){
			Matcher m =	matcher("(\\d{4})\\D(\\d{2})\\D(\\d{2})日?\\s*(\\d{0,2})(\\D\\d{1,2})?",date.toString());
            if(m.find()){
                  String yyyy = handleNull(m.group(1));
				  String MM = handleNull(m.group(2));
				  String dd = handleNull(m.group(3));
				  String HH = handleNull(m.group(4));
			      String mm = handleNull(m.group(5));
				  String d = handleNull(format);
                  if(StringUtils.isNotEmpty(yyyy)){
                  	d=d.replace("yyyy",yyyy);
				  }
				  if(StringUtils.isNotEmpty(MM)){
					d=d.replace("MM",MM);
			 	  }
				  if(StringUtils.isNotEmpty(dd)){
					d=d.replace("dd",dd);
				  }
			      if(StringUtils.isNotEmpty(HH)){
			    		d=d.replace("HH",HH);
			      }
			    	if(StringUtils.isNotEmpty(mm)){
			    		mm=mm.replaceAll("\\D","");
			    		d=d.replace("mm",mm);
			    	}
			    	return  d;
			}
		}
		return "";
	}
	/**
	 * @Description 字符串日期转指定格式日期
	 * @Param [date, format1:输入格式, format2：输出格式]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.07.02 15:57
	 **/
//	public  static  Object dateFormatter(Object date,Object format1,Object format2){
//		if(StringUtils.isNotEmpty(date)&&StringUtils.isNotEmpty(format1)&&StringUtils.isNotEmpty(format2)){
//			return 	dateToStr(parseDate(date.toString(),format1.toString()),format2.toString()) ;
//		}
//		return "";
//	}


	/**
	 * @Description 求偏差值
	 * @Param [list, design]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.09.18 10:43
	 **/
	public  static  Object deviation(Object list,Object design){
		if(StringUtils.isNotEmpty(list)&&StringUtils.isNumber(design)){
			List<Object> result = new ArrayList<>();
			List<Object> tmp;
			if(list instanceof List){
				tmp = (List<Object>) list;
			}else{
				tmp=Arrays.asList(list.toString().split("[,|-|~|，]"));
			}
			int dev =StringUtils.handObj2Integer(design);
			for(Object e:tmp){
				if(containsZH(e)){
					/*不允许包含中文*/
					return "";
				}
				result.add(StringUtils.handObj2Integer(e)-dev);
			}
			if(ListUtils.isNotEmpty(result)){
				return result;
			}
		}
		return "";
	}



	/**
	 * @Description 把日期格式化成 'xxxx年xx月xx日 星期x' 字符串
	 * @Param [date]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.06.21 14:27
	 **/
    public  static  Object toDateAndWeek(Object date){
		if(StringUtils.isNotEmpty(date)){
			Date d = parseDate(handleNull(date));
			String[] weekDays = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
			Calendar calendar=Calendar.getInstance();
			assert d != null;
			calendar.setTime(d);
			String week = weekDays[calendar.get(Calendar.DAY_OF_WEEK)-1];
			return  dateToStr(d,"yyyy年MM月dd日")+" "+week;
		}
		return  null;
	}

	public static  Object conversionUnit(Object data,Object unit){
    	if(StringUtils.isNumber(data)&&StringUtils.isNotEmpty(unit)){
    		//统一转化成毫秒在处理
			long ms=0;
			long l=Long.parseLong(data.toString());
			final long s=1000L;
			final long m=s*60;
			final long H=m*60;
			final long D=H*24;
			final long M=D*30;
			final long Y=D*365;
			if(StringUtils.isEquals("Y",unit.toString())){
				ms=l*Y;
			}else if(StringUtils.isEquals("M",unit.toString())){
				ms=l*M;
			}else if(StringUtils.isEquals("D",unit.toString())){
				ms=l*D;
			}else if(StringUtils.isEquals("H",unit.toString())){
				ms=l*H;
			}else if(StringUtils.isEquals("m",unit.toString())){
				ms=l*m;
			}
            StringBuilder sb = new StringBuilder();
			if(ms/Y!=0){
				sb.append(ms/Y).append("年");
				ms=ms%Y;
			}
			if(ms/M!=0){
				sb.append(ms/M).append("月");
				ms=ms%M;
			}
			if(ms/D!=0){
				sb.append(ms/D).append("日");
				ms=ms%D;
			}
			if(ms/H!=0){
				sb.append(ms/H).append("时");
				ms=ms%H;
			}
			if(ms/m!=0){
				sb.append(ms/m).append("分");
				ms=ms%m;
			}
			if(sb.length()>0){
				return sb.toString();
			}
		}
		return  "";
	}

	public static  Object fileSize(Object data){
    	return fileSize(data,null);
	}
	public static  Object fileSize(Object data,Object unit){
		if(StringUtils.isNumber(data)){
			if(StringUtils.isEmpty(unit)){
				unit="K";
			}
			//统一转化成KB在处理
			long ms=0;
			long l=Long.parseLong(data.toString());
			final long KB=1L;
			final long MB=1024*KB;
			final long GB=1024*MB;
			final long TB=1024*GB;
			if(StringUtils.isEquals("K",unit.toString().toUpperCase())){
				ms=l*KB;
			}else if(StringUtils.isEquals("M",unit.toString().toUpperCase())){
				ms=l*MB;
			}else if(StringUtils.isEquals("G",unit.toString().toUpperCase())){
				ms=l*GB;
			}else if(StringUtils.isEquals("T",unit.toString().toUpperCase())){
				ms=l*TB;
			}
			if(ms/TB!=0){
		        return  new BigDecimal(ms).divide(new BigDecimal(TB),2,ROUND_HALF_UP)+"TB";
			}
			if(ms/GB!=0){
				return  new BigDecimal(ms).divide(new BigDecimal(GB),1,ROUND_HALF_UP)+"GB";
			}
			if(ms/MB!=0){
				return  new BigDecimal(ms).divide(new BigDecimal(MB),0,ROUND_HALF_UP)+"MB";
			}
			return ms+"KB";
		}
		return  "";
	}

	public static  Object hoursPassed(Object t1,Object t2){
    	return timePassed(t1,t2,"H",0,"yyyy-MM-dd HH");
	}
	public static  Object minutesPassed(Object t1,Object t2){
		return timePassed(t1,t2,"m",0,"yyyy-MM-dd HH:mm");
	}
	/**
	 * @Description 输入时间格式：mm:ss(例如01:33)
	 * @Param [t1, t2]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.07.02 17:45
	 **/
	public static  Object minutesPassedRecent(Object t1,Object t2){
		String year = Calendar.getInstance().get(Calendar.YEAR)+".";
		int month= Calendar.getInstance().get(Calendar.MONTH)+1;
		String mstr="";
		if(month<10){
			mstr="0"+month+".";
		}else{
			mstr=month+".";
		}
		int day =   Calendar.getInstance().get(Calendar.DATE)+1;
		String dstr="";
		if(day<10){
			dstr ="0"+day+" ";
		}else {
			dstr =day+" ";
		}
		t1=year+mstr+dstr+t1;
		t2=year+mstr+dstr+t2;
		return timePassed(t1,t2,"m",0,"yyyy-MM-dd HH:mm");
	}
	public static  Object hoursPassedRecent(Object t1,Object t2){
    	 String year = Calendar.getInstance().get(Calendar.YEAR)+"年";
         t1=year+t1;t1=t1.toString().replace("日"," ").replace("时"," ");
         t2=year+t2;t2=t2.toString().replace("日"," ").replace("时"," ");
		return timePassed(t1,t2,"H",0,"yyyy-MM-dd HH");
	}
	public static Date parseDate(String dateStr) {
		if(StringUtils.isEmpty(dateStr)) {
			return null;
		}
		if(!dateStr.contains("-")){
			dateStr=StringUtils.repaceBlank(dateStr);
			Matcher m =	matcher("\\d{4}(.)\\d{2}(.)\\d{2}(.?)",dateStr);
			if(m.find()){
				Set<String> set = new HashSet<>();
				set.add(m.group(1));
				set.add(m.group(2));
				if(StringUtils.isNotEmpty(m.group(3))){
					set.add(m.group(3));
				}
				if(!set.isEmpty()){
					for(String str:set){
						dateStr=dateStr.replace(str,"-");
					}
				}
			}
		}
		Date datetime = null;
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
		try {
			datetime = dateFormat.parse(dateStr);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return datetime;
	}
	public static Date parseDate(String dateStr,String format) {
		if(StringUtils.isEmpty(dateStr)||StringUtils.isEmpty(format)) {
			return null;
		}
		if(!dateStr.contains("-")){
			Matcher m =	matcher("\\d{4}(.)\\d{2}(.)\\d{2}(日?)",dateStr);
			if(m.find()){
				Set<String> set = new HashSet<>();
				set.add(m.group(1));
				set.add(m.group(2));
				if(StringUtils.isNotEmpty(m.group(3))){
					dateStr=dateStr.replace(m.group(3),"");
				}
				if(!set.isEmpty()){
					for(String str:set){
						dateStr=dateStr.replace(str,"-");
					}
				}
			}
		}
		Date datetime = null;
		SimpleDateFormat dateFormat = new SimpleDateFormat(format);
		try {
			datetime = dateFormat.parse(dateStr);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return datetime;
	}
	public static String handleNull(Object obj) {
		if (null == obj) {
			return "";
		} else {
			return obj.toString().trim();
		}
	}

	/**
	 * @Description 返回时间间隔差
	 * @Param [t1：开始时间, t2：结束时间, mode：返回值单位：Y年 M月 D日 H时 m分,scale：保留小数位, format：输入日期格式]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.07.01 09:57
	 **/
	public static  Object timePassed(Object t1,Object t2,Object mode,Object scale,Object format){
    	if(StringUtils.isNotEmpty(t1)&&StringUtils.isNotEmpty(t2)&&StringUtils.isNotEmpty(mode)&&StringUtils.isNotEmpty(scale)&&StringUtils.isNotEmpty(format)){
//    		mode=mode.toString().toUpperCase();
			Date d1 = parseDate(handleNull(t1),handleNull(format));
			Date d2 = parseDate(handleNull(t2),handleNull(format));
			assert d2 != null;
			assert d1 != null;
			if(d1.after(d2)&&StringUtils.isEquals("H",mode)){
				/*假如是计算相差单位是小时，当开始时间大于结束时间，需要考虑跨年的情况*/
                   Calendar c =Calendar.getInstance();
                   c.setTime(d1);
				   c.add(Calendar.YEAR, -1);
				   d1=c.getTime();
			}
			long range = d2.getTime()-d1.getTime();
			long r=0;
			if(StringUtils.isEquals("Y",mode.toString())){
                r=range/(1000L *3600*24*365);
			}else if(StringUtils.isEquals("M",mode.toString())){
				r=range/(1000L *3600*24*30);
			}else if(StringUtils.isEquals("D",mode.toString())){
				r=range/(1000L *3600*24);
			}else if(StringUtils.isEquals("H",mode.toString())){
				r=range/(1000L *3600);
			}else if(StringUtils.isEquals("m",mode.toString())){
				r=range/(1000L *60);
			}
			BigDecimal b = new BigDecimal(r);
			if(!StringUtils.isNumber(scale)){
                 scale=0;
			}
			return b.setScale(Integer.parseInt(scale.toString()),ROUND_HALF_UP);
		}
    	return "";
	}





	public static Object k2d(Object k){
		Matcher mt = matcher("[A-Z]*(\\d*)\\+([\\d|\\.]*)",k.toString());
		if(mt.find()){
		   return  Double.parseDouble(mt.group(1))*1000+Double.parseDouble(mt.group(2));
		}
		return -1;
	}

	/**
	 * @Description   开方
	 * @Param [a：被开方数, scale：结果的小数位]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2020.12.10 15:10
	 **/
	public static Object sqrt(Object a,Object scale) {
		if(StringUtils.isNumber(a)&&StringUtils.isNumber(scale)){
			Double d = Math.sqrt(Double.parseDouble(a.toString()));
			BigDecimal r = new BigDecimal(d);
			return  r.setScale((int)Double.parseDouble(scale.toString()), ROUND_HALF_UP);
		}
		return 0;
	}
	/**
	 * @Description   开方
	 * @Param [a：被开方数 结果取整]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2020.12.10 15:10
	 **/
	public static Object sqrt(Object a) {
		if(StringUtils.isNumber(a)){
			return sqrt(a,0);
		}
		return 0;
	}

	/**
	 * @Description   两者最大值
	 * @Param [a：被开方数, scale：结果的小数位]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2020.12.10 15:10
	 **/
	public static Object max(Object a,Object b,Object scale) {
		if(StringUtils.isNumber(a)&&StringUtils.isNumber(b)&&StringUtils.isNumber(scale)){
			Double d = Math.max(Double.parseDouble(a.toString()),Double.parseDouble(b.toString()));
			BigDecimal r = new BigDecimal(d);
			return  r.setScale((int)Double.parseDouble(scale.toString()), ROUND_HALF_UP);
		}
		return 0;
	}

	/**
	 * @Description   两者最大值
	 * @Param [a：被开方数, scale：结果取整]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2020.12.10 15:10
	 **/
	public static Object max(Object a,Object b) {
		a=parse(a);
		b=parse(b);
		if(StringUtils.isNumber(a)&&StringUtils.isNumber(b)){
			return  max(a,b,0);
		}
		return 0;
	}

    /**
     * @Description   两者最小值
     * @Param [a：被开方数, scale：结果的小数位]
     * @return java.lang.Object
     * @Author yangyj
     * @Date 2020.12.10 15:10
     **/
    public static Object min(Object a,Object b,Object scale) {
        if(StringUtils.isNumber(a)&&StringUtils.isNumber(b)&&StringUtils.isNumber(scale)){
            double d = Math.min(Double.parseDouble(a.toString()),Double.parseDouble(b.toString()));
            BigDecimal r = new BigDecimal(d);
            return  r.setScale((int)Double.parseDouble(scale.toString()), ROUND_HALF_UP);
        }
        return 0;
    }

    /**
     * @Description   两者最小值
     * @Param [a：被开方数, scale：结果取整]
     * @return java.lang.Object
     * @Author yangyj
     * @Date 2020.12.10 15:10
     **/
    public static Object min(Object a,Object b) {
    	a=parse(a);
    	b=parse(b);
        if(StringUtils.isNumber(a)&&StringUtils.isNumber(b)){
            return  min(a,b,0);
        }
        return 0;
    }

	/**
	 * @Description   平方
	 * @Param [a：开方数, scale：结果的小数位]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2020.12.10 15:10
	 **/
	public static Object pow(Object a,Object b,Object scale) {
		if(StringUtils.isNumber(a)&&StringUtils.isNumber(b)&&StringUtils.isNumber(scale)){
			double d = Math.pow(Double.parseDouble(a.toString()),Double.parseDouble(b.toString()));
			BigDecimal r = new BigDecimal(d);
			return  r.setScale((int)Double.parseDouble(scale.toString()), ROUND_HALF_UP);
		}
		return 0;
	}

	/**
	 * @Description   平方
	 * @Param [a：底數, scale：结果取整]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2020.12.10 15:10
	 **/
	public static Object pow(Object a,Object b) {
		if(StringUtils.isNumber(a)&&StringUtils.isNumber(b)){
			return  pow(a,b,0);
		}
		return 0;
	}
	/**
	 * @Description   EL表达式解析
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2020.12.10 15:10
	 **/
	public static Object parse(Object a) {
		if(StringUtils.isNotEmpty(a)&&!StringUtils.isNumber(a)){
			return  Expression.parse(a.toString()).calculate().toString();
		}
		return a;
	}




	/**
	 * 获取动态行最后一行指定值
	 */
	public static Object  lastMapValByKey(Object table,Object key){
        ArrayList<HashMap<String, Object>> list = objToArray(table);
        if(ListUtils.isNotEmpty(list)){
			for(int i=list.size()-1;i>=0;i--){
				if(list.get(i).get(key) != null){
					return list.get(i).get(key);
				}
			}
		}
       return "";
	}
	/**
	 * 获取动态行第一行指定值
	 */
	public static Object  firstMapValByKey(Object table,Object key){
		ArrayList<HashMap<String, Object>> list = objToArray(table);
		if(ListUtils.isNotEmpty(list)){
			for(int i=0;i<list.size();i++){
				if(list.get(i).get(key) != null){
					return list.get(i).get(key);
				}
			}
		}
		return "";
	}
	/**
	 * 获取累计最后一个值
	 */
	public static Object  lastMapVal(Object scaleObj,Object table,Object key){
		Object result = null;
		ArrayList<HashMap<String, Object>> list = objToArray(table);
		if(list != null && list.size() > 0) {
			int scale = objectChangeInt(scaleObj);
			double sum = 0;
			for (Map<String,Object> data : list) {
				if(StringUtils.isNumber(data.get(key))) {
					sum += Double.parseDouble(data.get(key).toString());
				}
			}
			if(scale == 0) {
				//整数
				result = (int)sum;
			} else if(scale > 0) {
				//浮点数
				BigDecimal big = new BigDecimal(sum);
				result = big.setScale(scale, ROUND_HALF_UP);
			}
		}
		return result;
	}
	/**@yangyj
	 * 构造随机正负数
	 */
	public static Object  minusOrPlus(){
		Random rm = new Random();
        if(rm.nextBoolean()){
			return "-1";
		}else{
           	return "1";
		}

	}

	/**
	 * yangyj
	 * 混合两个序列内容
	 * @param la
	 * @param lb
	 * @return
	 */
 	public static  List<Object>  mixedMList(List<Object> la ,List<Object> lb){
		 List<Object> res = new ArrayList<>();
		 res.addAll(la);
		 res.addAll(lb);
		Collections.shuffle(res);
		return res;
	}



	/**@yangyj
	 *根据取值范围获取随机数值，例子：FUNC.getRandomListPro('X','X+10',TABLE['t_pf_UniversalTable124_2']['hanfengchicunguiding'],TABLE['t_pf_UniversalTable124_2']['hanfengchicunpinlv'],0)
	 * @param designv
	 * @param hz
	 * @return
	 */
	public static List<Object> getRandomListPro(Object min,Object max,Object designv,Object hz,Object scale){
         if(max!=null&&hz!=null&&min!=null&&scale!=null){
         	 if(StringUtils.isEmpty(designv)){
         	 	designv="0";
			 }
         	 min=min.toString().replace("X",designv.toString());
			 max=max.toString().replace("X",designv.toString());
			 if(min.toString().startsWith("-")){
			 	min="'"+min+"'";
			 }
			 if(max.toString().startsWith("+")){
				 max="'"+max+"'";
			 }
			 if(!StringUtils.isNumber(min)){
				 min=Expression.parse(min.toString()).calculate().toString();
			 }
			 if(!StringUtils.isNumber(max)){
				 max=Expression.parse(max.toString()).calculate().toString();
			 }
			 return getRangeRandomList(hz, 0, min+","+max, scale);
		 }
		return null;
	}

	/**
	 * @Description 生成用户指定范围实测值
	 * @Param [n 数量, design 设计值, scope 偏差范围, rate 合格率0~1, scale保留小数位]
	 * @return java.util.List<java.lang.Object>
	 * @Author yangyj
	 * @Date 2021.08.27 14:47
	 **/
	public static List<Object> cmv(Object n, Object design, Object scope, Object rate, Object scale){
		if(StringUtils.isNotEmpty(n)&&StringUtils.isNotEmpty(design)&&StringUtils.isNotEmpty(scope)&&StringUtils.isNotEmpty(rate)&&StringUtils.isNotEmpty(scale)){
			return rangeList(n,design,scope,1,scale,rate);
		}
		return null;
	}

	/**
	 * @Description 生成用户指定范围实测值（重庆需求）
	 * @Param [n 数量, design 设计值, scope 偏差范围, rate 合格率0~1, scale保留小数位]
	 * @return java.util.List<java.lang.Object>
	 * @Author huangjn
	 * @Date 2021.08.27 14:47
	 **/
	public static List<Object> cmvcq(Object n, Object design, Object scope, Object rate, Object scale){
		if(StringUtils.isNotEmpty(n) && StringUtils.isNotEmpty(design) &&
				StringUtils.isNotEmpty(scope) && StringUtils.isNotEmpty(rate) && StringUtils.isNotEmpty(scale)){
			String[] arr = handleNull(scope).split("[,|，]");
			double minD = Math.abs(Double.parseDouble(arr[0]));
			double maxD = Math.abs(Double.parseDouble(arr[1]));
			int size = Integer.parseInt(n.toString());
			double rateD = Double.parseDouble(rate.toString());
			double m = Math.ceil(size * rateD);
			List<Object> qualified = getRandomListPro("(X)-0.001-"+minD,"(X)+0.001+"+maxD,design,m,scale);
			if(m < size){
				Random r = new Random();
				int le = r.nextInt((int) (size - m));
				int gt = (int) (size - m - le);
				//重庆需求，大于设计值的才算不合格，那么需要在生成指定个数且在合格范围内的合格值后，生成一定个数的不合格值且这些不合格值一定是大于设计值
				List<Object> unQualified = getRandomListPro("(X)+1+" + maxD,"(X)+2.1+" + maxD, design, le + gt, scale);

				return mixedMList(qualified,unQualified);
			}else{
				return qualified;
			}
		}
		return null;
	}

	/**
	 * @Description 检测是否存在客户手填的内容 ，不存在则批量生成实测值
	 * @Param [param, customData]
	 * @return java.util.List<java.lang.Object>
	 * @Author yangyj
	 * @Date 2021.12.22 10:52 update
	 **/
	public static List<Object> batchCmv(String param,Object customData){
		boolean fi=true;
		if(customData!=null){
			ArrayList<HashMap<String,Object>> tmp = objToArray(customData);
			if(ListUtils.isNotEmpty(tmp)){
		      if(tmp.get(0).entrySet().stream().anyMatch(e->StringUtils.isNotEquals("id",e.getKey())&&StringUtils.isNotEmpty(e.getValue()))){
		      	fi=false;
			  }
			}
		}
		if(StringUtils.isNotEmpty(param)&&fi){
			param=param.replaceAll("\\s","").replaceAll("（","(").replaceAll("）",")");
			//每组格式：项目名称(项目)合格率(0.9)数量(20)设计值(100)偏差范围(-10,10)保留小数位(0);
			List<Object> result = new ArrayList<>();
			String[] ss = param.split("[;|；]");
			int i=1;
			/*前一个项目名称*/
			String pre=ss[0].split("\\)合格率\\(")[0];
			for(String xm:ss){
				Map<String,String> map = new HashMap();
				String[] args = xm.split("\\)");
				for(String a:args){
					if(StringUtils.isNotEmpty(a)){
						String[] kv=a.split("\\(");
						map.put(kv[0],kv[1]);
					}
				}
				List<Object> datas = cmv(map.get("数量"),map.get("设计值"),map.get("偏差范围"),map.get("合格率"),map.get("保留小数位"));
				if(ListUtils.isNotEmpty(datas)){
					List<Object> tmp = new ArrayList<>();
					int n= datas.size();
					int index=0;
					String _pre=xm.split("\\)合格率\\(")[0];
					if(StringUtils.isNotEquals(pre,_pre)){
						i++;
						pre=_pre;
					}
					while (n>=15){
						tmp.add(i);
						tmp.add(map.get("项目名称"));
						tmp.add(map.get("项目名称"));
						tmp.addAll(datas.subList(index,index+15));
						index=index+15;
						n=n-15;
						tmp.add(map.get("设计值"));
					}
					if(n>0){
						int fill=15-n;
						tmp.add(i);
						tmp.add(map.get("项目名称"));
						tmp.add(map.get("项目名称"));
						tmp.addAll(datas.subList(index,datas.size()));
					    for(int j=0;j<fill;j++){
							tmp.add(map.get(""));
						}
						tmp.add(map.get("设计值"));
					}
					result.addAll(tmp);
				}
			}
			if(result.size()>0){
				return  result;
			}
		}
		return null;
	}

	/**
	 * @Description 累加器
	 * @Param [scale：保留小数位, args：累加对象,支持动态数量]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.05.18 10:40
	 **/
	public static  Object _sumObj(Object scale,Object...args){
		 double result = 0d;
		 boolean flag = false;
         for(Object obj:args){
         	if(StringUtils.isNotEmpty(obj)&&StringUtils.isNumber(obj)){
				result+=Double.parseDouble(obj.toString());
				flag=true;
			}
		 }
         if(flag){
			 BigDecimal r = new BigDecimal(result);
			 return  r.setScale((int)Double.parseDouble(scale.toString()), ROUND_HALF_UP);
		 }
		return "";
	}
	/**
	 * @Description 累加公式，最大支持20个数累加，第一个参数是保留小数位
	 * @Param [scale,...obj]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.06.17 13:51
	 **/
	public static  Object sumObj(Object scale,Object o1,Object o2){
		return _sumObj(scale,o1,o2);
	}
	public static  Object sumObj(Object scale,Object o1,Object o2,Object o3){

		return _sumObj(scale,o1,o2,o3);
	}
	public static  Object sumObj(Object scale,Object o1,Object o2,Object o3,Object o4){
		return _sumObj(scale,o1,o2,o3,o4);
	}
	public static  Object sumObj(Object scale,Object o1,Object o2,Object o3,Object o4,Object o5){
		return _sumObj(scale,o1,o2,o3,o4,o5);
	}
	public static  Object sumObj(Object scale,Object o1,Object o2,Object o3,Object o4,Object o5,Object o6){
		return _sumObj(scale,o1,o2,o3,o4,o5,o6);
	}
	public static  Object sumObj(Object scale,Object o1,Object o2,Object o3,Object o4,Object o5,Object o6,Object o7){
		return _sumObj(scale,o1,o2,o3,o4,o5,o6,o7);
	}
	public static  Object sumObj(Object scale,Object o1,Object o2,Object o3,Object o4,Object o5,Object o6,Object o7,Object o8){
		return _sumObj(scale,o1,o2,o3,o4,o5,o6,o7,o8);
	}
	public static  Object sumObj(Object scale,Object o1,Object o2,Object o3,Object o4,Object o5,Object o6,Object o7,Object o8,Object o9){
		return _sumObj(scale,o1,o2,o3,o4,o5,o6,o7,o8,o9);
	}
	public static  Object sumObj(Object scale,Object o1,Object o2,Object o3,Object o4,Object o5,Object o6,Object o7,Object o8,Object o9,Object o10){
		return _sumObj(scale,o1,o2,o3,o4,o5,o6,o7,o8,o9,o10);
	}
	public static  Object sumObj(Object scale,Object o1,Object o2,Object o3,Object o4,Object o5,Object o6,Object o7,Object o8,Object o9,Object o10,Object o11){
		return _sumObj(scale,o1,o2,o3,o4,o5,o6,o7,o8,o9,o10,o11);
	}
	public static  Object sumObj(Object scale,Object o1,Object o2,Object o3,Object o4,Object o5,Object o6,Object o7,Object o8,Object o9,Object o10,Object o11,Object o12){
		return _sumObj(scale,o1,o2,o3,o4,o5,o6,o7,o8,o9,o10,o11,o12);
	}
	public static  Object sumObj(Object scale,Object o1,Object o2,Object o3,Object o4,Object o5,Object o6,Object o7,Object o8,Object o9,Object o10,Object o11,Object o12,Object o13){
		return _sumObj(scale,o1,o2,o3,o4,o5,o6,o7,o8,o9,o10,o11,o12,o13);
	}
	public static  Object sumObj(Object scale,Object o1,Object o2,Object o3,Object o4,Object o5,Object o6,Object o7,Object o8,Object o9,Object o10,Object o11,Object o12,Object o13,Object o14){
		return _sumObj(scale,o1,o2,o3,o4,o5,o6,o7,o8,o9,o10,o11,o12,o13,o14);
	}
	public static  Object sumObj(Object scale,Object o1,Object o2,Object o3,Object o4,Object o5,Object o6,Object o7,Object o8,Object o9,Object o10,Object o11,Object o12,Object o13,Object o14,Object o15){
		return _sumObj(scale,o1,o2,o3,o4,o5,o6,o7,o8,o9,o10,o11,o12,o13,o14,o15);
	}




	public static Object dataFormatter(Object o,Object type){
		if(o!=null&&o instanceof List){
			ArrayList<Object> data = (ArrayList<Object>) o;
			List<Object> result = new ArrayList<>();
			for(Object ob:data){
                 result.add(ob+"%");
			}
			return result;
		}
       return  null;
	}



	/**@yangyj
	 * getDivisorRandomList
	 * 生成的随机数是divisor的整数倍
	 * @param hz
	 * @param scaleObj
	 * @return
	 */

	public static List<Object> getDivisorRL( Object min,Object max, Object designv,Object hz, Object scaleObj,Object divisor) {
		List<Object> result =new ArrayList<Object>();
		if(StringUtils.isEmpty(min) || StringUtils.isEmpty(max) || StringUtils.isEmpty(designv) || StringUtils.isEmpty(hz) || StringUtils.isEmpty(scaleObj) || StringUtils.isEmpty(divisor)){
			return  result;
		}
		min=min.toString().replace("X",designv.toString());
		max=max.toString().replace("X",designv.toString());
		Double s = Double.parseDouble(Expression.parse(min.toString()).calculate().toString())/Double.parseDouble(divisor.toString());
		Double e = Double.parseDouble(Expression.parse(max.toString()).calculate().toString())/Double.parseDouble(divisor.toString());
		List<Object>  list = getRandomListPro(s,e,0,hz,0);
		for(Object obj:list){
			result.add(String.format("%."+scaleObj.toString()+"f",Double.parseDouble(obj.toString())*Double.parseDouble(divisor.toString())));
		}
		return  result;
	}


	/**
     * @yangyj 判断取值，例子：FUNC.ifVal('X<=2?2:(X-1)*3',TABLE[tablename][fieldname])
     * @param ari  运算表达式
     * @param designv 设计值（未知量X的值）
     * @return
     */
	public static Object ifVal(Object ari,Object designv){
          if(designv==null){
          	  return "";
		  }
          if(StringUtils.isEmpty(designv.toString())){
          	return "";
          }
		 ari = ari.toString().replaceAll("[\\t\\n\\r]", "");
		 ari=ari.toString().replace("X",designv.toString());
         return  Expression.parse(ari.toString()).calculate().toString();
	}
	/**
	 * @Description  空白或者/都判断为空
	 * @Param [data]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2022.04.01 15:04
	 **/
	public static Object isNotEmpty(Object data){
	      List<Object> list = obj2List(data);
         return  list.stream().map(StringUtils::handleNull).anyMatch(e->!e.contains("/"));
	}

	public static Object isPass(Object data){
		List<Object> list = obj2List(data);
		return  list.stream().map(StringUtils::handleNull).map(e-> !e.contains("/")&&StringUtils.isNotEmpty(e)?"合格":"").collect(Collectors.toList());
	}




	/**
	 * @Description 评定表实测值
	 * @Param [data, remark]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2022.01.13 15:26
	 **/
	public static Object eval(Object data ,Object remark){
		if(data!=null){
			if(data instanceof  List){
				data = removeEmpty(data);
				List<Object> datas = (List<Object>) data;
                if(datas.size()<=10&&datas.size()>0){
				  return join(datas,"、");
				}
			}else{
				if(StringUtils.isNotEmpty(data)){
					return handleNull(data);
				}
			}
		}
		return remark;
	}

	public static Object model100(Object data ,Object remark){
		if(data!=null){
			if(data instanceof  List){
				data = removeEmpty(data);
				List<Object> datas = (List<Object>) data;
				if(datas.size()<=10&&datas.size()>0){
					return join(datas,"、");
				}else{
					return remark;
				}
			}
		}
		return "";
	}





	/**
	 * @Description 共检点合格点公式
	 * @Param [data 数据, remark超出10个后的提示, design实际值, dev偏差值]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2022.02.11 10:09
	 **/
	public static Object checkpoints(Object data ,Object remark,Object design,Object dev){
		if(data!=null){
			    if(data instanceof  String &&((String) data).contains("NumberFormatException")){
			    	return data;
				}
				Object[] R=ck(data,design,dev);
				if(R[0]!=null&&R[1]!=null&&R[2]!=null){
					int checkpoints=Integer.parseInt(R[0].toString());
					int passpoints=Integer.parseInt(R[1].toString());
					List<Object> result = (List<Object>) R[2];
					boolean	over=checkpoints>result.size();
					if(checkpoints<=0){
						return "/";
					}else if(ListUtils.isNotEmpty(result)&&result.size()<=10&&!over){
						result=	result.stream().map(obj->{
							if(StringUtils.isNumber(obj)){
								if(obj.toString().contains(".")){
									BigDecimal big = new BigDecimal(obj.toString());
									String s = big.toString();
									return s.replaceAll("(0+|\\.0+)$","");
								}
							}
							return obj;
						}).collect(Collectors.toList());
						return join(result,"、");
					}else{
						if(StringUtils.isEmpty(remark)){
							remark ="共检点,合格点";
						}
						return remark.toString().replace("共检","共检"+checkpoints).replace("合格","合格"+passpoints);
					}
				}
		}
		return "/";
	}

	public static Object[] ck(Object data ,Object design,Object dev){
		Object[] r=new Object[3];
		List<Object> result = new ArrayList<>();
		List<Object> datas = obj2List(removeEmpty(data));
		if(ListUtils.isNotEmpty(datas)){
			int checkpoints=0;
			int passpoints=0;
			List<Object> designList = obj2List(design);
			if(ListUtils.isNotEmpty(designList)){
				design=designList.get(0);
			}
			for(Object e:datas){
				String s = handleNull(e);
				if(StringUtils.isNotEmpty(s)){
					if(containsZH(s)){
						Matcher m =matcher("[\u4e00-\u9fa5]+(\\d+)\\D*合格(\\d+)\\D+",s);
						if(m.find()){
							checkpoints+=Integer.parseInt(m.group(1));
							passpoints+=Integer.parseInt(m.group(2));
						}
					}else{
						result.add(s);
					}
				}
			}
			result=result.stream().map(StringUtils::handleNull).map(String::trim).filter(e->!StringUtils.isEquals("/",e)).collect(Collectors.toList());
			if(result.size()>0){
				List<Object> pl = passList(design,dev,result,1);
				passpoints+= pl.size();
				result=obj2List(result);
				checkpoints+=result.size();
			}else{
				System.out.println();
			}
			r[0]=checkpoints;
			r[1]=passpoints;
			r[2]=result;
		}
		return r;
	}

	public static Object tree(List<String>nodes,String param){
		if(CollectionUtil.isNotEmpty(nodes)&& Func.isNotBlank(param)){
			List<String> result = new ArrayList<>();
			param=param.replaceAll("(?i:c)","");
			List<String> list = Arrays.asList(param.split("-"));
			List<Integer> index =list.stream().map(Integer::parseInt).collect(Collectors.toList());
			for(Integer i:index){
				result.add(nodes.get(i));
			}
			return String.join(",", result);
		}
        return "";
	}

	public static Object qrate(Object design,Object dev,Object data){
		return qrate(design,dev,data,0,1);
	}
	public static Object qrate(Object design,Object dev,Object data,Object scale){
		return qrate(design,dev,data,scale,1);
	}
	/**
	 * @Description Qualified rate of measured value 计算合格率
	 * @Param [design： 设计值, dev：偏差范围或规定值, xN：偏差值单位转设计值单位倍率, data：数据, scale：保留小数位]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2022.01.14 09:56
	 **/
	public static Object qrate(Object design,Object dev,Object data,Object scale,Object xN){
		 if(data!=null&&StringUtils.isNotEmpty(design,dev,xN)){
              Object[] R=ck(data,design,dev);
              if(R[0]!=null&&R[1]!=null&&Math.abs(Double.parseDouble(R[0].toString()))>0){
                	String result=StringUtils.number2String(Double.parseDouble(R[1].toString())*100/Double.parseDouble(R[0].toString()),scale);
				  if(result.contains(".")){
					  result =result.replaceAll("(0+|\\.0+)$","");
				  }
				  return result;
			  }
		 }
		return "";
	}
	public static Object easyRate(Object data){
		if(null!=data){
			List<Object> datas = obj2List(data);
			if(datas.stream().anyMatch(e->containsZH(e))){
				return 100;
			}
		}
		return "";
	}
	/**
	 * @Description 筛选合格的部分
	 * @Param [design, dev, data, xN]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2022.02.12 13:59
	 **/
	public static List<Object> passList(Object design,Object dev,Object data,Object xN){
		List<Object> result = new ArrayList<>();
		List<Object> datas = obj2List(data);
		datas= (List<Object>) removeEmpty(datas);
		Double[] range=scopeParse(dev,design,xN);
		assert range != null;
		double finalMin = range[0];
		double finalMax = range[1];
        List<Object> l1 =   datas.stream().map(StringUtils::handleNull).filter(e->e.contains("*")||e.contains("X")||e.contains("x") ||e.contains("×")||e.contains("/")).collect(Collectors.toList());
        if(ListUtils.isNotEmpty(l1)){
        	for(Object obj:l1){
               String[] arr = obj.toString().split("[×xX*/]");
               if(Arrays.stream(Arrays.stream(arr).toArray()).allMatch(StringUtils::isNumber)){
               	    if(Arrays.stream(Arrays.stream(arr).toArray()).map(StringUtils::handleNull).map(Double::parseDouble).noneMatch(e->e>finalMax ||e< finalMin)){
               	    	result.add(obj);
					}
			   }
			}
		}
		List<Object> l2 =   datas.stream().filter(StringUtils::isNumber).map(StringUtils::handleNull).map(Double::parseDouble).filter(e->e<= finalMax &&e>= finalMin).collect(Collectors.toList());
		if(ListUtils.isNotEmpty(l2)){
			result.addAll(l2);
		}
		return  result;
	}


	public static Double[] scopeParse(Object dev, Object design, Object xN){
		if(StringUtils.isNotEmpty(dev)){
 			Double[] result = new Double[2];
			double designD=Double.parseDouble(design.toString());
			double xND=Double.parseDouble(xN.toString());
			String devStr = dev.toString();
			double min=0;
			double max=0;
			devStr=devStr.replaceAll("\\s+","");
			if(devStr.contains("≤")||devStr.contains("<=")||devStr.contains("<")){
				devStr=devStr.replace("≤","").replace("<=","");
				max=designD+Double.parseDouble(devStr)*xND;
			}else if(devStr.contains("≥")||devStr.contains(">=")||devStr.contains(">")){
				devStr=devStr.replace("≥","").replace(">=","");
				min=designD+Double.parseDouble(devStr)*xND;
				max=Double.MAX_VALUE;
			}else if(devStr.contains(",")||devStr.contains("，")){
				String[] arr = devStr.split("[,，]");
				min = designD+Double.parseDouble(arr[0])*xND;
				max = designD+Double.parseDouble(arr[1])*xND;
			}else if(devStr.contains("%")){
				devStr=devStr.replace("%","");
				double devD =Math.abs(Double.parseDouble(devStr)*designD/100);
				min = designD-devD;
				max = designD+devD;
			}else if(devStr.contains("±")){
				devStr=devStr.replace("±","");
				double devD =Math.abs(Double.parseDouble(devStr)*xND);
				min = designD-devD;
				max = designD+devD;
			}
				result[0]=min;
				result[1]=max;
				return result;
		}
		return null;
	}

	/*specifiedRangeList*/
	public static List<Object>  rangeList(Object hz,Object design,Object dev,Object xN,Object scale,Object passRate){
		 List<Object> result = new ArrayList<>();
		 if(StringUtils.isNotEmpty(design,dev,hz)){
			 if(StringUtils.isEmpty(scale)){
				 scale=0;
			 }
             if(StringUtils.isEmpty(passRate)){
             	passRate=1;
			 }
             if(StringUtils.isEmpty(xN)){
             	xN=1;
			 }
			 Double[] range=scopeParse(dev,design,xN);
             int scaleI= Integer.parseInt(scale.toString());
             int min=0,max=0;
			 assert range != null;
			 if(range.length>0){
				 min = (int)(range[0]*Math.pow(10,scaleI));
				 max = (int)(range[1]*Math.pow(10,scaleI));
			 }
			 Random rd= new Random();
			 int hzi=new BigDecimal(hz.toString()).multiply(new BigDecimal(passRate.toString())).setScale(0,ROUND_CEILING).intValue();
			 for(int i=0;i<hzi;i++){
			 	BigDecimal tb = new BigDecimal(rd.nextInt(max-min+1)+min).divide(BigDecimal.valueOf(Math.pow(10,scaleI)),scaleI,ROUND_HALF_UP);
			 	if(scaleI>0){
					result.add(tb.doubleValue());
				}else{
					result.add(tb.intValue());
				}

			 }
			 int total=StringUtils.handleObj2Integer(hz);
			 if(total-hzi>0){
			 	for(int k=0;k<total-hzi;k++){
					BigDecimal tb;
                    if(rd.nextBoolean()){
						 tb = new BigDecimal(rd.nextInt(((max-min)/2))+max+1).divide(BigDecimal.valueOf(Math.pow(10,scaleI)),scaleI,ROUND_HALF_UP);
					}else{
						 tb = new BigDecimal(min-1-rd.nextInt(((max-min)/2))).divide(BigDecimal.valueOf(Math.pow(10,scaleI)),scaleI,ROUND_HALF_UP);
					}
					if(scaleI>0){
						result.add(tb.doubleValue());
					}else{
						result.add(tb.intValue());
					}
				}
			 	if(ListUtils.isNotEmpty(result)){
					Collections.shuffle(result);
				}
			 }
		 }
		 return  result;
	}

	/**
	 * @Description obj 转List
	 * @Param [obj]
	 * @return java.util.List<java.lang.Object>
	 * @Author yangyj
	 * @Date 2022.01.13 15:40
	 **/
	public static List<Object> obj2List(Object obj){
		List<Object> result = new ArrayList<>();
		if(obj!=null){
			 List<Object> datas = new ArrayList<>();
			if(obj instanceof  List){
				datas =  (List<Object>) obj;
			}else {
				datas.add(obj);
			}
			if(ListUtils.isNotEmpty(datas)){
				for(Object e:datas){
					if(StringUtils.isNotEmpty(e)&&!CustomFunction.containsZH(e.toString())&&(e.toString().contains("、")||e.toString().contains(",")||e.toString().contains(" ")||e.toString().contains("，"))){
						String s=e.toString().trim();
						if(s.contains(" ")){
							s=s.replaceAll("\\s+","、");
						}
						Object[] bs = s.split("[、,，]");
						result.addAll(Arrays.asList(bs));
					}else{
						result.add(e);
					}
				}
			}
		}
		return  result;
	}
	/**
	 * @Description 对象转字符串，list取第一个对象
	 * @Param [obj]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2022.02.11 15:14
	 **/
	public static Object o2Str(Object obj){
		String result = "";
		if(obj!=null){
			List<Object> datas =obj2List(obj);
			if(ListUtils.isNotEmpty(datas)){
				return handleNull(datas.get(0));
			}
		}
		return  result;
	}

	public static Object getFirstNonNull(Object ob1,Object ob2,Object ob3){
		return _getFirstNonNull(ob1,ob2,ob3);
	}
	public static Object getFirstNonNull(Object ob1,Object ob2){
		return _getFirstNonNull(ob1,ob2);
	}
	/**
	 * @Description  返回第一个不为空的对象
	 * @Param
	 * @Author yangyj
	 * @Date 2022.01.04 13:57
	 **/
	public static Object _getFirstNonNull(Object ...obs){
		   if(obs!=null){
		   	 for(Object ob:obs){
		   	 	if(ob instanceof List){
		   	 		List<Object> list =obj2List(ob);
		   	 		if(ListUtils.isNotEmpty(list)&&list.stream().anyMatch(StringUtils::isNotEmpty)){
						return  ob;
					}
				}else if(ob instanceof Map){
		   	 		if(MapUtils.isNotEmpty((Map)ob)){
						return ob;
					}
				}else{
		   	 		if(StringUtils.isNotEmpty(ob)&&StringUtils.isNotEquals("/",ob)){
		   	 			return ob;
					}
				}
			 }
		   }
           return null;
	}


	/**
	 * @Description 三元运算 bool?o1:o2 ,默认返回空字符串
	 * @Param [bool, o1, o2]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.01.29 13:54
	 **/
	public static Object ifValObj(Object bool,Object o1 ,Object o2){
		Boolean fi;
          if(bool instanceof Boolean){
			 fi = (Boolean) bool;
		  }else{
          	return "";
		  }
         return fi?o1:o2;
	}
	/*太多写错公式名称的，应该是下面的方法名称比较容易接受*/
	public static Object isValObj(Object bool,Object o1 ,Object o2){
		return  ifValObj(bool,o1,o2);
	}
	/**
	 * @Description  判断o1中是否包含字符串o2
	 * @Param [o1, o2]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.01.29 14:04
	 **/
	public static Object ifContains(Object o1 ,Object o2){
		if(StringUtils.isNotEmpty(o1)&&StringUtils.isNotEmpty(o2)){
			return o1.toString().contains(o2.toString());
		}
		return false;
	}
	/**
	 * @Description 判断两个对象是否相等
	 * @Param [o1, o2]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.08.23 16:51
	 **/
	public static Object isEq(Object o1 ,Object o2){
		if(StringUtils.isNotEmpty(o1)||StringUtils.isNotEmpty(o2)){
		      return  StringUtils.isEquals(o1,o2);
		}
		return false;
	}
		/**
         * @yangyj
         * 单极点区间范围判断
         * @param value 数据
         * @param o1    比较对象1
         * @param o2    比较对象2
         * @param type  <=&&<
         * @return
         */
	public static  Object isVisible(Object value,Object o1 ,Object o2,Object type){
		if(o1!=null&&o2!=null){
			double fi =Double.parseDouble(o1.toString())-Double.parseDouble(o2.toString());
			if(type.equals("<=")){
				if(fi<=0){
					return value;
				}
			}else{
				if(fi<0){
					return value;
				}
			}
		}
		//如果不存在判断条件对象的值
		if((o1==null||o2==null)&&type.equals("<=")){
            return value;
        }
        return "";
	}

	/**@yangyj
	 * 双极点区间范围判断
	 * @param value
	 * @param o1
	 * @param o2
	 * @param o3
	 * @return
	 */
	public static  Object isVisibleD(Object value,Object o1 ,Object o2,Object o3){
		Object r1=isVisible(value,o1,o2,"<");
		Object r2=isVisible(value,o2,o3,"<=");
		if(r1!=""&&r2!=""){
			return  value;
		}
		return "";
	}


		/**@yangyj
         *获取列表最小值
         * @return
         */
	public static  Object getListMin(Object object){
		if(object instanceof  ArrayList){
			ArrayList<Object> arrayList = (ArrayList<Object>) object;
			if(ListUtils.isNotEmpty(arrayList)){
				arrayList.sort(((o1, o2) -> {
					Integer io1= Integer.valueOf(o1.toString());
					Integer io2 = Integer.valueOf(o2.toString());
					return io1.compareTo(io2);
				}));
				return arrayList.get(0);
			}
		}
		return "";
	}




	/**
	 * @Description 计算数据集的合格率
	 * @Param [list：数据集, design：设计值, dev：偏差范围, scale：保存小数位]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.10.26 09:34
	 **/
	public static  Object getListTick(Object list,Object design,Object dev,Object scale){
		if(list!=null&&design!=null&&StringUtils.isNotEmpty(dev)){
			if(!StringUtils.isNumber(scale)){
				scale=0;
			}
			Matcher m = matcher("(-?\\d+(\\.\\d+)?)[h|H]?[,|，](\\+?\\d+(\\.\\d+)?)[h|H]?",dev.toString().replaceAll("[(|)]",""));
			if(list instanceof  List&&m.find()){
				List<Object> arrayList = (ArrayList<Object>) list;
				double tick=0;
				double designD= Double.parseDouble(handleNull(design));
				double h=1;
				if(dev.toString().toUpperCase(Locale.ROOT).contains("H")){
					h=designD;
				}
				for(Object obj:arrayList){
                    double dx = Double.parseDouble(handleNull(obj))-designD;
					if(Double.parseDouble(m.group(1))*h<=dx&&dx<=Double.parseDouble(m.group(3))*h){
                       tick++;
					}
				}
			    if(tick>0){
			    	BigDecimal a= new BigDecimal(tick);
			    	BigDecimal b= new BigDecimal(arrayList.size());

			    	return a.divide(b,8,ROUND_HALF_UP).multiply(new BigDecimal(100)).setScale(StringUtils.handleObj2Integer(scale.toString()),ROUND_HALF_UP);
				}else{
			    	return "0";
				}
			}
		}
		return "";
	}
	/**
	 * @Description   指定表字段 数据
	 * @Param [table, field]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2022.10.11 11:28
	 **/
	public static Object getTaleRow(Object table,Object field){
		if(table!=null&&field!=null){
			List<Object>  datas = new ArrayList<Object>();
			ArrayList<HashMap<String,Object>> list=objToArray(table);
			if(ListUtils.isNotEmpty(list)){
				for(HashMap<String, Object> ob:list){
					datas.add(ob.get(field));
				}
			}
			return datas;
		}
      return null;
	}



	/**
	 * @Description 获取最后一个对象
	 * @Param [list]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.08.09 14:37
	 **/
	public static  Object getListLast(Object o){
		if(o instanceof List){
			List<Object> list = (List<Object>) o;
			if(ListUtils.isNotEmpty(list)){
				return list.get(list.size()-1);
			}
		}
		return "";
	}
	/**
	 * @Description 获取最后一个对象
	 * @Param [list]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.08.09 14:37
	 **/
	public static  Object getListnum(Object o,Integer type){
		if(o == null){
			return "";
		}
		if(o instanceof List){
			List<Object> list = (List<Object>) o;
			if(ListUtils.isNotEmpty(list) || list.size() > type){
				return list.get(type);
			}
		}else{
			return o.toString();
		}
		return "";
	}
	/**
	 * @Description 根据参数，取包含有对应参数的list
	 * @Param [list],o是list，str是包含的字符串，type=1包含，2未包含
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.08.09 14:37
	 **/
	public static  Object getListtype(Object o,Object objstr,Integer type){
		if(o == null || type == null){
			return "";
		}
		String str = "";
		if(objstr != null ){
			str =objstr.toString();
		}
		List<Object> result = new ArrayList<>();
		if(o instanceof List){
			List<Object> list = (List<Object>) o;
			if(ListUtils.isNotEmpty(list)){
				for(Object obj : list){
					if(obj == null){
						continue;
					}
					if(type == 2){
						if(!obj.toString().contains(str)){
							result.add(obj);
						}
					}else{
						if(obj.toString().contains(str)){
							result.add(obj);
						}
					}

				}
				return result;
			}
		}else{
			if(type == 2 && !o.toString().contains(str)){
				return o.toString();
			}else if(type == 1 && o.toString().contains(str)){
				return o.toString();
			}
		}
		return "";
	}
	/**
	 * @Description 过滤掉List中的空对象
	 * @Param [o]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.07.28 11:16
	 **/
	public static  Object removeEmpty(Object o){
		List<Object> result = new ArrayList<>();
		if(o instanceof  List){
			for(Object e:(List<Object>)o){
				if(StringUtils.isNotEmpty(e)){
					result.add(e);
				}
			}
		}else{
			result.add(o);
		}
		return result;
	}
	/**
	 * @Description 过滤掉List中的相同的对象
	 * @Param [o]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.07.28 11:16
	 **/
	public static  Object removeeqEmpty(Object o){
		List<Object> result = new ArrayList<>();
		if(o instanceof  List){
			for(Object e:(List<Object>)o){
				if(StringUtils.isNotEmpty(e) && !result.contains(e)){
					result.add(e);
				}
			}
		}else{
			result.add(o);
		}
		return result;
	}
	/**
	 * @Description 设置保留小数位
	 * @Param
	 * @return
	 * @Author yangyj
	 * @Date 2021.12.31 17:14
	 **/
	public static  Object setScale(Object o,Object scale){
		if(StringUtils.isNumber(scale)&&o!=null){
			if(o instanceof  List){
				List<Object> result = new ArrayList<>();
				for(Object e:(List<Object>)o){
					if(StringUtils.isNumber(e)){
						result.add(StringUtils.number2String(e,scale));
					}else{
						result.add("");
					}
				}
				return result;
			}else{
				if(StringUtils.isNumber(o)){
					return StringUtils.number2String(o,scale);
				}
			}
		}
		return "";
	}


	public static  Object abs(Object o){
		/**
		 * @Description  测试
		 * @Param [o]
		 * @return java.lang.Object
		 * @Author yangyj
		 * @Date 2022.03.21 15:43
		 **/
		if(o!=null){
			if(o instanceof  List){
				List<Object> result = new ArrayList<>();
				List<Object> datas = obj2List(o);
				if(ListUtils.isNotEmpty(datas)){
					for(Object e:datas){
						if(StringUtils.isNotEmpty(e)){
							result.add(e.toString().replaceAll("^-",""));
						}
					}
				}
				return  result;
			}else{
				return o.toString().replaceAll("^-","");
			}
		}
		return null;
	}

	/**
	 * @Description 返回正则式匹配内容
	 * @Param [regex：正则式, value：匹配的字符串, i：group(i), g:是否返回全局搜索，全局搜索返回的是列表]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.01.08 16:31
	 **/
	public static Object matcherFindGroup(String regex, String value ,int i,boolean g){
		Matcher m = matcher(regex,value);
		List<Object> result = new ArrayList<>();
		while (m.find()){
			result.add(m.group(i));
		}
		if(ListUtils.isNotEmpty(result)){
			if(g){
				return result;
			}else {
				return result.get(0);
			}
		}
		return null;
	}
	/**
	 * @Description 放大缩小
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2022.01.14 14:17
	 **/
	public static  Object xN(Object o,Object xN){
		String cur="";
		try{
			if(StringUtils.isNotEmpty(o)&&StringUtils.isNumber(xN)){
				double xND=Double.parseDouble(xN.toString());
				List<Object> outList = new ArrayList<>();
				if(o instanceof List){
					List<Object> datas = (List<Object>)o;
					for(Object e:datas){
						if(StringUtils.isNotEmpty(e)){
							String[] as = e.toString().split("[^\\d.]");
							Object m= matcherFindGroup("[^\\d.]",e.toString(),0,false);
							StringBuilder d = new StringBuilder();
							for(int i=0;i<as.length;i++){
								String s=as[i];
								cur=s;
								int scale = (int) Math.max(getScale(s)-Math.log10(xND),0);
                                d.append(StringUtils.number2String(Double.parseDouble(s) * xND, scale)).append(i!=as.length-1&&m!=null?m:"");
							}
							outList.add(d.toString());
						}
					}
					if(ListUtils.isNotEmpty(outList)){
						return outList;
					}
				}else{
					List<Object> datas = Arrays.asList(o.toString().split("[、， ,]"));
					Matcher m = matcher("[、， ,]",o.toString());
					String s="、";
					if(m.find()){
						s=handleNull(m.group());
					}
					if(ListUtils.isNotEmpty(datas)){
						for(Object e:datas){
							if(StringUtils.isNotEmpty(e)){
								int scale = (int) Math.max(getScale(s)-Math.log10(xND),0);
								cur=e.toString();
								outList.add(StringUtils.number2String(Double.parseDouble(e.toString())*xND,scale));
							}
						}
					}
					if(ListUtils.isNotEmpty(outList)){
						return StringUtils.join(outList.stream().map(StringUtils::handleNull).collect(Collectors.toList()),s);
					}
				}
			}
		}catch (NumberFormatException e){
			e.printStackTrace();
			String  error = "";
			if(e.getMessage().contains("multiple points")){
				error=cur+"包含多个小数点";
			}else {
				error=cur;
			}
			return "NumberFormatException(数字格式异常，请检查)"+error;
		}
		return "";
	}
	public static  Object repeat(Object data){
		List<Object> result = new ArrayList<>();
		if(data!=null){
			List<Object> list = obj2List(removeEmpty(data));
			result=list.stream().distinct().collect(Collectors.toList());
		}
		return  result;
	}
	/**
	 * @Description  截取list subList(list,1,5) 返回list的第1到第5个元素
	 * @Param [o]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.07.28 11:16
	 **/
	public static  Object subList(Object o,Object  start ,Object end){
		List<Object> result = new ArrayList<>();
		if(o instanceof  List){
			 result = (List<Object>) o;
			 int s=StringUtils.handleObj2Integer(start);
			 int e=StringUtils.handleObj2Integer(end);
			 s= Math.max(s, 1);
			 if(e<=0){
			 	e=result.size();
			 }
			 return result.subList(s-1,e);
		}
		return result;
	}

	/**
	 * @Description 获取G8测点偏差
	 * @Param [cd, pc]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2022.02.25 11:05
	 **/
	public static  Object g8dx(Object cd,Object pc){
		if(cd!=null&&pc!=null){
			List<Object> result = new ArrayList<>();
			List<Object> stakes=obj2List(cd);
			List<Object> dx=obj2List(pc);
			if(ListUtils.isNotEmpty(stakes)&&dx.size()>=stakes.size()){
				Object bmd = stakes.get(0);
				if(StringUtils.isNotEmpty(bmd)){
					for(int i=0;i<stakes.size();i++){
						  Object cp = stakes.get(i);
                          if(StringUtils.isNotEmpty(cp)&&StringUtils.isNotEquals(bmd,cp)){
							  Matcher m = matcher("(?i)zd\\d+",cp.toString());
							  if(!m.find()){
							  	 result.add(dx.get(i));
							  }
						  }
					}
					return result;
				}
			}
		}
		return "";
	}
	public static  Object g8stakes(Object cd){
		if(cd!=null){
			List<Object> result = new ArrayList<>();
			List<Object> stakes=obj2List(cd);
			if(ListUtils.isNotEmpty(stakes)){
				Object bmd = stakes.get(0);
				if(StringUtils.isNotEmpty(bmd)){
					for (Object cp : stakes) {
						if (StringUtils.isNotEmpty(cp) && StringUtils.isNotEquals(bmd, cp)) {
							Matcher m = matcher("(?i)zd\\d+", cp.toString());
							if (!m.find()) {
								result.add(cp);
							}
						}
					}
					return result;
				}
			}
		}
		return "";
	}
	public static  List<Object> g8c103(Object cd,Object sj, Object sc,Object dx){
		List<Object> result = new ArrayList<>();
		if(cd!=null&&sj!=null&&sc!=null&&dx!=null){
			List<Object> cds=obj2List(cd);
			List<Object> sjs=obj2List(sj);
			List<Object> scs=obj2List(sc);
			List<Object> dxs=obj2List(dx);
			int min=Math.min(Math.min(sjs.size(),scs.size()),dxs.size());
			if(ListUtils.isNotEmpty(cds)&&min>=cds.size()){
				Object bmd = cds.get(0);
				if(StringUtils.isNotEmpty(bmd)){
					for(int i=0;i<cds.size();i++){
						Object cp = cds.get(i);
						if(StringUtils.isNotEmpty(cp)&&StringUtils.isNotEquals(bmd,cp)){
							Matcher m = matcher("(?i)zd\\d+",cp.toString());
							if(!m.find()){
								if(StringUtils.isNumber(cp)){
									result.add("");
									result.add("");
									result.add("");
									result.add(dxs.get(i));
								}else {
									result.add(sjs.get(i));
									result.add(scs.get(i));
									result.add(dxs.get(i));
									result.add("");
								}
							}
						}
					}
				}
			}
		}
        return result;
	}

	public static  List<Object> g8zzds(Object cd,Object dx,Object fi){
		List<Object> result = new ArrayList<>();
		if(cd!=null&&dx!=null){
			List<Object> cds=obj2List(cd);
			List<Object> dxs=obj2List(dx);
			boolean bol= (boolean) fi;
			int min=dxs.size();
			if(ListUtils.isNotEmpty(cds)&&min>=cds.size()){
				Object bmd = cds.get(0);
				List<String> l1 = new ArrayList<>();
				List<String> l2 = new ArrayList<>();
				List<String> l3 = new ArrayList<>();
				List<String> dyn ;
				if(bol){
					dyn=l3;
				}else{
					dyn=l2;
				}
				if(StringUtils.isNotEmpty(bmd)){
					for(int i=0;i<cds.size();i++){
						Object cp = cds.get(i);
						if(StringUtils.isNotEmpty(cp)&&StringUtils.isNotEquals(bmd,cp)){
							Matcher m = matcher("(?i)zd\\d+",cp.toString());
							if(!m.find()){
								if(StringUtils.isNumber(cp)){
									dyn.add(handleNull(dxs.get(i)));
								}else {
							    	l1.add(handleNull(dxs.get(i)));
								}
							}
						}
					}
					result.add(StringUtils.join(l1,","));
					result.add(StringUtils.join(l2,","));
					result.add(StringUtils.join(l3,","));
				}
			}
		}
		return  result;
	}

	public static List<Object> gcc(Object zh,Object sj,Object sc,Object dx,Object mode){
		List<Object> result = new ArrayList<>();
		if(zh!=null&&sj!=null&&sc!=null&&dx!=null){
			List<Object> cds=obj2List(zh);
			List<Object> sjs=obj2List(sj);
			List<Object> scs=obj2List(sc);
			List<Object> dxs=obj2List(dx);
			int min=Math.min(Math.min(dxs.size(),sjs.size()),scs.size());
			if(ListUtils.isNotEmpty(cds)&&min>=cds.size()){
				Object bmd = cds.get(0);
				if(StringUtils.isNotEmpty(bmd)){
					for(int i=0;i<cds.size();i++){
						Object cp = cds.get(i);
						if(StringUtils.isNotEmpty(cp)&&StringUtils.isNotEquals(bmd,cp)){
							Matcher m = matcher("(?i)zd\\d+",cp.toString());
							if(!m.find()){
								if(StringUtils.isEquals(mode,0)){
									if(!Pattern.matches(".+(?i)v$",cp.toString())){
										result.add(sjs.get(i));
										result.add(scs.get(i));
										result.add(dxs.get(i));
									}
								}else if(StringUtils.isEquals(mode,1)){
									if(Pattern.matches(".+(?i)v$",cp.toString())){
										result.add(sjs.get(i));
										result.add(scs.get(i));
										result.add(dxs.get(i));
									}
								}

							}
						}
					}
				}
			}
		}
		return  result;
	}

	/**
	 * @Description 获取最后一份G8
	 * @Param [data, out]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2022.04.02 17:46
	 **/
	public static  Object g8zd(Object data,Object out){
		List<Object> result = new ArrayList<>();
		if(StringUtils.isNotEmpty(out)&&data instanceof List){
			List<Object> datas =obj2List(data);
			String bm = handleNull(datas.get(0));
			List<Object> cds = new ArrayList<>();
			List<Object> bhs = new ArrayList<>();
			List<Object> hss = new ArrayList<>();
			List<Object> qss = new ArrayList<>();
			List<Object> ygs = new ArrayList<>();
			List<Object> scs = new ArrayList<>();
			List<Object> sjs = new ArrayList<>();
			List<Object> dxs = new ArrayList<>();
			for(int n=0;n<datas.size();n++){
                 int m=n%13;
                 Object d=datas.get(n);
                 if(m==0){
                 	cds.add(d);
				 }else if(m==1){
					 bhs.add(d);
				 }else if(m==2){
					 hss.add(d);
				 }else if(m==4){
					 qss.add(d);
				 }else if(m==6){
					 ygs.add(d);
				 }else if(m==8){
					 scs.add(d);
				 }else if(m==10){
					 sjs.add(d);
				 }else if(m==12){
					 dxs.add(d);
				 }
			}
			/*同时存在超过一组水准点，则存在多张复制表*/
			if(cds.stream().filter(e -> StringUtils.isEquals(bm, e)).count() >2){
				Collections.reverse(cds);
				int length =0;
				int count=0;
				for(int x=0;x<cds.size();x++){
					if(StringUtils.isEquals(cds.get(x),bm)){
						/*倒序后，第一次bm点到第二次bm点为一组*/
						if(count==2){
							length=x+1;
							break;
						}else{
							count++;
						}

					}
				}
				Collections.reverse(cds);
				cds = cds.stream().skip(cds.size()-length).collect(Collectors.toList());
				bhs = bhs.stream().skip(bhs.size()-length).collect(Collectors.toList());
				hss = hss.stream().skip(hss.size()-length).collect(Collectors.toList());
				qss = qss.stream().skip(qss.size()-length).collect(Collectors.toList());
				ygs = ygs.stream().skip(ygs.size()-length).collect(Collectors.toList());
				scs = scs.stream().skip(scs.size()-length).collect(Collectors.toList());
				sjs = sjs.stream().skip(sjs.size()-length).collect(Collectors.toList());
				dxs = dxs.stream().skip(dxs.size()-length).collect(Collectors.toList());
			}
			if(cds.size()>0){
				String BM=handleNull(cds.get(0));
				for(int i=0;i<bhs.size();i++){
					Object _bh=bhs.get(i);
					if(StringUtils.isNotEmpty(_bh)){
						int k=i;
						boolean loop=true;
						do{
							Object _cd=cds.get(k);
							if(StringUtils.isNotEmpty(_cd)&&(_cd.toString().contains("ZD")||StringUtils.isEquals(BM,_cd))){
								loop=false;
							}else{
								k--;
							}
						}while (k>=0&&loop);
						String outStr=handleNull(out);
						if(outStr.contains("桩号")){
							result.add(handleNull(cds.get(i))+"  "+_bh);
						}
						if(outStr.contains("后视")){
							result.add(hss.get(k));
						}
						if(outStr.contains("前视")){
							result.add(qss.get(k));
						}
						if(outStr.contains("仪器高")){
							result.add(ygs.get(k));
						}
						if(outStr.contains("实测高程、设计高程、高程差")){
							if(_bh.toString().contains("右")){
								result.addAll(Arrays.asList("","",scs.get(i)));
								result.addAll(Arrays.asList("","",sjs.get(i)));
								result.addAll(Arrays.asList("","",dxs.get(i)));
							}else if(_bh.toString().contains("左")){
								result.addAll(Arrays.asList(scs.get(i),"",""));
								result.addAll(Arrays.asList(sjs.get(i),"",""));
								result.addAll(Arrays.asList(dxs.get(i),"",""));
							}else{
								result.addAll(Arrays.asList("",scs.get(i),""));
								result.addAll(Arrays.asList("",sjs.get(i),""));
								result.addAll(Arrays.asList("",dxs.get(i),""));
							}
						}
					}
				}
			}

		}
		return result;
	}

	/**
	 * @Description  list 去头尾
	 * @Param [o]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.12.31 14:53
	 **/
	public static  Object removeHT(Object o){
		List<Object> result = new ArrayList<>();
		if(o instanceof  List){
			result= (List<Object>) o;
			if(result.size()>2){
				int end =result.size();
				for(int i=result.size()-1;i>1;i--){
					if(StringUtils.isNotEmpty(result.get(i))){
						end=i;
						break;
					}
				}
				return subList(result,2,end);
			}
		}
		return result;
	}

	/**
	 * @Description  list 去头
	 * @Param [o]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.12.31 14:53
	 **/
	public static  Object removeH(Object o){
		List<Object> result = new ArrayList<>();
		if(o instanceof  List){
			result= (List<Object>) o;
			if(result.size()>2){
				return subList(result,2,result.size());
			}
		}
		return result;
	}


	public static  Object removeByReg(Object o,Object reg){
		List<Object> result = new ArrayList<>();
		if(o instanceof  List && StringUtils.isNotEmpty(reg)){
			result= (List<Object>) o;
			return result.stream().map(StringUtils::handleNull).filter(e->!Pattern.matches(reg.toString(),e)).collect(Collectors.toList());
		}
		return result;
	}

	/**
	 * @Description 获取动态行某列内容
	 * @Param [data, field]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2022.01.08 10:02
	 **/
	public static  Object getColumn(Object data ,Object field){
	   if(StringUtils.isNotEmpty(field)){
	   	    List<HashMap<String,Object>> _data =objToArray(data);
	   	    if(ListUtils.isNotEmpty(_data)){
	   	    	return  _data.stream().map(e->e.get(field.toString())).collect(Collectors.toList());
			}
	   }
		return data;
	}

	/**
	 * @Description 合并多个list
	 * @Param [listArr]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.12.31 15:10
	 **/
	public static  Object mergeList(Object l1,Object l2){
		return _mergeList(l1,l2);
	}
	public static  Object mergeList(Object l1,Object l2,Object l3){
		return _mergeList(l1,l2,l3);
	}
	public static  Object mergeList(Object l1,Object l2,Object l3,Object l4){
		return _mergeList(l1,l2,l3,l4);
	}
	public static  Object mergeList(Object l1,Object l2,Object l3,Object l4,Object l5){
		return _mergeList(l1,l2,l3,l4,l5);
	}
	public static  Object mergeList(Object l1,Object l2,Object l3,Object l4,Object l5,Object l6){
		return _mergeList(l1,l2,l3,l4,l5,l6);
	}
	public static  Object mergeList(Object l1,Object l2,Object l3,Object l4,Object l5,Object l6,Object l7){
		return _mergeList(l1,l2,l3,l4,l5,l6,l7);
	}
	public static  Object mergeList(Object l1,Object l2,Object l3,Object l4,Object l5,Object l6,Object l7,Object l8){
		return _mergeList(l1,l2,l3,l4,l5,l6,l7,l8);
	}
	public static  Object _mergeList(Object ...listArr){
		List<Object> result = new ArrayList<>();
	    if(listArr!=null&&listArr.length>=2){
	    	List<List<Object>> tmp =new ArrayList<>();
	    	int max=0;
	    	for(Object o:listArr){
				List<Object> list = Collections.singletonList("");
	    		if(o instanceof List){
	    			list = (List<Object>) o;
					max=Math.max(max,list.size());
				}
	    		tmp.add(list);
			}
	    	if(ListUtils.isNotEmpty(tmp)){
	    		for(int i=0;i<max;i++){
	    			for(List<Object> _l:tmp){
	    				if(_l.size()>i){
	    					result.add(_l.get(i));
						}else{
	    					result.add("");
						}
					}
				}
			}
		}
		return result;
	}

	/**
	 * @Description 删除列表最后一个数据
	 * @Param [o]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.07.28 15:47
	 **/
	public static  Object remLast(Object o){
		if(o instanceof  List){
		     rem(o,	((List<Object>)o).size()-1);
		}
		return  o;
	}
	/**
	 * @Description list 转 string
	 * @Param [o, separator:分隔符]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.07.28 15:50
	 **/
	public static  Object _join(Object o,Object separator){
		StringBuilder r = new StringBuilder();
		if(o instanceof  List){
			if(null==separator){
				separator=space(1);
			}
			for(Object e:(List<Object>)o){
				if(StringUtils.isNotEmpty(e)){
					r.append(handleNull(e)).append(separator);
				}
			}
		}else if(StringUtils.isNotEmpty(o)){
			r.append(o).append(",");
		}
		if(r.length()>0){
			r.deleteCharAt(r.length()-1);
		}
		return  r;
	}
	public static  Object __join(Object ...args){
		StringBuilder r = new StringBuilder();
		if(args!=null){
			if(args.length>=2){
				String separator=handleNull(args[args.length-1]);
				for(int i=0;i<args.length-1;i++){
					r.append(_join(args[i],separator)).append(separator);
				}
				if(r.length()>0){
					r.deleteCharAt(r.length()-1);
				}
			}else{
               return _join(args[0],"、");
			}
		}
		return  r.toString();
	}
	public static  Object join(Object o1,Object o2,Object o3,Object separator){
		return __join(o1,o2,o3,separator);
	}
	public static  Object join(Object o1,Object o2,Object separator){
		return __join(o1,o2,separator);
	}
	public static  Object join(Object o1,Object separator){
		return __join(o1,separator);
	}
	public static  Object join(Object o1){
		return __join(o1);
	}
	/**
	 * @Description String 转List
	 * @Param [o, separator]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2021.12.03 15:09
	 **/
	public static  Object split(Object o,Object separator){
		 if(StringUtils.isNotEmpty(o,separator)){
			 System.out.println(separator);
		 	String[] arr = o.toString().split(separator.toString());
		    return 	Arrays.stream(arr).collect(Collectors.toList());
		 }
         return null;
	}
	public static  Object split(Object o){
		return split(o,"/|,|、|，|；|;|\\\\|(\\s+)");
	}

	/**
	 * @Description  删除下标为index的元素
	 * @Param [o, index]
	 * @return void
	 * @Author yangyj
	 * @Date 2021.07.28 15:52
	 **/
	public static  void rem(Object o,Object index){
		if(o instanceof  List&&StringUtils.isNumber(index)){
			((List<Object>)o).remove(StringUtils.handleObj2Integer(index).intValue());
		}
	}

	/**
	 * @Description  根据百分比返回子集list内容
	 * @Param [obj：数据源, percent：0-100]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2020.12.04 09:24
	 **/
	public  static Object getListPercent(Object obj,Object percent){
		if(obj!=null&&percent!=null){
			if(obj instanceof  List){
				ArrayList<Object> list = (ArrayList<Object>) obj;
				Collections.shuffle(list);
				int n = (int) Math.round((Double.parseDouble(percent.toString())/100)*list.size());
				if(n<=list.size()){
					return  list.subList(0,n);
				}
				return list;
			}
		}
		return "";
	}



	public static Object  doForTableList(Object ot,Object type){
		if(ot!=null){
			//记录表46：构造深度平均值
			if(type.toString().equals("0")){
				List<Object>  datas = new ArrayList<Object>();
				if(ot instanceof  HashMap){
					HashMap mp = (HashMap) ot;
					if(mp.size()>0){
						datas.add(mp.get("TdGZSD"));
					}
				}else if(ot instanceof  ArrayList){
					ArrayList<HashMap<String,Object>> list = (ArrayList<HashMap<String, Object>>) ot;
					if(ListUtils.isNotEmpty(list)){
						for(HashMap<String, Object> ob:list){
							datas.add(ob.get("TdGZSD"));
						}
					}
				}
				return  avg(1,datas);
			}

		}

		return  null;
	}




	public static boolean isNumeric(String str){
		Pattern pattern = Pattern.compile("[0-9.]*");
		return pattern.matcher(str).matches();
	}



	/**
	 * @Description  把Object 转换成 ArrayList<HashMap<String, Object>>
	 * @Param [obj]
	 * @return java.util.ArrayList<java.util.HashMap<java.lang.String,java.lang.Object>>
	 * @Author yangyj
	 * @Date 2020.12.11 09:44
	 **/
	public static ArrayList<HashMap<String,Object>> objToArray(Object obj){
		if(obj instanceof  ArrayList){
			return (ArrayList<HashMap<String, Object>>) obj;
		}else if(obj instanceof  HashMap){
			ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
			HashMap<String, Object> map =	(HashMap<String, Object>) obj  ;
			if(map.size()>0){
				array.add(map);
			}
			return array;
		}
       return null;
	}



	/**
	 *  @author: zhifk
	 *  @Date:  2020/9/4 - 11:00
	 *  @Description:
	 *  value1:公式所在单元格的分类，value2:选择的分类,value3:从记录表获得的共检点合格点
	 *  根据选择的分类判断是否是该分类的共检点合格点
	 *  为：FUNC.isfenlei(TABLE['t_pf_RecordTable015']['shigongkaishiriqi'],'板拱',FORMULA[‘公式编号’])
	 */
	public static Object isfenlei(Object value1,Object value2,Object value3){
		if( StringUtils.isEmpty(value1)  || StringUtils.isEmpty(value2) || StringUtils.isEmpty(value3)){
			return null;
		}
		if(value1.toString().contains(value2.toString())){
			return value3;
		}
		return null;
	}



	public  static Object dXd(Object design,Object data){
		return dXd(design,data,1,getScale(design,data));
	}
	public  static Object dXd(Object design,Object data,Object xN){
		int scale=0;
		if(StringUtils.isNotEmpty(design,data,xN)){
			 scale=getScale(design,data);
			 scale= (int) (scale-Math.log10(Double.parseDouble(xN.toString())));
		}
		return dXd(design,data,xN,scale);
	}
	/**
	 * @Description 求偏差公式  支持AXA-BXB=DXD或者A-B=D的格式
	 * @Param [design:设计值, data：实测值, xN：倍率, scale：保留小数位]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2022.01.20 09:45
	 **/
	public  static Object dXd(Object design,Object data,Object xN,Object scale){
		if(StringUtils.isNotEmpty(design,data)){
			if(StringUtils.isEmpty(xN)){
				xN=1;
			}
			if(StringUtils.isEmpty(scale)){
				scale=0;
			}
			String delimiter=handleNull(matcherFindGroup("[^0-9.]",design.toString(),0,false));
			if(StringUtils.isEmpty(delimiter)){
				delimiter=CONCAT;
			}
			String[] dArr=handleNull(design).split("["+delimiter+"]");
			String[] bArr=handleNull(data).split("["+delimiter+"]");
			Object _dx=null;
			for(int n=0;n<dArr.length;n++){
				BigDecimal a = new BigDecimal(dArr[n]);
				BigDecimal b = new BigDecimal(bArr[n]);
				String _data=b.subtract(a).multiply(new BigDecimal(xN.toString())).setScale(Integer.parseInt(scale.toString()), ROUND_HALF_UP).toString();
				if(StringUtils.isNotEmpty(_dx)){
					_dx=StringUtils.join(_dx,_data,delimiter);
				}else{
					_dx=_data;
				}
			}
			return _dx;
		}
		return "";
	}


	public  static Object over10(Object C82 ,Object C81 ,Object xmm, Object remark){
         List<Object> list = obj2List(C82);
         if(ListUtils.isNotEmpty(list)){
         	if(list.stream().map(StringUtils::handleNull).anyMatch(e->e.contains(xmm.toString()))){
				return remark;
			}
		 }
		List<Object> list2 =obj2List(C81);
		if(ListUtils.isNotEmpty(list2)){
			return list2.stream().filter(StringUtils::isNotEmpty).map(StringUtils::handleNull).collect(Collectors.joining("、"));
		}else{
			return "";
		}
	}

	/**
	 * @Description 字符串连接
	 * @Param [obs]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2022.02.12 17:21
	 **/
	public  static Object _concat(Object ...obs){
		StringBuilder sb  = new StringBuilder();
		if(obs!=null){
			for(Object ob:obs){
				sb.append(handleNull(ob));
			}
		}
        return sb.toString();
	}
	public  static Object concat(Object o1,Object o2,Object o3,Object o4){
		return _concat(o1,o2,o3,o4);
	}
	public  static Object concat(Object o1,Object o2,Object o3){
		return _concat(o1,o2,o3);
	}
	public  static Object concat(Object o1,Object o2){
		return _concat(o1,o2);
	}
	public  static Object concat(Object o1){
		return _concat(o1);
	}


	/**
	 * @Description 总体标准差
	 * @Param [data, scale]
	 * @return java.lang.Object
	 * @Author yangyj
	 * @Date 2022.04.14 11:32
	 **/
	public  static Object sd(Object data,Object scale){
		if(data!=null&&StringUtils.isNumber(scale)){
			data=removeEmpty(data);
			List<Object> datas=obj2List(data);
			int total=datas.size();
			List<String> _datas=datas.stream().map(StringUtils::handleNull).collect(Collectors.toList());
			double avgVal=_datas.stream().mapToDouble(Double::parseDouble).average().orElse(0D);
			double result=Math.sqrt(_datas.stream().mapToDouble(Double::parseDouble).map(e->Math.pow(e-avgVal,2)).sum()/total);
			return  StringUtils.number2String(result,scale);
		}
		return "";
	}



//	public static void main(String[] args)  {
//	}

}
