Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
nengyuanzhang committed Jan 1, 2024
2 parents 177de07 + 88577fa commit 7e848e4
Show file tree
Hide file tree
Showing 5 changed files with 353 additions and 2,869 deletions.
33 changes: 33 additions & 0 deletions database/install/myems_system_db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,39 @@ CREATE TABLE IF NOT EXISTS `myems_system_db`.`tbl_energy_storage_containers_user
CREATE INDEX `tbl_energy_storage_containers_users_index_1` ON `myems_system_db`.`tbl_energy_storage_containers_users` (`energy_storage_container_id`);


-- ---------------------------------------------------------------------------------------------------------------------
-- Table `myems_system_db`.`tbl_energy_storage_power_stations`
-- ---------------------------------------------------------------------------------------------------------------------
DROP TABLE IF EXISTS `myems_system_db`.`tbl_energy_storage_power_stations` ;

CREATE TABLE IF NOT EXISTS `myems_system_db`.`tbl_energy_storage_power_stations` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
`uuid` CHAR(36) NOT NULL,
`address` VARCHAR(255) NOT NULL,
`postal_code` VARCHAR(255) NOT NULL,
`latitude` DECIMAL(9, 6) NOT NULL,
`longitude` DECIMAL(9, 6) NOT NULL,
`capacity` DECIMAL(18, 3) NOT NULL,
`contact_id` BIGINT NOT NULL,
`cost_center_id` BIGINT NOT NULL,
`svg` LONGTEXT NOT NULL,
`description` VARCHAR(255),
PRIMARY KEY (`id`));
CREATE INDEX `tbl_energy_storage_power_stations_index_1` ON `myems_system_db`.`tbl_energy_storage_power_stations` (`name`);

-- ---------------------------------------------------------------------------------------------------------------------
-- Table `myems_system_db`.`tbl_energy_storage_power_stations_containers`
-- ---------------------------------------------------------------------------------------------------------------------
DROP TABLE IF EXISTS `myems_system_db`.`tbl_energy_storage_power_stations_containers` ;

CREATE TABLE IF NOT EXISTS `myems_system_db`.`tbl_energy_storage_power_stations_containers` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`energy_storage_power_station_id` BIGINT NOT NULL,
`energy_storage_container_id` BIGINT NOT NULL,
PRIMARY KEY (`id`));
CREATE INDEX `tbl_energy_storage_power_stations_containers_index_1` ON `myems_system_db`.`tbl_energy_storage_power_stations_containers` (`energy_storage_power_station_id`);

-- ---------------------------------------------------------------------------------------------------------------------
-- Table `myems_system_db`.`tbl_equipments`
-- ---------------------------------------------------------------------------------------------------------------------
Expand Down
261 changes: 256 additions & 5 deletions myems-api/MyEMS.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -4199,7 +4199,7 @@
},
{
"key": "Token",
"value": "89a46230080ea491b6b347ebba1d10f62721da57c9025a430ad488f47b36febfef1cf615dca508cdfc98c0eb3787af77c663e156002f38edf5eb9165cc6d8ea9",
"value": "24a728a1db350d19d99b7a58bdd4a7092273e27dec7b20a8dbe80897c4b9cdc8fc207451d27466a0eeadc95a01f9e7cd1d65d1a85655418a06405a62dd743ad5",
"type": "text"
}
],
Expand Down Expand Up @@ -4256,7 +4256,7 @@
},
{
"key": "Token",
"value": "89a46230080ea491b6b347ebba1d10f62721da57c9025a430ad488f47b36febfef1cf615dca508cdfc98c0eb3787af77c663e156002f38edf5eb9165cc6d8ea9",
"value": "24a728a1db350d19d99b7a58bdd4a7092273e27dec7b20a8dbe80897c4b9cdc8fc207451d27466a0eeadc95a01f9e7cd1d65d1a85655418a06405a62dd743ad5",
"type": "text"
}
],
Expand Down Expand Up @@ -4321,18 +4321,18 @@
},
{
"key": "Token",
"value": "89a46230080ea491b6b347ebba1d10f62721da57c9025a430ad488f47b36febfef1cf615dca508cdfc98c0eb3787af77c663e156002f38edf5eb9165cc6d8ea9",
"value": "24a728a1db350d19d99b7a58bdd4a7092273e27dec7b20a8dbe80897c4b9cdc8fc207451d27466a0eeadc95a01f9e7cd1d65d1a85655418a06405a62dd743ad5",
"type": "text"
}
],
"url": {
"raw": "{{base_url}}/energystoragecontainers/2",
"raw": "{{base_url}}/energystoragecontainers/1",
"host": [
"{{base_url}}"
],
"path": [
"energystoragecontainers",
"2"
"1"
]
}
},
Expand Down Expand Up @@ -5206,6 +5206,257 @@
}
]
},
{
"name": "Energy Storage Power Station Ⓔ",
"item": [
{
"name": "GET All Energy Storage Power Stations",
"request": {
"method": "GET",
"header": [
{
"key": "User-UUID",
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
"type": "text"
},
{
"key": "Token",
"value": "24a728a1db350d19d99b7a58bdd4a7092273e27dec7b20a8dbe80897c4b9cdc8fc207451d27466a0eeadc95a01f9e7cd1d65d1a85655418a06405a62dd743ad5",
"type": "text"
}
],
"url": {
"raw": "{{base_url}}/energystoragepowerstations",
"host": [
"{{base_url}}"
],
"path": [
"energystoragepowerstations"
]
}
},
"response": []
},
{
"name": "GET an Energy Storage Power Station by ID",
"request": {
"method": "GET",
"header": [
{
"key": "User-UUID",
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
"type": "default"
},
{
"key": "Token",
"value": "24a728a1db350d19d99b7a58bdd4a7092273e27dec7b20a8dbe80897c4b9cdc8fc207451d27466a0eeadc95a01f9e7cd1d65d1a85655418a06405a62dd743ad5",
"type": "default"
}
],
"url": {
"raw": "{{base_url}}/energystoragepowerstations/1",
"host": [
"{{base_url}}"
],
"path": [
"energystoragepowerstations",
"1"
]
}
},
"response": []
},
{
"name": "POST Create New Energy Storage Power Station",
"request": {
"method": "POST",
"header": [
{
"key": "User-UUID",
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
"type": "text"
},
{
"key": "Token",
"value": "24a728a1db350d19d99b7a58bdd4a7092273e27dec7b20a8dbe80897c4b9cdc8fc207451d27466a0eeadc95a01f9e7cd1d65d1a85655418a06405a62dd743ad5",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\"data\":{\"name\":\"Beijing Office\", \"address\":\"Wangfujing Street, Dongcheng District, Beijing\", \"postal_code\":\"100000\", \"latitude\":39.909429, \"longitude\":116.416993, \"capacity\":600.000, \"contact_id\":1, \"cost_center_id\":1, \"svg\":\"<svg></svg>\", \"description\":\"Classic\"}}"
},
"url": {
"raw": "{{base_url}}/energystoragepowerstations",
"host": [
"{{base_url}}"
],
"path": [
"energystoragepowerstations"
]
}
},
"response": []
},
{
"name": "PUT Update an Energy Storage Power Station",
"request": {
"method": "PUT",
"header": [
{
"key": "User-UUID",
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
"type": "text"
},
{
"key": "Token",
"value": "24a728a1db350d19d99b7a58bdd4a7092273e27dec7b20a8dbe80897c4b9cdc8fc207451d27466a0eeadc95a01f9e7cd1d65d1a85655418a06405a62dd743ad5",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\"data\":{\"name\":\"Beijing Office\", \"address\":\"Wangfujing Street, Dongcheng District, Beijing\", \"postal_code\":\"100000\", \"latitude\":39.909429, \"longitude\":116.416993, \"capacity\":600.000, \"contact_id\":1, \"cost_center_id\":1, \"svg\":\"<svg></svg>\", \"description\":\"Classic\"}}"
},
"url": {
"raw": "{{base_url}}/energystoragepowerstations/1",
"host": [
"{{base_url}}"
],
"path": [
"energystoragepowerstations",
"1"
]
}
},
"response": []
},
{
"name": "DELETE an Energy Storage Power Station by ID",
"request": {
"method": "DELETE",
"header": [
{
"key": "User-UUID",
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
"type": "text"
},
{
"key": "Token",
"value": "24a728a1db350d19d99b7a58bdd4a7092273e27dec7b20a8dbe80897c4b9cdc8fc207451d27466a0eeadc95a01f9e7cd1d65d1a85655418a06405a62dd743ad5",
"type": "text"
}
],
"url": {
"raw": "{{base_url}}/energystoragepowerstations/2",
"host": [
"{{base_url}}"
],
"path": [
"energystoragepowerstations",
"2"
]
}
},
"response": []
},
{
"name": "GET All Energy Storage Containers of an Energy Storage Power Station",
"request": {
"method": "GET",
"header": [
{
"key": "User-UUID",
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
"type": "default"
},
{
"key": "Token",
"value": "24a728a1db350d19d99b7a58bdd4a7092273e27dec7b20a8dbe80897c4b9cdc8fc207451d27466a0eeadc95a01f9e7cd1d65d1a85655418a06405a62dd743ad5",
"type": "default"
}
],
"url": {
"raw": "{{base_url}}/energystoragepowerstations/1/containers",
"host": [
"{{base_url}}"
],
"path": [
"energystoragepowerstations",
"1",
"containers"
]
}
},
"response": []
},
{
"name": "POST Bind an Energy Storage Container to an Energy Storage Power Station",
"request": {
"method": "POST",
"header": [
{
"key": "User-UUID",
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
"type": "text"
},
{
"key": "Token",
"value": "24a728a1db350d19d99b7a58bdd4a7092273e27dec7b20a8dbe80897c4b9cdc8fc207451d27466a0eeadc95a01f9e7cd1d65d1a85655418a06405a62dd743ad5",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\"data\":{\"energy_storage_container_id\":1}}"
},
"url": {
"raw": "{{base_url}}/energystoragepowerstations/1/containers",
"host": [
"{{base_url}}"
],
"path": [
"energystoragepowerstations",
"1",
"containers"
]
}
},
"response": []
},
{
"name": "DELETE an Energy Storage from an Energy Storage Container",
"request": {
"method": "DELETE",
"header": [
{
"key": "User-UUID",
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
"type": "text"
},
{
"key": "Token",
"value": "24a728a1db350d19d99b7a58bdd4a7092273e27dec7b20a8dbe80897c4b9cdc8fc207451d27466a0eeadc95a01f9e7cd1d65d1a85655418a06405a62dd743ad5",
"type": "text"
}
],
"url": {
"raw": "{{base_url}}/energystoragepowerstations/1/containers/1",
"host": [
"{{base_url}}"
],
"path": [
"energystoragepowerstations",
"1",
"containers",
"1"
]
}
},
"response": []
}
]
},
{
"name": "Equipment",
"item": [
Expand Down
11 changes: 10 additions & 1 deletion myems-api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
costfile, offlinemeterfile, version, contact, emailserver, combinedequipment, datasource, equipment, tenant, \
shopfloor, webmessage, distributionsystem, store, emailmessage, tenanttype, wechatmessage, space, gateway, \
offlinemeter, rule, energycategory, sensor, energyitem, notification, menu, datarepairfile, workingcalendar, \
microgrid, virtualpowerplant, energystoragecontainer, photovoltaicpowerstation, windfarm
microgrid, virtualpowerplant, energystoragecontainer, energystoragepowerstation, photovoltaicpowerstation, windfarm

from reports import advancedreportfile
from reports import combinedequipmentbatch
Expand Down Expand Up @@ -276,6 +276,15 @@
api.add_route('/energystoragecontainers/{id_}/users/{uid}',
energystoragecontainer.EnergyStorageContainerUserItem())

api.add_route('/energystoragepowerstations',
energystoragepowerstation.EnergyStoragePowerStationCollection())
api.add_route('/energystoragepowerstations/{id_}',
energystoragepowerstation.EnergyStoragePowerStationItem())
api.add_route('/energystoragepowerstations/{id_}/containers',
energystoragepowerstation.EnergyStoragePowerStationContainerCollection())
api.add_route('/energystoragepowerstations/{id_}/containers/{sid}',
energystoragepowerstation.EnergyStoragePowerStationContainerItem())

api.add_route('/equipments',
equipment.EquipmentCollection())
api.add_route('/equipments/{id_}',
Expand Down
21 changes: 20 additions & 1 deletion myems-api/core/energystoragecontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,26 @@ def on_delete(req, resp, id_):
raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
description='API.ENERGY_STORAGE_CONTAINER_NOT_FOUND')

cursor.execute(" DELETE FROM tbl_energy_storage_containers WHERE id = %s ", (id_,))
cursor.execute(" DELETE FROM tbl_energy_storage_containers_sensors "
" WHERE energy_storage_container_id = %s ", (id_, ))

cursor.execute(" DELETE FROM tbl_energy_storage_containers_batteries "
" WHERE energy_storage_container_id = %s ", (id_, ))

cursor.execute(" DELETE FROM tbl_energy_storage_containers_grids "
" WHERE energy_storage_container_id = %s ", (id_, ))

cursor.execute(" DELETE FROM tbl_energy_storage_containers_loads "
" WHERE energy_storage_container_id = %s ", (id_, ))

cursor.execute(" DELETE FROM tbl_energy_storage_containers_power_conversion_systems "
" WHERE energy_storage_container_id = %s ", (id_, ))

cursor.execute(" DELETE FROM tbl_energy_storage_containers_users "
" WHERE energy_storage_container_id = %s ", (id_, ))

cursor.execute(" DELETE FROM tbl_energy_storage_containers "
" WHERE id = %s ", (id_,))
cnx.commit()

cursor.close()
Expand Down
Loading

0 comments on commit 7e848e4

Please sign in to comment.