Package com.ufis_as.ek_if.rms.entities

Examples of com.ufis_as.ek_if.rms.entities.EntDbStaffShift


   */
  private void insertJobAndShift(RTCAssignmentType _input, String idJobTask,
      BigDecimal urno, StaffDetailsType _inputStaffDetail, String recStatus)
      throws ParseException {
    Date msgSendDate = convertDateToUTC(_input.getMeta().getMessageTime());
    EntDbStaffShift shift = insertShift(idJobTask, urno, _inputStaffDetail, msgSendDate, recStatus);
   
    //INSERT STAFF
    EntDbFltJobAssign jobAssign = new EntDbFltJobAssign();
    if(_inputStaffDetail.getID() != null)//Conditional case
      jobAssign.setStaffNumber(_inputStaffDetail.getID());
    if(_inputStaffDetail.getName() != null)
      jobAssign.setStaffName(_inputStaffDetail.getName());

    EquipmentType equipType = _input.getTaskDetails().getResources().getEquipment();
    EquipmentDetailsType equip = new EquipmentDetailsType();
    if(equipType != null &&  !equipType.getEquipmentDetails().isEmpty()){//Conditional case
      equip = equipType.getEquipmentDetails().get(0);//get the first equip ONLY

      if(equip.getID() != null)//Conditional case
        jobAssign.setEquipId(equip.getID());
      if(equip.getDescription() != null)
        jobAssign.setEquipDesc(equip.getDescription());
    }else{
      jobAssign.setEquipId(null);
      jobAssign.setEquipDesc(null);
    }
   
    jobAssign.setMsgSendDate(msgSendDate);
    jobAssign.setIdStaffShift((shift == null)? null : shift.getId());
    jobAssign.setIdFltJobTask(idJobTask);
    jobAssign.setIdFlight(urno);
    jobAssign.setRecStatus(recStatus);
    jobAssign.setCreatedDate(HpUfisCalendar.getCurrentUTCTime());
    jobAssign.setCreatedUser(HpEKConstants.RMS_RTC_SOURCE);
View Full Code Here


      LOG.debug("No Shift Detail in input Staff <{}>.", _inputStaffDetail.getID());
      return null;
    }
   
    //INSERT SHIFT DETAIL
    EntDbStaffShift dbStaffShift = new EntDbStaffShift();

    if(_inputShiftDetailsType.getFunction()!= null)
      dbStaffShift.setShiftFunctionDate(convertDateToUTC(_inputShiftDetailsType.getFunction()));
    if(_inputShiftDetailsType.getRemarks() != null)
      dbStaffShift.setShiftRemarks(_inputShiftDetailsType.getRemarks());
   
    String mutCode = null;
    //if (isNullOrEmptyStr(_inputShiftDetailsType.getMutationCode())) {// check in MD table
    if (_inputShiftDetailsType.getMutationCode() != null) {// check in MD table
      for (EntDbMdRmsMutateCode mutateCode : clsEntStartUpInitSingleton.getMdRmsMutateCodeList()) {
        if (_inputShiftDetailsType.getMutationCode().equalsIgnoreCase(mutateCode.getMutationId())) {
          if(mutateCode.getStaffTypeCode().equalsIgnoreCase(HpEKConstants.RMS_STAFF_TYPE_ROP))
            mutCode = _inputStaffDetail.getShiftDetails().getMutationCode(); break;
        }
      }
      if(mutCode == null)
        LOG.debug("Mutation Code <{}> is not found in MdRmsMutateCode table.", _inputShiftDetailsType.getMutationCode());
      dbStaffShift.setMutateCode(_inputShiftDetailsType.getMutationCode());
    }

    if(_inputStaffDetail.getID() != null)//Conditional case
      dbStaffShift.setStaffNumber(_inputStaffDetail.getID());
    if(_inputStaffDetail.getName() != null)
      dbStaffShift.setStaffName(_inputStaffDetail.getName());
    if(_inputStaffDetail.getMobile() != null)
      dbStaffShift.setStaffMobileNo(_inputStaffDetail.getMobile());
    if(_inputStaffDetail.getWalkie() != null)
      dbStaffShift.setStaffWalkieNo(_inputStaffDetail.getWalkie());
    if(_inputStaffDetail.getHDD() != null)
      dbStaffShift.setStaffHhdNo(_inputStaffDetail.getHDD());
    if(_inputStaffDetail.getQualification() != null)
      dbStaffShift.setStaffQualification(_inputStaffDetail.getQualification());
    if(_inputShiftDetailsType.getSchStartTime() != null)
      dbStaffShift.setShiftScheStartDate(convertDateToUTC(_inputShiftDetailsType.getSchStartTime()));
    if(_inputShiftDetailsType.getSchEndTime() != null)
      dbStaffShift.setShiftScheEndDate(convertDateToUTC(_inputShiftDetailsType.getSchEndTime()));
    if(_inputShiftDetailsType.getEstStartTime() != null)
      dbStaffShift.setShiftEstStartDate(convertDateToUTC(_inputShiftDetailsType.getEstStartTime()));
    if(_inputShiftDetailsType.getEstEndTime() != null)
      dbStaffShift.setShiftEstEndDate(convertDateToUTC(_inputShiftDetailsType.getEstEndTime()));
    if(_inputShiftDetailsType.getActStartTime() != null)
      dbStaffShift.setShiftActualStartDate(convertDateToUTC(_inputShiftDetailsType.getActStartTime()));
    if(_inputShiftDetailsType.getActEndTime() != null)
      dbStaffShift.setShiftActualEndDate(convertDateToUTC(_inputShiftDetailsType.getActEndTime()));
   
    dbStaffShift.setMsgSendDate(msgSendDate);
    dbStaffShift.setIdFltJobTask(idJobTask);
    dbStaffShift.setIdFlight(urno);
    dbStaffShift.setDataSource(HpEKConstants.RMS_RTC_SOURCE);
    dbStaffShift.setRecStatus(recStatus);
    dbStaffShift.setStaffType(HpEKConstants.RMS_STAFF_TYPE_ROP);     
    dbStaffShift.setCreatedDate(HpUfisCalendar.getCurrentUTCTime());
    dbStaffShift.setCreatedUser(HpEKConstants.RMS_RTC_SOURCE);

    EntDbStaffShift result = clsDlStaffShiftLocal.merge(dbStaffShift);
    if(result != null)
      LOG.debug("Staff Shift has been processed for Staff <{}>.", result.getStaffNumber());
    return result;
  }
View Full Code Here

      jobAssign.setRecStatus(rec_status);
      jobAssign.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
      jobAssign.setUpdatedUser(HpEKConstants.RMS_RTC_SOURCE);
      jobAssign.setMsgSendDate(msgSendDate);
     
      EntDbStaffShift dbStaffShift = null;
      if(!isNullOrEmptyStr(jobAssign.getIdStaffShift())){
        //one job per one shift
         dbStaffShift = clsDlStaffShiftLocal.findById(jobAssign.getIdStaffShift());
        if(dbStaffShift != null){
          //update "X" only when Shift exist
          dbStaffShift.setRecStatus(rec_status);
          dbStaffShift.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
          dbStaffShift.setUpdatedUser(HpEKConstants.RMS_RTC_SOURCE);
          dbStaffShift.setMsgSendDate(msgSendDate);
        }
      }
      EntDbStaffShift resultShift = clsDlStaffShiftLocal.merge(dbStaffShift);
      if(resultShift != null)
        LOG.debug("Removed assign shift for Staff <{}>.", resultShift.getStaffNumber());
      //merge to DB
      EntDbFltJobAssign resultJob = clsDlFltJobAssignLocal.merge(jobAssign);
      if(resultJob != null)
        LOG.debug("Removed assigned job for Staff <{}>.", resultJob.getStaffNumber());

     
    }else if(" ".equals(rec_status)){
         
      /** UPDATE JOB_ASSIGN **/
      if(_inputStaffDetail.getID() != null)//Conditional case
        jobAssign.setStaffNumber(_inputStaffDetail.getID());
      if(_inputStaffDetail.getName() != null)
        jobAssign.setStaffName(_inputStaffDetail.getName());

      EquipmentType equipType = _input.getTaskDetails().getResources().getEquipment();
      EquipmentDetailsType equip = new EquipmentDetailsType();
      if(equipType != null &&  !equipType.getEquipmentDetails().isEmpty()){//Conditional case
        equip = equipType.getEquipmentDetails().get(0);//get the first equip ONLY

        if(equip.getID() != null)//Conditional case
          jobAssign.setEquipId(equip.getID());
        if(equip.getDescription() != null)
          jobAssign.setEquipDesc(equip.getDescription());
      }else{
        jobAssign.setEquipId(null);
        jobAssign.setEquipDesc(null);
      }
      //jobAssign.setRecStatus(rec_status);
      jobAssign.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
      jobAssign.setUpdatedUser(HpEKConstants.RMS_RTC_SOURCE);
      jobAssign.setMsgSendDate(msgSendDate);
      jobAssign.setStaffType(HpEKConstants.RMS_STAFF_TYPE_ROP);
      jobAssign.setTransactUser(_input.getAudit().getChangeUser());
      jobAssign.setTransactDate(convertDateToUTC(_input.getAudit().getChangeTime()));
     
     
      //merge JOB_ASSIGN to db
      EntDbFltJobAssign resultJobAssign = clsDlFltJobAssignLocal.merge(jobAssign);
      if(resultJobAssign != null)
        LOG.debug("Assigned job has been updated for Staff <{}>", resultJobAssign.getStaffNumber());
     
      ShiftDetailsType _inputShiftDetailsType = _inputStaffDetail.getShiftDetails();
     
      /** UPDATE shift **/
      if(isNullOrEmptyStr(jobAssign.getIdStaffShift())){
        LOG.debug("No input shift to update for staff <{}>", jobAssign.getStaffNumber());
      }else{
        EntDbStaffShift dbStaffShift = clsDlStaffShiftLocal.findById(jobAssign.getIdStaffShift());
        if(dbStaffShift != null){//is existing..
          dbStaffShift.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
          dbStaffShift.setUpdatedUser(HpEKConstants.RMS_RTC_SOURCE);
        }
        else{
          dbStaffShift = new EntDbStaffShift();
          dbStaffShift.setCreatedDate(HpUfisCalendar.getCurrentUTCTime());
          dbStaffShift.setCreatedUser(HpEKConstants.RMS_RTC_SOURCE);
        }
       
        dbStaffShift.setMsgSendDate(msgSendDate);
        dbStaffShift.setRecStatus(rec_status);
        dbStaffShift.setStaffType(HpEKConstants.RMS_STAFF_TYPE_ROP);
       
        if(_inputStaffDetail.getID() != null)//Conditional case
          dbStaffShift.setStaffNumber(_inputStaffDetail.getID());
        if(_inputStaffDetail.getName() != null)
          dbStaffShift.setStaffName(_inputStaffDetail.getName());
        if(_inputStaffDetail.getMobile() != null)
          dbStaffShift.setStaffMobileNo(_inputStaffDetail.getMobile());
        if(_inputStaffDetail.getWalkie() != null)
          dbStaffShift.setStaffWalkieNo(_inputStaffDetail.getWalkie());
        if(_inputStaffDetail.getHDD() != null)
          dbStaffShift.setStaffHhdNo(_inputStaffDetail.getHDD());
        if(_inputStaffDetail.getQualification() != null)
          dbStaffShift.setStaffQualification(_inputStaffDetail.getQualification());
        // ShiftDetails
        if(_inputShiftDetailsType != null){
          if(_inputShiftDetailsType.getFunction()!= null)
            dbStaffShift.setShiftFunctionDate(convertDateToUTC(_inputShiftDetailsType.getFunction()));
          if(_inputShiftDetailsType.getRemarks() != null)
            dbStaffShift.setShiftRemarks(_inputShiftDetailsType.getRemarks());
         
          String mutCode = null;
          //if (isNullOrEmptyStr(_inputShiftDetailsType.getMutationCode())) {// check in MD table
          if (_inputShiftDetailsType.getMutationCode() != null) {// check in MD table
            for (EntDbMdRmsMutateCode mutateCode : clsEntStartUpInitSingleton.getMdRmsMutateCodeList()) {
              if (_inputShiftDetailsType.getMutationCode().equalsIgnoreCase(mutateCode.getMutationId())) {
                mutCode = _inputStaffDetail.getShiftDetails().getMutationCode(); break;
              }
            }
            if(mutCode == null)
              LOG.debug("Mutation Code <{}> is not found in MdRmsMutateCode table.", _inputShiftDetailsType.getMutationCode());
            dbStaffShift.setMutateCode(_inputShiftDetailsType.getMutationCode());
          }
         
          if(_inputShiftDetailsType.getSchStartTime() != null)
            dbStaffShift.setShiftScheStartDate(convertDateToUTC(_inputShiftDetailsType.getSchStartTime()));
          if(_inputShiftDetailsType.getSchEndTime() != null)
            dbStaffShift.setShiftScheEndDate(convertDateToUTC(_inputShiftDetailsType.getSchEndTime()));
          if(_inputShiftDetailsType.getEstStartTime() != null)
            dbStaffShift.setShiftEstStartDate(convertDateToUTC(_inputShiftDetailsType.getEstStartTime()));
          if(_inputShiftDetailsType.getEstEndTime() != null)
            dbStaffShift.setShiftEstEndDate(convertDateToUTC(_inputShiftDetailsType.getEstEndTime()));
          if(_inputShiftDetailsType.getActStartTime() != null)
            dbStaffShift.setShiftActualStartDate(convertDateToUTC(_inputShiftDetailsType.getActStartTime()));
          if(_inputShiftDetailsType.getActEndTime() != null)
            dbStaffShift.setShiftActualEndDate(convertDateToUTC(_inputShiftDetailsType.getActEndTime()));
        }
        EntDbStaffShift resultShift = clsDlStaffShiftLocal.merge(dbStaffShift);
        if(resultShift != null)
          LOG.debug("Assigned shift has been updated for Staff <{}>.", resultShift.getStaffNumber());
     
      }
    }
  }
View Full Code Here

   */
  private void insertJobAndShift(RTCAssignmentType _input, String idJobTask,
      BigDecimal urno, StaffDetailsType _inputStaffDetail, String recStatus)
      throws ParseException {
    Date msgSendDate = convertDateToUTC(_input.getMeta().getMessageTime());
    EntDbStaffShift shift = insertShift(idJobTask, urno, _inputStaffDetail, msgSendDate, recStatus);
   
    //INSERT STAFF
    EntDbFltJobAssign jobAssign = new EntDbFltJobAssign();
    if(_inputStaffDetail.getID() != null)//Conditional case
      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
      equip = equipType.getEquipmentDetails().get(0);//get the first equip ONLY

      if(equip.getID() != null)//Conditional case
        jobAssign.setEquipId(equip.getID());
      if(equip.getDescription() != null)
        jobAssign.setEquipDesc(equip.getDescription());
    }else{
      jobAssign.setEquipId(null);
      jobAssign.setEquipDesc(null);
    }
   
    jobAssign.setTransactUser(_input.getAudit().getChangeUser());
    jobAssign.setTransactDate(convertDateToUTC(_input.getAudit().getChangeTime()));
   
    jobAssign.setMsgSendDate(msgSendDate);
    jobAssign.setIdStaffShift((shift == null)? null : shift.getId());
    jobAssign.setIdFltJobTask(idJobTask);
    jobAssign.setIdFlight(urno);
    jobAssign.setRecStatus(recStatus);
    jobAssign.setCreatedDate(HpUfisCalendar.getCurrentUTCTime());
    jobAssign.setCreatedUser(HpEKConstants.RMS_RTC_SOURCE);
View Full Code Here

   */
  private EntDbStaffShift insertShift(String idJobTask, BigDecimal urno,
      StaffDetailsType _inputStaffDetail, Date msgSendDate, String rec) throws ParseException {
   
    //INSERT Service Detail
    EntDbStaffShift dbStaffShift = new EntDbStaffShift();
    if(_inputStaffDetail.getID() != null)//Conditional case
      dbStaffShift.setStaffNumber(_inputStaffDetail.getID());
    if(_inputStaffDetail.getName() != null)
      dbStaffShift.setStaffName(_inputStaffDetail.getName());
    if(_inputStaffDetail.getWalkie() != null)
      dbStaffShift.setStaffWalkieNo(_inputStaffDetail.getWalkie());
    if(_inputStaffDetail.getQualification() != null)
      dbStaffShift.setStaffQualification(_inputStaffDetail.getQualification());
   
    dbStaffShift.setResourceType(HpEKConstants.RMS_RTC_RESOURCE_TYPE);
    dbStaffShift.setMsgSendDate(msgSendDate);
    dbStaffShift.setIdFltJobTask(idJobTask);
    dbStaffShift.setIdFlight(urno);
    dbStaffShift.setDataSource(HpEKConstants.RMS_RTC_SOURCE);
    dbStaffShift.setRecStatus(rec);
    dbStaffShift.setStaffType(HpEKConstants.RMS_STAFF_TYPE_SPHL);     
    dbStaffShift.setCreatedDate(HpUfisCalendar.getCurrentUTCTime());
    dbStaffShift.setCreatedUser(HpEKConstants.RMS_RTC_SOURCE);
   
    EntDbStaffShift result = clsDlStaffShiftLocal.merge(dbStaffShift);
    if(result != null)
      LOG.debug("Staff Shift has been processed for Staff <{}>.", result.getStaffNumber());
    return result;
  }
View Full Code Here

      jobAssign.setRecStatus(rec_status);
      jobAssign.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
      jobAssign.setUpdatedUser(HpEKConstants.RMS_RTC_SOURCE);
      jobAssign.setMsgSendDate(msgSendDate);
     
      EntDbStaffShift dbStaffShift = null;
      if(!isNullOrEmptyStr(jobAssign.getIdStaffShift())){
        //one job per one shift
         dbStaffShift = clsDlStaffShiftLocal.findById(jobAssign.getIdStaffShift());
        if(dbStaffShift != null){
          //update "X" only when Shift exist
          dbStaffShift.setRecStatus(rec_status);
          dbStaffShift.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
          dbStaffShift.setUpdatedUser(HpEKConstants.RMS_RTC_SOURCE);
          dbStaffShift.setMsgSendDate(msgSendDate);
        }
      }
      //merge to DB
      EntDbFltJobAssign resultJob = clsDlFltJobAssignLocal.merge(jobAssign);
      if(resultJob != null)
        LOG.debug("Removed assigned job for Staff <{}>.", resultJob.getStaffNumber());
     
      EntDbStaffShift resultShift = clsDlStaffShiftLocal.merge(dbStaffShift);
      if(resultShift != null)
        LOG.debug("Removed assign shift for Staff <{}>.", resultShift.getStaffNumber());
     
    }else if(" ".equals(rec_status)){
         
      /** UPDATE JOB_ASSIGN **/
      if(_inputStaffDetail.getID() != null)//Conditional case
        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(jobAssign.getIdFlight(), 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: {}",
              jobAssign.getIdFlight(),
              paxName);
        } else if (paxes.size() > 1) {
          LOG.warn("More than 1 Pax found in Load_Pax table by id_flight: {} and pax_name: {}",
              jobAssign.getIdFlight(),
              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(jobAssign.getIdFlight(), 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: {}",
                jobAssign.getIdFlight(),
                paxes.get(0).getPKId().getIntrefnumber(),
                _inputServiceDetailsType.getServiceCode());
          } else {
            idServiceReq = requests.get(0).getUuid();
          }
        }
        jobAssign.setIdLoadPax(idLoadPax);
        jobAssign.setIdServiceReq(idServiceReq);
        jobAssign.setPaxName(paxName);
      }

      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
        equip = equipType.getEquipmentDetails().get(0);//get the first equip ONLY

        if(equip.getID() != null)//Conditional case
          jobAssign.setEquipId(equip.getID());
        if(equip.getDescription() != null)
          jobAssign.setEquipDesc(equip.getDescription());
      }else{
        jobAssign.setEquipId(null);
        jobAssign.setEquipDesc(null);
      }
     
      jobAssign.setTransactUser(_input.getAudit().getChangeUser());
      jobAssign.setTransactDate(convertDateToUTC(_input.getAudit().getChangeTime()));
     
      jobAssign.setMsgSendDate(msgSendDate);
      jobAssign.setRecStatus(rec_status);
      jobAssign.setStaffType(HpEKConstants.RMS_STAFF_TYPE_SPHL);
      jobAssign.setDataSource(HpEKConstants.RMS_RTC_SOURCE);
      jobAssign.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
      jobAssign.setUpdatedUser(HpEKConstants.RMS_RTC_SOURCE);
     
      //merge JOB_ASSIGN to db
      EntDbFltJobAssign resultJobAssign = clsDlFltJobAssignLocal.merge(jobAssign);
      if(resultJobAssign != null)
        LOG.debug("Assigned job has been updated for Staff <{}>", resultJobAssign.getStaffNumber());
     
     
      /** UPDATE shift **/
      if(isNullOrEmptyStr(jobAssign.getIdStaffShift())){
        LOG.debug("No input shift to update for staff <{}>", jobAssign.getStaffNumber());
      }else{
        EntDbStaffShift dbStaffShift = clsDlStaffShiftLocal.findById(jobAssign.getIdStaffShift());
        if(dbStaffShift != null){//is existing..
          dbStaffShift.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
          dbStaffShift.setUpdatedUser(HpEKConstants.RMS_RTC_SOURCE);
        }
        else{
          dbStaffShift = new EntDbStaffShift();
          dbStaffShift.setCreatedDate(HpUfisCalendar.getCurrentUTCTime());
          dbStaffShift.setCreatedUser(HpEKConstants.RMS_RTC_SOURCE);
        }
     
        if(_inputStaffDetail.getID() != null)//Conditional case
          dbStaffShift.setStaffNumber(_inputStaffDetail.getID());
        if(_inputStaffDetail.getName() != null)
          dbStaffShift.setStaffName(_inputStaffDetail.getName());
        if(_inputStaffDetail.getWalkie() != null)
          dbStaffShift.setStaffWalkieNo(_inputStaffDetail.getWalkie());
        if(_inputStaffDetail.getQualification() != null)
          dbStaffShift.setStaffQualification(_inputStaffDetail.getQualification());
       
        dbStaffShift.setRecStatus(rec_status);
        dbStaffShift.setMsgSendDate(msgSendDate);
        dbStaffShift.setStaffType(HpEKConstants.RMS_STAFF_TYPE_SPHL);
        dbStaffShift.setDataSource(HpEKConstants.RMS_RTC_SOURCE);
        dbStaffShift.setStaffType(HpEKConstants.RMS_STAFF_TYPE_SPHL);     
       
        EntDbStaffShift resultShift = clsDlStaffShiftLocal.merge(dbStaffShift);
        if(resultShift != null)
          LOG.debug("Assigned shift has been updated for Staff <{}>.", resultShift.getStaffNumber());
     
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.ufis_as.ek_if.rms.entities.EntDbStaffShift

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.