| Line 32... |
Line 32... |
| 32 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropRepository;
|
32 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropRepository;
|
| 33 |
import com.spice.profitmandi.service.NotificationService;
|
33 |
import com.spice.profitmandi.service.NotificationService;
|
| 34 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
34 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 35 |
import com.spice.profitmandi.service.catalog.BrandsService;
|
35 |
import com.spice.profitmandi.service.catalog.BrandsService;
|
| 36 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
36 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| - |
|
37 |
import com.spice.profitmandi.service.order.OrderService;
|
| 37 |
import com.spice.profitmandi.service.pricecircular.PriceCircularItemModelNew;
|
38 |
import com.spice.profitmandi.service.pricecircular.PriceCircularItemModelNew;
|
| 38 |
import com.spice.profitmandi.service.pricecircular.PriceCircularModel;
|
39 |
import com.spice.profitmandi.service.pricecircular.PriceCircularModel;
|
| 39 |
import com.spice.profitmandi.service.pricecircular.PriceCircularService;
|
40 |
import com.spice.profitmandi.service.pricecircular.PriceCircularService;
|
| 40 |
import com.spice.profitmandi.service.pricing.PriceDropService;
|
41 |
import com.spice.profitmandi.service.pricing.PriceDropService;
|
| 41 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
42 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
| Line 125... |
Line 126... |
| 125 |
@Autowired
|
126 |
@Autowired
|
| 126 |
private NotificationService notificationService;
|
127 |
private NotificationService notificationService;
|
| 127 |
@Autowired
|
128 |
@Autowired
|
| 128 |
private FofoStoreRepository fofoStoreRepository;
|
129 |
private FofoStoreRepository fofoStoreRepository;
|
| 129 |
|
130 |
|
| - |
|
131 |
@Autowired
|
| - |
|
132 |
OrderService orderService;
|
| - |
|
133 |
|
| 130 |
@RequestMapping(value = "/getItemDescription", method = RequestMethod.GET)
|
134 |
@RequestMapping(value = "/getItemDescription", method = RequestMethod.GET)
|
| 131 |
public String getItemDescription(HttpServletRequest request, Model model) throws Throwable {
|
135 |
public String getItemDescription(HttpServletRequest request, Model model) throws Throwable {
|
| 132 |
List<PriceDrop> priceDrops = priceDropRepository.selectAllIncomplete();
|
136 |
List<PriceDrop> priceDrops = priceDropRepository.selectAllIncomplete();
|
| 133 |
Set<Integer> catalogIds = priceDrops.stream().map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
|
137 |
Set<Integer> catalogIds = priceDrops.stream().map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
|
| 134 |
|
138 |
|
| Line 138... |
Line 142... |
| 138 |
model.addAttribute("priceDrops", priceDrops);
|
142 |
model.addAttribute("priceDrops", priceDrops);
|
| 139 |
model.addAttribute("catalogDescription", catalogDescription);
|
143 |
model.addAttribute("catalogDescription", catalogDescription);
|
| 140 |
return "price-drop";
|
144 |
return "price-drop";
|
| 141 |
}
|
145 |
}
|
| 142 |
|
146 |
|
| - |
|
147 |
@RequestMapping(value = "/getPricedropByDate", method = RequestMethod.GET)
|
| - |
|
148 |
public String getItemDescriptionByDate(
|
| - |
|
149 |
HttpServletRequest request,
|
| - |
|
150 |
@RequestParam LocalDateTime startDate,
|
| - |
|
151 |
@RequestParam LocalDateTime endDate,
|
| - |
|
152 |
Model model) throws Throwable {
|
| - |
|
153 |
if (endDate.isAfter(LocalDateTime.now()) || startDate.isAfter(LocalDateTime.now())) {
|
| - |
|
154 |
throw new ProfitMandiBusinessException("startData and end data must if before the today date ", "", "");
|
| - |
|
155 |
}
|
| - |
|
156 |
try {
|
| - |
|
157 |
List<PriceDrop> priceDrops = priceDropRepository.selectAllByDatesBetweenSortByDate(startDate, endDate);
|
| - |
|
158 |
|
| - |
|
159 |
Set<Integer> catalogIds = priceDrops.stream()
|
| - |
|
160 |
.map(PriceDrop::getCatalogItemId)
|
| - |
|
161 |
.collect(Collectors.toSet());
|
| - |
|
162 |
|
| - |
|
163 |
List<Item> items = itemRepository.selectAllByCatalogIds(catalogIds);
|
| - |
|
164 |
Map<Integer, String> catalogDescription = items.stream()
|
| - |
|
165 |
.collect(Collectors.toMap(
|
| - |
|
166 |
Item::getCatalogItemId,
|
| - |
|
167 |
Item::getItemDescriptionNoColor,
|
| - |
|
168 |
(description1, description2) -> description1));
|
| - |
|
169 |
|
| - |
|
170 |
model.addAttribute("priceDrops", priceDrops);
|
| - |
|
171 |
model.addAttribute("catalogDescription", catalogDescription);
|
| - |
|
172 |
|
| - |
|
173 |
return "price-drop-table";
|
| - |
|
174 |
|
| - |
|
175 |
} catch (Exception e) {
|
| - |
|
176 |
e.printStackTrace();
|
| - |
|
177 |
return "price-drop";
|
| - |
|
178 |
}
|
| - |
|
179 |
}
|
| - |
|
180 |
|
| - |
|
181 |
@RequestMapping(value = "/pricedropByDate/download", method = RequestMethod.GET)
|
| - |
|
182 |
public ResponseEntity<?> dowloadItems(HttpServletRequest request, @PathVariable(name = "tagId") @RequestParam LocalDateTime startDate, @RequestParam LocalDateTime endDate)
|
| - |
|
183 |
throws Throwable {
|
| - |
|
184 |
List<PriceDrop> priceDrops = priceDropRepository.selectAllByDatesBetweenSortByDate(startDate, endDate);
|
| - |
|
185 |
Set<Integer> catalogIds = priceDrops.stream().map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
|
| - |
|
186 |
List<Item> items = itemRepository.selectAllByCatalogIds(catalogIds);
|
| - |
|
187 |
Map<Integer, String> catalogDescription = items.stream().collect(Collectors.toMap(x -> x.getCatalogItemId(),
|
| - |
|
188 |
x -> x.getItemDescriptionNoColor(), (description1, description2) -> description1));
|
| - |
|
189 |
|
| - |
|
190 |
List<List<?>> rows = new ArrayList<>();
|
| - |
|
191 |
for (PriceDrop priceDrop : priceDrops) {
|
| - |
|
192 |
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())
|
| - |
|
194 |
));
|
| - |
|
195 |
|
| - |
|
196 |
}
|
| - |
|
197 |
org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
|
| - |
|
198 |
Arrays.asList("Drop Id", "Item Name", "TP", "DP", "Mop", "Price Drop",
|
| - |
|
199 |
"New DP", "Affected On", "Created On"),
|
| - |
|
200 |
rows);
|
| - |
|
201 |
ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, "Price Drop ");
|
| - |
|
202 |
return responseEntity;
|
| - |
|
203 |
}
|
| - |
|
204 |
|
| 143 |
@RequestMapping(value = "/getClosedPricedropItemDescription", method = RequestMethod.GET)
|
205 |
@RequestMapping(value = "/getClosedPricedropItemDescription", method = RequestMethod.GET)
|
| 144 |
public String getClosedPricedropItemDescription(HttpServletRequest request, Model model) throws Throwable {
|
206 |
public String getClosedPricedropItemDescription(HttpServletRequest request, Model model) throws Throwable {
|
| 145 |
List<PriceDrop> priceDrops = priceDropRepository.selectAllComplete();
|
207 |
List<PriceDrop> priceDrops = priceDropRepository.selectAllComplete();
|
| 146 |
int processOn = 1;
|
208 |
int processOn = 1;
|
| 147 |
|
209 |
|