프로젝트

일반

사용자정보

개정판 2f121b7a

ID2f121b7a90e8a4a22497127dfffcfba3844c4ea8
상위 a4e3e4f7
하위 0ccdb1ac, 59a3b95b

함의성이(가) 4년 이상 전에 추가함

issue #1461: on progress

Change-Id: Ic5272b26747661975628caa9fe82acf963e4dcb6

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
2487 2487
        with app_doc_data.project.database.connect() as conn:
2488 2488
            try:
2489 2489
                cursor = conn.cursor()
2490
                sql = 'delete from HMB'
2490
                sql = 'delete from HMB_LIST'
2491
                cursor.execute(sql)
2492
                sql = 'delete from HMB_VALUE'
2493
                cursor.execute(sql)
2494
                sql = 'delete from Stream_No'
2491 2495
                cursor.execute(sql)
2492 2496

  
2497
                """stream no save"""
2498
                sql = f'insert into Stream_No(UID, Stream_No, From, To) values(?,?,?)'
2499
                params = (str(hmb.uid) if hmb.uid else str(uuid.uuid4()), hmb.stream_no, hmb.hfrom, hmb.hto)
2500
                cursor.execute(sql, params)
2501

  
2502
                first = True
2493 2503
                for hmb in hmb_list:
2494
                    sql = f"insert into HMB(UID, StreamNumber) values(?,?)"
2495
                    params = (str(hmb.uid) if hmb.uid else str(uuid.uuid4()), hmb.stream_no)
2496
                    affected = cursor.execute(sql, params)
2504
                    if first:
2505
                        """save hmb data catalog""" 
2506
                        for data in hmb.data:
2507
                            sql = f"insert into HMB_LIST(UID, Name, Unit) values(?,?,?)"
2508
                            params = (str(uuid.uuid4()), data.name, data.unit)
2509
                            cursor.execute(sql, params)
2510
                        first = False
2511

  
2512
                    """save hmb data value"""
2513
                    for data in hmb.data:
2514
                        sql = f"insert into HMB_Value(UID, HMB_LIST_UID, Stream_No_UID, Value) values(?,(select UID from HMB_LIST where Name=?),?,?)"
2515
                        params = (str(uuid.uuid4()), data.name, hmb.stream_no, data.unit)
2516
                        cursor.execute(sql, params)
2497 2517
            except Exception as ex:
2498 2518
                # Roll back any change if something goes wrong
2499 2519
                conn.rollback()
DTI_PID/DTI_PID/HMBDialog.py
130 130
    def on_open_hmb_file(self):
131 131
        """open hmb file"""
132 132
        import openpyxl
133
        from HMBTable import HMBData
133
        from HMBTable import HMBData, StreamData
134 134

  
135 135
        options = QFileDialog.Options()
136 136
        options |= QFileDialog.DontUseNativeDialog
......
149 149
            # get max column count
150 150
            max_column = sheet.max_column
151 151

  
152
            stream_lines = []
153
            for col in range(2, max_column + 1):
152
            for col in range(3, max_column + 1):
154 153
                stream_no = sheet.cell(row=1, column=col).value
155
                from_ = sheet.cell(row=2, column=col).value
156
                to_ = sheet.cell(row=3, column=col).value
154
                from_ = sheet.cell(row=2, column=col).value if sheet.cell(row=2, column=col).value else ''
155
                to_ = sheet.cell(row=3, column=col).value if sheet.cell(row=3, column=col).value else ''
157 156

  
158 157
                hmb = HMBData()
159 158
                hmb.stream_no = stream_no
160
                hmb_list.append(hmb)
159
                hmb.hfrom = from_
160
                hmb.hto = to_
161

  
162
                data = []
163
                for row in range(4, max_row + 1):
164
                    name = sheet.cell(row=row, column=1).value if sheet.cell(row=row, column=1).value else ''
165
                    unit = sheet.cell(row=row, column=2).value if sheet.cell(row=row, column=2).value else ''
166
                    value = sheet.cell(row=row, column=col).value if sheet.cell(row=row, column=col).value else ''
161 167

  
162
                stream_lines.append((stream_no, None, from_, None, to_))
168
                    data.append(StreamData(name, unit, value))
169

  
170
                hmb.data = data
171
                hmb_list.append(hmb)
163 172

  
164 173
            app_doc_data = AppDocData.instance()
165 174
            app_doc_data.save_hmb_data(hmb_list)
166 175

  
167
            AppDocData.save_stream_line_data(stream_lines)
168

  
169 176
            self.fill_hmb_data(None)
170 177

  
171 178
    def accept(self):
DTI_PID/DTI_PID/HMBTable.py
7 7

  
8 8

  
9 9
class StreamData:
10
    def __init__(self, name, value):
10
    def __init__(self, name, unit='', value=''):
11 11
        self.name = name
12
        self.unit = unit
12 13
        self.value = value
13 14

  
14 15

  
......
17 18
    def __init__(self, uid=None):
18 19
        self._uid = uid
19 20
        self._stream_no = None
21
        self._from = None
22
        self._to = None
23

  
24
        self._data = []
25

  
26
        '''
20 27
        self.StreamDescription = None
21 28
        self.DATACASE = None
22 29
        self.STREAMPHASE = None
......
93 100
        self.AQUEOUSTHERMALCONDUCTIVITY = None
94 101
        self.AQUEOUSVISCOSITY = None
95 102
        self.DataSource = None
103
        '''
96 104

  
97 105
    @property
98 106
    def data(self):
99
        """return hmb data as (key, value)"""
100
        res = []
107
        """return hmb data"""
108
        return self._data
109

  
110
    @data.setter
111
    def data(self, value):
112
        """hmb data"""
113
        self._data = value
101 114

  
102
        props = vars(self)
103
        for key, value in props.items():
104
            res.append(StreamData(key, value))
115
    @property
116
    def hfrom(self):
117
        """from"""
118
        return self._from
119

  
120
    @hfrom.setter
121
    def hfrom(self, value):
122
        """from"""
123
        self._from = value
105 124

  
106
        return res
125
    @property
126
    def hto(self):
127
        """to"""
128
        return self._to
129

  
130
    @hto.setter
131
    def hto(self, value):
132
        """to"""
133
        self._to = value
107 134

  
108 135
    @property
109 136
    def uid(self):

내보내기 Unified diff

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