提交 8920b35a 编写于 作者: nengyuangzhang's avatar nengyuangzhang

added microgrid actions in myems-api

上级 313d6e2c
......@@ -566,7 +566,7 @@ CREATE TABLE IF NOT EXISTS `myems_system_db`.`tbl_microgrids` (
`address` VARCHAR(255) NOT NULL,
`latitude` DECIMAL(9, 6) NOT NULL,
`longitude` DECIMAL(9, 6) NOT NULL,
`installed_capacity` DECIMAL(18, 3) NOT NULL,
`capacity` DECIMAL(18, 3) NOT NULL,
`microgrid_type_id` BIGINT NOT NULL,
`microgrid_owner_type_id` BIGINT NOT NULL,
`is_input_counted` BOOL NOT NULL,
......@@ -631,6 +631,47 @@ VALUES
(3, 'Industrial', 'e99fceda-1b34-4b6a-8bd2-c8532c835322', 'Industry', 'IND');
-- ---------------------------------------------------------------------------------------------------------------------
-- Table `myems_system_db`.`tbl_microgrids_batteries`
-- ---------------------------------------------------------------------------------------------------------------------
DROP TABLE IF EXISTS `myems_system_db`.`tbl_microgrids_batteries` ;
CREATE TABLE IF NOT EXISTS `myems_system_db`.`tbl_microgrids_batteries` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
`uuid` CHAR(36) NOT NULL,
`microgrid_id` BIGINT NOT NULL,
`capacity` DECIMAL(18, 3) NOT NULL,
PRIMARY KEY (`id`));
CREATE INDEX `tbl_microgrids_batteries_index_1` ON `myems_system_db`.`tbl_microgrids_batteries` (`name`);
-- ---------------------------------------------------------------------------------------------------------------------
-- Table `myems_system_db`.`tbl_microgrids_photovoltaics`
-- ---------------------------------------------------------------------------------------------------------------------
DROP TABLE IF EXISTS `myems_system_db`.`tbl_microgrids_photovoltaics` ;
CREATE TABLE IF NOT EXISTS `myems_system_db`.`tbl_microgrids_photovoltaics` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
`uuid` CHAR(36) NOT NULL,
`microgrid_id` BIGINT NOT NULL,
`capacity` DECIMAL(18, 3) NOT NULL,
PRIMARY KEY (`id`));
CREATE INDEX `tbl_microgrids_photovoltaics_index_1` ON `myems_system_db`.`tbl_microgrids_photovoltaics` (`name`);
-- ---------------------------------------------------------------------------------------------------------------------
-- Table `myems_system_db`.`tbl_microgrids_sensors`
-- ---------------------------------------------------------------------------------------------------------------------
DROP TABLE IF EXISTS `myems_system_db`.`tbl_microgrids_sensors` ;
CREATE TABLE IF NOT EXISTS `myems_system_db`.`tbl_microgrids_sensors` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`microgrid_id` BIGINT NOT NULL,
`sensor_id` BIGINT NOT NULL,
PRIMARY KEY (`id`));
CREATE INDEX `tbl_microgrids_sensors_index_1` ON `myems_system_db`.`tbl_microgrids_sensors` (`microgrid_id`);
-- ---------------------------------------------------------------------------------------------------------------------
-- Table `myems_system_db`.`tbl_offline_meters`
-- ---------------------------------------------------------------------------------------------------------------------
......
......@@ -18,7 +18,7 @@ CREATE TABLE IF NOT EXISTS `myems_system_db`.`tbl_microgrids` (
`address` VARCHAR(255) NOT NULL,
`latitude` DECIMAL(9, 6) NOT NULL,
`longitude` DECIMAL(9, 6) NOT NULL,
`installed_capacity` DECIMAL(18, 3) NOT NULL,
`capacity` DECIMAL(18, 3) NOT NULL,
`microgrid_type_id` BIGINT NOT NULL,
`microgrid_owner_type_id` BIGINT NOT NULL,
`is_input_counted` BOOL NOT NULL,
......@@ -81,6 +81,46 @@ VALUES
(3, 'Industrial', 'e99fceda-1b34-4b6a-8bd2-c8532c835322', 'Industry', 'IND');
-- ---------------------------------------------------------------------------------------------------------------------
-- Table `myems_system_db`.`tbl_microgrids_batteries`
-- ---------------------------------------------------------------------------------------------------------------------
DROP TABLE IF EXISTS `myems_system_db`.`tbl_microgrids_batteries` ;
CREATE TABLE IF NOT EXISTS `myems_system_db`.`tbl_microgrids_batteries` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
`uuid` CHAR(36) NOT NULL,
`microgrid_id` BIGINT NOT NULL,
`capacity` DECIMAL(18, 3) NOT NULL,
PRIMARY KEY (`id`));
CREATE INDEX `tbl_microgrids_batteries_index_1` ON `myems_system_db`.`tbl_microgrids_batteries` (`name`);
-- ---------------------------------------------------------------------------------------------------------------------
-- Table `myems_system_db`.`tbl_microgrids_photovoltaics`
-- ---------------------------------------------------------------------------------------------------------------------
DROP TABLE IF EXISTS `myems_system_db`.`tbl_microgrids_photovoltaics` ;
CREATE TABLE IF NOT EXISTS `myems_system_db`.`tbl_microgrids_photovoltaics` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
`uuid` CHAR(36) NOT NULL,
`microgrid_id` BIGINT NOT NULL,
`capacity` DECIMAL(18, 3) NOT NULL,
PRIMARY KEY (`id`));
CREATE INDEX `tbl_microgrids_photovoltaics_index_1` ON `myems_system_db`.`tbl_microgrids_photovoltaics` (`name`);
-- ---------------------------------------------------------------------------------------------------------------------
-- Table `myems_system_db`.`tbl_microgrids_sensors`
-- ---------------------------------------------------------------------------------------------------------------------
DROP TABLE IF EXISTS `myems_system_db`.`tbl_microgrids_sensors` ;
CREATE TABLE IF NOT EXISTS `myems_system_db`.`tbl_microgrids_sensors` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`microgrid_id` BIGINT NOT NULL,
`sensor_id` BIGINT NOT NULL,
PRIMARY KEY (`id`));
CREATE INDEX `tbl_microgrids_sensors_index_1` ON `myems_system_db`.`tbl_microgrids_sensors` (`microgrid_id`);
-- UPDATE VERSION NUMBER
UPDATE `myems_system_db`.`tbl_versions` SET version='3.4.0RC', release_date='2023-06-16' WHERE id=1;
......
{
"info": {
"_postman_id": "bd0a9e37-486d-4575-b91a-bdbdcddae6b3",
"_postman_id": "cf01b0e4-707f-4eab-9532-96586e805515",
"name": "MyEMS",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "9079920"
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
......@@ -4587,6 +4586,224 @@
}
]
},
{
"name": "Microgrid",
"item": [
{
"name": "GET All Microgrids",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{base_url}}/microgrids",
"host": [
"{{base_url}}"
],
"path": [
"microgrids"
]
}
},
"response": []
},
{
"name": "GET a Microgrid by ID",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{base_url}}/microgrids/1",
"host": [
"{{base_url}}"
],
"path": [
"microgrids",
"1"
]
}
},
"response": []
},
{
"name": "POST Create New Microgrids",
"request": {
"method": "POST",
"header": [
{
"key": "User-UUID",
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
"type": "text"
},
{
"key": "Token",
"value": "9a3748fadf64270dd4617594939169d0008a1b713e3a5861af384c68de73442b56b56771ce2be1e51ecd7443ec0fc1fbd6dcc3335a2c7518ca12b7a479ccb2e0",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\"data\":{\"name\":\"Beijing Office\", \"address\":\"Wangfujing Street, Dongcheng District, Beijing\", \"latitude\":39.909429, \"longitude\":116.416993, \"capacity\":600.000, \"microgrid_type_id\":1, \"microgrid_owner_type_id\":1, \"is_input_counted\":true, \"is_output_counted\":true, \"contact_id\":1, \"cost_center_id\":1, \"description\":\"Classic\"}}"
},
"url": {
"raw": "{{base_url}}/microgrids",
"host": [
"{{base_url}}"
],
"path": [
"microgrids"
]
}
},
"response": []
},
{
"name": "PUT Update a Microgrid",
"request": {
"method": "PUT",
"header": [
{
"key": "User-UUID",
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
"type": "text"
},
{
"key": "Token",
"value": "9a3748fadf64270dd4617594939169d0008a1b713e3a5861af384c68de73442b56b56771ce2be1e51ecd7443ec0fc1fbd6dcc3335a2c7518ca12b7a479ccb2e0",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\"data\":{\"name\":\"Beijing Office\", \"address\":\"Wangfujing Street, Dongcheng District, Beijing\", \"latitude\":39.909429, \"longitude\":116.416993, \"capacity\":600.000, \"microgrid_type_id\":1, \"microgrid_owner_type_id\":1, \"is_input_counted\":true, \"is_output_counted\":true, \"contact_id\":1, \"cost_center_id\":1, \"description\":\"New\"}}"
},
"url": {
"raw": "{{base_url}}/microgrids/1",
"host": [
"{{base_url}}"
],
"path": [
"microgrids",
"1"
]
}
},
"response": []
},
{
"name": "DELETE a Microgrid by ID",
"request": {
"method": "DELETE",
"header": [
{
"key": "User-UUID",
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
"type": "text"
},
{
"key": "Token",
"value": "9a3748fadf64270dd4617594939169d0008a1b713e3a5861af384c68de73442b56b56771ce2be1e51ecd7443ec0fc1fbd6dcc3335a2c7518ca12b7a479ccb2e0",
"type": "text"
}
],
"url": {
"raw": "{{base_url}}/microgrids/2",
"host": [
"{{base_url}}"
],
"path": [
"microgrids",
"2"
]
}
},
"response": []
},
{
"name": "GET All Sensors of Microgrid by ID",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{base_url}}/microgrids/1/sensors",
"host": [
"{{base_url}}"
],
"path": [
"microgrids",
"1",
"sensors"
]
}
},
"response": []
},
{
"name": "POST Bind a Sensor to a Microgrid",
"request": {
"method": "POST",
"header": [
{
"key": "User-UUID",
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
"type": "text"
},
{
"key": "Token",
"value": "9a3748fadf64270dd4617594939169d0008a1b713e3a5861af384c68de73442b56b56771ce2be1e51ecd7443ec0fc1fbd6dcc3335a2c7518ca12b7a479ccb2e0",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\"data\":{\"sensor_id\":1}}"
},
"url": {
"raw": "{{base_url}}/microgrids/1/sensors",
"host": [
"{{base_url}}"
],
"path": [
"microgrids",
"1",
"sensors"
]
}
},
"response": []
},
{
"name": "DELETE a Sensor from Stores",
"request": {
"method": "DELETE",
"header": [
{
"key": "User-UUID",
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
"type": "text"
},
{
"key": "Token",
"value": "9a3748fadf64270dd4617594939169d0008a1b713e3a5861af384c68de73442b56b56771ce2be1e51ecd7443ec0fc1fbd6dcc3335a2c7518ca12b7a479ccb2e0",
"type": "text"
}
],
"url": {
"raw": "{{base_url}}/microgrids/1/sensors/1",
"host": [
"{{base_url}}"
],
"path": [
"microgrids",
"1",
"sensors",
"1"
]
}
},
"response": []
}
]
},
{
"name": "Notification",
"item": [
......
......@@ -35,7 +35,7 @@ python-decouple
Quick run on Linux (NOT for production use):
```bash
cd myems/myems-api
sudo pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
sudo pip install -r requirements.txt
cp example.env .env
sudo chmod +x run.sh
./run.sh
......
......@@ -6,7 +6,9 @@ from core import energyflowdiagram, privilege, textmessage, distributioncircuit,
costcenter, point, knowledgefile, meter, tariff, user, storetype, timezone, \
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
offlinemeter, rule, energycategory, sensor, energyitem, notification, menu, datarepairfile, workingcalendar, \
microgrid
from reports import advancedreport
from reports import combinedequipmentbatch
from reports import combinedequipmentcarbon
......@@ -277,6 +279,15 @@ api.add_route('/meters/{id_}/points',
api.add_route('/meters/{id_}/points/{pid}',
meter.MeterPointItem())
api.add_route('/microgrids',
microgrid.MicrogridCollection())
api.add_route('/microgrids/{id_}',
microgrid.MicrogridItem())
api.add_route('/microgrids/{id_}/sensors',
microgrid.MicrogridSensorCollection())
api.add_route('/microgrids/{id_}/sensors/{sid}',
microgrid.MicrogridSensorItem())
api.add_route('/notifications',
notification.NotificationCollection())
api.add_route('/notifications/{id_}',
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册