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/DeviceStateAggregateNoFeedbackService.java | 90 +++++++++++++++++++++++++++-----------------
1 files changed, 55 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..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
@@ -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));
@@ -103,42 +97,68 @@
iotDBCommonService.setTemmplateIfNotSet(IOTDBConstant.TEMPLATE_AGGREGATESTATE, deviceId);//鎸傝浇妯℃澘
Tablet tablet = new Tablet(deviceId, schemas);
- tablet.rowSize = aggStates.size();
AggregateState aggState;
+ int tblIndex = -1;
+
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());
+ tblIndex = tablet.rowSize++;
+ 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());
+
+ 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) {
+ log.error("淇濆瓨鍥哄畾鐐规暟鎹紓甯�",e);
+ }
+ }
}
- try {
- this.iotdbConfig.getSessionPool().insertAlignedTablet(tablet);
- log.info("淇濆瓨鑱氬悎鐘舵�佸畬鎴�");
- } catch (Exception e) {
- log.error("淇濆瓨鑱氬悎鐘舵�佹暟鎹紓甯�",e);
- }
+
+ if(tablet.rowSize > 0) {
+ try {
+ //姣忎釜宸ヤ綅鎵归噺鎻掑叆涓�娆℃暟鎹�
+ this.iotdbConfig.getSessionPool().insertAlignedTablet(tablet);
+ log.info("淇濆瓨鑱氬悎鐘舵�佸畬鎴恌inaltblIndex={}",tblIndex);
+ tablet.reset();
+ tblIndex = -1;
+ } 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