// send notification
ufisTopicProducer.sendNotification(true, UfisASCommands.IRT,
String.valueOf(entDbFltJobAssign.getIdFlight()), null, entDbFltJobAssign);
// search record in staffShift table
EntDbStaffShift existStaffShift;
startTime = System.currentTimeMillis();
existStaffShift = dlEKRTCStaffShiftBean
.getExsitRecordByShiftIdX(entDbFltJobAssign
.getShiftId());
LOG.info("search records in staffShift table, takes {} ms", System.currentTimeMillis()
- startTime);
if (existStaffShift != null){
EntDbStaffShift oldEntDbStaffShift = (EntDbStaffShift)SerializationUtils.clone(existStaffShift);
EntDbFltJobTask oldEntDbFltJobTask = (EntDbFltJobTask)SerializationUtils.clone(entDbFltJobTask);
// staffShift set idFlight and updated
existStaffShift.setIdFlight(entDbFltJobTask.getIdFlight());
existStaffShift.setIdFltJobTask(entDbFltJobTask.getId());
existStaffShift.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
// dlEKRTCStaffShiftBean.Update(existStaffShift);
// update fltJboAssign
entDbFltJobAssign.setIdStaffShift(existStaffShift.getId());
entDbFltJobAssign.setStaffFirstName(existStaffShift.getStaffFirstName());
entDbFltJobAssign.setStaffName(existStaffShift.getStaffName());
entDbFltJobAssign.setStaffNumber(existStaffShift.getStaffNumber());
entDbFltJobAssign.setStaffType(existStaffShift.getStaffType());
// dlEKRTCFltJobAssignBean.Update(entDbFltJobAssign);
// send notification
ufisTopicProducer.sendNotification(true, UfisASCommands.URT,
String.valueOf(entDbFltJobTask.getIdFlight()), oldEntDbFltJobTask, entDbFltJobTask);
ufisTopicProducer.sendNotification(true, UfisASCommands.URT,
String.valueOf(existStaffShift.getIdFlight()), oldEntDbStaffShift, existStaffShift);
}
}else if ("UPD".equalsIgnoreCase(blHandleEKRTC.getResAssignMsgSubType())){
// search record in FltJobTask table
EntDbFltJobTask existJobTask;
startTime = System.currentTimeMillis();
existJobTask = dlEKRTCFltJobTaskBean
.getExsitRecordX(entDbFltJobTask.getTaskId());
LOG.info("search records in jobTask table, takes {} ms", System.currentTimeMillis()
- startTime);
// // search record in FltJobTask table
// EntDbFltJobTask existJobTask = dlEKRTCFltJobTaskBean.getExsitRecord(entDbFltJobTask);
// // search exist record of fltJobTask
// EntDbFltJobAssign existJobAssign = dlEKRTCFltJobAssignBean.getExsitRecord(existJobTask.getId(), entDbFltJobAssign.getShiftId());
if (existJobTask != null){
// search exist record of FltJobAssign and StaffShift by idFltJobTask startTime = System.currentTimeMillis();
// search record in staffShift table
EntDbFltJobTask oldEntDbFltJobTask = (EntDbFltJobTask)SerializationUtils.clone(existJobTask);
boolean isContainShiftId = false;
List<EntDbStaffShift> existStaffShiftList;
startTime = System.currentTimeMillis();
existStaffShiftList = dlEKRTCStaffShiftBean
.getExsitRecordByidFltJboTaskX(existJobTask.getId());
LOG.info("search records in staffShift table, takes {} ms", System.currentTimeMillis()
- startTime);
// EntDbFltJobTask existJobTask = dlEKRTCFltJobTaskBean.getExsitRecordByJobAssignShiftId(entDbStaffShift.getShiftId());
List<EntDbFltJobAssign> existJobAssignList;
startTime = System.currentTimeMillis();
existJobAssignList = dlEKRTCFltJobAssignBean
.getExsitRecordX(existJobTask.getId());
LOG.info("search records in jobAssign table, takes {} ms",
System.currentTimeMillis() - startTime);
EntDbStaffShift MatchStaffShift = null;
if (existStaffShiftList != null){
Iterator<EntDbStaffShift> existStaffShiftListIt = existStaffShiftList.iterator();
while (existStaffShiftListIt.hasNext()){
EntDbStaffShift StaffShift = existStaffShiftListIt.next();
if (StaffShift.getShiftId().equals(entDbFltJobAssign.getShiftId())){
isContainShiftId = true;
MatchStaffShift = StaffShift;
break;
}
}
}
if (isContainShiftId){
startTime = System.currentTimeMillis();
// update jobTask
Class<EntDbFltJobTask> EntDbFltJobTask = EntDbFltJobTask.class;
Field[] EntDbFltJobTaskClassFields = EntDbFltJobTask
.getDeclaredFields();
for (Field f : EntDbFltJobTaskClassFields) {
if (!"id".equalsIgnoreCase(f.getName())
&& !"serialVersionUID"
.equalsIgnoreCase(f.getName())) {
setEntityValue(
existJobTask,
f.getName(),
getEntityValue(entDbFltJobTask,
f.getName()));
}
}
existJobTask.setRecStatus(" ");
existJobTask.setUpdatedUser(HpEKConstants.EKRTC_DATA_SOURCE);
existJobTask.setUpdatedDate(HpUfisCalendar
.getCurrentUTCTime());
LOG.info("update fltJobTask table, takes {} ms",
System.currentTimeMillis() - startTime);
// send notification
ufisTopicProducer.sendNotification(true, UfisASCommands.URT,
String.valueOf(existJobTask.getIdFlight()), oldEntDbFltJobTask, existJobTask);
EntDbFltJobAssign matchFltJobAssign = null;
Iterator<EntDbFltJobAssign> existJobAssignListIt = existJobAssignList.iterator();
while (existJobAssignListIt.hasNext()){
EntDbFltJobAssign FltJobAssign = existJobAssignListIt.next();
if (FltJobAssign.getShiftId().equals(entDbFltJobAssign.getShiftId())){
matchFltJobAssign = FltJobAssign;
break;
}
}
if (matchFltJobAssign != null){
startTime = System.currentTimeMillis();
// update jobAssign
Class<EntDbFltJobAssign> EntDbFltJobAssign = EntDbFltJobAssign.class;
Field[] EntDbFltJobAssignClassFields = EntDbFltJobAssign
.getDeclaredFields();
for (Field f : EntDbFltJobAssignClassFields) {
if (!"id".equalsIgnoreCase(f.getName())
&& !"serialVersionUID"
.equalsIgnoreCase(f.getName())) {
setEntityValue(
matchFltJobAssign,
f.getName(),
getEntityValue(entDbFltJobAssign,
f.getName()));
}
}
matchFltJobAssign.setRecStatus(" ");
matchFltJobAssign.setUpdatedDate(HpUfisCalendar
.getCurrentUTCTime());
LOG.info("update fltJobAssign table, takes {} ms",
System.currentTimeMillis() - startTime);
// dlEKRTCFltJobAssignBean.Update(existJobAssign);
}else {
LOG.info("existJobAssign is null, jobAssign table will not be updated");
}
if (MatchStaffShift != null){
startTime = System.currentTimeMillis();
startTime = System.currentTimeMillis();
// update staffShift
MatchStaffShift.setIdFlight(existJobTask
.getIdFlight());
MatchStaffShift.setIdFltJobTask(existJobTask
.getId());
LOG.info("update staffShift table, takes {} ms",
System.currentTimeMillis() - startTime);
}
}else{
startTime = System.currentTimeMillis();
// mark fltJobTask as 'X'
existJobTask.setRecStatus("X");
existJobTask.setUpdatedUser(HpEKConstants.EKRTC_DATA_SOURCE);
existJobTask.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
Iterator<EntDbStaffShift> existStaffShifListIt = existStaffShiftList.iterator();
while(existStaffShifListIt.hasNext()){
EntDbStaffShift entDbStaffShiftX = existStaffShifListIt.next();
// mark existing staffShift as 'X', delete
entDbStaffShiftX.setRecStatus("X");
entDbStaffShiftX.setUpdatedUser(HpEKConstants.EKRTC_DATA_SOURCE);
entDbStaffShiftX.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
}
Iterator<EntDbFltJobAssign> existEntDbFltJobAssignListIt = existJobAssignList.iterator();
while (existEntDbFltJobAssignListIt.hasNext()){
EntDbFltJobAssign entDbFltJobAssignX = existEntDbFltJobAssignListIt.next();
// mark existing fltJobTask as 'X', delete
entDbFltJobAssignX.setRecStatus("X");
entDbFltJobAssignX.setUpdatedUser(HpEKConstants.EKRTC_DATA_SOURCE);
entDbFltJobAssignX.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
}
LOG.info("update related staffShift fltJobAssign fltJobTask records to 'X', takes {} ms ", (System.currentTimeMillis() - startTime));
startTime = System.currentTimeMillis();
// insert new record to fltJobTask and fltJobAssign table
entDbFltJobTask.setIdFlight(urno);
dlEKRTCFltJobTaskBean.Persist(entDbFltJobTask);
entDbFltJobAssign.setIdFlight(urno);
entDbFltJobAssign.setIdFltJobTask(entDbFltJobTask
.getId());
dlEKRTCFltJobAssignBean.Persist(entDbFltJobAssign);
LOG.info("insert new record to fltJobTask and fltJobAssign table, takes {} ms",
System.currentTimeMillis() - startTime);
}
}
// else {
// LOG.info("exist record for JobTask not found, resourceAssignmentType 'UPD' message will be insert as new record");
// // insert into fltJobTask table
// entDbFltJobTask.setIdFlight(urno);
// dlEKRTCFltJobTaskBean.Persist(entDbFltJobTask);
// // insert into fltJobAssign table
// entDbFltJobAssign.setIdFlight(urno);
// entDbFltJobAssign.setIdFltJobTask(entDbFltJobTask.getId());
// dlEKRTCFltJobAssignBean.Persist(entDbFltJobAssign);
//
// startTime = System.currentTimeMillis();
// // search record in staffShift table
// EntDbStaffShift existStaffShift = dlEKRTCStaffShiftBean.getExsitRecordByShiftIdX(entDbFltJobAssign.getShiftId());
// endTime = System.currentTimeMillis();
// LOG.info("takes {} ms to search records in staffShift table ", (endTime - startTime));
//
// if (existStaffShift != null){
// // staffShift set idFlight and updated
// existStaffShift.setIdFlight(entDbFltJobTask.getIdFlight());
// existStaffShift.setIdFltJobTask(entDbFltJobTask.getId());
// existStaffShift.setUpdatedDate(new Date());
//// dlEKRTCStaffShiftBean.Update(existStaffShift);
//
// // update fltJboAssign
// entDbFltJobAssign.setIdStaffShift(existStaffShift.getId());
// entDbFltJobAssign.setStaffFirstName(existStaffShift.getStaffFirstName());
// entDbFltJobAssign.setStaffName(existStaffShift.getStaffName());
// entDbFltJobAssign.setStaffNumber(existStaffShift.getStaffNumber());
// entDbFltJobAssign.setStaffType(existStaffShift.getStaffType());
//// dlEKRTCFltJobAssignBean.Update(entDbFltJobAssign);
// }
// }
}else if ("DEL".equalsIgnoreCase(blHandleEKRTC.getResAssignMsgSubType())){
// search record in FltJobTask table
EntDbFltJobTask existJobTask;
startTime = System.currentTimeMillis();
existJobTask = dlEKRTCFltJobTaskBean
.getExsitRecordX(entDbFltJobTask.getTaskId());
LOG.info("search records in jobTask table, takes {} ms", System.currentTimeMillis()
- startTime);
if (existJobTask != null){
startTime = System.currentTimeMillis();
// mark task record as deleted, "X"
// update jobTask
Class<EntDbFltJobTask> entDbFltJobTaskClass = EntDbFltJobTask.class;
Field[] entDbFltJobTaskClassFields = entDbFltJobTaskClass.getDeclaredFields();
for(Field f : entDbFltJobTaskClassFields){
if (!"id".equalsIgnoreCase(f.getName()) && !"serialVersionUID".equalsIgnoreCase(f.getName())){
setEntityValue(existJobTask, f.getName(), getEntityValue(entDbFltJobTask, f.getName()));
}
}
existJobTask.setRecStatus("X");
// dlEKRTCFltJobTaskBean.Update(existJobTask);
existJobTask.setUpdatedUser(HpEKConstants.EKRTC_DATA_SOURCE);
existJobTask.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
// search exist record of jobAssign
List<EntDbFltJobAssign> existJobAssignList = dlEKRTCFltJobAssignBean.getExsitRecordX(existJobTask.getId());
Iterator<EntDbFltJobAssign> existJobAssignListIt = existJobAssignList.iterator();
while (existJobAssignListIt.hasNext()){
EntDbFltJobAssign existFltJobAssign = existJobAssignListIt.next();
// update jobTask
Class<EntDbFltJobAssign> entDbFltJobAssignClass = EntDbFltJobAssign.class;
Field[] entDbFltJobAssignClassFields = entDbFltJobAssignClass.getDeclaredFields();
for(Field f : entDbFltJobAssignClassFields){
if (!"id".equalsIgnoreCase(f.getName()) && !"serialVersionUID".equalsIgnoreCase(f.getName())){
setEntityValue(existFltJobAssign, f.getName(), getEntityValue(entDbFltJobAssign, f.getName()));
}
}
// mark job assign as deleted, "X"
existFltJobAssign.setIdFlight(existJobTask.getIdFlight());
existFltJobAssign.setRecStatus("X");
existFltJobAssign.setUpdatedUser(HpEKConstants.EKRTC_DATA_SOURCE);
// dlEKRTCFltJobAssignBean.Update(existFltJobAssign);
existFltJobAssign.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
// send notification
ufisTopicProducer.sendNotification(true, UfisASCommands.DET,
String.valueOf(existFltJobAssign.getIdFlight()), null, existFltJobAssign);
}
// search exist record of staffShift
List<EntDbStaffShift> existStaffShiftList = dlEKRTCStaffShiftBean.getExsitRecordByidFltJboTaskX(existJobTask.getId());
Iterator<EntDbStaffShift> existStaffShiftListIt = existStaffShiftList.iterator();
while (existStaffShiftListIt.hasNext()){
EntDbStaffShift existStaffShift = existStaffShiftListIt.next();
// mark staff shift record as deleted, "X"
existStaffShift.setRecStatus("X");
existStaffShift.setUpdatedUser(HpEKConstants.EKRTC_DATA_SOURCE);
// dlEKRTCStaffShiftBean.Update(existStaffShift);
existStaffShift.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
// send notification
ufisTopicProducer.sendNotification(true, UfisASCommands.DET,
String.valueOf(existStaffShift.getIdFlight()), null, existStaffShift);
}
LOG.info("update related staffShift fltJobTask fltJobAssign records to 'X' , takes {} ms", ( System.currentTimeMillis() - startTime));
}else {