| | |
| | | import com.core.common.Arith; |
| | | import com.core.common.Cools; |
| | | import com.core.common.SpringUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.BasCrnp; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.service.BasCrnpService; |
| | |
| | | import com.zy.core.model.protocol.CrnProtocol; |
| | | import com.zy.core.thread.CrnThread; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.text.DecimalFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Arrays; |
| | | import java.util.Comparator; |
| | | import java.util.HashSet; |
| | | import java.util.Set; |
| | | import java.util.*; |
| | | |
| | | public class Utils { |
| | | |
| | | private static final String LOC_NO_FLAG = "-"; |
| | | private static final DecimalFormat fmt = new DecimalFormat("##0.00"); |
| | | private static Integer defaultDeviceLogCollectTime = 200; |
| | | private static Long lastUpdateDeviceLogCollectTime = -1L; |
| | | |
| | | public static float scale(Float f){ |
| | | if (f == null || f == 0f || Float.isNaN(f)) { |
| | |
| | | |
| | | //获取设备日志采集时间 |
| | | public static int getDeviceLogCollectTime() { |
| | | int defaultTime = 200; |
| | | try { |
| | | RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class); |
| | | if (redisUtil == null) { |
| | | return defaultTime; |
| | | } |
| | | if (defaultDeviceLogCollectTime == null || System.currentTimeMillis() - lastUpdateDeviceLogCollectTime > 60 * 1000) { |
| | | int defaultTime = 200; |
| | | lastUpdateDeviceLogCollectTime = System.currentTimeMillis(); |
| | | try { |
| | | RedisUtil redisUtil = null; |
| | | try { |
| | | redisUtil = SpringUtils.getBean(RedisUtil.class); |
| | | } catch (CoolException coolException) { |
| | | |
| | | Object object = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key); |
| | | if (object == null) { |
| | | return defaultTime; |
| | | } |
| | | } |
| | | if (redisUtil == null) { |
| | | return defaultTime; |
| | | } |
| | | |
| | | HashMap<String, String> systemConfigMap = (HashMap<String, String>) object; |
| | | String deviceLogCollectTime = systemConfigMap.get("deviceLogCollectTime"); |
| | | if(deviceLogCollectTime == null){ |
| | | return defaultTime; |
| | | } |
| | | Object object = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key); |
| | | if (object == null) { |
| | | return defaultTime; |
| | | } |
| | | |
| | | return Integer.parseInt(deviceLogCollectTime); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | HashMap<String, String> systemConfigMap = (HashMap<String, String>) object; |
| | | String deviceLogCollectTime = systemConfigMap.get("deviceLogCollectTime"); |
| | | if(deviceLogCollectTime == null){ |
| | | return defaultTime; |
| | | } |
| | | |
| | | return Integer.parseInt(deviceLogCollectTime); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return defaultTime; |
| | | return defaultDeviceLogCollectTime; |
| | | } |
| | | |
| | | //获取入库任务可用排 |
| | |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | |
| | | public static Map<String, Object> convertObjectToMap(Object obj) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | Class<?> clazz = obj.getClass(); |
| | | Field[] fields = clazz.getDeclaredFields(); |
| | | for (Field field : fields) { |
| | | field.setAccessible(true); |
| | | try { |
| | | map.put(field.getName(), field.get(obj)); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return map; |
| | | } |
| | | } |