⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ticketescalationmanagerejb.java

📁 CRM源码This file describes some issues that should be implemented in future and how it should be imple
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            return getNextCheckDate( delay, Calendar.MINUTE );
        case TicketEscalationHelper.HOURS_DELAY_UNITS:
            return getNextCheckDate( delay, Calendar.HOUR );
        case TicketEscalationHelper.DAYS_DELAY_UNITS:
            return getNextCheckDate( delay, Calendar.DATE );
        case TicketEscalationHelper.WORKDAYS_DELAY_UNITS:
            return getNextCheckDateForWorkDays( delay );
        default:
            throwException( "Unsupported ticket escalation delay units: "
                            + delayUnits );
            return null;
        }
    }

    //
    // Check ticket and ticket escalation.
    //
    private boolean equals( LogonSession ls, TicketObject ticket,
                            TicketEscalationObject escalation )
        throws EQLException {
        JEOManagerLocal jeoManager = getJEOManagerLocal();
        EQLManagerLocal eqlManager = getEQLManagerLocal();
        // Check for equal statuses.
        // getEscalation ID
        Long escalationId = escalation.getQw_escalationid();
        // ticket status
        Integer ticketStatus = ticket.getQw_status();
        if( ticketStatus == null ) {
            throw new NullPointerException(
                "Field 'STATUS' is NULL. Ticket #" + ticket.getQw_ticketid() );
        }
        // Check for equal status.
        List escStatusHandlers = EscStatusFieldObjectHandler
            .selectByEscalationId( jeoManager, ls, escalationId );

        if( escStatusHandlers != null ) {
            boolean returned = false;
            for( int i = 0; i < escStatusHandlers.size(); i++ ) {
                EscStatusFieldObjectHandler escStatusFieldObjectHandler = 
                    ( EscStatusFieldObjectHandler ) escStatusHandlers.get( i );
                EscStatusFieldObject escStatusFieldObject = 
                    ( EscStatusFieldObject ) escStatusFieldObjectHandler.getJEObject();
                if( escStatusFieldObject.getQw_status().intValue() == ticketStatus.intValue() ) {
                    returned = true;
                    break;
                }
            }
            if( !returned ) {
                return false;
            }
        }
        // Check for equal priorities.
        Integer ticketPriority = ticket.getQw_priority();
        if( ticketPriority == null ) {
            throw new NullPointerException(
                "Field 'PRIORITY' is NULL. Ticket #" + ticket.getQw_ticketid() );
        }
        List escPriorityHandlers = EscPriorityFieldObjectHandler
            .selectByEscalationId( jeoManager, ls, escalationId );

        if( escPriorityHandlers != null ) {
            boolean returned = false;
            for( int i = 0; i < escPriorityHandlers.size(); i++ ) {
                EscPriorityFieldObjectHandler escPriorityFieldObjectHandler = 
                    ( EscPriorityFieldObjectHandler ) escPriorityHandlers.get( i );
                EscPriorityFieldObject escPriorityFieldObject = 
                    ( EscPriorityFieldObject ) escPriorityFieldObjectHandler.getJEObject();

                if( escPriorityFieldObject.getQw_priority().intValue() == ticketPriority.intValue() ) {
                    returned = true;
                    break;
                }
            }
            if( !returned ) {
                return false;
            }
        }

        // Check for equals organizations.
        Long ticketCustomer = ticket.getQw_customerid();
        boolean isIntCustomer = false;
        if(ticketCustomer == null){
            ticketCustomer = ticket.getQw_employeeid();
            isIntCustomer = true;
        }    
        Long ticketOrg = null; 
        if(!isIntCustomer)
            ticketOrg = CustomerObjectHandler.selectOrgByID( eqlManager, ls, ticketCustomer.longValue() );
        else
            ticketOrg = EmployeeObjectHandler.selectOrgByID( eqlManager, ls, ticketCustomer.longValue() );
        
        Long escOrg = escalation.getQw_organizationid();
        
        if( ticketOrg == null)
            if(escOrg != null) return false;
        else
            if( escOrg != null && escOrg.longValue() != ticketOrg.longValue() ) return false;
        
        // Apply product filter.
        Long ticketProduct = ticket.getQw_productid();
        Long escProduct = escalation.getQw_productid();
        String productFilter = escalation.getQw_productfilter();

        if( !checkTicketProduct( ls, ticketProduct, escProduct, productFilter ) ) {
            return false;
        }
        // Return true.
        return true;
    }

    //
    // Checks ticket product.
    //
    private boolean checkTicketProduct( LogonSession ls, Long ticketProduct,
                                        Long escProduct, String filter )
        throws EQLException {

        // Check Ids.
        if( escProduct != null ) {
            return escProduct.equals( ticketProduct );
        }
        // Check filters.
        if( filter == null ) {
            // ..skip checking
            return true;
        }

        // check 'product' name by template
        ReqEntity reqEntity = new ReqEntity();
        reqEntity.setName( PRODUCT_ENTITY );

        Req req = new Req();
        req.setReqEntity( reqEntity );

        // .. add first condirion = id
        ReqFilters reqFilters = new ReqFilters();
        ReqFilter reqFilter = new ReqFilter();
        reqFilter.setEntity( PRODUCT_ENTITY );
        reqFilter.setName( PRODUCT_EFIELD_ID );
        reqFilter
            .setReqFilterValue( new String[] {String.valueOf( ticketProduct )} );
        ReqFiltersTypeItem reqFiltersTypeItem = new ReqFiltersTypeItem();
        reqFiltersTypeItem.setReqFilter( reqFilter );
        reqFilters.addReqFiltersTypeItem( reqFiltersTypeItem );

        // .. add second condition like 'filter'
        reqFilter = new ReqFilter();
        reqFilter.setEntity( PRODUCT_ENTITY );
        reqFilter.setName( PRODUCT_EFIELD_NAME );
        reqFilter.setReqFilterValue( new String[] {filter} );
        reqFiltersTypeItem = new ReqFiltersTypeItem();
        reqFiltersTypeItem.setReqFilter( reqFilter );
        reqFilters.addReqFiltersTypeItem( reqFiltersTypeItem );

        Reqs reqs = new Reqs();
        reqs.setReq( req );
        reqs.setReqFilters( reqFilters );
        reqs.setDoheader( Boolean.FALSE );
        reqs.setGetrequest( Boolean.FALSE );
        reqs.setDocount( Boolean.TRUE );

        // .. call GetRecords EJB
        GetRecordsLocal local = ( GetRecordsLocal ) getLocalObject(
            JNDINames.GetRecords, GetRecordsLocalHome.class );

        GetRecordsRes grRes = local.process( reqs, ls );
        Ress ress = grRes.getRess();

        if( getLogger().isInfoEnabled() ) {
            INFO( "Check product by the filter '" + filter + "' and pkey: "
                  + ticketProduct + ". Run GetRecords. Got count: "
                  + ress.getCount() );
        }

        if( ress.getCount().intValue() <= 0 ) {
            // not equals
            return false;
        } else {
            return true;
        }
    }

    //
    // Checks escalation fireif.
    //
    private boolean checkFireif( TicketObject ticketObject,
                                 TicketEscalationObject escObj, TicketEsclEventObject eventObj ) {

        boolean continueEscalation = false;
        int fireif = escObj.getQw_fireif().intValue();
        switch( fireif ) {
        case TicketEscalationHelper.NOT_CLOSED_FIREIF:
            // If ticket has status 'CLOSED' - break escalation
            if( ticketObject.getQw_status().intValue() != TicketHelper.CLOSED_STATUS ) {
                // ..failed - continue
                continueEscalation = true;
            }
            break;
        case TicketEscalationHelper.NOT_ASSIGNED_FIREIF:
            // If ticket has not status 'NEW' - break escalation
            if( ticketObject.getQw_status().intValue() == TicketHelper.NEW_STATUS ) {
                // ..failed - continue
                continueEscalation = true;
            }
            break;
        case TicketEscalationHelper.NOT_UPDATED_FIREIF:
            // If ticket's modified date is greater than event's - break
            // escalation
            Date eventDatemodified = eventObj.getQw_datemodified();
            Date ticketDatemodified = ticketObject.getQw_datemodified();
            if( eventDatemodified != null
                && ticketDatemodified != null
                && ticketDatemodified.getTime() <= eventDatemodified.getTime() ) {
                // ..failed - continue
                continueEscalation = true;
            }
            break;
        default:
            throwException( "Unsupported escalation 'FireIf': " + fireif );
        }
        return continueEscalation;
    }

    //
    // Ticket entity loader.
    //
    private Entity loadTicketEntity() {
        return getEntityViewConfigManagerLocal().getEntityViewConfig(
            TicketObjectHandler.ENTITY );
    }


    //
    // Escalation message loader.
    //
    private String loadEscalationMessage() {

        StringBuffer msgBody = new StringBuffer();
        msgBody.append( "Ticket #<qw_ticketid> escalation message" );
        msgBody.append( "\nTicket ID: <qw_ticketid>" );
        msgBody.append( "\nCustomer: <qw_customerid>" );
        //msgBody.append( "\nOrganization: <cust_organization>" );
        msgBody.append( "\nProduct: <qw_productid>" );
        msgBody.append( "\nPriority: <qw_priority>" );
        msgBody.append( "\nProblem summary: <qw_problem>" );

        return msgBody.toString();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -