def runFHPackageOrder(): envdata = request.get_json().get('envdata') print('orderId is: ' + envdata) try: vp = FHPackahequicklyOrder(FHPackageInfo1,envdata) resp = vp.run() print('resp is: ' + str(resp)) except: resp = cors_response({"success": False, "msg": '生成订单失败,请重新生成或者查看日志', "orderId": ''}) return resp
def runpebble(): vp = getcancelOrder() orderId = request.get_json().get('orderId') print('orderId is: ' + orderId) try: response = vp.runcase(orderId) resp = response except: resp = cors_response({"success": False, "data": None}) print("返回给客户端的Json是" + str(resp)) return resp
def sync_execUrlCheck(): file_name = request.args.get('file_name') or "testCase_portal.py" case_name = request.args.get('case_name') or "url检查接口(自定义)" version = request.args.get('version') or '10.19.0' env = request.args.get('env') or 'pre' print('version:', version, "env:", env) error_webhook = request.args.get( 'webhook' ) or "https://oapi.dingtalk.com/robot/send?access_token=ebb3a70ad93edff6d8a025fe85902d615dca48bbc537c18cb8ece746fc37b010" print(file_name, case_name, '\n', version, env, '\n') Common_params.version = version Common_params.env = env executor.submit(execUrlCheck, file_name, case_name, error_webhook, env) response = {"success": "true", "msg": "url批量检查中,请稍后[自动化报告列表]界面查看~~"} return cors_response(response)
def runpebble(): # url = "https://api.tuniu.com/res/pack/saveInternalHotel/app?c=%7B%22cc%22%3A1602%2C%22ct%22%3A20%2C%22dt%22%3A1%2C%22ov%22%3A20%2C%22p%22%3A19326%2C%22v%22%3A%2210.11.0%22%7D" # # param = { # # "hotel": { # # "hotelId": 711527, # # "checkIn": "2019-08-10", # # "checkOut": "2019-08-11", # # "adultNum": "2", # # "childNum": "0", # # "vendorId": 23690, # # "vendorRatePlanId": "304979059", # # "roomNum": 1, # # "roomId": 222126105 # # }, # # "packType": "2", # # "sessionId": "54cd52119c2a8ee71225315da472ff6f_", # # "operateType": "2", # # "replaceHotelUniqueFlag": "hotel|711527|true|222126105|0|23690|9401106|2019-07-29|2019-07-31|2|0" # # } # url = "https://api.tuniu.com/portal/home/list/v3?c=%7B%22cc%22%3A1602%2C%22ct%22%3A10%2C%22p%22%3A14588%2C%22ov%22%3A20%2C%22dt%22%3A0%2C%22v%22%3A%2210.12.0%22%7D&d=%7B%22pageLimit%22%3A10%2C%22bottomOffset%22%3A-1%2C%22currentPage%22%3A1%2C%22needPlay%22%3Atrue%2C%22width%22%3A750%2C%22deviceNum%22%3A%22c6777549d3dca9d907271ee6ac3d189df00fdb49%22%2C%22getRecommendFlag%22%3Afalse%2C%22moduleName%22%3A%22%E5%85%A8%E9%83%A8%22%2C%22moduleId%22%3A%2215539527%22%2C%22abTest%22%3A%22bi%22%2C%22sessionId%22%3A%228aa78300422a479677185ec2119c52eb_%22%2C%22uniqueKey%22%3A%229EA881B7-E104-412A-BD96-5B57413B75B3%22%2C%22isFirst%22%3Atrue%7D" vp = findInternalInterface() url = request.get_json().get('url') env = request.get_json().get('env') postparams = request.get_json().get('postparams') print('url is ' + url + "env is: " + env + " postparans is " + postparams) try: resp = vp.sendrequest(url, env, postparams) response = vp.getInternalInterfaceList(resp) resp =cors_response({"success": True, "pebble": response[0], "tsp": response[1]}) except: resp = cors_response({"success": False, "data": None}) print("返回给客户端的Json是" + str(resp)) return resp # @FindInternalInterface.route('/FindTsp', methods=['GET', 'POST']) # def runTsp(): # url = "https://api.tuniu.com/res/pack/saveInternalHotel/app?c=%7B%22cc%22%3A1602%2C%22ct%22%3A20%2C%22dt%22%3A1" \ # "%2C%22ov%22%3A20%2C%22p%22%3A19326%2C%22v%22%3A%2210.11.0%22%7D " # param = { # "hotel": { # "hotelId": 711527, # "checkIn": "2019-08-10", # "checkOut": "2019-08-11", # "adultNum": "2", # "childNum": "0", # "vendorId": 23690, # "vendorRatePlanId": "304979059", # "roomNum": 1, # "roomId": 222126105 # }, # "packType": "2", # "sessionId": "54cd52119c2a8ee71225315da472ff6f_", # "operateType": "2", # "replaceHotelUniqueFlag": "hotel|711527|true|222126105|0|23690|9401106|2019-07-29|2019-07-31|2|0" # } # vp = findInternalInterface() # resp = vp.sendrequest(url, 'prd', param) # Tsp = vp.getInternalInterfaceList(resp)[1] # return Tsp # if __name__ == "__main__": # vp = findInternalInterface() # # url1 = "https://api.tuniu.com/res/pack/getDefaultRecommend/app?d=%7B%22packType%22%3A%222%22%2C%22bookCityCode%22%3A1602%2C%22bookCityName%22%3A%22%E5%8D%97%E4%BA%AC%22%2C%22departCityCode%22%3A0%2C%22departCityName%22%3A%22%22%2C%22departDate%22%3A%222019-07-29%22%2C%22adultNum%22%3A2%2C%22childNum%22%3A0%2C%22isInternational%22%3A0%2C%22journeyType%22%3A2%2C%22journeyList%22%3A%5B%7B%22cabinType%22%3A1%2C%22startCityCode%22%3A0%2C%22startCityName%22%3A%22%22%2C%22destCityCode%22%3A200%2C%22destCityName%22%3A%22%E5%8C%97%E4%BA%AC%22%2C%22journeyDepartDate%22%3A%222019-07-29%22%2C%22journeyEndDate%22%3A%222019-07-31%22%7D%5D%2C%22sessionId%22%3A%2254cd52119c2a8ee71225315da472ff6f_%22%7D&c=%7B%22cc%22%3A1602%2C%22ct%22%3A20%2C%22dt%22%3A1%2C%22ov%22%3A20%2C%22p%22%3A19326%2C%22v%22%3A%2210.11.0%22%7D" # # # url3 = "https://api.tuniu.com/res/pack/getDefaultRecommend/app?d=%7B%22packType%22%3A%222%22%2C%22bookCityCode%22%3A1602%2C%22bookCityName%22%3A%22%E5%8D%97%E4%BA%AC%22%2C%22departCityCode%22%3A0%2C%22departCityName%22%3A%22%22%2C%22departDate%22%3A%222019-08-01%22%2C%22adultNum%22%3A2%2C%22childNum%22%3A0%2C%22isInternational%22%3A0%2C%22journeyType%22%3A2%2C%22journeyList%22%3A%5B%7B%22cabinType%22%3A1%2C%22startCityCode%22%3A0%2C%22startCityName%22%3A%22%22%2C%22destCityCode%22%3A200%2C%22destCityName%22%3A%22%E5%8C%97%E4%BA%AC%22%2C%22journeyDepartDate%22%3A%222019-08-01%22%2C%22journeyEndDate%22%3A%222019-08-03%22%7D%5D%2C%22sessionId%22%3A%2254b60a2f3b45e7cc657de6a800e07b36_%22%7D&c=%7B%22cc%22%3A1602%2C%22ct%22%3A20%2C%22dt%22%3A1%2C%22ov%22%3A20%2C%22p%22%3A11210%2C%22v%22%3A%2210.11.0%22%7D" # # url4 = "https://api.tuniu.com/portal/home/list/v3?c=%7B%22cc%22%3A1602%2C%22ct%22%3A10%2C%22p%22%3A14588%2C%22ov%22%3A20%2C%22dt%22%3A0%2C%22v%22%3A%2210.12.0%22%7D&d=%7B%22pageLimit%22%3A10%2C%22bottomOffset%22%3A-1%2C%22currentPage%22%3A1%2C%22needPlay%22%3Atrue%2C%22width%22%3A750%2C%22deviceNum%22%3A%22c6777549d3dca9d907271ee6ac3d189df00fdb49%22%2C%22getRecommendFlag%22%3Afalse%2C%22moduleName%22%3A%22%E5%85%A8%E9%83%A8%22%2C%22moduleId%22%3A%2215539527%22%2C%22abTest%22%3A%22bi%22%2C%22sessionId%22%3A%228aa78300422a479677185ec2119c52eb_%22%2C%22uniqueKey%22%3A%229EA881B7-E104-412A-BD96-5B57413B75B3%22%2C%22isFirst%22%3Atrue%7D" # # param ={"hotel":{"hotelId":711527,"checkIn":"2019-08-10","checkOut": "2019-08-11","adultNum":"2","childNum":"0","vendorId":23690,"vendorRatePlanId":"304979059","roomNum":1,"roomId":222126105 },"packType":"2","sessionId":"54cd52119c2a8ee71225315da472ff6f_","operateType":"2","replaceHotelUniqueFlag":"hotel|711527|true|222126105|0|23690|9401106|2019-07-29|2019-07-31|2|0"} # # param = { "hotel": { "hotelId": 711527, "checkIn": "2019-08-10", "checkOut": "2019-08-11", "adultNum": "2", "childNum": "0", "vendorId": 23690, "vendorRatePlanId": "304979059", "roomNum": 1, "roomId": 222126105 }, "packType": "2", "sessionId": "54cd52119c2a8ee71225315da472ff6f_", "operateType": "2", "replaceHotelUniqueFlag": "hotel|711527|true|222126105|0|23690|9401106|2019-07-29|2019-07-31|2|0" } # # vp = findInternalInterface() # # fullUrl1 = vp.composeUrl(url4, 'prd') # # fullUrl2 = vp.composeUrl(url2, 'prd', param) # resp1 = vp.sendrequest(url2, 'prd', param) # # resp2 = vp.sendrequest(url4, 'prd') # vp.getInternalInterfaceList(resp1) # # dependentPebbles = resp2['requestLogs']['dependentPebbles'] # # print("222222222" + str(dependentPebbles)) # # list = vp.getInternalInterfaceList(resp2) # # pebble = list[0] # # print("pebble" + str(len(pebble)) + str(pebble)) # # Tsp = list[1] # # print("tsp" + str(len(Tsp)) + str(Tsp)) # # pebblelist = resp2 # # TSPList = resp2 # # # # vp.getInternalInterfaceList(resp1) # # # vp.getInternalInterfaceList(resp2) # # vp.getIps() # # vp.getIpsbyCode('mob-res-pre') # # vp.getIpbyUrl(url4,'prd') # # vp.getIpbyUrl(url1) # url5 = "https://api.tuniu.com/res/pack/saveInternalFlight/app?c=%7B%22cc%22%3A1602%2C%22ct%22%3A20%2C%22dt%22%3A1%2C%22ov%22%3A20%2C%22p%22%3A14584%2C%22v%22%3A%2210.15.0%22%7D" # param5 = { # "adultNum": 1, # "childNum": 1, # "flight": { # "cabinCodes": "E#V", # "flightNos": "CZ6172#CZ6197", # "priceInfoId": "", # "queryId": "Y2l0eUtleXM9U0hBLVdVSCNXVUgtU0hBLGRlcGFydHVyZURhdGU9MjAxOS0wOS0xOSxkZXBhcnR1cmVEYXRlcz0wIzEscGFzc2VuZ2VyUXVhbnRpdHk9MSMxIzAjMCxwaHlzaWNhbENhYmluPW51bGw\u003d", # "specVendorId": "", # "vendorId": "1" # }, # "sessionId": "4eed619ff2ebfe31985d6462ef22d6d0_" # } # vp = findInternalInterface() # fullUrl2 = vp.composeUrl(url5, 'prd', param5) # resp1 = vp.sendrequest(url5, 'prd', param5) # vp.getInternalInterfaceList(resp1) # url2 = "https://api.tuniu.com/res/pack/saveInternalHotel/app?c=%7B%22cc%22%3A1602%2C%22ct%22%3A20%2C%22dt%22%3A1%2C%22ov%22%3A20%2C%22p%22%3A19326%2C%22v%22%3A%2210.11.0%22%7D" # param2 = { # "hotel": { # "hotelId": 711527, # "checkIn": "2019-08-10", # "checkOut": "2019-08-11", # "adultNum": "2", # "childNum": "0", # "vendorId": 23690, # "vendorRatePlanId": "304979059", # "roomNum": 1, # "roomId": 222126105 # }, # "packType": "2", # "sessionId": "54cd52119c2a8ee71225315da472ff6f_", # "operateType": "2", # "replaceHotelUniqueFlag": "hotel|711527|true|222126105|0|23690|9401106|2019-07-29|2019-07-31|2|0" # } # vp = findInternalInterface() # fullUrl2 = vp.composeUrl(url2, 'prd', param2) # resp1 = vp.sendrequest(url2, 'prd', param2) # vp.getInternalInterfaceList(resp1) # # # # # url4 = "https://api.tuniu.com/portal/home/list/v3?c=%7B%22cc%22%3A1602%2C%22ct%22%3A10%2C%22p%22%3A14588%2C%22ov%22%3A20%2C%22dt%22%3A0%2C%22v%22%3A%2210.12.0%22%7D&d=%7B%22pageLimit%22%3A10%2C%22bottomOffset%22%3A-1%2C%22currentPage%22%3A1%2C%22needPlay%22%3Atrue%2C%22width%22%3A750%2C%22deviceNum%22%3A%22c6777549d3dca9d907271ee6ac3d189df00fdb49%22%2C%22getRecommendFlag%22%3Afalse%2C%22moduleName%22%3A%22%E5%85%A8%E9%83%A8%22%2C%22moduleId%22%3A%2215539527%22%2C%22abTest%22%3A%22bi%22%2C%22sessionId%22%3A%228aa78300422a479677185ec2119c52eb_%22%2C%22uniqueKey%22%3A%229EA881B7-E104-412A-BD96-5B57413B75B3%22%2C%22isFirst%22%3Atrue%7D" # # vp = findInternalInterface() # # fullUrl2 = vp.composeUrl(url4, 'pre') # # resp1 = vp.sendrequest(url4, 'prd') # # vp.getInternalInterfaceList(resp1)
def sync_iosuitest(): case_name = request.args.get('case_name') or "ios界面自动化" executor.submit(iosUItest, case_name) response = {"success": "true", "msg": "ios界面自动化脚本后台运行中,请稍后[自动化报告列表]界面查看~~"} return cors_response(response)
def run(self): """ 机酒打包业务流程启动,action字段代表这一串业务里可以在哪里终止,预留字段 :param action: 业务终止位置 :return: 返回测试结果 """ try: ###先进行登陆,获取sessionId self.Begin_Session.setReqParam() self.Begin_Session.sendrequest(self.envdata) sessionId = self.Begin_Session.getSessionId() self.Login.setReqParam(sessionId) self.Login.sendrequest(self.envdata) """ 先生成随机出发日期和返回日期 出发日期距离当前时间1个月至1个半月,不能占用距离较近的资源 返回日期:出发日期后随机加1-5天 """ now = datetime.datetime.now() start_delta = datetime.timedelta(days=30) start_days = now + start_delta startint = random.randint(0, 15) start_delta1 = datetime.timedelta(days=startint) journeyDepartDate = (start_days + start_delta1) logging.debug( "行程开始时间是:" + "journeyDepartDate:{}".format(journeyDepartDate.date())) touristduration = random.randint(1, 5) end_delta11 = datetime.timedelta(days=touristduration) journeyEndDate = (journeyDepartDate + end_delta11) logging.debug( "行程返回时间是:" + "journeyEndDate:{}".format(journeyEndDate.date())) ###推荐接口如果没有查询到数据会在185秒(推荐缓存3分钟加5秒)之后开启第2次查询 i = 1 while i < 3: self.FHPackage_getDefaultRecommend.setReqParam( self.tdata['JourneyInfoList']['bookCityCode'], self.tdata['JourneyInfoList']['bookCityName'], self.tdata['JourneyInfoList'][ "departCityCode"], self.tdata['JourneyInfoList'][ "departCityName"], str(journeyDepartDate.date()), self.tdata['JourneyInfoList']["adultNum"], self.tdata['JourneyInfoList']["childNum"], 0, 2, self.tdata['JourneyInfoList']["cabinType"], self.tdata['JourneyInfoList'][ "departCityCode"], self.tdata['JourneyInfoList'][ "departCityName"], self.tdata['JourneyInfoList']["destCityCode"], self.tdata['JourneyInfoList']["destCityName"], str(journeyDepartDate.date()), str(journeyEndDate.date()), sessionId) self.FHPackage_getDefaultRecommend.sendrequest(self.envdata) ResComResult = self.FHPackage_getDefaultRecommend.checkFHResourceComplete() if ResComResult == True: logging.debug("推荐接口查询的信息信息完整") break else: i = i + 1 logging.debug("推荐接口查询的信息不全重新执行,总共执行两次,3分钟后开启第" + str(i + 1) + "次查询") time.sleep(185) ### 检查机票基本信息 if self.FHPackage_getDefaultRecommend.checkflight() is True: if self.FHPackage_getDefaultRecommend.checkdepartflightistransit() is False: logging.debug("推荐去程航班直达") logging.debug("推荐去程航班直达" + "推荐机票是:" + str( self.FHPackage_getDefaultRecommend.getFlightInfo()[1][ 'FlightNo1']) + "推荐机票舱等是:" + str( self.FHPackage_getDefaultRecommend.getFlightInfo()[2]['FlightCabin1'])) else: logging.debug("推荐去程航班需要中转,航班信息如下") if self.FHPackage_getDefaultRecommend.checkdestflightistransit() is False: logging.debug("推荐返程航班直达") logging.debug("推荐去程航班直达" + "推荐机票是:" + str( self.FHPackage_getDefaultRecommend.getFlightInfo()[3][ 'FlightNo2']) + "推荐机票舱等是:" + str( self.FHPackage_getDefaultRecommend.getFlightInfo()[4]['FlightCabin2'])) else: logging.debug("推荐返程航班直达") logging.debug( "推荐机票总价:" + str(self.FHPackage_getDefaultRecommend.getFlightInfo()[0]['totalPrice'])) logging.debug( "推荐机票信息:" + str(self.FHPackage_getDefaultRecommend.getFlightInfo()[1:])) ### 检查酒店信息 if self.FHPackage_getDefaultRecommend.checkHotel() is True: ### 检查酒店基本信息 logging.debug("推荐酒店名称是: " + str( self.FHPackage_getDefaultRecommend.getHotelInfo()[0][ 'HotelName']) + " 价格计划名称: " + str( self.FHPackage_getDefaultRecommend.getHotelInfo()[3][ 'ratePlanName']) + " 总价: " + str( self.FHPackage_getDefaultRecommend.getHotelInfo()[4][ 'totalPrice']) + " 入住时间: " + str( self.FHPackage_getDefaultRecommend.getHotelInfo()[1][ 'checkInDate']) + " 离店时间: " + str( self.FHPackage_getDefaultRecommend.getHotelInfo()[2]['checkOutDate'])) ### 机酒信息完整则开始验仓验价 self.CheckPriceAndPackage.setReqParam(self.tdata['JourneyInfoList']['bookCityCode'], self.tdata['JourneyInfoList']['bookCityName'], self.tdata['JourneyInfoList'][ 'departCityCode'], self.tdata['JourneyInfoList'][ 'departCityName'], self.tdata['JourneyInfoList'][ 'departCityCode'], self.tdata['JourneyInfoList'][ 'departCityName'], self.tdata['JourneyInfoList']['destCityCode'], self.tdata['JourneyInfoList']['destCityName'], str(journeyDepartDate.date()), str(journeyEndDate.date()), sessionId) self.CheckPriceAndPackage.sendrequest(self.envdata) if self.CheckPriceAndPackage.getCheckResult() == True: logging.debug( "验仓验价成功,资源变化信息如下 :" + str(self.CheckPriceAndPackage.getCheckDesc())) ###获取验仓验价和打包的结果备用于下单 productId = self.CheckPriceAndPackage.getProductId() ### 验价成功开始下单先执行stepone接口再执行addorder接口 self.FHPackage_StepOne.setReqParam(productId, str(journeyDepartDate.date()), str(journeyEndDate.date()), self.tdata['JourneyInfoList']['bookCityCode'], self.tdata['JourneyInfoList']['departCityCode'], self.tdata['JourneyInfoList']['destCityCode'], self.tdata['JourneyInfoList']['adultNum'], self.tdata['JourneyInfoList']['childNum'], sessionId) self.FHPackage_StepOne.sendrequest(self.envdata) ### bookid生成成功则继续下单 bookId = self.FHPackage_StepOne.getBookId() if bookId: logging.debug( "打包预定第一步stepone执行结束,bookId是 :" + str(bookId)) ### 下单之前请求保险信息和优惠信息 self.FHPackage_getInsurance.setReqParam(productId, str(journeyDepartDate.date()), str(journeyEndDate.date()), self.tdata['JourneyInfoList'][ 'bookCityCode'], self.tdata['JourneyInfoList'][ 'departCityCode'], self.tdata['JourneyInfoList'][ 'destCityCode'], self.tdata['JourneyInfoList']['adultNum'], self.tdata['JourneyInfoList']['childNum'], sessionId) self.FHPackage_getInsurance.sendrequest(self.envdata) self.FHPackage_getPromotion.setReqParam(productId, str(journeyDepartDate.date()), str(journeyEndDate.date()), self.tdata['JourneyInfoList'][ 'bookCityCode'], self.tdata['JourneyInfoList'][ 'departCityCode'], self.tdata['JourneyInfoList'][ 'destCityCode'], self.tdata['JourneyInfoList']['adultNum'], self.tdata['JourneyInfoList']['childNum'], sessionId) self.FHPackage_getPromotion.sendrequest(self.envdata) if self.FHPackage_getInsurance.CheckResult() == True and self.FHPackage_getPromotion.CheckResult() == True: RandomInsurance = self.FHPackage_getInsurance.GetRandomInsurance()[0] InsurancePrice = self.FHPackage_getInsurance.GetRandomInsurance()[1] RandomPromotion = self.FHPackage_getPromotion.GetRandomPromotion()[0] PromotionPrice = self.FHPackage_getPromotion.GetRandomPromotion()[1] self.FHPackage_addOrder.setReqParam(productId, str(journeyDepartDate.date()), str(journeyEndDate.date()), self.tdata['JourneyInfoList'][ 'bookCityCode'], self.tdata['JourneyInfoList'][ 'departCityCode'], self.tdata['JourneyInfoList'][ 'destCityCode'], self.tdata['JourneyInfoList']['adultNum'], self.tdata['JourneyInfoList']['childNum'], bookId, RandomPromotion, RandomInsurance, 0, self.tdata['ContractInfo'], "", self.tdata['TouristInfoList'], True, False,[],[], sessionId) self.FHPackage_addOrder.sendrequest(self.envdata) if self.FHPackage_addOrder.getOrderResult() == True: data = self.FHPackage_addOrder.getOrderInfo() print("data info is " + str(data)) print(data['productName'] + " 订单生成成功,订单号是:" + str(data['orderId']) + " 订单类型是" + str( data['orderType'])) time.sleep(10) # self.CancelOrder.setReqParam(data['orderId']) # self.CancelOrder.sendrequest() self.success = True self.msg = "订单打包成功" self.orderId = str(data['orderId']) else: logging.debug("订单生成失败") self.success = False self.msg = "订单打包失败" self.orderId = '' else: logging.debug("没有获取保险信息或者优惠信息") self.success = False self.msg = "订单打包失败" self.orderId = '' else: logging.debug("订单第一步stepone没有成功,没有获取bookid") self.success = False self.msg = "订单打包失败" self.orderId = '' else: logging.debug( "验仓验价失败 :" + str(self.CheckPriceAndPackage.getCheckDesc())) self.success = False self.msg = "验仓验价失败" self.orderId = '' ### 推荐接口没有返回酒店数据则用例失败 else: logging.error("推荐接口没有返回酒店数据"); self.success = False self.msg = "推荐接口没有查询到酒店数据" self.orderId = '' ### 推荐接口没有返回机票数据则用例失败 else: logging.error("推荐接口没有返回机票数据"); self.success = False self.msg = "推荐接口没有查询到机票数据" self.orderId = '' except Exception as e: self.success = False self.msg = "出现异常" self.orderId = '' finally: logging.info("finally scope") resp = cors_response({"success": self.success, "msg": self.msg, "orderId": self.orderId}) return resp
def gettimeworking(): try: dict = request.args if len(dict) == 1: week = request.args["week"] # 获取部门信息 #DepartmentInfo = [] # 获取部门总人数 totalnum1 = db.session.query( Time_working.totalnum).filter(Time_working.week == week).all() totalnum = totalnum1[0][0] #项目统计人数(总人数-休假人数,需要手工统计,这边统计-1) statisticsnum = totalnum - 1 #本期参与项目人数(默认等于项目统计人数) participationnum = statisticsnum #部门理论人天(部门总人数*5) theorytime = totalnum * 5 DepartmentInfo = { "totalnum": totalnum, "statisticsnum": statisticsnum, "participationnum": participationnum, "theorytime": theorytime } #获取项目工作量 #ProjectInfo = [] #项目总工时 inlinetime1 = db.session.query( Time_working.projectTime).filter(Time_working.week == week).all() inlinetime = inlinetime1[0][0] #项目理论工时(项目统计人数*5) projecttheorytime = statisticsnum * 5 #项目人员利用率((项目筹备人天+项目实际人天)/项目理论工时,目前项目筹备人天默认为0) #项目占比((项目筹备人天+项目实际人天)/部门理论工时,目前项目筹备人天默认为0) ProjectInfo = { "inlinetime": '%.2f' % inlinetime, "projecttheorytime": projecttheorytime, "utilization": "%.2f%%" % ((inlinetime / projecttheorytime) * 100), "proportion": "%.2f%%" % ((inlinetime / theorytime) * 100), } #获取资本化和技术支持的信息 # RtsupportInfo = [] #获取技术支持工时 supporttime1 = db.session.query( Time_working.supportTime).filter(Time_working.week == week).all() supporttime = supporttime1[0][0] # 获取小需求工时(资本化工时=总工时-技术支持工时-项目工时) requiretime1 = db.session.query( Time_working.capitalizationTime).filter( Time_working.week == week).all() requiretime = requiretime1[0][0] # 需求人天占比(资本化工时/部门理论人天) #技术支持占比(技术支持人天/项目理论人天) RtsupportInfo = { "requiretime": '%.2f' % requiretime, "rproportion": "%.2f%%" % ((requiretime / theorytime) * 100), "support": '%.2f' % supporttime, "sproportion": "%.2f%%" % ((supporttime / projecttheorytime) * 100) } # 获取资本化各个模块数据 # ModuleInfo = [] # 获取零售工时 lingshouTime1 = db.session.query( Time_working.lingshouTime).filter(Time_working.week == week).all() lingshouTime = lingshouTime1[0][0] # 获取度假转化工时 zhuanhuaTime1 = db.session.query( Time_working.zhuanhuaTime).filter(Time_working.week == week).all() zhuanhuaTime = zhuanhuaTime1[0][0] # 获取新客转化工时 xinkeTime1 = db.session.query( Time_working.xinkeTime).filter(Time_working.week == week).all() xinkeTime = xinkeTime1[0][0] # 获取老客运营工时 yunyingTime1 = db.session.query( Time_working.yunyingTime).filter(Time_working.week == week).all() yunyingTime = yunyingTime1[0][0] # 获取架构工时 jiagouTime1 = db.session.query( Time_working.jiagouTime).filter(Time_working.week == week).all() jiagouTime = jiagouTime1[0][0] # 获取打包预定工时 dabaoTime1 = db.session.query( Time_working.dabaoTime).filter(Time_working.week == week).all() dabaoTime = dabaoTime1[0][0] # 获取聚合转化工时 juheTime1 = db.session.query( Time_working.juheTime).filter(Time_working.week == week).all() juheTime = juheTime1[0][0] # 获取会员工时 huiyuanTime1 = db.session.query( Time_working.huiyuanTime).filter(Time_working.week == week).all() huiyuanTime = huiyuanTime1[0][0] # 获取供应链工时 gongyinglianTime1 = db.session.query( Time_working.gongyinglianTime).filter( Time_working.week == week).all() gongyinglianTime = gongyinglianTime1[0][0] # 获取订单工时 dingdanTime1 = db.session.query( Time_working.dingdanTime).filter(Time_working.week == week).all() dingdanTime = dingdanTime1[0][0] ModuleInfo = { "lingshouTime": lingshouTime, "zhuanhuaTime": zhuanhuaTime, "xinkeTime": xinkeTime, "yunyingTime": yunyingTime, "jiagouTime": jiagouTime, "dabaoTime": dabaoTime, "juheTime": juheTime, "huiyuanTime": huiyuanTime, "gongyinglianTime": gongyinglianTime, "dingdanTime": dingdanTime, } response = ({ "success": "true", "msg": "OK", "data": { "week": week, "DepartmentInfo": DepartmentInfo, "ProjectInfo": ProjectInfo, "RtsupportInfo": RtsupportInfo, "ModuleInfo": ModuleInfo } }) except Exception as e: raise e response = ({"success": "false", "msg": "操作失败~~"}) #response = json.dumps(response) return cors_response(response)