* @param dto
* @return
*/
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public FltConnectionDTO handleLoadSummaryMsg(EntUfisMsgDTO dto) {
FltConnectionDTO fltConx = new FltConnectionDTO();
try {
// main flight and connect flight urno(uaft)
String idFlight = null;
String idConxFlight = null;
// idFlight is the main flight
List<String> idFlights = dto.getHead().getIdFlight();
if (idFlights != null && idFlights.size() > 0) {
// main flight
idFlight = idFlights.get(0);
fltConx.setIdFlight(new BigDecimal(idFlight));
EntUfisMsgACT act = dto.getBody().getActs().get(0);
String tab = act.getTab();
List<String> fld = act.getFld();
List<Object> dat = act.getData();
String status = null;
String bagPcs = null;
String uldPcs = null;
String totalPax = null;
String infoType = null;
for (int i = 0; i < fld.size(); i++) {
String field = fld.get(i).toUpperCase();
Object value = dat.get(i);
if (value != null) {
switch (field) {
case FLD_ID_ARR_FLIGHT:
if (!value.toString().equals(idFlight)) {
idConxFlight = value.toString();
}
break;
case FLD_ID_DEP_FLIGHT:
if (!value.toString().equals(idFlight)) {
idConxFlight = value.toString();
}
break;
case FLD_INFO_TYPE:
infoType = value.toString();
break;
case FLD_ID_FLIGHT:
//idFlight = value.toString();
break;
case FLD_ID_CONX_FLIGHT:
idConxFlight = value.toString();
break;
case FLD_BAG_PCS:
bagPcs = value.toString();
break;
case FLD_TOTAL_PAX:
totalPax = value.toString();
break;
case FLD_ULD_PCS:
uldPcs = value.toString();
break;
default:
break;
}
}
}
// Check info_type: only accepted TXF(transfer)
if (HpUfisAppConstants.INFO_TYPE_TRANSFER.equalsIgnoreCase(infoType)) {
boolean isValid = false;
// arrival and departure flight urno cannot be null, empty or 0
// arrival and departure flight urno cannot be same
if ((HpUfisUtils.isNotEmptyStr(idFlight) && !DEF_FLIGHT_ID.equals(idFlight))
&& (HpUfisUtils.isNotEmptyStr(idConxFlight) && !DEF_FLIGHT_ID.equals(idConxFlight))
&& (!idFlight.equals(idConxFlight))) {
// Transfer pax number should be greater than 0
if (totalPax != null
&& totalPax.matches(NUMBER_VALUE)
&& Integer.parseInt(totalPax) > 0) {
isValid = true;
} else {
if (HpUfisAppConstants.CON_LOAD_PAX_SUMMARY.equalsIgnoreCase(tab)) {
LOG.warn("Total Pax number for transfer must be greater than 0. Received value: {}", totalPax);
}
}
// Transfer bag pcs should be greater than 0
if (bagPcs != null
&& bagPcs.matches(NUMBER_VALUE)
&& Integer.parseInt(bagPcs) > 0) {
isValid = true;
} else {
if (HpUfisAppConstants.CON_LOAD_BAG_SUMMARY.equalsIgnoreCase(tab)) {
LOG.warn("Total Bag Pieces for transfer must be greater than 0. Received value: {}", bagPcs);
}
}
// Treanfer uld pcs should be greater than 0
if (uldPcs != null
&& bagPcs.matches(NUMBER_VALUE)
&& Integer.parseInt(uldPcs) > 0) {
isValid = true;
} else {
if (HpUfisAppConstants.CON_LOAD_ULD_SUMMARY.equalsIgnoreCase(tab)) {
LOG.warn("Total Uld Pieces for transfer must be greater than 0. Received value: {}", uldPcs);
}
}
if (isValid) {
long start = System.currentTimeMillis();
// find arrival and departure flight from afttab
EntDbAfttab flight = afttabBean.findFlightForConxByUrno(Long.parseLong(idFlight));
EntDbAfttab conxFlight = afttabBean.findFlightForConxByUrno(Long.parseLong(idConxFlight));
LOG.debug("Search Flight from afttab used: {}", (System.currentTimeMillis() - start));
// Main flight and conx flight must be existing in afttab
if (flight == null) {
LOG.warn("Flight not found for urno: {}", idFlight);
return null;
}
if (conxFlight == null) {
LOG.warn("Conx Flight not found for urno: {}", idConxFlight);
return null;
}
// Main flight and conx flight must be either arrival or departure flight
if (ADID_ARRIVAL != flight.getAdid() && ADID_DEPARTURE != flight.getAdid()) {
LOG.warn("Main flight must be arrival or departure flight");
LOG.warn("ADID={} for main flight={}", flight.getAdid(), flight.getUrno());
return null;
}
if (ADID_ARRIVAL != conxFlight.getAdid() && ADID_DEPARTURE != conxFlight.getAdid()) {
LOG.warn("Conx flight must be arrival or departure flight");
LOG.warn("ADID={} for conx flight={}", conxFlight.getAdid(), conxFlight.getUrno());
return null;
}
// calculate the time span between main and connect flight
BigDecimal idArrFlight = null;
BigDecimal idDepFlight = null;
HpUfisCalendar tifa = null;
HpUfisCalendar tifd = null;
if (ADID_ARRIVAL == flight.getAdid()) {
tifa = new HpUfisCalendar(flight.getTifa());
tifd = new HpUfisCalendar(conxFlight.getTifd());
idArrFlight = flight.getUrno();
idDepFlight = conxFlight.getUrno();
} else {
tifa = new HpUfisCalendar(conxFlight.getTifd());
tifd = new HpUfisCalendar(flight.getTifa());
idArrFlight = conxFlight.getUrno();
idDepFlight = flight.getUrno();
}
int timeDiff = (int) tifa.timeDiff(tifd, EnumTimeInterval.Minutes, false);
LOG.debug("Time Difference between main flight and conx flight: {} mins", timeDiff);
if (timeDiff > HpEKConstants.MAX_CONX_TIME_PAX_ALERT) {
// Normal
//status = "N";
status = HpUfisAppConstants.CONX_STAT_NOMRAL;
} else if (timeDiff > HpEKConstants.MIN_CONX_TIME_PAX_ALERT
&& timeDiff <= HpEKConstants.MAX_CONX_TIME_PAX_ALERT) {
// Short
//status = "S";
status = HpUfisAppConstants.CONX_STAT_SHORT;
} else if (timeDiff <= HpEKConstants.MIN_CONX_TIME_PAX_ALERT) {
// Critical
//critical = 1;
//status = "C";
status = HpUfisAppConstants.CONX_STAT_CRITICAL;
fltConx.setCriticalCount(1);
} else {
// No Connection
//status = "X";
status = HpUfisAppConstants.CONX_STAT_NOCONNX;
}