def exportToExcel(self, rowdata): key = [ 'id', 'create_time', 'update_time', 'create_id', 'update_id', 'msg_list_id', 'sender_type', 'sender_name', 'sender_code', 'send_date', 'send_time', 'sender_addr', 'receiver_type', 'receiver_name', 'receiver_code', 'receive_date', 'receive_time', 'receiver_addr', 'message_type', 'message_sn', 'content_type', 'bin_content', 'text_content', 'send_status' ] messageList = [] for i, item in enumerate(rowdata): messageInfo = dict(zip(key, item)) messageList.append(messageInfo) cur = self.db.getCursor() utils.getDataDict(cur, messageList, "send_status", "PROGRAM_SEND_STATUS", "send_status_name") utils.getDataDict(cur, messageList, "message_type", "MSG_TYPE_CONTROLLER", "message_type_name") data = [] sn = 1 for item in messageList: if 'send_status_name' not in item: item['send_status_name'] = "未发送" if 'apply_status_name' not in item: item['apply_status_name'] = "未提交" itemData = [] itemData.append(sn) sn = sn + 1 itemData.append(messageInfo['sender_name']) itemData.append(messageInfo['send_date']) itemData.append(messageInfo['send_time']) itemData.append(messageInfo['receiver_name']) itemData.append(messageInfo['receive_date']) itemData.append(messageInfo['receive_time']) itemData.append(messageInfo['message_type']) itemData.append(messageInfo['message_sn']) itemData.append(messageInfo['text_content']) data.append(itemData) struct = "SN, 发送方名称, 发送日期, 发送时间, 接收方名称, 接收日期, 接收时间, 消息类别, 消息序号, 消息正文" path = {} path = excel.createTempFile("xls") excel.saveExcel(path['path'], struct, data) logInfo = " %s 下载了消息发送详单 " % self.objUserInfo['name'] operation_log(self.db).addLog(self.GetUserInfo(), "messageManage", logInfo, 0) self.response(path)
def exportToExcel(self, rowdata): data = [] sn = 1 key = ['u_id', 'id', 'menu_code', 'operation_context', 'operation_no', 'create_time', 'operator_name', 'menu_name'] for i, item in enumerate(rowdata): messageInfo = dict(zip(key, item)) itemData = [] itemData.append( sn ) sn = sn + 1 itemData.append( messageInfo['operator_name'] ) itemData.append( messageInfo['create_time'].strftime('%Y-%m-%d %H:%M:%S') ) itemData.append( messageInfo['operation_context']) data.append(itemData) struct = "SN, 操作人, 操作时间, 操作内容" path = {} path = excel.createTempFile("xls") excel.saveExcel(path['path'], struct, data ) logInfo = " %s 下载了操作日志清单 "%self.objUserInfo['name'] operation_log(self.db).addLog(self.GetUserInfo(), "operationLog", logInfo, 0) self.response(path)
def exportToExcel(self, rowdata): key = [ 'id', 'create_time', 'update_time', 'create_id', 'update_id', 'code', 'name', 'valid_date', 'apply_id', 'apply_name', 'apply_date', 'checker_id', 'checker_name', 'check_date', 'apply_status', 'video_type', 'sender_id', 'sender_name', 'send_date', 'send_time', 'send_status' ] messageList = [] for i, item in enumerate(rowdata): messageInfo = dict(zip(key, item)) messageList.append(messageInfo) cur = self.db.getCursor() utils.getDataDict(cur, messageList, "send_status", "PROGRAM_SEND_STATUS", "send_status_name") utils.getDataDict(cur, messageList, "apply_status", "PROGRAM_APPLY_STATUS", "apply_status_name") data = [] sn = 1 for item in messageList: if 'send_status_name' not in item: item['send_status_name'] = "未发送" if 'apply_status_name' not in item: item['apply_status_name'] = "未提交" itemData = [] itemData.append(sn) sn = sn + 1 itemData.append(item['name']) # 节目单名称 itemData.append(item['valid_date']) # 生效日期 itemData.append(item['apply_name']) # 申请人姓名 itemData.append(item['apply_date']) # 申请日期 itemData.append(item['checker_name']) itemData.append(item['check_date']) # 审核日期 itemData.append(item['apply_status_name']) # 申请状态 itemData.append(item['sender_name']) # 发送人姓名 itemData.append(item['send_date']) # 发送日期 itemData.append(item['send_time']) # 发送日期 itemData.append(item['send_status_name']) # 发送状态 data.append(itemData) struct = "SN, 节目单名称, 生效日期, 申请人姓名, 申请日期, 审核人姓名, 审核日期, 申请状态, 发送者姓名, 发送日期, 发送时间, 发送状态" path = {} path = excel.createTempFile("xls") excel.saveExcel(path['path'], struct, data) logInfo = " %s 下载了节目单清单 " % self.objUserInfo['name'] operation_log(self.db).addLog(self.GetUserInfo(), "listManage", logInfo, 0) self.response(path)
def exportToExcel(self, rowdata): key = [ 'id', 'vendor_id', 'vendor_code', 'name', 'name_en', 'abbr', 'abbr_en', 'abbr', 'abbr_en', 'registe_addr', 'current_addr', 'logo_file', 'contactor_name', 'contactor_mobile', 'vendor_type', 'description', 'certifaction_status', 'certifaction_date', 'certifaction_desc', 'start_date', 'end_date' ] vendorList = [] for i, item in enumerate(rowdata): vendorInfo = dict(zip(key, item)) vendorList.append(vendorInfo) cur = self.db.getCursor() getDataDict(cur, vendorList, "certifaction_status", "VENDOR_COOPERATION_STATUS", "status_name") getDataDict(cur, vendorList, "vendor_type", "VENDOR_TYPE", "vendor_type_name") data = [] sn = 1 for item in vendorList: itemData = [] itemData.append(sn) sn = sn + 1 itemData.append(item['name']) itemData.append(item['name_en']) itemData.append(item['abbr']) itemData.append(item['registe_addr']) itemData.append(item['contactor_name']) itemData.append(item['contactor_mobile']) itemData.append(item['vendor_type_name']) itemData.append(item['description']) itemData.append(item['status_name']) itemData.append(item['certifaction_date']) itemData.append(item['start_date']) itemData.append(item['end_date']) itemData.append(item['certifaction_desc']) data.append(itemData) struct = "SN, 供应商名称, 供应商名称(英), 供应商缩写, 供应商地址, 联系人, 联系电话, 供应商类型, 供应商描述, 供应商状态, 认证日期, 合作开始日期, 合作结束日期" path = {} path = excel.createTempFile("xls") excel.saveExcel(path['path'], struct, data) logInfo = " %s 下载了供应商清单 " % self.objUserInfo['name'] operation_log(self.db).addLog(self.GetUserInfo(), "vendorManage", logInfo, 0) self.response(path)
def exportStationInfo(self, lid): sql = "select st.id, st.code, st.name, st.ip_address" sql += " from pis.station st" sql += " inner join pis.station_line sl on sl.station_id = st.id" sql += " where sl.line_id = %s " % lid sql += " order by st.code" cur = self.db.getCursor() cur.execute(sql) rows = cur.fetchall() key = ['id', 'code', 'name', 'ip_address'] data = [] sn = 1 for item in rows: station = dict(zip(key, item)) data.append( [sn, station['code'], station['name'], station['ip_address']]) sn = sn + 1 sql = " select lc.code, lc.name, lc.ip_address" sql += " from pis.controller lc" sql += " where lc.install_id = %s and lc.install_type >= '2' and lc.install_type <= '4' " % station[ 'id'] sql += " order by lc.code " cur.execute(sql) rowsdata = cur.fetchall() key2 = ['code', 'name', 'ip_address'] for iteminfo in rowsdata: controller = dict(zip(key2, iteminfo)) data.append([ sn, '', '', '', controller['code'], controller['name'], controller['ip_address'] ]) sn = sn + 1 struct = "SN, 车站编号, 车站名称, 服务器地址, 控制器编号, 控制器类型, 控制器地址" path = {} path = excel.createTempFile("xls") excel.saveExcel(path['path'], struct, data) logInfo = " %s 下载了车站信息 " % self.objUserInfo['name'] operation_log(self.db).addLog(self.GetUserInfo(), "listManage", logInfo, 0) self.response(path)
def exportToExcel(self, rowdata): key = [ 'id', 'name', 'name_en', 'abbr', 'abbr_en', 'organization_type', 'registe_date', 'registe_addr', 'current_addr', 'business_scope', 'social_credit_code', 'legal_representative', 'legal_id_type', 'legal_id_no', 'contactor_name', 'contactor_mobile', 'logo_file', 'description', 'system_user_id' ] organizationList = [] for i, item in enumerate(rowdata): organizationInfo = dict(zip(key, item)) organizationList.append(organizationInfo) cur = self.db.getCursor() getDataDict(cur, organizationList, "organization_type", "ORGANIZATION_TYPE", "organization_type_name") data = [] sn = 1 for item in organizationList: itemData = [] itemData.append(sn) sn = sn + 1 itemData.append(item['name']) itemData.append(item['name_en']) itemData.append(item['abbr']) itemData.append(item['abbr_en']) itemData.append(item['organization_type_name']) itemData.append(item['registe_date']) itemData.append(item['registe_addr']) itemData.append(item['current_addr']) itemData.append(item['business_scope']) itemData.append(item['social_credit_code']) itemData.append(item['legal_representative']) itemData.append(item['contactor_name']) itemData.append(item['contactor_mobile']) itemData.append(item['description']) data.append(itemData) struct = "SN, 名称, 名称(英), 中文缩写, 英文缩写, 类型, 注册日期, 注册地址, 当前地址, 经营范围, 社会信用代码, 法人代表, 联系人员, 电话号码, 描述" path = {} path = excel.createTempFile("xls") excel.saveExcel(path['path'], struct, data) logInfo = " %s 下载了组织团体清单 " % self.objUserInfo['name'] operation_log(self.db).addLog(self.GetUserInfo(), "organizationManage", logInfo, 0) self.response(path)
def exportToExcel(self, rowdata): key = [ 'id', 'name', 'code', 'serial_no', 'device_type', 'vendor', 'mac_addr', 'install_date', 'install_batch', 'install_type', 'install_id', 'status', 'addr' ] moduleList = [] for i, item in enumerate(rowdata): logInfo = dict(zip(key, item)) moduleList.append(logInfo) cur = self.db.getCursor() utils.getDataDict(cur, moduleList, "device_type", "GPS_MODULE_DEVICE_TYPE", "device_type_name") utils.getDataDict(cur, moduleList, "install_type", "GPS_MODULE_INSTALL_TYPE", "install_type_name") utils.getDataDict(cur, moduleList, "status", "GPS_MODULE_STATUS", "status_name") data = [] sn = 1 for module in moduleList: itemData = [] itemData.append(sn) sn = sn + 1 itemData.append(module['name']) itemData.append(module['code']) itemData.append(module['serial_no']) itemData.append(module['device_type_name']) itemData.append(module['vendor']) itemData.append(module['mac_addr']) itemData.append(module['install_date']) itemData.append(module['install_batch']) itemData.append(module['install_type_name']) itemData.append(module['status_name']) itemData.append(module['addr']) data.append(itemData) struct = "SN, 名称, 编号, 序列号, 设备类型, 厂家, MAC地址, 安装日期, 安装批次, 安装类型, 状态, 最新位置" path = {} path = excel.createTempFile("xls") excel.saveExcel(path['path'], struct, data) logInfo = " %s 下载了定位模块清单 " % self.objUserInfo['name'] operation_log(self.db).addLog(self.GetUserInfo(), "gpsModuleManage", logInfo, 0) return path
def exportTrainInfo(self, lid): sql = "select t.id, t.code, t.name" sql += " from pis.train t" sql += " where t.line_id = %s " % lid sql += " order by t.sort" cur = self.db.getCursor() cur.execute(sql) rows = cur.fetchall() key = ['id', 'code', 'name'] data = [] sn = 1 for item in rows: train = dict(zip(key, item)) sql = " select lc.code, lc.ip_address" sql += " from pis.controller lc" sql += " where lc.install_id = %s and lc.install_type >= '0' and lc.install_type <= '1' " % train[ 'id'] sql += " order by lc.code " cur.execute(sql) rowsdata = cur.fetchall() data.append([ sn, train['code'], train['name'], rowsdata[0][0], rowsdata[0][1], rowsdata[1][0], rowsdata[1][1] ]) sn = sn + 1 struct = "SN, 列车编号, 列车名称, 车头控制器编号, 车头控制器地址, 车尾控制器编号, 车尾控制器地址" path = {} path = excel.createTempFile("xls") excel.saveExcel(path['path'], struct, data) logInfo = " %s 下载了列车控制器信息 " % self.objUserInfo['name'] operation_log(self.db).addLog(self.GetUserInfo(), "listManage", logInfo, 0) self.response(path)
def exportToExcel(self, structs, rowdata): bulletinList = [] bulletinList = ConvertDataToTuple(structs, rows) cur = self.db.getCursor() utils.getDataDict(cur, bulletinList, "device_type", "GPS_MODULE_DEVICE_TYPE", "device_type_name") utils.getDataDict(cur, bulletinList, "install_type", "GPS_MODULE_INSTALL_TYPE", "install_type_name") utils.getDataDict(cur, bulletinList, "status", "GPS_MODULE_STATUS", "status_name") data = [] sn = 1 for module in bulletinList: itemData = [] itemData.append(sn) sn = sn + 1 itemData.append(module['name']) itemData.append(module['code']) itemData.append(module['serial_no']) itemData.append(module['device_type_name']) itemData.append(module['vendor']) itemData.append(module['mac_addr']) itemData.append(module['install_date']) itemData.append(module['install_batch']) itemData.append(module['install_type_name']) itemData.append(module['status_name']) itemData.append(module['addr']) data.append(itemData) struct = "SN, 名称, 编号, 序列号, 设备类型, 厂家, MAC地址, 安装日期, 安装批次, 安装类型, 状态, 最新位置" path = {} path = excel.createTempFile("xls") excel.saveExcel(path['path'], struct, data) logInfo = " %s 下载了定位模块清单 " % self.objUserInfo['name'] operation_log(self.db).addLog(self.GetUserInfo(), "oaBulletinBoardManager", logInfo, 0) return path
def exportToExcel(self, rowdata): key = ['id', 'project_name', 'project_amount', 'sign_date', 'sign_addr', 'parta_id', 'parta_code', 'parta_man_name', 'parta_title', 'partb_id', 'partb_code', 'partb_man_name', 'partb_title', 'parta_name', 'partb_name'] rsuList = [] for i, item in enumerate(rowdata): rsuInfo = dict(zip(key, item)) rsuList.append(rsuInfo) data = [] sn = 1 for module in moduleList: itemData = [] itemData.append( sn ) sn = sn + 1 itemData.append( module['project_name'] ) itemData.append( module['project_amount'] ) itemData.append( module['sign_date'] ) itemData.append( module['sign_addr'] ) itemData.append( module['parta_name'] ) itemData.append( module['parta_code'] ) itemData.append( module['parta_man_name']) itemData.append( module['parta_title'] ) itemData.append( module['partb_name'] ) itemData.append( module['partb_code'] ) itemData.append( module['partb_man_name']) itemData.append( module['partb_title'] ) data.append(itemData) struct = "SN, 项目名称, 项目金额, 签订日期, 签订地点, 甲方名称, 甲方合同号, 甲方签署人, 甲方签署人职务, 乙方名称, 乙方合同号, 乙方签署人, 乙方签署人职务" path = {} path = excel.createTempFile("xls") excel.saveExcel(path['path'], struct, data ) logInfo = " %s 下载了RSU项目清单 "%self.objUserInfo['name'] operation_log(self.db).addLog(self.GetUserInfo(), "rsuProjectManage", logInfo, 0) return path
def exportToExcel(self, rowdata): key = [ 'id', 'create_time', 'update_time', 'create_id', 'update_id', 'file_name', 'file_path', 'uploader_id', 'uploader_name', 'upload_date', 'video_type' ] fileList = [] for item in rowdata: programInfo = dict(zip(key, item)) fileList.append(programInfo) data = [] sn = 1 for item in fileList: itemData = [] itemData.append(sn) sn = sn + 1 itemData.append(item['file_name']) itemData.append(item['uploader_name']) itemData.append(item['upload_date']) if item['video_type'] == '1': itemData.append('节目视频') else: itemData.append('安全垫片') data.append(itemData) struct = "SN, 文件名称, 上传人姓名, 上传日期, 文件类型 " path = {} path = excel.createTempFile("xls") excel.saveExcel(path['path'], struct, data) logInfo = " %s 下载了节目文件清单 " % self.objUserInfo['name'] operation_log(self.db).addLog(self.GetUserInfo(), "programFileManage", logInfo, 0) self.response(path)
def exportToExcel(self, rowdata): key = [ 'id', 'code', 'name', 'name_en', 'value_type', 'value_s', 'value_i', 'value_f', 'description', 'value_type_name', 'value' ] itemList = [] for i, item in enumerate(rowdata): itemInfo = dict(zip(key, item)) itemList.append(itemInfo) data = [] sn = 1 for item in vendorList: itemData = [] itemData.append(sn) sn = sn + 1 itemData.append(item['code']) itemData.append(item['name']) itemData.append(item['name_en']) itemData.append(item['value_type_name']) itemData.append(item['value']) itemData.append(item['status_name']) itemData.append(item['description']) data.append(itemData) struct = "SN, 属性代码, 属性名称, 属性名称(英), 属性类型, 属性值, 属性描述" path = {} path = excel.createTempFile("xls") excel.saveExcel(path['path'], struct, data) logInfo = " %s 下载了属性清单 " % self.objUserInfo['name'] operation_log(self.db).addLog(self.GetUserInfo(), "propertyManage", logInfo, 0) self.response(path)
def exportToExcel(self, rowdata): key = ['id', 'operation_id1', 'operation_id2', 'message_type', 'content', 'sender_id', 'sender_name', 'send_date', 'send_time', 'send_status'] messageList = [] for i, item in enumerate(rowdata): messageInfo = dict(zip(key, item)) messageList.append(messageInfo) cur = self.db.getCursor() utils.getDataDict(cur, messageList, "send_status", "PROGRAM_SEND_STATUS", "send_status_name") utils.getDataDict(cur, messageList, "message_type", "MESSAGE_TYPE", "message_type_name") data = [] sn = 1 for messageInfo in messageList: itemData = [] itemData.append( sn ) sn = sn + 1 itemData.append( messageInfo['sender_name'] ) itemData.append( messageInfo['send_date'] ) itemData.append( messageInfo['send_time']) itemData.append( messageInfo['message_type_name'] ) itemData.append( messageInfo['content'] ) itemData.append( messageInfo['send_status_name'] ) data.append(itemData) struct = "SN, 发送方名称, 发送日期, 发送时间, 消息类别, 消息正文, 发送状态" path = {} path = excel.createTempFile("xls") excel.saveExcel(path['path'], struct, data ) logInfo = " %s 下载了消息清单 "%self.objUserInfo['name'] operation_log(self.db).addLog(self.GetUserInfo(), "messageListManage", logInfo, 0) self.response(path)
def exportToExcel(self, rowdata): key = [ 'id', 'code', 'name', 'name_en', 'abbr_en', 'description', 'system_user_id' ] itemList = [] for i, item in enumerate(rowdata): itemInfo = dict(zip(key, item)) itemList.append(itemInfo) data = [] sn = 1 for item in itemList: itemData = [] itemData.append(sn) sn = sn + 1 itemData.append(item['name']) itemData.append(item['name_en']) itemData.append(item['abbr_en']) itemData.append(item['code']) itemData.append(item['description']) data.append(itemData) struct = "SN, 中文名称, 英文名称, 英文缩写, 类型编号, 设备说明" path = {} path = excel.createTempFile("xls") excel.saveExcel(path['path'], struct, data) logInfo = " %s 下载了设备类型清单 " % self.objUserInfo['name'] operation_log(self.db).addLog(self.GetUserInfo(), "propertyManage", logInfo, 0) self.response(path)
def exportToExcel(self, rowdata): key = [ 'id', 'code', 'name', 'name_en', 'description', 'system_user_id' ] itemList = [] for i, item in enumerate(rowdata): itemInfo = dict(zip(key, item)) itemList.append(itemInfo) cur = self.db.getCursor() data = [] sn = 1 for item in vendorList: itemData = [] itemData.append(sn) sn = sn + 1 itemData.append(item['code']) itemData.append(item['name']) itemData.append(item['name_en']) itemData.append(item['description']) data.append(itemData) struct = "SN, 组件编号, 名称, 名称(英), 描述" path = {} path = excel.createTempFile("xls") excel.saveExcel(path['path'], struct, data) logInfo = " %s 下载了组件清单 " % self.objUserInfo['name'] operation_log(self.db).addLog(self.GetUserInfo(), "componentManage", logInfo, 0) self.response(path)
def exportToExcel(self, rowdata): key = [ 'id', 'create_time', 'update_time', 'create_id', 'update_id', 'controller', 'date', 'time', 'type', 'content', 'controller_code', 'log_id', 'level', 'title', ] logList = [] for i, item in enumerate(rowdata): logInfo = dict(zip(key, item)) logList.append(logInfo) cur = self.db.getCursor() utils.getDataDict(cur, logList, "type", "CTRL_LOG_TYPE", "type_name") utils.getDataDict(cur, logList, "level", "CTRL_LOG_LEVEL", "level_name") data = [] sn = 1 for logInfo in logList: if 'type_name' not in logInfo: logInfo['type_name'] = "" if 'level_name' not in logInfo: logInfo['level_name'] = "" itemData = [] itemData.append(sn) sn = sn + 1 itemData.append(logInfo['controller_code']) # 控制器编号 itemData.append(logInfo['date'] + ' ' + logInfo['time']) # 日志日期 itemData.append(logInfo['level_name']) # 日志级别 itemData.append(logInfo['type_name']) # 日志类型 itemData.append(logInfo['title']) # 日志标题 itemData.append(logInfo['content']) # 日志内容 data.append(itemData) struct = "SN, 控制器编号, 时间, 级别, 类型, 标题, 内容" path = {} path = excel.createTempFile("xls") excel.saveExcel(path['path'], struct, data) logInfo = " %s 下载了控制器日志清单 " % self.objUserInfo['name'] operation_log(self.db).addLog(self.GetUserInfo(), "logManage", logInfo, 0) self.response(path)
def exportToExcel(self, rowdata, flag): if flag: key = [ 'id', 'create_time', 'update_time', 'create_id', 'update_id', 'code', 'name', 'uploader_id', 'uploader_name', 'upload_date', 'file_path', 'file_name', 'sender_id', 'sender_name', 'send_date', 'send_time', 'send_status' ] else: key = [ 'id', 'create_time', 'update_time', 'create_id', 'update_id', 'code', 'name', 'uploader_id', 'uploader_name', 'upload_date', 'file_path', 'file_name' ] messageList = [] for item in rowdata: messageInfo = dict(zip(key, item)) messageList.append(messageInfo) if flag == False: cur = self.db.getCursor() utils.getDataDict(cur, messageList, "send_status", "PROGRAM_SEND_STATUS", "send_status_name") data = [] sn = 1 for item in messageList: if 'send_status_name' not in item: item['send_status_name'] = "未发送" itemData = [] itemData.append(sn) sn = sn + 1 itemData.append(item['name']) itemData.append(item['uploader_name']) itemData.append(item['upload_date']) if flag == False: itemData.append(item['sender_name']) itemData.append(item['send_date']) itemData.append(item['send_time']) itemData.append(item['send_status_name']) data.append(itemData) struct = "SN, 文件名称, 上传人姓名, 上传日期 " if flag == False: struct += ", 下发人姓名, 发送日期, 发送时间, 发送状态" path = {} path = excel.createTempFile("xlsx") # logI("exportToExcel path:", path) excel.saveExcel(path['path'], struct, data) logInfo = " %s 下载了版式文件清单 " % self.objUserInfo['name'] operation_log(self.db).addLog(self.GetUserInfo(), "listManage", logInfo, 0) self.response(path)