From 9a9b747962cc00801d8cce4137d1e123d556a79b Mon Sep 17 00:00:00 2001 From: yangys <y_ys79@sina.com> Date: 星期六, 02 十一月 2024 16:59:59 +0800 Subject: [PATCH] 修复iotdb大批插入数据问题 --- collect/src/main/java/com/qianwen/mdc/collect/service/DeviceStateAggregateNoFeedbackService.java | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-) diff --git a/collect/src/main/java/com/qianwen/mdc/collect/service/DeviceStateAggregateNoFeedbackService.java b/collect/src/main/java/com/qianwen/mdc/collect/service/DeviceStateAggregateNoFeedbackService.java index ef1a33a..fd4bdf7 100644 --- a/collect/src/main/java/com/qianwen/mdc/collect/service/DeviceStateAggregateNoFeedbackService.java +++ b/collect/src/main/java/com/qianwen/mdc/collect/service/DeviceStateAggregateNoFeedbackService.java @@ -97,13 +97,13 @@ iotDBCommonService.setTemmplateIfNotSet(IOTDBConstant.TEMPLATE_AGGREGATESTATE, deviceId);//鎸傝浇妯℃澘 Tablet tablet = new Tablet(deviceId, schemas); - tablet.rowSize = aggStates.size(); - + AggregateState aggState; - int tblIndex = 0; + int tblIndex = -1; for(int i=0;i<aggStates.size();i++) { aggState = aggStates.get(i); + tblIndex = tablet.rowSize++; tablet.addTimestamp(tblIndex, aggState.getTime()); tablet.addValue("workstation_id", tblIndex, aggState.getWorkstationId()); tablet.addValue("value_collect", tblIndex, aggState.getValueCollect()); @@ -123,12 +123,16 @@ tablet.addValue("is_deleted", tblIndex, aggState.getIsDeleted()); tablet.addValue("employee_id", tblIndex, aggState.getEmployeeId()); - tblIndex++; + if(aggState.getWorkstationId() == 1656819337286631426L) { + System.out.println("laile"+aggState.getWorkstationId()); + } + //tblIndex++; if(tblIndex >= MAX_COUNT) { try { //姣忎釜宸ヤ綅鎵归噺鎻掑叆涓�娆℃暟鎹� this.iotdbConfig.getSessionPool().insertAlignedTablet(tablet); log.info("淇濆瓨鑱氬悎鐘舵�佸畬鎴恡blIndex={}",tblIndex); + //tablet.rowSize = 0; tablet.reset(); tblIndex = 0; } catch (Exception e) { @@ -138,13 +142,13 @@ } - if(tblIndex > 0) { + if(tablet.rowSize > 0) { try { //姣忎釜宸ヤ綅鎵归噺鎻掑叆涓�娆℃暟鎹� this.iotdbConfig.getSessionPool().insertAlignedTablet(tablet); log.info("淇濆瓨鑱氬悎鐘舵�佸畬鎴恌inaltblIndex={}",tblIndex); tablet.reset(); - tblIndex = 0; + tblIndex = -1; } catch (Exception e) { log.error("淇濆瓨鍥哄畾鐐规暟鎹紓甯�",e); } -- Gitblit v1.9.3