Commit 56624ee1 authored by Narendar Vakiti's avatar Narendar Vakiti

mystatus integration changes

parent a040a26a
package com.nisum.myteam.controller; package com.nisum.myteam.controller;
import com.nisum.myteam.status.fileexport.GenerateExcelReport; import com.nisum.myteam.fileexport.GenerateStatusExcelReport;
import com.nisum.myteam.status.fileexport.GeneratePdfReport; import com.nisum.myteam.fileexport.GenerateStatusPdfReport;
import com.nisum.myteam.status.model.FromToDates; import com.nisum.myteam.model.Book;
import com.nisum.myteam.status.model.Status; import com.nisum.myteam.model.FromToDates;
import com.nisum.myteam.status.model.StatusResponse; import com.nisum.myteam.model.dao.MyStatus;
import com.nisum.myteam.status.service.StatusService; import com.nisum.myteam.model.StatusResponse;
import com.nisum.myteam.service.MyStatusService;
import com.nisum.myteam.utils.MyTeamDateUtils;
import org.apache.commons.compress.utils.IOUtils; import org.apache.commons.compress.utils.IOUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -22,16 +24,17 @@ import javax.servlet.http.HttpServletResponse; ...@@ -22,16 +24,17 @@ import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@RestController @RestController
//@RequestMapping("/mystatus") //@RequestMapping("/mystatus")
public class StatusResource { public class MyStatusController {
private static final Logger LOGGER = LoggerFactory.getLogger(StatusResource.class); private static final Logger LOGGER = LoggerFactory.getLogger(MyStatusController.class);
@Autowired @Autowired
private StatusService statusService; private MyStatusService statusService;
/** /**
* Save the task details * Save the task details
...@@ -39,10 +42,10 @@ public class StatusResource { ...@@ -39,10 +42,10 @@ public class StatusResource {
* @return * @return
*/ */
//@PostMapping("/saveStatusDetails") //@PostMapping("/saveStatusDetails")
@RequestMapping(value = "/saveStatusDetails", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "saveStatusDetails", method = RequestMethod.POST)
public StatusResponse saveStatusDetails(@RequestBody Status status) { public ResponseEntity<StatusResponse> saveStatusDetails(@RequestBody MyStatus status) {
Status saveResponse = null; MyStatus saveResponse = null;
LOGGER.info("Creating the employee status for taskType: " + status.getTaskType()); LOGGER.info("Creating the employee status for taskType: " + status.getTaskType());
StatusResponse response = new StatusResponse(); StatusResponse response = new StatusResponse();
response.setStatusCode(400); response.setStatusCode(400);
...@@ -52,8 +55,7 @@ public class StatusResource { ...@@ -52,8 +55,7 @@ public class StatusResource {
if (status != null) { if (status != null) {
int totalTime = 0; int totalTime = 0;
if (status.getHoursSpent() != null && status.getTaskDate() != null) { if (status.getHoursSpent() != null && status.getTaskDate() != null) {
LocalDate date = status.getTaskDate(); totalTime = hoursSpentCal(status.getEmpId(), MyTeamDateUtils.convertUtilDateToLocalDate(status.getTaskDate()));
totalTime = hoursSpentCal(status.getEmpId(), date);
String hours = status.getHoursSpent(); String hours = status.getHoursSpent();
totalTime = totalTime + getTotalMinutes(hours); totalTime = totalTime + getTotalMinutes(hours);
if (totalTime <= 840) { if (totalTime <= 840) {
...@@ -69,7 +71,7 @@ public class StatusResource { ...@@ -69,7 +71,7 @@ public class StatusResource {
} catch (Exception exp) { } catch (Exception exp) {
LOGGER.error("Getting exception while saving the details in database : " + exp); LOGGER.error("Getting exception while saving the details in database : " + exp);
} }
return response; return ResponseEntity.ok().body(response);
} }
/** /**
...@@ -77,8 +79,8 @@ public class StatusResource { ...@@ -77,8 +79,8 @@ public class StatusResource {
* @return * @return
*/ */
@GetMapping("/getAllEmployeesStatusDetails") @GetMapping("/getAllEmployeesStatusDetails")
public ResponseEntity<List<Status>> getEmployeeStatusDetails() { public ResponseEntity<List<MyStatus>> getEmployeeStatusDetails() {
List<Status> statusResponse = null; List<MyStatus> statusResponse = null;
try { try {
statusResponse = statusService.getEmployeeStatusDetails(); statusResponse = statusService.getEmployeeStatusDetails();
} catch (Exception ex) { } catch (Exception ex) {
...@@ -95,8 +97,8 @@ public class StatusResource { ...@@ -95,8 +97,8 @@ public class StatusResource {
* @return * @return
*/ */
@PutMapping("/updateStatusDetails/{id}") @PutMapping("/updateStatusDetails/{id}")
public StatusResponse updateEmployeeStatusDetails(@PathVariable Integer id, @RequestBody Status status) { public StatusResponse updateEmployeeStatusDetails(@PathVariable Integer id, @RequestBody MyStatus status) {
Status statusUpdated = null; MyStatus statusUpdated = null;
LOGGER.info("Updating the employee status for Id: " + id); LOGGER.info("Updating the employee status for Id: " + id);
status.setId(id); status.setId(id);
StatusResponse response = new StatusResponse(); StatusResponse response = new StatusResponse();
...@@ -141,8 +143,8 @@ public class StatusResource { ...@@ -141,8 +143,8 @@ public class StatusResource {
* @return * @return
*/ */
@GetMapping("/getDefaultStatusDetails/{empId}") @GetMapping("/getDefaultStatusDetails/{empId}")
public ResponseEntity<List<Status>> getDefalutStatusDetails(@PathVariable String empId) { public ResponseEntity<List<MyStatus>> getDefalutStatusDetails(@PathVariable String empId) {
List<Status> statusResponse = null; List<MyStatus> statusResponse = null;
try { try {
LOGGER.info("Retrieving the employee last five days task details for EmpId : " + empId); LOGGER.info("Retrieving the employee last five days task details for EmpId : " + empId);
statusResponse = statusService.getDefaultStatusDetails(empId); statusResponse = statusService.getDefaultStatusDetails(empId);
...@@ -162,27 +164,27 @@ public class StatusResource { ...@@ -162,27 +164,27 @@ public class StatusResource {
public void downloadExcelFormat(HttpServletResponse response) throws IOException { public void downloadExcelFormat(HttpServletResponse response) throws IOException {
response.setContentType("application/octet-stream"); response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment; filename=status-report.xlsx"); response.setHeader("Content-Disposition", "attachment; filename=status-report.xlsx");
List<Status> statusResponse = null; List<MyStatus> statusResponse = null;
try { try {
statusResponse = statusService.getEmployeeStatusDetails(); statusResponse = statusService.getEmployeeStatusDetails();
} catch (Exception ex) { } catch (Exception ex) {
LOGGER.error("Getting exception while fetching the details from database : " + ex); LOGGER.error("Getting exception while fetching the details from database : " + ex);
throw ex; throw ex;
} }
ByteArrayInputStream stream = GenerateExcelReport.generateExcelStatusReport(statusResponse); ByteArrayInputStream stream = GenerateStatusExcelReport.generateExcelStatusReport(statusResponse);
IOUtils.copy(stream, response.getOutputStream()); IOUtils.copy(stream, response.getOutputStream());
} }
@GetMapping("/getAllEvents/{empId}") @GetMapping("/getAllEvents/{empId}")
public List<Status> getByDateRange(@PathVariable String empId, @RequestParam(value = "fromDate", required = false) LocalDate fromDate, @RequestParam(value = "toDate", required = false) LocalDate toDate) { public List<MyStatus> getByDateRange(@PathVariable String empId, @RequestParam(value = "fromDate", required = false) LocalDate fromDate, @RequestParam(value = "toDate", required = false) LocalDate toDate) {
LOGGER.info("Retrieving the employee status details for Id: " + empId); LOGGER.info("Retrieving the employee status details for Id: " + empId);
List<Status> empResponse = null; List<MyStatus> empResponse = null;
try { try {
if (StringUtils.isNotBlank(empId)) { if (StringUtils.isNotBlank(empId)) {
if (fromDate != null && toDate != null) if (fromDate != null && toDate != null){}
empResponse = statusService.getByDateRange(fromDate, toDate, empId); //empResponse = statusService.getByDateRange(fromDate, toDate, empId);
else //else
empResponse = statusService.getStatusDetailsByEmpId(empId); // empResponse = statusService.getStatusDetailsByEmpId(empId);
} }
} catch (Exception exp) { } catch (Exception exp) {
LOGGER.error("Getting exception while retrieving the Details : " + exp); LOGGER.error("Getting exception while retrieving the Details : " + exp);
...@@ -197,10 +199,10 @@ public class StatusResource { ...@@ -197,10 +199,10 @@ public class StatusResource {
* @param dates * @param dates
* @return * @return
*/ */
@PostMapping("/getStatusDetailsByDateRange/{empId}") @PostMapping(value = "getStatusDetailsByDateRange/{empId}", consumes = MediaType.APPLICATION_JSON_VALUE)
public List<Status> getEmpStatus(@PathVariable String empId, @RequestBody FromToDates dates) { public List<MyStatus> getEmpStatus(@PathVariable String empId, @RequestBody FromToDates dates) {
LOGGER.info("Retrieving the employee task details for " + empId + " from date : " + dates.getFromDate() + " to date : " + dates.getToDate()); LOGGER.info("Retrieving the employee task details for " + empId + " from date : " + dates.getFromDate() + " to date : " + dates.getToDate());
List<Status> empResponse = null; List<MyStatus> empResponse = null;
try { try {
if (StringUtils.isNotBlank(empId) && dates.getFromDate() != null && dates.getToDate() != null) { if (StringUtils.isNotBlank(empId) && dates.getFromDate() != null && dates.getToDate() != null) {
empResponse = statusService.getByDateRange(dates.getFromDate(), dates.getToDate(), empId); empResponse = statusService.getByDateRange(dates.getFromDate(), dates.getToDate(), empId);
...@@ -221,14 +223,14 @@ public class StatusResource { ...@@ -221,14 +223,14 @@ public class StatusResource {
public ResponseEntity<InputStreamResource> downloadPdfFormat() throws IOException { public ResponseEntity<InputStreamResource> downloadPdfFormat() throws IOException {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.add("Content-Disposition", "inline; filename=StatusReport.pdf"); headers.add("Content-Disposition", "inline; filename=StatusReport.pdf");
List<Status> statusResponse = null; List<MyStatus> statusResponse = null;
try { try {
statusResponse = statusService.getEmployeeStatusDetails(); statusResponse = statusService.getEmployeeStatusDetails();
} catch (Exception ex) { } catch (Exception ex) {
LOGGER.error("Getting exception while fetching the details from database : " + ex); LOGGER.error("Getting exception while fetching the details from database : " + ex);
throw ex; throw ex;
} }
ByteArrayInputStream bis = GeneratePdfReport.statusReport(statusResponse); ByteArrayInputStream bis = GenerateStatusPdfReport.statusReport(statusResponse);
return ResponseEntity return ResponseEntity
.ok() .ok()
.headers(headers) .headers(headers)
...@@ -242,18 +244,20 @@ public class StatusResource { ...@@ -242,18 +244,20 @@ public class StatusResource {
* @return * @return
*/ */
@GetMapping("/findTodayStatusByEmpId/{empId}") @GetMapping("/findTodayStatusByEmpId/{empId}")
public List<Status> findTodayStatus(@PathVariable String empId) { public List<MyStatus> findTodayStatus(@PathVariable String empId) {
LOGGER.info("Fetching the today status details using EmpId : " + empId); LOGGER.info("Fetching the today status details using EmpId : " + empId);
String response = null; String response = null;
StatusResponse error = new StatusResponse(); StatusResponse error = new StatusResponse();
error.setTitle("Status Details"); error.setTitle("Status Details");
List<Status> status = null; List<MyStatus> status = null;
try { try {
status = statusService.findTodayStatus(empId); status = statusService.findTodayStatus(empId);
response = status.toString();
if (status == null) { if (status == null) {
error.setMessage("No data found for today status"); error.setMessage("No data found for today status");
response = error.toString(); response = error.toString();
}else {
response = status.toString();
LOGGER.info("Employee :: "+ empId +" Today Status :: "+response);
} }
} catch (Exception e) { } catch (Exception e) {
LOGGER.error("Getting exception while fetching the today status details from database : " + e); LOGGER.error("Getting exception while fetching the today status details from database : " + e);
...@@ -268,14 +272,13 @@ public class StatusResource { ...@@ -268,14 +272,13 @@ public class StatusResource {
/** /**
* Find number of hours by task date and employee id * Find number of hours by task date and employee id
* @param empId * @param empId
* @param date
* @return totalTime * @return totalTime
*/ */
public int hoursSpentCal(String empId, LocalDate date) { public int hoursSpentCal(String empId, LocalDate today) {
int totalTime = 0; int totalTime = 0;
List<Status> taskData = statusService.findTaskDataByTaskDate(empId, date); List<MyStatus> taskData = statusService.findTaskDataByTaskDate(empId, today);
if (taskData != null) { if (taskData != null) {
for (Status st : taskData) { for (MyStatus st : taskData) {
if (st.getHoursSpent() != null) { if (st.getHoursSpent() != null) {
String time = st.getHoursSpent(); String time = st.getHoursSpent();
String[] t = time.split(":"); String[] t = time.split(":");
...@@ -293,4 +296,10 @@ public class StatusResource { ...@@ -293,4 +296,10 @@ public class StatusResource {
return Integer.valueOf(t[0]) * 60 + Integer.valueOf(t[1]); return Integer.valueOf(t[0]) * 60 + Integer.valueOf(t[1]);
} }
List<Book> book = new ArrayList<>();
@PostMapping("bookdata")
public List<Book> savebook(@RequestBody Book bookdata){
book.add(bookdata);
return book;
}
} }
package com.nisum.myteam.status.exceptions; package com.nisum.myteam.exception.handler;
import com.nisum.myteam.exception.handler.EmployeeNotFoundException;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ControllerAdvice;
...@@ -25,7 +26,7 @@ public class ControllerAdvisor extends ResponseEntityExceptionHandler { ...@@ -25,7 +26,7 @@ public class ControllerAdvisor extends ResponseEntityExceptionHandler {
} }
@ExceptionHandler(EmployeeRecordsNotFound.class) @ExceptionHandler(EmployeeRecordsNotFound.class)
public ResponseEntity<Object> handleEmployeeRecordsNotFoundException( public ResponseEntity<Object> handleEmployeeRecordsNotFoundException(
EmployeeRecordsNotFound ex, WebRequest request) { EmployeeRecordsNotFound ex, WebRequest request) {
Map<String, Object> body = new LinkedHashMap<>(); Map<String, Object> body = new LinkedHashMap<>();
body.put("timestamp", LocalDateTime.now()); body.put("timestamp", LocalDateTime.now());
......
package com.nisum.myteam.status.exceptions; package com.nisum.myteam.exception.handler;
public class EmployeeRecordsNotFound extends RuntimeException { public class EmployeeRecordsNotFound extends RuntimeException {
public EmployeeRecordsNotFound(Integer id) { public EmployeeRecordsNotFound(Integer id) {
......
package com.nisum.myteam.status.fileexport; package com.nisum.myteam.fileexport;
import com.nisum.myteam.status.model.Status; import com.nisum.myteam.model.dao.MyStatus;
import com.nisum.myteam.status.util.FileUtil; import com.nisum.myteam.utils.MyStatusFileUtil;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
...@@ -11,8 +11,8 @@ import java.io.IOException; ...@@ -11,8 +11,8 @@ import java.io.IOException;
import java.sql.Date; import java.sql.Date;
import java.util.List; import java.util.List;
public class GenerateExcelReport { public class GenerateStatusExcelReport {
public static ByteArrayInputStream generateExcelStatusReport(List<Status> statusList) throws IOException { public static ByteArrayInputStream generateExcelStatusReport(List<MyStatus> statusList) throws IOException {
try (Workbook workbook = new XSSFWorkbook()) { try (Workbook workbook = new XSSFWorkbook()) {
...@@ -60,31 +60,31 @@ public class GenerateExcelReport { ...@@ -60,31 +60,31 @@ public class GenerateExcelReport {
int rowCount = 1; int rowCount = 1;
for (Status status : statusList) { for (MyStatus status : statusList) {
Row statusRow = sheet.createRow(rowCount++); Row statusRow = sheet.createRow(rowCount++);
Cell taksDateCell = statusRow.createCell(0); Cell taksDateCell = statusRow.createCell(0);
taksDateCell.setCellValue(Date.valueOf(status.getTaskDate())); taksDateCell.setCellValue(status.getTaskDate());
taksDateCell.setCellStyle(FileUtil.cellStyleDate(workbook)); taksDateCell.setCellStyle(MyStatusFileUtil.cellStyleDate(workbook));
statusRow.createCell(1).setCellValue(status.getTaskType()); statusRow.createCell(1).setCellValue(status.getTaskType());
statusRow.createCell(2).setCellValue(status.getTicketNumber()); statusRow.createCell(2).setCellValue(status.getTicketNumber());
statusRow.createCell(3).setCellValue(status.getStoryPoints()); statusRow.createCell(3).setCellValue(status.getStoryPoints());
Cell planedTaskStartDateCell = statusRow.createCell(4); Cell planedTaskStartDateCell = statusRow.createCell(4);
planedTaskStartDateCell.setCellValue(Date.valueOf(status.getPlanedStartDate())); planedTaskStartDateCell.setCellValue(status.getPlanedStartDate());
planedTaskStartDateCell.setCellStyle(FileUtil.cellStyleDate(workbook)); planedTaskStartDateCell.setCellStyle(MyStatusFileUtil.cellStyleDate(workbook));
Cell planedTaskEndDateCell = statusRow.createCell(5); Cell planedTaskEndDateCell = statusRow.createCell(5);
planedTaskEndDateCell.setCellValue(Date.valueOf(status.getPlanedEndDate())); planedTaskEndDateCell.setCellValue(status.getPlanedEndDate());
planedTaskEndDateCell.setCellStyle(FileUtil.cellStyleDate(workbook)); planedTaskEndDateCell.setCellStyle(MyStatusFileUtil.cellStyleDate(workbook));
Cell actualStartDateCell = statusRow.createCell(6); Cell actualStartDateCell = statusRow.createCell(6);
actualStartDateCell.setCellValue(Date.valueOf(status.getActualEndDate())); actualStartDateCell.setCellValue(status.getActualEndDate());
actualStartDateCell.setCellStyle(FileUtil.cellStyleDate(workbook)); actualStartDateCell.setCellStyle(MyStatusFileUtil.cellStyleDate(workbook));
Cell actualEndDateCell = statusRow.createCell(7); Cell actualEndDateCell = statusRow.createCell(7);
actualEndDateCell.setCellValue(Date.valueOf(status.getActualEndDate())); actualEndDateCell.setCellValue(status.getActualEndDate());
actualEndDateCell.setCellStyle(FileUtil.cellStyleDate(workbook)); actualEndDateCell.setCellStyle(MyStatusFileUtil.cellStyleDate(workbook));
statusRow.createCell(8).setCellValue(status.getHoursSpent()); statusRow.createCell(8).setCellValue(status.getHoursSpent());
statusRow.createCell(9).setCellValue(status.getPriority()); statusRow.createCell(9).setCellValue(status.getPriority());
......
package com.nisum.myteam.status.fileexport; package com.nisum.myteam.fileexport;
import com.itextpdf.io.source.ByteArrayOutputStream; import com.itextpdf.io.source.ByteArrayOutputStream;
import com.itextpdf.text.*; import com.itextpdf.text.*;
import com.itextpdf.text.pdf.PdfPCell; import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable; import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter; import com.itextpdf.text.pdf.PdfWriter;
import com.nisum.myteam.status.model.Status; import com.nisum.myteam.model.dao.MyStatus;
import com.nisum.myteam.status.util.FileUtil; import com.nisum.myteam.utils.MyStatusFileUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.util.List; import java.util.List;
public class GeneratePdfReport { public class GenerateStatusPdfReport {
public static ByteArrayInputStream statusReport(List<Status> statusResponse) { public static ByteArrayInputStream statusReport(List<MyStatus> statusResponse) {
final Logger log = LoggerFactory.getLogger(GeneratePdfReport.class); final Logger log = LoggerFactory.getLogger(GenerateStatusPdfReport.class);
Document document = new Document(); Document document = new Document();
ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream();
...@@ -82,10 +82,10 @@ public class GeneratePdfReport { ...@@ -82,10 +82,10 @@ public class GeneratePdfReport {
hcell.setHorizontalAlignment(Element.ALIGN_CENTER); hcell.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(hcell); table.addCell(hcell);
for(Status status: statusResponse){ for(MyStatus status: statusResponse){
PdfPCell cell; PdfPCell cell;
cell = new PdfPCell(new Phrase(FileUtil.dateToStringFormatter(status.getTaskDate()))); cell = new PdfPCell(new Phrase(MyStatusFileUtil.dateToStringFormatter(status.getTaskDate())));
table.addCell(cell); table.addCell(cell);
cell = new PdfPCell(new Phrase(status.getTaskType())); cell = new PdfPCell(new Phrase(status.getTaskType()));
table.addCell(cell); table.addCell(cell);
...@@ -93,13 +93,13 @@ public class GeneratePdfReport { ...@@ -93,13 +93,13 @@ public class GeneratePdfReport {
table.addCell(cell); table.addCell(cell);
cell = new PdfPCell(new Phrase(String.valueOf(status.getStoryPoints()))); cell = new PdfPCell(new Phrase(String.valueOf(status.getStoryPoints())));
table.addCell(cell); table.addCell(cell);
cell = new PdfPCell(new Phrase(FileUtil.dateToStringFormatter((status.getPlanedStartDate())))); cell = new PdfPCell(new Phrase(MyStatusFileUtil.dateToStringFormatter((status.getPlanedStartDate()))));
table.addCell(cell); table.addCell(cell);
cell = new PdfPCell(new Phrase(FileUtil.dateToStringFormatter(status.getPlanedEndDate()))); cell = new PdfPCell(new Phrase(MyStatusFileUtil.dateToStringFormatter(status.getPlanedEndDate())));
table.addCell(cell); table.addCell(cell);
cell = new PdfPCell(new Phrase(FileUtil.dateToStringFormatter(status.getActualStartDate()))); cell = new PdfPCell(new Phrase(MyStatusFileUtil.dateToStringFormatter(status.getActualStartDate())));
table.addCell(cell); table.addCell(cell);
cell = new PdfPCell(new Phrase(FileUtil.dateToStringFormatter(status.getActualEndDate()))); cell = new PdfPCell(new Phrase(MyStatusFileUtil.dateToStringFormatter(status.getActualEndDate())));
table.addCell(cell); table.addCell(cell);
cell = new PdfPCell(new Phrase(String.valueOf(status.getHoursSpent()))); cell = new PdfPCell(new Phrase(String.valueOf(status.getHoursSpent())));
table.addCell(cell); table.addCell(cell);
......
package com.nisum.myteam.model;
import lombok.*;
import java.time.LocalDate;
import java.util.Date;
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Book {
private int bookId;
private String bookName;
private Date date;
}
package com.nisum.myteam.status.model; package com.nisum.myteam.model;
import lombok.*; import lombok.*;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Date;
@Getter @Getter
...@@ -13,6 +14,6 @@ import java.time.LocalDate; ...@@ -13,6 +14,6 @@ import java.time.LocalDate;
@Data @Data
public class FromToDates { public class FromToDates {
private LocalDate fromDate; private Date fromDate;
private LocalDate toDate; private Date toDate;
} }
package com.nisum.myteam.status.model; package com.nisum.myteam.model;
import lombok.*; import lombok.*;
......
package com.nisum.myteam.status.model; package com.nisum.myteam.model.dao;
import lombok.*; import lombok.*;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.Document;
import java.io.Serializable;
@Getter @Setter @ToString @Getter @Setter @ToString
@NoArgsConstructor @AllArgsConstructor @NoArgsConstructor @AllArgsConstructor
@Document(collection = "database_sequences") @Document(collection = "database_sequences")
public class DatabaseSequence { public class DatabaseSequence implements Serializable {
private static final long serialVersionUID = 1L;
@Id @Id
private String id; private String id;
......
package com.nisum.myteam.status.model; package com.nisum.myteam.model.dao;
import lombok.*; import lombok.*;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient; import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.Document;
import java.time.LocalDate; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Date;
@Getter @Setter @Getter @Setter
@ToString @ToString
...@@ -14,20 +15,22 @@ import java.time.LocalDateTime; ...@@ -14,20 +15,22 @@ import java.time.LocalDateTime;
@Data @Data
@Document(collection = "mystatus") @Document(collection = "mystatus")
public class Status { public class MyStatus implements Serializable {
private static final long serialVersionUID = 1L;
@Transient @Transient
public static final String SEQUENCE_NAME = "users_sequence"; public static final String SEQUENCE_NAME = "users_sequence";
@Id @Id
private Integer id; private Integer id;
private LocalDate taskDate; private Date taskDate;
private String ticketNumber; private String ticketNumber;
private int storyPoints; private int storyPoints;
private LocalDate planedStartDate; private Date planedStartDate;
private LocalDate planedEndDate; private Date planedEndDate;
private LocalDate actualStartDate; private Date actualStartDate;
private LocalDate actualEndDate; private Date actualEndDate;
private String hoursSpent; private String hoursSpent;
private String comments; private String comments;
private String taskDetails; private String taskDetails;
......
package com.nisum.myteam.status.repository; package com.nisum.myteam.repository;
import com.nisum.myteam.model.dao.MyStatus;
import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.mongodb.repository.MongoRepository;
import com.nisum.myteam.status.model.Status;
import org.springframework.stereotype.Repository;
import java.util.Optional; import java.util.Optional;
//@Repository //@Repository
public interface StatusRepository extends MongoRepository<Status, Integer> { public interface MyStatusRepository extends MongoRepository<MyStatus, Integer> {
public Optional<Status> findById(Integer id); public Optional<MyStatus> findById(Integer id);
public Boolean existsById(Integer id); public Boolean existsById(Integer id);
public void deleteById(Integer id); public void deleteById(Integer id);
......
package com.nisum.myteam.status.repository; package com.nisum.myteam.repository;
import org.springframework.data.domain.Sort; import com.nisum.myteam.model.dao.MyStatus;
import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import com.nisum.myteam.status.model.Status;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Date;
import java.util.List; import java.util.List;
@Repository @Repository
public class StatusRepositoryImpl{ public class MyStatusRepositoryImpl {
private final MongoTemplate mongoTemplate; private final MongoTemplate mongoTemplate;
public StatusRepositoryImpl(MongoTemplate mongoTemplate) { public MyStatusRepositoryImpl(MongoTemplate mongoTemplate) {
this.mongoTemplate = mongoTemplate; this.mongoTemplate = mongoTemplate;
} }
public List<Status> findByempId(String empId){ public List<MyStatus> findByempId(String empId){
try{ try{
Query query = new Query().addCriteria(Criteria.where("empId").is(empId)); Query query = new Query().addCriteria(Criteria.where("empId").is(empId));
return mongoTemplate.find(query, Status.class); return mongoTemplate.find(query, MyStatus.class);
} }
catch(Exception e){ catch(Exception e){
throw e; throw e;
} }
} }
public List<Status> findByDateRange(LocalDate fromDate, LocalDate toDate, String empId){ public List<MyStatus> findByDateRange(Date fromDate, Date toDate, String empId){
try{ try{
Query query = new Query().addCriteria(Criteria.where("empId").is(empId) Query query = new Query().addCriteria(Criteria.where("empId").is(empId)
.andOperator( .andOperator(
...@@ -38,7 +37,7 @@ public class StatusRepositoryImpl{ ...@@ -38,7 +37,7 @@ public class StatusRepositoryImpl{
Criteria.where("taskDate").lte(toDate)) Criteria.where("taskDate").lte(toDate))
); );
//query.with(Sort.by(Sort.Order.desc("taskDate"))); //query.with(Sort.by(Sort.Order.desc("taskDate")));
return mongoTemplate.find(query, Status.class); return mongoTemplate.find(query, MyStatus.class);
} }
catch(Exception e){ catch(Exception e){
throw e; throw e;
...@@ -46,23 +45,23 @@ public class StatusRepositoryImpl{ ...@@ -46,23 +45,23 @@ public class StatusRepositoryImpl{
} }
//@Query(value = "SELECT *FROM mystatus_db.mystatus t WHERE t.emp_id =?1 and (select count(distinct t2.task_date) from mystatus_db.mystatus t2 where t2.emp_id = t.emp_id and t2.task_date >= t.task_date) <= 5 order by t.task_date desc") //@Query(value = "SELECT *FROM mystatus_db.mystatus t WHERE t.emp_id =?1 and (select count(distinct t2.task_date) from mystatus_db.mystatus t2 where t2.emp_id = t.emp_id and t2.task_date >= t.task_date) <= 5 order by t.task_date desc")
public List<Status> findByLastFiveDays(String empId){ public List<MyStatus> findByLastFiveDays(String empId){
try{ try{
Query query = new Query().addCriteria(Criteria.where("empId").is(empId) Query query = new Query().addCriteria(Criteria.where("empId").is(empId)
); );
query.limit(20); query.limit(20);
//query.with(Sort.by(Sort.Order.desc("taskDate"))).limit(20); //query.with(Sort.by(Sort.Order.desc("taskDate"))).limit(20);
return mongoTemplate.find(query, Status.class); return mongoTemplate.find(query, MyStatus.class);
} }
catch(Exception e){ catch(Exception e){
throw e; throw e;
} }
} }
public List<Status> findTodayStatus(String empId, LocalDate today){ public List<MyStatus> findTodayStatus(String empId, LocalDate today){
try{ try{
Query query = new Query().addCriteria(Criteria.where("empId").is(empId).and("taskDate").is(today)); Query query = new Query().addCriteria(Criteria.where("empId").is(empId).and("taskDate").is(today));
return mongoTemplate.find(query, Status.class); return mongoTemplate.find(query, MyStatus.class);
} }
catch(Exception e){ catch(Exception e){
throw e; throw e;
......
package com.nisum.myteam.service;
import com.nisum.myteam.model.dao.MyStatus;
import java.time.LocalDate;
import java.util.Date;
import java.util.List;
public interface MyStatusService {
public MyStatus saveStatusDetails(MyStatus status);
public List<MyStatus> findTodayStatus(String empId);
public List<MyStatus> findTaskDataByTaskDate(String empId, LocalDate date);
public List<MyStatus> getStatusDetailsByEmpId(String empId);
public List<MyStatus> getByDateRange(Date fromDate, Date toDate, String empId);
public List<MyStatus> getEmployeeStatusDetails();
public MyStatus updateStatusDetails(MyStatus status);
public void deleteEmployeeStatusDetails(Integer id);
public List<MyStatus> getDefaultStatusDetails(String empId);
}
package com.nisum.myteam.status.service; package com.nisum.myteam.service;
import com.nisum.myteam.model.dao.DatabaseSequence;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoOperations; import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.query.Update; import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.nisum.myteam.status.model.DatabaseSequence;
import java.util.Objects; import java.util.Objects;
import static org.springframework.data.mongodb.core.FindAndModifyOptions.options; import static org.springframework.data.mongodb.core.FindAndModifyOptions.options;
import static org.springframework.data.mongodb.core.query.Criteria.where; import static org.springframework.data.mongodb.core.query.Criteria.where;
import static org.springframework.data.mongodb.core.query.Query.query; import static org.springframework.data.mongodb.core.query.Query.query;
import java.util.Objects;
@Service @Service
public class SequenceGeneratorService { public class SequenceGeneratorService {
......
package com.nisum.myteam.status.service; package com.nisum.myteam.service.impl;
import com.itextpdf.styledxmlparser.jsoup.helper.StringUtil; import com.itextpdf.styledxmlparser.jsoup.helper.StringUtil;
import com.nisum.myteam.exception.handler.EmployeeNotFoundException;
import com.nisum.myteam.service.MyStatusService;
import com.nisum.myteam.service.SequenceGeneratorService;
import com.nisum.myteam.model.dao.MyStatus;
import com.nisum.myteam.repository.MyStatusRepository;
import com.nisum.myteam.repository.MyStatusRepositoryImpl;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.LocalDataSourceJobStore;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.nisum.myteam.status.exceptions.EmployeeNotFoundException;
import com.nisum.myteam.status.model.Status;
import com.nisum.myteam.status.repository.StatusRepository;
import com.nisum.myteam.status.repository.StatusRepositoryImpl;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@Service @Service
public class StatusServiceImpl implements StatusService { public class MyStatusServiceImpl implements MyStatusService {
private static final Logger LOGGER = LoggerFactory.getLogger(StatusServiceImpl.class); private static final Logger LOGGER = LoggerFactory.getLogger(MyStatusServiceImpl.class);
@Autowired @Autowired
private StatusRepository repository; private MyStatusRepository repository;
@Autowired @Autowired
private SequenceGeneratorService sequenceGeneratorService; private SequenceGeneratorService sequenceGeneratorService;
@Autowired @Autowired
private StatusRepositoryImpl statusRepositoryImpl; private MyStatusRepositoryImpl statusRepositoryImpl;
/** /**
* Save the task details * Save the task details
* @param status * @param status
* @return * @return
*/ */
public Status saveStatusDetails(Status status) { public MyStatus saveStatusDetails(MyStatus status) {
Optional<Status> s = Optional.ofNullable(status); Optional<MyStatus> s = Optional.ofNullable(status);
if(s.isPresent()){ if(s.isPresent()){
status.setId((int) sequenceGeneratorService.generateSequence(Status.SEQUENCE_NAME)); status.setId((int) sequenceGeneratorService.generateSequence(MyStatus.SEQUENCE_NAME));
if(StringUtil.isBlank(status.getTicketNumber())){ if(StringUtil.isBlank(status.getTicketNumber())){
status.setTicketNumber("NA"); status.setTicketNumber("NA");
} }
...@@ -57,7 +61,7 @@ public class StatusServiceImpl implements StatusService { ...@@ -57,7 +61,7 @@ public class StatusServiceImpl implements StatusService {
status.setStatus("NA"); status.setStatus("NA");
} }
} }
Status saveStatus = s.get(); MyStatus saveStatus = s.get();
LOGGER.info("Request for saving task details : "+saveStatus); LOGGER.info("Request for saving task details : "+saveStatus);
return repository.save(saveStatus); return repository.save(saveStatus);
} }
...@@ -67,9 +71,9 @@ public class StatusServiceImpl implements StatusService { ...@@ -67,9 +71,9 @@ public class StatusServiceImpl implements StatusService {
* @param empId * @param empId
* @return * @return
*/ */
public List<Status> findTodayStatus(String empId){ public List<MyStatus> findTodayStatus(String empId){
LocalDate today = LocalDate.now(); LocalDate today = LocalDate.now();
List<Status> status = null; List<MyStatus> status = null;
try{ try{
if(empId != null){ if(empId != null){
status = statusRepositoryImpl.findTodayStatus(empId, today); status = statusRepositoryImpl.findTodayStatus(empId, today);
...@@ -87,8 +91,8 @@ public class StatusServiceImpl implements StatusService { ...@@ -87,8 +91,8 @@ public class StatusServiceImpl implements StatusService {
* @param date * @param date
* @return status * @return status
*/ */
public List<Status> findTaskDataByTaskDate(String empId, LocalDate date){ public List<MyStatus> findTaskDataByTaskDate(String empId, LocalDate date){
List<Status> status = null; List<MyStatus> status = null;
try{ try{
if(!StringUtil.isBlank(empId) && date != null){ if(!StringUtil.isBlank(empId) && date != null){
status = statusRepositoryImpl.findTodayStatus(empId, date); status = statusRepositoryImpl.findTodayStatus(empId, date);
...@@ -107,7 +111,7 @@ public class StatusServiceImpl implements StatusService { ...@@ -107,7 +111,7 @@ public class StatusServiceImpl implements StatusService {
* @param empId * @param empId
* @return * @return
*/ */
public List<Status> getStatusDetailsByEmpId(String empId){ public List<MyStatus> getStatusDetailsByEmpId(String empId){
try{ try{
return statusRepositoryImpl.findByempId(empId); return statusRepositoryImpl.findByempId(empId);
}catch(Exception e){ }catch(Exception e){
...@@ -122,7 +126,7 @@ public class StatusServiceImpl implements StatusService { ...@@ -122,7 +126,7 @@ public class StatusServiceImpl implements StatusService {
* @param empId * @param empId
* @return * @return
*/ */
public List<Status> getByDateRange(LocalDate fromDate, LocalDate toDate, String empId){ public List<MyStatus> getByDateRange(Date fromDate, Date toDate, String empId){
try{ try{
return statusRepositoryImpl.findByDateRange(fromDate, toDate, empId); return statusRepositoryImpl.findByDateRange(fromDate, toDate, empId);
}catch(Exception e){ }catch(Exception e){
...@@ -134,7 +138,7 @@ public class StatusServiceImpl implements StatusService { ...@@ -134,7 +138,7 @@ public class StatusServiceImpl implements StatusService {
* Find the all employees task details * Find the all employees task details
* @return * @return
*/ */
public List<Status> getEmployeeStatusDetails() { public List<MyStatus> getEmployeeStatusDetails() {
try{ try{
return repository.findAll(); return repository.findAll();
} }
...@@ -148,10 +152,10 @@ public class StatusServiceImpl implements StatusService { ...@@ -148,10 +152,10 @@ public class StatusServiceImpl implements StatusService {
* @param status * @param status
* @return * @return
*/ */
public Status updateStatusDetails(Status status) { public MyStatus updateStatusDetails(MyStatus status) {
Optional<Status> optionalStatus = repository.findById(status.getId()); Optional<MyStatus> optionalStatus = repository.findById(status.getId());
if (optionalStatus.isPresent()) { if (optionalStatus.isPresent()) {
Status updatedStatus = optionalStatus.get(); MyStatus updatedStatus = optionalStatus.get();
updatedStatus.setTaskType(status.getTaskType()); updatedStatus.setTaskType(status.getTaskType());
updatedStatus.setTaskDate(status.getTaskDate()); updatedStatus.setTaskDate(status.getTaskDate());
updatedStatus.setStoryPoints(status.getStoryPoints()); updatedStatus.setStoryPoints(status.getStoryPoints());
...@@ -165,10 +169,11 @@ public class StatusServiceImpl implements StatusService { ...@@ -165,10 +169,11 @@ public class StatusServiceImpl implements StatusService {
updatedStatus.setComments(status.getComments()); updatedStatus.setComments(status.getComments());
updatedStatus.setStatus(status.getStatus()); updatedStatus.setStatus(status.getStatus());
updatedStatus.setTaskDetails(status.getTaskDetails()); updatedStatus.setTaskDetails(status.getTaskDetails());
updatedStatus.setTaskAddedTime(LocalDateTime.now());
repository.save(updatedStatus); repository.save(updatedStatus);
return updatedStatus; return updatedStatus;
} else { } else {
throw new EmployeeNotFoundException(status.getId()); throw new EmployeeNotFoundException("Employee not found on "+status.getId() + " Id");
} }
} }
...@@ -191,9 +196,9 @@ public class StatusServiceImpl implements StatusService { ...@@ -191,9 +196,9 @@ public class StatusServiceImpl implements StatusService {
* @param empId * @param empId
* @return * @return
*/ */
public List<Status> getDefaultStatusDetails(String empId) { public List<MyStatus> getDefaultStatusDetails(String empId) {
try{ try{
List<Status> status = statusRepositoryImpl.findByLastFiveDays(empId); List<MyStatus> status = statusRepositoryImpl.findByLastFiveDays(empId);
LOGGER.info("Response for last five dates task details : "+status); LOGGER.info("Response for last five dates task details : "+status);
return status; return status;
}catch(Exception e){ }catch(Exception e){
......
package com.nisum.myteam.status.exceptions;
public class EmployeeNotFoundException extends RuntimeException {
public EmployeeNotFoundException(Integer id) {
super("Employee Id Not Found");
}
}
package com.nisum.myteam.status.service;
import java.time.LocalDate;
import java.util.List;
import com.nisum.myteam.status.model.Status;
public interface StatusService {
public Status saveStatusDetails(Status status);
public List<Status> findTodayStatus(String empId);
public List<Status> findTaskDataByTaskDate(String empId, LocalDate date);
public List<Status> getStatusDetailsByEmpId(String empId);
public List<Status> getByDateRange(LocalDate fromDate, LocalDate toDate, String empId);
public List<Status> getEmployeeStatusDetails();
public Status updateStatusDetails(Status status);
public void deleteEmployeeStatusDetails(Integer id);
public List<Status> getDefaultStatusDetails(String empId);
}
package com.nisum.myteam.status.util; package com.nisum.myteam.utils;
import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.CreationHelper; import org.apache.poi.ss.usermodel.CreationHelper;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.util.Date;
public class FileUtil { public class MyStatusFileUtil {
public static CellStyle cellStyleDate(Workbook workbook) { public static CellStyle cellStyleDate(Workbook workbook) {
try{ try{
CellStyle cellStyle = workbook.createCellStyle(); CellStyle cellStyle = workbook.createCellStyle();
...@@ -20,7 +20,7 @@ public class FileUtil { ...@@ -20,7 +20,7 @@ public class FileUtil {
} }
} }
public static String dateToStringFormatter(LocalDate date){ public static String dateToStringFormatter(Date date){
String strDate = ""; String strDate = "";
try{ try{
if(date != null){ if(date != null){
......
...@@ -77,5 +77,5 @@ myTeam.exemptHours.toemail=offshore_funtional_leads@nisum.com ...@@ -77,5 +77,5 @@ myTeam.exemptHours.toemail=offshore_funtional_leads@nisum.com
email.exemptHours.notification.cron=00 00 09 * * 1-1 email.exemptHours.notification.cron=00 00 09 * * 1-1
email.exempt.hours.employeelist.template.file.path=email/employeesExemptHours.html email.exempt.hours.employeelist.template.file.path=email/employeesExemptHours.html
spring.profiles.active=production spring.profiles.active=development
message=this is from default configuration message=this is from default configuration
\ No newline at end of file
Markdown is supported
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