EntDbLoadUld entUld = _dlLoadUldBean.getUldNum(urno, uldNumber);
idUld = (entUld == null) ? "0" : entUld.getId();
boolean flag = false;
String cmdForBroadcasting = null;
EntDbLoadUldMove loadUldMove = null;
EntDbLoadUldMove oldLoadUldMove = null;
if("UNDO".equals(_inputUldScanInfo.getRECORDTYPE())){
loadUldMove = _dlLoadUldMoveBean.getUldMoveByIdFlightUldNum(urno, uldNumber);
flag = true;
}
if(loadUldMove == null){//null? create a new record
if(flag){
LOG.error(" ULD record does not exist to UNDO. Message dropped.");
addExptInfo(EnumExceptionCodes.ENOUD.name(), uldNumber);
return false;
}
loadUldMove = new EntDbLoadUldMove();
oldLoadUldMove = loadUldMove;
loadUldMove.setFltDate(new HpUfisCalendar(flDate).getTime());
loadUldMove.setUldFltno(flno);
loadUldMove.setUldNumber(_inputUldScanInfo.getULDNUMBER());
loadUldMove.setCreatedUser(_inputUldScanInfo.getSCANBY());
loadUldMove.setCreatedDate(HpUfisCalendar.getCurrentUTCTime());
cmdForBroadcasting = HpUfisAppConstants.UfisASCommands.IRT.toString();
}
else{
oldLoadUldMove = new EntDbLoadUldMove(loadUldMove);
loadUldMove.setUpdatedUser(_inputUldScanInfo.getSCANBY());
loadUldMove.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
cmdForBroadcasting = HpUfisAppConstants.UfisASCommands.URT.toString();
}
loadUldMove.setIdFlight(urno);
loadUldMove.setIdLoadUlds(idUld);
List<EntDbMdUldLoc> uldLocList = _BasicDataSingleton.getUldLocList();
List<EntDbMdUldScanAct> uldScanActList = _BasicDataSingleton.getUldScanActList();
boolean isFound = false;
for(int i = 0; i < uldLocList.size(); i++){
if(uldLocList.get(i).getUldPlaceLoc().trim().equals(_inputUldScanInfo.getSCANLOCATIONCODE().trim())){
loadUldMove.setIdScanMdUldLoc(uldLocList.get(i).getId());
isFound = true;
}
//if(!HpUfisUtils.isNullOrEmptyStr(_inputUldScanInfo.getSCANDISLOCCODE())){ // only when the value is exist, check against the md value
if(uldLocList.get(i).getUldPlaceLoc().trim().equals(_inputUldScanInfo.getSCANDISLOCCODE().trim())){
loadUldMove.setIdDispMdUldLoc(uldLocList.get(i).getId());
isFound = true;
}
//}
}
if (!isFound) {
addExptInfo(EnumExceptionCodes.WNOMD.name(), String.format("SCAN_LOCATION_CODE/SCAN_DIS_LOC_CODE => %s/%s", _inputUldScanInfo.getSCANLOCATIONCODE().trim(),_inputUldScanInfo.getSCANDISLOCCODE().trim()));
LOG.warn("Master Data scanLoc/scanDisLoc code is not match in MdUldLoc.");
}
isFound = false;
for(int i = 0; i < uldScanActList.size(); i++){
if(uldScanActList.get(i).getUldScanAction().trim().equals(_inputUldScanInfo.getSCANACTION().trim())){
loadUldMove.setIdMdUldScanAct(uldScanActList.get(i).getId());
isFound = true;
break;
}
}
if (!isFound) {
addExptInfo(EnumExceptionCodes.WNOMD.name(), String.format("SCAN_ACTION => %s", _inputUldScanInfo.getSCANACTION().trim()));
LOG.warn("Master Data uldScanAction is not match in MdUldScanAct.");
}
String status = " ";
if("UNDO".equals(_inputUldScanInfo.getRECORDTYPE())){
status = "X";
cmdForBroadcasting = HpUfisAppConstants.UfisASCommands.DRT.toString();
}
loadUldMove.setRecFlag(status);
loadUldMove.setArrDepFlag(_inputUldScanInfo.getFLIGHTAD());
loadUldMove.setScanAction(_inputUldScanInfo.getSCANACTION());
loadUldMove.setScanLocCode(_inputUldScanInfo.getSCANLOCATIONCODE());
loadUldMove.setScanLocDesc(_inputUldScanInfo.getSCANLOCATIONDESC());
if(!HpUfisUtils.isNullOrEmptyStr(_inputUldScanInfo.getSCANDATETIME()))
loadUldMove.setScanDate(new HpUfisCalendar(convertFlDateToUTC(_inputUldScanInfo.getSCANDATETIME())).getTime());
loadUldMove.setScanUser(_inputUldScanInfo.getSCANBY());
loadUldMove.setDataSource(HpEKConstants.ULD_SOURCE);
loadUldMove.setDispLocCode(_inputUldScanInfo.getSCANDISLOCCODE());
loadUldMove.setDispLocDesc(_inputUldScanInfo.getSCANDISLOCDESC());
if(!HpUfisUtils.isNullOrEmptyStr(_inputUldScanInfo.getRECORDSENDDATE()))
loadUldMove.setUldSentDate(new HpUfisCalendar(convertFlDateToUTC(_inputUldScanInfo.getRECORDSENDDATE())).getTime());
EntDbLoadUldMove uldMove = _dlLoadUldMoveBean.merge(loadUldMove);
if(uldMove != null){
sendNotifyUldMoveInJson(uldMove, oldLoadUldMove, cmdForBroadcasting);
}
}
else {