Unverified Commit dbb352e0 authored by rahu-tarento's avatar rahu-tarento Committed by GitHub
Browse files

Merge pull request #31 from Radheshhathwar/main

Reverted system time related changes to avoid ticket creation issues
Showing with 18 additions and 52 deletions
+18 -52
......@@ -118,11 +118,7 @@
<artifactId>maven-artifact-manager</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.14.2</version>
</dependency>
</dependencies>
<build>
......
package org.upsmf.grievance.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.*;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
......@@ -50,11 +49,9 @@ public class Ticket {
@Column(name = "is_junk")
private boolean junk = false;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.S", timezone = "Asia/Kolkata")
@Column(name = "created_date")
private Timestamp createdDate;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.S", timezone = "Asia/Kolkata")
@Column(name = "updated_date")
private Timestamp updatedDate;
......@@ -67,7 +64,6 @@ public class Ticket {
@Column(name = "is_escalated_to_admin")
private boolean escalatedToAdmin;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.S", timezone = "Asia/Kolkata")
@Column(name = "escalated_date")
private Timestamp escalatedDate;
......
package org.upsmf.grievance.model.es;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.*;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
......@@ -9,7 +8,6 @@ import org.upsmf.grievance.enums.RequesterType;
import org.upsmf.grievance.enums.TicketPriority;
import org.upsmf.grievance.enums.TicketStatus;
import javax.persistence.Column;
@Document(indexName = "ticket", createIndex = false)
@Getter
......@@ -53,11 +51,9 @@ public class Ticket {
@Field(name = "is_junk")
private Boolean junk = false;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.S", timezone = "Asia/Kolkata")
@Column(name = "created_date")
@Field(name = "created_date")
private String createdDate;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Kolkata")
@Field(name = "updated_date")
private String updatedDate;
......@@ -73,7 +69,6 @@ public class Ticket {
@Field(name = "is_escalated")
private Boolean escalated;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.S", timezone = "Asia/Kolkata")
@Field(name = "escalated_date")
private String escalatedDate;
......
......@@ -30,12 +30,9 @@ import org.upsmf.grievance.model.reponse.TicketResponse;
import org.upsmf.grievance.repository.es.TicketRepository;
import org.upsmf.grievance.service.SearchService;
import org.upsmf.grievance.service.TicketService;
import org.upsmf.grievance.util.DateUtil;
import java.io.IOException;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
......@@ -69,7 +66,6 @@ public class SearchServiceImpl implements SearchService {
@Value("${assessment}")
private String ASSESSMENT;
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.S");
private Map<String, Object> departmentNameResponse = new HashMap<>();
......
......@@ -25,7 +25,6 @@ import org.upsmf.grievance.util.ErrorCode;
import javax.transaction.Transactional;
import java.sql.Timestamp;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
......@@ -142,7 +141,6 @@ public class TicketServiceImpl implements TicketService {
// send mail
EmailDetails emailDetails = EmailDetails.builder().recipient(ticket.getEmail()).subject("New Complaint Registration").build();
emailService.sendCreateTicketMail(emailDetails, ticket);
System.out.println(ticket);
return ticket;
}
......@@ -154,12 +152,10 @@ public class TicketServiceImpl implements TicketService {
*/
private Ticket createTicketWithDefault(TicketRequest ticketRequest) throws Exception {
Timestamp currentTimestamp = DateUtil.convertToISTInTS(new Timestamp(DateUtil.getCurrentDate().getTime()));
LocalDateTime escalationDateTime = LocalDateTime.now().plusDays(Long.parseLong(ticketEscalationDays));
ZoneId istZone = ZoneId.of("Asia/Kolkata");
LocalDateTime istDateTime = escalationDateTime.atZone(istZone).toLocalDateTime();
Timestamp currentTimestamp = new Timestamp(DateUtil.getCurrentDate().getTime());
LocalDateTime escalationDateTime = LocalDateTime.now().plus(Long.valueOf(ticketEscalationDays), ChronoUnit.DAYS);
return Ticket.builder()
.createdDate(currentTimestamp)
.createdDate(new Timestamp(DateUtil.getCurrentDate().getTime()))
.firstName(ticketRequest.getFirstName())
.lastName(ticketRequest.getLastName())
.phone(ticketRequest.getPhone())
......@@ -170,7 +166,7 @@ public class TicketServiceImpl implements TicketService {
.updatedDate(currentTimestamp)
.lastUpdatedBy("-1")//need to get user details and add id or name
.escalated(false)
.escalatedDate(Timestamp.valueOf(istDateTime))
.escalatedDate(Timestamp.valueOf(escalationDateTime))
.escalatedTo("-1")
.status(TicketStatus.OPEN)
.requestType(ticketRequest.getRequestType())
......@@ -295,7 +291,7 @@ public class TicketServiceImpl implements TicketService {
if(updateTicketRequest.getIsJunk()!=null) {
ticket.setJunk(updateTicketRequest.getIsJunk());
}
ticket.setUpdatedDate(DateUtil.convertToISTInTS(new Timestamp(DateUtil.getCurrentDate().getTime())));
ticket.setUpdatedDate(new Timestamp(DateUtil.getCurrentDate().getTime()));
// update assignee comments
if(updateTicketRequest.getComment()!=null) {
Comments comments = Comments.builder().comment(updateTicketRequest.getComment())
......@@ -322,6 +318,7 @@ public class TicketServiceImpl implements TicketService {
* @return
*/
private org.upsmf.grievance.model.es.Ticket convertToESTicketObj(Ticket ticket) {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(DateUtil.DEFAULT_DATE_FORMAT);
// get user details based on ID
return org.upsmf.grievance.model.es.Ticket.builder()
.ticketId(ticket.getId())
......@@ -334,13 +331,13 @@ public class TicketServiceImpl implements TicketService {
.assignedToName("") // get user details based on ID
.description(ticket.getDescription())
.junk(ticket.isJunk())
.createdDate(String.valueOf(ticket.getCreatedDate()))
.createdDate(ticket.getCreatedDate().toLocalDateTime().format(dateTimeFormatter))
.createdDateTS(ticket.getCreatedDate().getTime())
.updatedDate(String.valueOf(ticket.getUpdatedDate()))
.updatedDate(ticket.getUpdatedDate().toLocalDateTime().format(dateTimeFormatter))
.updatedDateTS(ticket.getUpdatedDate().getTime())
.lastUpdatedBy(ticket.getLastUpdatedBy())
.escalated(ticket.isEscalated())
.escalatedDate(ticket.getEscalatedDate() != null ? DateUtil.convertToIST(ticket.getEscalatedDate()) : null)
.escalatedDate(ticket.getEscalatedDate()!=null?ticket.getEscalatedDate().toLocalDateTime().format(dateTimeFormatter):null)
.escalatedDateTS(ticket.getEscalatedDate()!=null?ticket.getEscalatedDate().getTime():-1)
.status(ticket.getStatus())
.requestType(ticket.getRequestType())
......@@ -348,7 +345,8 @@ public class TicketServiceImpl implements TicketService {
.escalatedBy(ticket.getEscalatedBy())
.escalatedTo(ticket.getEscalatedTo())
.escalatedToAdmin(ticket.isEscalatedToAdmin())
.rating(0L).build();
.rating(Long.valueOf(0)).build();
}
/**
......@@ -428,11 +426,7 @@ public class TicketServiceImpl implements TicketService {
@Synchronized
public void updateTicket(Long ticketId) {
Ticket ticket = getTicketById(ticketId);
try {
ticket.setUpdatedDate(new Timestamp(DateUtil.getCurrentDate().getTime()));
} catch (Exception e) {
throw new RuntimeException(e);
}
ticket.setUpdatedDate(new Timestamp(new Date().getTime()));
ticket.setEscalatedDate(new Timestamp(new Date().getTime()));
ticket.setEscalatedToAdmin(true);
ticket.setPriority(TicketPriority.MEDIUM);
......
......@@ -202,21 +202,10 @@ public class DateUtil {
* @throws Exception
*/
public static Date getCurrentDate() throws Exception {
LocalDateTime istDateTime = LocalDateTime.now(ZoneId.of("Asia/Kolkata"));
return Date.from(istDateTime.atZone(ZoneId.systemDefault()).toInstant());
}
public static String convertToIST(Timestamp timestamp) {
LocalDateTime dateTime = timestamp.toLocalDateTime();
LocalDateTime istDateTime = dateTime.atZone(ZoneId.of("Asia/Kolkata")).toLocalDateTime();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
return istDateTime.format(formatter);
}
public static Timestamp convertToISTInTS(Timestamp timestamp) {
LocalDateTime dateTime = timestamp.toLocalDateTime();
ZonedDateTime zonedDateTime = dateTime.atZone(ZoneId.of("Asia/Kolkata"));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
return Timestamp.valueOf(zonedDateTime.toLocalDateTime().format(formatter));
SimpleDateFormat formatterWithDefaultTimeZone = new SimpleDateFormat(DEFAULT_DATE_FORMAT);
Date currDate = new Date();
String currTimeWithTimeZone = formatterWithDefaultTimeZone.format(currDate);
return formatterWithDefaultTimeZone.parse(currTimeWithTimeZone);
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment