yangys
2024-09-04 910131c0e5271f018c516480cfd926f8660d2dbb
collect/src/main/java/com/qianwen/mdc/collect/service/CollectDataService.java
@@ -21,6 +21,7 @@
import com.alibaba.fastjson.JSONObject;
import com.qianwen.mdc.collect.config.IotDBSessionConfig;
import com.qianwen.mdc.collect.constants.IOTDBConstant;
import com.qianwen.mdc.collect.domain.TelemetryData;
import com.qianwen.mdc.collect.domain.TelemetryDataItem;
import com.qianwen.mdc.collect.utils.redis.RedisUtil;
@@ -32,14 +33,12 @@
public class CollectDataService {
   private static final Logger log = LoggerFactory.getLogger(CollectDataService.class);
   
   private String DB_PREFIX = "root.f2.";
   //private String DB_PREFIX = "root.f2.";
   private static final Map<Integer, String> PROCESS_PARAM_MAP = new HashMap<>();
   @Autowired
   private IotDBSessionConfig iotdbConfig;
   @Autowired
   private IotDBCommonService iotDBCommonService;
   @Autowired
   private  RedisUtil redisUtil;
   
   private static String TEMPLATE_NAME = "process_param";
@@ -53,7 +52,7 @@
      PROCESS_PARAM_MAP.put(7, "ALARM");
   }
   // TelemetryDataMessage telemetryDataMessage
   public void handleCollectData(List<TelemetryData> telemetryDataList) {
      for (TelemetryData dt : telemetryDataList) {
@@ -92,7 +91,7 @@
         
         deviceId = generateDeviceId(dt.getWorkstationId(),name);
         //System.out.println("deivcdid="+deviceId);
         iotDBCommonService.setTemmplateIsNotSet(TEMPLATE_NAME, deviceId);
         iotDBCommonService.setTemmplateIfNotSet(TEMPLATE_NAME, deviceId);
         Tablet tablet = new Tablet(deviceId, schemas);
         for(TypedTelemetryData tdata : typeList) {
            rowIndex = tablet.rowSize++;
@@ -110,7 +109,6 @@
            log.error("IOTDB入库失败",e);
            e.printStackTrace();
         }
         //System.out.println(typeList);
      }
      
@@ -227,7 +225,7 @@
   }
   
   String generateDeviceId(long workstationId,String propertyName) {
      return DB_PREFIX+TEMPLATE_NAME + "_" + workstationId+"_"+propertyName;
      return IOTDBConstant.DB_PREFIX+TEMPLATE_NAME + "_" + workstationId+"_"+propertyName;
   }
}