프로젝트

일반

사용자정보

개정판 0b42b2be

ID0b42b2beedfef3b7f848de3138e7b79f1169f30e
상위 32b3604d
하위 c2b87ac7, 1049c8e1

백흠경이(가) 약 5년 전에 추가함

issue #627: Components 테이블에서 리스트를 가져오도록 수정

Change-Id: I0573a08be38dd6c37f18b989633978eb6831aa83

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
2094 2094
                if hasattr(self, '_equipment_attributes'):
2095 2095
                    del self._equipment_attributes
2096 2096

  
2097
                if hasattr(self, '_valve_attributes'):
2098
                    del self._valve_attributes
2099

  
2100
                if hasattr(self, '_inst_attributes'):
2101
                    del self._inst_attributes
2102

  
2103
                if hasattr(self, '_note_attributes'):
2104
                    del self._note_attributes
2097 2105
            # Catch the exception
2098 2106
            except Exception as ex:
2099 2107
                # Roll back any change if something goes wrong
......
2319 2327
        """ get connectors of given component """
2320 2328
        if self._connecterss and component in self._connecterss:
2321 2329
            return self._connecterss[component]
2322
        elif self._connecterss:
2323
            return []
2324 2330

  
2325 2331
        conn = self.project.database.connect()
2326 2332
        with conn:
......
2328 2334
                # Get a cursor object
2329 2335
                cursor = conn.cursor() if self.project.database.db_type == 'SQLite' else conn.cursor(as_dict=True)
2330 2336

  
2331
                # sql = "select * from Points where Components_UID='{}' order by [Index]".format(component)
2332
                sql = "select a.* from Points a \
2333
                            join Components b on a.Components_UID=b.[UID] where Drawings_UID='{}' order by Components_UID, [Index]".format(
2334
                    self.activeDrawing.UID)
2337
                sql = f"select a.* from Points a join Components b on a.Components_UID=b.[UID] where Drawings_UID=" \
2338
                      f"'{self.activeDrawing.UID}' order by Components_UID, [Index]"
2335 2339
                cursor.execute(sql)
2336 2340

  
2337 2341
                pre = ''
......
2658 2662
                print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
2659 2663
                                                          sys.exc_info()[-1].tb_lineno))
2660 2664

  
2661
    def getDocumentNameList(self):
2662
        '''
2663
            @brief      get documentName list
2664
            @author     euisung
2665
            @date       2018.12.11
2666
        '''
2665
    def get_document_name_list(self):
2666
        """ get document name list """
2667 2667
        result = []
2668 2668

  
2669 2669
        conn = self.project.database.connect()
......
2672 2672
                # Get a cursor object
2673 2673
                cursor = conn.cursor()
2674 2674

  
2675
                sql = 'select DISTINCT(PNID_NO) from LINE_DATA_LIST'
2676
                cursor.execute(sql)
2677
                sql = 'select DISTINCT(PNID_NO) from EQUIPMENT_DATA_LIST'
2678
                cursor.execute(sql)
2679
                sql = 'select DISTINCT(PNID_NO) from INSTRUMENT_DATA_LIST'
2680
                cursor.execute(sql)
2681
                sql = 'select DISTINCT(PNID_NO) from NOTE_DATA_LIST'
2682
                cursor.execute(sql)
2683
                sql = 'select DISTINCT(PNID_NO) from VALVE_DATA_LIST'
2675
                sql = "select distinct B.Name as 'Drawing_Name' from Components A join Drawings B on A.Drawings_UID=B.UID"
2684 2676
                cursor.execute(sql)
2685 2677

  
2686 2678
                rows = cursor.fetchall()
2687 2679
                for row in rows:
2688 2680
                    result.append(row[0])
2689 2681

  
2690
                result = list(set(result))
2691 2682
                result.sort()
2692 2683
            # Catch the exception
2693 2684
            except Exception as ex:
......
2725 2716
        return result
2726 2717

  
2727 2718
    '''
2728
        @brief      get line documentName list
2729
        @author     kyouho
2730
        @date       2018.08.14
2731
    '''
2732

  
2733
    def getEquipDocumentNameList(self):
2734
        result = []
2735

  
2736
        conn = self.project.database.connect()
2737
        with conn:
2738
            try:
2739
                # Get a cursor object
2740
                cursor = conn.cursor()
2741

  
2742
                sql = 'select DISTINCT(PNID_NO) from EQUIPMENT_DATA_LIST'
2743

  
2744
                cursor.execute(sql)
2745
                rows = cursor.fetchall()
2746
                for row in rows:
2747
                    result.append(row[0])
2748
            # Catch the exception
2749
            except Exception as ex:
2750
                print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
2751
                                                          sys.exc_info()[-1].tb_lineno))
2752

  
2753
        return result
2754

  
2755
    '''
2756 2719
        @brief      get line data list
2757 2720
        @author     kyouho
2758 2721
        @date       2018.08.13
......
2806 2769
                sql = "select A.UID,B.NAME,C.SymbolType_UID,D.Type from Components A join Drawings B on A.Drawings_UID=B.UID\
2807 2770
                        join Symbol C on A.Symbol_UID=C.UID\
2808 2771
                        join SymbolType D on C.SymbolType_UID=D.UID\
2809
                        where D.Category='Equipment'"
2772
                        where D.Category in ('Equipment','Equipment Components')"
2810 2773

  
2811 2774
                if drawing is not None:
2812
                    sql += f" where A.Drawings_UID=(select UID from Drawings where Name='{drawing}')"
2775
                    sql += f" and A.Drawings_UID=(select UID from Drawings where Name='{drawing}')"
2813 2776

  
2814 2777
                cursor.execute(sql)
2815 2778
                comps = [(row[0], row[1], row[2], row[3]) for row in cursor.fetchall()]
......
2992 2955
                print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
2993 2956
                                                          sys.exc_info()[-1].tb_lineno))
2994 2957

  
2995
    '''
2996
        @brief      get equipment data list
2997
        @author     humkyung
2998
        @date       2018.05.03
2999
    '''
2958
    def get_valve_attributes(self):
2959
        """ return valve attributes """
3000 2960

  
3001
    def getEquipmentDataList(self, docName=None):
3002
        result = []
3003
        conn = self.project.database.connect()
3004
        with conn:
3005
            try:
3006
                # Get a cursor object
3007
                cursor = conn.cursor()
2961
        from SymbolAttr import SymbolAttr
3008 2962

  
3009
                sql = 'select a.*,C.Attribute,B.Value  from EQUIPMENT_DATA_LIST a left join Attributes B on a.UID=B.Components_UID ' \
3010
                      'left join SymbolAttribute C on B.SymbolAttribute_UID=C.UID'
3011
                if docName is not None:
3012
                    sql += " where PNID_NO = '{}'".format(docName)
2963
        res = None
2964
        if not hasattr(self, '_valve_attributes'):
2965
            self._valve_attributes = []
3013 2966

  
3014
                cursor.execute(sql)
3015
                col_names = [desc[0] for desc in cursor.description]  # get coloumn name
3016
                rows = cursor.fetchall()
3017
                for row in rows:
3018
                    matches = [res for res in result if res['UID'] == row[0]]
3019
                    if matches:
3020
                        matches[0][row[len(row) - 2]] = row[len(row) - 1]
3021
                    else:
3022
                        data = dict(zip(col_names[:-2], row[:-2]))
3023
                        if row[len(row) - 2] is not None:
3024
                            data[row[len(row) - 2]] = row[len(row) - 1]
3025
                        result.append(data)
3026
            # Catch the exception
3027
            except Exception as ex:
3028
                from App import App
3029
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
3030
                                                              sys.exc_info()[-1].tb_lineno)
3031
                App.mainWnd().addMessage.emit(MessageType.Error, message)
2967
            conn = self.project.database.connect()
2968
            with conn:
2969
                try:
2970
                    # Get a cursor object
2971
                    cursor = conn.cursor()
3032 2972

  
3033
        return result
2973
                    sql = "select distinct A.Attribute from SymbolAttribute A join SymbolType B on A.SymbolType_UID=B.UID " \
2974
                          "where B.Category = 'Piping'"
2975
                    cursor.execute(sql)
2976
                    rows = cursor.fetchall()
2977
                    for row in rows:
2978
                        attr = SymbolAttr()
2979
                        attr.Attribute = row[0]
2980
                        self._valve_attributes.append(attr)
2981

  
2982
                    res = self._valve_attributes
2983
                # Catch the exception
2984
                except Exception as ex:
2985
                    print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
2986
                                                               sys.exc_info()[-1].tb_lineno))
2987
        else:
2988
            res = self._valve_attributes
3034 2989

  
3035
    def get_valve_data_list(self, docName=None):
2990
        return res
2991

  
2992
    def get_valve_data_list(self, drawing=None):
3036 2993
        """
3037 2994
        @brief      get valve data list
3038 2995
        @author     humkyung
......
3044 3001
        with conn:
3045 3002
            try:
3046 3003
                # Get a cursor object
3047
                cursor = conn.cursor()
3004
                cursor = conn.cursor() if self.project.database.db_type == 'SQLite' else conn.cursor(as_dict=True)
3048 3005

  
3049
                sql = 'select a.UID,a.ITEM_NO,a.PNID_NO,a.MainSize,a.SubSize,c.Attribute,b.Value from VALVE_DATA_LIST a left join Attributes b on a.uid=b.Components_UID ' \
3050
                      'left join SymbolAttribute c on b.SymbolAttribute_UID=c.UID'
3051
                if docName is not None:
3052
                    sql += " where PNID_NO = '{}'".format(docName)
3006
                sql = "select a.UID,D.Name,E.Name as 'Drawing Name',C.Attribute,B.Value from Components a " \
3007
                      "join Attributes B on a.UID=B.Components_UID " \
3008
                      "join SymbolAttribute C on B.SymbolAttribute_UID=C.UID " \
3009
                      "join Symbol D on a.Symbol_UID=D.UID " \
3010
                      "join Drawings E on a.Drawings_UID=E.UID " \
3011
                      "where a.Symbol_UID in (select UID from Symbol where SymbolType_UID in " \
3012
                      "(select UID from SymbolType where Category in ('Piping')))"
3013
                if drawing is not None:
3014
                    sql += f" and A.Drawings_UID=(select UID from Drawings where Name='{drawing}')"
3053 3015

  
3054 3016
                cursor.execute(sql)
3055 3017
                rows = cursor.fetchall()
3056 3018
                for row in rows:
3057
                    matches = [res for res in result if res['UID'] == row[0]]
3019
                    matches = [res for res in result if res['UID'] == row['UID']]
3058 3020
                    if matches:
3059
                        matches[0][row[5]] = row[6]
3021
                        matches[0][row['Attribute']] = row['Value']
3060 3022
                    else:
3061
                        data = {'UID': row[0], 'ITEM_NO': row[1], 'PNID_NO': row[2], 'MainSize': row[3],
3062
                                'SubSize': row[4]}
3063
                        data[row[5]] = row[6]
3023
                        data = {'UID': row['UID'], 'ITEM_NO': row['Name'], 'Drawing Name': row['Drawing Name'],
3024
                                row['Attribute']: row['Value']}
3064 3025
                        result.append(data)
3065 3026

  
3066 3027
            # Catch the exception
......
3072 3033

  
3073 3034
        return result
3074 3035

  
3036
    def get_instrument_attributes(self):
3037
        """ return valve attributes """
3038

  
3039
        from SymbolAttr import SymbolAttr
3040

  
3041
        res = None
3042
        if not hasattr(self, '_inst_attributes'):
3043
            self._inst_attributes = []
3044

  
3045
            conn = self.project.database.connect()
3046
            with conn:
3047
                try:
3048
                    # Get a cursor object
3049
                    cursor = conn.cursor()
3050

  
3051
                    sql = "select distinct A.Attribute from SymbolAttribute A join SymbolType B on A.SymbolType_UID=B.UID " \
3052
                          "where B.Category = 'Instrumentation'"
3053
                    cursor.execute(sql)
3054
                    rows = cursor.fetchall()
3055
                    for row in rows:
3056
                        attr = SymbolAttr()
3057
                        attr.Attribute = row[0]
3058
                        self._inst_attributes.append(attr)
3059

  
3060
                    res = self._inst_attributes
3061
                # Catch the exception
3062
                except Exception as ex:
3063
                    print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
3064
                                                               sys.exc_info()[-1].tb_lineno))
3065
        else:
3066
            res = self._inst_attributes
3067

  
3068
        return res
3069

  
3075 3070
    '''
3076 3071
        @brief      get instrument data list
3077 3072
        @author     kyouho
3078 3073
        @date       2018.08.14
3079 3074
    '''
3080 3075

  
3081
    def getInstrumentDataList(self, docName=None):
3076
    def get_instrument_data_list(self, drawing=None):
3082 3077
        result = []
3083 3078
        conn = self.project.database.connect()
3084 3079
        with conn:
3085 3080
            try:
3086 3081
                # Get a cursor object
3087
                cursor = conn.cursor()
3082
                cursor = conn.cursor() if self.project.database.db_type == 'SQLite' else conn.cursor(as_dict=True)
3088 3083

  
3089
                # sql = 'select UID, ITEM_NO, SERVICE, FLOW_RATE, PRESSURE, TEMPERATURE, TYPE, RANGE, NOR_LEVEL_MM, NOR_LEVEL_PERCENT, DEL_PRESS, SHUT_OFF, LOCATION, PNID_NO, REV from INSTRUMENT_DATA_LIST'
3090
                sql = 'select * from INSTRUMENT_DATA_LIST'
3091
                if docName is not None:
3092
                    sql += " where PNID_NO = '{}'".format(docName)
3084
                sql = "select a.UID,D.Name,E.Name as 'Drawing Name',C.Attribute,B.Value from Components a " \
3085
                      "join Attributes B on a.UID=B.Components_UID " \
3086
                      "join SymbolAttribute C on B.SymbolAttribute_UID=C.UID " \
3087
                      "join Symbol D on a.Symbol_UID=D.UID " \
3088
                      "join Drawings E on a.Drawings_UID=E.UID " \
3089
                      "where a.Symbol_UID in (select UID from Symbol where SymbolType_UID in " \
3090
                      "(select UID from SymbolType where Category in ('Instrumentation')))"
3091
                if drawing is not None:
3092
                    sql += f" and A.Drawings_UID=(select UID from Drawings where Name='{drawing}')"
3093 3093

  
3094 3094
                cursor.execute(sql)
3095 3095
                rows = cursor.fetchall()
3096 3096
                for row in rows:
3097
                    data = []
3098
                    for index in range(len(cursor.description)):
3099
                        data.append(row[index])
3100
                    result.append(data)
3097
                    matches = [res for res in result if res['UID'] == row['UID']]
3098
                    if matches:
3099
                        matches[0][row['Attribute']] = row['Value']
3100
                    else:
3101
                        data = {'UID': row['UID'], 'ITEM_NO': row['Name'], 'Drawing Name': row['Drawing Name'],
3102
                                row['Attribute']: row['Value']}
3103
                        result.append(data)
3101 3104
            # Catch the exception
3102 3105
            except Exception as ex:
3103 3106
                from App import App
......
3107 3110

  
3108 3111
        return result
3109 3112

  
3110
    '''
3111
        @brief      get Note data list
3112
        @author     kyouho
3113
        @date       2018.10.10
3114
    '''
3113
    def get_note_attributes(self):
3114
        """ return note attributes """
3115 3115

  
3116
    def getNoteDataList(self, docName=None):
3116
        from SymbolAttr import SymbolAttr
3117

  
3118
        res = None
3119
        if not hasattr(self, '_note_attributes'):
3120
            self._note_attributes = []
3121

  
3122
            conn = self.project.database.connect()
3123
            with conn:
3124
                try:
3125
                    # Get a cursor object
3126
                    cursor = conn.cursor()
3127

  
3128
                    sql = "select distinct A.Attribute from SymbolAttribute A join SymbolType B on A.SymbolType_UID=B.UID " \
3129
                          "where B.Category='General' and B.Type='Notes'"
3130
                    cursor.execute(sql)
3131
                    rows = cursor.fetchall()
3132
                    for row in rows:
3133
                        attr = SymbolAttr()
3134
                        attr.Attribute = row[0]
3135
                        self._note_attributes.append(attr)
3136

  
3137
                    res = self._note_attributes
3138
                # Catch the exception
3139
                except Exception as ex:
3140
                    print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
3141
                                                               sys.exc_info()[-1].tb_lineno))
3142
        else:
3143
            res = self._note_attributes
3144

  
3145
        return res
3146

  
3147
    def get_note_data_list(self, drawing=None):
3148
        """ get note data list """
3117 3149
        result = []
3118 3150

  
3119 3151
        conn = self.project.database.connect()
3120 3152
        with conn:
3121 3153
            try:
3122 3154
                # Get a cursor object
3123
                cursor = conn.cursor()
3155
                cursor = conn.cursor() if self.project.database.db_type == 'SQLite' else conn.cursor(as_dict=True)
3124 3156

  
3125
                sql = 'select UID, NOTE_NO, DESCRIPTION, PNID_NO from NOTE_DATA_LIST'
3126
                if docName is not None:
3127
                    sql += " where PNID_NO = '{}'".format(docName)
3157
                sql = "select a.UID,D.Name,E.Name as 'Drawing Name',C.Attribute,B.Value from Components a " \
3158
                      "join Attributes B on a.UID=B.Components_UID " \
3159
                      "join SymbolAttribute C on B.SymbolAttribute_UID=C.UID " \
3160
                      "join Symbol D on a.Symbol_UID=D.UID " \
3161
                      "join Drawings E on a.Drawings_UID=E.UID " \
3162
                      "where a.Symbol_UID in (select UID from Symbol where SymbolType_UID in " \
3163
                      "(select UID from SymbolType where Category='General' and Type='Notes'))"
3164
                if drawing is not None:
3165
                    sql += f" and A.Drawings_UID=(select UID from Drawings where Name='{drawing}')"
3128 3166

  
3129
                sql += ' ORDER BY NOTE_NO ASC'
3130 3167
                cursor.execute(sql)
3131 3168
                rows = cursor.fetchall()
3132 3169
                for row in rows:
3133
                    data = []
3134
                    for index in range(len(cursor.description)):
3135
                        data.append(row[index])
3136
                    result.append(data)
3170
                    matches = [res for res in result if res['UID'] == row['UID']]
3171
                    if matches:
3172
                        matches[0][row['Attribute']] = row['Value']
3173
                    else:
3174
                        data = {'UID': row['UID'], 'ITEM_NO': row['Name'], 'Drawing Name': row['Drawing Name'],
3175
                                row['Attribute']: row['Value']}
3176
                        result.append(data)
3137 3177
            # Catch the exception
3138 3178
            except Exception as ex:
3139 3179
                from App import App
......
3157 3197

  
3158 3198
                sql = "delete from LINE_DATA_LIST where PNID_NO = '{}'".format(drawing_name)
3159 3199
                cursor.execute(sql)
3160
                sql = "delete from EQUIPMENT_DATA_LIST where PNID_NO = '{}'".format(drawing_name)
3161
                cursor.execute(sql)
3162
                sql = "delete from VALVE_DATA_LIST where PNID_NO = '{}'".format(drawing_name)
3163
                cursor.execute(sql)
3164
                sql = "delete from INSTRUMENT_DATA_LIST where PNID_NO = '{}'".format(drawing_name)
3165
                cursor.execute(sql)
3166
                sql = "delete from NOTE_DATA_LIST where PNID_NO = '{}'".format(drawing_name)
3167
                cursor.execute(sql)
3168 3200
                sql = "delete from TitleBlockValues where Drawings_UID = '{}'".format(drawing_name)
3169 3201
                cursor.execute(sql)
3170 3202

  
......
3294 3326
                                                              sys.exc_info()[-1].tb_lineno)
3295 3327
                App.mainWnd().addMessage.emit(MessageType.Error, message)
3296 3328

  
3297
    '''
3298
        @brief      set Note data list
3299
        @author     kyoyho
3300
        @date       2018.10.10
3301
    '''
3302

  
3303
    def setNoteDataList(self, dataList):
3304
        conn = self.project.database.connect()
3305
        with conn:
3306
            try:
3307
                # Get a cursor object
3308
                cursor = conn.cursor()
3309

  
3310
                for data in dataList:
3311
                    sql = self.project.database.to_sql(
3312
                        "insert into NOTE_DATA_LIST(UID, NOTE_NO, DESCRIPTION, PNID_NO) values(?, ?, ?, ?)")
3313
                    param = tuple(data)
3314
                    cursor.execute(sql, param)
3315
                conn.commit()
3316
            # Catch the exception
3317
            except Exception as ex:
3318
                # Roll back any change if something goes wrong
3319
                conn.rollback()
3320

  
3321
                from App import App
3322
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
3323
                                                              sys.exc_info()[-1].tb_lineno)
3324
                App.mainWnd().addMessage.emit(MessageType.Error, message)
3325

  
3326 3329
    def getDrawings(self):
3327 3330
        """ get drawings """
3328 3331
        from Drawing import Drawing
......
3552 3555

  
3553 3556
        return res
3554 3557

  
3555
    def add_column_into_table(self, table, columnName):
3556
        '''
3557
            @brief  add column into table
3558
            @author euisung
3559
            @date   2019.03.13
3560
        '''
3561
        err = False
3562
        conn = self.project.database.connect()
3563
        with conn:
3564
            try:
3565
                # Get a cursor object
3566
                cursor = conn.cursor()
3567
                sql = "alter table {} add {}".format(table, columnName)
3568
                cursor.execute(sql)
3569

  
3570
                conn.commit()
3571

  
3572
            # Catch the exception
3573
            except Exception as ex:
3574
                # Roll back any change if something goes wrong
3575
                conn.rollback()
3576
                err = True
3577
                print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
3578
                                                          sys.exc_info()[-1].tb_lineno))
3579
            finally:
3580
                return (True if not err else False)
3581

  
3582
    def edit_column_Name_in_table(self, table, columnName, newColName):
3583
        '''
3584
            @brief  edit column into table
3585
            @author euisung
3586
            @date   2019.03.13
3587
        '''
3588
        err = False
3589
        colNames = AppDocData.instance().getColNames(table)
3590

  
3591
        for index in range(len(colNames)):
3592
            if colNames[index] == columnName:
3593
                colNames[index] = newColName
3594
                break
3595

  
3596
        conn = self.project.database.connect()
3597
        with conn:
3598
            try:
3599
                # Get a cursor object
3600
                cursor = conn.cursor()
3601
                sql = "ALTER TABLE {} RENAME TO {}".format(table, table + '_orig')
3602
                cursor.execute(sql)
3603
                value = []
3604
                for colName in colNames:
3605
                    value.append(colName + ' TEXT')
3606
                sql = "CREATE TABLE {}({}, CONSTRAINT '{}_PK' PRIMARY KEY('UID'))".format(table, ','.join(value), table)
3607
                cursor.execute(sql)
3608
                sql = "INSERT INTO {} SELECT * FROM {}".format(table, table + '_orig')
3609
                cursor.execute(sql)
3610
                sql = "DROP TABLE {}".format(table + '_orig')
3611
                cursor.execute(sql)
3612

  
3613
                conn.commit()
3614

  
3615
            # Catch the exception
3616
            except Exception as ex:
3617
                # Roll back any change if something goes wrong
3618
                conn.rollback()
3619
                err = True
3620
                print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
3621
                                                          sys.exc_info()[-1].tb_lineno))
3622
            finally:
3623
                return (True if not err else False)
3624

  
3625 3558
    '''
3626 3559
        @brief  getter of OCRData
3627 3560
        @author humkyung
DTI_PID/DTI_PID/Drawing.py
224 224
                cursor = conn.cursor()
225 225
                sql = database.to_sql('delete from LINE_DATA_LIST where PNID_NO=?')
226 226
                cursor.execute(sql, (self.name,))
227
                sql = database.to_sql('delete from EQUIPMENT_DATA_LIST where PNID_NO=?')
228
                cursor.execute(sql,(self.name,))
229
                sql = database.to_sql('delete from VALVE_DATA_LIST where PNID_NO=?')
230
                cursor.execute(sql, (self.name,))
231 227
                sql = database.to_sql('delete from INSTRUMENT_DATA_LIST where PNID_NO=?')
232 228
                cursor.execute(sql, (self.name,))
233
                sql = database.to_sql('delete from NOTE_DATA_LIST where PNID_NO=?') 
234
                cursor.execute(sql, (self.name,))
235 229
                sql = database.to_sql('delete from TitleBlockValues where Drawings_UID=(select UID from Drawings where [Name]=?)')
236 230
                cursor.execute(sql, (self.name,))
237 231
                sql = database.to_sql('delete from LineNoAttributes where Components_UID in (select UID from Components where Drawings_UID=(select UID from Drawings where Name=?))')
DTI_PID/DTI_PID/ItemDataExportDialog.py
181 181
            QMessageBox.about(self, self.tr("Information"), self.tr('Successfully saved.'))
182 182

  
183 183
            command = os.path.join(project.path, fileName + '.xlsx')
184
            subprocess.call(command, shell=True)
184
            os.startfile(command)
185 185
        except Exception as ex:
186 186
            from App import App
187 187
            from AppDocData import MessageType
......
267 267
            App.mainWnd().addMessage.emit(MessageType.Error, message)
268 268

  
269 269
    def auto_resize_columns(self, sheet):
270
        """
271
        @brief      auto resize columns with contents
272
        @author     humkyung
273
        @date       2018.10.11
274
        """
275
        for col in sheet.columns:
276
            max_length = 0
277
            column = col[0].column  # Get the column name
278
            for cell in col:
279
                try:  # Necessary to avoid error on empty cells
280
                    if len(str(cell.value)) > max_length:
281
                        max_length = len(cell.value)
282
                except:
283
                    pass
284

  
285
            adjusted_width = (max_length + 2) * 1.2
286
            sheet.column_dimensions[column].width = adjusted_width
270
        """ auto resize columns with contents """
271
        try:
272
            for col in sheet.columns:
273
                max_length = 0
274
                column = col[0].column  # Get the column name
275
                for cell in col:
276
                    try:  # Necessary to avoid error on empty cells
277
                        if len(str(cell.value)) > max_length:
278
                            max_length = len(cell.value)
279
                    except:
280
                        pass
281

  
282
                adjusted_width = (max_length + 2) * 1.2
283
                sheet.column_dimensions[str(chr(64 + column)) if type(column) is int else column].width = adjusted_width
284
        except Exception as ex:
285
            from App import App
286
            from AppDocData import MessageType
287

  
288
            message = 'error occurred({}) in {}:{}'.format(repr(ex), sys.exc_info()[-1].tb_frame.f_code.co_filename,
289
                                                          sys.exc_info()[-1].tb_lineno)
290
            App.mainWnd().addMessage.emit(MessageType.Error, message)
287 291

  
288 292
    '''
289 293
        @brief      init combobox
......
293 297

  
294 298
    def initComboBox(self):
295 299
        self.ui.comboBoxDoc.addItem('ALL')
296
        docData = AppDocData.instance()
300
        app_doc_data = AppDocData.instance()
297 301

  
298 302
        documentNameList = []
299
        documentNameData = docData.getDocumentNameList()
303
        documentNameData = app_doc_data.get_document_name_list()
300 304
        documentNameList.extend(documentNameData)
301 305

  
302 306
        for name in documentNameData:
......
304 308

  
305 309
        if not self.parent.graphicsView.hasImage():
306 310
            return
307
        result = self.ui.comboBoxDoc.findText(docData.imgName)
311
        result = self.ui.comboBoxDoc.findText(app_doc_data.imgName)
308 312
        if result == -1:
309
            self.ui.comboBoxDoc.addItem(docData.imgName)
313
            self.ui.comboBoxDoc.addItem(app_doc_data.imgName)
310 314

  
311 315
    '''
312 316
        @brief      init table widget
......
327 331
        self.equipColumnListAll = ['UID']
328 332
        self.equipColumnListAll.extend([prop.Attribute for prop in app_doc_data.get_equipment_attributes()])
329 333
        self.equipColumnListAll.append('Drawing Name')
330
        self.valveColumnListAll = app_doc_data.getColNames(QItemDataExportDialog.DATA_LIST[2])
331
        self.instColumnListAll = app_doc_data.getColNames(QItemDataExportDialog.DATA_LIST[3])
332
        self.noteColumnListAll = app_doc_data.getColNames(QItemDataExportDialog.DATA_LIST[4])
334
        self.valveColumnListAll = ['UID', 'ITEM_NO']
335
        self.valveColumnListAll.extend([prop.Attribute for prop in app_doc_data.get_valve_attributes()])
336
        self.valveColumnListAll.append('Drawing Name')
337
        self.instColumnListAll = ['UID', 'ITEM_NO']
338
        self.instColumnListAll.extend([prop.Attribute for prop in app_doc_data.get_instrument_attributes()])
339
        self.instColumnListAll.append('Drawing Name')
340
        self.noteColumnListAll = ['UID', 'ITEM_NO']
341
        self.noteColumnListAll.extend([prop.Attribute for prop in app_doc_data.get_note_attributes()])
342
        self.noteColumnListAll.append('Drawing Name')
333 343

  
334 344
        self.columnListAll.clear()
335 345
        self.columnListAll[QItemDataExportDialog.DATA_LIST[0]] = self.lineColumnListAll
......
383 393
                self.viewTables[key].hideColumn(0)
384 394

  
385 395
            # table Data 설정
386
            self.settingLineData()
387
            self.settingEquipmentData()
388
            self.set_valve_data()
389
            self.settingInstrumentData()
390
            self.settingNoteData()
396
            self.docNameChanged(None)
391 397
            self.fill_special_items()
392 398

  
393 399
            self.sortListOrder()
......
480 486
            text = self.ui.comboBoxDoc.itemText(index)
481 487
            if self.ui.comboBoxDoc.currentIndex() == 0:
482 488
                text = None
483
            dataList = app_doc_data.getEquipmentDataList(text)
489
            dataList = app_doc_data.get_equipment_data_list()
484 490
            equipTable.setRowCount(len(dataList))
485 491
            row = 0
486 492
            for data in dataList:
......
506 512
        @author     humkyung 
507 513
        @date       2018.10.11
508 514
        """
509
        from EngineeringTextItem import QEngineeringTextItem
510 515

  
511 516
        try:
512 517
            valve_table = self.ui.tableWidgetValveDataList
......
530 535
                        valve_table.setItem(row, col, item)
531 536
                row += 1
532 537

  
533
            # get column headers
538
            # set column headers
534 539
            headers = []
535 540
            for col in range(valve_table.columnCount()):
536 541
                headers.append(valve_table.horizontalHeaderItem(col).text())
......
548 553
        @date       2018.08.14
549 554
    '''
550 555

  
551
    def settingInstrumentData(self):
552
        instTable = self.ui.tableWidgetInstrumentDataList
553
        docData = AppDocData.instance()
556
    def set_instrument_data(self):
557
        inst_table = self.ui.tableWidgetInstrumentDataList
558
        app_doc_data = AppDocData.instance()
554 559

  
555 560
        # 기존 저장된 데이터 불러옴
556 561
        index = self.ui.comboBoxDoc.currentIndex()
557 562
        text = self.ui.comboBoxDoc.itemText(index)
558 563
        if self.ui.comboBoxDoc.currentIndex() == 0:
559 564
            text = None
560
        dataList = docData.getInstrumentDataList(text)
561
        instTable.setRowCount(len(dataList))
565
        dataList = app_doc_data.get_instrument_data_list(text)
566
        inst_table.setRowCount(len(dataList))
562 567
        row = 0
563 568
        for data in dataList:
564
            for dataIndex in range(len(data)):
565
                item = QTableWidgetItem(data[dataIndex] if data[dataIndex] is not None else '')
566
                item.setFlags(Qt.ItemIsEnabled)
567
                instTable.setItem(row, dataIndex, item)
569
            for col in range(self.ui.tableWidgetInstrumentDataList.columnCount()):
570
                col_name = self.ui.tableWidgetInstrumentDataList.horizontalHeaderItem(col).text()
571
                matches = [key for key in data.keys() if key == col_name]
572
                if matches:
573
                    item = QTableWidgetItem(data[matches[0]])
574
                    item.setFlags(Qt.ItemIsEnabled)
575
                    inst_table.setItem(row, col, item)
568 576
            row += 1
569 577

  
570
    '''
571
        @brief      setting note data
572
        @author     kyouho
573
        @date       2018.10.10
574
    '''
578
        # set column headers
579
        headers = []
580
        for col in range(inst_table.columnCount()):
581
            headers.append(inst_table.horizontalHeaderItem(col).text())
575 582

  
576
    def settingNoteData(self):
577
        noteTable = self.ui.tableWidgetNoteDataList
578
        docData = AppDocData.instance()
583
    def set_note_data(self):
584
        """ set note data """
585
        note_table = self.ui.tableWidgetNoteDataList
586
        app_doc_data = AppDocData.instance()
579 587

  
580 588
        # 기존 저장된 데이터 불러옴
581 589
        index = self.ui.comboBoxDoc.currentIndex()
582 590
        text = self.ui.comboBoxDoc.itemText(index)
583 591
        if self.ui.comboBoxDoc.currentIndex() == 0:
584 592
            text = None
585
        dataList = docData.getNoteDataList(text)
586
        noteTable.setRowCount(len(dataList))
593
        dataList = app_doc_data.get_note_data_list(text)
594
        note_table.setRowCount(len(dataList))
587 595

  
588 596
        row = 0
589 597
        for data in dataList:
590
            for dataIndex in range(len(data)):
591
                item = QTableWidgetItem(data[dataIndex] if data[dataIndex] is not None else '')
592
                item.setFlags(Qt.ItemIsEnabled)
593
                noteTable.setItem(row, dataIndex, item)
598
            for col in range(note_table.columnCount()):
599
                col_name = note_table.horizontalHeaderItem(col).text()
600
                matches = [key for key in data.keys() if key == col_name]
601
                if matches:
602
                    item = QTableWidgetItem(data[matches[0]])
603
                    item.setFlags(Qt.ItemIsEnabled)
604
                    note_table.setItem(row, col, item)
594 605
            row += 1
595 606

  
607
        # set column headers
608
        headers = []
609
        for col in range(note_table.columnCount()):
610
            headers.append(note_table.horizontalHeaderItem(col).text())
611

  
596 612
    def fill_special_items(self):
597 613
        """ fill table widget with special items """
598 614

  
......
640 656
        self.settingLineData()
641 657
        self.settingEquipmentData()
642 658
        self.set_valve_data()
643
        self.settingInstrumentData()
644
        self.settingNoteData()
645

  
646
    def saveSceneData(self):
647
        """
648
        @brief      save Line Data at scene
649
        @author     kyouho
650
        @date       2018.08.13
651
        """
652
        if not self.parent.graphicsView.hasImage():
653
            return
654

  
655
        from EngineeringLineNoTextItem import QEngineeringLineNoTextItem
656
        items = [item for item in self.parent.graphicsView.scene.items() if type(item) is QEngineeringLineNoTextItem]
657
        for item in items:
658
            text = item.text()
659
            self.sceneLineData[text] = item.getLineDataList()
660

  
661
        from EngineeringEquipmentItem import QEngineeringEquipmentItem
662
        items = [item for item in self.parent.graphicsView.scene.items() if type(item) is QEngineeringEquipmentItem]
663
        for item in items:
664
            self.sceneEquipData[str(item.uid)] = item.getEquipmentDataList()
665

  
666
        from SymbolSvgItem import SymbolSvgItem
667
        items = [item for item in self.parent.graphicsView.scene.items() if type(item) is SymbolSvgItem]
668
        for item in items:
669
            self.scene_valve_data[str(item.uid)] = item
670

  
671
        from EngineeringInstrumentItem import QEngineeringInstrumentItem
672
        items = [item for item in self.parent.graphicsView.scene.items() if type(item) is QEngineeringInstrumentItem]
673
        for item in items:
674
            self.sceneInstData[str(item.uid)] = item.getInstrumentDataList()
675

  
676
        from EngineeringNoteItem import QEngineeringNoteItem
677
        items = [item for item in self.parent.graphicsView.scene.items() if type(item) is QEngineeringNoteItem]
678
        for item in items:
679
            loopIndex = 1
680
            for note in item.getNoteDataList():
681
                self.sceneNoteData[str(item.uid) + "-" + str(loopIndex)] = note
682
                loopIndex += 1
659
        self.set_instrument_data()
660
        self.set_note_data()
683 661

  
684 662
    '''
685 663
        @brief      save Line Data
......
771 749
        docData.setInstrumentDataList(dataLists)
772 750

  
773 751
    '''
774
        @brief      save note Data
775
        @author     kyouho
776
        @date       2018.10.10
777
    '''
778

  
779
    def saveNoteDataList(self):
780

  
781
        noteTable = self.ui.tableWidgetNoteDataList
782
        docData = AppDocData.instance()
783

  
784
        dataLists = []
785
        for rowIndex in range(noteTable.rowCount()):
786
            dataList = []
787
            for columnIndex in range(noteTable.columnCount()):
788
                widgetItem = noteTable.item(rowIndex, columnIndex)
789

  
790
                if widgetItem is not None:
791
                    dataList.append(widgetItem.text())
792
                else:
793
                    dataList.append('')
794

  
795
            dataLists.append(dataList)
796

  
797
        docData.setNoteDataList(dataLists)
798

  
799
    '''
800 752
        @brief      key press event
801 753
        @author     kyouho
802 754
        @date       2018.08.13
DTI_PID/DTI_PID/ItemDataFormatDialog.py
435 435
                        editedCol.append(history)
436 436
                else: # add
437 437
                    addedCol.append(history[1])
438
            for edited in editedCol:
439
                docData.edit_column_Name_in_table(dbListName[index], edited[0], edited[1])
440
            for added in addedCol:
441
                docData.add_column_into_table(dbListName[index], added)
442 438

  
443 439
            # save column order
444 440
            value = ''
DTI_PID/DTI_PID/QEquipmentDataListDialog.py
25 25
        self.ui.tableWidgetEqpDataList.horizontalHeaderItem(0).setSizeHint(QSize(30, 30))
26 26

  
27 27
        docData = AppDocData.instance()
28
        dataList = docData.getEquipmentDataList()
28
        dataList = docData.get_equipment_data_list()
29 29
        self.ui.tableWidgetEqpDataList.setRowCount(len(dataList))
30 30

  
31 31
        row = 0
DTI_PID/DTI_PID/QInstrumentDataListDialog.py
25 25
        self.ui.tableWidgetInstrumentDataList.horizontalHeaderItem(0).setSizeHint(QSize(30, 30))
26 26

  
27 27
        docData = AppDocData.instance()
28
        dataList = docData.getEquipmentDataList()
28
        dataList = docData.get_equipment_data_list()
29 29
        self.ui.tableWidgetInstrumentDataList.setRowCount(len(dataList))
30 30

  
31 31
        row = 0
DTI_PID/DTI_PID/QLineDataListDialog.py
25 25
        self.ui.tableWidgetLineDataList.horizontalHeaderItem(0).setSizeHint(QSize(30, 30))
26 26

  
27 27
        docData = AppDocData.instance()
28
        dataList = docData.getEquipmentDataList()
28
        dataList = docData.get_equipment_data_list()
29 29
        self.ui.tableWidgetLineDataList.setRowCount(len(dataList))
30 30

  
31 31
        row = 0
DTI_PID/DTI_PID/Scripts/ID2.sql
156 156
    Allowables  TEXT
157 157
);
158 158

  
159
CREATE TABLE IF NOT EXISTS EQUIPMENT_DATA_LIST (
160
    UID                       VARCHAR (37) CONSTRAINT EQUIPMENT_DATA_LIST_PK PRIMARY KEY,
161
    ITEM_NO                   TEXT,
162
    SERVICE                   TEXT,
163
    NO_REQ                    TEXT,
164
    FLUID                     TEXT,
165
    DESC_OF_PART              TEXT,
166
    OPERATION_CONDITION_TEMP  TEXT,
167
    OPERATION_CONDITION_PRESS TEXT,
168
    DESIGN_CONDITION_TEMP     TEXT,
169
    DESIGN_CONDITION_PRESS    TEXT,
170
    MATERIAL                  TEXT,
171
    WEIGHT                    TEXT,
172
    POWER                     TEXT,
173
    INSULATION                TEXT,
174
    PNID_NO                   TEXT,
175
    REV                       TEXT
176
);
177

  
178 159
CREATE TABLE IF NOT EXISTS FluidCode (
179 160
    UID         VARCHAR (37) NOT NULL,
180 161
    CODE        VARCHAR (32) NOT NULL,
......
199 180
    )
200 181
);
201 182

  
202
CREATE TABLE IF NOT EXISTS INSTRUMENT_DATA_LIST (
203
    UID               VARCHAR (37),
204
    ITEM_NO           TEXT,
205
    SERVICE           TEXT,
206
    FLOW_RATE         TEXT,
207
    PRESSURE          TEXT,
208
    TEMPERATURE       TEXT,
209
    TYPE              TEXT,
210
    RANGE             TEXT,
211
    NOR_LEVEL_MM      TEXT,
212
    NOR_LEVEL_PERCENT TEXT,
213
    DEL_PRESS         TEXT,
214
    SHUT_OFF          TEXT,
215
    LOCATION          TEXT,
216
    PNID_NO           TEXT,
217
    REV               TEXT,
218
    CONSTRAINT EQUIPMENT_DATA_LIST_PK PRIMARY KEY (
219
        UID
220
    )
221
);
222

  
223 183
CREATE TABLE IF NOT EXISTS InsulationPurpose (
224 184
    UID         VARCHAR (37) CONSTRAINT InsulationPurpose_PK PRIMARY KEY
225 185
                             NOT NULL,
......
417 377
    Allowables  TEXT
418 378
);
419 379

  
420
CREATE TABLE IF NOT EXISTS VALVE_DATA_LIST (
421
    UID      VARCHAR (37),
422
    ITEM_NO  TEXT,
423
    MainSize TEXT,
424
    SubSize  TEXT,
425
    PNID_NO  TEXT,
426
    CONSTRAINT VALVE_DATA_LIST_PK PRIMARY KEY (
427
        UID
428
    )
429
);
430

  
431 380
CREATE TABLE IF NOT EXISTS ValveOperCodes (
432 381
    UID         VARCHAR (37) CONSTRAINT ValveOperCodes_PK PRIMARY KEY
433 382
                             NOT NULL,
DTI_PID/DTI_PID/Scripts/MSSQL/ID2.sql
1604 1604
    Allowables  TEXT
1605 1605
);
1606 1606

  
1607

  
1608
CREATE TABLE EQUIPMENT_DATA_LIST (
1609
    UID                       VARCHAR (37) CONSTRAINT EQUIPMENT_DATA_LIST_PK PRIMARY KEY,
1610
    ITEM_NO                   TEXT,
1611
    SERVICE                   TEXT,
1612
    NO_REQ                    TEXT,
1613
    FLUID                     TEXT,
1614
    DESC_OF_PART              TEXT,
1615
    OPERATION_CONDITION_TEMP  TEXT,
1616
    OPERATION_CONDITION_PRESS TEXT,
1617
    DESIGN_CONDITION_TEMP     TEXT,
1618
    DESIGN_CONDITION_PRESS    TEXT,
1619
    MATERIAL                  TEXT,
1620
    WEIGHT                    TEXT,
1621
    POWER                     TEXT,
1622
    INSULATION                TEXT,
1623
    PNID_NO                   VARCHAR(256),
1624
    REV                       TEXT
1625
);
1626

  
1627 1607
CREATE TABLE FluidCode (
1628 1608
    UID         VARCHAR (37) NOT NULL PRIMARY KEY,
1629 1609
    CODE        VARCHAR(32)         NOT NULL,
......
1643 1623
    )
1644 1624
);
1645 1625

  
1646
CREATE TABLE INSTRUMENT_DATA_LIST (
1647
    UID               VARCHAR (37) PRIMARY KEY,
1648
    ITEM_NO           TEXT,
1649
    SERVICE           TEXT,
1650
    FLOW_RATE         TEXT,
1651
    PRESSURE          TEXT,
1652
    TEMPERATURE       TEXT,
1653
    TYPE              TEXT,
1654
    RANGE             TEXT,
1655
    NOR_LEVEL_MM      TEXT,
1656
    NOR_LEVEL_PERCENT TEXT,
1657
    DEL_PRESS         TEXT,
1658
    SHUT_OFF          TEXT,
1659
    LOCATION          TEXT,
1660
    PNID_NO           VARCHAR(256),
1661
    REV               TEXT
1662
);
1663

  
1664

  
1665 1626
CREATE TABLE InsulationPurpose (
1666 1627
    UID         VARCHAR (37) CONSTRAINT InsulationPurpose_PK PRIMARY KEY
1667 1628
                             NOT NULL,
......
1978 1939
    Allowables  TEXT
1979 1940
);
1980 1941

  
1981
CREATE TABLE VALVE_DATA_LIST (
1982
    UID      VARCHAR (37),
1983
    ITEM_NO  TEXT,
1984
    MainSize TEXT,
1985
    SubSize  TEXT,
1986
    PNID_NO  VARCHAR(256) NOT NULL,
1987
    CONSTRAINT VALVE_DATA_LIST_PK PRIMARY KEY (
1988
        UID
1989
    )
1990
);
1991

  
1992 1942
CREATE TABLE ValveOperCodes (
1993 1943
    UID         VARCHAR (37) CONSTRAINT ValveOperCodes_PK PRIMARY KEY
1994 1944
                             NOT NULL,
DTI_PID/DTI_PID/Shapes/EngineeringEquipmentItem.py
231 231

  
232 232
    def toSql_return_separately(self):
233 233
        """ convert equipment data to sql query """
234
        import uuid
234 235
        from AppDocData import AppDocData
235 236
        res = []
236 237
        resLater = []
237 238

  
238
        appDocData = AppDocData.instance()
239

  
240
        cols = ['UID', 'ITEM_NO', 'PNID_NO']
241
        values = ['?','?','?']
242
        param = [str(self.uid), self.tag_no, appDocData.activeDrawing.name]
243

  
244
        """ save attributes to database """
245
        _attrs = self.getAttributes()
246
        for key,value in _attrs.items():
247
            cols.append(key.Attribute)
248
            values.append('?')
249
            param.append(value)
250

  
251
        sql = 'insert into EQUIPMENT_DATA_LIST({}) values({})'.format(','.join(cols), ','.join(values))
252
        res.append((sql, (tuple(param),)))
253

  
254 239
        res.append(self.toSql_Components())
255 240
        
256 241
        _attrs = self.getAttributes()
......
290 275
        # up to here
291 276
        
292 277
        return res, resLater
293

  
294
    '''
295
        @brief      return equip Data List
296
        @author     kyouho
297
        @date       2018.08.14
298
    '''
299
    def getEquipmentDataList(self):
300
        dataList = []
301
        try:
302
            from AppDocData import AppDocData
303

  
304
            docData = AppDocData.instance()
305
            attrs = self.attrs
306

  
307
            for index in range(len(QEngineeringEquipmentItem.EQUIP_COLUMN_LIST)):
308
                dataList.append('')
309

  
310
            dataList[0] = str(self.uid)
311
            dataList[14] = docData.imgName
312

  
313
            for attr in attrs:
314
                attrInfo = docData.getSymbolAttributeByUID(attr.UID)
315
                attrName = attrInfo[0]
316
                if QEngineeringEquipmentItem.EQUIP_COLUMN_LIST.count(attrName):
317
                    colIndex = QEngineeringEquipmentItem.EQUIP_COLUMN_LIST.index(attrName)
318
                    
319
                    if type(attr) is UserInputAttribute:
320
                        dataList[colIndex] = attr.text if attr.text is not None else ''
321
                    elif type(attr) is QEngineeringTextItem:
322
                        dataList[colIndex] = attr.text()
323
                    else:
324
                        dataList[colIndex] = attr.uid
325
            
326
        except Exception as ex:
327
            print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
328

  
329
        return dataList
DTI_PID/DTI_PID/Shapes/EngineeringInstrumentItem.py
310 310

  
311 311
        res = []
312 312
        resLater = []
313
        appDocData = AppDocData.instance()
314

  
315
        cols = ['UID', 'PNID_NO']
316
        values = ['?', '?']
317
        param = [(str(self.uid), appDocData.activeDrawing.name)]
318
        sql = 'insert into INSTRUMENT_DATA_LIST({}) values({})'.format(','.join(cols), ','.join(values))
319
        res.append((sql, tuple(param)))
320 313

  
321 314
        res.append(self.toSql_Components())
322 315

  
DTI_PID/DTI_PID/Shapes/EngineeringNoteItem.py
41 41

  
42 42
    @property
43 43
    def numbers(self):
44
        '''
45
        return note numbers which combines of digits
46
        '''
44
        ''' return note numbers which combines of digits '''
47 45
        import re
48 46

  
49 47
        return re.findall('\d+', self.text())
......
102 100

  
103 101
    def toSql(self):
104 102
        """ convert note no data to sql query """
103
        import uuid
105 104
        from AppDocData import AppDocData
106 105
        res = []
107 106

  
108 107
        app_doc_data = AppDocData.instance()
109 108

  
110
        cols = ['UID', 'NOTE_NO', 'DESCRIPTION', 'PNID_NO']
111
        values = ['?','?', '?', '?']
112
        params = []
113

  
114
        noteContentsList = self.findNoteContents(self.text())
115
        for key in noteContentsList.keys():
116
            params.append((str(self.uid), key, ' '.join(noteContentsList[key]), app_doc_data.activeDrawing.name))
117
        sql = 'insert into NOTE_DATA_LIST({}) values({})'.format(','.join(cols), ','.join(values))
118
        res.append((sql, tuple(params)))
119

  
120 109
        cols = ['UID', 'Drawings_UID', 'Symbol_UID', 'X', 'Y', 'Width', 'Height', 'Rotation', 'Area', 'Value', 'Owner', 'Connected', \
121 110
                'SpecialItemTypes_UID']
122 111
        values = ['?', '?', "(select UID from Symbol where Name='Note' and SymbolType_UID=-1)", '?', '?', '?', '?', '?', '?', '?', '?', '?', '?']
......
130 119
        sql = 'insert into Components({}) values({})'.format(','.join(cols), ','.join(values))
131 120
        res.append((sql, tuple(param)))
132 121

  
122
        _attrs = self.getAttributes()
123
        if _attrs:
124
            cols = ['UID', 'Components_UID', 'SymbolAttribute_UID', 'Value', 'Association_UID', 'Freeze']
125
            values = ['?', '?', '?', '?', '?', '?']
126
            params = []
127
            for key in _attrs.keys():
128
                params.append((str(uuid.uuid4()), str(self.uid), str(key.UID), str(_attrs[key]), str(key.AssocItem),
129
                               str(key.Freeze)))
130
            sql = 'insert into Attributes({}) values({})'.format(','.join(cols), ','.join(values))
131
            res.append((sql, tuple(params)))
132

  
133 133
        return res
134 134

  
135 135
    '''
DTI_PID/DTI_PID/Shapes/EngineeringReducerItem.py
161 161
        resLater = []
162 162
        appDocData = AppDocData.instance()
163 163

  
164
        cols = ['UID', 'ITEM_NO', 'PNID_NO', 'MainSize', 'SubSize']
165
        values = ['?', '?', '?', '?', '?']
166
        main_size = self.prop('Main Size')
167
        sub_size = self.prop('Sub Size')
168
        param = [(str(self.uid), self.name, appDocData.activeDrawing.name, main_size if main_size else '',
169
                  sub_size if sub_size else '')]
170
        sql = 'insert into VALVE_DATA_LIST({}) values({})'.format(','.join(cols), ','.join(values))
171
        res.append((sql, tuple(param)))
172

  
173 164
        res.append(self.toSql_Components())
174 165

  
175 166
        cols = ['UID', 'Components_UID', 'SymbolAttribute_UID', 'Value']
DTI_PID/DTI_PID/Shapes/EngineeringUnknownItem.py
45 45
        self.setAcceptHoverEvents(True)
46 46
        self.setAcceptTouchEvents(True)
47 47

  
48
        for pt in pts:
49
            self._pol.append(QPointF(pt[0], pt[1]))
50
        self._pol.append(QPointF(pts[0][0], pts[0][1]))  # close path
48
        if pts:
49
            for pt in pts:
50
                self._pol.append(QPointF(pt[0], pt[1]))
51
            self._pol.append(QPointF(pts[0][0], pts[0][1]))  # close path
52

  
51 53
        self.lineIndicator = lineIndicator
52 54
        self.isVH = isVH
53 55
        self.otherLine = otherLine
......
224 226
                item = QEngineeringUnknownItem(points, 'False')
225 227

  
226 228
            item.setVisible(False)
227
            if component['Area']:
229
            if component['Area'] and points:
228 230
                minx = min([coord[0] for coord in points])
229 231
                maxx = max([coord[0] for coord in points])
230 232
                miny = min([coord[1] for coord in points])
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py
496 496

  
497 497
        res = []
498 498
        resLater = []
499
        appDocData = AppDocData.instance()
500

  
501
        cols = ['UID', 'ITEM_NO', 'MainSize', 'SubSize', 'PNID_NO']
502
        values = ['?', '?', '?', '?', '?']
503
        size = self.prop('Size')
504
        param = [(str(self.uid), self.name, size if size else '', size if size else '', appDocData.activeDrawing.name)]
505
        sql = 'insert into VALVE_DATA_LIST({}) values({})'.format(','.join(cols), ','.join(values))
506
        res.append((sql, tuple(param)))
499
        app_doc_data = AppDocData.instance()
507 500

  
508 501
        res.append(self.toSql_Components())
509 502

  

내보내기 Unified diff

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