def session_request(session): session_locations = data.get_locations(session) stages = list(set([s['stage'] for s in session_locations])) locs_by_stage = {s : [] for s in stages} for l in session_locations: locs_by_stage[l['stage']].append(l) return jsonify({"locations" : locs_by_stage})
def prompt_for_new_loc_id(): """ 提示用户输入新的货架位置loc_id并返回,或者返回None """ while True: loc_id = input("请输新的货架位置ID:") if loc_id == "": return None elif loc_id in data.get_locations(): print('该货架位置已经存在,请重新输入') else: return loc_id
def prompt_for_old_loc_id(): """提示用户输入有效的货架位置loc_id并返回有效货架位置ID,或者返回None""" while True: loc_id = input("请输入货架位置ID:") if loc_id == "": return None elif loc_id not in data.get_locations(): print("该货架位置不存在,请重新输入") else: return loc_id
def loop_request(session): # get session session_locations = data.get_locations(session) # get loop set loop_set = data.checkForLoop(session_locations) # make list of loop set objectIds if loop_set != None: loop_objIds = [l['objectId'] for l in loop_set] for sl in session_locations: if sl['objectId'] in loop_objIds: sl['in_loop'] = True else: sl['in_loop'] = False return jsonify({"type" : "loops", "locations" : session_locations}) else: return jsonify({"error" : "No loops found", "locations" : session_locations})
def report_items(): """库存信息报表""" for (k, v) in data.get_items(): sku_name = data.get_products()[k] loc_name = data.get_locations()[v] print('{0:8} {1}: {2:8} {3}'.format(k, sku_name, v, loc_name))
def report_locations(): """货架位置报表""" for (k, v) in data.get_locations().items(): print(' {0:8} {1}'.format(k, v))