|
@@ 645-670 (lines=26) @@
|
| 642 |
|
rows = cursor.fetchall() |
| 643 |
|
|
| 644 |
|
result = list() |
| 645 |
|
if rows is not None and len(rows) > 0: |
| 646 |
|
for row in rows: |
| 647 |
|
circuit_result = {"id": row[0], "name": row[1], "uuid": row[2], |
| 648 |
|
"distribution_room": row[3], "switchgear": row[4], |
| 649 |
|
"peak_load": row[5], "peak_current": row[6], |
| 650 |
|
"customers": row[7], "meters": row[8], |
| 651 |
|
"points": None} |
| 652 |
|
query = (" SELECT p.id AS point_id, p.name AS point_name, p.address AS point_address, " |
| 653 |
|
" dc.id AS distribution_circuit_id, dc.name AS distribution_circuit_name, " |
| 654 |
|
" dc.uuid AS distribution_circuit_uuid " |
| 655 |
|
" FROM tbl_points p, tbl_distribution_circuits_points dcp, tbl_distribution_circuits dc " |
| 656 |
|
" WHERE dcp.distribution_circuit_id = %s AND p.id = dcp.point_id " |
| 657 |
|
" AND dcp.distribution_circuit_id = dc.id " |
| 658 |
|
" ORDER BY p.name ") |
| 659 |
|
cursor.execute(query, (circuit_result['id'],)) |
| 660 |
|
rows = cursor.fetchall() |
| 661 |
|
|
| 662 |
|
points = list() |
| 663 |
|
if rows is not None and len(rows) > 0: |
| 664 |
|
for point_row in rows: |
| 665 |
|
point_result = {"id": point_row[0], "name": point_row[1], "address": point_row[2]} |
| 666 |
|
points.append(point_result) |
| 667 |
|
circuit_result['points'] = points |
| 668 |
|
|
| 669 |
|
result.append(circuit_result) |
| 670 |
|
meta_result['circuits'] = result |
| 671 |
|
timezone_offset = int(config.utc_offset[1:3]) * 60 + int(config.utc_offset[4:6]) |
| 672 |
|
if config.utc_offset[0] == '-': |
| 673 |
|
timezone_offset = -timezone_offset |
|
@@ 438-463 (lines=26) @@
|
| 435 |
|
rows = cursor.fetchall() |
| 436 |
|
|
| 437 |
|
result = list() |
| 438 |
|
if rows is not None and len(rows) > 0: |
| 439 |
|
for row in rows: |
| 440 |
|
circuit_result = {"id": row[0], "name": row[1], "uuid": row[2], |
| 441 |
|
"distribution_room": row[3], "switchgear": row[4], |
| 442 |
|
"peak_load": row[5], "peak_current": row[6], |
| 443 |
|
"customers": row[7], "meters": row[8], |
| 444 |
|
"points": None} |
| 445 |
|
query = (" SELECT p.id AS point_id, p.name AS point_name, " |
| 446 |
|
" dc.id AS distribution_circuit_id, dc.name AS distribution_circuit_name, " |
| 447 |
|
" dc.uuid AS distribution_circuit_uuid " |
| 448 |
|
" FROM tbl_points p, tbl_distribution_circuits_points dcp, tbl_distribution_circuits dc " |
| 449 |
|
" WHERE dcp.distribution_circuit_id = %s AND p.id = dcp.point_id " |
| 450 |
|
" AND dcp.distribution_circuit_id = dc.id " |
| 451 |
|
" ORDER BY p.name ") |
| 452 |
|
cursor.execute(query, (circuit_result['id'],)) |
| 453 |
|
rows = cursor.fetchall() |
| 454 |
|
|
| 455 |
|
points = list() |
| 456 |
|
if rows is not None and len(rows) > 0: |
| 457 |
|
for point_row in rows: |
| 458 |
|
point_result = {"id": point_row[0], "name": point_row[1]} |
| 459 |
|
points.append(point_result) |
| 460 |
|
circuit_result['points'] = points |
| 461 |
|
|
| 462 |
|
result.append(circuit_result) |
| 463 |
|
meta_result['circuits'] = result |
| 464 |
|
|
| 465 |
|
cursor.close() |
| 466 |
|
cnx.close() |