class CataloguedPage: def __init__(self, loginName, loginPwd): self.rp = RequestsPage() self.ep = ElibPage(loginName, loginPwd) def CataloguedForQuery(self): """ 编目管理书目列表功能验证 :return: None """ res = self.rp.sendRequest('POST', self.ep.getUrl() + '/service/api/e/catalog/catalogue/list', { 'userToken': self.ep.getUserToken(), 'libid': self.ep.getLibid(), 'pageNumber': 1, 'pageSize': 15, 'userType': 1, 'dateType': 1 }).json() print(res) if 'message' in res: if res['message'] == '操作成功': print("编目管理书目列表查询成功") # pass else: print("编目管理书目列表查询出错") else: print("编目管理书目列表查询出错", res) def CataloguedForAdd(self): """ 新增编目功能验证 :return: marctyid 书目编号,定位要编目的书目记录 """ data = {"userToken": self.ep.getUserToken(), "marcfbid": self.ep.getFblxid(isMore=False), "simpleList": [ {"fieldName": "分类号", "marcField": "690a", "content": "EC-7", "isEmpty": 1, "sort": 1}, {"fieldName": "并列正题名", "marcField": "510a", "content": "", "isEmpty": 1, "sort": 2}, {"fieldName": "正题名拼音", "marcField": "2009", "content": "", "isEmpty": 1, "sort": 3}, {"fieldName": "国内订购号", "marcField": "092b", "content": "", "isEmpty": 1, "sort": 4}, {"fieldName": "语种", "marcField": "101a", "content": "", "isEmpty": 1, "sort": 5}, {"fieldName": "期刊价格", "marcField": "011d", "content": "", "isEmpty": 1, "sort": 6}, {"fieldName": "ISBN", "marcField": "010a", "content": "508", "isEmpty": 0, "sort": 7}, {"fieldName": "责任者拼音", "marcField": "7019", "content": "", "isEmpty": 1, "sort": 8}, {"fieldName": "副题名", "marcField": "200e", "content": "", "isEmpty": 1, "sort": 9}, {"fieldName": "价格", "marcField": "010d", "content": "", "isEmpty": 1, "sort": 10}, {"fieldName": "版次", "marcField": "205a", "content": "", "isEmpty": 1, "sort": 11}, {"fieldName": "正题名", "marcField": "200a", "content": "这是正题名", "isEmpty": 0, "sort": 12}, {"fieldName": "出版地", "marcField": "210a", "content": "", "isEmpty": 1, "sort": 13}, {"fieldName": "其他责任者", "marcField": "200g", "content": "", "isEmpty": 1, "sort": 14}, {"fieldName": "页码", "marcField": "215a", "content": "", "isEmpty": 1, "sort": 15}, {"fieldName": "统一书刊号", "marcField": "091a", "content": "", "isEmpty": 1, "sort": 16}, {"fieldName": "分辑名", "marcField": "200i", "content": "", "isEmpty": 1, "sort": 17}, {"fieldName": "版本与书目史附注", "marcField": "305a", "content": "", "isEmpty": 1, "sort": 18}, {"fieldName": "内容附注", "marcField": "327a", "content": "", "isEmpty": 1, "sort": 19}, {"fieldName": "一般性附注", "marcField": "300a", "content": "", "isEmpty": 1, "sort": 20}, {"fieldName": "丛编题名", "marcField": "225a", "content": "", "isEmpty": 1, "sort": 21}, {"fieldName": "国外订购号", "marcField": "092c", "content": "", "isEmpty": 1, "sort": 22}, {"fieldName": "摘要", "marcField": "330a", "content": "", "isEmpty": 1, "sort": 23}, {"fieldName": "尺寸", "marcField": "215e", "content": "", "isEmpty": 1, "sort": 24}, {"fieldName": "责任者", "marcField": "200f", "content": "", "isEmpty": 1, "sort": 25}, {"fieldName": "相关题名附注", "marcField": "312a", "content": "", "isEmpty": 1, "sort": 26}, {"fieldName": "出版社", "marcField": "210c", "content": "", "isEmpty": 1, "sort": 27}, {"fieldName": "附件", "marcField": "215b", "content": "", "isEmpty": 1, "sort": 28}, {"fieldName": "分辑号", "marcField": "200h", "content": "", "isEmpty": 1, "sort": 29}, {"fieldName": "文献类型", "marcField": "200b", "content": "", "isEmpty": 1, "sort": 30}, {"fieldName": "丛编责任者", "marcField": "225f", "content": "", "isEmpty": 1, "sort": 31}, {"fieldName": "书目控制号", "marcField": "001", "content": "012020", "isEmpty": 1, "sort": 32}, {"fieldName": "出版日期", "marcField": "210d", "content": "", "isEmpty": 1, "sort": 33}, {"fieldName": "ISRC", "marcField": "016a", "content": "", "isEmpty": 1, "sort": 34}, {"fieldName": "主题词", "marcField": "606a", "content": "", "isEmpty": 1, "sort": 35}, {"fieldName": "ISSN", "marcField": "011a", "content": "", "isEmpty": 1, "sort": 36}, {"fieldName": "出版周期", "marcField": "326a", "content": "", "isEmpty": 1, "sort": 37}, {"fieldName": "封面题名", "marcField": "512a", "content": "", "isEmpty": 1, "sort": 38}, {"fieldName": "并列题名", "marcField": "200d", "content": "", "isEmpty": 1, "sort": 39}] } res = self.rp.sendRequest('JSON', self.ep.getUrl() + '/service/api/e/catalog/catalogue/simple/save', json.dumps(data)).json() if 'message' in res: if res['message'] == '操作成功!': print("新增编目成功") return res['data']['marctyid'] else: print("新增编目出错") else: print("新增编目出错", res) def CataloguedForMod(self, cata): """ 修改编目功能验证 marctyid:书目编号,定位要编目的书目记录 :return: None """ data = {"userToken": self.ep.getUserToken(), "marcfbid": self.ep.getFblxid(isMore=False), "marctyid": cata, "simpleList": [ {"fieldName": "分类号", "marcField": "690a", "content": "EC-7", "isEmpty": 1, "sort": 1}, {"fieldName": "并列正题名", "marcField": "510a", "content": "", "isEmpty": 1, "sort": 2}, {"fieldName": "正题名拼音", "marcField": "2009", "content": "", "isEmpty": 1, "sort": 3}, {"fieldName": "国内订购号", "marcField": "092b", "content": "", "isEmpty": 1, "sort": 4}, {"fieldName": "语种", "marcField": "101a", "content": "", "isEmpty": 1, "sort": 5}, {"fieldName": "期刊价格", "marcField": "011d", "content": "", "isEmpty": 1, "sort": 6}, {"fieldName": "ISBN", "marcField": "010a", "content": "5021", "isEmpty": 0, "sort": 7}, {"fieldName": "责任者拼音", "marcField": "7019", "content": "", "isEmpty": 1, "sort": 8}, {"fieldName": "副题名", "marcField": "200e", "content": "", "isEmpty": 1, "sort": 9}, {"fieldName": "价格", "marcField": "010d", "content": "", "isEmpty": 1, "sort": 10}, {"fieldName": "版次", "marcField": "205a", "content": "", "isEmpty": 1, "sort": 11}, {"fieldName": "正题名", "marcField": "200a", "content": "5021", "isEmpty": 0, "sort": 12}, {"fieldName": "出版地", "marcField": "210a", "content": "", "isEmpty": 1, "sort": 13}, {"fieldName": "其他责任者", "marcField": "200g", "content": "", "isEmpty": 1, "sort": 14}, {"fieldName": "页码", "marcField": "215a", "content": "", "isEmpty": 1, "sort": 15}, {"fieldName": "统一书刊号", "marcField": "091a", "content": "", "isEmpty": 1, "sort": 16}, {"fieldName": "分辑名", "marcField": "200i", "content": "", "isEmpty": 1, "sort": 17}, {"fieldName": "版本与书目史附注", "marcField": "305a", "content": "", "isEmpty": 1, "sort": 18}, {"fieldName": "内容附注", "marcField": "327a", "content": "", "isEmpty": 1, "sort": 19}, {"fieldName": "一般性附注", "marcField": "300a", "content": "", "isEmpty": 1, "sort": 20}, {"fieldName": "丛编题名", "marcField": "225a", "content": "", "isEmpty": 1, "sort": 21}, {"fieldName": "国外订购号", "marcField": "092c", "content": "", "isEmpty": 1, "sort": 22}, {"fieldName": "摘要", "marcField": "330a", "content": "", "isEmpty": 1, "sort": 23}, {"fieldName": "尺寸", "marcField": "215e", "content": "", "isEmpty": 1, "sort": 24}, {"fieldName": "责任者", "marcField": "200f", "content": "", "isEmpty": 1, "sort": 25}, {"fieldName": "相关题名附注", "marcField": "312a", "content": "", "isEmpty": 1, "sort": 26}, {"fieldName": "出版社", "marcField": "210c", "content": "", "isEmpty": 1, "sort": 27}, {"fieldName": "附件", "marcField": "215b", "content": "", "isEmpty": 1, "sort": 28}, {"fieldName": "分辑号", "marcField": "200h", "content": "", "isEmpty": 1, "sort": 29}, {"fieldName": "文献类型", "marcField": "200b", "content": "", "isEmpty": 1, "sort": 30}, {"fieldName": "丛编责任者", "marcField": "225f", "content": "", "isEmpty": 1, "sort": 31}, {"fieldName": "书目控制号", "marcField": "001", "content": "012020", "isEmpty": 1, "sort": 32}, {"fieldName": "出版日期", "marcField": "210d", "content": "", "isEmpty": 1, "sort": 33}, {"fieldName": "ISRC", "marcField": "016a", "content": "", "isEmpty": 1, "sort": 34}, {"fieldName": "主题词", "marcField": "606a", "content": "", "isEmpty": 1, "sort": 35}, {"fieldName": "ISSN", "marcField": "011a", "content": "", "isEmpty": 1, "sort": 36}, {"fieldName": "出版周期", "marcField": "326a", "content": "", "isEmpty": 1, "sort": 37}, {"fieldName": "封面题名", "marcField": "512a", "content": "", "isEmpty": 1, "sort": 38}, {"fieldName": "并列题名", "marcField": "200d", "content": "", "isEmpty": 1, "sort": 39}] } res = self.rp.sendRequest('JSON', self.ep.getUrl() + '/service/api/e/catalog/catalogue/simple/save', json.dumps(data)).json() if 'message' in res: if res['message'] == '操作成功!': print("修改编目成功") else: print("修改编目出错") else: print("修改编目出错", res) def CataloguedForDel(self, cata): """ 删除编目功能验证 marctyid:书目编号,定位要编目的书目记录 :return: None """ res = self.rp.sendRequest('POST', self.ep.getUrl() + '/service/api/e/catalog/catalogue/delete', { 'userToken': self.ep.getUserToken(), 'marctyIds': cata }).json() if 'message' in res: if res['message'] == '操作成功!': print("删除编目成功") else: print("删除编目出错") else: print("删除编目出错", res)
class InterviewPage: def __init__(self, loginName, loginPwd): self.rp = RequestsPage() self.ep = ElibPage(loginName, loginPwd) def ZDManage(self): print(self.subscriptionBooksImport()) print(self.subscriptionBooks()) print(self.directSubscription()) print(self.subscriptionVerify()) print(self.directVerify()) def subscriptionBooksImport(self): """ 征订书目导入功能 :return: """ with open('D:\Cache\Project\TJProject\list.xls', mode="rb+") as f: # 打开文件 file = { "excel": ('list.xls', f.read()), # 引号的file是接口的字段,后面的是文件的名称、文件的内容 "userToken": self.ep.getUserToken(), # 如果接口中有其他字段也可以加上 } res = self.rp.sendRequest('FILE', self.ep.getUrl() + '/service/api/e/interview/file/zdsmI', file).json() r = self.rp.sendRequest('POST', self.ep.getUrl() + '/service/api/e/interview/zdsm/import/main', { 'userToken': self.ep.getUserToken(), 'path': res['data']['path'], 'marcfbid': self.ep.getFblxid(isMore=False), 'zdpcid': self.ep.getZdpcid(isMore=False), 'isbn': 'ISBN,0', 'ztming': '正题名,0', 'zrsming': '责任者, 1', 'cbzhe': '出版社, 1', 'cbrqi': '出版日期, 1', 'cbdi': '出版社, 1', 'flhao': '分类号, 1', 'jge': '价格, 1' }).json() return r['message'] def subscriptionBooks(self): """ 征订书目预订功能 :return: """ # 先在 预订单管理 设置第一个为工作预定单 self.rp.sendRequest('POST', self.ep.getUrl() + '/service/api/e/interview/work/save', { 'userToken': self.ep.getUserToken(), 'ydpcid': self.ep.getYdd()[0] }) # 获取征订目录列表 res = self.rp.sendRequest('POST', self.ep.getUrl() + '/service/api/e/interview/zdpc/search', { 'userToken': self.ep.getUserToken(), 'pageNumber': 1, 'pageSize': 50 }).json() # 获取图书信息 r = self.rp.sendRequest('POST', self.ep.getUrl() + '/service/api/e/interview/zdsm/search', { 'userToken': self.ep.getUserToken(), 'zdpcid': res['data']['dataList'][0]['zdpcid'], 'pageNumber': 1, 'pageSize': 50 }).json() # 判断图书信息中价格是否存在 price = 0 if 'jge' in dict(r): price = int(self.rp.matchNumber(r['data']['page']['dataList'][0]['jge'])) # 获取预订单信息 yd = self.rp.sendRequest('POST', self.ep.getUrl() + '/service/api/e/interview/yd/pcList', { 'userToken': self.ep.getUserToken() }).json() # 预订 result = self.rp.sendRequest('POST', self.ep.getUrl() + '/service/api/e/interview/yd/smSave', { 'userToken': self.ep.getUserToken(), 'cygName': yd['data'][0]['cygName'], 'ysName': yd['data'][0]['ysName'], 'marcid': r['data']['page']['dataList'][0]['marcid'], 'gysName': yd['data'][0]['gysName'], 'ydbhao': '', 'ydpcid': yd['data'][0]['ydpcid'], 'ceshu': 1, 'ydlaiyuan': '订购', 'yjhbid': self.ep.getHbList(isMore='NO'), 'jzleixing': '纸张', 'yuanjia': price, 'zdfangshi': '平装', 'ydhbid': self.ep.getHbList(isMore='NO'), 'juance': 1, 'jiage': price, 'fuzhu': '', 'zdpcdm': res['data']['dataList'][0]['zdpcdm'], 'ydpcdm': self.ep.getZdsmReserve(zdpcid=res['data']['dataList'][0]['zdpcid'], zdsmid=r['data']['page']['dataList'][0]['zdsmid']), 'ysCode': yd['data'][0]['ysCode'], 'zdpcid': self.ep.getZdpcid(isMore='NO'), 'gysCode': yd['data'][0]['gysCode'], 'ydleixing': '征订预订' }).json() print(result['message']) # 操作成功! def directSubscription(self): """ 直接预订功能 :return: """ # 先在 预订单管理 设置第一个为工作预定单 self.rp.sendRequest('POST', self.ep.getUrl() + '/service/api/e/interview/work/save', { 'userToken': self.ep.getUserToken(), 'ydpcid': self.ep.getYdd()[0] }) # 获取图书信息 res = self.rp.sendRequest('POST', self.ep.getUrl() + '/service/api/e/interview/yd/searchBook', { 'userToken': self.ep.getUserToken(), 'pageNumber': 1, 'pageSize': 50, 'flag': 1 }).json() # 征订书目-直接预订 r = self.ep.getZdsmReserve(marcid=res['data']['dataList'][0]['marcid']) # 预定 result = self.rp.sendRequest('POST', self.ep.getUrl() + '/service/api/e/interview/yd/smSave', { 'userToken': self.ep.getUserToken(), 'cygName': r['data']['cygName'], 'ysName': r['data']['ysName'], 'marcid': r['data']['marcid'], 'gysName': r['data']['gysName'], 'ydbhao': '', 'ydpcid': r['data']['ydpcid'], 'ceshu': 1, 'ydlaiyuan': '订购', 'yjhbid': self.ep.getHbList(isMore='NO'), 'jzleixing': '纸张', 'yuanjia': 0, 'zdfangshi': '平装', 'ydhbid': self.ep.getHbList(isMore='NO'), 'juance': 1, 'jiage': 0, 'fuzhu': '', 'ydpcdm': 1, 'ysCode': r['data']['ysCode'], 'gysCode': r['data']['gysCode'], 'ydleixing': '直接预订' }).json() print(result['message']) # 操作成功! 已超出预算金额,不能预订! def subscriptionVerify(self): """ 预订验收功能 :return: """ # 先在 验收单管理 设置第一个为工作验收单 self.rp.sendRequest('POST', self.ep.getUrl() + '/service/api/e/interview/work/save', { 'userToken': self.ep.getUserToken(), 'yspcid': self.ep.getYsd()[0] }) # 获取图书信息 res = self.rp.sendRequest('POST', self.ep.getUrl() + '/service/api/e/interview/yd/smSearch', { 'userToken': self.ep.getUserToken(), 'pageNumber': 1, 'pageSize': 50, 'from': 1, 'flag': 1 }).json() # 获取索书号 r = self.rp.sendRequest('POST', self.ep.getUrl() + '/service/api/e/interview/ys/curSshao', { 'userToken': self.ep.getUserToken(), 'marcid': res['data']['dataList'][0]['marcid'] }).json() # 验收 numList = list() for i in range(res['data']['dataList'][0]['ceshu']): numDict = dict() numDict['barcode'] = "TS" + str(random.randint(1, 10000)).zfill(5) numDict['libId'] = self.ep.getLibid() numDict['czId'] = self.ep.getCzid(isMore='NO') numDict['ltlxId'] = self.ep.getLtlxid(isMore='NO') numList.append(numDict) # '[' # '{"barcode": "test100", "libId": "2", "czId": "ebd840b69bc04948859cd05a4da638b3", "ltlxId": "1"},' # '{"barcode": "test101", "libId": "2", "czId": "ebd840b69bc04948859cd05a4da638b3", "ltlxId": "1"}' # ']', result = self.rp.sendRequest('POST', self.ep.getUrl() + '/service/api/e/interview/ys/smSave', { 'userToken': self.ep.getUserToken(), 'marcid': res['data']['dataList'][0]['marcid'], 'yslxing': '预订验收', 'yspcid': self.ep.getYsd()[0], 'collectionDtos': json.dumps(numList), 'yjhbid': self.ep.getHbList(isMore='NO'), 'yuanjia': res['data']['dataList'][0]['jiage'], 'cejia': res['data']['dataList'][0]['jiage'], 'ydlaiyuan': '订购', 'ydhbid': self.ep.getHbList(isMore='NO'), 'jiage': res['data']['dataList'][0]['jiage'], 'taojia': res['data']['dataList'][0]['jiage'], 'jzleixing': '纸张', 'zdfangshi': '平装', 'juance': 1, 'fuben': res['data']['dataList'][0]['ceshu'], 'sshao': r['data']['sshao'], 'ydRecord': res['data']['dataList'][0]['ydRecord'], 'ydsmid': res['data']['dataList'][0]['ydsmid'], 'ydjge': res['data']['dataList'][0]['jiage'] }).json() print(result['message']) def directVerify(self): """ 快捷验收功能 :return: """ # 先在 验收单管理 设置第一个为工作验收单 self.rp.sendRequest('POST', self.ep.getUrl() + '/service/api/e/interview/work/save', { 'userToken': self.ep.getUserToken(), 'yspcid': self.ep.getYsd()[0] }) # 获取图书信息 res = self.rp.sendRequest('POST', self.ep.getUrl() + '/service/api/e/interview/yd/searchBook', { 'userToken': self.ep.getUserToken(), 'pageNumber': 1, 'pageSize': 50, 'flag': 1 }).json() # 获取索书号 r = self.rp.sendRequest('POST', self.ep.getUrl() + '/service/api/e/interview/yd/searchBookByMarcid', { 'userToken': self.ep.getUserToken(), 'marcid': res['data']['dataList'][0]['marcid'] }).json() print(r['data']['sshao']) # 验收 numList = list() for i in range(res['data']['dataList'][0]['fuben']+1): numDict = dict() numDict['barcode'] = "TS" + str(random.randint(1, 10000)).zfill(5) numDict['libId'] = self.ep.getLibid() numDict['czId'] = self.ep.getCzid(isMore='NO') numDict['ltlxId'] = self.ep.getLtlxid(isMore='NO') numList.append(numDict) result = self.rp.sendRequest('POST', self.ep.getUrl() + '/service/api/e/interview/ys/smSave', { 'userToken': self.ep.getUserToken(), 'marcid': res['data']['dataList'][0]['marcid'], 'yslxing': '直接验收', 'yspcid': self.ep.getYsd()[0], 'collectionDtos': json.dumps(numList), 'yjhbid': self.ep.getHbList(isMore='NO'), 'yuanjia': r['data']['jge'], 'cejia': r['data']['jge'], 'ydlaiyuan': '订购', 'ydhbid': self.ep.getHbList(isMore='NO'), 'jiage': r['data']['jge'], 'taojia': r['data']['jge'], 'jzleixing': '纸张', 'zdfangshi': '平装', 'juance': 1, 'fuben': res['data']['dataList'][0]['fuben']+1, 'sshao': r['data']['sshao'], }).json() print(result['message'])