コード例 #1
0
    def _store(self, sheet, start_row, max_row, user_id, update_time):
        from Source.spec2db_server.arl.def_server import DefRecord
        def_obj = DefRecord()
        commit_list = []
        for row in range(start_row, max_row + 1):
            # print row
            values1 = self.get_row(sheet, row, from_col=1, to_col=4)  # 4个
            values5 = self.get_row(sheet, row, from_col=9,
                                   to_col=10)  # 基本要件——关连基本要件
            values2 = self.get_row(sheet, row, from_col=11, to_col=11)  # 1个
            values3 = self.get_row(sheet, row, from_col=19, to_col=22)  # 4个
            values4 = self.get_row(sheet, row, from_col=52,
                                   to_col=63)  # 12个, 63:Md5
            hu_id = values1[1]
            if not hu_id:
                break
            definition_id, unique_id = values1[2], values1[3]
            unique_id = int(unique_id)
            values1[3] = unique_id
            if not definition_id:
                definition_id = '.'.join([hu_id, str(unique_id)])
                values1[2] = definition_id
            if definition_id[0] in ('A', 'B', 'C', 'D'):
                continue
            # if type(unique_id) in (str, unicode):
            #     unique_id = int((definition_id.split('.'))[-1])
            #     values1[3] = unique_id
            new_date = values4[-2]  # 日付
            if new_date:
                values4[-2] = self.convert_time(new_date)
            params = values1 + values5 + values2 + values3 + values4
            model_vals = self.get_row(sheet, row, 23, 51)
            new_data = self._convert_info(params, model_vals)
            new_data["md5_key"] = values4[-1]
            try:
                md5_check, lock_check, curr_commit_list = def_obj.add(
                    self._pg, new_data, self._col_list, update_time)
                if not md5_check:
                    return definition_id + " MD5 不存在!"
                elif not lock_check:
                    return definition_id + " 不能被修改!"
                elif curr_commit_list:
                    commit_list += curr_commit_list
            except Exception as e:
                print e
                return e.message

        log = {'user_id': user_id, "commit_list": commit_list}
        if commit_list:
            from Source.spec2db_server.arl.commit_log import CommitLog
            commit_log = CommitLog()
            flag, commit_id = commit_log.add_commit_log2(self._pg, log)
            if flag:
                print '提交'
                self._pg.commit()
            else:
                print 'log_commit errol!'
        else:
            print '不用更新'
コード例 #2
0
ファイル: block.py プロジェクト: lsn1183/web_project
 def _store(self, sheet, classify, start_row, max_row, user_id, update_time, up, down):
     error, update_count = None, 0
     if classify == 'HU_DEF':
         obj = HuRecord()
         basic_obj = BasicHuRecord()
     elif classify == 'TAGL_DEF':
         obj = DefRecord()
         basic_obj = BasicDefRecord()
     elif classify == 'TAGL_ANA':
         obj = AnalysisRecord()
         basic_obj = BasicAnaRecord()
     else:
         error = 'Unkown classify [%s]' % classify
         return error, update_count
     commit_list = []
     for row in range(start_row, max_row + 1):
         values = self.get_row(sheet, row, from_col=1, to_col=2)
         _id, block = values[0], values[1]
         if not _id:
             break
         lock_status = 0  # unlock
         if block == u'〇':
             lock_status = 1  # lock
         if self.is_basic_id(_id):
             curr_commit_list = basic_obj.upate_lock_status(self._pg, _id, lock_status, update_time, up, down)
         else:
             curr_commit_list = obj.upate_lock_status(self._pg, _id, lock_status, update_time, up, down)
         if curr_commit_list:
             update_count += 1
             commit_list += curr_commit_list
     log = {'user_id': user_id, "commit_list": commit_list}
     if commit_list:
         commit_log = CommitLog()
         flag, commit_id = commit_log.add_commit_log2(self._pg, log)
         if flag:
             obj.update_post_lock_status(self._pg)
             obj.update_parent_lock_status(self._pg)
         else:
             self._pg.conn.rollback()
             error = 'log_commit errol!'
     else:
         print 'no change.'
     return error, update_count
コード例 #3
0
 def _store(self, sheet, start_row, max_row, user_id, update_time):
     from Source.spec2db_server.arl.hu_server import HuRecord
     hu_obj = HuRecord()
     count = 0
     commit_list = []
     for row in range(start_row, max_row + 1):
         # print row
         # 担当, ARLID
         values1 = self.get_row(sheet, row, from_col=1, to_col=2)
         # 基本要件
         values5 = self.get_row(sheet, row, from_col=7, to_col=7)
         # H/U要件定義ID ==> H/U分類ID
         values2 = self.get_row(sheet, row, from_col=13, to_col=30)
         # 備考 ==> 最終修正担当
         values3 = self.get_row(sheet, row, from_col=61, to_col=77)
         # Group ==> TAGL要件提出
         values4 = self.get_row(sheet, row, from_col=78, to_col=81)
         arl_id = values1[1]
         if not arl_id:
             break
         new_date = values4[0]  # 日付
         if new_date:
             values4[0] = self.convert_time(new_date)
         hu_id, unique_id = values2[0], self.convert_2_int(values2[1])
         values2[1] = unique_id
         if not hu_id:
             hu_id = '.'.join([arl_id, str(unique_id)])
             values2[0] = hu_id
         if hu_id[0] in ('A', 'B', 'C', 'D'):
             continue
         # amp, dsrc, dcm, rse, touch_pad, separate_disp
         i = 2
         while i < 8:
             values2[i] = self.convert_2_int(values2[i])
             i += 1
         hu_category_id = self.convert_2_int(values2[-1])
         values2[-1] = hu_category_id
         # print '%s,%s\n' % (arl_id, hu_id)
         # if type(unique_id) in (str, unicode):
         #     unique_id = int((hu_id.split('.'))[-1])
         #     values2[1] = unique_id
         params = values1 + values5 + values2 + values3 + values4
         model_vals = self.get_row(sheet, row, 31, 60)
         new_data = self._convert_info(params, model_vals)
         new_data["md5_key"] = values4[-1]
         try:
             md5_check, lock_check, curr_commit_list = hu_obj.add(
                 self._pg, new_data, self._col_list, update_time)
             if not md5_check:
                 return hu_id + " MD5 不存在!"
             elif not lock_check:
                 return hu_id + " 不能被修改!"
             elif curr_commit_list:
                 commit_list += curr_commit_list
         except Exception as e:
             print e
             return e.message
     log = {'user_id': user_id, "commit_list": commit_list}
     if commit_list:
         from Source.spec2db_server.arl.commit_log import CommitLog
         commit_log = CommitLog()
         flag, commit_id = commit_log.add_commit_log2(self._pg, log)
         if flag:
             print '提交'
             self._pg.commit()
         else:
             print 'log_commit errol!'
     else:
         print '不用更新'
コード例 #4
0
 def new_store(self, hu_data_list, user_id, update_time, role, check_list):
     hu_import_record = dict()
     hu_import_record['result'] = 0
     self._pg.connect()
     commit_list = []
     from Source.spec2db_server.arl.hu_server import HuRecord
     from Source.spec2db_server.arl.basic_hu import BasicHuRecord
     from Source.spec2db_server.arl.arl_group import ArlGroup
     from Source.spec2db_server.arl.basic_def import BasicDefRecord
     from Source.spec2db_server.spec_import.definition import DefinitionSpec
     group_obj = ArlGroup()
     hu_obj = HuRecord()
     basic_hu_obj = BasicHuRecord()
     basic_def_obj = BasicDefRecord()
     sqlcmd = group_obj.get_group_id(user_id)
     self._pg.execute(sqlcmd)
     row = self._pg.fetchone()
     group_id = None
     if row:
         group_id = row[0]
     # data_list = group_obj.get_one_member(self._pg, user_id)
     for hu_data in hu_data_list:
         hu_id = hu_data["hu_id"].get("datavalue")
         if not hu_id:
             continue
         basic_flag = False
         # if not self._import_power(self._pg, user_id, arl_id, data_list): # 导入权限验证
         #     continue
         try:
             if re.match("^[B|C|D].*", hu_id):
                 new_data = self.convert_basic_data(hu_data)
                 if new_data.get("group_name"):
                     new_data.pop("group_name")
                 new_data["group_id"] = group_id
                 new_data["user_id"] = user_id
                 arl_id = new_data.get("arl_id")
                 if not arl_id:
                     continue
                 basic_flag = True
                 md5_check, lock_check, curr_commit_list = basic_hu_obj.add(
                     self._pg, new_data, self._col_list, update_time, role)
             else:
                 new_data = self.convert_data(hu_data)
                 arl_id = new_data.get("arl_id")
                 if not arl_id:
                     continue
                 md5_check, lock_check, curr_commit_list = hu_obj.add(
                     self._pg, new_data, self._col_list, update_time, role)
             if not md5_check:
                 hu_import_record['result'] = 1
                 if not new_data.get("md5_key"):
                     hu_import_record["error_list"] = hu_id + " MD5 不存在!"
                 else:
                     hu_import_record["error_list"] = hu_id + " MD5 不正确!"
                 return hu_import_record
             elif not lock_check:
                 hu_import_record['result'] = 1
                 hu_import_record["error_list"] = hu_id + " 不能被修改!"
                 return hu_import_record
             if curr_commit_list:
                 if basic_flag:
                     rel_def_list = basic_def_obj._get_by_parent_id(
                         self._pg, hu_id)
                     for def_data in rel_def_list:
                         def_data['dcu_status'] = new_data['dcu_status']
                         def_data['dcu_trigger'] = new_data['dcu_trigger']
                         def_data['dcu_action'] = new_data['dcu_action']
                         def_data['meu_status'] = new_data['meu_status']
                         def_data['meu_trigger'] = new_data['meu_trigger']
                         def_data['meu_action'] = new_data['meu_action']
                         def_data['hu_remark'] = new_data['remark']
                         sub_result = basic_def_obj.add(
                             self._pg,
                             def_data,
                             DefinitionSpec()._col_list,
                             update_time,
                             "Admin",
                             excel_import=False)
                         md5_check, lock_check, sub_commit_list = sub_result
                         if sub_commit_list:
                             curr_commit_list += sub_commit_list
                 commit_list += curr_commit_list
         except Exception as e:
             hu_import_record['result'] = 1
             hu_import_record["error_list"] = e.message
             return hu_import_record
     if commit_list:
         author_log = []
         charge_log = []
         author_commit_list, charger_commit_list = self.split_commit_list(
             commit_list)
         if author_commit_list:
             author_log = {
                 'user_id': user_id,
                 "commit_list": author_commit_list,
                 "group_id": group_id
             }
         if charger_commit_list:
             charge_log = {
                 'user_id': user_id,
                 "commit_list": charger_commit_list,
                 "group_id": group_id
             }
         from Source.spec2db_server.arl.commit_log import CommitLog
         commit_log = CommitLog()
         if author_log:
             flag, commit_id = commit_log.add_commit_log2(
                 self._pg, author_log)
             if flag:
                 self.import_check_list(self._pg, check_list, 'hu',
                                        commit_id, 'author')
             else:
                 print 'log_commit errol!'
         if charge_log:
             flag, commit_id = commit_log.add_commit_log2(
                 self._pg, charge_log)
             if flag:
                 self.import_check_list(self._pg, check_list, 'hu',
                                        commit_id, 'charge')
         print '提交'
         self._pg.commit()
         self._pg.close()
     else:
         self._pg.close()
         print '不用更新'
     return hu_import_record
コード例 #5
0
    def new_store(self, ana_data_list, user_id, update_time, role, check_list):
        ana_import_record = dict()
        ana_import_record['result'] = 0
        self._pg.connect()
        commit_list = []
        from Source.spec2db_server.arl.analysis_service import AnalysisRecord
        from Source.spec2db_server.arl.basic_ana import BasicAnaRecord
        from Source.spec2db_server.arl.arl_group import ArlGroup
        basic_ana_obj = BasicAnaRecord()
        ana_obj = AnalysisRecord()
        group_obj = ArlGroup()
        sqlcmd = group_obj.get_group_id(user_id)
        self._pg.execute(sqlcmd)
        row = self._pg.fetchone()
        group_id = None
        if row:
            group_id = row[0]
        # data_list = group_obj.get_one_member(self._pg, user_id)
        for ana_data in ana_data_list:
            definition_id = ana_data["definition_id"].get("datavalue")
            if not definition_id:
                continue
            # if not self._import_power(self._pg, user_id, arl_id, data_list): # 导入权限验证
            #     continue
            try:
                if re.match("^[B|C|D].*", definition_id):
                    new_data = self.convert_basic_data(ana_data)
                    if new_data.get("definition_id") == 'B.4.2.3.1':
                        print new_data.get("unique_id")
                        pass
                    new_data["analysis_id"] = '.'.join([
                        new_data.get("definition_id"),
                        str(new_data.get("unique_id"))
                    ])
                    # 检查时序是否正确
                    # seq_diagram = new_data.get('seq_diagram')
                    # asta_filename = new_data.get('asta_filename')
                    # seq_diagram = seq_diagram.replace('\n', '')
                    # asta_filename = asta_filename.replace('\n', '')
                    # check_flag = basic_ana_obj.check_seq_diagram(self._pg, seq_diagram, asta_filename)
                    # if not check_flag:
                    #     ana_import_record['result'] = 1
                    #     ana_import_record["error_list"] = definition_id + " 的“シーケンス図”不在对应的Astah文件中!"
                    #     return ana_import_record
                    if new_data.get("group_name"):
                        new_data.pop("group_name")
                    new_data["group_id"] = group_id
                    new_data["user_id"] = user_id
                    md5_check, lock_check, curr_commit_list = basic_ana_obj.add(
                        self._pg, new_data, self._col_list, update_time, role)
                else:
                    new_data = self.convert_data(ana_data)
                    new_data["analysis_id"] = '.'.join([
                        new_data.get("definition_id"),
                        str(new_data.get("unique_id"))
                    ])
                    # 检查时序是否正确
                    # seq_diagram = new_data.get('seq_diagram')
                    # asta_filename = new_data.get('asta_filename')
                    # seq_diagram = seq_diagram.replace('\n', '')
                    # asta_filename = asta_filename.replace('\n', '')
                    # check_flag = basic_ana_obj.check_seq_diagram(self._pg, seq_diagram, asta_filename)
                    # if not check_flag:
                    #     ana_import_record['result'] = 1
                    #     ana_import_record["error_list"] = definition_id + " 的“シーケンス図”或“astaファイル名”不正确!"
                    #     return ana_import_record

                    md5_check, lock_check, curr_commit_list = ana_obj.add(
                        self._pg, new_data, self._col_list, update_time, role)
                if not md5_check:
                    ana_import_record['result'] = 1
                    if not new_data.get("md5_key"):
                        ana_import_record[
                            "error_list"] = definition_id + " MD5 不存在!"
                    else:
                        ana_import_record[
                            "error_list"] = definition_id + " MD5 不正确!"
                    return ana_import_record
                elif not lock_check:
                    ana_import_record['result'] = 1
                    ana_import_record["error_list"] = definition_id + " 不能被修改!"
                    return ana_import_record
                if curr_commit_list:
                    commit_list += curr_commit_list
            except Exception as e:
                ana_import_record['result'] = 1
                ana_import_record["error_list"] = e.message
                return ana_import_record
        if commit_list:
            author_commit_list, charger_commit_list = self.split_commit_list(
                commit_list)
            author_log = {
                'user_id': user_id,
                "commit_list": author_commit_list,
                "group_id": group_id
            }
            charge_log = {
                'user_id': user_id,
                "commit_list": charger_commit_list,
                "group_id": group_id
            }
            from Source.spec2db_server.arl.commit_log import CommitLog
            commit_log = CommitLog()
            if author_log:
                flag, commit_id = commit_log.add_commit_log2(
                    self._pg, author_log)
                if flag:
                    self.import_check_list(self._pg, check_list, 'analysis',
                                           commit_id, 'author')
                else:
                    print 'log_commit errol!'
            if charge_log:
                flag, commit_id = commit_log.add_commit_log2(
                    self._pg, charge_log)
                if flag:
                    self.import_check_list(self._pg, check_list, 'analysis',
                                           commit_id, 'charge')
            print '提交'
            self._pg.commit()
            self._pg.close()
        else:
            self._pg.close()
            print '不用更新'
        return ana_import_record
コード例 #6
0
 def _store(self, sheet, start_row, max_row, user_id, update_time):
     from Source.spec2db_server.arl.analysis_service import AnalysisRecord
     def_obj = AnalysisRecord()
     commit_list = []
     for row in range(start_row, max_row + 1):
         values1 = self.get_row(sheet, row, from_col=1, to_col=3)  # 3个
         values2 = self.get_row(sheet, row, from_col=8,
                                to_col=10)  # 基本要件——除外
         values3 = self.get_row(sheet, row, from_col=15,
                                to_col=15)  # 1个: 除外
         values4 = self.get_row(sheet, row, from_col=121,
                                to_col=127)  # 補足参照仕様書==>備考==>1234
         values5 = self.get_row(sheet, row, from_col=128,
                                to_col=130)  # 更新日==>astaファイル名
         values6 = self.get_row(sheet, row, from_col=131,
                                to_col=132)  # 组, MD5
         # values6 = self.get_row(sheet, row, from_col=131, to_col=142)  # 指摘
         definition_id = values1[1]
         if not definition_id:
             break
         if definition_id[0] in ('A', 'B', 'C', 'D'):
             continue
         unique_id = int(values1[2])
         values1[2] = unique_id
         if type(unique_id) in (str, unicode):
             unique_id = int((definition_id.split('.'))[-1])
             values1[2] = unique_id
         new_date = values4[-2]  # 日付
         if new_date:
             values4[-2] = self.convert_time(new_date)
         # point_date = values6[9]  # 指摘日
         # if point_date:
         #     values6[9] = self.convert_time(point_date)
         # else:
         #     continue
     #     point_dict = self._convert_point_out(values6)
     #     point_dict["id"] = definition_id
     #     point_dict["classify "] = "analysis"
     #     point_dict["update_time"] = update_time
     #     from Source.spec2db_server.arl.arl_base import ServiceBase
     #     obi = ServiceBase()
     #     if obi._add_point_out(self._pg, point_dict):
     #         continue
     #     else:
     #         print "出错!"
     # self._pg.commit()
     # self._pg.close()
         params = values1 + values2 + values3 + values4 + values5
         model_vals = self.get_row(sheet, row, 16, 120)
         new_data = self._convert_info(params, model_vals)
         new_data["md5_key"] = values6[-1]
         try:
             md5_check, lock_check, curr_commit_list = def_obj.add(
                 self._pg, new_data, self._col_list, update_time)
             if not md5_check:
                 return definition_id + " MD5 不存在!"
             elif not lock_check:
                 return definition_id + " 不能被修改!"
             elif curr_commit_list:
                 commit_list += curr_commit_list
         except Exception as e:
             print e
             return e.message
     log = {'user_id': user_id, "commit_list": commit_list}
     if commit_list:
         from Source.spec2db_server.arl.commit_log import CommitLog
         commit_log = CommitLog()
         flag, commit_id = commit_log.add_commit_log2(self._pg, log)
         if flag:
             print '提交'
             self._pg.commit()
         else:
             print 'log_commit errol!'
     else:
         print '不用更新'