프로젝트

일반

사용자정보

개정판 d1a02244

IDd1a0224414c6075e8f592d2e5b8d4ad75d0390aa
상위 2855cf16
하위 7169de6d

gaqhf 이(가) 6년 이상 전에 추가함

dev issue #627: lineNoText, Equipment, instrument 아이템 삭제 후 저장시 삭제했던 아이템 DB에서 Delete 추가 및 로직 변경

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
1662 1662
            conn.close()
1663 1663

  
1664 1664
    '''
1665
        @brief      delete data list
1666
        @author     kyouho
1667
        @date       2018.08.16
1668
    '''
1669
    def deleteDataList(self, tableName, UID):
1670
        try:
1671
            # Creates or opens a file called mydb with a SQLite3 DB
1672
            dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db')
1673
            conn = sqlite3.connect(dbPath)
1674
            # Get a cursor object
1675
            cursor = conn.cursor()
1676

  
1677
            sql = 'delete from {} where UID = {}'.format(tableName, UID)
1678
            
1679
            cursor.execute(sql)
1680

  
1681
            conn.commit()
1682

  
1683
        # Catch the exception
1684
        except Exception as ex:
1685
            # Roll back any change if something goes wrong
1686
            conn.rollback()
1687
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1688
        finally:
1689
            # Close the db connection
1690
            conn.close()
1691

  
1692

  
1693
    '''
1665 1694
        @brief      get line documentName list
1666 1695
        @author     kyouho
1667 1696
        @date       2018.08.13
......
1822 1851
            conn.close()
1823 1852

  
1824 1853
    '''
1854
        @brief      delete line data list
1855
        @author     kyouho
1856
        @date       2018.08.13
1857
    '''
1858
    def deleteLineDataList_LineNo(self, removeUID):
1859
        try:
1860
            # Creates or opens a file called mydb with a SQLite3 DB
1861
            dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db')
1862
            conn = sqlite3.connect(dbPath)
1863
            # Get a cursor object
1864
            cursor = conn.cursor()
1865
            
1866
            for uid in removeUID:
1867
                sql = "delete from LINE_DATA_LIST where LINE_NO = ?"
1868
                param = (uid,)
1869
                cursor.execute(sql, param)
1870

  
1871
            conn.commit()
1872

  
1873
        # Catch the exception
1874
        except Exception as ex:
1875
            # Roll back any change if something goes wrong
1876
            conn.rollback()
1877
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1878
        finally:
1879
            # Close the db connection
1880
            conn.close()
1881

  
1882
    '''
1825 1883
        @brief      delete equip data list
1826 1884
        @author     kyouho
1827 1885
        @date       2018.08.14
DTI_PID/DTI_PID/ItemDataExportDialog.py
7 7
import sqlite3
8 8
from AppDocData import AppDocData
9 9
from AppDocData import Config
10
from openpyxl import *
10 11
import ItemDataExport_UI
11 12

  
13

  
12 14
class QItemDataExportDialog(QDialog):
13 15
    def __init__(self, parent):
14 16
        QDialog.__init__(self, parent)
......
36 38
        
37 39
        # evnet connect
38 40
        self.ui.comboBoxDoc.currentTextChanged.connect(self.docNameChanged)
41
        self.ui.pushButtonExport.clicked.connect(self.saveExcel)
42

  
43

  
44
    '''
45
        @brief      save excel
46
        @author     kyouho
47
        @date       2018.08.16
48
    '''
49
    def saveExcel(self):
50
        try:
51
            options = QFileDialog.Options()
52
            options |= QFileDialog.DontUseNativeDialog
53
            fileName = QFileDialog.getSaveFileName(self, "Save xlsx file", os.getcwd(), "xlsx files(*.xlsx)", options=options)
54

  
55
            wb = Workbook()
56
            wb.active.title = '라인 리스트'
57
            wb.create_sheet('장치 리스트')
58
            wb.create_sheet('계장 리스트')
59
            
60
            lineTable = self.ui.tableWidgetLineDataList
61
            equipTable = self.ui.tableWidgetEquipmentDataList
62
            instTable = self.ui.tableWidgetInstrumentDataList
63

  
64
            lineSheet = wb.worksheets[0]
65
            equipSheet = wb.worksheets[1]
66
            instSheet = wb.worksheets[2]
67

  
68
            self.qtableToSheet(lineTable, lineSheet)
69
            self.qtableToSheet(equipTable, equipSheet)
70
            self.qtableToSheet(instTable, instSheet)
71

  
72
            fileName, ext = os.path.splitext(fileName[0])
73
            wb.save(fileName + ext if ext == '.xlsx' else fileName + '.xlsx')
74

  
75
        except Exception as ex:
76
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
77

  
78
    '''
79
        @brief      save excel
80
        @author     kyouho
81
        @date       2018.08.16
82
    '''
83
    def qtableToSheet(self, table, sheet):
84
        self.setSheetHeader(table, sheet)
85
        self.setSheetData(table, sheet)
86

  
87
    '''
88
        @brief      save excel
89
        @author     kyouho
90
        @date       2018.08.16
91
    '''
92
    def setSheetHeader(self, table, sheet):
93
        for index in range(table.columnCount()):
94
            if not index:
95
                continue
96
            sheet.cell(1, index, table.horizontalHeaderItem(index).text())
97
            #sheet['A' + str(index)] = table.horizontalHeaderItem(index).text()
39 98

  
40 99

  
100
    '''
101
        @brief      save excel
102
        @author     kyouho
103
        @date       2018.08.16
104
    '''
105
    def setSheetData(self, table, sheet):
106
        for rowIndex in range(table.rowCount()):
107
            for colIndex in range(table.columnCount()):
108
                if not colIndex:
109
                    continue
110
                data = table.item(rowIndex, colIndex).text() if table.item(rowIndex, colIndex) is not None else ''
111
                sheet.cell(rowIndex + 2, colIndex, data)
41 112

  
42 113
    '''
43 114
        @brief      init combobox
......
183 254
                    equipData = self.sceneEquipData[uid]
184 255

  
185 256
                    for index in range(len(equipData)):
186
                        widgetItem = QTableWidgetItem(equipData[index] if equipData[index] is not None else '')
257
                        widgetItem = QTableWidgetItem(str(equipData[index]) if equipData[index] is not None else '')
187 258
                        if widgetItem.text() != '':
188 259
                            widgetItem.setBackground(QColor(int(134), int(229), int(127)))
189 260
                        equipTable.setItem(rowCount - 1, index, widgetItem)
......
225 296
                else:
226 297
                    rowCount += 1
227 298
                    instTable.setRowCount(rowCount)
228
                    equipData = self.sceneInstData[uid]
299
                    instData = self.sceneInstData[uid]
229 300

  
230
                    for index in range(len(equipData)):
231
                        widgetItem = QTableWidgetItem(equipData[index] if equipData[index] is not None else '')
301
                    for index in range(len(instData)):
302
                        widgetItem = QTableWidgetItem(str(instData[index]) if instData[index] is not None else '')
232 303
                        if widgetItem.text() != '':
233 304
                            widgetItem.setBackground(QColor(int(134), int(229), int(127)))
234 305
                        instTable.setItem(rowCount - 1, index, widgetItem)
......
263 334
        from QEngineeringEquipmentItem import QEngineeringEquipmentItem
264 335
        items = [item for item in self.parent.graphicsView.scene.items() if type(item) is QEngineeringEquipmentItem]
265 336
        for item in items:
266
            self.sceneEquipData[item.uid] = item.getEquipmentDataList()
337
            self.sceneEquipData[str(item.uid)] = item.getEquipmentDataList()
267 338

  
268 339
        from QEngineeringInstrumentItem import QEngineeringInstrumentItem
269 340
        items = [item for item in self.parent.graphicsView.scene.items() if type(item) is QEngineeringInstrumentItem]
270 341
        for item in items:
271
            self.sceneInstData[item.uid] = item.getInstrumentDataList()
342
            self.sceneInstData[str(item.uid)] = item.getInstrumentDataList()
272 343

  
273 344

  
274 345
    ''' self.equipmentDataList
DTI_PID/DTI_PID/ItemTreeWidget.py
18 18
from EngineeringTextItem import QEngineeringTextItem
19 19
from QEngineeringNoteItem import QEngineeringNoteItem
20 20
from QEngineeringLineNoTextItem import QEngineeringLineNoTextItem
21
from QEngineeringEquipmentItem import QEngineeringEquipmentItem
22
from QEngineeringInstrumentItem import QEngineeringInstrumentItem
21 23
from QEngineeringTrimLineNoTextItem import QEngineeringTrimLineNoTextItem
22 24
from EngineeringUnknownItem import QEngineeringUnknownItem
23 25
from AppDocData import AppDocData
......
57 59
                        data = item.data(0, self.TREE_DATA_ROLE)
58 60
                        if data is not None:
59 61
                            self.imageViewer.scene.removeItem(data)
62

  
63
                            if type(data) is QEngineeringLineNoTextItem:
64
                                self.imageViewer.mainWindow.removedItems['LINE'].append(str(data.uid))
65
                            elif type(data) is QEngineeringInstrumentItem:
66
                                self.imageViewer.mainWindow.removedItems['INST'].append(str(data.uid))
67
                            elif type(data) is QEngineeringEquipmentItem:
68
                                self.imageViewer.mainWindow.removedItems['EQUIP'].append(str(data.uid))
69

  
60 70
                            item.parent().removeChild(item)
61 71
                event.accept()
62 72
            elif event.key() == Qt.Key_Up:
DTI_PID/DTI_PID/MainWindow.py
37 37
from QEngineeringSizeTextItem import QEngineeringSizeTextItem
38 38
from EngineeringUnknownItem import QEngineeringUnknownItem
39 39
from QEngineeringEquipmentItem import QEngineeringEquipmentItem
40
from QEngineeringInstrumentItem import QEngineeringInstrumentItem
40 41
from AppDocData import *
41 42
import SymbolTreeWidget, SymbolPropertyTableWidget
42 43
import SymbolEditorDialog
......
161 162
        self.actionSave.triggered.connect(self.actionSaveCliked)
162 163
        self.addMessage.connect(self.onAddMessage)
163 164

  
165
        # removedItems
166
        self.removedItems = {}
167
        self.removedItems['LINE'] = []
168
        self.removedItems['EQUIP'] = []
169
        self.removedItems['INST'] = []
170

  
164 171
    '''
165 172
        @brief      action save click event
166 173
        @author     kyouho
......
183 190
            return
184 191
        result = xg.writeXmlOnScene(docData.imgName, docData.imgWidth, docData.imgHeight, self.graphicsView.scene)
185 192
        
193
        if len(self.removedItems['LINE']):
194
            docData.deleteLineDataList_LineNo(self.removedItems['LINE'])
195
            self.removedItems['LINE'] = []
196

  
197
        if len(self.removedItems['EQUIP']):
198
            docData.deleteEquipDataList(self.removedItems['EQUIP'])
199
            self.removedItems['EQUIP'] = []
200

  
201
        if len(self.removedItems['INST']):
202
            docData.deleteInstDataList(self.removedItems['INST'])
203
            self.removedItems['INST'] = []
204

  
186 205
        if alert:
187 206
            resultStr = '[저장 결과]'
188 207

  
......
329 348
        if not self.graphicsView.hasImage():
330 349
            self.actionEquipment.setChecked(False)
331 350
            self.showImageSelectionMessageBox()
351

  
332 352
            return
333 353

  
334 354
        items = self.graphicsView.scene.items()
335 355
        for item in items:
336 356
            if type(item) is not QGraphicsPixmapItem:
337 357
                self.graphicsView.scene.removeItem(item)
358

  
359
                if type(item) is QEngineeringLineNoTextItem:
360
                    self.removedItems['LINE'].append(str(item.uid))
361
                elif type(item) is QEngineeringInstrumentItem:
362
                    self.removedItems['INST'].append(str(item.uid))
363
                elif type(item) is QEngineeringEquipmentItem:
364
                    self.removedItems['EQUIP'].append(str(item.uid))
338 365
                
339 366
        if self.path is not None:
340 367
            baseName = os.path.basename(self.path)
......
793 820
    def itemRemoved(self, item):
794 821
        try:
795 822
            self.resultTreeWidget.itemRemoved(item)
823

  
824
            if type(item) is QEngineeringLineNoTextItem:
825
                self.removedItems['LINE'].append(str(item.uid))
826
            elif type(item) is QEngineeringInstrumentItem:
827
                self.removedItems['INST'].append(str(item.uid))
828
            elif type(item) is QEngineeringEquipmentItem:
829
                self.removedItems['EQUIP'].append(str(item.uid))
830

  
796 831
            if item.scene() is not None: item.scene().removeItem(item)
797 832
        except Exception as ex:
798 833
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
......
868 903
                size = [symbol.getWidth(), symbol.getHeight()]
869 904
                name = symbol.getName()
870 905
                angle = round(math.radians(symbol.getRotatedAngle()), 2)
871
                type = symbol.getType()
906
                _type = symbol.getType()
872 907
                origin = [0,0]
873 908
                if 2 == len(symbol.getOriginalPoint().split(',')):
874 909
                    tokens = symbol.getOriginalPoint().split(',')
......
880 915
                childSymbol = symbol.getAdditionalSymbol()
881 916
                hasInstrumentLabel = symbol.getHasInstrumentLabel()
882 917

  
883
                svgFilePath = os.path.join(project.getSvgFilePath(), type, name + '.svg')
918
                svgFilePath = os.path.join(project.getSvgFilePath(), _type, name + '.svg')
884 919
                if os.path.isfile(svgFilePath):
885
                    svg = SymbolSvgItem.createItem(type, svgFilePath)
886
                    svg.buildItem(name, type, angle, pt, size, origin, connPts, parentSymbol, childSymbol, hasInstrumentLabel)
920
                    svg = SymbolSvgItem.createItem(_type, svgFilePath)
921
                    svg.buildItem(name, _type, angle, pt, size, origin, connPts, parentSymbol, childSymbol, hasInstrumentLabel)
887 922
                    svg.reCalculationRotatedItem()
888 923

  
889 924
                    # set owner - 2018.07.20 added by humkyung                   
......
895 930

  
896 931
                    svg.transfer.onRemoved.connect(self.itemRemoved)
897 932
                    self.addSvgItemToScene(svg)
933
                    
934
                    # Equipment Item 경우 저장
935
                    if type(svg) is QEngineeringEquipmentItem:
936
                        svg.saveEquipData()
937

  
938
                    # Equipment Item 경우 저장
939
                    if type(svg) is QEngineeringInstrumentItem:
940
                        svg.saveInstData()
941

  
898 942
                else:
899 943
                    item = QGraphicsBoundingBoxItem(pt[0], pt[1], size[0], size[1])
900 944
                    item.isSymbol = True
......
902 946
                    item.setPen(QPen(Qt.red, 5, Qt.SolidLine))
903 947
                    self.graphicsView.scene.addItem(item)
904 948

  
905
                # Equipment Item 경우 저장
906
                if type(item) is QEngineeringEquipmentItem:
907
                    item.saveEquipData()
949
                
908 950
            # up to here
909 951
        except Exception as ex:
910 952
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
......
1287 1329
    '''
1288 1330
    def generateOutput(self):
1289 1331
        import XmlGenerator as xg
1290
        from QEngineeringEquipmentItem import QEngineeringEquipmentItem
1291 1332

  
1292 1333
        if not self.graphicsView.hasImage():
1293 1334
            self.showImageSelectionMessageBox()
DTI_PID/DTI_PID/Shapes/QEngineeringEquipmentItem.py
12 12
from EngineeringConnectorItem import QEngineeringConnectorItem
13 13
from EngineeringTextItem import QEngineeringTextItem
14 14

  
15
equipColumnList = ['UID', 'LINE_SIZE', 'LINE_SYMBOL', 'LINE_NO', 'LINE_CLASS', 'LINE_ROUTING_FROM', 'LINE_ROUTING_TO', 'SERVICE_FLUID', 'SERVICE_DENSITY', 'SERVICE_STATE', 'OPERATION_CONDITION_TEMP', 'OPERATION_CONDITION_PRESS', 'DESIGN_CONDITION_TEMP', 'DESIGN_CONDITION_PRESS', 'TEST_CONDITION_TEMP', 'TEST_CONDITION_PRESS', 'INSUL_CODE', 'PAINT_CODE', 'NDE_CODE', 'PWHT', 'PNID_NO', 'DOCUMENT_NAME']
15
equipColumnList = ['UID', 'ITEM_NO', 'SERVICE', 'NO_REQ', 'FLUID', 'DESC_OF_PART', 'OPERATION_CONDITION_TEMP', 'OPERATION_CONDITION_PRESS', 'DESIGN_CONDITION_TEMP', 'DESIGN_CONDITION_PRESS', 'MATERIAL', 'WEIGHT', 'POWER', 'INSULATION', 'PNID_NO', 'REV']
16 16

  
17 17
class QEngineeringEquipmentItem(SymbolSvgItem):
18 18
    clicked = pyqtSignal(QGraphicsSvgItem)
......
92 92
            from AppDocData import AppDocData
93 93

  
94 94
            docData = AppDocData.instance()
95
            docData.setEquipmentDataList([self.getEquipmentDataList])
95
            docData.setEquipmentDataList([self.getEquipmentDataList()])
96 96
        except Exception as ex:
97 97
            return str(self.uid)
98 98
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
......
115 115
            for index in range(len(equipColumnList)):
116 116
                dataList.append('')
117 117

  
118
            dataList[0] = self.uid
118
            dataList[0] = str(self.uid)
119 119
            dataList[14] = docData.imgName
120 120

  
121 121
            childItems = [item for item in self.childItems() if issubclass(type(item), QEngineeringTextItem)]
......
128 128
        except Exception as ex:
129 129
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
130 130

  
131
        return dataList
131
        return dataList
DTI_PID/DTI_PID/Shapes/QEngineeringInstrumentItem.py
249 249
        except Exception as ex:
250 250
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
251 251

  
252
    '''
253
        @brief      save inst Data
254
        @author     kyouho
255
        @date       2018.08.16
256
    '''
257
    def saveInstData(self):
258
        try:
259
            from AppDocData import AppDocData
260

  
261
            docData = AppDocData.instance()
262
            docData.setInstrumentDataList([self.getInstrumentDataList()])
263
        except Exception as ex:
264
            return str(self.uid)
265
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
252 266

  
253 267
    '''
254
        @brief      return equip Data List
268
        @brief      return inst Data List
255 269
        @author     kyouho
256 270
        @date       2018.08.14
257 271
    '''
......
268 282
            for index in range(len(instColumnList)):
269 283
                dataList.append('')
270 284

  
271
            dataList[0] = self.uid
285
            dataList[0] = str(self.uid)
272 286
            dataList[13] = docData.imgName
273 287

  
274 288
            childItems = [item for item in self.childItems() if issubclass(type(item), QEngineeringTextItem)]
......
282 296
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
283 297

  
284 298
        return dataList
299

  
DTI_PID/DTI_PID/Shapes/QEngineeringLineNoTextItem.py
19 19
from AppDocData import AppDocData
20 20
from EngineeringTextItem import QEngineeringTextItem
21 21

  
22
lineColumnList = ['UID', 'LINE_SIZE', 'LINE_SYMBOL', 'LINE_NO', 'LINE_CLASS', 'LINE_ROUTING_FROM', 'LINE_ROUTING_TO', 'SERVICE_FLUID', 'SERVICE_DENSITY', 'SERVICE_STATE', 'OPERATION_CONDITION_TEMP', 'OPERATION_CONDITION_PRESS', 'DESIGN_CONDITION_TEMP', 'DESIGN_CONDITION_PRESS', 'TEST_CONDITION_TEMP', 'TEST_CONDITION_PRESS', 'INSUL_CODE', 'PAINT_CODE', 'NDE_CODE', 'PWHT', 'PNID_NO', 'DOCUMENT_NAME']
22
lineColumnList = ['UID', 'LINE_SIZE', 'LINE_SYMBOL', 'LINE_NO', 'LINE_CLASS', 'LINE_ROUTING_FROM', 'LINE_ROUTING_TO', 'SERVICE_FLUID', 'SERVICE_DENSITY', 'SERVICE_STATE', 'OPERATION_CONDITION_TEMP', 'OPERATION_CONDITION_PRESS', 'DESIGN_CONDITION_TEMP', 'DESIGN_CONDITION_PRESS', 'TEST_CONDITION_TEMP', 'TEST_CONDITION_PRESS', 'INSUL_CODE', 'PAINT_CODE', 'NDE_CODE', 'PWHT', 'PNID_NO']
23 23

  
24 24
class QEngineeringLineNoTextItem(QEngineeringTextItem):
25 25

  
......
232 232
    def saveLineData(self):
233 233
        try:
234 234
            docData = AppDocData.instance()
235
            docData.setLineDataList([self.getLineDataList])
235
            docData.setLineDataList([self.getLineDataList()])
236 236
        except Exception as ex:
237 237
            return str(self.uid)
238 238
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)