Subversion Repositories SmartDukaan

Rev

Rev 35618 | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.spice.profitmandi.dao.entity.cs;

import com.spice.profitmandi.dao.entity.fofo.ActivityType;
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;

import javax.persistence.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author amit
 *
 */
@Entity
@Table(name = "cs.ticket")

@NamedQueries({

                @NamedQuery(name = "Ticket.selectRecentClosedTicket", query = "select new com.spice.profitmandi.dao.model.TicketViewModel(t.id,tc.name,tbc.name,"
                                + "t.closeTimestamp" + ")"
                                + " from Ticket t  left join  TicketSubCategory tbc on t.subCategoryId  = tbc.id left join TicketCategory tc on tbc.categoryId = tc.id where t.closeTimestamp > :startDate and t.fofoId = :fofoId"),

})
public class Ticket {

        // Escalation thresholds in WORKING days (excludes weekends)
        public static final int L2_ESCALATION_WORKING_DAYS = 3;   // L1 -> L2 after 3 working days
        public static final int L3_ESCALATION_WORKING_DAYS = 3;   // L2 -> L3 after 3 more working days (6 total)
        public static final int FINAL_ESCALATION_WORKING_DAYS = 2; // L3 -> Final after 2 more working days (8 total)

        // Legacy constants (deprecated - use working days instead)
        @Deprecated
        public static final int L2EscalationDays = 5;
        @Deprecated
        public static final int L3EscalationDays = 10;
        @Deprecated
        public static final int FinalEscalationDays = 15;

        @Id
        @Column
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private int id;

        @Column(name = "fofo_id")
        private int fofoId;

        @Column(name = "subcategory_id")
        private int subCategoryId;

        @Column(name = "create_timestamp")
        private LocalDateTime createTimestamp;

        @Column(name = "update_timestamp")
        private LocalDateTime updateTimestamp;

        @Column(name = "close_timestamp")
        private LocalDateTime closeTimestamp;

        @Column(name = "current_assignee_id")
        private int currentAssigneeId;

        @Column(name = "current_manager_id")
        private int currentManagerId;

        @Column(name = "current_escalation_level")
        @Enumerated(EnumType.STRING)
        private EscalationType currentEscalationLevel;

        @Column(name = "happy_code")
        private String happyCode;

        @Column(name = "assignment_id")
        private int assignmentId;

        @Column(name = "last_activity")
        @Enumerated(EnumType.STRING)
        private ActivityType lastActivity;

        @Column(name = "last_activity_id")
        private int lastActivityId;

        @Column(name = "first_activity_id")
        private int firstActivityId;

        @Transient
        private TicketAssigned lastAassignment;

        public TicketAssigned getLastAassignment() {
                return lastAassignment;
        }

        public void setLastAassignment(TicketAssigned lastAassignment) {
                this.lastAassignment = lastAassignment;
        }

        public int getLastActivityId() {
                return lastActivityId;
        }

        public void setLastActivityId(int lastActivityId) {
                this.lastActivityId = lastActivityId;
        }

        public int getFirstActivityId() {
                return firstActivityId;
        }

        public void setFirstActivityId(int firstActivityId) {
                this.firstActivityId = firstActivityId;
        }

        public int getAssignmentId() {
                return assignmentId;
        }

        public void setAssignmentId(int assignmentId) {
                this.assignmentId = assignmentId;
        }

        public String getFormattedCreateTimestamp() {
                if (createTimestamp == null) {
                        return null;
                }
                DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
                return createTimestamp.format(formatter);
        }

        public String getFormattedCloseTimestamp() {
                if (closeTimestamp == null) {
                        return null;
                }
                DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
                return closeTimestamp.format(formatter);
        }

        public int getId() {
                return id;
        }

        public void setId(int id) {
                this.id = id;
        }

        public int getFofoId() {
                return fofoId;
        }

        public void setFofoId(int fofoId) {
                this.fofoId = fofoId;
        }

        public int getSubCategoryId() {
                return subCategoryId;
        }

        public void setSubCategoryId(int subCategoryId) {
                this.subCategoryId = subCategoryId;
        }

        public LocalDateTime getCreateTimestamp() {
                return createTimestamp;
        }

        public void setCreateTimestamp(LocalDateTime createTimestamp) {
                this.createTimestamp = createTimestamp;
        }

        public LocalDateTime getUpdateTimestamp() {
                return updateTimestamp;
        }

        public void setUpdateTimestamp(LocalDateTime updateTimestamp) {
                this.updateTimestamp = updateTimestamp;
        }

        public LocalDateTime getCloseTimestamp() {
                return closeTimestamp;
        }

        public void setCloseTimestamp(LocalDateTime closeTimestamp) {
                this.closeTimestamp = closeTimestamp;
        }

        public int getCurrentAssigneeId() {
                return currentAssigneeId;
        }

        public void setCurrentAssigneeId(int currentAssigneeId) {
                this.currentAssigneeId = currentAssigneeId;
        }

        public int getCurrentManagerId() {
                return currentManagerId;
        }

        public void setCurrentManagerId(int currentManagerId) {
                this.currentManagerId = currentManagerId;
        }

        public EscalationType getCurrentEscalationLevel() {
                return currentEscalationLevel;
        }

        public void setCurrentEscalationLevel(EscalationType currentEscalationLevel) {
                this.currentEscalationLevel = currentEscalationLevel;
        }

        public String getHappyCode() {
                return happyCode;
        }

        public void setHappyCode(String happyCode) {
                this.happyCode = happyCode;
        }

        public ActivityType getLastActivity() {
                return lastActivity;
        }

        public void setLastActivity(ActivityType lastActivity) {
                this.lastActivity = lastActivity;
        }

        public static int getL2escalationdays() {
                return L2EscalationDays;
        }

        public static int getL3escalationdays() {
                return L3EscalationDays;
        }

        public static int getFinalescalationdays() {
                return FinalEscalationDays;
        }

        @Override
        public int hashCode() {
                final int prime = 31;
                int result = 1;
                result = prime * result + assignmentId;
                result = prime * result + ((closeTimestamp == null) ? 0 : closeTimestamp.hashCode());
                result = prime * result + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
                result = prime * result + fofoId;
                result = prime * result + ((happyCode == null) ? 0 : happyCode.hashCode());
                result = prime * result + id;
                result = prime * result + currentAssigneeId;
                result = prime * result + currentManagerId;
                result = prime * result + ((currentEscalationLevel == null) ? 0 : currentEscalationLevel.hashCode());
                result = prime * result + ((lastActivity == null) ? 0 : lastActivity.hashCode());
                result = prime * result + lastActivityId;
                result = prime * result + firstActivityId;
                result = prime * result + subCategoryId;
                result = prime * result + ((updateTimestamp == null) ? 0 : updateTimestamp.hashCode());
                return result;
        }

        @Override
        public boolean equals(Object obj) {
                if (this == obj)
                        return true;
                if (obj == null)
                        return false;
                if (getClass() != obj.getClass())
                        return false;
                Ticket other = (Ticket) obj;
                if (assignmentId != other.assignmentId)
                        return false;
                if (closeTimestamp == null) {
                        if (other.closeTimestamp != null)
                                return false;
                } else if (!closeTimestamp.equals(other.closeTimestamp))
                        return false;
                if (createTimestamp == null) {
                        if (other.createTimestamp != null)
                                return false;
                } else if (!createTimestamp.equals(other.createTimestamp))
                        return false;
                if (fofoId != other.fofoId)
                        return false;
                if (happyCode == null) {
                        if (other.happyCode != null)
                                return false;
                } else if (!happyCode.equals(other.happyCode))
                        return false;
                if (id != other.id)
                        return false;
                if (currentAssigneeId != other.currentAssigneeId)
                        return false;
                if (currentManagerId != other.currentManagerId)
                        return false;
                if (currentEscalationLevel != other.currentEscalationLevel)
                        return false;
                if (lastActivity != other.lastActivity)
                        return false;
                if (lastActivityId != other.lastActivityId)
                        return false;
                if (firstActivityId != other.firstActivityId)
                        return false;
                if (subCategoryId != other.subCategoryId)
                        return false;
                if (updateTimestamp == null) {
                        if (other.updateTimestamp != null)
                                return false;
                } else if (!updateTimestamp.equals(other.updateTimestamp))
                        return false;
                return true;
        }

        @Override
        public String toString() {
                return "Ticket{" +
                                "id=" + id +
                                ", fofoId=" + fofoId +
                                ", subCategoryId=" + subCategoryId +
                                ", createTimestamp=" + createTimestamp +
                                ", updateTimestamp=" + updateTimestamp +
                                ", closeTimestamp=" + closeTimestamp +
                                ", currentAssigneeId=" + currentAssigneeId +
                                ", currentManagerId=" + currentManagerId +
                                ", currentEscalationLevel=" + currentEscalationLevel +
                                ", happyCode='" + happyCode + '\'' +
                                ", assignmentId=" + assignmentId +
                                ", lastActivity=" + lastActivity +
                                ", lastActivityId=" + lastActivityId +
                                ", firstActivityId=" + firstActivityId +
                                ", lastAassignment=" + lastAassignment +
                                '}';
        }

}