yangys
2024-09-02 a33c33d48c2c16995130b825355b6883be4eb159
collect/src/main/java/com/qianwen/mdc/collect/handler/DeviceStatusDataHandler.java
@@ -1,6 +1,7 @@
package com.qianwen.mdc.collect.handler;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
@@ -18,6 +19,7 @@
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.DeviceStateService;
import com.qianwen.mdc.collect.service.IotDBCommonService;
@Component
@@ -29,6 +31,8 @@
   private IotDBSessionConfig iotdbCfg;
    @Autowired
    private IotDBCommonService iotDBCommonService;
    @Autowired
    private DeviceStateService deviceStateService;
    @Override
    public void handleData(PackedTelemetryData data) {
       DeviceState state = new DeviceState();
@@ -48,9 +52,13 @@
       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 +72,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 +91,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 +113,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 +133,5 @@
      } catch (Exception e) {
         log.error("聚合产量IODDB入库失败", e);
      }
    }
    }*/
}