def get_by_id_deep(self, pg, _id): """ :param _id: arl_id :return: """ _, def_data_list = self.get_by_def_id(pg, _id) for def_data in def_data_list: point_obj = PointOut(self.table_name) point_list = point_obj.get_list_by_id(pg, _id) def_data["point_list"] = point_list return def_data_list
def _add_sub(self, pg, data, update_time): hu_id = data.get(self.id_col) def_data_list = data.get(self.sub_list_name) def_obj = BasicDefRecord() sub_log_list = def_obj.add_list(pg, hu_id, def_data_list, update_time) if sub_log_list is None: return None point_out = PointOut(self.table_name) po_log_list = point_out.add_list(pg, data.get(self.id_col), data.get("point_list"), update_time) if po_log_list is None: return None return sub_log_list + po_log_list
def _add_sub(self, pg, data, update_time): def_id = data.get(self.id_col) def_data_list = data.get(self.sub_list_name) analysis_obj = AnalysisRecord() sub_log_list = analysis_obj.add_list(pg, def_id, def_data_list, update_time) if sub_log_list is None: return None point_out = PointOut("DEF") po_log_list = point_out.add_list(pg, data.get(self.id_col), data.get("point_list"), update_time) if po_log_list is None: return None return sub_log_list + po_log_list
def update_point_diff_dict(self, pg, point_diff_dict): if point_diff_dict: action = point_diff_dict.get("action") if action == "change": data = point_diff_dict.get("data") point_rc_id = data.get("pointout_rc_id") col_change_list = point_diff_dict.get("col_change_list") col_change_list.append("update_time") params = self.get_params(data, col_change_list) update_sql = self.list_2_update_sql("point_out", col_change_list, ["pointout_rc_id"], "pointout_rc_id") pg.execute(update_sql, params + [point_rc_id]) if pg.pgcur.rowcount <= 0: return False if action == "add": data = point_diff_dict.get("data") from Source.spec2db_server.arl.point_out import PointOut point_obj = PointOut(None) insert_sql = self.list_2_insert_sql("point_out", point_obj.attr_list[1:], "pointout_rc_id") params = self.get_params(data, point_obj.attr_list[1:]) pg.execute(insert_sql, params) if pg.pgcur.rowcount <= 0: return False rc_id = self.fetch_id(pg) data["pointout_rc_id"] = rc_id point_diff_dict["record_id"] = rc_id return True
def get_by_id_deep(self, pg, _id): """ :param _id: arl_id :return: """ if not _id: return [] count, hu_data_list = self._get_by_arl_id(pg, _id) from Source.spec2db_server.arl.def_server import DefRecord def_obj = DefRecord() for data_dict in hu_data_list: hu_id = data_dict.get('hu_id') point_obj = PointOut(self.table_name) point_list = point_obj.get_list_by_id(pg, hu_id) data_dict["point_list"] = point_list data_dict[self.sub_list_name] = def_obj.get_by_id_deep(pg, hu_id) return hu_data_list
def get_by_id_deep(self, pg, _id): """ :param _id: arl_id :return: """ if not _id: return [] _, def_data_list = self.get_definition_by_hu_id_deep(pg, _id) from Source.spec2db_server.arl.basic_ana import BasicAnaRecord analysis_obj = BasicAnaRecord() for data_dict in def_data_list: def_id = data_dict.get(self.id_col) point_obj = PointOut(self.table_name) point_list = point_obj.get_list_by_id(pg, def_id) data_dict["point_list"] = point_list data_dict[self.sub_list_name] = analysis_obj.get_by_id_deep( pg, def_id) return def_data_list
def _get_by_basic_id_deep(self, pg, _id, user_id, group_id): """ :param pg: :param _id: :return: """ "" if not _id: return [] info_list = [] arl_dict = self.get_by_id(pg, _id, self.attr_list) if not arl_dict.get("user_id"): arl_dict["user_id"] = self.get_user_id_by_arl_id( arl_dict["definition_id"]) self.del_unkown_ch(arl_dict) if arl_dict: type_id = str(_id) if type_id[0] != 'B' and type_id[0] != 'C' and type_id[0] != 'D': def_id = arl_dict.get("definition_id") point_obj = PointOut("def") point_list = point_obj.get_list_by_id(pg, def_id) arl_dict["point_list"] = point_list from Source.spec2db_server.arl.analysis_service import AnalysisRecord ana_obj = AnalysisRecord() arl_dict[self.sub_list_name] = ana_obj.get_by_id_deep(pg, _id) arl_user_id = arl_dict.get("user_id") # 设置权限控制 control_list = self._get_procudure_control( pg, arl_user_id, user_id) self._set_procudure_control(arl_dict, control_list) else: def_id = arl_dict.get(self.id_col) point_obj = PointOut("def") point_list = point_obj.get_list_by_id(pg, def_id) arl_dict["point_list"] = point_list from Source.spec2db_server.arl.basic_ana import BasicAnaRecord ana_obj = BasicAnaRecord() arl_dict[self.sub_list_name] = ana_obj.get_by_id_deep(pg, _id) arl_user_id = arl_dict.get("user_id") # 设置权限控制 control_list = self._get_procudure_control( pg, arl_user_id, user_id) self._set_procudure_control(arl_dict, control_list) info_list.append(arl_dict) return info_list
def _get_by_basic_id_deep(self, pg, _id, user_id, group_id): """ :param pg: :param _id: :return: """"" if not _id: return [] info_list = [] arl_dict = self.get_by_id(pg, _id, self.attr_list) if not arl_dict.get("user_id"): arl_dict["user_id"] = self.get_user_id_by_arl_id(arl_dict["hu_id"]) self.del_unkown_ch(arl_dict) if arl_dict: type_id = str(_id) if type_id[0] != 'B' and type_id[0] != 'C' and type_id[0] != 'D': hu_id = arl_dict.get('hu_id') point_obj = PointOut("hu") point_list = point_obj.get_list_by_id(pg, hu_id) arl_dict["point_list"] = point_list from Source.spec2db_server.arl.def_server import DefRecord def_obj = DefRecord() arl_dict[self.sub_list_name] = def_obj.get_by_id_deep(pg, _id) arl_user_id = arl_dict.get("user_id") # 设置权限控制 control_list = self._get_procudure_control(pg, arl_user_id, user_id) self._set_procudure_control(arl_dict, control_list) else: hu_id = arl_dict.get('hu_id') point_obj = PointOut(self.table_name) point_list = point_obj.get_list_by_id(pg, hu_id) arl_dict["point_list"] = point_list from Source.spec2db_server.arl.basic_def import BasicDefRecord def_obj = BasicDefRecord() arl_dict[self.sub_list_name] = def_obj.get_by_id_deep(pg, hu_id) arl_user_id = arl_dict.get("user_id") # 设置权限控制 control_list = self._get_procudure_control(pg, arl_user_id, user_id) self._set_procudure_control(arl_dict, control_list) info_list.append(arl_dict) return info_list
def _get_by_basic_id_deep(self, pg, _id, user_id, group_id): """ :param pg: :param _id: :return: """ "" if not _id: return [] info_list = [] arl_dict = self.get_by_id(pg, _id, self.attr_list) if arl_dict: if not arl_dict.get("user_id"): arl_dict["user_id"] = self.get_user_id_by_arl_id( arl_dict["definition_id"]) self.del_unkown_ch(arl_dict) if arl_dict: type_id = str(_id) if type_id[0] != 'B' and type_id[0] != 'C' and type_id[ 0] != 'D': point_obj = PointOut("analysis") point_list = point_obj.get_list_by_id(pg, _id) arl_dict["point_list"] = point_list arl_user_id = arl_dict.get("user_id") # # 设置权限控制 control_list = self._get_procudure_control( pg, arl_user_id, user_id) arl_dict["control_list"] = control_list # self._set_procudure_control(arl_dict, control_list) else: point_obj = PointOut(self.table_name) point_list = point_obj.get_list_by_id(pg, _id) arl_dict["point_list"] = point_list arl_user_id = arl_dict.get("user_id") # # 设置权限控制 control_list = self._get_procudure_control( pg, arl_user_id, user_id) arl_dict["control_list"] = control_list # self._set_procudure_control(arl_dict, control_list) info_list.append(arl_dict) return info_list
def _add_sub(self, pg, data, update_time): point_out = PointOut(self.table_name) return point_out.add_list(pg, data.get(self.id_col), data.get("point_list"), update_time)