| Line 148... |
Line 148... |
| 148 |
public String getItemDescriptionByDate(
|
148 |
public String getItemDescriptionByDate(
|
| 149 |
HttpServletRequest request,
|
149 |
HttpServletRequest request,
|
| 150 |
@RequestParam LocalDateTime startDate,
|
150 |
@RequestParam LocalDateTime startDate,
|
| 151 |
@RequestParam LocalDateTime endDate,
|
151 |
@RequestParam LocalDateTime endDate,
|
| 152 |
Model model) throws Throwable {
|
152 |
Model model) throws Throwable {
|
| 153 |
if (endDate.isAfter(LocalDateTime.now()) || startDate.isAfter(LocalDateTime.now())) {
|
153 |
if (endDate.isAfter(LocalDateTime.now().plusDays(1)) || startDate.isAfter(LocalDateTime.now().plusDays(1))) {
|
| 154 |
throw new ProfitMandiBusinessException("startData and end data must if before the today date ", "", "");
|
154 |
throw new ProfitMandiBusinessException("startData and end data must if before the today date ", "", "");
|
| 155 |
}
|
155 |
}
|
| 156 |
try {
|
156 |
try {
|
| 157 |
List<PriceDrop> priceDrops = priceDropRepository.selectAllByDatesBetweenSortByDate(startDate, endDate);
|
157 |
List<PriceDrop> priceDrops = priceDropRepository.selectAllByDatesBetweenSortByDate(startDate, endDate);
|
| 158 |
|
158 |
|
| Line 175... |
Line 175... |
| 175 |
} catch (Exception e) {
|
175 |
} catch (Exception e) {
|
| 176 |
e.printStackTrace();
|
176 |
e.printStackTrace();
|
| 177 |
return "price-drop";
|
177 |
return "price-drop";
|
| 178 |
}
|
178 |
}
|
| 179 |
}
|
179 |
}
|
| 180 |
|
- |
|
| 181 |
@RequestMapping(value = "/pricedropByDate/download", method = RequestMethod.GET)
|
180 |
@RequestMapping(value = "/pricedropByDate/download", method = RequestMethod.GET)
|
| 182 |
public ResponseEntity<?> dowloadItems(HttpServletRequest request, @PathVariable(name = "tagId") @RequestParam LocalDateTime startDate, @RequestParam LocalDateTime endDate)
|
181 |
public ResponseEntity<?> dowloadItems(HttpServletRequest request, @PathVariable(name = "tagId") @RequestParam LocalDateTime startDate, @RequestParam LocalDateTime endDate)
|
| 183 |
throws Throwable {
|
182 |
throws Throwable {
|
| 184 |
List<PriceDrop> priceDrops = priceDropRepository.selectAllByDatesBetweenSortByDate(startDate, endDate);
|
183 |
List<PriceDrop> priceDrops = priceDropRepository.selectAllByDatesBetweenSortByDate(startDate, endDate);
|
| 185 |
Set<Integer> catalogIds = priceDrops.stream().map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
|
184 |
Set<Integer> catalogIds = priceDrops.stream().map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
|
| Line 188... |
Line 187... |
| 188 |
x -> x.getItemDescriptionNoColor(), (description1, description2) -> description1));
|
187 |
x -> x.getItemDescriptionNoColor(), (description1, description2) -> description1));
|
| 189 |
|
188 |
|
| 190 |
List<List<?>> rows = new ArrayList<>();
|
189 |
List<List<?>> rows = new ArrayList<>();
|
| 191 |
for (PriceDrop priceDrop : priceDrops) {
|
190 |
for (PriceDrop priceDrop : priceDrops) {
|
| 192 |
rows.add(Arrays.asList(priceDrop.getId(), catalogDescription.get(priceDrop.getCatalogItemId()), priceDrop.getTp(), priceDrop.getOldDp(), priceDrop.getMop(),
|
191 |
rows.add(Arrays.asList(priceDrop.getId(), catalogDescription.get(priceDrop.getCatalogItemId()), priceDrop.getTp(), priceDrop.getOldDp(), priceDrop.getMop(),
|
| 193 |
priceDrop.getAmount(), priceDrop.getNewDp(), FormattingUtils.format(priceDrop.getAffectedOn()), FormattingUtils.format(priceDrop.getCreatedOn())
|
192 |
priceDrop.getAmount(), priceDrop.getNewDp(), FormattingUtils.formatDate(priceDrop.getAffectedOn()), FormattingUtils.formatDate(priceDrop.getCreatedOn())
|
| 194 |
));
|
193 |
));
|
| 195 |
|
194 |
|
| 196 |
}
|
195 |
}
|
| 197 |
org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
|
196 |
org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
|
| 198 |
Arrays.asList("Drop Id", "Item Name", "TP", "DP", "Mop", "Price Drop",
|
197 |
Arrays.asList("Drop Id", "Item Name", "TP", "DP", "Mop", "Price Drop",
|