본문으로 바로 가기

MyEMS 데이터베이스 설계

목차​

데이터베이스 아키텍처 설계​

MyEMS는 MySQL 데이터베이스 13개를 사용합니다. 설치 스크립트는 database/install에 있습니다. 각 스크립트는 문자 집합 utf8mb4, 정렬 규칙 utf8mb4_unicode_ci로 데이터베이스 하나를 만듭니다. 테이블은 BIGINT 기본 키와 UTC DATETIME 열을 쓰고, 측정값과 집계값은 DECIMAL(21, 6)입니다.

데이터베이스테이블 수용도
myems_system_db166마스터 데이터: 공간, 계량기, 데이터 포인트, 설비, 발전소, 요금, 연관
myems_historical_db12데이터 포인트 원시값과 업로드된 비용, 오프라인 계량기, 복구, 계획 파일
myems_energy_db39시간별 에너지 집계
myems_billing_db39시간별 비용 집계. 테이블 집합은 에너지와 같음
myems_carbon_db39시간별 탄소 집계. 테이블 집합은 에너지와 같음
myems_energy_baseline_db39시간별 기준선. 테이블 집합은 에너지와 같음
myems_energy_model_db398760시간의 전형적 연도. 대상 집합은 에너지와 같음
myems_energy_plan_db39시간별 계획. 테이블 집합은 에너지와 같음
myems_energy_prediction_db39시간별 예측. 테이블 집합은 에너지와 같음
myems_fdd_db9고장 규칙과 이메일, SMS, 웹, WeChat 메시지
myems_user_db10사용자, 권한, 세션, API 키, 감사 로그
myems_reporting_db4보고서 정의, 템플릿, 생성 파일, 보고서 메일
myems_production_db8제품, 팀, 교대, 시간별 생산량

설계 개념​

데이터베이스책임기록 주체
myems_system_db구성과 토폴로지웹 UI가 myems-api를 통해
myems_historical_db데이터 포인트 시계열과 업로드된 통합 문서데이터 수집과 파일 가져오기
myems_energy_db시간별 에너지정규화와 집계
myems_billing_db시간별 비용과금. 에너지 값과 요금에서 산출
myems_carbon_db시간별 배출탄소 계산. 에너지 값과 배출 계수에서 산출
myems_energy_baseline_db시간별 기준선기준선 서비스
myems_energy_model_db윤년이 아닌 해의 각 시간당 하나의 값모델링 서비스
myems_energy_plan_db시간별 계획계획 서비스
myems_energy_prediction_db시간별 예측예측 서비스
myems_fdd_db규칙과 발신 알림FDD 서비스
myems_user_db신원과 권한API
myems_reporting_db예약된 보고서보고서 서비스
myems_production_db에너지 원단위에 쓰는 생산량생산 가져오기와 집계

구성 객체는 id로 서로를 참조합니다. 데이터베이스를 넘는 테이블은 같은 id를 저장하며, 다른 데이터베이스를 가리키는 외래 키를 선언하지 않습니다.

명명 규칙​

대상규칙예
데이터베이스접두사 myems_, 접미사 _dbmyems_system_db
테이블접두사 tbl_tbl_meters
연관 테이블tbl_{owner}_{child}tbl_spaces_meters
시간별 팩트 테이블{object}_{measure}_hourlytbl_meter_hourly
모델 팩트 테이블같은 대상 집합, 접미사 _8760tbl_meter_8760
기본 키idid BIGINT NOT NULL AUTO_INCREMENT
업무 키구성 객체의 uuid CHAR(36)계량기, 공간, 설비
시각*_datetime_utc 또는 utc_date_timestart_datetime_utc
인덱스{table}_index_{n}tbl_meters_index_1

데이터베이스 상세 설명​

1. 시스템 데이터베이스 (myems_system_db)​

myems_system_db는 마스터 데이터를 담으며 테이블은 166개입니다. 구성 객체는 보통 id, name, uuid, description을 가집니다. 연관 테이블은 외래 키 두 개와 id만 저장합니다. 발전소 아래 구성 요소 테이블은 물리 설비마다 한 행을 두고, 대응하는 *_points 테이블을 가집니다.

에너지 분류​

테이블주요 열설명
tbl_energy_categoriesname, uuid, unit_of_measure, kgce, kgco2e에너지 분류와 기본 환산 계수
tbl_energy_itemsname, uuid, energy_category_id분류 아래의 항목

kgce와 kgco2e는 분류의 기본 계수입니다. 기간이 있는 가격과 배출 계수는 요금 테이블과 배출 계수 테이블에 있습니다.

계량기와 데이터 포인트​

테이블주요 열설명
tbl_metersenergy_category_id, energy_item_id, cost_center_id, master_meter_id, is_counted, is_enabled, hourly_low_limit, hourly_high_limit온라인 계량기
tbl_offline_meters같은 한계와 분류 열. master_meter_id 없음수동 입력 계량기
tbl_virtual_metersequation (LONGTEXT), energy_category_id, energy_item_id, is_counted, is_enabled수식으로 계산하는 계량기
tbl_variablesname, virtual_meter_id, meter_type, meter_id가상 계량기 수식의 변수 바인딩
tbl_pointsdata_source_id, object_type, units, high_limit, low_limit, higher_limit, lower_limit, ratio, offset_constant, is_trend, is_virtual, address, faults, definitions데이터 포인트. address, faults, definitions는 JSON 텍스트. uuid 없음
tbl_points_set_valuespoint_id, utc_date_time, set_value, is_set데이터 포인트의 설정값
tbl_meters_pointsmeter_id, point_id계량기와 데이터 포인트 바인딩
tbl_meters_commandsmeter_id, command_id계량기와 명령 바인딩

tbl_points의 higher_limit, lower_limit, is_in_alarm은 FDD 서비스가 사용합니다. ratio와 offset_constant는 원시값을 스케일합니다.

데이터 수집​

테이블주요 열설명
tbl_gatewaysname, uuid, token, last_seen_datetime_utc수집 게이트웨이
tbl_data_sourcesgateway_id, protocol, connection (LONGTEXT), process_id, last_seen_datetime_utc게이트웨이 아래 연결. connection은 JSON
tbl_protocolsname, code프로토콜 목록
tbl_sensorsname, uuid센서
tbl_sensors_pointssensor_id, point_id센서와 데이터 포인트 바인딩
tbl_iot_sim_cardsiccid, imsi, operator, status, used_traffic, total_trafficSIM 카드 대장. 이 테이블에는 uuid가 없음

공간과 비용 센터​

테이블주요 열설명
tbl_spacesparent_space_id, area, number_of_occupants, timezone_id, contact_id, cost_center_id, latitude, longitude, is_input_counted, is_output_counted공간 트리
tbl_cost_centersname, uuid, external_id비용 센터
tbl_contactsname, uuid, email, phone연락처
tbl_timezonesname, utc_offset시간대
tbl_working_calendarsname근무 달력
tbl_working_calendars_non_working_daysworking_calendar_id, date_local, description비근무일

공간은 하위 객체의 space_id 열이 아니라 연관 테이블로 연결합니다.

tbl_spaces_meters, tbl_spaces_offline_meters, tbl_spaces_virtual_meters, tbl_spaces_points, tbl_spaces_sensors, tbl_spaces_equipments, tbl_spaces_combined_equipments, tbl_spaces_commands, tbl_spaces_shopfloors, tbl_spaces_stores, tbl_spaces_tenants, tbl_spaces_charging_stations, tbl_spaces_microgrids, tbl_spaces_photovoltaic_power_stations, tbl_spaces_energy_storage_power_stations, tbl_spaces_wind_farms, tbl_spaces_distribution_systems, tbl_spaces_energy_flow_diagrams, tbl_spaces_working_calendars.

설비​

테이블주요 열설명
tbl_equipmentsis_input_counted, is_output_counted, is_enabled, cost_center_id, efficiency_indicator, svg_id, camera_url설비
tbl_combined_equipmentstbl_equipments와 같은 열조합 설비
tbl_combined_equipments_equipmentscombined_equipment_id, equipment_id조합 설비의 구성원

두 종류의 설비 모두 계량기, 오프라인 계량기, 가상 계량기, 매개변수, 데이터 소스, 명령을 바인딩합니다.

  • tbl_equipments_meters, tbl_equipments_offline_meters, tbl_equipments_virtual_meters, tbl_equipments_parameters, tbl_equipments_data_sources, tbl_equipments_commands
  • tbl_combined_equipments_meters, tbl_combined_equipments_offline_meters, tbl_combined_equipments_virtual_meters, tbl_combined_equipments_parameters, tbl_combined_equipments_data_sources, tbl_combined_equipments_commands

작업장, 매장, 임차인​

테이블주요 열설명
tbl_shopfloorsarea, is_input_counted, is_enabled, contact_id, cost_center_id작업장
tbl_storesaddress, latitude, longitude, area, store_type_id, is_input_counted, is_enabled, contact_id, cost_center_id매장
tbl_store_typesname, uuid, simplified_code매장 유형
tbl_tenantsbuildings, floors, rooms, area, tenant_type_id, is_input_counted, is_enabled, is_key_tenant, lease_number, lease_start_datetime_utc, lease_end_datetime_utc, is_in_lease, contact_id, cost_center_id임차인
tbl_tenant_typesname, uuid, simplified_code임차인 유형

이 세 객체는 모두 계량기, 오프라인 계량기, 가상 계량기, 데이터 포인트, 센서, 명령, 근무 달력의 연관 테이블을 가집니다. 작업장에는 tbl_shopfloors_equipments도 있습니다.

태양광 발전소​

tbl_photovoltaic_power_stations는 station_code, address, latitude, longitude, latitude_point_id, longitude_point_id, rated_capacity, rated_power, contact_id, cost_center_id, SVG 슬롯 다섯 개(svg_id부터 svg5_id), is_cost_data_displayed, phase_of_lifecycle, commissioning_date를 저장합니다.

하위 테이블:

테이블역할
tbl_photovoltaic_power_stations_invertors / _invertors_points인버터와 그 데이터 포인트
tbl_photovoltaic_power_stations_grids / _grids_points계통 연결과 그 데이터 포인트
tbl_photovoltaic_power_stations_loads / _loads_points부하와 그 데이터 포인트
tbl_photovoltaic_power_stations_data_sources데이터 소스
tbl_photovoltaic_power_stations_users바인딩된 사용자

에너지 저장​

tbl_energy_storage_containers는 rated_capacity, rated_power, contact_id, cost_center_id를 저장합니다. 구성 요소 테이블과 나열된 대응 *_points 테이블:

구성 요소 테이블데이터 포인트 테이블
tbl_energy_storage_containers_batteries (soc_point_id, power_point_id, charge_meter_id, discharge_meter_id)—
tbl_energy_storage_containers_power_conversion_systemstbl_energy_storage_containers_pcses_points
—tbl_energy_storage_containers_bmses_points (bms_id, point_id. BMS 마스터 테이블 없음)
tbl_energy_storage_containers_dcdcstbl_energy_storage_containers_dcdcs_points
tbl_energy_storage_containers_stsestbl_energy_storage_containers_stses_points
tbl_energy_storage_containers_gridstbl_energy_storage_containers_grids_points
tbl_energy_storage_containers_loadstbl_energy_storage_containers_loads_points
tbl_energy_storage_containers_hvacstbl_energy_storage_containers_hvacs_points
tbl_energy_storage_containers_firecontrolstbl_energy_storage_containers_firecontrols_points

그 밖에 tbl_energy_storage_containers_commands, tbl_energy_storage_containers_data_sources, tbl_energy_storage_containers_schedules가 있습니다.

tbl_energy_storage_power_stations는 태양광 발전소와 같은 사이트 열(주소, 좌표, 정격 용량과 전력, 연락처, 비용 센터, SVG 다섯 개, 수명 주기)을 사용합니다. 컨테이너는 tbl_energy_storage_power_stations_containers에, 사용자는 tbl_energy_storage_power_stations_users에 묶입니다.

마이크로그리드​

tbl_microgrids는 사이트 열에 postal_code와 serial_number를 더합니다. 하위 테이블:

구성 요소데이터 포인트
tbl_microgrids_batteries—
—tbl_microgrids_bmses_points (bms_id, point_id. BMS 마스터 테이블 없음)
tbl_microgrids_power_conversion_systemstbl_microgrids_pcses_points
tbl_microgrids_photovoltaicstbl_microgrids_pvs_points
tbl_microgrids_evchargerstbl_microgrids_evchargers_points
tbl_microgrids_generatorstbl_microgrids_generators_points
tbl_microgrids_gridstbl_microgrids_grids_points
tbl_microgrids_heatpumpstbl_microgrids_heatpumps_points
tbl_microgrids_loadstbl_microgrids_loads_points

그 밖에 tbl_microgrids_commands, tbl_microgrids_data_sources, tbl_microgrids_schedules, tbl_microgrids_sensors, tbl_microgrids_users가 있습니다.

기타 플랜트와 적산기​

테이블주요 열설명
tbl_charging_stations주소, 좌표, rated_capacity, rated_power, 연락처, 비용 센터, SVG 다섯 개, 수명 주기충전소
tbl_wind_farms주소, 좌표, rated_power, 연락처, 비용 센터, SVG 다섯 개풍력 발전소
tbl_virtual_power_plantscost_center_id, balancing_price_point_id, svg_id가상 발전소
tbl_virtual_power_plants_microgridsvirtual_power_plant_id, microgrid_id가상 발전소의 마이크로그리드
tbl_power_integratorspower_point_id, result_point_id, is_enabled전력을 에너지로 적산
tbl_fuel_integratorsmodel, power_point_id, result_point_id, is_enabled연료 적산기
tbl_heat_integratorshigh_temperature_point_id, low_temperature_point_id, flow_point_id, heat_capacity, liquid_density, coefficient, result_point_id, is_enabled열 적산기

명령과 제어​

테이블주요 열설명
tbl_commandstopic, payload (LONGTEXT), set_value명령 정의
tbl_control_modesname, uuid, is_active제어 모드
tbl_control_modes_timescontrol_mode_id, start_time_of_day, end_time_of_day, power_value, power_point_id, power_equation제어 모드 안의 한 구간

요금과 배출 계수​

테이블주요 열설명
tbl_tariffsenergy_category_id, tariff_type, unit_of_price, valid_from_datetime_utc, valid_through_datetime_utc요금. tariff_type은 timeofuse
tbl_tariffs_timeofusestariff_id, start_time_of_day, end_time_of_day, peak_type, price DECIMAL(23, 8)하루 중 한 구간의 가격. peak_type은 toppeak, onpeak, midpeak, offpeak, deep
tbl_cost_centers_tariffscost_center_id, tariff_id요금 바인딩
tbl_emission_factorsenergy_category_id, unit_of_factor, valid_from_datetime_utc, valid_through_datetime_utc기간이 있는 배출 계수
tbl_emission_factors_timeofusesemission_factor_id, start_time_of_day, end_time_of_day, factor하루 중 한 구간의 계수
tbl_cost_centers_emission_factorscost_center_id, emission_factor_id계수 바인딩

도면, 메뉴, 파일, 작업 지시​

테이블주요 열설명
tbl_distribution_systemsname, uuid, svg_id배전 시스템
tbl_distribution_circuitsdistribution_system_id, distribution_room, switchgear, peak_load, peak_current, customers, meters회로
tbl_distribution_circuits_pointsdistribution_circuit_id, point_id회로 데이터 포인트
tbl_energy_flow_diagramsname, uuid에너지 흐름도
tbl_energy_flow_diagrams_nodesenergy_flow_diagram_id, name노드
tbl_energy_flow_diagrams_linksenergy_flow_diagram_id, source_node_id, target_node_id, meter_uuid연결
tbl_svgsname, uuid, source_code (LONGTEXT)SVG 그래픽
tbl_menusname, route, parent_menu_id, is_hidden메뉴 트리. uuid 없음
tbl_knowledge_filesfile_name, uuid, upload_datetime_utc, upload_user_uuid, file_object (LONGBLOB)지식 베이스 파일
tbl_work_ordersnumber, category, title, priority, status, belong_to_object_type, belong_to_object_id, source_type, source_id, creator_user_id, assignee_user_id, 계획 시각과 실제 시각작업 지시
tbl_work_order_logswork_order_id, user_id, action, from_status, to_status, comment, created_datetime_utc상태 로그
tbl_work_order_fileswork_order_id, file_name, file_path, file_size, uploaded_by_user_id첨부 경로. 파일 바이트는 디스크에 저장
tbl_versionsversion, release_date스키마 버전

2. 이력 데이터베이스 (myems_historical_db)​

myems_historical_db는 데이터 포인트 원시값과 업로드된 통합 문서를 저장합니다. 테이블은 12개입니다.

값 종류마다 이력 테이블과 최신값 테이블이 있습니다. 이력 행은 is_bad와 is_published를 포함합니다. 최신값 행은 point_id, utc_date_time, actual_value만 유지합니다. 둘 다 (point_id, utc_date_time)과 utc_date_time에 인덱스가 있습니다.

테이블actual_value 형식설명
tbl_analog_value, tbl_analog_value_latestDECIMAL(21, 6)아날로그
tbl_energy_value, tbl_energy_value_latestDECIMAL(21, 6)누적 에너지
tbl_digital_value, tbl_digital_value_latestINT디지털
tbl_text_value, tbl_text_value_latestLONGTEXT텍스트

업로드 파일은 file_name, uuid, upload_datetime_utc, status(new, done, error), file_object(LONGBLOB)를 공유합니다.

테이블용도
tbl_cost_files비용 통합 문서
tbl_offline_meter_files오프라인 계량기 통합 문서
tbl_data_repair_files데이터 복구 통합 문서
tbl_energy_plan_files에너지 계획 통합 문서

3. 에너지 데이터베이스 (myems_energy_db)​

myems_energy_db는 시간별 실제 에너지를 저장합니다. 테이블은 39개이며 일, 월, 년 테이블은 없습니다. 보고서는 조회할 때 시간을 위로 합산합니다.

모든 테이블에는 id, 부모 객체 id, start_datetime_utc, actual_value DECIMAL(21, 6)이 있습니다. 분류 테이블에는 energy_category_id가, 항목 테이블에는 energy_item_id가 더 있습니다. 복합 인덱스는 (object_id, [분류 또는 항목 id], start_datetime_utc)입니다.

그룹테이블
계량기tbl_meter_hourly, tbl_offline_meter_hourly, tbl_virtual_meter_hourly
설비tbl_equipment_input_category_hourly, tbl_equipment_input_item_hourly, tbl_equipment_output_category_hourly
조합 설비tbl_combined_equipment_input_category_hourly, tbl_combined_equipment_input_item_hourly, tbl_combined_equipment_output_category_hourly
공간tbl_space_input_category_hourly, tbl_space_input_item_hourly, tbl_space_output_category_hourly
작업장tbl_shopfloor_input_category_hourly, tbl_shopfloor_input_item_hourly
매장tbl_store_input_category_hourly, tbl_store_input_item_hourly
임차인tbl_tenant_input_category_hourly, tbl_tenant_input_item_hourly
에너지 저장 컨테이너tbl_energy_storage_container_{charge,discharge,grid_buy,grid_sell,load}_hourly
에너지 저장 발전소tbl_energy_storage_power_station_{charge,discharge,grid_buy,grid_sell,load}_hourly
마이크로그리드tbl_microgrid_{charge,discharge,evcharger,grid_buy,grid_sell,load,photovoltaic}_hourly
태양광 발전소tbl_photovoltaic_power_station_{generation,grid_buy,grid_sell,load}_hourly

계량기, 오프라인 계량기, 가상 계량기, 저장, 마이크로그리드, 태양광 발전소 테이블에는 에너지 분류 열이 없습니다. 분류는 부모 객체가 결정합니다.

4. 요금 데이터베이스 (myems_billing_db)​

myems_billing_db는 myems_energy_db와 같은 39개의 시간별 테이블과 같은 열을 가집니다. actual_value는 요금 통화의 비용입니다. 과금은 시간별 에너지와 비용 센터에 바인딩된 요금을 읽습니다.

5. 탄소 데이터베이스 (myems_carbon_db)​

myems_carbon_db는 같은 39개의 시간별 테이블을 가집니다. actual_value는 배출량입니다. 계산은 시간별 에너지와 tbl_energy_categories.kgco2e 또는 tbl_emission_factors의 시간대 행을 사용합니다.

6. 에너지 기준선 데이터베이스 (myems_energy_baseline_db)​

myems_energy_baseline_db는 같은 39개의 시간별 테이블을 가집니다. actual_value는 그 시간의 기준선입니다.

7. 에너지 모델 데이터베이스 (myems_energy_model_db)​

myems_energy_model_db는 같은 39개 대상 그룹을 가집니다. 테이블 이름은 _hourly가 아니라 _8760으로 끝나고, 시간 열은 start_datetime_utc가 아니라 hour_of_year(INT)입니다. 예: tbl_meter_8760(meter_id, hour_of_year, actual_value).

8. 에너지 계획 데이터베이스 (myems_energy_plan_db)​

myems_energy_plan_db는 myems_energy_db와 같은 39개의 시간별 테이블을 가집니다. actual_value는 계획량입니다. 계획 통합 문서는 먼저 myems_historical_db.tbl_energy_plan_files에 들어갑니다.

9. 에너지 예측 데이터베이스 (myems_energy_prediction_db)​

myems_energy_prediction_db는 같은 39개의 시간별 테이블을 가집니다. actual_value는 예측량입니다.

10. FDD 데이터베이스 (myems_fdd_db)​

myems_fdd_db는 테이블 9개입니다.

테이블주요 열설명
tbl_rulesname, uuid, category, fdd_code, priority, channel, expression, message_template, is_enabled, last_run_datetime_utc, next_run_datetime_utc, is_run_immediately고장 규칙. expression은 JSON. message_template은 $ 치환을 지원하는 일반 텍스트
tbl_email_servershost, port, requires_authentication, user_name, password, from_addrSMTP 서버
tbl_email_messagesrule_id, recipient_email, subject, message, attachment_file_object, scheduled_datetime_utc, status발신 메일
tbl_text_messages_outboxrule_id, recipient_mobile, message, acknowledge_code, status발신 SMS
tbl_text_messages_inboxsender_mobile, message, received_datetime_utc, status수신 SMS
tbl_web_messagesrule_id, user_id, subject, category, priority, message, status, reply, belong_to_object_type, belong_to_object_id웹 메시지
tbl_wechat_configsapi_server, app_id, app_secret, access_token, expires_datetime_utcWeChat 앱
tbl_wechat_messages_outboxrule_id, recipient_openid, message_template_id, message_data, status발신 WeChat
tbl_wechat_messages_inboxsender_openid, message, received_datetime_utc, status수신 WeChat

tbl_rules.category는 REALTIME, SYSTEM, SPACE, METER, TENANT, STORE, SHOPFLOOR, EQUIPMENT, COMBINEDEQUIPMENT 중 하나입니다. priority는 CRITICAL, HIGH, MEDIUM, LOW입니다. channel은 WEB, EMAIL, SMS, WECHAT, CALL입니다. fdd_code는 규칙을 식별합니다. 예: REALTIME01, SPACE02.

11. 사용자 데이터베이스 (myems_user_db)​

myems_user_db는 테이블 10개입니다.

테이블주요 열설명
tbl_usersname, uuid, display_name, email, phone, salt, password, is_admin, is_read_only, privilege_id, account_expiration_datetime_utc, password_expiration_datetime_utc, failed_login_count사용자. password는 솔트 해시(VARCHAR(256))
tbl_privilegesname, data (LONGTEXT, JSON)권한 집합
tbl_sessionsuser_uuid, token, utc_expires로그인 세션
tbl_logsuser_uuid, request_datetime_utc, request_method, resource_type, resource_id, request_bodyAPI 감사 로그. request_body는 JSON
tbl_api_keysname, token, created_datetime_utc, expires_datetime_utcAPI 키. id는 INT
tbl_new_usersname, uuid, display_name, email, salt, password승인 대기 등록
tbl_email_messagesrecipient_email, subject, message, scheduled_datetime_utc, status비밀번호 재설정 같은 사용자 메일. status는 new, sent, timeout
tbl_email_message_sessionsrecipient_email, token, expires_datetime_utc메일 작업 토큰
tbl_verification_codesrecipient_email, verification_code, created_datetime_utc, expires_datetime_utc이메일 확인 코드. id는 INT
tbl_notificationsuser_id, created_datetime_utc, status, subject, message, url앱 내 알림. status는 unread, read, archived

12. 보고서 데이터베이스 (myems_reporting_db)​

myems_reporting_db는 테이블 4개입니다.

테이블주요 열설명
tbl_reportsname, uuid, expression, is_enabled, last_run_datetime_utc, next_run_datetime_utc, is_run_immediately보고서 일정. expression은 JSON
tbl_template_filesuuid, report_id, file_name, file_type, file_object보고서에 바인딩된 템플릿
tbl_reports_filesuuid, create_datetime_utc, file_name, file_type, file_object생성된 파일
tbl_email_messagesrecipient_email, subject, message, attachment_file_object, scheduled_datetime_utc, status보고서 전달 메일. 이 테이블에는 rule_id가 없음

13. 생산 데이터베이스 (myems_production_db)​

myems_production_db는 테이블 8개입니다. 시간별 생산량은 start_datetime_utc, product_id, product_count를 공유합니다.

테이블주요 열설명
tbl_productsname, uuid, unit_of_measure, tag, standard_product_coefficient제품
tbl_teamsname, uuid, description팀
tbl_shopfloors_productsshopfloor_id, product_id작업장에서 만드는 제품
tbl_shopfloors_teamsshopfloor_id, team_id작업장의 팀
tbl_shiftsshopfloor_id, team_id, product_id, product_count, start_datetime_utc, end_datetime_utc, reference_timestamp교대 기록
tbl_equipment_hourlyequipment_id, start_datetime_utc, product_id, product_count설비 하나의 시간별 생산량
tbl_shopfloor_hourlyshopfloor_id, start_datetime_utc, product_id, product_count작업장의 시간별 생산량
tbl_space_hourlyspace_id, start_datetime_utc, product_id, product_count공간으로 합산된 시간별 생산량

데이터 흐름 관계​

처리 순서:

  1. 게이트웨이는 데이터 포인트 값을 myems_historical_db에 씁니다. 업로드된 통합 문서는 같은 데이터베이스의 파일 테이블에 들어갑니다.
  2. 정규화는 tbl_points의 ratio와 offset_constant로 데이터 포인트 값을 계량기 지시값으로 바꿉니다.
  3. 집계는 계량기와 각 부모 객체(설비, 공간, 매장, 임차인, 작업장, 저장, 마이크로그리드, 태양광 발전소)에 대해 myems_energy_db에 시간별 행을 씁니다.
  4. 과금은 그 시간값에 tbl_tariffs / tbl_tariffs_timeofuses를 곱해 myems_billing_db에 씁니다.
  5. 탄소는 그 시간값에 kgco2e 또는 tbl_emission_factors를 곱해 myems_carbon_db에 씁니다.
  6. 기준선, 모델, 계획, 예측 서비스는 각자 데이터베이스에 씁니다. 모델 데이터베이스는 타임스탬프 대신 hour_of_year를 저장합니다.
  7. FDD는 tbl_rules.expression을 데이터 포인트 한계와 집계값에 대해 평가한 뒤, 이메일, SMS, 웹, WeChat 메시지를 큐에 넣습니다.
  8. 보고서는 에너지, 비용, 탄소를 읽어 tbl_template_files를 채우고 결과를 tbl_reports_files에 저장합니다.
  9. myems_production_db의 시간별 생산량은 에너지 원단위의 분모입니다.

테이블 구조 설계 사양​

공통 열​

myems_system_db의 구성 테이블은 보통 다음을 포함합니다.

열형식설명
idBIGINT NOT NULL AUTO_INCREMENT기본 키
nameVARCHAR(128) 또는 VARCHAR(255)표시 이름
uuidCHAR(36) NOT NULL안정적인 업무 키
descriptionVARCHAR(255)선택적 설명

시계열 테이블과 연관 테이블은 이 집합을 따르지 않습니다. 팩트 테이블은 id, 외래 키, actual_value를 사용합니다. 많은 연관 테이블은 id와 외래 키 두 개뿐입니다. tbl_points, tbl_menus, tbl_iot_sim_cards에는 uuid가 없습니다.

데이터 형식​

용도형식
기본 키와 외래 키BIGINT (tbl_api_keys와 tbl_verification_codes는 INT)
에너지, 비용, 탄소, 한계, 면적DECIMAL(21, 6)
요금 구간 가격DECIMAL(23, 8)
위도DECIMAL(12, 10)
경도DECIMAL(13, 10)
타임스탬프DATETIME, UTC로 저장
달력 날짜DATE
하루 중 시각TIME
플래그BOOL
짧은 코드와 상태VARCHAR
JSON 문서 (address, faults, definitions, connection, 규칙과 보고서의 expression, 권한 data, request_body)LONGTEXT
수식 (tbl_virtual_meters.equation, power_equation)LONGTEXT
디지털 포인트 값INT
파일LONGBLOB

인덱스​

보조 인덱스 이름은 {table_name}_index_{n}입니다.

패턴예
이름 조회tbl_meters_index_1 (name)
부모와 시각tbl_meter_hourly_index_1 (meter_id, start_datetime_utc)
분류와 시각tbl_space_input_category_hourly_index_1 (space_id, energy_category_id, start_datetime_utc)
데이터 포인트 이력tbl_analog_value_index_1 (point_id, utc_date_time), tbl_analog_value_index_2 (utc_date_time)
요금 유효 기간tbl_tariffs_index_2 (energy_category_id, valid_from_datetime_utc, valid_through_datetime_utc)

스크립트는 외래 키를 선언하지 않습니다. 참조 무결성은 API가 유지합니다.