jobAssign.setStaffNumber(_inputStaffDetail.getID());
if(_inputStaffDetail.getName() != null)
jobAssign.setStaffName(_inputStaffDetail.getName());
//Service Detail
ServiceDetailsType _inputServiceDetailsType = _inputStaffDetail.getServiceDetails();
if(_inputServiceDetailsType == null){
LOG.debug("No Service Detail in input Staff <{}>.", _inputStaffDetail.getID());
return;
}
String serCode = null;
if (_inputServiceDetailsType.getServiceCode() != null) {// check in MD table
for (EntDbMdRmsServCode servicCode : clsEntStartUpInitSingleton.getMdRmsServCodesList()) {
if (_inputServiceDetailsType.getServiceCode().equalsIgnoreCase(servicCode.getStaffTypeCode())) {
if(servicCode.getStaffTypeCode().equalsIgnoreCase(HpEKConstants.RMS_STAFF_TYPE_SPHL))
serCode = _inputStaffDetail.getServiceDetails().getServiceCode(); break;
}
}
if(serCode == null)
LOG.debug("Service Code <{}> is not found in MdRmsServiceCode table.", _inputServiceDetailsType.getServiceCode());
jobAssign.setSpecialService(_inputServiceDetailsType.getServiceCode());
}
String paxSeq = String.valueOf(_inputServiceDetailsType.getPaxSequence());
// 2013-11-22 updated by JGO - remove pax_ref_num and add pax_name for sphl
//jobAssign.setPaxRefNum(paxSeq);
String paxName = _inputServiceDetailsType.getPaxName();
if (_input.getMeta().getSource().contains("SPHL") && HpUfisUtils.isNotEmptyStr(paxName)) {
paxName = paxName.replaceAll("/", " ");
// find the pax from macs
// check from load pax table by id_flight, paxname and status <> 'x'
List<EntDbLoadPax> paxes = loadPaxBean.findPaxByFlightAndName(urno, paxName);
String idLoadPax = "0";
String idServiceReq = "0";
if (paxes.size() == 0) {
LOG.warn("No Pax found in Lod_Pax table by id_flight: {} and pax_name: {}",
urno,
paxName);
} else if (paxes.size() > 1) {
LOG.warn("More than 1 Pax found in Load_Pax table by id_flight: {} and pax_name: {}",
urno,
paxName);
} else {
idLoadPax = paxes.get(0).getUuid();
// look for service request for the pax
// fisrt round: search by id_load_pax and service_code
LOG.debug("Find service request from service_request table");
List<EntDbServiceRequest> requests = serviceRequestBean
.findPaxRequest(null, idLoadPax, _inputServiceDetailsType.getServiceCode(), null);
if (requests == null || requests.size() == 0) {
LOG.warn("No service request found by id_load_pax: {} and service_code: {}",
idLoadPax,
_inputServiceDetailsType.getServiceCode());
LOG.debug("Change Criteria to find service request");
// if not found, second round: search by id_flight, inter_ref_number and service_code
requests = serviceRequestBean.findPaxRequest(urno, null,
_inputServiceDetailsType.getServiceCode(), paxes.get(0)
.getPKId().getIntrefnumber());
}
if (requests == null || requests.size() == 0) {
LOG.warn("No service request found by id_flight: {}, interRefNumber: {} and service_code: {}",
urno,
paxes.get(0).getPKId().getIntrefnumber(),
_inputServiceDetailsType.getServiceCode());
} else {
idServiceReq = requests.get(0).getUuid();
}
}
jobAssign.setIdLoadPax(idLoadPax);
jobAssign.setIdServiceReq(idServiceReq);
jobAssign.setPaxName(paxName);
}
//to find from SERVICE_REQUEST
/* EntDbServiceRequest entSerRequest = clsDlPaxServiceRequest.findByIdFlightAndPaxRefNum(urno.intValue(), paxSeq);
if(entSerRequest != null){
jobAssign.setIdServiceRequest(entSerRequest.getIntId());//ID???
}*/
jobAssign.setChargeNote(String.valueOf(_inputServiceDetailsType.getDocNumber()));
//Equipment
EquipmentType equipType = _input.getTaskDetails().getResources().getEquipment();
EquipmentDetailsType equip = new EquipmentDetailsType();
if(equipType != null && !equipType.getEquipmentDetails().isEmpty()){//Conditional case