Package com.ufis_as.ufisapp.lib.time

Examples of com.ufis_as.ufisapp.lib.time.HpUfisCalendar


              }
             
              // Calculate the time span between main and connect flight
              BigDecimal idArrFlight = null;
              BigDecimal idDepFlight = null;
              HpUfisCalendar tifa = null;
              HpUfisCalendar tifd = null;
              char tga1 = ' ';
              char tgd1 = ' ';
              if (ADID_ARRIVAL == mainFlt.getAdid()) {
                tifa = new HpUfisCalendar(mainFlt.getTifa());
                tifd = new HpUfisCalendar(conxFlight.getTifd());
                idArrFlight = mainFlt.getUrno();
                idDepFlight = conxFlight.getUrno();
                tga1 = mainFlt.getTga1();
                tgd1 = conxFlight.getTgd1();
              } else {
                tifa = new HpUfisCalendar(conxFlight.getTifa());
                tifd = new HpUfisCalendar(mainFlt.getTifd());
                idArrFlight = conxFlight.getUrno();
                idDepFlight = mainFlt.getUrno();
                tga1 = conxFlight.getTgd1();
                tgd1 = mainFlt.getTga1();
              }
              int timeDiff = (int) tifa.timeDiff(tifd, EnumTimeInterval.Minutes, false);
              LOG.debug("Time Difference between main flight and conx flight: {} mins", timeDiff);
             
              // check bag/pax/uld number for transfer
              int transferNum = 0;
            switch (tab) {
            case HpUfisAppConstants.CON_LOAD_BAG_SUMMARY:
              transferNum = dto.getBagPcs();
              break;
            case HpUfisAppConstants.CON_LOAD_PAX_SUMMARY:
              transferNum = dto.getTotalPax();
              break;
            case HpUfisAppConstants.CON_LOAD_ULD_SUMMARY:
              transferNum = dto.getUldPcs();
              break;
            default:
              break;
            }
           
            // Connection status (no transfer subject or pax, no connection)
              String status = null;
              if (transferNum > 0 || tab.equals(HpUfisAppConstants.CON_AFTTAB)) {
                long shortTime = 0;
                long criticalTime = 0;
                if (tga1 != ' ' && tga1 == tgd1) {
                  shortTime = HpEKConstants.CONX_ST_SHORT;
                  criticalTime = HpEKConstants.CONX_ST_CRITICAL;
                } else {
                  shortTime = HpEKConstants.CONX_DT_SHORT;
                  criticalTime = HpEKConstants.CONX_DT_CRITICAL;
                }
                LOG.debug("TGA1: {} - TGD1: {}", tga1, tgd1);
                LOG.debug("Short: {}", shortTime);
                LOG.debug("Critical: {}", criticalTime);
               
                if (timeDiff <= criticalTime) {
                // Critical
                status = HpUfisAppConstants.CONX_STAT_CRITICAL;
                criticalCount += 1;
                } else if (timeDiff > criticalTime && timeDiff <= shortTime) {
                  // Short
                status = HpUfisAppConstants.CONX_STAT_SHORT;
                shortCount += 1;
              } else if (timeDiff > shortTime) {
                // Normal
                status = HpUfisAppConstants.CONX_STAT_NOMRAL;
              } else {
                // No Connection
                status = HpUfisAppConstants.CONX_STAT_NOCONNX;
              }
              } else {
                // No Connection
              status = HpUfisAppConstants.CONX_STAT_NOCONNX;
              }
             
             
              // Find FLT_CONNECT_SUMMARY by id_arr_flight and id_dep_flight
              UfisASCommands cmd =  UfisASCommands.URT;
              EntDbFltConnectSummary data = null;
              EntDbFltConnectSummary fltConx = fltConnectSummaryBean.findExisting(idArrFlight, idDepFlight);
              if (fltConx == null) {
                data = new EntDbFltConnectSummary();
                cmd =  UfisASCommands.IRT;
                data = new EntDbFltConnectSummary();
                data.setIdArrFlight(idArrFlight);
                data.setIdDepFlight(idDepFlight);
                data.setCreatedDate(HpUfisCalendar.getCurrentUTCTime());
                data.setCreatedUser(HpEKConstants.FLT_CONX_SOURCE);
                // 2013-11-05 added by JGO - Default connection status
                data.setConxStatPax(HpUfisAppConstants.CONX_STAT_NOCONNX);
                data.setConxStatBag(HpUfisAppConstants.CONX_STAT_NOCONNX);
                data.setConxStatUld(HpUfisAppConstants.CONX_STAT_NOCONNX);
              // 2013-11-04 added by JGO - default decision
                data.setConxDecBag(HpUfisAppConstants.CONX_DEC_NODC);
                data.setConxDecPax(HpUfisAppConstants.CONX_DEC_NODC);
                data.setConxDecUld(HpUfisAppConstants.CONX_DEC_NODC);
                data.setRecStatus(" ");
                fltConnectSummaryBean.persist(data);
              } else {
                data = EntDbFltConnectSummary.valueOf(fltConx);
              }
             
              //evaluatePaxJourneyTime
              switch(tab) {
                case HpUfisAppConstants.CON_AFTTAB:
              case HpUfisAppConstants.CON_LOAD_PAX_SUMMARY:
                 evaluatePaxJourneyTime(tab, mainFlt, conxFlight, data, timeDiff);
                break;
              default:
                break;
              }
            
            switch (tab) {
            case HpUfisAppConstants.CON_AFTTAB:
              data.setConxStatBag(status);
              data.setConxStatPax(status);
              data.setConxStatUld(status);
              break;
            case HpUfisAppConstants.CON_LOAD_BAG_SUMMARY:
              data.setConxStatBag(status);
              break;
            case HpUfisAppConstants.CON_LOAD_PAX_SUMMARY:
              data.setConxStatPax(status);
              break;
            case HpUfisAppConstants.CON_LOAD_ULD_SUMMARY:
              data.setConxStatUld(status);
              break;
            default:
              break;
            }
              data.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
              data.setUpdatedUser(HpEKConstants.FLT_CONX_SOURCE);
             
              //set tifa/tifd
              data.setTifa(tifa.getTime());
              data.setTifd(tifd.getTime());
             
              data = fltConnectSummaryBean.merge(data);
            LOG.debug("Flt_Connect_Summary record has been created/update for idArrFlight={} and idDepFlight={}",
                data.getIdArrFlight(),
                data.getIdDepFlight());
View Full Code Here


   */
  private void sendCountToCeda(String tab, String idFlight, int criticalCount, int shortCount) {
    try {
      StringWriter writer = new StringWriter();
      _ms.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
      HpUfisCalendar ufisCalendar = new HpUfisCalendar(TimeZone.getTimeZone("UTC"));

      MSG msg = new MSG();
      MSG.MSGSTREAMIN msgstream_in = new MSG.MSGSTREAMIN();

      // HEADER
      INFOBJGENERIC infobjgeneric = new INFOBJGENERIC();
      infobjgeneric.setACTIONTYPE(ACTIONTYPE.U);
      infobjgeneric.setMESSAGETYPE(HpEKConstants.JCEDA_SOURCE);
      infobjgeneric.setMESSAGEORIGIN(HpEKConstants.FLT_CONX_SOURCE);
      infobjgeneric.setURNO(idFlight);
      infobjgeneric.setTIMEID(TIMEID.UTC);
      infobjgeneric.setTIMESTAMP(ufisCalendar.getCedaString());

      // BODY
      MSGOBJECTS msgObjects = new MSGOBJECTS();
      INFOBJFLIGHT infobjFlight = new INFOBJFLIGHT();
      String cxCount = Integer.toString(criticalCount);
View Full Code Here

      XMLGregorianCalendar fltDate) {
    if (fltDate == null) {
      return null;
    }
    try {
      HpUfisCalendar ufisCalendar = new HpUfisCalendar();
      // df.setTimeZone(TimeZone.getTimeZone("UTC"));
      ufisCalendar.setTime(fltDate);
      return fldaDF.format(ufisCalendar.getTime());
      // return ufisCalendar.getCedaDateString();
    } catch (Exception e) {
      LOG.error("ERROR!!!: {}" + e);
    }
    return null;
View Full Code Here

  private Date chgXMLGregorianCalendarToDate(XMLGregorianCalendar fltDate) {
    if (fltDate == null) {
      return null;
    }
    try {
      HpUfisCalendar ufisCalendar = new HpUfisCalendar();
      // df.setTimeZone(TimeZone.getTimeZone("UTC"));
      ufisCalendar.setTime(fltDate);
      return ufisCalendar.getTime();
      // return ufisCalendar.getCedaDateString();
    } catch (Exception e) {
      LOG.error("ERROR!!!: {}" + e);
    }
    return null;
View Full Code Here

   
  private Date convertXMLGregorianCalendarToDate(XMLGregorianCalendar calendar) {
    Date result = null;
    if (calendar != null) {

      HpUfisCalendar cal = new HpUfisCalendar(calendar);
      DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
      DateFormat df2 = new SimpleDateFormat("yyyyMMddHHmmss");
      df.setTimeZone(HpEKConstants.utcTz);
      String date = df.format(cal.getTime());
      try {
        result = df2.parse(date);
      } catch (ParseException e) {
        LOG.debug("timezone convertion erro" + e);
      }
View Full Code Here

      DateFormat df = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
      DateFormat df2 = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
//      try {
       if (dateTimeString != null) {
        LOG.info("df.parse:" + df.parse(dateTimeString));
        HpUfisCalendar cal = new HpUfisCalendar(df.parse(dateTimeString));

        df.setTimeZone(HpEKConstants.utcTz);
        String date = df.format(cal.getTime());
        LOG.info("(cal):" + cal.getTime());
        LOG.info("df.format(cal):" + date);
        LOG.info("df2.parse:" + df2.parse(date));
        result = df2.parse(date);
       }
//      } catch (Exception e) {
View Full Code Here

    // ftyp
    queryStr.append("a.ftyp = :ftyp");

    // tifa or tifd in range (range: -3 ~ +3, Local to UTC: -4)
    HpUfisCalendar ufisCalendarFrom = new HpUfisCalendar();
    ufisCalendarFrom.DateAdd(-7, EnumTimeInterval.Hours);

    HpUfisCalendar ufisCalendarTo = new HpUfisCalendar();
    ufisCalendarTo.DateAdd(-1, EnumTimeInterval.Hours);
    queryStr.append(" AND ");
    queryStr.append("((a.tifa between :fromDate and :endDate) or (a.tifd between :fromDate and :endDate))");

    Query query = em.createQuery(queryStr.toString());
    if (HpUfisUtils.isNotEmptyStr(carrier) && carrier.length() == 2) {
      query.setParameter("alc2", carrier);
    }
    if (HpUfisUtils.isNotEmptyStr(carrier) && carrier.length() == 3) {
      query.setParameter("alc3", carrier);
    }
    if (HpUfisUtils.isNotEmptyStr(fltn)) {
      query.setParameter("fltn", fltn);
    }
    if (HpUfisUtils.isNotEmptyStr(org3)) {
      query.setParameter("org3", org3);
    }
    if (HpUfisUtils.isNotEmptyStr(regn)) {
      query.setParameter("regn", regn);
    }
    query.setParameter("ftyp", 'O');
    query.setParameter("fromDate", ufisCalendarFrom.getCedaString());
    query.setParameter("endDate", ufisCalendarTo.getCedaString());
    EntDbAfttab flight = null;
    try {
      List<EntDbAfttab> list = query.getResultList();
      if (list != null && list.size() > 0) {
        flight = list.get(0);
View Full Code Here

 
  @Override
  public List<EntDbAfttab> findAllFlightByTimeRange() {
    List<EntDbAfttab> res = new ArrayList<>();

    HpUfisCalendar startDate = new HpUfisCalendar();
    HpUfisCalendar endDate = new HpUfisCalendar();
    startDate.setTimeZone(HpEKConstants.utcTz);
    endDate.setTimeZone(HpEKConstants.utcTz);

    startDate.DateAdd(HpPaxAlertTimeRangeConfig.getPaxAlertFromOffset(),
        EnumTimeInterval.Hours);
    endDate.DateAdd(HpPaxAlertTimeRangeConfig.getPaxAlertToOffset(),
        EnumTimeInterval.Hours);
    LOG.debug("TIFA FromOffset : <{}>  ToOffset : <{}>",
        startDate.getCedaString(), endDate.getCedaString());

    Query query = em
        .createNamedQuery("EntDbAfttab.findForEKByTifaTimeRange");
    query.setParameter("startDate", startDate.getCedaString());
    query.setParameter("endDate", endDate.getCedaString());
    query.setParameter("adid", 'A');// find for arrival flight only
    try {
      res = query.getResultList();
      LOG.debug("Total Arrival Flight for  <{}>", res.size());
View Full Code Here

  }

  public Tuple getUrnoByCriteriaQuery(EntDbAfttab params,
      MSGTYPE egdsMsgType, ADID adid, int fromOffset, int toOffset) {
    // BigDecimal uaft = null;
    HpUfisCalendar ufisCalendarFrom = new HpUfisCalendar();
    HpUfisCalendar ufisCalendarTo = new HpUfisCalendar();

    CriteriaBuilder cb = em.getCriteriaBuilder();
    // CriteriaQuery<BigDecimal> cq = cb.createQuery(BigDecimal.class);
    CriteriaQuery<Tuple> cq = cb.createTupleQuery();

    // from
    Root<EntDbAfttab> root = cq.from(EntDbAfttab.class);

    // select
    // cq.select(root.<BigDecimal>get("urno"));
    cq.multiselect(root.get("urno").alias("urno"),
        root.get("tifa").alias("tifa"), root.get("tifd").alias("tifd"),
        root.get("adid").alias("adid"));

    // result value limited filters
    List<Predicate> filters = new LinkedList<>();
    // alc2
    filters.add(cb.equal(root.get("alc2"), HpEKConstants.EK_ALC2));
    // fltn
    if (HpUfisUtils.isNotEmptyStr(params.getFltn())) {
      filters.add(cb.equal(cb.trim(root.<String> get("fltn")),
          params.getFltn()));
    }
    // regn
    filters.add(cb.equal(cb.trim(root.<String> get("regn")),
        params.getRegn()));
    // ftyp
    filters.add(cb.equal(root.get("ftyp"), HpEKConstants.EK_FTYP_OPERATION));

    // range
    ufisCalendarFrom.DateAdd(fromOffset, EnumTimeInterval.Hours);
    ufisCalendarTo.DateAdd(toOffset, EnumTimeInterval.Hours);
    LOG.debug("EGDS: fromOffset={}", ufisCalendarFrom.getCedaString());
    LOG.debug("EGDS: toOffset={}", ufisCalendarTo.getCedaString());

    if (adid != null && egdsMsgType != MSGTYPE.ROUTE) {
      if (MSGTYPE.MVT == egdsMsgType) {
        // time range
        if (ADID.A == adid) {
          filters.add(cb.between(root.<String> get("stoa"),
              ufisCalendarFrom.getCedaString(),
              ufisCalendarTo.getCedaString()));
        } else {
          filters.add(cb.between(root.<String> get("stod"),
              ufisCalendarFrom.getCedaString(),
              ufisCalendarTo.getCedaString()));
        }
      } else if (MSGTYPE.ROUTE == egdsMsgType) {
        // time range
        filters.add(cb.between(root.<String> get("tifd"),
            ufisCalendarFrom.getCedaString(),
            ufisCalendarTo.getCedaString()));
        // atot (actual takeo-ff time)
        // filters.add(cb.equal(root.<String>get("atot"), " "));
        filters.add(cb.isNull(cb.trim(root.<String> get("atot"))));
        // aobt (actual off-block time
        // filters.add(cb.equal(root.<String>get("aobt"), " "));
        filters.add(cb.isNull(cb.trim(root.<String> get("aobt"))));
      } else {
        if (ADID.A == adid) {
          // time range
          filters.add(cb.between(root.<String> get("tifa"),
              ufisCalendarFrom.getCedaString(),
              ufisCalendarTo.getCedaString()));
          if (MSGTYPE.FUEL == egdsMsgType) {
            // aldt
            filters.add(cb.isNotNull(cb.trim(root
                .<String> get("aldt"))));
          }
        } else {
          // time range
          filters.add(cb.between(root.<String> get("tifd"),
              ufisCalendarFrom.getCedaString(),
              ufisCalendarTo.getCedaString()));
          if (MSGTYPE.FUEL == egdsMsgType) {
            filters.add(cb.isNull(cb.trim(root.<String> get("atot"))));
            filters.add(cb.isNull(cb.trim(root.<String> get("aobt"))));
          }
        }
      }
    } else {
      // (adid = A And tifa between x and y) or (adid = D And tifd between
      // x and y)
      Predicate p = cb.and(cb.or(cb.and(
          cb.equal(root.get("adid"), HpEKConstants.ADID_A),
          cb.between(root.<String> get("tifa"),
              ufisCalendarFrom.getCedaString(),
              ufisCalendarTo.getCedaString())), cb.and(
          cb.equal(root.get("adid"), HpEKConstants.ADID_D),
          cb.between(root.<String> get("tifd"),
              ufisCalendarFrom.getCedaString(),
              ufisCalendarTo.getCedaString()))));
      filters.add(p);
    }

    cq.where(cb.and(filters.toArray(new Predicate[0])));
    Query query = em.createQuery(cq);
View Full Code Here

  @Override
  public BigDecimal getUrnoByFilterQuery(EntDbAfttab params, ADID adid,
      short fromOffset, short toOffset) {
    // BigDecimal uaft = null;
    long startTime = new Date().getTime();
    HpUfisCalendar ufisCalendarFrom = new HpUfisCalendar();
    HpUfisCalendar ufisCalendarTo = new HpUfisCalendar();
    HpUfisCalendar ufisCurrentCalendar = new HpUfisCalendar();
    BigDecimal result = null;
    try {
      ufisCalendarFrom.setTime(ufisCalendarFrom.getCurrentUTCTime());
      ufisCalendarTo.setTime(ufisCalendarTo.getCurrentUTCTime());
      ufisCurrentCalendar
          .setTime(ufisCurrentCalendar.getCurrentUTCTime());
      // LOG.info("ufisCalendarFrom:"+ufisCalendarFrom.getCedaString()+"  ufisCalendarTo:"+ufisCalendarTo.getCedaString()+"  ufisCurrentCalendar:"+ufisCurrentCalendar.getCedaString());
      long currTimeInMillis = ufisCurrentCalendar.getTimeInMillis();
      // LOG.info("Current Time:" + ufisCurrentCalendar.getCedaString());
      // LOG.info("Current Time In Millis:" + currTimeInMillis);
      CriteriaBuilder cb = em.getCriteriaBuilder();
      // CriteriaQuery cq = cb.createQuery();
      CriteriaQuery<Tuple> cq = cb.createTupleQuery();

      // fromO
      Root<EntDbAfttab> root = cq.from(EntDbAfttab.class);

      // select
      // cq.select(root.<BigDecimal>get("urno"));
      // cq.select(root.get("urno").alias("urno"));
      cq.multiselect(root.get("urno").alias("urno"), root.get("stoa")
          .alias("stoa"), root.get("stod").alias("stod"));
      // result value limited filters
      List<Predicate> filters = new LinkedList<>();
      // LOG.info("FLNO:" + params.getFlno());
      // flno
      if (HpUfisUtils.isNotEmptyStr(params.getFlno())) {
        // filters.add(cb.equal(cb.trim(root.<String> get("flno")),
        // params.getFlno()));
        filters.add(cb.equal(cb.trim(root.<String> get("flno")), params
            .getFlno().trim()));
      }

      filters.add(cb.not(cb.in(root.get("ftyp")).value('T').value('G')
          .value('X').value('N')));

      // range
      ufisCalendarFrom.DateAdd(fromOffset, EnumTimeInterval.Minutes);
      ufisCalendarTo.DateAdd(toOffset, EnumTimeInterval.Minutes);
      // LOG.info("PROVEO: fromOffset={}",
      // ufisCalendarFrom.getCedaString());
      // LOG.info("PROVEO: toOffset={}", ufisCalendarTo.getCedaString());
      LOG.info("ufisCalendarFrom After adding Offset:"
          + ufisCalendarFrom.getCedaString()
          + "  ufisCalendarTo after adding Offset:"
          + ufisCalendarTo.getCedaString());
      if (adid != null) {
        // time range
        if (ADID.A.equals(adid)) {
          filters.add(cb.between(root.<String> get("stoa"),
              ufisCalendarFrom.getCedaString(),
              ufisCalendarTo.getCedaString()));
        } else {
          filters.add(cb.between(root.<String> get("stod"),
              ufisCalendarFrom.getCedaString(),
              ufisCalendarTo.getCedaString()));
        }

      }
      // SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMddHHmmss");
      // cb.diff(root.<String> get("stoa"),sdf.parse(new
      // HpUfisCalendar().getCedaString()));

      cq.where(cb.and(filters.toArray(new Predicate[0])));
      if (ADID.A.equals(adid)) {
        cq.orderBy(cb.desc(root.<String> get("stoa")));
      } else {
        cq.orderBy(cb.desc(root.<String> get("stod")));
      }
      Query query = em.createQuery(cq);
      // List<BigDecimal> result = query.getResultList();
      List<Tuple> results = query.getResultList();
      if (results == null || results.size() == 0) {
        LOG.warn("PROVEO: Cannot find flight from afttab");
        // LOG.info("CriteriaQuery: {}", cq.toString());
      } else if (results.size() > 1) {
        long min = 0;
        long stoaCal = 0;
        long stodCal = 0;
        LOG.info("PROVEO: More than 1 record found for flight from afttab");
        // LOG.info("CriteriaQuery: {}", cq.toString());
        for (int i = 0; i < results.size(); i++) {
          if (ADID.A == adid) {
            // LOG.info("results.get(i).get(1):" +
            // results.get(i).get(1) + "   String:" +
            // results.get(i).get(1).toString());
            stoaCal = new HpUfisCalendar(results.get(i).get(1)
                .toString(), "yyyyMMddHHmmss")
                .getTimeInMillis();
            // LOG.info("STOACAL:" + stoaCal);
            if (i == 0) {
              min = Math.abs(currTimeInMillis - stoaCal);
              result = (BigDecimal) results.get(0).get(0);
            }
            if (Math.abs(currTimeInMillis - stoaCal) < min) {
              min = Math.abs(currTimeInMillis - stoaCal);
              result = (BigDecimal) results.get(i).get(0);
            }
            // LOG.info("MIN:" + min + "  Result:" + result);
          } else if (ADID.D == adid) {
            // LOG.info("results.get(i).get(2):" +
            // results.get(i).get(2) + "   String:" +
            // results.get(i).get(2).toString());
            stodCal = new HpUfisCalendar(results.get(i).get(2)
                .toString(), "yyyyMMddHHmmss")
                .getTimeInMillis();
            // LOG.info("STODCAL:" + stodCal);
            if (i == 0) {
              min = Math.abs(currTimeInMillis - stodCal);
View Full Code Here

TOP

Related Classes of com.ufis_as.ufisapp.lib.time.HpUfisCalendar

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.