From 7ef593e1e3c35aaeecf9318f0b3941230d3ed002 Mon Sep 17 00:00:00 2001 From: yangys <y_ys79@sina.com> Date: 星期三, 09 十月 2024 11:22:54 +0800 Subject: [PATCH] 增加在数据点计算规则后数据点名称加_n的适配 --- collect/src/main/java/com/qianwen/mdc/collect/service/DeviceStateAggregateNoFeedbackService.java | 86 +++++++++++++++++++++++++----------------- 1 files changed, 51 insertions(+), 35 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 875e9a1..ef1a33a 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 @@ -39,6 +39,8 @@ private IotDBSessionConfig iotdbConfig; @Autowired private IotDBCommonService iotDBCommonService; + + private static final int MAX_COUNT = 1000; public List<AggregateState> stateAggregateForSpecialTimeRange(Long workstationId, StateAggregateTimeDTO timeRange, List<DeviceState> effectiveStateList) { //鎸塼imeRange鏌ヨ鏃堕棿鍖洪棿鍐呯殑鐘舵�佹暟鎹紝闄や簡宸插垹闄ょ殑锛屽叾浠栨暟鎹兘鏌ュ嚭鏉ヤ簡 @@ -62,14 +64,6 @@ * @param effectTimeRangeList */ public void handlerAggregateState(List<AggregateState> result, Long workstationId, StateAggregateTimeDTO timeRange) { - /* - if (Func.isNotEmpty(result)) { - Map<String, List> stringListMap = CommonUtil.groupList(getFinallyAggregateStateList(result, workstationId, effectTimeRangeList), CommonConstant.MAX_RECORDS_FOR_SQL_LENGTH.intValue()); - stringListMap.forEach(k, v -> { - this.workstationAggregateStateMapper.batchSave(workstationId, v); - }); - }*/ - if(result.isEmpty()) { return; } @@ -93,7 +87,7 @@ schemas.add(new MeasurementSchema("rps", TSDataType.INT32)); //schemas.add(new MeasurementSchema("is_sync", TSDataType.BOOLEAN)); schemas.add(new MeasurementSchema("is_plan", TSDataType.INT32));//TODO 杩欎釜灞炴�у簲璇ユ槸GlobalWcsOfRps涓殑鍊硷紝濡備綍濉啓锛� - //schemas.add(new MeasurementSchema("feedback_id", TSDataType.INT64)); + schemas.add(new MeasurementSchema("is_deleted", TSDataType.BOOLEAN)); schemas.add(new MeasurementSchema("employee_id", TSDataType.INT64)); @@ -104,41 +98,63 @@ Tablet tablet = new Tablet(deviceId, schemas); tablet.rowSize = aggStates.size(); - + AggregateState aggState; + int tblIndex = 0; + for(int i=0;i<aggStates.size();i++) { aggState = aggStates.get(i); - tablet.addTimestamp(i, aggState.getTime()); - tablet.addValue("workstation_id", i, aggState.getWorkstationId()); - tablet.addValue("value_collect", i, aggState.getValueCollect()); - tablet.addValue("end_time", i, aggState.getEndTime()); - tablet.addValue("duration_collect", i, aggState.getDurationCollect()); - tablet.addValue("calendar_code", i, aggState.getCalendarCode()); - tablet.addValue("factory_year", i, aggState.getFactoryYear()); - tablet.addValue("factory_month", i, aggState.getFactoryMonth()); - tablet.addValue("factory_week", i, aggState.getFactoryWeek()); - tablet.addValue("factory_date", i, aggState.getFactoryDate()); - tablet.addValue("shift_index", i, aggState.getShiftIndex()); - tablet.addValue("shift_time_type", i, aggState.getShiftTimeType()); - tablet.addValue("wcs", i, aggState.getWcs()); - tablet.addValue("rps", i, aggState.getRps()); + tablet.addTimestamp(tblIndex, aggState.getTime()); + tablet.addValue("workstation_id", tblIndex, aggState.getWorkstationId()); + tablet.addValue("value_collect", tblIndex, aggState.getValueCollect()); + tablet.addValue("end_time", tblIndex, aggState.getEndTime()); + tablet.addValue("duration_collect", tblIndex, aggState.getDurationCollect()); + tablet.addValue("calendar_code", tblIndex, aggState.getCalendarCode()); + tablet.addValue("factory_year", tblIndex, aggState.getFactoryYear()); + tablet.addValue("factory_month", tblIndex, aggState.getFactoryMonth()); + tablet.addValue("factory_week", tblIndex, aggState.getFactoryWeek()); + tablet.addValue("factory_date", tblIndex, aggState.getFactoryDate()); + tablet.addValue("shift_index", tblIndex, aggState.getShiftIndex()); + tablet.addValue("shift_time_type", tblIndex, aggState.getShiftTimeType()); + tablet.addValue("wcs", tblIndex, aggState.getWcs()); + tablet.addValue("rps", tblIndex, aggState.getRps()); - tablet.addValue("is_plan", i, aggState.getIsPlan()); - //tablet.addValue("feedback_id", i, aggState.getFeedbackId()); - tablet.addValue("is_deleted", i, aggState.getIsDeleted()); - tablet.addValue("employee_id", i, aggState.getEmployeeId()); + tablet.addValue("is_plan", tblIndex, aggState.getIsPlan()); + tablet.addValue("is_deleted", tblIndex, aggState.getIsDeleted()); + tablet.addValue("employee_id", tblIndex, aggState.getEmployeeId()); + + tblIndex++; + if(tblIndex >= MAX_COUNT) { + try { + //姣忎釜宸ヤ綅鎵归噺鎻掑叆涓�娆℃暟鎹� + this.iotdbConfig.getSessionPool().insertAlignedTablet(tablet); + log.info("淇濆瓨鑱氬悎鐘舵�佸畬鎴恡blIndex={}",tblIndex); + tablet.reset(); + tblIndex = 0; + } catch (Exception e) { + log.error("淇濆瓨鍥哄畾鐐规暟鎹紓甯�",e); + } + } } - try { - this.iotdbConfig.getSessionPool().insertAlignedTablet(tablet); - log.info("淇濆瓨鑱氬悎鐘舵�佸畬鎴�"); - } catch (Exception e) { - log.error("淇濆瓨鑱氬悎鐘舵�佹暟鎹紓甯�",e); - } + + if(tblIndex > 0) { + try { + //姣忎釜宸ヤ綅鎵归噺鎻掑叆涓�娆℃暟鎹� + this.iotdbConfig.getSessionPool().insertAlignedTablet(tablet); + log.info("淇濆瓨鑱氬悎鐘舵�佸畬鎴恌inaltblIndex={}",tblIndex); + tablet.reset(); + tblIndex = 0; + } catch (Exception e) { + log.error("淇濆瓨鍥哄畾鐐规暟鎹紓甯�",e); + } + + } + } - + private List<AggregateState> getFinallyAggregateStateList(List<AggregateState> result, Long workstationId, StateAggregateTimeDTO timeRange) { /* List<StateAggregateTimeDTO> effectTimeRangeList2 = effectTimeRangeList.stream().filter(x -> { -- Gitblit v1.9.3