| | |
| | | */ |
| | | @Bean |
| | | public MessageProducer inbound() { |
| | | java.util.Random r = new java.util.Random(); |
| | | |
| | | String clientId = "spring-boot-mqtt-client-inbound"+r.nextInt(1000); |
| | | MqttPahoMessageDrivenChannelAdapter adapter = |
| | | new MqttPahoMessageDrivenChannelAdapter("spring-boot-mqtt-client-inbound", |
| | | new MqttPahoMessageDrivenChannelAdapter(clientId, |
| | | mqttClientFactory(), COLLECT_DATA_TOPIC, FEEDBACK_TOPIC,WOCKSTATION_CREATE_TOPIC);//最后一个参数允许多个topic参数 |
| | | adapter.setCompletionTimeout(5000); |
| | | adapter.setConverter(new DefaultPahoMessageConverter()); |
| | |
| | | package com.qianwen.mdc.collect.controller; |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.google.common.collect.Sets; |
| | | import com.qianwen.core.tool.utils.Func; |
| | | import com.qianwen.mdc.collect.cache.TimeSliceCache; |
| | | import com.qianwen.mdc.collect.config.IotDBSessionConfig; |
| | | import com.qianwen.mdc.collect.dto.CacheBuildDTO; |
| | | import com.qianwen.mdc.collect.dto.CalendarShiftInfoDTO; |
| | | import com.qianwen.mdc.collect.entity.iotdb.Output; |
| | | import com.qianwen.mdc.collect.entity.iotdb.ProcessParam; |
| | | import com.qianwen.mdc.collect.mapper.iotdb.OutputMapper; |
| | | import com.qianwen.mdc.collect.mapper.iotdb.ProcessParamMapper; |
| | | import com.qianwen.mdc.collect.mapper.mgr.CalendarMapper; |
| | | import com.qianwen.mdc.collect.mqtt.MqttMessageSender; |
| | | import com.qianwen.mdc.collect.service.DeviceStateAggregateService; |
| | | import com.qianwen.mdc.collect.service.DeviceStateFixPointService; |
| | | import com.qianwen.mdc.collect.service.IOTMqttReceiveService; |
| | | import com.qianwen.mdc.collect.service.IotDBCommonService; |
| | | import com.qianwen.mdc.collect.service.OutputAggregateService; |
| | | import com.qianwen.mdc.collect.utils.redis.RedisUtil; |
| | | import com.xxl.job.core.log.XxlJobLogger; |
| | | |
| | | import cn.hutool.core.date.DateField; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | |
| | | @RestController |
| | | public class JobTestController { |
| | |
| | | @GetMapping("/rec2") |
| | | public void testRec2() { |
| | | //数据格式:{"174":[{"values":{"d1":12},"ts":"1721978780449"}]} 174是应用id |
| | | //多条格式:{"174":[{"values":{"DeviceStatus":2},"ts":"1722478128278"},{"values":{"spindleSpeed":22},"ts":"1722478128281"}]} |
| | | String payload = "{\"174\":[{\"values\":{\"DeviceStatus\":2,\"Output\":38},\"ts\":\"1725247557768\"}]}"; |
| | | //多条格式:{"174":[{"values":{"DeviceStatus":2},"ts":"1722478128278"},{"values":{"SpindleSpeed":22},"ts":"1722478128281"}]} |
| | | String payload = "{\"174\":[{\"values\":{\"DeviceStatus\":2,\"Output\":38},\"ts\":\""+System.currentTimeMillis()+"\"}]}"; |
| | | //payload = "{\"174\":[{\"values\":{\"Output\":11},\"ts\":\"1722478128278\"},{\"values\":{\"SpindleSpeed\":22},\"ts\":\"1722478128281\"}]}"; |
| | | recService.handle(payload); |
| | | } |
| | |
| | | package com.qianwen.mdc.collect.controller; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.qianwen.mdc.collect.config.IotDBSessionConfig; |
| | | import com.qianwen.mdc.collect.dto.CalendarShiftInfoDTO; |
| | | import com.qianwen.mdc.collect.dto.StateAggregateTimeDTO; |
| | | import com.qianwen.mdc.collect.entity.iotdb.DeviceState; |
| | | import com.qianwen.mdc.collect.entity.iotdb.Output; |
| | | import com.qianwen.mdc.collect.entity.iotdb.ProcessParam; |
| | | import com.qianwen.mdc.collect.mapper.iotdb.DeviceStateMapper; |
| | | import com.qianwen.mdc.collect.mapper.iotdb.OutputMapper; |
| | | import com.qianwen.mdc.collect.mapper.iotdb.ProcessParamMapper; |
| | | import com.qianwen.mdc.collect.mapper.mgr.CalendarMapper; |
| | | import com.qianwen.mdc.collect.mqtt.MqttMessageSender; |
| | | import com.qianwen.mdc.collect.service.DeviceStateAggregateService; |
| | | import com.qianwen.mdc.collect.service.DeviceStateFixPointService; |
| | | import com.qianwen.mdc.collect.service.IOTMqttReceiveService; |
| | | import com.qianwen.mdc.collect.service.IotDBCommonService; |
| | | import com.qianwen.mdc.collect.service.OutputAggregateService; |
| | | import com.qianwen.mdc.collect.utils.redis.RedisUtil; |
| | | |
| | | import cn.hutool.core.date.DateField; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | |
| | | @RestController |
| | | public class StateController { |
| | |
| | | |
| | | 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.setValueCollect(translateStatus(data.getValue())); |
| | | |
| | | state.setWcs(state.getValueCollect()); |
| | | state.setWorkstationId(data.getWorkstationId()); |
| | | |
| | |
| | | //insertState(state); |
| | | deviceStateService.saveDeviceStates(Arrays.asList(state)); |
| | | |
| | | log.info("状态聚合聚合完成:数据"); |
| | | log.info("设备状态保存完成"); |
| | | } |
| | | |
| | | private void fillWorkStationCondition(PackedTelemetryData data, DeviceState state) { |
| | |
| | | //log.info("获取包装工况以及绩效信息" + JsonUtil.toJson(workstationState)); |
| | | |
| | | } |
| | | /* |
| | | void insertState(DeviceState state){ |
| | | String deviceId = IOTDBConstant.DB_PREFIX+IOTDBConstant.TEMPLATE_STATE+"_"+state.getWorkstationId(); |
| | | try { |
| | | iotDBCommonService.setTemmplateIfNotSet(IOTDBConstant.TEMPLATE_STATE, deviceId); |
| | | |
| | | List<MeasurementSchema> schemas = new ArrayList<>(); |
| | | |
| | | schemas.add(new MeasurementSchema("workstation_id", TSDataType.INT64)); |
| | | schemas.add(new MeasurementSchema("value_collect", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("calendar_code", TSDataType.TEXT)); |
| | | schemas.add(new MeasurementSchema("factory_year", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("factory_month", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("factory_week", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("factory_date", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("shift_index", TSDataType.INT32)); |
| | | 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)); |
| | | schemas.add(new MeasurementSchema("is_deleted", TSDataType.BOOLEAN)); |
| | | schemas.add(new MeasurementSchema("employee_id", TSDataType.INT64)); |
| | | |
| | | |
| | | Tablet tablet = new Tablet(deviceId, schemas); |
| | | int rowIndex = tablet.rowSize++; |
| | | |
| | | tablet.timestamps[rowIndex] = state.getTime(); |
| | | tablet.addValue("workstation_id", rowIndex, state.getWorkstationId()); |
| | | tablet.addValue("value_collect", rowIndex, state.getValueCollect()); |
| | | tablet.addValue("calendar_code", rowIndex, state.getCalendarCode()); |
| | | tablet.addValue("factory_year", rowIndex, state.getFactoryYear()); |
| | | 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());//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()); |
| | | tablet.addValue("is_deleted", rowIndex, state.getIsDeleted()); |
| | | tablet.addValue("employee_id", rowIndex, state.getEmployeeId()); |
| | | |
| | | iotdbCfg.getSessionPool().insertAlignedTablet(tablet); |
| | | |
| | | log.info("状态汇总完成"); |
| | | } catch (Exception e) { |
| | | log.error("聚合产量IODDB入库失败", e); |
| | | } |
| | | }*/ |
| | | |
| | | int translateStatus(String statusVal) { |
| | | int oriStatus = Integer.valueOf(statusVal); |
| | | |
| | | int result = oriStatus; |
| | | //西门子828d, cnc_run_status: 运行状态(0:RESET,1:STOP,2:HOLD,3:START,4:SPENDLE_CW_CCW,5:OTHER) |
| | | switch(oriStatus) { |
| | | case 3://START |
| | | result = 2; |
| | | break; |
| | | case 0://,reset |
| | | case 2://hold |
| | | result = 3;//3待机 |
| | | break; |
| | | case 4:// SPENDLE_CW_CCW |
| | | result = 2; |
| | | break; |
| | | case 5://其他 |
| | | result = oriStatus; |
| | | break; |
| | | default: |
| | | result = oriStatus; |
| | | } |
| | | log.info("statusconvert,ori={},result={}",oriStatus,result); |
| | | if(result == 0) { |
| | | result = 2;// |
| | | } |
| | | return result; |
| | | } |
| | | } |
| | |
| | | public ReturnT<String> workStationAggregateJobHandler(String param) throws Exception { |
| | | XxlJobLogger.log("XXL-JOB, 定时计算工位的状态,产量等信息,开始发送.....", new Object[0]); |
| | | |
| | | |
| | | Map<Long, WorkstationDTO> workstations = workstationCache.getWorkstations(); |
| | | if (ObjectUtil.isNotEmpty(workstations)) { |
| | | |
| | | Set<Long> workStationIds = workstations.keySet(); |
| | | log.info("聚合状态工位总数:{}",workStationIds.size()); |
| | | for(Long workstationId :workStationIds) { |
| | | log.info("开始聚合工位{}的状态",workstationId); |
| | | deviceStateAggregateService.stateAggregate(workstationId); |
| | | } |
| | | } |
| | | |
| | | log.info("聚合状态整体结束"); |
| | | XxlJobLogger.log("XXL-JOB, 定时计算工位的状态,产量等信息,发送结束", new Object[0]); |
| | | return ReturnT.SUCCESS; |
| | | } |
| | |
| | | * @param factoryDate |
| | | * @return |
| | | */ |
| | | long fixPointCountByDate(int factoryDate); |
| | | Long fixPointCountByDate(int factoryDate); |
| | | |
| | | /** |
| | | * 根据工位id,获取 小于时间戳 的非反馈点数据 |
| | |
| | | import com.qianwen.mdc.collect.dto.CacheBuildDTO; |
| | | import com.qianwen.mdc.collect.mapper.iotdb.DeviceStateMapper; |
| | | import com.qianwen.mdc.collect.service.DeviceStateFixPointService; |
| | | import com.qianwen.mdc.collect.service.WorkstationAppMappingService; |
| | | |
| | | import cn.hutool.core.date.DatePattern; |
| | | import cn.hutool.core.date.DateTime; |
| | |
| | | private TimeSliceCache timeSliceCache; |
| | | @Autowired |
| | | private DeviceStateMapper deviceStateMapper; |
| | | |
| | | @Autowired |
| | | private WorkstationAppMappingService mappingService;; |
| | | |
| | | @Override |
| | | public void run(ApplicationArguments args) throws Exception { |
| | | |
| | | mappingService.saveToCache(); |
| | | |
| | | //生成时间切片 |
| | | CacheBuildDTO cacheBuildDTO = CacheBuildDTO.builder().tenantIds(Sets.newHashSet(new String[]{"000000"})).targetDate(LocalDate.now()).build(); |
| | | timeSliceCache.build(cacheBuildDTO); |
| | |
| | | DateTime dateTime = DateTime.now(); |
| | | log.info("进入程序启动校验是否存在工位打过固定点....... "); |
| | | |
| | | long count = deviceStateMapper.fixPointCountByDate(Integer.valueOf(DatePattern.PURE_DATE_FORMAT.format(dateTime))); |
| | | Long count = deviceStateMapper.fixPointCountByDate(Integer.valueOf(DatePattern.PURE_DATE_FORMAT.format(dateTime))); |
| | | /* |
| | | Long result = this.workstationStateMapper.selectCount(Wrappers.<WorkstationState>lambdaQuery() |
| | | .eq(WorkstationState::getFactoryDate, Integer.valueOf(DatePattern.PURE_DATE_FORMAT.format(dateTime))) |
| | | .eq(WorkstationState::getIsFixPoint, Boolean.TRUE)); |
| | | */ |
| | | //Long result = 1L; |
| | | if (count <= 0) { |
| | | if(count == null || count == 0) { |
| | | //if (count <= 0) { |
| | | log.info("设备未打过锚点,启动时打点....... "); |
| | | //this.workStationStateFixPointService.workStationStateFixPoint(dateTime, null); |
| | | stateFixPointService.deviceStateFixPoint(dateTime, null); |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.qianwen.core.tool.utils.ObjectUtil; |
| | | 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.mqtt.MqttMessageSender; |
| | | import com.qianwen.mdc.collect.utils.redis.RedisUtil; |
| | | |
| | | import cn.hutool.json.JSONUtil; |
| | | |
| | | /** |
| | | * 采集数据处理入库 |
| | |
| | | private IotDBSessionConfig iotdbConfig; |
| | | @Autowired |
| | | private IotDBCommonService iotDBCommonService; |
| | | @Autowired |
| | | private MqttMessageSender mqttMessageSender; |
| | | |
| | | /** |
| | | * 实时数据topic,要与mdc里面得相同 |
| | | */ |
| | | public static final String WOCKSTATION_REALTIMEDATA_TOPIC = "mdc/realtimedata"; |
| | | |
| | | private static String TEMPLATE_NAME = "process_param"; |
| | | |
| | |
| | | |
| | | for (TelemetryData dt : telemetryDataList) { |
| | | handleOneWorkstation(dt); |
| | | |
| | | sendRealtimeDataMsg(dt); |
| | | } |
| | | |
| | | } |
| | | |
| | | void sendRealtimeDataMsg(TelemetryData dt) { |
| | | if(ObjectUtil.isEmpty(dt.getDataItems())){ |
| | | return; |
| | | } |
| | | |
| | | List<TypedTelemetryData> dataList= new ArrayList<>(); |
| | | String propertyName; |
| | | for (TelemetryDataItem dataItem : dt.getDataItems()) { |
| | | |
| | | for (Map<String, String> point : dataItem.getDataPoints()) { |
| | | |
| | | String[] keys = point.keySet().toArray(new String[0]); |
| | | for(int i=0;i<keys.length;i++) { |
| | | TypedTelemetryData tpData = new TypedTelemetryData(); |
| | | propertyName = keys[i]; |
| | | tpData.setTime(dataItem.getTime()); |
| | | tpData.setName(propertyName); |
| | | tpData.setValue(point.get(propertyName)); |
| | | |
| | | dataList.add(tpData); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | //发送mqtt消息,通知mdc消息来了 |
| | | for(TypedTelemetryData item : dataList) { |
| | | JSONObject json = new JSONObject(); |
| | | json.put("workstationId",dt.getWorkstationId()); |
| | | json.put("name", item.getName()); |
| | | json.put("value", item.getValue()); |
| | | json.put("time", item.getTime()); |
| | | |
| | | mqttMessageSender.sendMessage(WOCKSTATION_REALTIMEDATA_TOPIC, json.toJSONString()); |
| | | } |
| | | |
| | | } |
| | | /** |
| | | * 处理一个工位的数据解析入库 |
| | | * @param dt |
| | | */ |
| | | void handleOneWorkstation(TelemetryData dt) { |
| | | String deviceId;// = DB_PREFIX+TEMPLATE_NAME + "_" + dt.getWorkstationId(); |
| | | |
| | | // 挂载模板 |
| | | //iotDBCommonService.setTemmplateIsNotSet(TEMPLATE_NAME, deviceId); |
| | | |
| | | List<MeasurementSchema> schemas = new ArrayList<>(); |
| | | |
| | |
| | | try { |
| | | iotdbConfig.getSessionPool().insertAlignedTablet(tablet); |
| | | |
| | | updateLastParam(dt.getWorkstationId(),typeList); |
| | | //updateLastParam(dt.getWorkstationId(),typeList); |
| | | } catch (Exception e) { |
| | | log.error("IOTDB入库失败",e); |
| | | e.printStackTrace(); |
| | | }finally { |
| | | //iotdbConfig.getSessionPool().clo1se(); |
| | | } |
| | | } |
| | | |
| | |
| | | schemas.add(new MeasurementSchema("param_json", TSDataType.TEXT)); |
| | | |
| | | Tablet tablet = new Tablet("root.f2.last_process_param", schemas); |
| | | for(TypedTelemetryData tdata: typeList) { |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | String sql = "select update_time,workstation_id,param_json from root.f2.last_process_param where workstation_id="+workstationId; |
| | | SessionDataSetWrapper dsw = iotdbConfig.getSessionPool().executeQueryStatement(sql); |
| | | |
| | | if(dsw.hasNext()) { |
| | | RowRecord rec = dsw.next(); |
| | | long time = rec.getTimestamp(); |
| | | |
| | | String paramJsonStr = rec.getFields().get(2).getStringValue(); |
| | | |
| | | tablet.rowSize = 1; |
| | | tablet.addTimestamp(0, time); |
| | | tablet.addValue("update_time", 0, updateTime); |
| | | tablet.addValue("workstation_id", 0, workstationId); |
| | | JSONObject paramObj = JSONObject.parseObject(paramJsonStr); |
| | | for(TypedTelemetryData tdata: typeList) { |
| | | try(SessionDataSetWrapper dsw = iotdbConfig.getSessionPool().executeQueryStatement(sql)){ |
| | | if(dsw.hasNext()) { |
| | | RowRecord rec = dsw.next(); |
| | | long time = rec.getTimestamp(); |
| | | |
| | | if(paramObj.containsKey(tdata.getName())) { |
| | | JSONObject itemObj = paramObj.getJSONObject(tdata.getName()); |
| | | itemObj.put("value", tdata.getValue()); |
| | | itemObj.put("time", tdata.getTime());//采集时间 |
| | | paramObj.put(tdata.getName(), itemObj); |
| | | }else { |
| | | String paramJsonStr = rec.getFields().get(2).getStringValue(); |
| | | |
| | | tablet.rowSize = 1; |
| | | tablet.addTimestamp(0, time); |
| | | tablet.addValue("update_time", 0, updateTime); |
| | | tablet.addValue("workstation_id", 0, workstationId); |
| | | JSONObject paramObj = JSONObject.parseObject(paramJsonStr); |
| | | for(TypedTelemetryData tdata: typeList) { |
| | | |
| | | if(paramObj.containsKey(tdata.getName())) { |
| | | JSONObject itemObj = paramObj.getJSONObject(tdata.getName()); |
| | | itemObj.put("value", tdata.getValue()); |
| | | itemObj.put("time", tdata.getTime());//采集时间 |
| | | paramObj.put(tdata.getName(), itemObj); |
| | | }else { |
| | | JSONObject itemObj = new JSONObject(); |
| | | itemObj.put("value", tdata.getValue()); |
| | | itemObj.put("time", tdata.getTime());//采集时间 |
| | | paramObj.put(tdata.getName(), itemObj); |
| | | |
| | | } |
| | | } |
| | | tablet.addValue("param_json", 0, paramObj.toJSONString()); |
| | | |
| | | this.iotdbConfig.getSessionPool().insertAlignedTablet(tablet); |
| | | |
| | | }else { |
| | | //没数据,新加入一条 |
| | | tablet.rowSize = 1; |
| | | |
| | | tablet.addTimestamp(0, updateTime); |
| | | tablet.addValue("update_time", 0, updateTime); |
| | | tablet.addValue("workstation_id", 0, workstationId); |
| | | |
| | | JSONObject paramObj = new JSONObject(); |
| | | for(TypedTelemetryData tdata: typeList) { |
| | | JSONObject itemObj = new JSONObject(); |
| | | itemObj.put("value", tdata.getValue()); |
| | | itemObj.put("time", tdata.getTime());//采集时间 |
| | | paramObj.put(tdata.getName(), itemObj); |
| | | |
| | | } |
| | | |
| | | tablet.addValue("param_json", 0,paramObj.toJSONString()); |
| | | this.iotdbConfig.getSessionPool().insertAlignedTablet(tablet); |
| | | } |
| | | tablet.addValue("param_json", 0, paramObj.toJSONString()); |
| | | |
| | | this.iotdbConfig.getSessionPool().insertAlignedTablet(tablet); |
| | | |
| | | }else { |
| | | //没数据,新加入一条 |
| | | tablet.rowSize = 1; |
| | | |
| | | tablet.addTimestamp(0, updateTime); |
| | | tablet.addValue("update_time", 0, updateTime); |
| | | tablet.addValue("workstation_id", 0, workstationId); |
| | | |
| | | JSONObject paramObj = new JSONObject(); |
| | | for(TypedTelemetryData tdata: typeList) { |
| | | JSONObject itemObj = new JSONObject(); |
| | | itemObj.put("value", tdata.getValue()); |
| | | itemObj.put("time", tdata.getTime());//采集时间 |
| | | paramObj.put(tdata.getName(), itemObj); |
| | | } |
| | | |
| | | tablet.addValue("param_json", 0,paramObj.toJSONString()); |
| | | this.iotdbConfig.getSessionPool().insertAlignedTablet(tablet); |
| | | } |
| | | |
| | | //dsw.close(); |
| | | } |
| | | |
| | | /** |
| | |
| | | ////使用workstationWcsFeedbackMapper更新反馈得状态,我们不需要 |
| | | //IWorkstationFeedbackService workstationFeedbackService = SpringUtil.getBean(IWorkstationFeedbackService.class); |
| | | workstationFeedbackService.handlerFeedbackComplete(workstationId); |
| | | |
| | | log.info("聚合状态完成:工位{}",workstationId); |
| | | } |
| | | |
| | | |
| | |
| | | List<String> pathlist; |
| | | try { |
| | | pathlist = iotdbCfg.getSessionPool().showPathsTemplateSetOn(template); |
| | | //logger.info("pathlist"+pathlist); |
| | | return pathlist.contains(path); |
| | | } catch (StatementExecutionException|IoTDBConnectionException e) { |
| | | logger.error("获取模板使用错误",e); |
| | |
| | | try { |
| | | iotdbCfg.getSessionPool().setSchemaTemplate(template, deviceId); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | logger.error("获取模板使用错误,template="+template+",deviceId="+deviceId,e); |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.qianwen.mdc.collect.service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import org.apache.iotdb.isession.SessionDataSet; |
| | | import org.apache.iotdb.isession.pool.SessionDataSetWrapper; |
| | | import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType; |
| | | import org.apache.iotdb.tsfile.read.common.RowRecord; |
| | | import org.apache.iotdb.tsfile.write.record.Tablet; |
| | | import org.apache.iotdb.tsfile.write.schema.MeasurementSchema; |
| | | import org.slf4j.Logger; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.qianwen.mdc.collect.config.IotDBSessionConfig; |
| | | import com.qianwen.mdc.collect.constants.IOTDBConstant; |
| | | import com.qianwen.mdc.collect.entity.iotdb.AggregateOutput; |
| | | import com.qianwen.mdc.collect.entity.iotdb.Output; |
| | | import com.qianwen.mdc.collect.enums.WorkstationParamTypeEnum; |
| | | import com.qianwen.mdc.collect.mapper.iotdb.OutputMapper; |
| | | |
| | | @DS("iotdb") |
| | |
| | | keepalive: 10 |
| | | connectionTimeout: 3000 #连接超时时间 |
| | | |
| | | #第三方登陆 |
| | | social: |
| | | enabled: true |
| | | domain: http://127.0.0.1:1888 |
| | | |
| | | # rocketmq |
| | | rocketmq-name-server: 192.168.3.107:9876 |
| | | |
| | | # mysql |
| | | datasource: |
| | | type: mysql |
| | |
| | | driver: org.apache.iotdb.jdbc.IoTDBDriver |
| | | host: 127.0.0.1 |
| | | port: 6667 |
| | | maxSize: 300 |
| | | maxSize: 100 |
| | | username: root |
| | | password: root |
| | | |
| | |
| | | executor: |
| | | appname: qwmdc-collect |
| | | ip: |
| | | port: 38801 |
| | | port: 8802 |
| | | ### xxl-job log path |
| | | logpath: /qwlogs/xxl-job/jobhandler |
| | | ### xxl-job log remain days |
| | |
| | | <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
| | | <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
| | | <!--日志文件输出的文件名--> |
| | | <FileNamePattern>${LOG_HOME}/qwcollect.log.%d{yyyy-MM-dd}.log</FileNamePattern> |
| | | <FileNamePattern>${LOG_HOME}/qwcollect.%d{yyyy-MM-dd}.log</FileNamePattern> |
| | | <!--日志文件保留天数--> |
| | | <MaxHistory>30</MaxHistory> |
| | | </rollingPolicy> |
| | |
| | | <!-- 日志输出级别 --> |
| | | <root level="INFO"> |
| | | <appender-ref ref="STDOUT" /> |
| | | <appender-ref ref="FILE" /> |
| | | </root> |
| | | </configuration> |