def cars_init(self, cars_list): new_cars_list = cars_list for car in new_cars_list: car.set_finish_time(Tool.datetime_to_string(Tool.string_to_datetime(car.get_entry_time()) + datetime.timedelta(seconds=self.__unloadTime))) if car.get_finish_time() < '2019-10-25 00:00:00': car.set_finish_time('2019-10-25 00:00:00') return new_cars_list
def ready_cars_init(self, cars_list): # 准备车辆也确定了进厂时间和离厂时间 new_cars_list = cars_list for car in new_cars_list: for warehouse in self.__inFactory.get_warehouse(): if car.get_target_warehouse() == warehouse.get_warehouse_code( ): car.set_entry_time( Tool.datetime_to_string( Tool.string_to_datetime(car.get_notice_time()) + datetime.timedelta( seconds=warehouse.get_preTime()))) if car.get_entry_time() < '2019-10-25 00:00:00': car.set_entry_time('2019-10-25 00:00:00') car.set_finish_time( Tool.datetime_to_string( Tool.string_to_datetime(car.get_entry_time()) + datetime.timedelta( seconds=warehouse.get_unloadTime()))) return new_cars_list
def data_analyse4(data): result = list() hour = datetime.timedelta(hours=1) half_hour = datetime.timedelta(minutes=30) time = '2019-10-25 00:00:00' while time != '2019-11-29 00:00:00': for warehouse in warehouse_code: num = len(data[(data['WAREHOUSE_CODE'] == warehouse) & (data['ENTRY_TIME'] < time) & (data['FINISH_TIME'] > time)]) warehouse_dict[warehouse].append(num) # print(warehouse, '在', time, '的时候有', num, '辆车') time = tool.datetime_to_string(tool.string_to_datetime(time) + hour) for warehouse in warehouse_code: j = 0 for i in range(len(warehouse_dict[warehouse])): if warehouse_dict[warehouse][j] == 0: warehouse_dict[warehouse].pop(j) else: j += 1 temp = list() temp.append(warehouse) temp.append(stats.mode(warehouse_dict[warehouse])[0][0]) temp.append(max(warehouse_dict[warehouse])) # print(warehouse, '的众数是:', stats.mode(warehouse_dict[warehouse])[0][0]) # print(warehouse, '的max是:', max(warehouse_dict[warehouse])) warehouse_dict[warehouse].sort(reverse=True) temp.append( int( np.mean(warehouse_dict[warehouse] [0:len(warehouse_dict[warehouse]) // 3 + 1]))) result.append(temp) # print(warehouse, '的较大值是:', np.mean(warehouse_dict[warehouse][0: len(warehouse_dict[warehouse]) // 3 + 1])) df = pd.DataFrame(result, columns=['warehouse_code', 'mode', 'max', 'minorMax']) df.to_excel('warehouseLimit.xls', index=False)
def call(self, time): car_list = list() # 存储本次叫号的车辆 pre_time = Tool.datetime_to_string( Tool.string_to_datetime(time) - datetime.timedelta(seconds=Tool.interval)) # 选取上一个时间段的plan_day plan_day = self.plan_day[(self.plan_day['update_time'] >= pre_time) & (self.plan_day['update_time'] <= time)] # 更新每个仓库内的每个原料的更新时间和剩余未完成量 for warehouse in self.__inFactory.get_warehouse(): for mat in warehouse.get_mat_list(): if mat.get_mat_code() == '11002000010000': mat_plan_day = plan_day[ (plan_day['sub_kind_name'] == mat.get_sub_kind_name()) & (plan_day['warehouse_code'] == warehouse. get_warehouse_code())]['add_weight'].tolist() else: mat_plan_day = plan_day[ (plan_day['kind_code'] == mat.get_mat_code()) & (plan_day['warehouse_code'] == warehouse. get_warehouse_code())]['add_weight'].tolist() if len(mat_plan_day) == 0: continue add_weight = int(mat_plan_day[-1]) mat.update(time, add_weight - mat.get_sum()) self.__inFactory.cal_mat_priority(time) # 计算每个原料的优先级 self.cal_cars_priority(time) # 计算每辆车的优先级 self.__queue_cars.sort(key=lambda x: x.get_priority()) # for car in self.__queue_cars: # for car in self.__queue_cars: # # 外购废钢看小品名 # if car.get_mat_code() == '11002000010000': # for warehouse in self.__inFactory.get_warehouse(): # for mat in warehouse.get_mat_list(): # if mat.get_sub_kind_name() == car.get_sub_kind_name(): # if mat.get_rest() > 0: # car.set_notice_time(time) # car.set_entry_time(Tool.datetime_to_string # (Tool.string_to_datetime(car.get_notice_time()) + datetime.timedelta # (seconds=warehouse.get_preTime()))) # car.set_finish_time(Tool.datetime_to_string # (Tool.string_to_datetime(car.get_entry_time)) + datetime.timedelta # (seconds=warehouse.get_unloadTime())) # mat.add_sum() # mat.sub_rest() # car_list.append(car) # # 其他看物料名 # else: # for warehouse in self.__inFactory.get_warehouse(): # for mat in warehouse.get_mat_list(): # if mat.get_mat_code() == car.get_mat_code(): # if mat.get_rest() > 0: # car.set_notice_time(time) # car.set_entry_time(Tool.datetime_to_string # (Tool.string_to_datetime(car.get_notice_time()) + datetime.timedelta # (seconds=warehouse.get_preTime()))) # car.set_finish_time(Tool.datetime_to_string # (Tool.string_to_datetime(car.get_entry_time)) + datetime.timedelta # (seconds=warehouse.get_unloadTime())) # mat.add_sum() # mat.sub_rest() # car_list.append(car) return car_list