| | |
| | | |
| | | 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; |
| | | } |
| | | } |