6 |
6 |
import subprocess
|
7 |
7 |
from functools import partial
|
8 |
8 |
|
9 |
|
from openpyxl.drawing import colors
|
10 |
|
|
|
9 |
# from openpyxl.drawing import colors
|
11 |
10 |
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
|
12 |
11 |
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '\\Commands')
|
13 |
12 |
import CreateCommand
|
... | ... | |
15 |
14 |
import PlaceStreamlineCommand
|
16 |
15 |
import LeftAlignmentCommand, RightAlignmentCommand, UpAlignmentCommand, DownAlignmentCommand
|
17 |
16 |
|
18 |
|
import numpy as np
|
19 |
|
|
20 |
17 |
from PyQt5.QtCore import *
|
21 |
18 |
from PyQt5.QtGui import *
|
22 |
19 |
from PyQt5.QtWidgets import *
|
23 |
20 |
from PyQt5.QtSvg import *
|
24 |
21 |
|
25 |
|
from PIL import Image
|
26 |
|
|
27 |
22 |
import MainWindow_UI
|
28 |
23 |
import QtImageViewer
|
29 |
24 |
from SingletonInstance import SingletonInstane
|
... | ... | |
168 |
163 |
self.actionUndo.triggered.connect(self.on_undo)
|
169 |
164 |
self.actionRedo.triggered.connect(self.on_redo)
|
170 |
165 |
self.actionCalculation.triggered.connect(partial(self.calculation, True))
|
171 |
|
self.actionGenerateReport.triggered.connect(self.generate_report)
|
|
166 |
self.actionGenerateReport.triggered.connect(self.on_generate_report)
|
172 |
167 |
self.actionLine.triggered.connect(self.onPlaceLine)
|
173 |
168 |
self.actionConfiguration.triggered.connect(self.configuration)
|
174 |
169 |
self.actionInitialize.triggered.connect(self.onInitializeScene)
|
... | ... | |
1355 |
1350 |
f"{sys.exc_info()[-1].tb_lineno}"
|
1356 |
1351 |
self.addMessage.emit(MessageType.Error, message)
|
1357 |
1352 |
|
1358 |
|
def generate_report(self):
|
|
1353 |
def on_generate_report(self):
|
1359 |
1354 |
"""generate calculation report"""
|
1360 |
1355 |
from tempfile import NamedTemporaryFile
|
1361 |
1356 |
import openpyxl
|
1362 |
1357 |
from DrawImage import DrawImage
|
1363 |
1358 |
from openpyxl.styles import Font
|
1364 |
1359 |
from datetime import datetime
|
1365 |
|
from EngineeringStreamlineItem import QEngineeringStreamlineItem
|
|
1360 |
# from EngineeringStreamlineItem import QEngineeringStreamlineItem
|
1366 |
1361 |
|
1367 |
1362 |
try:
|
1368 |
1363 |
app_doc_data = AppDocData.instance()
|
... | ... | |
1404 |
1399 |
pages = math.ceil(len(list(app_doc_data.activeDrawing.hmbTable.streamNos())) / 20)
|
1405 |
1400 |
for page in range(pages):
|
1406 |
1401 |
ws = wb.copy_worksheet(wb.get_sheet_by_name('Page'))
|
1407 |
|
ws.title = 'Page ({})'.format(page_no)
|
|
1402 |
ws.title = f"Page ({page_no})"
|
1408 |
1403 |
|
1409 |
1404 |
cal_image = openpyxl.drawing.image.Image(image_path)
|
1410 |
1405 |
rect = self.graphicsView.sceneRect()
|
... | ... | |
1417 |
1412 |
company_image = openpyxl.drawing.image.Image(company_image_path)
|
1418 |
1413 |
company_image.width *= 0.8
|
1419 |
1414 |
company_image.height *= 0.7
|
1420 |
|
ws.add_image(company_image, 'W53')
|
|
1415 |
ws.add_image(company_image, 'X54')
|
1421 |
1416 |
|
1422 |
1417 |
"""write sheet information"""
|
1423 |
1418 |
configs = app_doc_data.getConfigs('Sheet')
|
1424 |
1419 |
for config in configs:
|
1425 |
1420 |
if config.key == 'JobNo' and config.value:
|
1426 |
|
ws['Z58'].value = config.value
|
|
1421 |
ws['Z59'].value = config.value
|
1427 |
1422 |
elif config.key == 'JobName' and config.value:
|
1428 |
|
ws['W59'].value = config.value
|
|
1423 |
ws['W60'].value = config.value
|
1429 |
1424 |
elif config.key == 'Description' and config.value:
|
1430 |
|
ws['W73'].value = config.value
|
|
1425 |
ws['W74'].value = config.value
|
1431 |
1426 |
elif config.key == 'RevStatus' and config.value:
|
1432 |
|
ws['Y68'].value = config.value
|
|
1427 |
ws['Y69'].value = config.value
|
1433 |
1428 |
elif config.key == 'CheckedBy' and config.value:
|
1434 |
|
ws['Z78'].value = config.value
|
1435 |
|
elif config.key == 'ApprovedBy' and config.value:
|
1436 |
1429 |
ws['Z79'].value = config.value
|
|
1430 |
elif config.key == 'ApprovedBy' and config.value:
|
|
1431 |
ws['Z80'].value = config.value
|
1437 |
1432 |
|
1438 |
1433 |
configs = app_doc_data.getAppConfigs('app', 'SingleID')
|
1439 |
1434 |
if configs and configs[0].value:
|
1440 |
|
ws['Z77'].value = configs[0].value
|
1441 |
|
ws['Z68'].value = str(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
|
|
1435 |
ws['Z78'].value = configs[0].value
|
|
1436 |
ws['Z69'].value = str(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
|
1442 |
1437 |
"""up to here"""
|
1443 |
1438 |
|
1444 |
1439 |
# Output [Pump, Compressor, Control Valve]
|
... | ... | |
1688 |
1683 |
row_no = row_no - 4 if col_no == 28 else row_no + 2
|
1689 |
1684 |
|
1690 |
1685 |
# write hmb unit
|
1691 |
|
ws['B54'].value = '-'
|
1692 |
|
ws['B55'].value = units['Pipe_Diameter']
|
1693 |
|
ws['B56'].value = units['Flowrate_Mass']
|
1694 |
|
ws['B57'].value = units['Flowrate_Volume']
|
1695 |
|
ws['B58'].value = units['Density']
|
1696 |
|
ws['B59'].value = units['Viscosity']
|
1697 |
|
ws['B60'].value = units['Temperature'] # Hidden
|
1698 |
|
ws['B61'].value = '' # Hidden
|
|
1686 |
ws['B55'].value = '-'
|
|
1687 |
ws['B56'].value = units['Pipe_Diameter']
|
|
1688 |
ws['B57'].value = units['Flowrate_Mass']
|
|
1689 |
ws['B58'].value = units['Flowrate_Volume']
|
|
1690 |
ws['B59'].value = units['Density']
|
|
1691 |
ws['B60'].value = units['Viscosity']
|
|
1692 |
ws['B61'].value = units['Temperature'] # Hidden
|
1699 |
1693 |
ws['B62'].value = '' # Hidden
|
1700 |
1694 |
ws['B63'].value = '' # Hidden
|
1701 |
|
ws['B64'].value = units['Pipe_Diameter'] # Hidden
|
|
1695 |
ws['B64'].value = '' # Hidden
|
1702 |
1696 |
ws['B65'].value = units['Pipe_Diameter'] # Hidden
|
1703 |
|
ws['B66'].value = '' # Hidden
|
1704 |
|
ws['B67'].value = units['Length']
|
|
1697 |
ws['B66'].value = units['Pipe_Diameter'] # Hidden
|
|
1698 |
ws['B67'].value = '' # Hidden
|
1705 |
1699 |
ws['B68'].value = units['Length']
|
1706 |
|
ws['B69'].value = units['Roughness']
|
1707 |
|
ws['B70'].value = units['Velocity'] # Hidden
|
1708 |
|
ws['B71'].value = '{}/100{})'.format(units['Pressure'], units['Length']) # Hidden
|
1709 |
|
ws['B73'].value = units['Velocity']
|
1710 |
|
ws['B74'].value = '' # Hidden
|
|
1700 |
ws['B69'].value = units['Length']
|
|
1701 |
ws['B70'].value = units['Roughness']
|
|
1702 |
ws['B71'].value = units['Velocity'] # Hidden
|
|
1703 |
ws['B72'].value = '{}/100{})'.format(units['Pressure'], units['Length']) # Hidden
|
|
1704 |
ws['B74'].value = units['Velocity']
|
1711 |
1705 |
ws['B75'].value = '' # Hidden
|
1712 |
|
ws['B76'].value = '{}/100{}'.format(units['Pressure'], units['Length'])
|
1713 |
|
ws['B77'].value = units['Pressure']
|
|
1706 |
ws['B76'].value = '' # Hidden
|
|
1707 |
ws['B77'].value = '{}/100{}'.format(units['Pressure'], units['Length'])
|
1714 |
1708 |
ws['B78'].value = units['Pressure']
|
1715 |
|
ws['B79'].value = '{}(g)'.format(units['Pressure'])
|
|
1709 |
ws['B79'].value = units['Pressure']
|
|
1710 |
ws['B80'].value = '{}(g)'.format(units['Pressure'])
|
1716 |
1711 |
|
1717 |
1712 |
page_no += 1
|
1718 |
1713 |
|
... | ... | |
1732 |
1727 |
current_ws = ws
|
1733 |
1728 |
col_no = 3
|
1734 |
1729 |
|
1735 |
|
row_no = 53
|
|
1730 |
row_no = 54
|
1736 |
1731 |
ws.cell(row_no, col_no, hmb.stream_no)
|
1737 |
1732 |
row_no += 1
|
1738 |
1733 |
ws.cell(row_no, col_no, hmb.phase_type)
|
... | ... | |
1985 |
1980 |
|
1986 |
1981 |
QMessageBox.information(self, self.tr('Information'), self.tr('Report is done'))
|
1987 |
1982 |
except Exception as ex:
|
1988 |
|
message = 'error occurred({}) in {}:{}'.format(repr(ex), sys.exc_info()[-1].tb_frame.f_code.co_filename,
|
1989 |
|
sys.exc_info()[-1].tb_lineno)
|
|
1983 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \
|
|
1984 |
f"{sys.exc_info()[-1].tb_lineno}"
|
1990 |
1985 |
self.addMessage.emit(MessageType.Error, message)
|
1991 |
1986 |
|
1992 |
1987 |
def get_work_sheet(self, work_book, count):
|