package com.zy.asrs.utils; import com.core.common.Arith; import com.core.common.Cools; import com.zy.core.properties.SlaveProperties; import java.lang.reflect.Field; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * Created by vincent on 2020/8/27 */ public class Utils { private static final DecimalFormat fmt = new DecimalFormat("##0.00"); public static float scale(Float f){ if (f == null || f == 0f || Float.isNaN(f)) { return 0f; } return (float) Arith.multiplys(2, f, 1); } public static String zerofill(String msg, Integer count){ if (msg.length() == count){ return msg; } else if (msg.length() > count){ return msg.substring(0, 16); } else { StringBuilder msgBuilder = new StringBuilder(msg); for (int i = 0; i objectToMap(Object obj) { Map map = new HashMap<>(); Field[] fields = obj.getClass().getDeclaredFields(); for (Field field : fields) { field.setAccessible(true); // 设置私有字段可访问 try { map.put(field.getName(), field.get(obj)); } catch (IllegalAccessException e) { e.printStackTrace(); } } return map; } public static void main(String[] args) { SlaveProperties slaveProperties = new SlaveProperties(); slaveProperties.setDoubleDeep(true); List list = new ArrayList<>(); list.add(1);list.add(4);list.add(5);list.add(8);list.add(9);list.add(12); slaveProperties.setDoubleLocs(list); slaveProperties.setGroupCount(4); Integer deepRow = getDeepRow(slaveProperties, 6); System.out.println(deepRow); } }