def create_gof_from_golden(bid, csvout): bid_type = bid['a'] crewid = bid['Number'] bid_points = cl.setPoints((int(bid['Wt']))) # use for MHCC # bid_points = cl.setPoints_lhcc(bid_type, bid['Pref Type']) # use for LHCC date_from = cl.conv_d(bid['From']) csvout.writerow({ 'bidType_h': bid_type, 'crewId_h': crewid, 'dateIntervalFrom_h': date_from, 'bidPoints_h': bid_points })
def create_timeoff_from_qual_timeoff(bid, csvout): bid_type = bid['a'] crewid = bid['Number'] bid_points = cl.setPoints((int(bid['Wt']))) # use for MHCC # bid_points = cl.setPoints_lhcc(bid_type, bid['Pref Type']) # use for LHCC time_pair = cl.get_end_time(bid['From'], bid['Durn']) time_from = time_pair[0] time_to = time_pair[1] csvout.writerow({ 'bidType_h': bid_type, 'crewId_h': crewid, 'dateIntervalFrom_h': BidTypes.roster_start_date, 'dateIntervalTo_h': BidTypes.roster_end_date, 'timeIntervalFrom_h': time_from, 'timeIntervalTo_h': time_to, 'bidPoints_h': bid_points })
def create_timeoff_from_spec_timeoff(bid, csvout): bid_type = bid['a'] crewid = bid['Number'] bid_points = cl.setPoints((int(bid['Wt']))) # use for MHCC # bid_points = cl.setPoints_lhcc(bid_type, bid['Pref Type']) # use for LHCC date_from = cl.conv_d(bid['From']) date_to = cl.get_end_date_time_from_duration(bid['From'], bid['Durn']) time_from = cl.conv_t(bid['From']) time_to = date_to[1] csvout.writerow({ 'bidType_h': bid_type, 'crewId_h': crewid, 'dateIntervalFrom_h': date_from, 'dateIntervalTo_h': date_to[0], 'timeIntervalFrom_h': time_from, 'timeIntervalTo_h': time_to, 'bidPoints_h': bid_points })
def create_timeoff_from_gen_timeoff(bid, csvout, gen_timeoff_start_dict): bid_type = bid['a'] crewid = bid['Number'] bid_points = cl.setPoints((int(bid['Wt']))) # use for MHCC # bid_points = cl.setPoints_lhcc(bid_type, bid['Pref Type']) # use for LHCC data = cl.get_time_off_params(bid_type, bid['From'], bid['Durn'], bid['Remarks']) time_from = cl.get_start_time_gen_timeoff(bid['SeqNum'], gen_timeoff_start_dict) for i in range(0, len(data)): csvout.writerow({ 'bidType_h': bid_type, 'crewId_h': crewid, 'dateIntervalFrom_h': data[i][0], 'dateIntervalTo_h': data[i][1], 'timeIntervalFrom_h': time_from, 'timeIntervalTo_h': data[i][2], 'startDay_h': data[i][3], 'endDay_h': data[i][4], 'bidPoints_h': bid_points })
count_time_off = 0 count_spec_pairing = 0 count_spec_time_off = 0 count_gen_time_off = 0 count_qual_time_off = 0 for row in csvDReader: bid_type = row['.'] crewid = row['Number'] avoid = str(cl.get_avoid(row['Pref Type'])) max_times_roster = cl.setMaxTimesRoster(row['Rqd']) region = cl.get_region(row['Rgn']) layover = cl.get_transit(row['L/O']) transit = cl.get_layover(row['Tod/Port']) max_lo_nt = row['Nt'] bid_points = cl.setPoints((int(row['Wt']))) pax = cl.get_pax(row['Px']) dow_to_list = cl.get_days_from_dow(row['Remarks']) day_range = list(cl.group(dow_to_list)) if bid_type == 'GEN_PAIRING' and len(day_range) != 0: date_from = cl.conv_d(row['From']) date_to = cl.conv_d(row['Until']) for i in range(0, len(day_range)): day_from = day_range[i][0] day_to = day_range[i][1] outputWriter.writerow([ bid_type, crewid, date_from, date_to, avoid, daydict[day_from], daydict[day_to], max_times_roster, region, layover, max_lo_nt, transit, pax, bid_points ]) t_count = t_count + 1
def create_generic_from_generic(bid_in, csv_out): bid_type = bid_in['a'] crewid = bid_in['Number'] avoid = str(cl.get_avoid(bid_in['Pref Type'])) max_times_roster = cl.setMaxTimesRoster(bid_in['Rqd'], bid_in['Pref Type']) region = cl.get_region(bid_in['Rgn']) max_lo_nt = bid_in['Nt'] bid_points = cl.setPoints((int(bid_in['Wt']))) pax = cl.get_pax(bid_in['Px']) day_range_2 = cl.get_dow_list(bid_in['From'], bid_in['Until'], bid_in['Remarks']) date_from = cl.conv_d(bid_in['From']) date_to = cl.conv_d(bid_in['Until']) port_data = cl.get_layover_transit(bid_in['Tod/Port'], bid_in['L/O']) layover = port_data[0] transit = port_data[1] pairingMin = bid_in['Min'] pairingMax = cl.setPairingLenMax(bid_in['Max']) if bid_in['Rest'] == 'TRUE': specRuleRelax = 'Accept Minimum Rest' specRuleRelaxVal = 'Yes' else: specRuleRelax = '' specRuleRelaxVal = '' if len(day_range_2) != 0: for i in range(0, len(day_range_2)): day_from = day_range_2[i][0] day_to = day_range_2[i][1] csv_out.writerow({ 'bidType_h': bid_type, 'crewId_h': crewid, 'dateIntervalFrom_h': date_from, 'dateIntervalTo_h': date_to, 'workPlaceLocation_h': specRuleRelax, 'workPlaceTask_h': specRuleRelaxVal, 'avoid_h': avoid, 'startDay_h': BidTypes.daydict[day_from], 'endDay_h': BidTypes.daydict[day_to], 'maxTimesPerPeriod_h': max_times_roster, 'bidRegion_h': region, 'layoverStation_h': layover, 'layoverLengthTo_h': max_lo_nt, 'stopStation_h': transit, 'tripLengthFrom_h': pairingMin, 'tripLengthTo_h': pairingMax, 'bidTripType_h': pax, 'bidPoints_h': bid_points }) elif len(day_range_2) == 0: csv_out.writerow({ 'bidType_h': bid_type, 'crewId_h': crewid, 'dateIntervalFrom_h': date_from, 'dateIntervalTo_h': date_to, 'workPlaceLocation_h': 'Accept Min Rest', 'workPlaceTask_h': rest, 'avoid_h': avoid, 'maxTimesPerPeriod_h': max_times_roster, 'bidRegion_h': region, 'layoverStation_h': layover, 'layoverLengthTo_h': max_lo_nt, 'stopStation_h': transit, 'tripLengthFrom_h': pairingMin, 'tripLengthTo_h': pairingMax, 'bidTripType_h': pax, 'bidPoints_h': bid_points })