Subversion Repositories SmartDukaan

Rev

Rev 27261 | Rev 27410 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 27261 Rev 27393
Line 115... Line 115...
115
 
115
 
116
	@Override
116
	@Override
117
	public void assignTicket(Ticket ticket) throws ProfitMandiBusinessException {
117
	public void assignTicket(Ticket ticket) throws ProfitMandiBusinessException {
118
		TicketAssigned ticketAssigned = null;
118
		TicketAssigned ticketAssigned = null;
119
		EscalationType newEscalationType = EscalationType.L1;
119
		EscalationType newEscalationType = EscalationType.L1;
120
		try {
120
		if(ticket.getAssignmentId()>0) {
121
			ticketAssigned = ticketAssignedRepository.selectById(ticket.getAssignmentId());
121
			ticketAssigned = ticketAssignedRepository.selectById(ticket.getAssignmentId());
122
			newEscalationType = ticketAssigned.getEscalationType().next();
122
			newEscalationType = ticketAssigned.getEscalationType().next();
123
			if (newEscalationType == null) {
123
			if (newEscalationType == null || newEscalationType.equals(EscalationType.Final)) {
124
				LOGGER.info("Cant escalate further");
124
				LOGGER.info("Cant escalate further");
125
				return;
125
				return;
126
			}
126
			}
-
 
127
		} else {
-
 
128
			ticket.setL1AuthUser(0);
-
 
129
			ticket.setL2AuthUser(0);
-
 
130
			ticket.setL3AuthUser(0);
-
 
131
			ticket.setL4AuthUser(0);
127
		} catch (Exception e) {
132
			ticket.setL5AuthUser(0);
128
		}
133
		}
129
		ticket.setUpdateTimestamp(LocalDateTime.now());
134
		ticket.setUpdateTimestamp(LocalDateTime.now());
130
		TicketSubCategory ticketSubCategory = ticketSubCategoryRepository.selectById(ticket.getSubCategoryId());
135
		TicketSubCategory ticketSubCategory = ticketSubCategoryRepository.selectById(ticket.getSubCategoryId());
131
		TicketCategory ticketCategory = ticketCategoryRepository.selectById(ticketSubCategory.getCategoryId());
136
		TicketCategory ticketCategory = ticketCategoryRepository.selectById(ticketSubCategory.getCategoryId());
132
		Map<Integer, EscalationType> escalationUserMap = new HashedMap<>();
137
		Map<Integer, EscalationType> escalationUserMap = new HashedMap<>();
133
		Set<Integer> assigneeUserIds = new LinkedHashSet<>();
138
		Set<Integer> assigneeUserIds = new LinkedHashSet<>();
134
		EscalationType escalationTypeNext = newEscalationType;
139
		EscalationType escalationTypeNext = newEscalationType;
135
		ticket.setL1AuthUser(0);
-
 
136
		ticket.setL2AuthUser(0);
-
 
137
		ticket.setL3AuthUser(0);
-
 
138
		ticket.setL4AuthUser(0);
-
 
139
		ticket.setL5AuthUser(0);
-
 
140
		do {
140
		do {
141
			int assigneeUserId = this.getAuthUserId(ticketCategory.getId(), escalationTypeNext, ticket.getFofoId());
141
			int assigneeUserId = this.getAuthUserId(ticketCategory.getId(), escalationTypeNext, ticket.getFofoId());
142
			if (assigneeUserId == 0) {
142
			if (assigneeUserId == 0) {
143
				escalationTypeNext = escalationTypeNext.next();
143
				escalationTypeNext = escalationTypeNext.next();
144
				LOGGER.info("Escalation type next {}", escalationTypeNext);
144
				LOGGER.info("Escalation type next {}", escalationTypeNext);
Line 169... Line 169...
169
			escalationTypeNext = escalationTypeNext.next();
169
			escalationTypeNext = escalationTypeNext.next();
170
			// LOGGER.info("Escalation type next {}", escalationTypeNext);
170
			// LOGGER.info("Escalation type next {}", escalationTypeNext);
171
		} while (!escalationTypeNext.equals(EscalationType.Final));
171
		} while (!escalationTypeNext.equals(EscalationType.Final));
172
 
172
 
173
		int assigneeAuthId = assigneeUserIds.stream().findFirst().orElse(0);
173
		int assigneeAuthId = assigneeUserIds.stream().findFirst().orElse(0);
-
 
174
		
174
		int managerAuthId = 0;
175
		int managerAuthId = 0;
175
		EscalationType assigneeEscalationType = null;
176
		EscalationType assigneeEscalationType = null;
176
		if (assigneeAuthId == 0) {
177
		if (assigneeAuthId == 0) {
177
			assigneeAuthId = ProfitMandiConstants.FINAL_AUTH_ID;
178
			assigneeAuthId = ProfitMandiConstants.FINAL_AUTH_ID;
178
			assigneeEscalationType = EscalationType.Final;
179
			assigneeEscalationType = EscalationType.Final;
-
 
180
			managerAuthId = ProfitMandiConstants.FINAL_AUTH_ID;
179
		} else {
181
		} else {
180
			assigneeEscalationType = escalationUserMap.get(assigneeAuthId);
182
			assigneeEscalationType = escalationUserMap.get(assigneeAuthId);
181
			managerAuthId = assigneeUserIds.stream().skip(1).findFirst().orElse(0);
183
			managerAuthId = assigneeUserIds.stream().skip(1).findFirst().orElse(0);
182
			if (managerAuthId == 0) {
184
			if (managerAuthId == 0) {
183
				managerAuthId = ProfitMandiConstants.FINAL_AUTH_ID;
185
				managerAuthId = ProfitMandiConstants.FINAL_AUTH_ID;
Line 186... Line 188...
186
 
188
 
187
		TicketAssigned ticketAssignedNew = new TicketAssigned();
189
		TicketAssigned ticketAssignedNew = new TicketAssigned();
188
		ticketAssignedNew.setTicketId(ticket.getId());
190
		ticketAssignedNew.setTicketId(ticket.getId());
189
		ticketAssignedNew.setAssineeId(assigneeAuthId);
191
		ticketAssignedNew.setAssineeId(assigneeAuthId);
190
		ticketAssignedNew.setEscalationType(assigneeEscalationType);
192
		ticketAssignedNew.setEscalationType(assigneeEscalationType);
191
		if (!assigneeEscalationType.equals(EscalationType.Final)) {
-
 
192
			ticketAssignedNew.setManagerId(managerAuthId);
193
		ticketAssignedNew.setManagerId(managerAuthId);
193
		}
-
 
194
		ticketAssignedNew.setCreateTimestamp(LocalDateTime.now());
194
		ticketAssignedNew.setCreateTimestamp(LocalDateTime.now());
195
		ticketAssignedRepository.persist(ticketAssignedNew);
195
		ticketAssignedRepository.persist(ticketAssignedNew);
196
		LOGGER.info(ticketAssigned);
196
		LOGGER.info(ticketAssigned);
-
 
197
		
197
		AuthUser authUser = authRepository.selectById(ticketAssignedNew.getAssineeId());
198
		AuthUser authUser = authRepository.selectById(ticketAssignedNew.getAssineeId());
198
		AuthUser authUserManager = null;
199
		AuthUser authUserManager = null;
-
 
200
		
-
 
201
		//Dont send cc mail if both are same
199
		if (managerAuthId > 0) {
202
		if (managerAuthId!= assigneeAuthId) {
200
			authUserManager = authRepository.selectById(managerAuthId);
203
			authUserManager = authRepository.selectById(managerAuthId);
201
		}
204
		}
202
		ticket.setAssignmentId(ticketAssignedNew.getId());
205
		ticket.setAssignmentId(ticketAssignedNew.getId());
203
		this.sendAssignedTicketMail(authUser, Arrays.asList(authUserManager), ticket, ticketAssigned!=null);
206
		this.sendAssignedTicketMail(authUser, Arrays.asList(authUserManager), ticket, ticketAssigned!=null);
204
		if (!ticketAssignedNew.getEscalationType().equals(EscalationType.L1)) {
207
		if (!ticketAssignedNew.getEscalationType().equals(EscalationType.L1)) {
Line 239... Line 242...
239
 
242
 
240
		
243
		
241
		Activity categoryChangedActivity = this.createActivity(ActivityType.CATEGORY_CHANGED, "Category changed to "
244
		Activity categoryChangedActivity = this.createActivity(ActivityType.CATEGORY_CHANGED, "Category changed to "
242
				+ ticketSubCategory.getTicketCategory().getName() + " - " + ticketSubCategory.getName(), 0);
245
				+ ticketSubCategory.getTicketCategory().getName() + " - " + ticketSubCategory.getName(), 0);
243
		this.addActivity(ticket, categoryChangedActivity);
246
		this.addActivity(ticket, categoryChangedActivity);
-
 
247
		ticket.setAssignmentId(0);
244
		this.assignTicket(ticket);
248
		this.assignTicket(ticket);
245
		
249
		
246
	}
250
	}
247
 
251
 
-
 
252
	@Override
248
	private Activity createActivity(ActivityType activityType, String message, int createdBy) {
253
	public Activity createActivity(ActivityType activityType, String message, int createdBy) {
249
		Activity activity = new Activity();
254
		Activity activity = new Activity();
250
		activity.setMessage(message);
255
		activity.setMessage(message);
251
		activity.setCreatedBy(createdBy);
256
		activity.setCreatedBy(createdBy);
252
		activity.setType(activityType);
257
		activity.setType(activityType);
253
		activity.setCreateTimestamp(LocalDateTime.now());
258
		activity.setCreateTimestamp(LocalDateTime.now());