개정판 46483342
issue #1264 : Report
Change-Id: Idf3d325cdef5f1337d0ad5af01ec3604f88f5d19
HYTOS/HYTOS/AppDocData.py | ||
---|---|---|
625 | 625 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
626 | 626 |
return res |
627 | 627 |
|
628 |
def getAppDrawing(self, uid): |
|
629 |
res = [] |
|
630 |
|
|
631 |
try: |
|
632 |
# Creates or opens a file called mydb with a SQLite3 DB |
|
633 |
dbPath = self.getAppDbPath() |
|
634 |
conn = sqlite3.connect(dbPath) |
|
635 |
conn.execute('PRAGMA foreign_keys = ON') |
|
636 |
# Get a cursor object |
|
637 |
cursor = conn.cursor() |
|
638 |
|
|
639 |
sql = "select * from Drawings where uid=?" |
|
640 |
param = (uid,) |
|
641 |
|
|
642 |
cursor.execute(sql, param) |
|
643 |
rows = cursor.fetchall() |
|
644 |
for row in rows: |
|
645 |
res.append([row[0], row[1], row[2]]) |
|
646 |
# Catch the exception |
|
647 |
except Exception as ex: |
|
648 |
from App import App |
|
649 |
# Roll back any change if something goes wrong |
|
650 |
conn.rollback() |
|
651 |
|
|
652 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
653 |
sys.exc_info()[-1].tb_lineno) |
|
654 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
655 |
finally: |
|
656 |
# Close the db connection |
|
657 |
conn.close() |
|
658 |
|
|
659 |
return res |
|
660 |
|
|
628 | 661 |
def getAppConfigs(self, section, key=None): |
629 | 662 |
""" |
630 | 663 |
@brief get application configurations |
HYTOS/HYTOS/ConfigurationDialog.py | ||
---|---|---|
191 | 191 |
"""fill up with sheet information""" |
192 | 192 |
configs = app_doc_data.getAppConfigs('app', 'UserName') |
193 | 193 |
self.ui.lineEditUserName.setText(configs[0].value) |
194 |
configs = app_doc_data.getAppDrawing(drawing.UID) |
|
195 |
self.ui.lineEditDate.setText(configs[0][2]) |
|
194 | 196 |
configs = app_doc_data.getConfigs('Sheet') |
195 | 197 |
for config in configs: |
196 |
if config.key == 'Date': |
|
197 |
self.ui.lineEditDate.setText(config.value) |
|
198 |
elif config.key == 'Description': |
|
198 |
if config.key == 'Description': |
|
199 | 199 |
self.ui.lineEditDescription.setText(config.value) |
200 | 200 |
elif config.key == 'CheckedBy': |
201 | 201 |
self.ui.lineEditCheckedBy.setText(config.value) |
HYTOS/HYTOS/Configuration_UI.py | ||
---|---|---|
75 | 75 |
font.setBold(False) |
76 | 76 |
font.setWeight(50) |
77 | 77 |
self.lineEditDate.setFont(font) |
78 |
self.lineEditDate.setReadOnly(True) |
|
78 | 79 |
self.lineEditDate.setObjectName("lineEditDate") |
79 | 80 |
self.gridLayout_16.addWidget(self.lineEditDate, 1, 1, 1, 1) |
80 | 81 |
self.label_2 = QtWidgets.QLabel(self.groupBox_2) |
... | ... | |
387 | 388 |
self.horizontalLayout_16 = QtWidgets.QHBoxLayout() |
388 | 389 |
self.horizontalLayout_16.setObjectName("horizontalLayout_16") |
389 | 390 |
self.label_16 = QtWidgets.QLabel(self.groupBoxText_2) |
390 |
self.label_16.setMinimumSize(QtCore.QSize(160, 0))
|
|
391 |
self.label_16.setMaximumSize(QtCore.QSize(160, 16777215))
|
|
391 |
self.label_16.setMinimumSize(QtCore.QSize(180, 0))
|
|
392 |
self.label_16.setMaximumSize(QtCore.QSize(180, 16777215))
|
|
392 | 393 |
font = QtGui.QFont() |
393 | 394 |
font.setBold(False) |
394 | 395 |
font.setWeight(50) |
... | ... | |
1156 | 1157 |
_translate = QtCore.QCoreApplication.translate |
1157 | 1158 |
ConfigurationDialog.setWindowTitle(_translate("ConfigurationDialog", "Configuration")) |
1158 | 1159 |
self.groupBox_2.setTitle(_translate("ConfigurationDialog", "Sheet Information")) |
1159 |
self.label_3.setText(_translate("ConfigurationDialog", "Date :")) |
|
1160 |
self.label_3.setText(_translate("ConfigurationDialog", "Create Date :"))
|
|
1160 | 1161 |
self.label_2.setText(_translate("ConfigurationDialog", "Description :")) |
1161 | 1162 |
self.label.setText(_translate("ConfigurationDialog", "Checked By :")) |
1162 | 1163 |
self.label_8.setText(_translate("ConfigurationDialog", "Approved By :")) |
HYTOS/HYTOS/MainWindow.py | ||
---|---|---|
123 | 123 |
self.tabifyDockWidget(self.dockWidgetDrawingExplorer, self.dockWidgetSymbolExplorer) |
124 | 124 |
self.dockWidgetDrawingExplorer.raise_() |
125 | 125 |
|
126 |
# ToDo.. |
|
127 |
# Menu bar - Admin Hide |
|
128 |
# Loop Tab Hide |
|
126 | 129 |
except Exception as ex: |
127 | 130 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
128 | 131 |
sys.exc_info()[-1].tb_lineno) |
... | ... | |
831 | 834 |
""" generate loop """ |
832 | 835 |
cmd = HydroCalculationCommand(self.graphicsView) |
833 | 836 |
cmd.execute(None) |
837 |
cmd.execute_second(None) |
|
834 | 838 |
self.display_loops(cmd.loops) |
835 | 839 |
self.display_output() |
836 | 840 |
|
... | ... | |
851 | 855 |
import openpyxl |
852 | 856 |
from openpyxl.styles import Font |
853 | 857 |
from datetime import datetime |
858 |
from EngineeringStreamlineItem import QEngineeringStreamlineItem |
|
854 | 859 |
|
855 | 860 |
try: |
856 | 861 |
image_path = None |
... | ... | |
858 | 863 |
image_path = f.name + '.png' |
859 | 864 |
|
860 | 865 |
if image_path: |
866 |
app_doc_data = AppDocData.instance() |
|
867 |
|
|
861 | 868 |
self.graphicsView.save_as_image(image_path) |
862 | 869 |
|
863 | 870 |
workspace = self.getWorkSpace() |
864 |
|
|
871 |
file_name = os.path.join(workspace, app_doc_data.activeDrawing.name + '.xlsx') |
|
865 | 872 |
options = QFileDialog.Options() |
866 | 873 |
options |= QFileDialog.DontUseNativeDialog |
867 |
name, _ = QFileDialog.getSaveFileName(self, self.tr('Report'), workspace, 'Excel(*.xlsx)',
|
|
874 |
name, _ = QFileDialog.getSaveFileName(self, self.tr('Report'), file_name, 'Excel(*.xlsx)',
|
|
868 | 875 |
options=options) |
869 | 876 |
|
870 | 877 |
template = os.path.join(os.getenv('ALLUSERSPROFILE'), App.NAME, 'Report_Template.xlsx') |
871 | 878 |
if name and os.path.exists(template): |
872 | 879 |
wb = openpyxl.load_workbook(template) |
873 |
ws = wb.active |
|
880 |
ws = wb.get_sheet_by_name('Page') |
|
881 |
|
|
874 | 882 |
cal_image = openpyxl.drawing.image.Image(image_path) |
875 | 883 |
x_scale, y_scale = 1, 1 |
876 | 884 |
cal_image.width *= x_scale |
... | ... | |
878 | 886 |
ws.add_image(cal_image, 'C4') |
879 | 887 |
|
880 | 888 |
"""write sheet information""" |
881 |
app_doc_data = AppDocData.instance() |
|
882 | 889 |
configs = app_doc_data.getConfigs('Sheet') |
883 | 890 |
for config in configs: |
884 | 891 |
if config.key == 'JobNo' and config.value: |
... | ... | |
1069 | 1076 |
col_no = 24 if col_no == 27 else 28 |
1070 | 1077 |
ws.cell(row_no, col_no, 'dP Ratio :') |
1071 | 1078 |
col_no += 2 |
1072 |
ws.cell(row_no, col_no, round(attr['dP Ratio'], 3))
|
|
1079 |
ws.cell(row_no, col_no, round(attr['dP Ratio'] * 100, 2))
|
|
1073 | 1080 |
col_no += 1 |
1074 | 1081 |
ws.cell(row_no, col_no, '%') |
1075 | 1082 |
|
... | ... | |
1098 | 1105 |
ws['B73'] = units['Velocity'] |
1099 | 1106 |
ws['B74'] = '' # Hidden |
1100 | 1107 |
ws['B75'] = '' # Hidden |
1101 |
ws['B76'] = '{}/100{})'.format(units['Pressure'], units['Length'])
|
|
1108 |
ws['B76'] = '{}/100{}'.format(units['Pressure'], units['Length']) |
|
1102 | 1109 |
ws['B77'] = units['Pressure'] |
1103 | 1110 |
ws['B78'] = units['Pressure'] |
1104 | 1111 |
ws['B79'] = '{}(g)'.format(units['Pressure']) |
1105 | 1112 |
|
1113 |
has_mixed_type = False |
|
1106 | 1114 |
# write hmb data |
1107 | 1115 |
drawing = app_doc_data.activeDrawing |
1108 | 1116 |
hmbs = drawing.hmbTable._hmbs |
1109 | 1117 |
if hmbs is not None: |
1110 | 1118 |
col_no = 3 |
1111 | 1119 |
for hmb in hmbs: |
1120 |
if hmb.phase_type == 'Mixed': |
|
1121 |
has_mixed_type = True |
|
1122 |
|
|
1112 | 1123 |
row_no = 54 |
1113 | 1124 |
ws.cell(row_no, col_no, hmb.phase_type) |
1114 | 1125 |
row_no += 1 |
... | ... | |
1162 | 1173 |
|
1163 | 1174 |
col_no += 1 |
1164 | 1175 |
|
1176 |
# two_phase |
|
1177 |
ws = wb.get_sheet_by_name('Two_phase') |
|
1178 |
if has_mixed_type: |
|
1179 |
pass |
|
1180 |
else: |
|
1181 |
ws.sheet_state = 'hidden' |
|
1182 |
|
|
1165 | 1183 |
name_without_ext, ext = os.path.splitext(name) |
1166 | 1184 |
save_file_name = name if ext.upper() == '.XLSX' else name + '.xlsx' |
1167 | 1185 |
wb.save(filename=save_file_name) |
... | ... | |
1257 | 1275 |
self.add_data('Outlet P :', round(attr['Disc.P'], 3), |
1258 | 1276 |
'{}.g'.format(units['Pressure'])) |
1259 | 1277 |
self.add_data('Diff.P :', round(attr['Diff.P'], 3), units['Pressure']) |
1260 |
self.add_data('dP Ratio :', round(attr['dP Ratio'], 3), '%')
|
|
1278 |
self.add_data('dP Ratio :', round(attr['dP Ratio'] * 100, 2), '%')
|
|
1261 | 1279 |
|
1262 | 1280 |
except Exception as ex: |
1263 | 1281 |
message = 'error occurred({}) in {}:{}'.format(repr(ex), sys.exc_info()[-1].tb_frame.f_code.co_filename, |
... | ... | |
1293 | 1311 |
# display calcuation values |
1294 | 1312 |
for row in range(len(loops[col].items)): |
1295 | 1313 |
if loops[col].items[row] in loops[col].pressures: |
1296 |
item = QTableWidgetItem(str(loops[col].pressures[loops[col].items[row]]))
|
|
1314 |
item = QTableWidgetItem(str(round(loops[col].pressures[loops[col].items[row]], 8)))
|
|
1297 | 1315 |
item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) |
1298 |
if not loops[col].pressures[loops[col].items[row]]: item.setBackground(Qt.red) |
|
1316 |
# if not loops[col].pressures[loops[col].items[row]]: item.setBackground(Qt.red)
|
|
1299 | 1317 |
self.tableWidgetLoop.setItem(row, col * 4 + 1, item) |
1300 | 1318 |
|
1301 | 1319 |
if loops[col].items[row] in loops[col].pressure_drops: |
1302 |
item = QTableWidgetItem(str(loops[col].pressure_drops[loops[col].items[row]]))
|
|
1320 |
item = QTableWidgetItem(str(round(loops[col].pressure_drops[loops[col].items[row]], 9)))
|
|
1303 | 1321 |
item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) |
1304 |
if not loops[col].pressure_drops[loops[col].items[row]]: item.setBackground(Qt.red) |
|
1322 |
# if not loops[col].pressure_drops[loops[col].items[row]]: item.setBackground(Qt.red)
|
|
1305 | 1323 |
self.tableWidgetLoop.setItem(row, col * 4 + 2, item) |
1306 | 1324 |
|
1307 | 1325 |
if loops[col].items[row] in loops[col].density_elevations: |
1308 |
item = QTableWidgetItem(str(loops[col].density_elevations[loops[col].items[row]]))
|
|
1326 |
item = QTableWidgetItem(str(round(loops[col].density_elevations[loops[col].items[row]], 8)))
|
|
1309 | 1327 |
item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) |
1310 |
if not loops[col].density_elevations[loops[col].items[row]]: item.setBackground(Qt.red) |
|
1328 |
# if not loops[col].density_elevations[loops[col].items[row]]: item.setBackground(Qt.red)
|
|
1311 | 1329 |
self.tableWidgetLoop.setItem(row, col * 4 + 3, item) |
1312 | 1330 |
|
1313 | 1331 |
self.tableWidgetLoop.resizeColumnsToContents() |
HYTOS/HYTOS/UI/Configuration.ui | ||
---|---|---|
94 | 94 |
</font> |
95 | 95 |
</property> |
96 | 96 |
<property name="text"> |
97 |
<string>Date :</string> |
|
97 |
<string>Create Date :</string>
|
|
98 | 98 |
</property> |
99 | 99 |
<property name="alignment"> |
100 | 100 |
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
... | ... | |
110 | 110 |
<bold>false</bold> |
111 | 111 |
</font> |
112 | 112 |
</property> |
113 |
<property name="readOnly"> |
|
114 |
<bool>true</bool> |
|
115 |
</property> |
|
113 | 116 |
</widget> |
114 | 117 |
</item> |
115 | 118 |
<item row="2" column="0"> |
... | ... | |
729 | 732 |
<widget class="QLabel" name="label_16"> |
730 | 733 |
<property name="minimumSize"> |
731 | 734 |
<size> |
732 |
<width>160</width>
|
|
735 |
<width>180</width>
|
|
733 | 736 |
<height>0</height> |
734 | 737 |
</size> |
735 | 738 |
</property> |
736 | 739 |
<property name="maximumSize"> |
737 | 740 |
<size> |
738 |
<width>160</width>
|
|
741 |
<width>180</width>
|
|
739 | 742 |
<height>16777215</height> |
740 | 743 |
</size> |
741 | 744 |
</property> |
내보내기 Unified diff