# ========================================== # config.py - 다중 업체(Multi-Tenant) 설정 관리 # ========================================== # --------------------------------------------------------- # [시스템 상수] 각 크롤러 시스템의 URL 및 엔드포인트 # --------------------------------------------------------- SYSTEM_CONSTANTS = { 'nrems': { 'api_url': 'http://www.nrems.co.kr/v2/local/proc/index_proc.php', 'detail_url': 'http://www.nrems.co.kr/v2/local/comp/cp_inv.php', 'inv_proc_url': 'http://www.nrems.co.kr/v2/local/proc/cp_inv_proc.php' }, 'kremc': { 'login_url': 'https://kremc.kr/api/v2.2/login', 'api_base': 'https://kremc.kr/api/v2.2', 'enso_type': '15001' }, 'sun_wms': { 'base_url': 'http://tb6.sun-wms.com', 'login_url': 'http://tb6.sun-wms.com/public/main/login_chk.php', 'data_url': 'http://tb6.sun-wms.com/public/main/realdata.php', 'statics_url': 'http://tb6.sun-wms.com/public/statics/statics.php' }, 'hyundai': { 'base_url': 'https://hs3.hyundai-es.co.kr', 'login_path': '/hismart/login', 'data_path': '/hismart/site/getSolraUnitedWork' }, 'cmsolar': { 'base_url': 'http://www.cmsolar2.kr', 'api_url': 'http://www.cmsolar2.kr', 'login_url': 'http://www.cmsolar2.kr/login_ok.php', 'data_url': 'http://www.cmsolar2.kr/plant/sub/report_ok.php' } } # --------------------------------------------------------- # [업체 목록] 업체 > 발전소 계층 구조 # --------------------------------------------------------- COMPANIES = [ { 'company_id': 'sunwind', 'company_name': '태양과바람', 'plants': [ # NREMS 계열 - 1, 2호기 (분리 처리) # id는 크롤러 내부에서 'nrems-01', 'nrems-02'로 분리 할당 { 'name': '1호기, 2호기', 'display_name': 'SPLIT_1_2', 'type': 'nrems', 'auth': { 'pscode': 'duce2023072288' }, 'options': { 'is_split': True }, 'start_date': '2014-03-31', 'capacity_kw': 100.0 # 1호기 50kW + 2호기 50kW # id는 크롤러에서 동적 할당 (nrems-01, nrems-02) }, # NREMS 계열 - 3호기 { 'id': 'nrems-03', 'name': '3호기', 'type': 'nrems', 'auth': { 'pscode': 'dc2023121086' }, 'options': { 'is_split': False }, 'start_date': '2015-12-22', 'capacity_kw': 99.82 }, # NREMS 계열 - 4호기 { 'id': 'nrems-04', 'name': '4호기', 'type': 'nrems', 'auth': { 'pscode': 'dc2023121085' }, 'options': { 'is_split': False }, 'start_date': '2017-01-11', 'capacity_kw': 88.2 }, # NREMS 계열 - 9호기 { 'id': 'nrems-09', 'name': '9호기', 'type': 'nrems', 'auth': { 'pscode': 'a2020061008' }, 'options': { 'is_split': False }, 'start_date': '2020-10-28', 'capacity_kw': 99.12 }, # KREMC - 5호기 { 'id': 'kremc-05', 'name': '5호기', 'type': 'kremc', 'auth': { 'user_id': '서대문도서관', 'password': 'sunhope5!' }, 'options': { 'cid': '10013000376', 'cityProvCode': '11', 'rgnCode': '11410', 'dongCode': '1141011700' }, 'start_date': '2018-06-28', 'capacity_kw': 42.7 }, # Sun-WMS - 6호기 { 'id': 'sunwms-06', 'name': '6호기', 'type': 'sun_wms', 'auth': { 'payload_id': 'kc0fXUW0LUm2wZa+2NQI0Q==', 'payload_pw': 'PGXjU6ib2mKYwtrh2i3fIQ==' }, 'options': {}, 'start_date': '2019-12-30', 'capacity_kw': 49.9 }, # 현대 - 8호기 { 'id': 'hyundai-08', 'name': '8호기', 'type': 'hyundai', 'auth': { 'user_id': 'epecoop', 'password': 'sunhope0419', 'site_id': 'M0494' }, 'options': {}, 'start_date': '2020-02-06', 'capacity_kw': 99.9 }, # CMSolar - 10호기 { 'id': 'cmsolar-10', 'name': '10호기', 'type': 'cmsolar', 'auth': { 'login_id': 'sy7144', 'login_pw': 'sy7144', 'site_no': '834' }, 'options': {}, 'start_date': '2020-08-31', 'capacity_kw': 31.5 } ] } ] # --------------------------------------------------------- # [헬퍼 함수] 평탄화된 발전소 리스트 반환 # --------------------------------------------------------- def get_all_plants(): """ 모든 업체의 발전소 정보를 평탄화하여 반환 """ all_plants = [] for company in COMPANIES: company_id = company.get('company_id', '') company_name = company.get('company_name', '') for plant in company.get('plants', []): plant_type = plant.get('type', '') system_config = SYSTEM_CONSTANTS.get(plant_type, {}) plant_info = { 'company_id': company_id, 'company_name': company_name, 'id': plant.get('id', ''), # DB용 고유 ID 'name': plant.get('name', ''), 'display_name': plant.get('display_name', plant.get('name', '')), 'type': plant_type, 'auth': plant.get('auth', {}), 'options': plant.get('options', {}), 'start_date': plant.get('start_date', ''), 'capacity_kw': plant.get('capacity_kw', 0.0), 'system': system_config } all_plants.append(plant_info) return all_plants def get_plants_by_company(company_id): """특정 업체의 발전소만 반환""" return [p for p in get_all_plants() if p['company_id'] == company_id] def get_plants_by_type(plant_type): """특정 타입의 발전소만 반환""" return [p for p in get_all_plants() if p['type'] == plant_type]