From 26f8e5990686bdba2119024a260d986266506757 Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期五, 27 九月 2024 11:06:00 +0800
Subject: [PATCH] 加入状态反馈,还没具体测试
---
collect/src/main/java/com/qianwen/mdc/collect/handler/DeviceStatusDataHandler.java | 47 +++++++++++++++++++++++++++++------------------
1 files changed, 29 insertions(+), 18 deletions(-)
diff --git a/collect/src/main/java/com/qianwen/mdc/collect/handler/DeviceStatusDataHandler.java b/collect/src/main/java/com/qianwen/mdc/collect/handler/DeviceStatusDataHandler.java
index a58d4db..7089893 100644
--- a/collect/src/main/java/com/qianwen/mdc/collect/handler/DeviceStatusDataHandler.java
+++ b/collect/src/main/java/com/qianwen/mdc/collect/handler/DeviceStatusDataHandler.java
@@ -1,34 +1,31 @@
package com.qianwen.mdc.collect.handler;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Arrays;
+import java.util.Date;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.write.record.Tablet;
-import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.qianwen.mdc.collect.cache.WorkstationCache;
-import com.qianwen.mdc.collect.config.IotDBSessionConfig;
-import com.qianwen.mdc.collect.constants.IOTDBConstant;
import com.qianwen.mdc.collect.dto.PackedTelemetryData;
import com.qianwen.mdc.collect.entity.iotdb.DeviceState;
import com.qianwen.mdc.collect.entity.mgr.GlobalWcsOfRps;
import com.qianwen.mdc.collect.enums.FeedbackTimePointEnum;
-import com.qianwen.mdc.collect.service.IotDBCommonService;
+import com.qianwen.mdc.collect.service.DeviceStateService;
@Component
public class DeviceStatusDataHandler implements TelemetryDataHandler {
private static final Logger log = LoggerFactory.getLogger(DeviceStatusDataHandler.class);
@Autowired
private WorkstationCache workstationCache;
+ //@Autowired
+ //private IotDBSessionConfig iotdbCfg;
+ //@Autowired
+ //private IotDBCommonService iotDBCommonService;
@Autowired
- private IotDBSessionConfig iotdbCfg;
- @Autowired
- private IotDBCommonService iotDBCommonService;
+ private DeviceStateService deviceStateService;
@Override
public void handleData(PackedTelemetryData data) {
DeviceState state = new DeviceState();
@@ -42,15 +39,21 @@
state.setIsFixPoint(false);
state.setIsSync(false);
state.setIsDeleted(false);
- //state.setEmployeeId(WorkstationCache.getBelongToEmployeeForWorkstation(entity.getWorkstationId(), new Date(entity.getTs().longValue())));
+
+ state.setEmployeeId(workstationCache.getBelongToEmployeeForWorkstation(data.getWorkstationId(), new Date(data.getTime())));
+
state.setFeedbackPointType(FeedbackTimePointEnum.NO_FEED_BACK_POINT.getValue());
//WorkstationState propertyData = (WorkstationState) Objects.requireNonNull(BeanUtil.copy(entity, WorkstationState.class));
state.setValueCollect(Integer.valueOf(data.getValue()));
state.setWcs(state.getValueCollect());
state.setWorkstationId(data.getWorkstationId());
+
+ state.setShiftIndex(data.getShiftIndex());
+ state.setShiftTimeType(data.getShiftTimeType());
fillWorkStationCondition(data, state);
- insertState(state);
+ //insertState(state);
+ deviceStateService.saveDeviceStates(Arrays.asList(state));
log.info("鐘舵�佽仛鍚堣仛鍚堝畬鎴�:鏁版嵁");
}
@@ -64,11 +67,11 @@
//log.info("鑾峰彇鍖呰宸ュ喌浠ュ強缁╂晥淇℃伅" + JsonUtil.toJson(workstationState));
}
-
+ /*
void insertState(DeviceState state){
String deviceId = IOTDBConstant.DB_PREFIX+IOTDBConstant.TEMPLATE_STATE+"_"+state.getWorkstationId();
try {
- iotDBCommonService.setTemmplateIsNotSet(IOTDBConstant.TEMPLATE_STATE, deviceId);
+ iotDBCommonService.setTemmplateIfNotSet(IOTDBConstant.TEMPLATE_STATE, deviceId);
List<MeasurementSchema> schemas = new ArrayList<>();
@@ -83,6 +86,10 @@
schemas.add(new MeasurementSchema("shift_time_type", TSDataType.INT32));
schemas.add(new MeasurementSchema("wcs", TSDataType.INT32));
schemas.add(new MeasurementSchema("rps", TSDataType.INT32));
+
+ schemas.add(new MeasurementSchema("is_fix_point", TSDataType.BOOLEAN));
+ schemas.add(new MeasurementSchema("is_sync", TSDataType.BOOLEAN));
+
schemas.add(new MeasurementSchema("is_plan", TSDataType.INT32));
schemas.add(new MeasurementSchema("feedback_point_type", TSDataType.INT32));
schemas.add(new MeasurementSchema("feedback_id", TSDataType.INT64));
@@ -101,10 +108,14 @@
tablet.addValue("factory_month", rowIndex, state.getFactoryMonth());
tablet.addValue("factory_week", rowIndex, state.getFactoryWeek());
tablet.addValue("factory_date", rowIndex, state.getFactoryDate());
- tablet.addValue("shift_index", rowIndex, state.getShiftIndex());
- tablet.addValue("shift_time_type", rowIndex, state.getShiftTimeType());
+ tablet.addValue("shift_index", rowIndex, state.getShiftIndex());//TODO null
+ tablet.addValue("shift_time_type", rowIndex, state.getShiftTimeType());//TODO null
tablet.addValue("wcs", rowIndex, state.getWcs());
tablet.addValue("rps", rowIndex, state.getRps());
+
+ tablet.addValue("is_fix_point", rowIndex,state.getIsFixPoint());
+ tablet.addValue("is_sync", rowIndex, state.getIsSync());
+
tablet.addValue("is_plan", rowIndex, state.getIsPlan());
tablet.addValue("feedback_point_type", rowIndex, state.getFeedbackPointType());
tablet.addValue("feedback_id", rowIndex, state.getFeedbackId());
@@ -117,5 +128,5 @@
} catch (Exception e) {
log.error("鑱氬悎浜ч噺IODDB鍏ュ簱澶辫触", e);
}
- }
+ }*/
}
--
Gitblit v1.9.3