def test_cpzdcommit(self, gettokenfixture, bool, expect):
     s = gettokenfixture
     self.log.info("---采购申请转单提交---")
     r = SRMBase(s)
     try:
         msg_getRequestid = r.cp_zdpage("requestDetailRemark",
                                        "自动化导入")  # 查询目标采购申请
         Requestid = jsonpath.jsonpath(msg_getRequestid.json(),
                                       '$..purchaseRequestId')[0]
         Detailid = jsonpath.jsonpath(msg_getRequestid.json(),
                                      '$..requestDetailId')[0]
         self.log.info("获取采购申请ID:%s" % Requestid)
     except:
         self.log.error("自动化导入数据已耗尽")
     msg_allotDty = r.cp_zdallotDty(Requestid, Detailid)  # 分配采购申请
     Alloid = msg_allotDty.json()["data"][0]
     self.log.info("分配的ID是:%s" % msg_allotDty.json()["data"][0])
     msg_commit = r.cp_zdcommit(Requestid, Detailid, Alloid)  # 分配页面的提交
     self.log.info("提交的结果是:%s" % msg_commit.json())
     msg_traceid = r.cp_queryByCompanyVendor("500973", "6100",
                                             "A01")  # 获取可提交明细
     for jg in msg_traceid.json()['data']:
         if jg['requestAllotId'] == Alloid:
             break
     Tranceid = jg['requestTransferId']
     msg_jlcommit = r.cp_zdjlcommit(Tranceid, Detailid, Alloid)  # 转单页面的提交
     tempid = msg_jlcommit.json()["data"]["tempId"]
     self.log.info("获取的tempID是:%s" % tempid)
     msg_page = r.cp_ordertempPage(tempid)  # 根据tempid查询获取传参
     detailtempid = jsonpath.jsonpath(msg_page.json(), '$..detailTempId')[0]
     orderdetailid = jsonpath.jsonpath(msg_page.json(),
                                       '$..orderDetailId')[0]
     msg_put = r.cp_orderDetailEdit(tempid, detailtempid, Tranceid,
                                    orderdetailid)  #更新采购订单明细
     try:
         msg_jccommit = r.cp_cgsqjccommit(tempid, bool)  # 最后提交采购订单
         self.log.info("生成采购订单号是:%s" % msg_jccommit.json()["msg"])
     except:
         self.log.error("采购订单提交失败")
     msg = r.cp_orderpage("purchaseOrderNo", msg_jccommit.json()["msg"])
     status = jsonpath.jsonpath(msg.json(), '$..status')[0]
     assert msg.json()["data"]["total"] == 1
     assert status == expect
 def test_cpPurchase_cancel(self, gettokenfixture):
     s = gettokenfixture
     self.log.info("采购申请转单取消")
     r = SRMBase(s)
     data = r.cp_queryByCompanyVendor("500973", "6100", "A01")
     print(data.json())
     for i in data.json()['data']:
         if i['purchaseRequestNo'] == "purchaseRequestNo":
             break
     TransferId = i["requestTransferId"]
     batchFlag = i["batchFlag"]
     cancel = r.cpPurchase_cancel(batchFlag, TransferId)
     self.log.info("取消返回结果:%s" % cancel.text)
     msg = r.cp_zdqueryAllpage()
     reset = r.cp_zdcommit("8e926428-c823-418d-9264-28c823a18d03",
                           "448ad576-bcc5-4689-8ad5-76bcc5d68971",
                           "8ce3691f-136f-49c6-a369-1f136ff9c6a0")
     for j in msg.json()['data']:
         if j['purchaseRequestNo'] == "PR2021042100008":
             break
     assert j["purchaseRequestNo"] == "PR2021042100008"