From 9faa74e1912022dc6e54c3e93426946876b5d83a Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期五, 25 十月 2024 10:49:13 +0800
Subject: [PATCH] 修改redistemplate的hashkey serializer,更方便客户端查看redis的数据
---
collect/src/main/java/com/qianwen/mdc/collect/service/DeviceStateService.java | 69 ++++++++++++++++++++++++++++++----
1 files changed, 61 insertions(+), 8 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..15eaad5 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
@@ -94,9 +94,68 @@
Tablet tablet = new Tablet(deviceId, schemas);
+
states = entry.getValue();
tablet.rowSize = states.size();
DeviceState state;
+
+
+ final int MAX_COUNT = 1000;
+ //int currentIdx = 0;
+
+
+ int tblIndex = 0;
+ for(int i=0; i < states.size(); i++) {
+ state = states.get(i);
+ tablet.addTimestamp(tblIndex, state.getTime());
+ tablet.addValue("workstation_id", tblIndex, state.getWorkstationId());
+ tablet.addValue("value_collect", tblIndex, state.getValueCollect());
+
+ 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 = 0;
+ } catch (Exception e) {
+ log.error("淇濆瓨鍥哄畾鐐规暟鎹紓甯�",e);
+ }
+ }
+ }
+
+ if(tblIndex > 0) {
+ try {
+ //姣忎釜宸ヤ綅鎵归噺鎻掑叆涓�娆℃暟鎹�
+ this.iotdbConfig.getSessionPool().insertAlignedTablet(tablet);
+ log.info("淇濆瓨璁惧鐘舵�佸畬鎴�2");
+ tablet.reset();
+ tblIndex = 0;
+ } catch (Exception e) {
+ log.error("淇濆瓨鍥哄畾鐐规暟鎹紓甯�",e);
+ }
+ }
+
+ /*
for(int i=0;i<states.size();i++) {
state = states.get(i);
tablet.addTimestamp(i, state.getTime());
@@ -119,14 +178,8 @@
tablet.addValue("feedback_id", i, state.getFeedbackId());
tablet.addValue("is_deleted", i, state.getIsDeleted());
tablet.addValue("employee_id", i, state.getEmployeeId());
-
- }
- try {
- //姣忎釜宸ヤ綅鎵归噺鎻掑叆涓�娆℃暟鎹�
- this.iotdbConfig.getSessionPool().insertAlignedTablet(tablet);
- } catch (Exception e) {
- log.error("淇濆瓨鍥哄畾鐐规暟鎹紓甯�",e);
- }
+ }*/
+
}
}
--
Gitblit v1.9.3