| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import java.io.IOException;
|
- |
|
| 4 |
import java.time.LocalDate;
|
- |
|
| 5 |
import java.time.LocalDateTime;
|
- |
|
| 6 |
import java.time.LocalTime;
|
- |
|
| 7 |
import java.time.format.DateTimeFormatter;
|
- |
|
| 8 |
import java.util.ArrayList;
|
- |
|
| 9 |
import java.util.Arrays;
|
- |
|
| 10 |
import java.util.HashMap;
|
- |
|
| 11 |
import java.util.List;
|
- |
|
| 12 |
import java.util.Map;
|
- |
|
| 13 |
|
- |
|
| 14 |
import javax.servlet.http.HttpServletRequest;
|
- |
|
| 15 |
|
- |
|
| 16 |
import com.spice.profitmandi.dao.model.SchemePayoutReportModel;
|
- |
|
| 17 |
import org.apache.http.HttpResponse;
|
- |
|
| 18 |
import org.apache.logging.log4j.LogManager;
|
- |
|
| 19 |
import org.apache.logging.log4j.Logger;
|
- |
|
| 20 |
import org.springframework.beans.factory.annotation.Autowired;
|
- |
|
| 21 |
import org.springframework.core.io.InputStreamResource;
|
- |
|
| 22 |
import org.springframework.http.HttpHeaders;
|
- |
|
| 23 |
import org.springframework.http.HttpStatus;
|
- |
|
| 24 |
import org.springframework.http.ResponseEntity;
|
- |
|
| 25 |
import org.springframework.stereotype.Controller;
|
- |
|
| 26 |
import org.springframework.transaction.annotation.Transactional;
|
- |
|
| 27 |
import org.springframework.ui.Model;
|
- |
|
| 28 |
import org.springframework.web.bind.annotation.PathVariable;
|
- |
|
| 29 |
import org.springframework.web.bind.annotation.RequestBody;
|
- |
|
| 30 |
import org.springframework.web.bind.annotation.RequestMapping;
|
- |
|
| 31 |
import org.springframework.web.bind.annotation.RequestMethod;
|
- |
|
| 32 |
import org.springframework.web.bind.annotation.RequestParam;
|
- |
|
| 33 |
|
- |
|
| 34 |
import com.spice.profitmandi.common.enumuration.ReporticoProject;
|
3 |
import com.spice.profitmandi.common.enumuration.ReporticoProject;
|
| 35 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
4 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 36 |
import com.spice.profitmandi.common.model.ReporticoUrlInfo;
|
5 |
import com.spice.profitmandi.common.model.ReporticoUrlInfo;
|
| 37 |
import com.spice.profitmandi.common.services.ReporticoService;
|
6 |
import com.spice.profitmandi.common.services.ReporticoService;
|
| 38 |
import com.spice.profitmandi.common.util.FileUtil;
|
7 |
import com.spice.profitmandi.common.util.FileUtil;
|
| Line 45... |
Line 14... |
| 45 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
14 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 46 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
15 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 47 |
import com.spice.profitmandi.service.order.OrderService;
|
16 |
import com.spice.profitmandi.service.order.OrderService;
|
| 48 |
import com.spice.profitmandi.web.model.LoginDetails;
|
17 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 49 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
18 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| - |
|
19 |
import org.apache.http.HttpResponse;
|
| - |
|
20 |
import org.apache.logging.log4j.LogManager;
|
| - |
|
21 |
import org.apache.logging.log4j.Logger;
|
| - |
|
22 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
23 |
import org.springframework.core.io.InputStreamResource;
|
| - |
|
24 |
import org.springframework.http.HttpHeaders;
|
| - |
|
25 |
import org.springframework.http.HttpStatus;
|
| - |
|
26 |
import org.springframework.http.ResponseEntity;
|
| - |
|
27 |
import org.springframework.stereotype.Controller;
|
| - |
|
28 |
import org.springframework.transaction.annotation.Transactional;
|
| - |
|
29 |
import org.springframework.ui.Model;
|
| - |
|
30 |
import org.springframework.web.bind.annotation.*;
|
| - |
|
31 |
|
| - |
|
32 |
import javax.servlet.http.HttpServletRequest;
|
| - |
|
33 |
import java.io.IOException;
|
| - |
|
34 |
import java.time.LocalDate;
|
| - |
|
35 |
import java.time.LocalDateTime;
|
| - |
|
36 |
import java.time.LocalTime;
|
| - |
|
37 |
import java.time.format.DateTimeFormatter;
|
| - |
|
38 |
import java.util.*;
|
| 50 |
|
39 |
|
| 51 |
@Controller
|
40 |
@Controller
|
| 52 |
@Transactional(rollbackFor = Throwable.class)
|
41 |
@Transactional(rollbackFor = Throwable.class)
|
| 53 |
public class ReportsController {
|
42 |
public class ReportsController {
|
| 54 |
|
43 |
|
| Line 128... |
Line 117... |
| 128 |
|
117 |
|
| 129 |
@RequestMapping(value = "/collectionSummary", method = RequestMethod.GET)
|
118 |
@RequestMapping(value = "/collectionSummary", method = RequestMethod.GET)
|
| 130 |
public String getCollectionSummary(HttpServletRequest request,
|
119 |
public String getCollectionSummary(HttpServletRequest request,
|
| 131 |
Model model) throws ProfitMandiBusinessException {
|
120 |
Model model) throws ProfitMandiBusinessException {
|
| 132 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
121 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 133 |
|
- |
|
| - |
|
122 |
boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
|
| 134 |
LocalDateTime currentDate = LocalDate.now().atStartOfDay();
|
123 |
LocalDateTime currentDate = LocalDate.now().atStartOfDay();
|
| 135 |
LocalDateTime currentStartMonth = currentDate.minusDays(30).toLocalDate().atStartOfDay();
|
124 |
LocalDateTime currentStartMonth = currentDate.minusDays(30).toLocalDate().atStartOfDay();
|
| 136 |
|
125 |
|
| 137 |
List<CollectionSummary> collectionSummaryList =orderRepository.selectCollectionSummary(fofoDetails.getFofoId(),currentStartMonth, currentDate);
|
126 |
List<CollectionSummary> collectionSummaryList =orderRepository.selectCollectionSummary(fofoDetails.getFofoId(),currentStartMonth, currentDate);
|
| 138 |
|
127 |
|
| 139 |
Logger.info("CollectionSummaryList {}", collectionSummaryList);
|
128 |
Logger.info("CollectionSummaryList {}", collectionSummaryList);
|
| 140 |
|
129 |
|
| 141 |
model.addAttribute("startDate",currentDate.minusDays(30).toLocalDate());
|
130 |
model.addAttribute("startDate",currentDate.minusDays(30).toLocalDate());
|
| 142 |
model.addAttribute("endDate", LocalDate.now());
|
131 |
model.addAttribute("endDate", LocalDate.now());
|
| 143 |
model.addAttribute("collectionSummaryList", collectionSummaryList);
|
132 |
model.addAttribute("collectionSummaryList", collectionSummaryList);
|
| - |
|
133 |
model.addAttribute("isAdmin", isAdmin);
|
| 144 |
return "partner-collection-summary";
|
134 |
return "partner-collection-summary";
|
| 145 |
}
|
135 |
}
|
| 146 |
@RequestMapping(value = "/collectionSummaryFetchReportByDate", method = RequestMethod.GET)
|
136 |
@RequestMapping(value = "/collectionSummaryFetchReportByDate", method = RequestMethod.GET)
|
| 147 |
public String getcollectionSummaryFetchReport(HttpServletRequest request,
|
137 |
public String getcollectionSummaryFetchReport(HttpServletRequest request,
|
| - |
|
138 |
@RequestParam(defaultValue = "0") int fofoId,
|
| 148 |
@RequestParam(name = "startDate", required = true, defaultValue = "") LocalDate startDate,
|
139 |
@RequestParam(name = "startDate", required = true, defaultValue = "") LocalDate startDate,
|
| 149 |
@RequestParam(name = "endDate", required = true, defaultValue = "") LocalDate endDate, Model model)
|
140 |
@RequestParam(name = "endDate", required = true, defaultValue = "") LocalDate endDate, Model model)
|
| 150 |
throws Exception {
|
141 |
throws Exception {
|
| 151 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
142 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
143 |
boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
|
| - |
|
144 |
if (isAdmin) {
|
| - |
|
145 |
startDate = LocalDate.now().minusDays(30);
|
| - |
|
146 |
endDate = LocalDate.now();
|
| - |
|
147 |
}
|
| - |
|
148 |
model.addAttribute("startDate",startDate);
|
| - |
|
149 |
model.addAttribute("endDate", endDate);
|
| - |
|
150 |
model.addAttribute("isAdmin", isAdmin);
|
| 152 |
|
151 |
|
| 153 |
List<List<?>> rows = new ArrayList<>();
|
- |
|
| 154 |
|
152 |
|
| - |
|
153 |
if (isAdmin) {
|
| - |
|
154 |
if (fofoId == 0) {
|
| - |
|
155 |
//No need to send any data
|
| 155 |
LocalDateTime currentDate = LocalDate.now().atStartOfDay();
|
156 |
model.addAttribute("collectionSummaryList", new ArrayList<>());
|
| - |
|
157 |
return "partner-collection-summary";
|
| - |
|
158 |
} else {
|
| - |
|
159 |
List<CollectionSummary> collectionSummaryList = orderRepository
|
| - |
|
160 |
.selectCollectionSummary(fofoId, startDate.atStartOfDay(), endDate.atTime(LocalTime.MAX));
|
| - |
|
161 |
model.addAttribute("collectionSummaryList", collectionSummaryList);
|
| - |
|
162 |
return "partner-collection-summary";
|
| 156 |
|
163 |
}
|
| - |
|
164 |
} else {
|
| - |
|
165 |
fofoId = fofoDetails.getFofoId();
|
| 157 |
List<CollectionSummary> collectionSummaryList =orderRepository
|
166 |
List<CollectionSummary> collectionSummaryList = orderRepository
|
| 158 |
.selectCollectionSummary(fofoDetails.getFofoId(), startDate.atStartOfDay(), endDate.atTime(LocalTime.MAX));
|
167 |
.selectCollectionSummary(fofoId, startDate.atStartOfDay(), endDate.atTime(LocalTime.MAX));
|
| 159 |
Logger.info("CollectionSummaryList {}", collectionSummaryList);
|
168 |
model.addAttribute("collectionSummaryList", collectionSummaryList);
|
| - |
|
169 |
return "partner-collection-summary";
|
| 160 |
|
170 |
|
| 161 |
model.addAttribute("startDate",startDate);
|
- |
|
| 162 |
model.addAttribute("endDate", endDate);
|
- |
|
| 163 |
model.addAttribute("collectionSummaryList", collectionSummaryList);
|
- |
|
| 164 |
return "partner-collection-summary";
|
171 |
}
|
| 165 |
}
|
172 |
}
|
| 166 |
|
173 |
|
| 167 |
@RequestMapping(value = "/downloadCollectionSummary", method = RequestMethod.GET)
|
174 |
@RequestMapping(value = "/downloadCollectionSummary", method = RequestMethod.GET)
|
| 168 |
public ResponseEntity<?> getDownloadCollectionSummary(HttpServletRequest request,
|
175 |
public ResponseEntity<?> getDownloadCollectionSummary(HttpServletRequest request,
|
| 169 |
@RequestParam(name = "startDate", required = true, defaultValue = "") LocalDate startDate,
|
176 |
@RequestParam(name = "startDate", required = true, defaultValue = "") LocalDate startDate,
|