from hub import methods, Global async def code_4001(**sources): """ 获取全部渣包状态数据接口 """ # --- fill d1 --- d1 = Global.enfei_api.get_pot_list() # --- check ---- if type(d1) != list: reason, detail = d1 return dict(code=1, data=[], reason=reason, detail=detail) # --- fill d2 --- d2 = list() d3 = list(reversed(d1)) d4 = list(['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N']) # 排 d5 = list(range(31)) # 罐数 count = 0 for i in d4: for j in d5: # --- define --- data = { 'pot_name': f"{i}.{j + 1}", # 渣罐别称 'pot_status': 0, # 渣罐状态 1 空位 2 就绪 3 缓冷(空冷) 4 水冷 5 自冷(水冷) 6 待倒 7 故障 'pot_number': '', # 渣罐编号 } # --- update --- # methods.debug_log('hs4000.code_4001.48:', f"#count: {count}") data['pot_status'] = d3[count].get('packageStatus') data['pot_number'] = d3[count].get('localNumber') d2.append(data) # methods.debug_log('hs4000.code_4001.52:', f"#data: {data}") count += 1 return dict(code=0, data=d2)