* @param input data RTCAssignmentType
*/
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
private EntDbFltJobTask processFltJobTask(RTCAssignmentType _input, BigDecimal idFlight,
boolean isUpdate, String recStatus)throws ParseException {
EntDbFltJobTask inputJobTask = null;
TaskInfoType taskInfo = _input.getTaskDetails().getTaskInfo();
TaskTimesType taskTimes = _input.getTaskDetails().getTaskTimes();
/**
* .. check for Master Data ..
*/
String type = null;
for(EntDbMdRmsOrderType orderType : clsEntStartUpInitSingleton.getMdRmsOrderTypeList()){
if(orderType.getOrderType().equalsIgnoreCase(taskInfo.getType())){
if(orderType.getStaffTypeCode().equalsIgnoreCase(HpEKConstants.RMS_STAFF_TYPE_SPHL))
type = taskInfo.getType(); break;
}
}
if(type == null)
LOG.debug("Order type <{}> is not found in MdRmsOrderType table.", taskInfo.getType());
String workArea = null;
for(EntDbMdRmsWorkArea wArea : clsEntStartUpInitSingleton.getMdRmsWorkAreasList()){
if(wArea.getWorkArea().trim().equalsIgnoreCase(taskInfo.getWorkArea())){
if(wArea.getStaffTypeCode().equalsIgnoreCase(HpEKConstants.RMS_STAFF_TYPE_SPHL))
workArea = taskInfo.getWorkArea(); break;
}
}
if(workArea == null)
LOG.debug("Work Area <{}> is not found in MdRmsWorkArea table.", taskInfo.getWorkArea());
String startLoc = null, stau = null;
for(EntDbMdRmsWorkLoc loc : clsEntStartUpInitSingleton.getMdRmsWorkLocsList()){
if(loc.getWorkLocationId().equalsIgnoreCase(taskInfo.getStartLoc())){
if(loc.getStaffTypeCode().equalsIgnoreCase(HpEKConstants.RMS_STAFF_TYPE_SPHL))
startLoc = taskInfo.getStartLoc();
}
if(loc.getWorkLocationId().equalsIgnoreCase(taskInfo.getEndLoc())){
if(loc.getStaffTypeCode().equalsIgnoreCase(HpEKConstants.RMS_STAFF_TYPE_SPHL))
stau = taskInfo.getStartLoc();
}
}
if(startLoc == null)
LOG.debug("Work start location <{}> is not found in MdRmsWorkLoc table.", taskInfo.getStartLoc());
if(stau == null)
LOG.debug("Work end location <{}> is not found in MdRmsWorkLoc table.", taskInfo.getEndLoc());
String status = null;
for(EntDbMdRmsTaskStatus taskStatus : clsEntStartUpInitSingleton.getMdRmsTaskStatusList()){
if(taskStatus.getTaskStatusId().equalsIgnoreCase(taskInfo.getStatus())){
if(taskStatus.getStaffTypeCode().equalsIgnoreCase(HpEKConstants.RMS_STAFF_TYPE_SPHL))
status = taskInfo.getStatus(); break;
}
}
if(status == null)
LOG.debug("Task Status Id <{}> is not found in MdRmsTaskStatus table.", taskInfo.getStatus());
/**
* UPDATE/INSERT Flight Job Task
*/
BigDecimal taskId = new BigDecimal(taskInfo.getSubTaskID());
if (isUpdate) {
// find the existing record
inputJobTask = clsDlFltJobTaskLocal.findExistingFltJobTask(
idFlight, taskId, HpEKConstants.RMS_STAFF_TYPE_SPHL);
if (inputJobTask != null) {
inputJobTask.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
inputJobTask.setUpdatedUser(HpEKConstants.RMS_RTC_SOURCE);
}else{
//flt Task is null to UPDATE
LOG.debug("Input job task is not existing to Update. Message dropped.");
return null;
}
} else {
inputJobTask = new EntDbFltJobTask();
inputJobTask.setCreatedDate(HpUfisCalendar.getCurrentUTCTime());
inputJobTask.setCreatedUser(HpEKConstants.RMS_RTC_SOURCE);
}
inputJobTask.setRecStatus(recStatus);
inputJobTask.setIdFlight(idFlight);
inputJobTask.setStaffType(HpEKConstants.RMS_STAFF_TYPE_SPHL);
inputJobTask.setDataSource(HpEKConstants.RMS_RTC_SOURCE);
/** TaskInfo **/
inputJobTask.setTaskId(taskId);
inputJobTask.setTaskType(taskInfo.getType());
inputJobTask.setTaskTypeDesc(taskInfo.getTypeDesc());
inputJobTask.setTaskWorkArea(taskInfo.getWorkArea());
inputJobTask.setTaskStartLoc(taskInfo.getStartLoc());
inputJobTask.setTaskEndLoc(taskInfo.getEndLoc());
inputJobTask.setTaskRemark(taskInfo.getRemarks());
inputJobTask.setTaskStatus(taskInfo.getStatus());
inputJobTask.setTaskStatusChngTime(convertDateToUTC(taskInfo.getStatusTimestamp()));
inputJobTask.setTaskCreatedDate(convertDateToUTC(taskInfo.getCreationTime()));
/** TaskTimes **/
Date planStartDate = convertDateToUTC(taskTimes.getPlnStartTime());
Date planEndDate = convertDateToUTC(taskTimes.getPlnEndTime());
inputJobTask.setTaskPlanStartDate(planStartDate);
inputJobTask.setTaskPlanEndDate(planEndDate);
//calculate plan minute (duration = endTime - startTime)
inputJobTask.setTaskPlanDuration(new BigDecimal((planEndDate.getTime() - planStartDate.getTime())/1000));
if(taskTimes.getActStartTime() != null)//Conditional case
inputJobTask.setTaskActualStartDate(convertDateToUTC(taskTimes.getActStartTime()));
if(taskTimes.getActEndTime() != null)
inputJobTask.setTaskActualEndDate(convertDateToUTC(taskTimes.getActEndTime()));
Date taskActualStartDate = inputJobTask.getTaskActualStartDate();
Date taskActualEndDate = inputJobTask.getTaskActualEndDate();
if(taskActualEndDate != null && taskActualStartDate != null)
inputJobTask.setTaskActualDuration(new BigDecimal((taskActualEndDate.getTime() - taskActualStartDate.getTime())/1000));
else
LOG.debug("One of Task Actual Start or End date is empty/null. Duration will be empty.");
EntDbFltJobTask resultFltJobTask = clsDlFltJobTaskLocal.merge(inputJobTask);
if(resultFltJobTask != null)
LOG.debug("Input Flt Job Task has been inserted/updated.");
return resultFltJobTask;
}