Commit aa7f2c24 authored by Ramakanth Dhane's avatar Ramakanth Dhane

Removed test data from dashboard

parent 96c532dd
package com.nisum.omd;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;
import java.util.concurrent.CompletableFuture;
......
package com.nisum.omd.config;
import com.github.javafaker.Faker;
import com.nisum.omd.domain.Order;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.common.serialization.StringSerializer;
......@@ -36,4 +37,8 @@ public class OmdProducerConfig {
public KafkaTemplate<String, Order> kafkaTemplate(){
return new KafkaTemplate<>(producerFactory());
}
@Bean
public Faker getFaker() {
return new Faker();
}
}
......@@ -19,7 +19,8 @@ public class RandomDataGeneratorImpl implements RandomDataGenerator {
@Autowired
private Order order;
private Faker faker = new Faker();
@Autowired
private Faker faker;
public String generateOrderNumber() {
return String.valueOf(faker.number().numberBetween(1000000, 9999999));
......
package com.nisum.omd.controllers;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -13,7 +12,7 @@ import com.nisum.omd.dto.WeeklyOrders;
import com.nisum.omd.pojo.OrdersSummary;
import com.nisum.omd.service.OrdersSummaryService;
@CrossOrigin(origins = "*", maxAge = 3600)
@RestController
@RequestMapping("orders")
public class OrdersSummaryController {
......@@ -26,14 +25,6 @@ public class OrdersSummaryController {
OrdersSummary ordersSummary=ordersSummaryService.getOrderSummaryCount();
return ordersSummary;
}
/*
@GetMapping("/weeklyCount")
public Map<LocalDate, Long> getWeeklyOrderSummary(){
Map<LocalDate, Long> ordersSummary=ordersSummaryService.getOrderSummaryInWeek();
return ordersSummary;
} */
@GetMapping("/weeklyCount")
public List<WeeklyOrders> getWeeklyOrderSummary(){
List<WeeklyOrders> ordersSummary=ordersSummaryService.getOrderSummaryInWeek();
......
package com.nisum.omd.service;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import com.nisum.omd.dto.WeeklyOrders;
import com.nisum.omd.pojo.OrdersSummary;
......@@ -10,7 +8,6 @@ import com.nisum.omd.pojo.OrdersSummary;
public interface OrdersSummaryService {
OrdersSummary getOrderSummaryCount();
// Map<LocalDate,Long> getOrderSummaryInWeek();
List<WeeklyOrders> getOrderSummaryInWeek();
}
......
......@@ -125,60 +125,36 @@ public class OrdersSummaryServiceImpl implements OrdersSummaryService {
}
/* private Map<LocalDate, Long> orderCountInCustomDate(){
private List<WeeklyOrders> orderCountInCustomDate() {
List<WeeklyOrders> orders = new ArrayList<>();
Integer weekCount = 6;
TreeMap<LocalDate, Long> hm = new TreeMap<>();
for(int i=weekCount; i >=0; i--) {
for (int i = weekCount; i >= 0; i--) {
LocalTime fromdt = LocalTime.of(00, 00,00);
LocalTime todt = LocalTime.of(23, 59,59);
LocalTime fromdt = LocalTime.of(00, 00, 00);
LocalTime todt = LocalTime.of(23, 59, 59);
Instant instant = fromdt.atDate(LocalDate.now().minusDays(i)).
atZone(ZoneId.systemDefault()).toInstant();
Instant instant = fromdt.atDate(LocalDate.now().minusDays(i)).atZone(ZoneId.systemDefault()).toInstant();
Date time1 = Date.from(instant);
Long fromDate=time1.getTime();
Long fromDate = time1.getTime();
Instant instant2 = todt.atDate(LocalDate.now().minusDays(i)).
atZone(ZoneId.systemDefault()).toInstant();
Instant instant2 = todt.atDate(LocalDate.now().minusDays(i)).atZone(ZoneId.systemDefault()).toInstant();
Date time2 = Date.from(instant2);
Long toDate=time2.getTime();
Long toDate = time2.getTime();
DynamicQuery dynamicQuery = new DynamicQuery();
dynamicQuery.setOrderDateFrom(fromDate);
dynamicQuery.setOrderDateTo(toDate);
Long orderCount = ordersSummaryRepository.query(dynamicQuery);
LocalDate formattedFromDate =
Instant.ofEpochMilli(fromDate).atZone(ZoneId.systemDefault()).toLocalDate();
hm.put(formattedFromDate, orderCount);
LocalDate formattedFromDate = Instant.ofEpochMilli(fromDate).atZone(ZoneId.systemDefault()).toLocalDate();
WeeklyOrders order = new WeeklyOrders(formattedFromDate + "", orderCount);
orders.add(order);
}
return hm;
}
*/
private List<WeeklyOrders> orderCountInCustomDate() {
List<WeeklyOrders> orders = new ArrayList<>();
WeeklyOrders order1 = new WeeklyOrders(LocalDate.now() + "", 900L);
WeeklyOrders order2 = new WeeklyOrders(LocalDate.now().minusDays(1) + "", 100L);
WeeklyOrders order3 = new WeeklyOrders(LocalDate.now().minusDays(2) + "", 200L);
WeeklyOrders order4 = new WeeklyOrders(LocalDate.now().minusDays(3) + "", 300L);
WeeklyOrders order5 = new WeeklyOrders(LocalDate.now().minusDays(4) + "", 400L);
WeeklyOrders order6 = new WeeklyOrders(LocalDate.now().minusDays(5) + "", 500L);
WeeklyOrders order7 = new WeeklyOrders(LocalDate.now().minusDays(6) + "", 600L);
orders.add(order1);
orders.add(order2);
orders.add(order3);
orders.add(order4);
orders.add(order5);
orders.add(order6);
orders.add(order7);
return orders;
}
/* public OrdersSummary getOrderSummaryCount(){
public OrdersSummary getOrderSummaryCount(){
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd-YYYY");
LocalDateTime localTime = LocalDateTime.now();
OrdersSummary ordersSummary=new OrdersSummary();
......@@ -191,37 +167,12 @@ public class OrdersSummaryServiceImpl implements OrdersSummaryService {
ordersSummary.setCurrentDate(simpleDateFormat.format(new Date()));
return ordersSummary;
}
*/
public OrdersSummary getOrderSummaryCount(){
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd-YYYY");
LocalDateTime localTime = LocalDateTime.now();
OrdersSummary ordersSummary=new OrdersSummary();
ordersSummary.setOrderCountInMinute(++minuteCount);
ordersSummary.setOrderCountInHour(++HrCount);
ordersSummary.setOrderCountInDay(++dayCount);
ordersSummary.setTotalCustomers(++cutomers);
ordersSummary.setCurrentMinute(LocalTime.of(localTime.getHour(), localTime.getMinute(),00).toString());
ordersSummary.setCurrentHour(LocalTime.of(localTime.getHour(), 00,00).toString());
ordersSummary.setCurrentDate(simpleDateFormat.format(new Date()));
return ordersSummary;
}
/* @Override
public Map<LocalDate, Long> getOrderSummaryInWeek() {
return orderCountInCustomDate();
}
*/
@Override
public List<WeeklyOrders> getOrderSummaryInWeek() {
return orderCountInCustomDate();
}
}
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