From 11d4be720620abf502d35000e2ed40d30c4023bf Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期一, 24 十一月 2025 16:33:34 +0800
Subject: [PATCH] 修复离线时间展示

---
 collect/src/main/java/com/qianwen/mdc/collect/service/DeviceStateService.java |  100 +++++++++++++++++++++++++++-----------------------
 1 files changed, 54 insertions(+), 46 deletions(-)

diff --git a/collect/src/main/java/com/qianwen/mdc/collect/service/DeviceStateService.java b/collect/src/main/java/com/qianwen/mdc/collect/service/DeviceStateService.java
index 95725fb..8a68ca3 100644
--- a/collect/src/main/java/com/qianwen/mdc/collect/service/DeviceStateService.java
+++ b/collect/src/main/java/com/qianwen/mdc/collect/service/DeviceStateService.java
@@ -1,10 +1,6 @@
 package com.qianwen.mdc.collect.service;
 
-import java.time.LocalDateTime;
-import java.time.ZoneId;
 import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -18,24 +14,9 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import com.google.common.collect.Lists;
-import com.qianwen.core.tool.utils.Func;
-import com.qianwen.core.tool.utils.SpringUtil;
-import com.qianwen.mdc.collect.cache.WorkstationCache;
 import com.qianwen.mdc.collect.config.IotDBSessionConfig;
-import com.qianwen.mdc.collect.constants.CommonConstant;
 import com.qianwen.mdc.collect.constants.IOTDBConstant;
-import com.qianwen.mdc.collect.dto.CalendarShiftInfoDTO;
-import com.qianwen.mdc.collect.dto.WorkstationDTO;
 import com.qianwen.mdc.collect.entity.iotdb.DeviceState;
-import com.qianwen.mdc.collect.enums.FeedbackTimePointEnum;
-import com.qianwen.mdc.collect.mapper.mgr.CalendarMapper;
-import com.qianwen.mdc.collect.utils.LocalDateTimeUtils;
-
-import cn.hutool.core.date.DatePattern;
-import cn.hutool.core.date.DateTime;
-import cn.hutool.core.date.DateUtil;
-import cn.hutool.core.util.ObjectUtil;
 /**
  * 璁惧鐘舵�佹櫘閫氭湇鍔�
  */
@@ -95,38 +76,65 @@
 			Tablet tablet = new Tablet(deviceId, schemas);
 			
 			states = entry.getValue();
-			tablet.rowSize = states.size();
 			DeviceState state;
-			for(int i=0;i<states.size();i++) {
+			
+			
+			final int MAX_COUNT = 1000;
+			//int currentIdx = 0;
+		
+				
+			int tblIndex = -1;
+			for(int i=0; i < states.size(); i++) {
 				state = states.get(i);
-				tablet.addTimestamp(i, state.getTime());
-				tablet.addValue("workstation_id", i, state.getWorkstationId());
-				tablet.addValue("value_collect", i, state.getValueCollect());
+				tblIndex = tablet.rowSize++;
+				tablet.addTimestamp(tblIndex, state.getTime());
+				tablet.addValue("workstation_id", tblIndex, state.getWorkstationId());
+				tablet.addValue("value_collect", tblIndex, state.getValueCollect());
 				
-				tablet.addValue("calendar_code", i, state.getCalendarCode());
-				tablet.addValue("factory_year", i, state.getFactoryYear());
-				tablet.addValue("factory_month", i, state.getFactoryMonth());
-				tablet.addValue("factory_week", i, state.getFactoryWeek());
-				tablet.addValue("factory_date", i, state.getFactoryDate());
-				tablet.addValue("shift_index", i, state.getShiftIndex());
-				tablet.addValue("shift_time_type", i, state.getShiftTimeType());
-				tablet.addValue("wcs", i, state.getWcs());
-				tablet.addValue("rps", i, state.getRps());
-				tablet.addValue("is_fix_point", i, state.getIsFixPoint());
-				tablet.addValue("is_sync", i, state.getIsSync());
-				tablet.addValue("is_plan", i, state.getIsPlan());
-				tablet.addValue("feedback_point_type", i, state.getFeedbackPointType());
-				tablet.addValue("feedback_id", i, state.getFeedbackId());
-				tablet.addValue("is_deleted", i, state.getIsDeleted());
-				tablet.addValue("employee_id", i, state.getEmployeeId());
+				tablet.addValue("calendar_code", tblIndex, state.getCalendarCode());
+				tablet.addValue("factory_year", tblIndex, state.getFactoryYear());
+				tablet.addValue("factory_month", tblIndex, state.getFactoryMonth());
+				tablet.addValue("factory_week", tblIndex, state.getFactoryWeek());
+				tablet.addValue("factory_date", tblIndex, state.getFactoryDate());
+				tablet.addValue("shift_index", tblIndex, state.getShiftIndex());
+				tablet.addValue("shift_time_type", tblIndex, state.getShiftTimeType());
+				tablet.addValue("wcs", tblIndex, state.getWcs());
+				tablet.addValue("rps", tblIndex, state.getRps());
+				tablet.addValue("is_fix_point", tblIndex, state.getIsFixPoint());
+				tablet.addValue("is_sync", tblIndex, state.getIsSync());
+				tablet.addValue("is_plan", tblIndex, state.getIsPlan());
+				tablet.addValue("feedback_point_type", tblIndex, state.getFeedbackPointType());
+				tablet.addValue("feedback_id", tblIndex, state.getFeedbackId());
+				tablet.addValue("is_deleted", tblIndex, state.getIsDeleted());
+				tablet.addValue("employee_id", tblIndex, state.getEmployeeId());
 				
+				//tblIndex++;
+				
+				if(tblIndex >= MAX_COUNT) {
+					try {
+						//姣忎釜宸ヤ綅鎵归噺鎻掑叆涓�娆℃暟鎹�
+						this.iotdbConfig.getSessionPool().insertAlignedTablet(tablet);
+						log.info("淇濆瓨璁惧鐘舵�佸畬鎴�");
+						tablet.reset();
+						tblIndex = -1;
+					} catch (Exception e) {
+						log.error("淇濆瓨鍥哄畾鐐规暟鎹紓甯�",e);
+					} 
+				}
 			}
-			try {
-				//姣忎釜宸ヤ綅鎵归噺鎻掑叆涓�娆℃暟鎹�
-				this.iotdbConfig.getSessionPool().insertAlignedTablet(tablet);
-			} catch (Exception e) {
-				log.error("淇濆瓨鍥哄畾鐐规暟鎹紓甯�",e);
-			} 
+			
+			if(tablet.rowSize > 0) {
+				try {
+					//姣忎釜宸ヤ綅鎵归噺鎻掑叆涓�娆℃暟鎹�
+					this.iotdbConfig.getSessionPool().insertAlignedTablet(tablet);
+					log.info("淇濆瓨璁惧鐘舵�佸畬鎴�2");
+					tablet.reset();
+					//tblIndex = -1;
+				} catch (Exception e) {
+					log.error("淇濆瓨鍥哄畾鐐规暟鎹紓甯�",e);
+				} 
+			}
+			
 			
 		}
     }

--
Gitblit v1.9.3