| 
														
															@@ -3,7 +3,10 @@ package com.jjt.utils; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import cn.hutool.json.JSONArray; 
														 | 
														
														 | 
														
															 import cn.hutool.json.JSONArray; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import cn.hutool.json.JSONObject; 
														 | 
														
														 | 
														
															 import cn.hutool.json.JSONObject; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.jjt.biz.domain.TwinDevice; 
														 | 
														
														 | 
														
															 import com.jjt.biz.domain.TwinDevice; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-import com.jjt.calc.domain.*; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import com.jjt.calc.domain.TwinCalcHour; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import com.jjt.calc.domain.TwinCalcHourSpec; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import com.jjt.calc.domain.TwinRecordAlarms; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import com.jjt.calc.domain.TwinRecordStop; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.jjt.common.utils.DateUtils; 
														 | 
														
														 | 
														
															 import com.jjt.common.utils.DateUtils; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import lombok.extern.slf4j.Slf4j; 
														 | 
														
														 | 
														
															 import lombok.extern.slf4j.Slf4j; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.springframework.scheduling.annotation.Async; 
														 | 
														
														 | 
														
															 import org.springframework.scheduling.annotation.Async; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -14,7 +17,6 @@ import javax.annotation.Resource; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import java.math.BigDecimal; 
														 | 
														
														 | 
														
															 import java.math.BigDecimal; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import java.math.RoundingMode; 
														 | 
														
														 | 
														
															 import java.math.RoundingMode; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import java.time.LocalDateTime; 
														 | 
														
														 | 
														
															 import java.time.LocalDateTime; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-import java.time.ZoneOffset; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import java.util.*; 
														 | 
														
														 | 
														
															 import java.util.*; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import java.util.concurrent.Future; 
														 | 
														
														 | 
														
															 import java.util.concurrent.Future; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import java.util.stream.Collectors; 
														 | 
														
														 | 
														
															 import java.util.stream.Collectors; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -31,25 +33,34 @@ public class AsyncService { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     @Resource 
														 | 
														
														 | 
														
															     @Resource 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     private IotService iotService; 
														 | 
														
														 | 
														
															     private IotService iotService; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     /** 
														 | 
														
														 | 
														
															     /** 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-     * 字段列表,方便看下标 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     * 小经编字段列表,方便看下标 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      */ 
														 | 
														
														 | 
														
															      */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    private final String[] fields = {"Capacity_data_2", "Capacity_data_37", "Capacity_data_38", "Capacity_data_39", "Capacity_data_42", 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            "Capacity_data_43", "Capacity_data_44", "Capacity_data_48", "Formula_data_3", "Formula_data_13", 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            "Capacity_data_36", "Capacity_data_41", "Alarm_unit_1", "Alarm_unit_2", "Alarm_unit_3", 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    private final String[] xFields = { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            "Capacity_data_1", "Capacity_data_2", "Capacity_data_15", "Capacity_data_16", "Capacity_data_17", 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            "Capacity_data_18", "Capacity_data_19", "Capacity_data_48", 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            "Formula_data_3", "Formula_data_15", "Formula_data_24", "Alarm_unit_1", 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            "Alarm_unit_10", "Alarm_unit_11", "Alarm_unit_12", "Alarm_unit_13", "Alarm_unit_14", 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            "Alarm_unit_15", "Alarm_unit_16", "Alarm_unit_17", "Alarm_unit_18", "Alarm_unit_19", 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            "Alarm_unit_2", "Alarm_unit_20", "Alarm_unit_21", "Alarm_unit_22", "Alarm_unit_23", 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            "Alarm_unit_24", "Alarm_unit_25", "Alarm_unit_26", "Alarm_unit_27", "Alarm_unit_3", 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             "Alarm_unit_4", "Alarm_unit_5", "Alarm_unit_6", "Alarm_unit_7", "Alarm_unit_8", 
														 | 
														
														 | 
														
															             "Alarm_unit_4", "Alarm_unit_5", "Alarm_unit_6", "Alarm_unit_7", "Alarm_unit_8", 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            "Alarm_unit_9", "Alarm_unit_10", "Alarm_unit_11", "Alarm_unit_12", "Alarm_unit_13", 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            "Alarm_unit_14", "Alarm_unit_15", "Alarm_unit_16", "Alarm_unit_17", "Alarm_unit_18", 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            "Alarm_unit_19", "Alarm_unit_20", "Alarm_unit_21", "Alarm_unit_22", "Alarm_unit_23", 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            "Alarm_unit_24", "Alarm_unit_25", "Alarm_unit_26", "Alarm_unit_27", "Capacity_data_33", 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            "Capacity_data_15", "Capacity_data_16", "Capacity_data_17", "Capacity_data_18", "Capacity_data_19", 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            "Capacity_data_34", "Formula_data_24", "Formula_data_15", "Capacity_data_1" 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            "Alarm_unit_9" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    }; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    /** 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     * 大经编字段列表,方便看下标 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    private final String[] dFields = { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            "Capacity_data_117 AS Capacity_data_1", "Capacity_data_177 AS Capacity_data_2", "Capacity_data_15", "Capacity_data_16", "Capacity_data_17", 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            "Capacity_data_18", "Capacity_data_19", "Capacity_data_118 AS Capacity_data_48", 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            "Formula_data_43 AS Formula_data_3", "Formula_data_55 AS Formula_data_15", "Capacity_data_112 AS Formula_data_24" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     }; 
														 | 
														
														 | 
														
															     }; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     /** 
														 | 
														
														 | 
														
															     /** 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      * 字段列表,方便查找位置 
														 | 
														
														 | 
														
															      * 字段列表,方便查找位置 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      */ 
														 | 
														
														 | 
														
															      */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    private final List<String> fieldList = Arrays.stream(fields).collect(Collectors.toList()); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    private final List<String> fieldList = Arrays.stream(xFields).collect(Collectors.toList()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     @Async("threadPoolTaskExecutor") 
														 | 
														
														 | 
														
															     @Async("threadPoolTaskExecutor") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     public Future<Map<String, Object>> currData(TwinDevice twinDevice) { 
														 | 
														
														 | 
														
															     public Future<Map<String, Object>> currData(TwinDevice twinDevice) { 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -83,20 +94,15 @@ public class AsyncService { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     public Future<Map<String, List<?>>> process(TwinDevice twinDevice, LocalDateTime start, LocalDateTime end) { 
														 | 
														
														 | 
														
															     public Future<Map<String, List<?>>> process(TwinDevice twinDevice, LocalDateTime start, LocalDateTime end) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         //开始时间都减了一秒的,这里要加回来,用于计算时段等数据 
														 | 
														
														 | 
														
															         //开始时间都减了一秒的,这里要加回来,用于计算时段等数据 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         LocalDateTime ldt = start.plusSeconds(1); 
														 | 
														
														 | 
														
															         LocalDateTime ldt = start.plusSeconds(1); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        Date date = Date.from(ldt.toLocalDate().atStartOfDay(ZoneOffset.of("+8")).toInstant()); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        Long startTime = start.toInstant(ZoneOffset.of("+8")).toEpochMilli(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        Long endTime = end.toInstant(ZoneOffset.of("+8")).toEpochMilli(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        Date date = DateUtils.toDate(ldt.toLocalDate()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         int period = ldt.getHour(); 
														 | 
														
														 | 
														
															         int period = ldt.getHour(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         Map<String, List<?>> result = new HashMap<>(16); 
														 | 
														
														 | 
														
															         Map<String, List<?>> result = new HashMap<>(16); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         List<TwinCalcHour> calcHours = new ArrayList<>(); 
														 | 
														
														 | 
														
															         List<TwinCalcHour> calcHours = new ArrayList<>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        String table = twinDevice.getDevicePath(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         TwinCalcHour hour = new TwinCalcHour(); 
														 | 
														
														 | 
														
															         TwinCalcHour hour = new TwinCalcHour(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         hour.setDeviceId(twinDevice.getDeviceId()); 
														 | 
														
														 | 
														
															         hour.setDeviceId(twinDevice.getDeviceId()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         hour.setDataDate(date); 
														 | 
														
														 | 
														
															         hour.setDataDate(date); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         hour.setHour(period); 
														 | 
														
														 | 
														
															         hour.setHour(period); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        Map<String, Object> map = calc(table, startTime, endTime); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        Map<String, Object> map = calc(twinDevice, start, end); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															         //0.已织造米数  1.总能耗 2.总重量 3.开机时间 4.关机时间 
														 | 
														
														 | 
														
															         //0.已织造米数  1.总能耗 2.总重量 3.开机时间 4.关机时间 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         float[] total = (float[]) map.get("total"); 
														 | 
														
														 | 
														
															         float[] total = (float[]) map.get("total"); 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -107,9 +113,6 @@ public class AsyncService { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         hour.setCloseTime((long) total[4]); 
														 | 
														
														 | 
														
															         hour.setCloseTime((long) total[4]); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         calcHours.add(hour); 
														 | 
														
														 | 
														
															         calcHours.add(hour); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        List<TwinPanHeadInfo> panHeadInfo = (List<TwinPanHeadInfo>) map.get("panHead"); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        panHeadInfo.forEach(info -> info.setDeviceId(twinDevice.getDeviceId())); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         List<TwinCalcHourSpec> specs = (List<TwinCalcHourSpec>) map.get("specList"); 
														 | 
														
														 | 
														
															         List<TwinCalcHourSpec> specs = (List<TwinCalcHourSpec>) map.get("specList"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         specs.forEach(spec -> { 
														 | 
														
														 | 
														
															         specs.forEach(spec -> { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             spec.setDeviceId(twinDevice.getDeviceId()); 
														 | 
														
														 | 
														
															             spec.setDeviceId(twinDevice.getDeviceId()); 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -180,7 +183,6 @@ public class AsyncService { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         result.put("calc", calcHours); 
														 | 
														
														 | 
														
															         result.put("calc", calcHours); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         result.put("stopRecord", newStopRecord); 
														 | 
														
														 | 
														
															         result.put("stopRecord", newStopRecord); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         result.put("alarmRecord", newAlarmRecord); 
														 | 
														
														 | 
														
															         result.put("alarmRecord", newAlarmRecord); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        result.put("panHead", panHeadInfo); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         result.put("specList", specs); 
														 | 
														
														 | 
														
															         result.put("specList", specs); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         return new AsyncResult<>(result); 
														 | 
														
														 | 
														
															         return new AsyncResult<>(result); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -188,25 +190,28 @@ public class AsyncService { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     /** 
														 | 
														
														 | 
														
															     /** 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      * //    0        Capacity_data_2	已织造米数 
														 | 
														
														 | 
														
															      * //    0        Capacity_data_2	已织造米数 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-     * //    1        Capacity_data_37	A班组开机时间 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-     * //    2        Capacity_data_38	A班组停机时间 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-     * //    3        Capacity_data_39	A班当前产量 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-     * //    4        Capacity_data_42	B班组开机时间 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-     * //    5        Capacity_data_43	B班组停机时间 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-     * //    6        Capacity_data_44	B班当前产量 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      * //    7        Capacity_data_48	停机状态 
														 | 
														
														 | 
														
															      * //    7        Capacity_data_48	停机状态 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      * //    8        Formula_data_3	米克重 
														 | 
														
														 | 
														
															      * //    8        Formula_data_3	米克重 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      * //    9        Formula_data_13	卷曲幅宽 
														 | 
														
														 | 
														
															      * //    9        Formula_data_13	卷曲幅宽 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      */ 
														 | 
														
														 | 
														
															      */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    public Map<String, Object> calc(String table, long startTime, long endTime) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    public Map<String, Object> calc(TwinDevice twinDevice, LocalDateTime start, LocalDateTime end) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        //为true表示小经编,false表示大经编 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        boolean flag = twinDevice.getDeviceCode().startsWith("C_"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        String table = twinDevice.getDevicePath(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        String[] fields = xFields; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        if (!flag) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            fields = dFields; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         String sql = "select %s from %s where time>%s and time <=%s"; 
														 | 
														
														 | 
														
															         String sql = "select %s from %s where time>%s and time <=%s"; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        sql = String.format(sql, String.join(",", fields), table, startTime, endTime); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        sql = String.format(sql, String.join(",", fields), table, DateUtils.parseIso(start), DateUtils.parseIso(end)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         long s = System.currentTimeMillis(); 
														 | 
														
														 | 
														
															         long s = System.currentTimeMillis(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         JSONObject jsonObject = iotService.query(sql); 
														 | 
														
														 | 
														
															         JSONObject jsonObject = iotService.query(sql); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         long e = System.currentTimeMillis(); 
														 | 
														
														 | 
														
															         long e = System.currentTimeMillis(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        log.info("接口耗时:{}ms,table:{},time:{}", e - s, table, DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, new Date(endTime))); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        log.info("接口耗时:{}ms,table:{},time:{}", e - s, table, end); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         JSONObject data = jsonObject.getJSONObject("data"); 
														 | 
														
														 | 
														
															         JSONObject data = jsonObject.getJSONObject("data"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         JSONArray values = data.getJSONArray("values"); 
														 | 
														
														 | 
														
															         JSONArray values = data.getJSONArray("values"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        values = mergedValues(values); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         JSONArray timestamps = data.getJSONArray("timestamps"); 
														 | 
														
														 | 
														
															         JSONArray timestamps = data.getJSONArray("timestamps"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         //初始时间点数据 
														 | 
														
														 | 
														
															         //初始时间点数据 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         //0-data2,1-data37,2-data38,3-data39,4-data42,5-data-43,6data-44 
														 | 
														
														 | 
														
															         //0-data2,1-data37,2-data38,3-data39,4-data42,5-data-43,6data-44 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -218,112 +223,138 @@ public class AsyncService { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         float[] last = new float[3]; 
														 | 
														
														 | 
														
															         float[] last = new float[3]; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         //统计数据,后面2个分别代表0.织造米长,1.电量 2.重量,3.开机时间,4.停机时间 
														 | 
														
														 | 
														
															         //统计数据,后面2个分别代表0.织造米长,1.电量 2.重量,3.开机时间,4.停机时间 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         float[] total = new float[5]; 
														 | 
														
														 | 
														
															         float[] total = new float[5]; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        //上一个时间点盘头数据 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        int[] lastPanHead = new int[5]; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         //米克重 
														 | 
														
														 | 
														
															         //米克重 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         int lastMkz = 0; 
														 | 
														
														 | 
														
															         int lastMkz = 0; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        //卷曲幅宽 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        float lastFk = 0f; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         //毛高 
														 | 
														
														 | 
														
															         //毛高 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         float lastHeight = 0f; 
														 | 
														
														 | 
														
															         float lastHeight = 0f; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         //上次密度记录的米长 
														 | 
														
														 | 
														
															         //上次密度记录的米长 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         float lastSpecLength = 0f; 
														 | 
														
														 | 
														
															         float lastSpecLength = 0f; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        //开始不为0的电能 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        //不为0的电能结束 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        float startKwh = 0f, endKwh = 0f; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         int last48 = 0; 
														 | 
														
														 | 
														
															         int last48 = 0; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         //告警时间记录 
														 | 
														
														 | 
														
															         //告警时间记录 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         List<TwinRecordAlarms> alarmRecord = new ArrayList<>(); 
														 | 
														
														 | 
														
															         List<TwinRecordAlarms> alarmRecord = new ArrayList<>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         //停机记录 
														 | 
														
														 | 
														
															         //停机记录 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         List<TwinRecordStop> stopRecord = new ArrayList<>(); 
														 | 
														
														 | 
														
															         List<TwinRecordStop> stopRecord = new ArrayList<>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        //盘头记录 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        List<TwinPanHeadInfo> panHeadInfo = new ArrayList<>(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															         for (int i = 0; i < values.size(); i++) { 
														 | 
														
														 | 
														
															         for (int i = 0; i < values.size(); i++) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             JSONArray da = values.getJSONArray(i); 
														 | 
														
														 | 
														
															             JSONArray da = values.getJSONArray(i); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            //0-data2,1-data37,2-data38,3-data39,4-data42,5-data-43,6data-44 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            //当前时间数据 米长,正向电能,牵拉密度 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            float[] curr = {da.getFloat(fieldList.indexOf("Capacity_data_2")), da.getFloat(fieldList.indexOf("Capacity_data_34")), da.getFloat(fieldList.indexOf("Formula_data_24"))}; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            int[] currPan = {da.getInt(fieldList.indexOf("Capacity_data_15")), da.getInt(fieldList.indexOf("Capacity_data_16")), da.getInt(fieldList.indexOf("Capacity_data_17")), 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    da.getInt(fieldList.indexOf("Capacity_data_18")), da.getInt(fieldList.indexOf("Capacity_data_19"))}; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            int curr48 = da.getInt(7); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            //当前时间数据 米长,正向电能,牵拉密度 2025-06-19 取消电量计算没必要了 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            float[] curr = {da.getFloat(fieldList.indexOf("Capacity_data_2")), 0f, da.getFloat(fieldList.indexOf("Formula_data_24"))}; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            int curr48 = da.getInt(fieldList.indexOf("Capacity_data_48")); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															             if (i == 0) { 
														 | 
														
														 | 
														
															             if (i == 0) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 //第一次数据是上次最后一条,只做记录用,不做处理 
														 | 
														
														 | 
														
															                 //第一次数据是上次最后一条,只做记录用,不做处理 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 first = curr.clone(); 
														 | 
														
														 | 
														
															                 first = curr.clone(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 last = curr.clone(); 
														 | 
														
														 | 
														
															                 last = curr.clone(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                lastPanHead = currPan.clone(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                lastMkz = da.getInt(8); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                lastFk = da.getFloat(9); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                lastMkz = da.getInt(fieldList.indexOf("Formula_data_3")); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 lastHeight = da.getFloat(fieldList.indexOf("Formula_data_15")); 
														 | 
														
														 | 
														
															                 lastHeight = da.getFloat(fieldList.indexOf("Formula_data_15")); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 last48 = curr48; 
														 | 
														
														 | 
														
															                 last48 = curr48; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                startKwh = da.getFloat(fieldList.indexOf("Capacity_data_34")); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 continue; 
														 | 
														
														 | 
														
															                 continue; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             } 
														 | 
														
														 | 
														
															             } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            //计算盘头 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            calcPan(currPan, lastPanHead, panHeadInfo, timestamps.getLong(i)); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            //计算规格米长 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             if (last[2] != curr[2]) { 
														 | 
														
														 | 
														
															             if (last[2] != curr[2]) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 calcSpec(total[0], lastSpecLength, last[2], lastMkz, lastHeight, specList); 
														 | 
														
														 | 
														
															                 calcSpec(total[0], lastSpecLength, last[2], lastMkz, lastHeight, specList); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 lastSpecLength = total[0]; 
														 | 
														
														 | 
														
															                 lastSpecLength = total[0]; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             } 
														 | 
														
														 | 
														
															             } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            //处理电量跳点 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            float currKwh = da.getFloat(fieldList.indexOf("Capacity_data_34")); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            if (startKwh == 0) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                startKwh = currKwh; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            if (currKwh != 0f) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                endKwh = currKwh; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-//            for (int j = 0; j < first.length; j++) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             //如果当前值为小于上一个,且上一个值不为0,则计算 
														 | 
														
														 | 
														
															             //如果当前值为小于上一个,且上一个值不为0,则计算 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             //因为会出现数据波动,停机再启动之后的第一个点不为0,为0.00几几几的 
														 | 
														
														 | 
														
															             //因为会出现数据波动,停机再启动之后的第一个点不为0,为0.00几几几的 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             //计算累加类的数据 
														 | 
														
														 | 
														
															             //计算累加类的数据 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             //这里只计算米长 
														 | 
														
														 | 
														
															             //这里只计算米长 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             if (curr[0] < last[0] && last[0] != 0f) { 
														 | 
														
														 | 
														
															             if (curr[0] < last[0] && last[0] != 0f) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                calcTotal(0, last, first, total, lastMkz, lastFk); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                calcTotal(0, last, first, total, lastMkz, lastFk); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                calcTotal(0, last, first, total, lastMkz); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 first[0] = curr[0]; 
														 | 
														
														 | 
														
															                 first[0] = curr[0]; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             } 
														 | 
														
														 | 
														
															             } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-//            } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            calcAlarms(values, timestamps.getLong(i), alarmRecord, i); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            if (flag) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                calcAlarms(values, timestamps.getLong(i), alarmRecord, i); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             calcStops(curr48, last48, timestamps.getLong(i), total, stopRecord, i); 
														 | 
														
														 | 
														
															             calcStops(curr48, last48, timestamps.getLong(i), total, stopRecord, i); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															             //复制数组,设置last值为当前值 
														 | 
														
														 | 
														
															             //复制数组,设置last值为当前值 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             last = curr.clone(); 
														 | 
														
														 | 
														
															             last = curr.clone(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            lastPanHead = currPan.clone(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            if (da.getInt(8) != 0) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                lastMkz = da.getInt(8); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            if (da.getInt(fieldList.indexOf("Formula_data_3")) != 0) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                lastMkz = da.getInt(fieldList.indexOf("Formula_data_3")); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             } 
														 | 
														
														 | 
														
															             } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            lastFk = da.getFloat(9); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             lastHeight = da.getFloat(fieldList.indexOf("Formula_data_15")); 
														 | 
														
														 | 
														
															             lastHeight = da.getFloat(fieldList.indexOf("Formula_data_15")); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             last48 = curr48; 
														 | 
														
														 | 
														
															             last48 = curr48; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        //最后再补一次计算 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-//        for (int j = 0; j < first.length; j++) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-//            //这里米长和电量都要计算 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-//            calcTotal(j, last, first, total, lastMkz, lastFk); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-//        } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         //还是只计算米长 
														 | 
														
														 | 
														
															         //还是只计算米长 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        calcTotal(0, last, first, total, lastMkz, lastFk); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        calcSpec(total[0], lastSpecLength, last[2], lastMkz, lastHeight, specList); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        //计算电量 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        total[1] = endKwh - startKwh; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        calcTotal(0, last, first, total, lastMkz); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        calcSpec(total[0], lastSpecLength, last[2], lastMkz, lastHeight, specList); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         total[3] = 3600 - total[4]; 
														 | 
														
														 | 
														
															         total[3] = 3600 - total[4]; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															         Map<String, Object> result = new HashMap<>(16); 
														 | 
														
														 | 
														
															         Map<String, Object> result = new HashMap<>(16); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         result.put("total", total); 
														 | 
														
														 | 
														
															         result.put("total", total); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         result.put("stopRecord", stopRecord); 
														 | 
														
														 | 
														
															         result.put("stopRecord", stopRecord); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         result.put("alarmRecord", alarmRecord); 
														 | 
														
														 | 
														
															         result.put("alarmRecord", alarmRecord); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        result.put("panHead", panHeadInfo); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         result.put("specList", specList); 
														 | 
														
														 | 
														
															         result.put("specList", specList); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         return result; 
														 | 
														
														 | 
														
															         return result; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     /** 
														 | 
														
														 | 
														
															     /** 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     * 处理数据 一会这儿有,一会那个有的情况 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     * 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     * @param values 原始数据 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    private JSONArray mergedValues(JSONArray values) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        /* 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+         * 合并values数组中的数据,将缺失的数据补全 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+         * 1. 遍历values数组,从第二条记录开始(第一条作为基准) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+         * 2. 将后续记录中非空的字段值补到第一条记录的对应位置 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+         * 3. 当第一条记录所有字段都非空时停止处理 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+         */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        JSONArray mergedValues = new JSONArray(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        JSONArray firstValues = values.getJSONArray(0); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        for (int i = 1; i < values.size(); i++) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            JSONArray curr = values.getJSONArray(i); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            // 遍历当前记录的每个字段 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            for (int j = 0; j < curr.size(); j++) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                // 如果当前字段有值且第一条记录的对应字段为空,则补充值 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                if (curr.get(j) != null && !curr.get(j).toString().isEmpty() 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                        && (firstValues.get(j) == null || firstValues.get(j).toString().isEmpty())) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    firstValues.set(j, curr.get(j)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            // 检查第一条记录是否所有字段都已补全 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            boolean isAll = true; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            for (Object firstValue : firstValues) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                if (firstValue == null || firstValue.toString().isEmpty()) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    isAll = false; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    break; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            // 如果所有字段都已补全,则停止处理 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            if (isAll) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                break; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        for (int i = 0; i < values.size(); i++) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            JSONArray curr = values.getJSONArray(i); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            JSONArray merged = new JSONArray(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            if (i > 0) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                // 取前一条记录作为基准 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                JSONArray prev = mergedValues.getJSONArray(i - 1); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                for (int j = 0; j < curr.size(); j++) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    if (curr.get(j) != null && !curr.get(j).toString().isEmpty()) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                        merged.add(curr.get(j)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    } else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                        merged.add(prev.get(j)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                // 第一条记录直接使用 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                merged = curr; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            mergedValues.add(merged); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        return mergedValues; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    /** 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      * 按规格计算米长 
														 | 
														
														 | 
														
															      * 按规格计算米长 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      * 
														 | 
														
														 | 
														
															      * 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      * @param len         当前米长 
														 | 
														
														 | 
														
															      * @param len         当前米长 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -344,28 +375,6 @@ public class AsyncService { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         specList.add(spec); 
														 | 
														
														 | 
														
															         specList.add(spec); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    /** 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-     * 计算盘头信息 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-     * 数组 分别是GB1-GB5 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-     * 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-     * @param currPan     当前剩余圈数 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-     * @param lastPanHead 上一条记录剩余圈数 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-     * @param panHeadInfo info 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-     * @param time        时间戳 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-     */ 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    private void calcPan(int[] currPan, int[] lastPanHead, List<TwinPanHeadInfo> panHeadInfo, Long time) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        //如果当前记录大于上一条记录,则证明是重新叫料了,需要记录下当前值 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        for (int i = 0; i < currPan.length; i++) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            if (currPan[i] > lastPanHead[i]) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                TwinPanHeadInfo info = new TwinPanHeadInfo(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                info.setRecordTime(new Date(time)); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                info.setPhNum((long) (i + 1)); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                info.setPhMax((long) currPan[i]); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                panHeadInfo.add(info); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     /** 
														 | 
														
														 | 
														
															     /** 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      * 停机次数计算 
														 | 
														
														 | 
														
															      * 停机次数计算 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -446,15 +455,15 @@ public class AsyncService { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             } 
														 | 
														
														 | 
														
															             } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             //需要单独计算alarm27 
														 | 
														
														 | 
														
															             //需要单独计算alarm27 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             //数据位置 
														 | 
														
														 | 
														
															             //数据位置 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            int pos = j + 12; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            int curr27 = curr.getInt(pos); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            if (curr27 != 0) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                flags[j] = false; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                recordAlarms = new TwinRecordAlarms(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                recordAlarms.setAlarmType(j + 1); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                recordAlarms.setStartTime(new Date(time)); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                alarmRecord.add(recordAlarms); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//            int pos = j + 12; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//            int curr27 = curr.getInt(pos); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//            if (curr27 != 0) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                flags[j] = false; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                recordAlarms = new TwinRecordAlarms(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                recordAlarms.setAlarmType(j + 1); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                recordAlarms.setStartTime(new Date(time)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                alarmRecord.add(recordAlarms); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         int j = 0; 
														 | 
														
														 | 
														
															         int j = 0; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         for (; j < index; j++) { 
														 | 
														
														 | 
														
															         for (; j < index; j++) { 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -478,32 +487,32 @@ public class AsyncService { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 } 
														 | 
														
														 | 
														
															                 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             } 
														 | 
														
														 | 
														
															             } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        if (flags[j]) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            //需要单独计算alarm27 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            //数据位置 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            int pos = j + 12; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            int alarm27 = curr.getInt(pos); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            //上面已经处理过i=0,所以这里i不可能等于0 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            int last27 = last.getInt(pos); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            if (alarm27 != 0 && last27 == 0) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                recordAlarms = new TwinRecordAlarms(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                recordAlarms.setAlarmType(j + 1); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                recordAlarms.setStartTime(new Date(time)); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                alarmRecord.add(recordAlarms); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            if (alarm27 == 0 && last27 != 0) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                recordAlarms = new TwinRecordAlarms(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                recordAlarms.setAlarmType(j + 1); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                recordAlarms.setEndTime(new Date(time)); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                alarmRecord.add(recordAlarms); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//        if (flags[j]) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//            //需要单独计算alarm27 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//            //数据位置 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//            int pos = j + 12; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//            int alarm27 = curr.getInt(pos); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//            //上面已经处理过i=0,所以这里i不可能等于0 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//            int last27 = last.getInt(pos); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//            if (alarm27 != 0 && last27 == 0) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                recordAlarms = new TwinRecordAlarms(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                recordAlarms.setAlarmType(j + 1); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                recordAlarms.setStartTime(new Date(time)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                alarmRecord.add(recordAlarms); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//            if (alarm27 == 0 && last27 != 0) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                recordAlarms = new TwinRecordAlarms(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                recordAlarms.setAlarmType(j + 1); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                recordAlarms.setEndTime(new Date(time)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                alarmRecord.add(recordAlarms); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     /** 
														 | 
														
														 | 
														
															     /** 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      * 重量计算 提取公共方法 
														 | 
														
														 | 
														
															      * 重量计算 提取公共方法 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      */ 
														 | 
														
														 | 
														
															      */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    private void calcTotal(int j, float[] last, float[] first, float[] total, int lastMkz, float lastFk) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    private void calcTotal(int j, float[] last, float[] first, float[] total, int lastMkz) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         float v = last[j] - first[j]; 
														 | 
														
														 | 
														
															         float v = last[j] - first[j]; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         total[j] += v; 
														 | 
														
														 | 
														
															         total[j] += v; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         if (j == 0) { 
														 | 
														
														 | 
														
															         if (j == 0) { 
														 |