| Line 89... |
Line 89... |
| 89 |
|
89 |
|
| 90 |
@Controller
|
90 |
@Controller
|
| 91 |
@Transactional(rollbackFor = Throwable.class)
|
91 |
@Transactional(rollbackFor = Throwable.class)
|
| 92 |
public class InventoryController {
|
92 |
public class InventoryController {
|
| 93 |
|
93 |
|
| 94 |
private static final Logger LOGGER = LogManager.getLogger(InventoryController.class);
|
94 |
private static final Logger LOGGER = LogManager.getLogger(InventoryController.class);
|
| 95 |
|
95 |
|
| 96 |
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("M/d/yyyy H:m:s");
|
96 |
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("M/d/yyyy H:m:s");
|
| 97 |
|
97 |
|
| 98 |
private static final List<String> imeis = Arrays.asList("351030944216680", "351030944217183", "351030944217886",
|
98 |
private static final List<String> imeis = Arrays.asList("351030944216680", "351030944217183", "351030944217886", "351030944507286", "351081710231270", "351081710238713", "351081710238796", "351081710241279", "351081710244737", "355777112655976");
|
| 99 |
"351030944507286", "351081710231270", "351081710238713", "351081710238796", "351081710241279",
|
- |
|
| 100 |
"351081710244737", "355777112655976");
|
- |
|
| 101 |
|
- |
|
| 102 |
List<EscalationType> esclationType = Arrays.asList(EscalationType.L3, EscalationType.L4);
|
- |
|
| 103 |
|
- |
|
| 104 |
List<String> emails = Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com");
|
- |
|
| 105 |
|
- |
|
| 106 |
@Autowired
|
- |
|
| 107 |
private CookiesProcessor cookiesProcessor;
|
- |
|
| 108 |
|
- |
|
| 109 |
@Autowired
|
- |
|
| 110 |
@Qualifier("fofoInventoryService")
|
- |
|
| 111 |
private InventoryService inventoryService;
|
- |
|
| 112 |
|
- |
|
| 113 |
@Autowired
|
- |
|
| 114 |
TagListingRepository tagListingRepository;
|
- |
|
| 115 |
|
- |
|
| 116 |
@Autowired
|
- |
|
| 117 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
- |
|
| 118 |
|
- |
|
| 119 |
@Autowired
|
- |
|
| 120 |
private TagRankingRepository tagRankingRepository;
|
- |
|
| 121 |
|
- |
|
| 122 |
@Autowired
|
- |
|
| 123 |
private InventoryItemRepository inventoryItemRepository;
|
- |
|
| 124 |
|
- |
|
| 125 |
@Autowired
|
- |
|
| 126 |
private LiveDemoBillingRespository liveDemoBillingRespository;
|
- |
|
| 127 |
|
- |
|
| 128 |
@Autowired
|
- |
|
| 129 |
private ItemRepository itemRepository;
|
- |
|
| 130 |
|
- |
|
| 131 |
@Autowired
|
- |
|
| 132 |
private Gson gson;
|
- |
|
| 133 |
|
- |
|
| 134 |
@Autowired
|
- |
|
| 135 |
private RetailerService retailerService;
|
- |
|
| 136 |
|
- |
|
| 137 |
@Autowired
|
- |
|
| 138 |
private MVCResponseSender mvcResponseSender;
|
- |
|
| 139 |
|
- |
|
| 140 |
@Autowired
|
- |
|
| 141 |
FofoStoreRepository fofoStoreRepository;
|
- |
|
| 142 |
|
- |
|
| 143 |
@Autowired
|
- |
|
| 144 |
private OrderRepository orderRepository;
|
- |
|
| 145 |
|
- |
|
| 146 |
@Autowired
|
- |
|
| 147 |
private NotifyItemRepository notifyItemRepository;
|
- |
|
| 148 |
|
- |
|
| 149 |
@Autowired
|
- |
|
| 150 |
private NotifyColorChangeRepository notifyColorChangeRepository;
|
- |
|
| 151 |
|
- |
|
| 152 |
@Autowired
|
- |
|
| 153 |
private NotifyOrderRespository notifyOrderRespository;
|
- |
|
| 154 |
|
- |
|
| 155 |
@Autowired
|
- |
|
| 156 |
private NotificationService notificationService;
|
- |
|
| 157 |
|
- |
|
| 158 |
@Autowired
|
- |
|
| 159 |
private NotifyMessageRepository notifyMessageRepository;
|
- |
|
| 160 |
|
- |
|
| 161 |
@Autowired
|
- |
|
| 162 |
private UserAccountRepository userAccountRepository;
|
- |
|
| 163 |
|
- |
|
| 164 |
@Autowired
|
- |
|
| 165 |
private OrderService orderService;
|
- |
|
| 166 |
|
- |
|
| 167 |
@Value("${saholic.api.host}")
|
- |
|
| 168 |
private String host;
|
- |
|
| 169 |
|
- |
|
| 170 |
@Value("${saholic.api.port}")
|
- |
|
| 171 |
private int port;
|
- |
|
| 172 |
|
- |
|
| 173 |
@Value("${saholic.api.webapp}")
|
- |
|
| 174 |
private String webapp;
|
- |
|
| 175 |
|
- |
|
| 176 |
@Autowired
|
- |
|
| 177 |
JavaMailSender mailSender;
|
- |
|
| 178 |
|
- |
|
| 179 |
@Autowired
|
- |
|
| 180 |
private NotifyCancelOrderRepository notifyCancelOrderRepository;
|
- |
|
| 181 |
|
- |
|
| 182 |
@Autowired
|
- |
|
| 183 |
private WarehousePurchaseOrderRepository warehousePurchaseOrderRepository;
|
- |
|
| 184 |
|
- |
|
| 185 |
@Autowired
|
- |
|
| 186 |
private WarehouseScanRepository warehouseScanRepository;
|
- |
|
| 187 |
|
- |
|
| 188 |
@Autowired
|
- |
|
| 189 |
private FofoOrderRepository fofoOrderRepository;
|
- |
|
| 190 |
@Autowired
|
- |
|
| 191 |
private Mongo mongoClient;
|
- |
|
| 192 |
|
- |
|
| 193 |
@Autowired
|
- |
|
| 194 |
private FocusedModelByPassRepository focusedModelByPassRepository;
|
- |
|
| 195 |
|
- |
|
| 196 |
@Autowired
|
- |
|
| 197 |
private CsService csService;
|
- |
|
| 198 |
|
- |
|
| 199 |
@Autowired
|
- |
|
| 200 |
AuthRepository authRepository;
|
- |
|
| 201 |
|
- |
|
| 202 |
@Autowired
|
- |
|
| 203 |
PositionRepository positionRepository;
|
- |
|
| 204 |
|
- |
|
| 205 |
@Autowired
|
- |
|
| 206 |
ActivatedImeiRepository activatedImeiRepository;
|
- |
|
| 207 |
|
- |
|
| 208 |
@Autowired
|
- |
|
| 209 |
HighDemandItemsRepository highDemandItemsRepository;
|
- |
|
| 210 |
|
- |
|
| 211 |
@Autowired
|
- |
|
| 212 |
WebOfferRepository webOfferRepository;
|
- |
|
| 213 |
|
- |
|
| 214 |
@Autowired
|
- |
|
| 215 |
ComboModelRepository comboModelRepository;
|
- |
|
| 216 |
|
- |
|
| 217 |
@Autowired
|
- |
|
| 218 |
ComboMappedModelRepository comboMappedModelRepository;
|
- |
|
| 219 |
|
- |
|
| 220 |
@Autowired
|
- |
|
| 221 |
private UserRepository userUserRepository;
|
- |
|
| 222 |
|
- |
|
| 223 |
@Autowired
|
- |
|
| 224 |
private AddressRepository addressRepository;
|
- |
|
| 225 |
|
- |
|
| 226 |
@RequestMapping(value = "/getCurrentInventorySnapshot")
|
- |
|
| 227 |
public String getCurrentAvailability(HttpServletRequest request,
|
- |
|
| 228 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
- |
|
| 229 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
- |
|
| 230 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
- |
|
| 231 |
throws ProfitMandiBusinessException {
|
- |
|
| 232 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 233 |
Map<String, Object> map = inventoryService.getCurrentInventorySnapshot(loginDetails.getFofoId(), offset, limit,
|
- |
|
| 234 |
searchTerm);
|
- |
|
| 235 |
model.addAllAttributes(map);
|
- |
|
| 236 |
return "inventory-snapshot";
|
- |
|
| 237 |
}
|
- |
|
| 238 |
|
- |
|
| 239 |
@RequestMapping(value = "/getBadInventorySnapshot")
|
- |
|
| 240 |
public String getBadAvailability(HttpServletRequest request,
|
- |
|
| 241 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
- |
|
| 242 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
- |
|
| 243 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
- |
|
| 244 |
throws ProfitMandiBusinessException {
|
- |
|
| 245 |
if (searchTerm == null) {
|
- |
|
| 246 |
searchTerm = "";
|
- |
|
| 247 |
}
|
- |
|
| 248 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 249 |
Map<String, Object> map = inventoryService.getBadInventorySnapshot(loginDetails.getFofoId(), offset, limit,
|
- |
|
| 250 |
searchTerm);
|
- |
|
| 251 |
model.addAllAttributes(map);
|
- |
|
| 252 |
return "bad-inventory-snapshot";
|
- |
|
| 253 |
}
|
- |
|
| 254 |
|
- |
|
| 255 |
@RequestMapping(value = "/getPaginatedCurrentInventorySnapshot")
|
- |
|
| 256 |
public String getPaginatedCurrentInventorySnapshot(HttpServletRequest request,
|
- |
|
| 257 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
- |
|
| 258 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
- |
|
| 259 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
- |
|
| 260 |
throws ProfitMandiBusinessException {
|
- |
|
| 261 |
if (searchTerm == null) {
|
- |
|
| 262 |
searchTerm = "";
|
- |
|
| 263 |
}
|
- |
|
| 264 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 265 |
Map<String, Object> map = inventoryService.getPaginatedCurrentInventorySnapshot(loginDetails.getFofoId(),
|
- |
|
| 266 |
offset, limit, searchTerm);
|
- |
|
| 267 |
model.addAllAttributes(map);
|
- |
|
| 268 |
return "inventory-snapshot-paginated";
|
- |
|
| 269 |
}
|
- |
|
| 270 |
|
- |
|
| 271 |
@RequestMapping(value = "/getCatalog")
|
- |
|
| 272 |
public String getCatalog(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset,
|
- |
|
| 273 |
@RequestParam(name = "limit", defaultValue = "20") int limit,
|
- |
|
| 274 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm,
|
- |
|
| 275 |
@RequestParam(name = "itemId", required = false, defaultValue = "0") int itemId,
|
- |
|
| 276 |
@RequestParam(name = "accesories", required = false, defaultValue = "0") boolean accesories,
|
- |
|
| 277 |
|
- |
|
| 278 |
@RequestParam(name = "brand", required = false, defaultValue = "") String brand, Model model)
|
- |
|
| 279 |
|
- |
|
| 280 |
throws ProfitMandiBusinessException {
|
- |
|
| 281 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 282 |
if (searchTerm == null) {
|
- |
|
| 283 |
searchTerm = "";
|
- |
|
| 284 |
}
|
- |
|
| 285 |
|
- |
|
| 286 |
Map<String, Object> map = inventoryService.getCatalog(loginDetails.getFofoId(), offset, limit, searchTerm,
|
- |
|
| 287 |
itemId, brand, accesories);
|
- |
|
| 288 |
model.addAllAttributes(map);
|
- |
|
| 289 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
- |
|
| 290 |
|
- |
|
| 291 |
return "catalog";
|
- |
|
| 292 |
}
|
- |
|
| 293 |
|
- |
|
| 294 |
@RequestMapping(value = "/getWebOfferByCatalogId")
|
- |
|
| 295 |
public String getCatalog(HttpServletRequest request, @RequestParam int catalogItemId, Model model)
|
- |
|
| 296 |
|
- |
|
| 297 |
throws ProfitMandiBusinessException {
|
- |
|
| 298 |
|
- |
|
| 299 |
List<WebOffer> webOffers = webOfferRepository.selectAllActiveOffers().get(catalogItemId);
|
- |
|
| 300 |
|
- |
|
| 301 |
model.addAttribute("webOffers", webOffers);
|
- |
|
| 302 |
|
- |
|
| 303 |
return "web-offer-model";
|
- |
|
| 304 |
}
|
- |
|
| 305 |
|
- |
|
| 306 |
// This method is currently hardcoded to faciliate watches sold as gift.
|
- |
|
| 307 |
private boolean hasGift(int fofoId) {
|
- |
|
| 308 |
try {
|
- |
|
| 309 |
return currentInventorySnapshotRepository.selectByItemIdAndFofoId(ProfitMandiConstants.GIFT_ID, fofoId)
|
- |
|
| 310 |
.getAvailability() > 0;
|
- |
|
| 311 |
} catch (ProfitMandiBusinessException e) {
|
- |
|
| 312 |
return false;
|
- |
|
| 313 |
}
|
- |
|
| 314 |
}
|
- |
|
| 315 |
|
- |
|
| 316 |
@RequestMapping(value = "/getPaginatedCatalog")
|
- |
|
| 317 |
public String getCatalogPaginated(HttpServletRequest request,
|
- |
|
| 318 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
- |
|
| 319 |
@RequestParam(name = "limit", defaultValue = "20") int limit,
|
- |
|
| 320 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm,
|
- |
|
| 321 |
@RequestParam(name = "itemId", required = false, defaultValue = "0") int itemId,
|
- |
|
| 322 |
@RequestParam(name = "accesories", required = false, defaultValue = "0") boolean accesories,
|
- |
|
| 323 |
@RequestParam(name = "brand", required = false, defaultValue = "") String brand, Model model)
|
- |
|
| 324 |
throws ProfitMandiBusinessException {
|
- |
|
| 325 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 326 |
if (searchTerm == null) {
|
- |
|
| 327 |
searchTerm = "";
|
- |
|
| 328 |
}
|
- |
|
| 329 |
Map<String, Object> map = inventoryService.getPaginatedCatalog(loginDetails.getFofoId(), offset, limit,
|
- |
|
| 330 |
searchTerm, itemId, brand, accesories);
|
- |
|
| 331 |
model.addAllAttributes(map);
|
- |
|
| 332 |
return "catalog-paginated";
|
- |
|
| 333 |
}
|
- |
|
| 334 |
|
- |
|
| 335 |
@RequestMapping(value = "/checkItemAvailability")
|
- |
|
| 336 |
public String getItemAvailability(HttpServletRequest request,
|
- |
|
| 337 |
@RequestParam(name = ProfitMandiConstants.ITEM_ID) int itemId, Model model)
|
- |
|
| 338 |
throws ProfitMandiBusinessException {
|
- |
|
| 339 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 340 |
CustomCurrentInventorySnapshot customCurrentInventorySnapshot = inventoryService.checkItemAvailability(itemId,
|
- |
|
| 341 |
loginDetails.getFofoId());
|
- |
|
| 342 |
/*
|
- |
|
| 343 |
* customCurrentInventorySnapshot
|
- |
|
| 344 |
* .setIconUrl(Utils.getIconUrl(customCurrentInventorySnapshot.getCatalogItemId(
|
- |
|
| 345 |
* ), host, port, webapp));
|
- |
|
| 346 |
*/
|
- |
|
| 347 |
model.addAttribute("currentInventorySnapshot", new Gson().toJson(customCurrentInventorySnapshot));
|
- |
|
| 348 |
return "current-item-availability";
|
- |
|
| 349 |
|
- |
|
| 350 |
}
|
- |
|
| 351 |
|
- |
|
| 352 |
@RequestMapping(value = "/cart", method = RequestMethod.POST)
|
- |
|
| 353 |
public String addToCart(HttpServletRequest request, @RequestParam(name = "cartData") String cartData, Model model)
|
- |
|
| 354 |
throws ProfitMandiBusinessException {
|
- |
|
| 355 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 356 |
|
- |
|
| 357 |
Map<String, Object> map = inventoryService.addToCart(cartData, loginDetails.getFofoId());
|
- |
|
| 358 |
model.addAllAttributes(map);
|
- |
|
| 359 |
return "cart";
|
- |
|
| 360 |
}
|
- |
|
| 361 |
|
- |
|
| 362 |
@RequestMapping(value = "/validate-cart", method = RequestMethod.POST)
|
- |
|
| 363 |
public String validateCart(HttpServletRequest request, HttpServletResponse response,
|
- |
|
| 364 |
@RequestParam(name = "cartData") String cartData, Model model) throws ProfitMandiBusinessException {
|
- |
|
| 365 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 366 |
|
- |
|
| 367 |
Map<String, Object> map = inventoryService.validateCart(cartData, loginDetails.getFofoId());
|
- |
|
| 368 |
model.addAllAttributes(map);
|
- |
|
| 369 |
return "validate-cart";
|
- |
|
| 370 |
}
|
- |
|
| 371 |
|
- |
|
| 372 |
@RequestMapping(value = "/grnHistory")
|
- |
|
| 373 |
public String getGrnHistory(HttpServletRequest request, @RequestParam(required = false) LocalDateTime startTime,
|
- |
|
| 374 |
@RequestParam(required = false) LocalDateTime endTime,
|
- |
|
| 375 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
- |
|
| 376 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
- |
|
| 377 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE, defaultValue = "") String purchaseReference,
|
- |
|
| 378 |
@RequestParam(name = "searchType", defaultValue = "") String searchType, Model model)
|
- |
|
| 379 |
throws ProfitMandiBusinessException {
|
- |
|
| 380 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 381 |
Map<String, Object> map = inventoryService.getGrnHistory(loginDetails.getFofoId(), startTime, endTime, offset,
|
- |
|
| 382 |
limit, purchaseReference, searchType);
|
- |
|
| 383 |
model.addAllAttributes(map);
|
- |
|
| 384 |
return "grn-history";
|
- |
|
| 385 |
}
|
- |
|
| 386 |
|
- |
|
| 387 |
@RequestMapping(value = "/downloadPurchaseInvoices")
|
- |
|
| 388 |
public ResponseEntity<?> downloadPurchaseInvoices(HttpServletRequest request,
|
- |
|
| 389 |
@RequestParam(required = false) LocalDateTime startTime,
|
- |
|
| 390 |
@RequestParam(required = false) LocalDateTime endTime,
|
- |
|
| 391 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
- |
|
| 392 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
- |
|
| 393 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE, defaultValue = "") String purchaseReference,
|
- |
|
| 394 |
@RequestParam(name = "searchType", defaultValue = "") String searchType, Model model)
|
- |
|
| 395 |
throws ProfitMandiBusinessException {
|
- |
|
| 396 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 397 |
Map<String, Object> map = inventoryService.getGrnHistory(loginDetails.getFofoId(), startTime, endTime, offset,
|
- |
|
| 398 |
limit, purchaseReference, searchType);
|
- |
|
| 399 |
|
- |
|
| 400 |
List<FofoOrder> fofoOrders = (List<FofoOrder>) map.get("saleHistories");
|
- |
|
| 401 |
|
- |
|
| 402 |
if (fofoOrders.size() == 0) {
|
- |
|
| 403 |
throw new ProfitMandiBusinessException("Search criteria", "", "No orders found for criteria");
|
- |
|
| 404 |
}
|
- |
|
| 405 |
|
- |
|
| 406 |
final HttpHeaders headers = new HttpHeaders();
|
- |
|
| 407 |
headers.setContentType(MediaType.APPLICATION_PDF);
|
- |
|
| 408 |
headers.set("Content-disposition", "inline; filename=invoices.pdf");
|
- |
|
| 409 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
- |
|
| 410 |
List<InvoicePdfModel> pdfModels = new ArrayList<>();
|
- |
|
| 411 |
PdfUtils.generateAndWrite(pdfModels, byteArrayOutputStream);
|
- |
|
| 412 |
headers.setContentLength(byteArrayOutputStream.toByteArray().length);
|
- |
|
| 413 |
final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
- |
|
| 414 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
- |
|
| 415 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
- |
|
| 416 |
}
|
- |
|
| 417 |
|
- |
|
| 418 |
@RequestMapping(value = "/getPaginatedGrnHistory")
|
- |
|
| 419 |
public String getPaginatedGrnHistory(HttpServletRequest request,
|
- |
|
| 420 |
@RequestParam(required = false) LocalDateTime startTime,
|
- |
|
| 421 |
@RequestParam(required = false) LocalDateTime endTime,
|
- |
|
| 422 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
- |
|
| 423 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
- |
|
| 424 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE, defaultValue = "") String purchaseReference,
|
- |
|
| 425 |
@RequestParam(name = "searchType", defaultValue = "") String searchType, Model model)
|
- |
|
| 426 |
throws ProfitMandiBusinessException {
|
- |
|
| 427 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 428 |
Map<String, Object> map = inventoryService.getPaginatedGrnHistory(loginDetails.getFofoId(), startTime, endTime,
|
- |
|
| 429 |
offset, limit);
|
- |
|
| 430 |
model.addAllAttributes(map);
|
- |
|
| 431 |
return "grn-history-paginated";
|
- |
|
| 432 |
}
|
- |
|
| 433 |
|
- |
|
| 434 |
@RequestMapping(value = "/grnHistoryDetailByPurchaseId")
|
- |
|
| 435 |
public String grnHistoryByPurchaseId(HttpServletRequest request,
|
- |
|
| 436 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_ID) int purchaseId, Model model)
|
- |
|
| 437 |
throws ProfitMandiBusinessException {
|
- |
|
| 438 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 439 |
Map<String, Object> map = inventoryService.getGrnHistoryDetail(loginDetails.getFofoId(), purchaseId, host, port,
|
- |
|
| 440 |
webapp);
|
- |
|
| 441 |
model.addAllAttributes(map);
|
- |
|
| 442 |
return "grn-details";
|
- |
|
| 443 |
}
|
- |
|
| 444 |
|
- |
|
| 445 |
@RequestMapping(value = "/grnHistoryDetailByPurchaseReference")
|
- |
|
| 446 |
public String grnHistoryByPurchaseReference(HttpServletRequest request,
|
- |
|
| 447 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE) String purchaseReference, Model model)
|
- |
|
| 448 |
throws ProfitMandiBusinessException {
|
- |
|
| 449 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 450 |
Map<String, Object> map = inventoryService.getGrnHistoryDetail(loginDetails.getFofoId(), purchaseReference,
|
- |
|
| 451 |
host, port, webapp);
|
- |
|
| 452 |
model.addAllAttributes(map);
|
- |
|
| 453 |
return "grn-details";
|
- |
|
| 454 |
}
|
- |
|
| 455 |
|
- |
|
| 456 |
@RequestMapping(value = "/activatedImeis")
|
- |
|
| 457 |
public String activatedImeis(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
- |
|
| 458 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 459 |
|
- |
|
| 460 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByActivatedNotSold(loginDetails.getFofoId());
|
- |
|
| 461 |
inventoryItems.stream().forEach(x -> {
|
- |
|
| 462 |
try {
|
- |
|
| 463 |
x.setItem(itemRepository.selectById(x.getItemId()));
|
- |
|
| 464 |
} catch (Exception e) {
|
- |
|
| 465 |
e.printStackTrace();
|
- |
|
| 466 |
}
|
- |
|
| 467 |
});
|
- |
|
| 468 |
model.addAttribute("inventoryItems", inventoryItems);
|
- |
|
| 469 |
return "activated-imeis";
|
- |
|
| 470 |
}
|
- |
|
| 471 |
|
- |
|
| 472 |
@RequestMapping(value = "/activated-imeis-grn-pending")
|
- |
|
| 473 |
public String activatedImeisGrnPending(HttpServletRequest request, Model model)
|
- |
|
| 474 |
throws ProfitMandiBusinessException {
|
- |
|
| 475 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 476 |
|
- |
|
| 477 |
List<Order> openOrders = orderRepository.selectGrnTimestampNull(loginDetails.getFofoId(),
|
- |
|
| 478 |
Arrays.asList(OrderStatus.SHIPPED_FROM_WH, OrderStatus.DELIVERY_SUCCESS));
|
- |
|
| 479 |
List<ImeiActivationTimestampModel> imeiActivationTimestampModels = activatedImeiRepository
|
- |
|
| 480 |
.selectActivatedImeisByOrders(openOrders.stream().map(x -> x.getId()).collect(Collectors.toList()));
|
- |
|
| 481 |
Map<Integer, Order> ordersMap = openOrders.stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
- |
|
| 482 |
model.addAttribute("ordersMap", ordersMap);
|
- |
|
| 483 |
model.addAttribute("imeiActivationTimestampModels", imeiActivationTimestampModels);
|
- |
|
| 484 |
return "activated-imeis-grn-pending";
|
- |
|
| 485 |
}
|
- |
|
| 486 |
|
- |
|
| 487 |
@RequestMapping(value = "/view-invoices")
|
- |
|
| 488 |
public String viewInvoices(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
- |
|
| 489 |
return "view-dummy-invoices";
|
- |
|
| 490 |
}
|
- |
|
| 491 |
|
- |
|
| 492 |
@RequestMapping(value = "/dummy-invoices")
|
- |
|
| 493 |
public ResponseEntity<?> downloadInvoices(HttpServletRequest request, @RequestParam String serialNumber,
|
- |
|
| 494 |
Model model) throws ProfitMandiBusinessException {
|
- |
|
| 495 |
byte[] bytes = null;
|
- |
|
| 496 |
if (!imeis.contains(serialNumber)) {
|
- |
|
| 497 |
|
- |
|
| 498 |
InvoicePdfModel pdfModel = orderService.getDummyPdfModel(serialNumber);
|
- |
|
| 499 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
- |
|
| 500 |
PdfUtils.generateAndWrite(Arrays.asList(pdfModel), byteArrayOutputStream);
|
- |
|
| 501 |
bytes = byteArrayOutputStream.toByteArray();
|
- |
|
| 502 |
} else {
|
- |
|
| 503 |
ClassPathResource resource = new ClassPathResource("/META-INF/" + serialNumber + ".pdf");
|
- |
|
| 504 |
try {
|
- |
|
| 505 |
bytes = FileUtils.readFileToByteArray(resource.getFile());
|
- |
|
| 506 |
} catch (Exception e) {
|
- |
|
| 507 |
|
- |
|
| 508 |
}
|
- |
|
| 509 |
}
|
- |
|
| 510 |
final HttpHeaders headers = new HttpHeaders();
|
- |
|
| 511 |
headers.setContentType(MediaType.APPLICATION_PDF);
|
- |
|
| 512 |
headers.set("Content-disposition", "inline; filename=invoice-" + serialNumber + ".pdf");
|
- |
|
| 513 |
headers.setContentLength(bytes.length);
|
- |
|
| 514 |
final InputStream inputStream = new ByteArrayInputStream(bytes);
|
- |
|
| 515 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
- |
|
| 516 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
- |
|
| 517 |
}
|
- |
|
| 518 |
|
- |
|
| 519 |
@RequestMapping(value = "/dummy-invoices-bulk")
|
- |
|
| 520 |
public ResponseEntity<?> downloadInvoicesBulk(HttpServletRequest request, @RequestParam List<String> serialNumbers,
|
- |
|
| 521 |
Model model) throws Exception {
|
- |
|
| 522 |
byte[] bytes = null;
|
- |
|
| 523 |
List<Attachment> attachments = new ArrayList<>();
|
- |
|
| 524 |
for (String serialNumber : serialNumbers) {
|
- |
|
| 525 |
if (!imeis.contains(serialNumber)) {
|
- |
|
| 526 |
InvoicePdfModel pdfModel = null;
|
- |
|
| 527 |
try {
|
- |
|
| 528 |
pdfModel = orderService.getDummyPdfModel(serialNumber);
|
- |
|
| 529 |
} catch (Exception e) {
|
- |
|
| 530 |
continue;
|
- |
|
| 531 |
}
|
- |
|
| 532 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
- |
|
| 533 |
PdfUtils.generateAndWrite(Arrays.asList(pdfModel), byteArrayOutputStream);
|
- |
|
| 534 |
bytes = byteArrayOutputStream.toByteArray();
|
- |
|
| 535 |
} else {
|
- |
|
| 536 |
ClassPathResource resource = new ClassPathResource("/META-INF/" + serialNumber + ".pdf");
|
- |
|
| 537 |
try {
|
- |
|
| 538 |
bytes = FileUtils.readFileToByteArray(resource.getFile());
|
- |
|
| 539 |
} catch (Exception e) {
|
- |
|
| 540 |
continue;
|
- |
|
| 541 |
}
|
- |
|
| 542 |
}
|
- |
|
| 543 |
attachments.add(new Attachment("invoice-" + serialNumber + ".pdf", new ByteArrayResource(bytes)));
|
- |
|
| 544 |
}
|
- |
|
| 545 |
|
- |
|
| 546 |
Utils.sendMailWithAttachments(mailSender, new String[] { "kuldeep.kumar@smartdukaan.com" }, null,
|
- |
|
| 547 |
"Invoices List", "PFA", attachments.toArray(new Attachment[attachments.size()]));
|
- |
|
| 548 |
return new ResponseEntity<Boolean>(true, HttpStatus.OK);
|
- |
|
| 549 |
}
|
- |
|
| 550 |
|
- |
|
| 551 |
@RequestMapping(value = "/getInventoryItemAgingByInterval", method = RequestMethod.POST)
|
- |
|
| 552 |
public String getInventoryItemAgingByInterval(HttpServletRequest request, @RequestBody List<Integer> intervals,
|
- |
|
| 553 |
Model model, @RequestParam(name = "searchContent", defaultValue = "") String searchContent,
|
- |
|
| 554 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
- |
|
| 555 |
@RequestParam(name = "limit", defaultValue = "10") int limit) throws ProfitMandiBusinessException {
|
- |
|
| 556 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 557 |
Map<String, Object> map = inventoryService.getPaginatedItemAgingByInterval(loginDetails.getFofoId(), intervals,
|
- |
|
| 558 |
searchContent, offset, limit);
|
- |
|
| 559 |
model.addAllAttributes(map);
|
- |
|
| 560 |
return "item-aging";
|
- |
|
| 561 |
}
|
- |
|
| 562 |
|
- |
|
| 563 |
@RequestMapping(value = "/downloadInventoryItemAgingByInterval", method = RequestMethod.POST)
|
- |
|
| 564 |
public ResponseEntity<?> downloadInventoryItemAgingByInterval(HttpServletRequest request,
|
- |
|
| 565 |
@RequestBody List<Integer> intervals, Model model) throws ProfitMandiBusinessException {
|
- |
|
| 566 |
LOGGER.info("Request received at url{} with body {}", request.getRequestURI(), intervals);
|
- |
|
| 567 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 568 |
|
- |
|
| 569 |
List<InventoryItemAgingModel> inventoryItemAgingModels = inventoryService
|
- |
|
| 570 |
.getItemAgingByInterval(fofoDetails.getFofoId(), intervals);
|
- |
|
| 571 |
|
- |
|
| 572 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
- |
|
| 573 |
ExcelUtils.writeInventoryItemAgingModels(inventoryItemAgingModels, intervals, byteArrayOutputStream);
|
- |
|
| 574 |
|
- |
|
| 575 |
final HttpHeaders headers = new HttpHeaders();
|
- |
|
| 576 |
// private static final String CONTENT_TYPE_XLSX =
|
- |
|
| 577 |
// "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
- |
|
| 578 |
headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
- |
|
| 579 |
// headers.set("Content-Type", "application/vnd.ms-excel");
|
- |
|
| 580 |
headers.set("Content-disposition", "inline; filename=InventoryItemAging.xlsx");
|
- |
|
| 581 |
headers.setContentLength(byteArrayOutputStream.toByteArray().length);
|
- |
|
| 582 |
final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
- |
|
| 583 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
- |
|
| 584 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
- |
|
| 585 |
}
|
- |
|
| 586 |
|
- |
|
| 587 |
@RequestMapping(value = "/aging-report", method = RequestMethod.GET)
|
- |
|
| 588 |
public ResponseEntity<?> downloadInventoryItemAgingByInterval(HttpServletRequest request)
|
- |
|
| 589 |
throws ProfitMandiBusinessException {
|
- |
|
| 590 |
|
- |
|
| 591 |
List<Integer> intervals = Arrays.asList(5, 15, 30, 45);
|
- |
|
| 592 |
List<InventoryItemAgingModel> inventoryItemAgingModels = inventoryService.getItemAgingByInterval(intervals)
|
- |
|
| 593 |
.values().stream().flatMap(Collection::stream).collect(Collectors.toList());
|
- |
|
| 594 |
LOGGER.info("Fofo Id {}", inventoryItemAgingModels.get(0).getFofoId());
|
- |
|
| 595 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
- |
|
| 596 |
ExcelUtils.writeInventoryItemAgingModels(inventoryItemAgingModels, intervals, byteArrayOutputStream);
|
- |
|
| 597 |
|
- |
|
| 598 |
final HttpHeaders headers = new HttpHeaders();
|
- |
|
| 599 |
// private static final String CONTENT_TYPE_XLSX =
|
- |
|
| 600 |
// "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
- |
|
| 601 |
headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
- |
|
| 602 |
// headers.set("Content-Type", "application/vnd.ms-excel");
|
- |
|
| 603 |
headers.set("Content-disposition", "inline; filename=InventoryItemAging.xlsx");
|
- |
|
| 604 |
headers.setContentLength(byteArrayOutputStream.toByteArray().length);
|
- |
|
| 605 |
final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
- |
|
| 606 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
- |
|
| 607 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
- |
|
| 608 |
}
|
- |
|
| 609 |
|
- |
|
| 610 |
@RequestMapping(value = "/featurePanel", method = RequestMethod.GET)
|
- |
|
| 611 |
public String FeaturePanel(HttpServletRequest request, Model model) throws Exception {
|
- |
|
| 612 |
|
- |
|
| 613 |
List<TagRanking> tagRanking = null;
|
- |
|
| 614 |
tagRanking = tagRankingRepository.getAllTagRanking();
|
- |
|
| 615 |
LOGGER.info("tagRanking" + tagRanking);
|
- |
|
| 616 |
if (!tagRanking.isEmpty()) {
|
- |
|
| 617 |
Set<Integer> catalogIds = tagRanking.stream().map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
|
- |
|
| 618 |
List<Item> items = itemRepository.selectAllByCatalogIds(catalogIds);
|
- |
|
| 619 |
Map<Integer, String> catalogDescription = items.stream().collect(Collectors.toMap(x -> x.getCatalogItemId(),
|
- |
|
| 620 |
x -> x.getItemDescription(), (description1, description2) -> description1));
|
- |
|
| 621 |
|
- |
|
| 622 |
LOGGER.info("catalogDescription" + catalogDescription);
|
- |
|
| 623 |
model.addAttribute("tagRanking", tagRanking);
|
- |
|
| 624 |
model.addAttribute("catalogDescription", catalogDescription);
|
- |
|
| 625 |
|
- |
|
| 626 |
} else {
|
- |
|
| 627 |
model.addAttribute("tagRanking", tagRanking);
|
- |
|
| 628 |
|
- |
|
| 629 |
}
|
- |
|
| 630 |
|
- |
|
| 631 |
return "feature";
|
- |
|
| 632 |
|
- |
|
| 633 |
}
|
- |
|
| 634 |
|
- |
|
| 635 |
@PostMapping(value = "/imei/upload")
|
- |
|
| 636 |
public String uploadContent(HttpServletRequest request, @RequestPart("file") MultipartFile file, Model model)
|
- |
|
| 637 |
throws Exception {
|
- |
|
| 638 |
/*
|
- |
|
| 639 |
* if(brand==null) { throw new
|
- |
|
| 640 |
* ProfitMandiBusinessException("Please select brand", "Brand empty",
|
- |
|
| 641 |
* "Brand required"); }
|
- |
|
| 642 |
*/
|
- |
|
| 643 |
List<CSVRecord> masterDataList = readFile(file);
|
- |
|
| 644 |
|
- |
|
| 645 |
Map<String, LocalDateTime> imeisActivationMap = masterDataList.stream()
|
- |
|
| 646 |
.collect(Collectors.toMap(x -> x.get(0).trim(), x -> {
|
- |
|
| 647 |
if (!StringUtils.isEmpty(x.get(1).trim())) {
|
- |
|
| 648 |
return LocalDateTime.parse((String) (x.get(1).trim()), formatter);
|
- |
|
| 649 |
} else {
|
- |
|
| 650 |
return null;
|
- |
|
| 651 |
}
|
- |
|
| 652 |
}));
|
- |
|
| 653 |
inventoryService.addActivatedImeis(imeisActivationMap);
|
- |
|
| 654 |
model.addAttribute("response1", true);
|
- |
|
| 655 |
return "response";
|
- |
|
| 656 |
}
|
- |
|
| 657 |
|
- |
|
| 658 |
private List<CSVRecord> readFile(MultipartFile file) throws Exception {
|
- |
|
| 659 |
List<CSVRecord> records = null;
|
- |
|
| 660 |
try (CSVParser parser = new CSVParser(new InputStreamReader(file.getInputStream()), CSVFormat.DEFAULT)) {
|
- |
|
| 661 |
records = parser.getRecords();
|
- |
|
| 662 |
if (records.size() < 2) {
|
- |
|
| 663 |
throw new ProfitMandiBusinessException("Uploaded File", "", "No records Found");
|
- |
|
| 664 |
}
|
- |
|
| 665 |
records.remove(0);
|
- |
|
| 666 |
} catch (Exception e) {
|
- |
|
| 667 |
throw new ProfitMandiBusinessException("Parsing Failed", "parse failed", "file parse failed");
|
- |
|
| 668 |
}
|
- |
|
| 669 |
return records;
|
- |
|
| 670 |
}
|
- |
|
| 671 |
|
- |
|
| 672 |
@RequestMapping(value = "/itemfeature", method = RequestMethod.POST)
|
- |
|
| 673 |
public String Itemfeature(HttpServletRequest request, @RequestBody ItemFeatureDataModel itemFeatureDatatModel,
|
- |
|
| 674 |
Model model) throws Exception {
|
- |
|
| 675 |
TagRanking tagRanking = tagRankingRepository.selectBycatalogItemId(itemFeatureDatatModel.getCatalogItemId());
|
- |
|
| 676 |
LOGGER.info("tagRanking" + tagRanking);
|
- |
|
| 677 |
if (tagRanking == null) {
|
- |
|
| 678 |
tagRanking = new TagRanking();
|
- |
|
| 679 |
tagRanking.setCatalogItemId(itemFeatureDatatModel.getCatalogItemId());
|
- |
|
| 680 |
}
|
- |
|
| 681 |
tagRanking.setFeature(itemFeatureDatatModel.getFeature());
|
- |
|
| 682 |
tagRanking.setRankPoints(itemFeatureDatatModel.getRankPoints());
|
- |
|
| 683 |
|
- |
|
| 684 |
tagRankingRepository.persist(tagRanking);
|
- |
|
| 685 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
- |
|
| 686 |
return "response";
|
- |
|
| 687 |
}
|
- |
|
| 688 |
|
- |
|
| 689 |
@RequestMapping(value = "/removeFeature", method = RequestMethod.DELETE)
|
- |
|
| 690 |
public String removeTagRankingEnteries(HttpServletRequest request,
|
- |
|
| 691 |
@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
- |
|
| 692 |
|
- |
|
| 693 |
tagRankingRepository.deleteById(id);
|
- |
|
| 694 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
- |
|
| 695 |
return "response";
|
- |
|
| 696 |
}
|
- |
|
| 697 |
|
- |
|
| 698 |
@RequestMapping(value = "/getDemolistbyfofoId", method = RequestMethod.GET)
|
- |
|
| 699 |
public String DemoListbyFofoId(HttpServletRequest request,
|
- |
|
| 700 |
@RequestParam(required = false, defaultValue = "0") int fofoId, Model model) throws Exception {
|
- |
|
| 701 |
|
- |
|
| 702 |
List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().map(x -> x.getId())
|
- |
|
| 703 |
.collect(Collectors.toList());
|
- |
|
| 704 |
|
- |
|
| 705 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
- |
|
| 706 |
Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> customRetailerMap.get(x))
|
- |
|
| 707 |
.filter(x -> x != null).collect(Collectors.toList()).stream()
|
- |
|
| 708 |
.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
- |
|
| 709 |
String customRetailers = JSONObject.valueToString(customRetailersMap.values());
|
- |
|
| 710 |
List<String> serailNumberList = liveDemoBillingRespository.selectAllSerialNumber();
|
- |
|
| 711 |
LOGGER.info("serailNumberList" + serailNumberList);
|
- |
|
| 712 |
List<InventoryItem> inventoryItem = null;
|
- |
|
| 713 |
List<InventoryItem> inventoryItem1 = new ArrayList<>();
|
- |
|
| 714 |
if (fofoId > 0) {
|
- |
|
| 715 |
List<Item> items = itemRepository.selectAllByBrand("Live Demo");
|
- |
|
| 716 |
Set<Integer> itemIds = new HashSet<>();
|
- |
|
| 717 |
for (Item Item : items) {
|
- |
|
| 718 |
itemIds.add(Item.getId());
|
- |
|
| 719 |
}
|
- |
|
| 720 |
inventoryItem = inventoryItemRepository.selectByFofoIdItemIds(fofoId, itemIds);
|
- |
|
| 721 |
|
- |
|
| 722 |
Set<String> serial = new HashSet<>();
|
- |
|
| 723 |
for (InventoryItem invItem : inventoryItem) {
|
- |
|
| 724 |
if (!serailNumberList.contains(invItem.getSerialNumber())) {
|
- |
|
| 725 |
inventoryItem1.add(invItem);
|
- |
|
| 726 |
|
- |
|
| 727 |
}
|
- |
|
| 728 |
|
- |
|
| 729 |
}
|
- |
|
| 730 |
|
- |
|
| 731 |
LOGGER.info("inventoyItem" + inventoryItem1);
|
- |
|
| 732 |
model.addAttribute("customRetailers", customRetailers);
|
- |
|
| 733 |
|
- |
|
| 734 |
model.addAttribute("liveDemo", inventoryItem1);
|
- |
|
| 735 |
CustomRetailer fofoIdsAndRetailerName = retailerService.getFofoRetailer(fofoId);
|
- |
|
| 736 |
|
- |
|
| 737 |
model.addAttribute("fofoIdsAndRetailerName", fofoIdsAndRetailerName);
|
- |
|
| 738 |
|
- |
|
| 739 |
}
|
- |
|
| 740 |
|
- |
|
| 741 |
else {
|
- |
|
| 742 |
model.addAttribute("customRetailers", customRetailers);
|
- |
|
| 743 |
model.addAttribute("liveDemo", inventoryItem1);
|
- |
|
| 744 |
}
|
- |
|
| 745 |
|
- |
|
| 746 |
return "live_demo_billing";
|
- |
|
| 747 |
|
- |
|
| 748 |
}
|
- |
|
| 749 |
|
- |
|
| 750 |
@RequestMapping(value = "/enableliveDemoSerailNumber", method = RequestMethod.POST)
|
- |
|
| 751 |
public String EnableliveDemoSerailNumber(HttpServletRequest request, @RequestParam String serial_number,
|
- |
|
| 752 |
Model model) throws Exception {
|
- |
|
| 753 |
|
- |
|
| 754 |
LiveDemoSerialNumber liveDemoSerialNumber = new LiveDemoSerialNumber();
|
- |
|
| 755 |
liveDemoSerialNumber.setSerialNumber(serial_number);
|
- |
|
| 756 |
|
- |
|
| 757 |
liveDemoBillingRespository.persist(liveDemoSerialNumber);
|
- |
|
| 758 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
- |
|
| 759 |
return "response";
|
- |
|
| 760 |
}
|
- |
|
| 761 |
|
- |
|
| 762 |
@RequestMapping(value = "/getInProcessOrder", method = RequestMethod.GET)
|
- |
|
| 763 |
public String getInProcessOrder(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
- |
|
| 764 |
|
- |
|
| 765 |
List<com.spice.profitmandi.dao.entity.transaction.Order> inProcessorder = orderRepository
|
- |
|
| 766 |
.selectAllOrder(OrderStatus.SUBMITTED_FOR_PROCESSING);
|
- |
|
| 767 |
List<Integer> retailerIds = new ArrayList<>();
|
- |
|
| 768 |
List<Integer> orderIds = new ArrayList<>();
|
- |
|
| 769 |
if (!inProcessorder.isEmpty()) {
|
- |
|
| 770 |
for (com.spice.profitmandi.dao.entity.transaction.Order order : inProcessorder) {
|
- |
|
| 771 |
retailerIds.add(order.getRetailerId());
|
- |
|
| 772 |
orderIds.add(order.getId());
|
- |
|
| 773 |
|
- |
|
| 774 |
}
|
- |
|
| 775 |
|
- |
|
| 776 |
List<NotifyOrder> notify = notifyOrderRespository.selectByorderIds(orderIds);
|
- |
|
| 777 |
for (NotifyOrder notifyOrder : notify) {
|
- |
|
| 778 |
|
- |
|
| 779 |
Order orderdetail = orderRepository.selectById(notifyOrder.getOrderId());
|
- |
|
| 780 |
if (!orderdetail.getStatus().equals(OrderStatus.SUBMITTED_FOR_PROCESSING)) {
|
- |
|
| 781 |
notifyOrder.setStatus(NotifyStatus.rejected);
|
- |
|
| 782 |
}
|
- |
|
| 783 |
}
|
- |
|
| 784 |
|
- |
|
| 785 |
Map<Integer, Optional<NotifyOrder>> notifyOrders = notifyOrderRespository.selectByorderIds(orderIds)
|
- |
|
| 786 |
.stream().collect(Collectors.groupingBy(NotifyOrder::getOrderId,
|
- |
|
| 787 |
Collectors.maxBy((x1, x2) -> x1.getId() - x2.getId())));
|
- |
|
| 788 |
|
- |
|
| 789 |
Map<Integer, NotifyCancel> notifyCancelOrders = notifyCancelOrderRepository.selectByOrderIds(orderIds)
|
- |
|
| 790 |
.stream().collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
|
- |
|
| 791 |
Map<Integer, String> storeIdAndFofoIdMap = fofoStoreRepository.selectByRetailerIds(retailerIds).stream()
|
- |
|
| 792 |
.collect(Collectors.toMap(FofoStore::getId, FofoStore::getCode));
|
- |
|
| 793 |
|
- |
|
| 794 |
model.addAttribute("inProcessorder", inProcessorder);
|
- |
|
| 795 |
model.addAttribute("storeIdAndFofoIdMap", storeIdAndFofoIdMap);
|
- |
|
| 796 |
model.addAttribute("latestNotifyOrders", notifyOrders);
|
- |
|
| 797 |
model.addAttribute("notifyCancelOrders", notifyCancelOrders);
|
- |
|
| 798 |
} else {
|
- |
|
| 799 |
model.addAttribute("inProcessorder", inProcessorder);
|
- |
|
| 800 |
}
|
- |
|
| 801 |
return "review_order";
|
- |
|
| 802 |
}
|
- |
|
| 803 |
|
- |
|
| 804 |
@RequestMapping(value = "/getPaymentPendingOrder", method = RequestMethod.GET)
|
- |
|
| 805 |
public String getPaymentPendingOrder(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
- |
|
| 806 |
|
- |
|
| 807 |
List<com.spice.profitmandi.dao.entity.transaction.Order> pendingPaymentorder = orderRepository
|
- |
|
| 808 |
.selectAllOrderDatesBetweenByStatus(LocalDateTime.now().minusMonths(3), LocalDateTime.now(),
|
- |
|
| 809 |
OrderStatus.PAYMENT_PENDING);
|
- |
|
| 810 |
List<com.spice.profitmandi.dao.entity.transaction.Order> failedPaymentorder = orderRepository
|
- |
|
| 811 |
.selectAllOrderDatesBetweenByStatus(LocalDateTime.now().minusMonths(3), LocalDateTime.now(),
|
- |
|
| 812 |
OrderStatus.PAYMENT_FAILED);
|
- |
|
| 813 |
pendingPaymentorder.addAll(failedPaymentorder);
|
- |
|
| 814 |
model.addAttribute("pendingPaymentorder", pendingPaymentorder);
|
- |
|
| 815 |
|
- |
|
| 816 |
return "payment-pending-order";
|
- |
|
| 817 |
}
|
- |
|
| 818 |
|
- |
|
| 819 |
@RequestMapping(value = "/getKeepInTabOrder", method = RequestMethod.GET)
|
- |
|
| 820 |
public String getKeepInTabOrder(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
- |
|
| 821 |
|
- |
|
| 822 |
List<com.spice.profitmandi.dao.entity.transaction.Order> keepatab = orderRepository
|
- |
|
| 823 |
.selectAllOrder(OrderStatus.KEEP_A_TAB);
|
- |
|
| 824 |
|
- |
|
| 825 |
model.addAttribute("keepatab", keepatab);
|
- |
|
| 826 |
|
- |
|
| 827 |
return "keep-a-tab";
|
- |
|
| 828 |
}
|
- |
|
| 829 |
|
- |
|
| 830 |
@RequestMapping(value = "/closeOrder", method = RequestMethod.POST)
|
- |
|
| 831 |
public String closeOrder(HttpServletRequest request, @RequestParam int orderId, Model model) throws Exception {
|
- |
|
| 832 |
|
- |
|
| 833 |
Order order = orderRepository.selectById(orderId);
|
- |
|
| 834 |
if (order != null) {
|
- |
|
| 835 |
order.setStatus(OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY);
|
- |
|
| 836 |
|
- |
|
| 837 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
- |
|
| 838 |
|
- |
|
| 839 |
} else {
|
- |
|
| 840 |
model.addAttribute("response1", mvcResponseSender.createResponseString(false));
|
- |
|
| 841 |
|
- |
|
| 842 |
}
|
- |
|
| 843 |
return "response";
|
- |
|
| 844 |
}
|
- |
|
| 845 |
|
- |
|
| 846 |
@RequestMapping(value = "/getcancelOrderItems", method = RequestMethod.GET)
|
- |
|
| 847 |
public String getcancelOrderItems(HttpServletRequest request, @RequestParam int itemId, Model model)
|
- |
|
| 848 |
throws Exception {
|
- |
|
| 849 |
|
- |
|
| 850 |
List<Order> inProcessselectedOrder = orderRepository.selectByItemIdOrderStatus(itemId,
|
- |
|
| 851 |
OrderStatus.SUBMITTED_FOR_PROCESSING);
|
- |
|
| 852 |
|
- |
|
| 853 |
List<Integer> retailerIds = new ArrayList<>();
|
- |
|
| 854 |
for (com.spice.profitmandi.dao.entity.transaction.Order order : inProcessselectedOrder) {
|
- |
|
| 855 |
retailerIds.add(order.getRetailerId());
|
- |
|
| 856 |
|
- |
|
| 857 |
}
|
- |
|
| 858 |
|
- |
|
| 859 |
Map<Integer, String> storeIdAndFofoIdMap = fofoStoreRepository.selectByRetailerIds(retailerIds).stream()
|
- |
|
| 860 |
.collect(Collectors.toMap(FofoStore::getId, FofoStore::getCode));
|
- |
|
| 861 |
|
- |
|
| 862 |
model.addAttribute("inProcessCancelOrder", inProcessselectedOrder);
|
- |
|
| 863 |
model.addAttribute("storeIdAndFofoIdMap", storeIdAndFofoIdMap);
|
- |
|
| 864 |
|
- |
|
| 865 |
return "cancel-order-modal";
|
- |
|
| 866 |
}
|
- |
|
| 867 |
|
- |
|
| 868 |
@RequestMapping(value = "/cancelOrder", method = RequestMethod.POST)
|
- |
|
| 869 |
public String cancelOrder(HttpServletRequest request, @RequestBody OrderCancellationModel orderCancellationModel,
|
- |
|
| 870 |
Model model) throws Exception {
|
- |
|
| 871 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 872 |
LOGGER.info("orderId" + orderCancellationModel.getOrderIds());
|
- |
|
| 873 |
|
- |
|
| 874 |
try {
|
- |
|
| 875 |
// List<Order> orders =
|
- |
|
| 876 |
// orderRepository.selectByOrderIds(orderCancellationModel.getOrderIds());
|
- |
|
| 877 |
|
- |
|
| 878 |
List<Order> orders = orderRepository.selectByOrderIdsOrdersStatus(orderCancellationModel.getOrderIds(),
|
- |
|
| 879 |
OrderStatus.SUBMITTED_FOR_PROCESSING);
|
- |
|
| 880 |
if (!orders.isEmpty()) {
|
- |
|
| 881 |
for (Order order : orders) {
|
- |
|
| 882 |
|
- |
|
| 883 |
orderRepository.refundOrder(order.getId(), loginDetails.getEmailId(),
|
- |
|
| 884 |
orderCancellationModel.getReason(), OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY);
|
- |
|
| 885 |
List<NotifyOrder> notifyOrders = notifyOrderRespository.selectByOrder(order.getId());
|
- |
|
| 886 |
for (NotifyOrder notifyOrder : notifyOrders) {
|
- |
|
| 887 |
if (notifyOrder.getStatus() == NotifyStatus.pending) {
|
- |
|
| 888 |
notifyOrder.setStatus(NotifyStatus.rejected);
|
- |
|
| 889 |
}
|
- |
|
| 890 |
}
|
- |
|
| 891 |
sendCancellationNotificationToPartner(order, orderCancellationModel.getReason());
|
- |
|
| 892 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
- |
|
| 893 |
|
- |
|
| 894 |
}
|
- |
|
| 895 |
}
|
- |
|
| 896 |
} catch (TransactionServiceException | TException e) {
|
- |
|
| 897 |
model.addAttribute("response1", mvcResponseSender.createResponseString(false));
|
- |
|
| 898 |
|
- |
|
| 899 |
}
|
- |
|
| 900 |
|
- |
|
| 901 |
return "response";
|
- |
|
| 902 |
}
|
- |
|
| 903 |
|
- |
|
| 904 |
private void sendCancellationNotificationToPartner(Order order, String reason) throws Exception {
|
- |
|
| 905 |
Item item = itemRepository.selectById(order.getLineItem().getItemId());
|
- |
|
| 906 |
|
- |
|
| 907 |
String title = "Order Cancellation";
|
- |
|
| 908 |
String message = String.format("Order %s %d(Pcs) has been cancelled", item.getItemDescription(),
|
- |
|
| 909 |
order.getLineItem().getQuantity());
|
- |
|
| 910 |
|
- |
|
| 911 |
com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(order.getRetailerId());
|
- |
|
| 912 |
|
- |
|
| 913 |
Address address = addressRepository.selectById(user.getAddressId());
|
- |
|
| 914 |
|
- |
|
| 915 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
- |
|
| 916 |
sendNotificationModel.setCampaignName(title);
|
- |
|
| 917 |
sendNotificationModel.setTitle(message);
|
- |
|
| 918 |
sendNotificationModel.setType("url");
|
- |
|
| 919 |
sendNotificationModel.setMessage(reason);
|
- |
|
| 920 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/orderDetails");
|
- |
|
| 921 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
|
- |
|
| 922 |
sendNotificationModel.setMessageType(MessageType.notification);
|
- |
|
| 923 |
int userId = userAccountRepository.selectUserIdByRetailerId(order.getRetailerId());
|
- |
|
| 924 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
- |
|
| 925 |
notificationService.sendNotification(sendNotificationModel);
|
- |
|
| 926 |
|
- |
|
| 927 |
// notificationService.sendWhatsappMessage(message, title,
|
- |
|
| 928 |
// address.getPhoneNumber());
|
- |
|
| 929 |
|
- |
|
| 930 |
}
|
- |
|
| 931 |
|
- |
|
| 932 |
@RequestMapping(value = "/getNotifyItemColor", method = RequestMethod.GET)
|
- |
|
| 933 |
public String getNotifyItemColor(HttpServletRequest request, @RequestParam int catalogItemId,
|
- |
|
| 934 |
@RequestParam int itemId, Model model) throws ProfitMandiBusinessException {
|
- |
|
| 935 |
|
- |
|
| 936 |
List<Item> availableColorItems = itemRepository.selectAllByCatalogItemId(catalogItemId);
|
- |
|
| 937 |
Iterator<Item> itemsIterator = availableColorItems.iterator();
|
- |
|
| 938 |
|
- |
|
| 939 |
while (itemsIterator.hasNext()) {
|
- |
|
| 940 |
Item item = itemsIterator.next();
|
- |
|
| 941 |
TagListing itemTagListing = tagListingRepository.selectByItemId(item.getId());
|
- |
|
| 942 |
|
- |
|
| 943 |
if (itemTagListing == null) {
|
- |
|
| 944 |
itemsIterator.remove();
|
- |
|
| 945 |
|
- |
|
| 946 |
}
|
- |
|
| 947 |
|
- |
|
| 948 |
else if (!itemTagListing.isActive()) {
|
- |
|
| 949 |
itemsIterator.remove();
|
- |
|
| 950 |
|
- |
|
| 951 |
}
|
- |
|
| 952 |
}
|
- |
|
| 953 |
|
- |
|
| 954 |
List<Order> inProcessselectedOrder = orderRepository.selectByItemIdOrderStatus(itemId,
|
- |
|
| 955 |
OrderStatus.SUBMITTED_FOR_PROCESSING);
|
- |
|
| 956 |
List<Integer> retailerIds = new ArrayList<>();
|
- |
|
| 957 |
|
- |
|
| 958 |
for (com.spice.profitmandi.dao.entity.transaction.Order order : inProcessselectedOrder) {
|
- |
|
| 959 |
retailerIds.add(order.getRetailerId());
|
- |
|
| 960 |
|
- |
|
| 961 |
}
|
- |
|
| 962 |
|
- |
|
| 963 |
Map<Integer, String> storeIdAndFofoIdMap = fofoStoreRepository.selectByRetailerIds(retailerIds).stream()
|
- |
|
| 964 |
.collect(Collectors.toMap(FofoStore::getId, FofoStore::getCode));
|
- |
|
| 965 |
LOGGER.info("item" + availableColorItems);
|
- |
|
| 966 |
model.addAttribute("item", availableColorItems);
|
- |
|
| 967 |
model.addAttribute("inProcessselectedOrder", inProcessselectedOrder);
|
- |
|
| 968 |
model.addAttribute("storeIdAndFofoIdMap", storeIdAndFofoIdMap);
|
- |
|
| 969 |
|
- |
|
| 970 |
return "notify-order-modal";
|
- |
|
| 971 |
}
|
- |
|
| 972 |
|
- |
|
| 973 |
@RequestMapping(value = "/notifyOrder", method = RequestMethod.POST)
|
- |
|
| 974 |
public String NotifyOrder(HttpServletRequest request, @RequestBody NotifyOrderModel notifyOrderModel, Model model)
|
- |
|
| 975 |
throws Exception {
|
- |
|
| 976 |
|
- |
|
| 977 |
com.spice.profitmandi.dao.entity.transaction.NotifyItem notifyItem = null;
|
- |
|
| 978 |
List<Integer> orderIds = new ArrayList<>();
|
- |
|
| 979 |
|
- |
|
| 980 |
NotifyColorChange notifytimestamp = new NotifyColorChange();
|
- |
|
| 981 |
notifytimestamp.setCreated(LocalDateTime.now());
|
- |
|
| 982 |
notifyColorChangeRepository.persist(notifytimestamp);
|
- |
|
| 983 |
NotifyMessage notifyMessage = new NotifyMessage();
|
- |
|
| 984 |
notifyMessage.setNotifyId(notifytimestamp.getId());
|
- |
|
| 985 |
notifyMessage.setNotifyMessages(notifyOrderModel.getMessage());
|
- |
|
| 986 |
notifyMessageRepository.persist(notifyMessage);
|
- |
|
| 987 |
for (NotifyItemIdModel itemid : notifyOrderModel.getItemIds()) {
|
- |
|
| 988 |
|
- |
|
| 989 |
notifyItem = new com.spice.profitmandi.dao.entity.transaction.NotifyItem();
|
- |
|
| 990 |
notifyItem.setItemId(itemid.getItemId());
|
- |
|
| 991 |
notifyItem.setResponseTime(itemid.getResponseTime());
|
- |
|
| 992 |
notifyItem.setProcuredDate(itemid.getProcuredTime());
|
- |
|
| 993 |
notifyItem.setNotifyColorchangeId(notifytimestamp.getId());
|
- |
|
| 994 |
notifyItemRepository.persist(notifyItem);
|
- |
|
| 995 |
LOGGER.info("notifyItem" + notifyItem);
|
- |
|
| 996 |
}
|
- |
|
| 997 |
for (NotifyOrderIdModel st : notifyOrderModel.getOrderIds()) {
|
- |
|
| 998 |
List<NotifyOrder> existingOrder = notifyOrderRespository.selectByOrder(st.getOrderId());
|
- |
|
| 999 |
if (!existingOrder.isEmpty()) {
|
- |
|
| 1000 |
LOGGER.info("existingOrder" + existingOrder);
|
- |
|
| 1001 |
for (NotifyOrder notifyOrder : existingOrder) {
|
- |
|
| 1002 |
if (NotifyStatus.pending == notifyOrder.getStatus()) {
|
- |
|
| 1003 |
notifyOrder.setStatus(NotifyStatus.rejected);
|
- |
|
| 1004 |
notifyOrder.setUpdateTimestamp(LocalDateTime.now());
|
- |
|
| 1005 |
}
|
- |
|
| 1006 |
}
|
- |
|
| 1007 |
}
|
- |
|
| 1008 |
NotifyOrder orderStatus = new NotifyOrder();
|
- |
|
| 1009 |
orderStatus.setOrderId(st.getOrderId());
|
- |
|
| 1010 |
orderStatus.setNotifyId(notifytimestamp.getId());
|
- |
|
| 1011 |
orderStatus.setItemId(st.getOlditemId());
|
- |
|
| 1012 |
Order id = orderRepository.selectById(st.getOrderId());
|
- |
|
| 1013 |
orderStatus.setFofoId(id.getRetailerId());
|
- |
|
| 1014 |
orderStatus.setStatus(NotifyStatus.pending);
|
- |
|
| 1015 |
notifyOrderRespository.persist(orderStatus);
|
- |
|
| 1016 |
|
- |
|
| 1017 |
LOGGER.info("itemStatus" + orderStatus);
|
- |
|
| 1018 |
orderIds.add(st.getOrderId());
|
- |
|
| 1019 |
}
|
- |
|
| 1020 |
|
- |
|
| 1021 |
LOGGER.info("orderIds" + orderIds);
|
- |
|
| 1022 |
List<Order> orders = orderRepository.selectByOrderIds(orderIds);
|
- |
|
| 1023 |
for (Order order : orders) {
|
- |
|
| 1024 |
LOGGER.info("order" + order.getId());
|
- |
|
| 1025 |
|
- |
|
| 1026 |
String title = "Alert!";
|
- |
|
| 1027 |
|
- |
|
| 1028 |
NotifyMessage message = notifyMessageRepository.selectByNotifyId(notifytimestamp.getId());
|
- |
|
| 1029 |
|
- |
|
| 1030 |
com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(order.getRetailerId());
|
- |
|
| 1031 |
|
- |
|
| 1032 |
Address address = addressRepository.selectById(user.getAddressId());
|
- |
|
| 1033 |
|
- |
|
| 1034 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
- |
|
| 1035 |
sendNotificationModel.setCampaignName("Notify Partner");
|
- |
|
| 1036 |
sendNotificationModel.setMessage(message.getNotifyMessages());
|
- |
|
| 1037 |
sendNotificationModel.setType("url");
|
- |
|
| 1038 |
sendNotificationModel.setTitle("Alert");
|
- |
|
| 1039 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifyOrder");
|
- |
|
| 1040 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
|
- |
|
| 1041 |
sendNotificationModel.setMessageType(MessageType.notification);
|
- |
|
| 1042 |
int userId = userAccountRepository.selectUserIdByRetailerId(order.getRetailerId());
|
- |
|
| 1043 |
|
- |
|
| 1044 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
- |
|
| 1045 |
notificationService.sendNotification(sendNotificationModel);
|
- |
|
| 1046 |
|
- |
|
| 1047 |
// notificationService.sendWhatsappMessage(message.getNotifyMessages(), title,
|
- |
|
| 1048 |
// address.getPhoneNumber());
|
- |
|
| 1049 |
|
- |
|
| 1050 |
}
|
- |
|
| 1051 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
- |
|
| 1052 |
return "response";
|
- |
|
| 1053 |
}
|
- |
|
| 1054 |
|
- |
|
| 1055 |
@RequestMapping(value = "/getAllNotifyOrder", method = RequestMethod.GET)
|
- |
|
| 1056 |
public String getAllNotifyOrder(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
- |
|
| 1057 |
List<NotifyOrder> notifyOrders = null;
|
- |
|
| 1058 |
List<com.spice.profitmandi.dao.entity.transaction.Order> inProcessorder = orderRepository
|
- |
|
| 1059 |
.selectAllOrder(OrderStatus.SUBMITTED_FOR_PROCESSING);
|
- |
|
| 1060 |
|
- |
|
| 1061 |
List<Integer> orderIds = new ArrayList<>();
|
- |
|
| 1062 |
if (!inProcessorder.isEmpty()) {
|
- |
|
| 1063 |
for (com.spice.profitmandi.dao.entity.transaction.Order order : inProcessorder) {
|
- |
|
| 1064 |
|
- |
|
| 1065 |
orderIds.add(order.getId());
|
- |
|
| 1066 |
|
- |
|
| 1067 |
}
|
- |
|
| 1068 |
notifyOrders = notifyOrderRespository.selectByorderIds(orderIds);
|
- |
|
| 1069 |
Set<Integer> oldItemIds = new HashSet<>();
|
- |
|
| 1070 |
List<Integer> fofoIds = new ArrayList<>();
|
- |
|
| 1071 |
List<Integer> notifyIds = new ArrayList<>();
|
- |
|
| 1072 |
if (!notifyOrders.isEmpty()) {
|
- |
|
| 1073 |
for (NotifyOrder notifyOrder : notifyOrders) {
|
- |
|
| 1074 |
oldItemIds.add(notifyOrder.getItemId());
|
- |
|
| 1075 |
fofoIds.add(notifyOrder.getFofoId());
|
- |
|
| 1076 |
notifyIds.add(notifyOrder.getNotifyId());
|
- |
|
| 1077 |
}
|
- |
|
| 1078 |
|
- |
|
| 1079 |
List<NotifyColorChange> notifyColorChanges = notifyColorChangeRepository.selectByNotifyId(notifyIds);
|
- |
|
| 1080 |
Map<Integer, NotifyColorChange> notifyIdNotifyColorMap = this
|
- |
|
| 1081 |
.notifyOrdersToNotifyId(notifyColorChanges);
|
- |
|
| 1082 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
- |
|
| 1083 |
Map<Integer, CustomRetailer> fofoIdsAndRetailerName = fofoIds.stream().distinct()
|
- |
|
| 1084 |
.map(x -> customRetailerMap.get(x)).filter(x -> x != null).collect(Collectors.toList()).stream()
|
- |
|
| 1085 |
.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
- |
|
| 1086 |
Map<Integer, String> itemdescription = inventoryService.getItemIdDescriptionMap(oldItemIds);
|
- |
|
| 1087 |
|
- |
|
| 1088 |
model.addAttribute("notifyOrders", notifyOrders);
|
- |
|
| 1089 |
model.addAttribute("notifyIdNotifyColorMap", notifyIdNotifyColorMap);
|
- |
|
| 1090 |
model.addAttribute("itemdescription", itemdescription);
|
- |
|
| 1091 |
model.addAttribute("fofoIdsAndRetailerName", fofoIdsAndRetailerName);
|
- |
|
| 1092 |
|
- |
|
| 1093 |
} else {
|
- |
|
| 1094 |
model.addAttribute("notifyOrders", notifyOrders);
|
- |
|
| 1095 |
}
|
- |
|
| 1096 |
} else {
|
- |
|
| 1097 |
model.addAttribute("notifyOrders", notifyOrders);
|
- |
|
| 1098 |
}
|
- |
|
| 1099 |
return "notify_order";
|
- |
|
| 1100 |
}
|
- |
|
| 1101 |
|
- |
|
| 1102 |
private Map<Integer, NotifyColorChange> notifyOrdersToNotifyId(List<NotifyColorChange> notifyColorChanges) {
|
- |
|
| 1103 |
Map<Integer, NotifyColorChange> notifyIdNotifyColorMap = new HashMap<>();
|
- |
|
| 1104 |
for (NotifyColorChange notifyColorChange : notifyColorChanges) {
|
- |
|
| 1105 |
notifyIdNotifyColorMap.put(notifyColorChange.getId(), notifyColorChange);
|
- |
|
| 1106 |
}
|
- |
|
| 1107 |
return notifyIdNotifyColorMap;
|
- |
|
| 1108 |
}
|
- |
|
| 1109 |
|
- |
|
| 1110 |
@RequestMapping(value = "/getItems", method = RequestMethod.GET)
|
- |
|
| 1111 |
public String getItems(HttpServletRequest request, @RequestParam int catalogItemId, Model model) throws Exception {
|
- |
|
| 1112 |
|
- |
|
| 1113 |
Set<Integer> itemIds = itemRepository.selectAllByCatalogItemId(catalogItemId).stream().map(x -> x.getId())
|
- |
|
| 1114 |
.collect(Collectors.toSet());
|
- |
|
| 1115 |
|
- |
|
| 1116 |
List<Order> notAvailableProcessingOrder = orderRepository.selectByItemIdsOrderStatus(itemIds,
|
- |
|
| 1117 |
OrderStatus.SUBMITTED_FOR_PROCESSING);
|
- |
|
| 1118 |
LOGGER.info("notAvailableProcessingOrder" + notAvailableProcessingOrder);
|
- |
|
| 1119 |
|
- |
|
| 1120 |
List<Integer> retailerIds = new ArrayList<>();
|
- |
|
| 1121 |
for (com.spice.profitmandi.dao.entity.transaction.Order order : notAvailableProcessingOrder) {
|
- |
|
| 1122 |
retailerIds.add(order.getRetailerId());
|
- |
|
| 1123 |
|
- |
|
| 1124 |
}
|
- |
|
| 1125 |
|
- |
|
| 1126 |
Map<Integer, String> storeIdAndFofoIdMap = fofoStoreRepository.selectByRetailerIds(retailerIds).stream()
|
- |
|
| 1127 |
.collect(Collectors.toMap(FofoStore::getId, FofoStore::getCode));
|
- |
|
| 1128 |
|
- |
|
| 1129 |
model.addAttribute("notAvailableProcessingOrder", notAvailableProcessingOrder);
|
- |
|
| 1130 |
model.addAttribute("storeIdAndFofoIdMap", storeIdAndFofoIdMap);
|
- |
|
| 1131 |
|
- |
|
| 1132 |
return "partner-cancel-order-modal";
|
- |
|
| 1133 |
}
|
- |
|
| 1134 |
|
- |
|
| 1135 |
@RequestMapping(value = "/notifyCancelOrder", method = RequestMethod.POST)
|
- |
|
| 1136 |
public String NotifyCancelOrder(HttpServletRequest request, @RequestBody NotifyOrderModel notifyOrderModel,
|
- |
|
| 1137 |
Model model) throws Exception {
|
- |
|
| 1138 |
for (NotifyOrderIdModel st : notifyOrderModel.getOrderIds()) {
|
- |
|
| 1139 |
LOGGER.info("orderId" + st.getOrderId());
|
- |
|
| 1140 |
Order order = orderRepository.selectById(st.getOrderId());
|
- |
|
| 1141 |
NotifyCancel nc = notifyCancelOrderRepository.selectByOrderId(st.getOrderId());
|
- |
|
| 1142 |
if (nc == null) {
|
- |
|
| 1143 |
nc = new NotifyCancel();
|
- |
|
| 1144 |
nc.setOrderId(st.getOrderId());
|
- |
|
| 1145 |
nc.setItemId(st.getOlditemId());
|
- |
|
| 1146 |
nc.setFofoId(order.getRetailerId());
|
- |
|
| 1147 |
nc.setCancellation(false);
|
- |
|
| 1148 |
nc.setCreatedTimestamp(LocalDateTime.now());
|
- |
|
| 1149 |
nc.setUpdatedTimestamp(LocalDateTime.now());
|
- |
|
| 1150 |
notifyCancelOrderRepository.persist(nc);
|
- |
|
| 1151 |
} else {
|
- |
|
| 1152 |
nc.setOrderId(st.getOrderId());
|
- |
|
| 1153 |
nc.setItemId(st.getOlditemId());
|
- |
|
| 1154 |
nc.setFofoId(order.getRetailerId());
|
- |
|
| 1155 |
nc.setCancellation(false);
|
- |
|
| 1156 |
nc.setUpdatedTimestamp(LocalDateTime.now());
|
- |
|
| 1157 |
notifyCancelOrderRepository.persist(nc);
|
- |
|
| 1158 |
}
|
- |
|
| 1159 |
|
- |
|
| 1160 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
- |
|
| 1161 |
sendNotificationModel.setCampaignName("Notify Partner");
|
- |
|
| 1162 |
sendNotificationModel.setMessage(notifyOrderModel.getMessage());
|
- |
|
| 1163 |
sendNotificationModel.setType("url");
|
- |
|
| 1164 |
sendNotificationModel.setTitle("Alert");
|
- |
|
| 1165 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifyCancelOrder");
|
- |
|
| 1166 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
|
- |
|
| 1167 |
sendNotificationModel.setMessageType(MessageType.notification);
|
- |
|
| 1168 |
int userId = userAccountRepository.selectUserIdByRetailerId(order.getRetailerId());
|
- |
|
| 1169 |
|
- |
|
| 1170 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
- |
|
| 1171 |
notificationService.sendNotification(sendNotificationModel);
|
- |
|
| 1172 |
|
- |
|
| 1173 |
}
|
- |
|
| 1174 |
|
- |
|
| 1175 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
- |
|
| 1176 |
return "response";
|
- |
|
| 1177 |
}
|
- |
|
| 1178 |
|
- |
|
| 1179 |
@RequestMapping(value = "/getNotifiedCancelOrder", method = RequestMethod.GET)
|
- |
|
| 1180 |
public String getNotifiedCancelOrder(HttpServletRequest request, Model model) throws Exception {
|
- |
|
| 1181 |
|
- |
|
| 1182 |
List<NotifyCancel> notifyCancels = notifyCancelOrderRepository.selectAllNonCancelOrder();
|
- |
|
| 1183 |
if (!notifyCancels.isEmpty()) {
|
- |
|
| 1184 |
List<Integer> retailerIds = new ArrayList<>();
|
- |
|
| 1185 |
Set<Integer> itemIds = new HashSet<>();
|
- |
|
| 1186 |
for (NotifyCancel nc : notifyCancels) {
|
- |
|
| 1187 |
retailerIds.add(nc.getFofoId());
|
- |
|
| 1188 |
itemIds.add(nc.getItemId());
|
- |
|
| 1189 |
}
|
- |
|
| 1190 |
|
- |
|
| 1191 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
- |
|
| 1192 |
|
- |
|
| 1193 |
Map<Integer, CustomRetailer> fofoIdsAndRetailerName = retailerIds.stream()
|
- |
|
| 1194 |
.map(x -> customRetailerMap.get(x)).filter(x -> x != null).collect(Collectors.toList()).stream()
|
- |
|
| 1195 |
.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
- |
|
| 1196 |
Map<Integer, String> itemdescription = inventoryService.getItemIdDescriptionMap(itemIds);
|
- |
|
| 1197 |
model.addAttribute("notifyCancels", notifyCancels);
|
- |
|
| 1198 |
model.addAttribute("itemdescription", itemdescription);
|
- |
|
| 1199 |
model.addAttribute("fofoIdsAndRetailerName", fofoIdsAndRetailerName);
|
- |
|
| 1200 |
} else {
|
- |
|
| 1201 |
|
- |
|
| 1202 |
model.addAttribute("notifyCancels", notifyCancels);
|
- |
|
| 1203 |
|
- |
|
| 1204 |
}
|
- |
|
| 1205 |
return "notify_cancel";
|
- |
|
| 1206 |
}
|
- |
|
| 1207 |
|
- |
|
| 1208 |
@RequestMapping(value = "/getNotifyItems", method = RequestMethod.GET)
|
- |
|
| 1209 |
public String getNotifyItems(HttpServletRequest request, @RequestParam int itemId, Model model) throws Exception {
|
- |
|
| 1210 |
Item item = itemRepository.selectById(itemId);
|
- |
|
| 1211 |
|
- |
|
| 1212 |
List<Integer> itemIds = itemRepository.selectAllByCatalogItemId(item.getCatalogItemId()).stream()
|
- |
|
| 1213 |
.map(x -> x.getId()).collect(Collectors.toList());
|
- |
|
| 1214 |
|
- |
|
| 1215 |
List<NotifyCancel> ncs = notifyCancelOrderRepository.selectByItemIdsAndStatus(itemIds);
|
- |
|
| 1216 |
List<Integer> retailerIds = new ArrayList<>();
|
- |
|
| 1217 |
Map<Integer, Object> orders = new HashMap<>();
|
- |
|
| 1218 |
for (NotifyCancel nc : ncs) {
|
- |
|
| 1219 |
retailerIds.add(nc.getFofoId());
|
- |
|
| 1220 |
Order od = orderRepository.selectById(nc.getOrderId());
|
- |
|
| 1221 |
orders.put(nc.getOrderId(), od);
|
- |
|
| 1222 |
}
|
- |
|
| 1223 |
|
- |
|
| 1224 |
Map<Integer, String> storeIdAndFofoIdMap = fofoStoreRepository.selectByRetailerIds(retailerIds).stream()
|
- |
|
| 1225 |
.collect(Collectors.toMap(FofoStore::getId, FofoStore::getCode));
|
- |
|
| 1226 |
|
- |
|
| 1227 |
model.addAttribute("notifyItems", ncs);
|
- |
|
| 1228 |
model.addAttribute("orders", orders);
|
- |
|
| 1229 |
model.addAttribute("storeIdAndFofoIdMap", storeIdAndFofoIdMap);
|
- |
|
| 1230 |
|
- |
|
| 1231 |
return "notify_cancel_order_modal";
|
- |
|
| 1232 |
}
|
- |
|
| 1233 |
|
- |
|
| 1234 |
@RequestMapping(value = "/changeNotifyCancelRequest", method = RequestMethod.POST)
|
- |
|
| 1235 |
public String changeNotifyCancelRequest(HttpServletRequest request, @RequestBody NotifyOrderModel notifyOrderModel,
|
- |
|
| 1236 |
Model model) throws Exception {
|
- |
|
| 1237 |
List<Integer> orderIds = notifyOrderModel.getOrderIds().stream().map(x -> x.getOrderId())
|
- |
|
| 1238 |
.collect(Collectors.toList());
|
- |
|
| 1239 |
|
- |
|
| 1240 |
List<NotifyCancel> ncs = notifyCancelOrderRepository.selectByOrderIds(orderIds);
|
- |
|
| 1241 |
for (NotifyCancel nc : ncs) {
|
- |
|
| 1242 |
nc.setCancellation(true);
|
- |
|
| 1243 |
}
|
- |
|
| 1244 |
|
- |
|
| 1245 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
- |
|
| 1246 |
return "response";
|
- |
|
| 1247 |
}
|
- |
|
| 1248 |
|
- |
|
| 1249 |
@RequestMapping(value = "/getProducts", method = RequestMethod.GET)
|
- |
|
| 1250 |
public String getProducts(HttpServletRequest request, Model model)
|
- |
|
| 1251 |
throws ProfitMandiBusinessException, URISyntaxException, IOException {
|
- |
|
| 1252 |
|
- |
|
| 1253 |
return "product-detail";
|
- |
|
| 1254 |
}
|
- |
|
| 1255 |
|
- |
|
| 1256 |
@RequestMapping(value = "/getProductInfo", method = RequestMethod.GET)
|
- |
|
| 1257 |
public String getProductInfo(HttpServletRequest request, long catalogId, Model model) throws Exception {
|
- |
|
| 1258 |
ContentPojo cp = mongoClient.getEntityById(catalogId);
|
- |
|
| 1259 |
model.addAttribute("cp", cp);
|
- |
|
| 1260 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
- |
|
| 1261 |
return "product-info";
|
- |
|
| 1262 |
}
|
- |
|
| 1263 |
|
- |
|
| 1264 |
@RequestMapping(value = "/getProductCompareInfo", method = RequestMethod.GET)
|
- |
|
| 1265 |
public String getProductCompareInfo(HttpServletRequest request, @RequestParam List<Long> catalogIds, Model model)
|
- |
|
| 1266 |
throws Exception {
|
- |
|
| 1267 |
List<ContentPojo> cps = new ArrayList<>();
|
- |
|
| 1268 |
Set<Integer> cataogIds = catalogIds.stream().mapToInt(Long::intValue).boxed().collect(Collectors.toSet());
|
- |
|
| 1269 |
LOGGER.info("tagListingMOP" + cataogIds);
|
- |
|
| 1270 |
for (Long cId : catalogIds) {
|
- |
|
| 1271 |
ContentPojo cp = mongoClient.getEntityById(cId);
|
- |
|
| 1272 |
if (cp.getName() == null) {
|
- |
|
| 1273 |
cp.setName(itemRepository.selectAllByCatalogItemId(cId.intValue()).get(0).getItemDescriptionNoColor());
|
- |
|
| 1274 |
}
|
- |
|
| 1275 |
List<Item> items = itemRepository.selectAllByCatalogItemId(cId.intValue());
|
- |
|
| 1276 |
LOGGER.info("itemsMop" + items);
|
- |
|
| 1277 |
int i = 0;
|
- |
|
| 1278 |
for (Item item : items) {
|
- |
|
| 1279 |
TagListing tagListing = tagListingRepository.selectByItemId(items.get(i).getId());
|
- |
|
| 1280 |
|
- |
|
| 1281 |
if (tagListing != null) {
|
- |
|
| 1282 |
cp.setPrice(tagListing.getMop());
|
- |
|
| 1283 |
|
- |
|
| 1284 |
LOGGER.info("tagListingMOP" + tagListing);
|
- |
|
| 1285 |
|
- |
|
| 1286 |
break;
|
- |
|
| 1287 |
|
- |
|
| 1288 |
}
|
- |
|
| 1289 |
i++;
|
- |
|
| 1290 |
}
|
- |
|
| 1291 |
cps.add(cp);
|
- |
|
| 1292 |
|
- |
|
| 1293 |
}
|
- |
|
| 1294 |
|
- |
|
| 1295 |
List<Map<String, String>> entityList = new ArrayList<>();
|
- |
|
| 1296 |
for (ContentPojo cp : cps) {
|
- |
|
| 1297 |
Map<String, String> specsMap = new HashMap<>();
|
- |
|
| 1298 |
for (SpecificationGroup sg : cp.getDetailedSpecs()) {
|
- |
|
| 1299 |
String title = sg.getTitle();
|
- |
|
| 1300 |
for (Specification s : sg.getSpecs()) {
|
- |
|
| 1301 |
String key = title + s.getName();
|
- |
|
| 1302 |
specsMap.put(key, String.join(", ", s.getValues()));
|
- |
|
| 1303 |
}
|
- |
|
| 1304 |
}
|
- |
|
| 1305 |
entityList.add(specsMap);
|
- |
|
| 1306 |
|
- |
|
| 1307 |
}
|
- |
|
| 1308 |
|
- |
|
| 1309 |
LOGGER.info("cps" + cps);
|
- |
|
| 1310 |
model.addAttribute("cps", cps);
|
- |
|
| 1311 |
model.addAttribute("catalogIds", gson.toJson(catalogIds, List.class));
|
- |
|
| 1312 |
model.addAttribute("entityList", entityList);
|
- |
|
| 1313 |
return "product-compare";
|
- |
|
| 1314 |
}
|
- |
|
| 1315 |
|
- |
|
| 1316 |
@RequestMapping(value = "/inventory", method = RequestMethod.GET)
|
- |
|
| 1317 |
public String Inventory(HttpServletRequest request,
|
- |
|
| 1318 |
@RequestParam(name = "warehouseIds", required = true, defaultValue = "0") List<Integer> warehouseIds,
|
- |
|
| 1319 |
Model model) throws Exception {
|
- |
|
| 1320 |
model.addAttribute("warehouseId", warehouseIds);
|
- |
|
| 1321 |
LOGGER.info("warehouseIds" + warehouseIds);
|
- |
|
| 1322 |
|
- |
|
| 1323 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
- |
|
| 1324 |
if (warehouseIds.contains(0)) {
|
- |
|
| 1325 |
warehouseIds.addAll(warehouseMap.keySet());
|
- |
|
| 1326 |
}
|
- |
|
| 1327 |
|
- |
|
| 1328 |
long poTodayValue = 0;
|
- |
|
| 1329 |
long poThreedaysValue = 0;
|
- |
|
| 1330 |
long poSevendaysValue = 0;
|
- |
|
| 1331 |
long poTodayQty = 0;
|
- |
|
| 1332 |
long poThreedaysQty = 0;
|
- |
|
| 1333 |
long poSevendaysQty = 0;
|
- |
|
| 1334 |
|
- |
|
| 1335 |
List<OpenPoModel> openPO = warehousePurchaseOrderRepository.selectOpenPo(warehouseIds);
|
- |
|
| 1336 |
for (OpenPoModel po : openPO) {
|
- |
|
| 1337 |
poTodayValue += po.getTodayValue();
|
- |
|
| 1338 |
poThreedaysValue += po.getThreedaysValue();
|
- |
|
| 1339 |
poSevendaysValue += po.getSevendaysValue();
|
- |
|
| 1340 |
poTodayQty += po.getTodayQty();
|
- |
|
| 1341 |
poThreedaysQty += po.getThreedaysQty();
|
- |
|
| 1342 |
poSevendaysQty += po.getSevendaysQty();
|
- |
|
| 1343 |
}
|
- |
|
| 1344 |
OpenPoModel poModel = new OpenPoModel();
|
- |
|
| 1345 |
poModel.setBrand("Total Values");
|
- |
|
| 1346 |
poModel.setTodayValue(poTodayValue);
|
- |
|
| 1347 |
poModel.setThreedaysValue(poThreedaysValue);
|
- |
|
| 1348 |
poModel.setSevendaysValue(poSevendaysValue);
|
- |
|
| 1349 |
poModel.setSevendaysQty(poSevendaysQty);
|
- |
|
| 1350 |
poModel.setThreedaysQty(poThreedaysQty);
|
- |
|
| 1351 |
poModel.setTodayQty(poTodayQty);
|
- |
|
| 1352 |
openPO.add(poModel);
|
- |
|
| 1353 |
|
- |
|
| 1354 |
long purtodayValue = 0;
|
- |
|
| 1355 |
long purthreedaysValue = 0;
|
- |
|
| 1356 |
long purlmsValue = 0;
|
- |
|
| 1357 |
long purmtd = 0;
|
- |
|
| 1358 |
long purtodayQty = 0;
|
- |
|
| 1359 |
long purthreedaysQty = 0;
|
- |
|
| 1360 |
long purlmsQty = 0;
|
- |
|
| 1361 |
long purmtdQty = 0;
|
- |
|
| 1362 |
|
- |
|
| 1363 |
List<OurPurchaseModel> purchase = warehouseScanRepository.selectOurPurchase(warehouseIds);
|
- |
|
| 1364 |
|
- |
|
| 1365 |
for (OurPurchaseModel pm : purchase) {
|
- |
|
| 1366 |
purtodayValue += pm.getTodayValue();
|
- |
|
| 1367 |
purthreedaysValue += pm.getThreedaysValue();
|
- |
|
| 1368 |
purlmsValue += pm.getLms();
|
- |
|
| 1369 |
purmtd += pm.getMtd();
|
- |
|
| 1370 |
purtodayQty += pm.getTodayQty();
|
- |
|
| 1371 |
purthreedaysQty += pm.getThreedaysQty();
|
- |
|
| 1372 |
purlmsQty += pm.getLmsQty();
|
- |
|
| 1373 |
purmtdQty += pm.getMtdQty();
|
- |
|
| 1374 |
}
|
- |
|
| 1375 |
OurPurchaseModel omp = new OurPurchaseModel();
|
- |
|
| 1376 |
omp.setBrand("Total Values");
|
- |
|
| 1377 |
omp.setTodayValue(purtodayValue);
|
- |
|
| 1378 |
omp.setThreedaysValue(purthreedaysValue);
|
- |
|
| 1379 |
omp.setLms(purlmsValue);
|
- |
|
| 1380 |
omp.setMtd(purmtd);
|
- |
|
| 1381 |
omp.setTodayQty(purtodayQty);
|
- |
|
| 1382 |
omp.setThreedaysQty(purthreedaysQty);
|
- |
|
| 1383 |
omp.setLmsQty(purlmsQty);
|
- |
|
| 1384 |
omp.setMtdQty(purmtdQty);
|
- |
|
| 1385 |
purchase.add(omp);
|
- |
|
| 1386 |
|
- |
|
| 1387 |
List<BrandWiseTertiaryModel> tertiary = fofoOrderRepository.selectGroupByBrandPartnerTertiary(warehouseIds);
|
- |
|
| 1388 |
long tertodayValue = 0;
|
- |
|
| 1389 |
long terthreedaysValue = 0;
|
- |
|
| 1390 |
long termtd = 0;
|
- |
|
| 1391 |
long terlmtd = 0;
|
- |
|
| 1392 |
long terlms = 0;
|
- |
|
| 1393 |
long tertodayQty = 0;
|
- |
|
| 1394 |
long terthreedaysQty = 0;
|
- |
|
| 1395 |
long termtdQty = 0;
|
- |
|
| 1396 |
long terlmtdQty = 0;
|
- |
|
| 1397 |
long terlmsQty = 0;
|
- |
|
| 1398 |
for (BrandWiseTertiaryModel btm : tertiary) {
|
- |
|
| 1399 |
tertodayValue += btm.getTodayValue();
|
- |
|
| 1400 |
terthreedaysValue += btm.getThreedaysValue();
|
- |
|
| 1401 |
termtd += btm.getMtd();
|
- |
|
| 1402 |
terlmtd += btm.getLmtd();
|
- |
|
| 1403 |
terlms += btm.getLms();
|
- |
|
| 1404 |
tertodayQty += btm.getTodayQty();
|
- |
|
| 1405 |
terthreedaysQty += btm.getThreedaysQty();
|
- |
|
| 1406 |
termtdQty += btm.getMtdQty();
|
- |
|
| 1407 |
terlmtdQty += btm.getLmtdQty();
|
- |
|
| 1408 |
terlmsQty += btm.getLmsQty();
|
- |
|
| 1409 |
}
|
- |
|
| 1410 |
BrandWiseTertiaryModel bwt = new BrandWiseTertiaryModel();
|
- |
|
| 1411 |
bwt.setBrand("Total Values");
|
- |
|
| 1412 |
bwt.setTodayValue(tertodayValue);
|
- |
|
| 1413 |
bwt.setThreedaysValue(terthreedaysValue);
|
- |
|
| 1414 |
bwt.setMtd(termtd);
|
- |
|
| 1415 |
bwt.setLmtd(terlmtd);
|
- |
|
| 1416 |
bwt.setLms(terlms);
|
- |
|
| 1417 |
bwt.setTodayQty(tertodayQty);
|
- |
|
| 1418 |
bwt.setThreedaysQty(terthreedaysQty);
|
- |
|
| 1419 |
bwt.setMtdQty(termtdQty);
|
- |
|
| 1420 |
bwt.setLmtdQty(terlmtdQty);
|
- |
|
| 1421 |
bwt.setLmsQty(terlmsQty);
|
- |
|
| 1422 |
tertiary.add(bwt);
|
- |
|
| 1423 |
|
- |
|
| 1424 |
List<SecondaryOrderBillingModel> billing = orderRepository.selectAllBilledOrderGroupByBrand(warehouseIds);
|
- |
|
| 1425 |
long sectodayValue = 0;
|
- |
|
| 1426 |
long secthreedaysValue = 0;
|
- |
|
| 1427 |
long secmtd = 0;
|
- |
|
| 1428 |
long seclmtd = 0;
|
- |
|
| 1429 |
long seclms = 0;
|
- |
|
| 1430 |
long sectodayQty = 0;
|
- |
|
| 1431 |
long secthreedaysQty = 0;
|
- |
|
| 1432 |
long secmtdQty = 0;
|
- |
|
| 1433 |
long seclmtdQty = 0;
|
- |
|
| 1434 |
long seclmsQty = 0;
|
- |
|
| 1435 |
for (SecondaryOrderBillingModel sbm : billing) {
|
- |
|
| 1436 |
sectodayValue += sbm.getTodayValue();
|
- |
|
| 1437 |
secthreedaysValue += sbm.getThreedaysValue();
|
- |
|
| 1438 |
secmtd += sbm.getMtd();
|
- |
|
| 1439 |
seclmtd += sbm.getLmtd();
|
- |
|
| 1440 |
seclms += sbm.getLms();
|
- |
|
| 1441 |
sectodayQty += sbm.getTodayQty();
|
- |
|
| 1442 |
secthreedaysQty += sbm.getThreedaysQty();
|
- |
|
| 1443 |
secmtdQty += sbm.getMtdQty();
|
- |
|
| 1444 |
seclmtdQty += sbm.getLmtdQty();
|
- |
|
| 1445 |
seclmsQty += sbm.getLmsQty();
|
- |
|
| 1446 |
}
|
- |
|
| 1447 |
|
- |
|
| 1448 |
SecondaryOrderBillingModel som = new SecondaryOrderBillingModel();
|
- |
|
| 1449 |
som.setBrand("Total Values");
|
- |
|
| 1450 |
som.setTodayValue(sectodayValue);
|
- |
|
| 1451 |
som.setThreedaysValue(secthreedaysValue);
|
- |
|
| 1452 |
som.setMtd(secmtd);
|
- |
|
| 1453 |
som.setLmtd(seclmtd);
|
- |
|
| 1454 |
som.setLms(seclms);
|
- |
|
| 1455 |
som.setTodayQty(sectodayQty);
|
- |
|
| 1456 |
som.setThreedaysQty(secthreedaysQty);
|
- |
|
| 1457 |
som.setMtdQty(secmtdQty);
|
- |
|
| 1458 |
som.setLmtdQty(seclmtdQty);
|
- |
|
| 1459 |
som.setLmsQty(seclmsQty);
|
- |
|
| 1460 |
billing.add(som);
|
- |
|
| 1461 |
LOGGER.info("openPO" + openPO);
|
- |
|
| 1462 |
LOGGER.info("purchase" + purchase);
|
- |
|
| 1463 |
LOGGER.info("tertiary" + tertiary);
|
- |
|
| 1464 |
LOGGER.info("billing" + billing);
|
- |
|
| 1465 |
|
- |
|
| 1466 |
LOGGER.info("warehouseIds" + warehouseIds);
|
- |
|
| 1467 |
model.addAttribute("warehouseMap", warehouseMap);
|
- |
|
| 1468 |
model.addAttribute("openPO", openPO);
|
- |
|
| 1469 |
model.addAttribute("purchase", purchase);
|
- |
|
| 1470 |
model.addAttribute("tertiary", tertiary);
|
- |
|
| 1471 |
model.addAttribute("billing", billing);
|
- |
|
| 1472 |
|
- |
|
| 1473 |
return "inventory-listing";
|
- |
|
| 1474 |
|
- |
|
| 1475 |
}
|
- |
|
| 1476 |
|
- |
|
| 1477 |
@RequestMapping(value = "/getOpenPoItemByBrand", method = RequestMethod.GET)
|
- |
|
| 1478 |
public String Inventory(HttpServletRequest request,
|
- |
|
| 1479 |
@RequestParam(name = "warehouseIds", required = true, defaultValue = "0") List<Integer> warehouseIds,
|
- |
|
| 1480 |
@RequestParam(name = "brand", required = true, defaultValue = "") List<String> brand, int timeValue,
|
- |
|
| 1481 |
Model model) throws Exception {
|
- |
|
| 1482 |
model.addAttribute("warehouseId", warehouseIds);
|
- |
|
| 1483 |
LOGGER.info("warehouseIds" + warehouseIds);
|
- |
|
| 1484 |
|
- |
|
| 1485 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
- |
|
| 1486 |
if (warehouseIds.contains(0)) {
|
- |
|
| 1487 |
warehouseIds.addAll(warehouseMap.keySet());
|
- |
|
| 1488 |
}
|
- |
|
| 1489 |
LOGGER.info("brand" + brand);
|
- |
|
| 1490 |
|
- |
|
| 1491 |
if (brand.contains("Total Values")) {
|
- |
|
| 1492 |
List<String> poBrands = warehousePurchaseOrderRepository.selectOpenPo(warehouseIds).stream()
|
- |
|
| 1493 |
.map(x -> x.getBrand()).collect(Collectors.toList());
|
- |
|
| 1494 |
|
- |
|
| 1495 |
brand.addAll(poBrands);
|
- |
|
| 1496 |
}
|
- |
|
| 1497 |
|
- |
|
| 1498 |
LOGGER.info("brand" + brand);
|
- |
|
| 1499 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
- |
|
| 1500 |
List<OpenPoItemModel> openPOItem = null;
|
- |
|
| 1501 |
if (timeValue != 0) {
|
- |
|
| 1502 |
openPOItem = warehousePurchaseOrderRepository.selectOpenPoItem(warehouseIds, brand,
|
- |
|
| 1503 |
curDate.minusDays(timeValue), curDate);
|
- |
|
| 1504 |
} else {
|
- |
|
| 1505 |
openPOItem = warehousePurchaseOrderRepository.selectTodayOpenPoItem(warehouseIds, brand, curDate);
|
- |
|
| 1506 |
}
|
- |
|
| 1507 |
LOGGER.info("openPOItem" + openPOItem);
|
- |
|
| 1508 |
|
- |
|
| 1509 |
model.addAttribute("openPOItem", openPOItem);
|
- |
|
| 1510 |
|
- |
|
| 1511 |
return "inventory-listing-po-item";
|
- |
|
| 1512 |
|
- |
|
| 1513 |
}
|
- |
|
| 1514 |
|
- |
|
| 1515 |
@RequestMapping(value = "/getOurPurchaseItemByBrand", method = RequestMethod.GET)
|
- |
|
| 1516 |
public String getOurPurchaseItemByBrand(HttpServletRequest request,
|
- |
|
| 1517 |
@RequestParam(name = "warehouseIds", required = true, defaultValue = "0") List<Integer> warehouseIds,
|
- |
|
| 1518 |
@RequestParam(name = "brand", required = true, defaultValue = "") List<String> brand, int timeValue,
|
- |
|
| 1519 |
Model model) throws Exception {
|
- |
|
| 1520 |
model.addAttribute("warehouseId", warehouseIds);
|
- |
|
| 1521 |
LOGGER.info("warehouseIds" + warehouseIds);
|
- |
|
| 1522 |
|
- |
|
| 1523 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
- |
|
| 1524 |
if (warehouseIds.contains(0)) {
|
- |
|
| 1525 |
warehouseIds.addAll(warehouseMap.keySet());
|
- |
|
| 1526 |
}
|
- |
|
| 1527 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
- |
|
| 1528 |
|
- |
|
| 1529 |
if (brand.contains("Total Values")) {
|
- |
|
| 1530 |
List<String> purchasebrands = warehouseScanRepository.selectOurPurchase(warehouseIds).stream()
|
- |
|
| 1531 |
.map(x -> x.getBrand()).collect(Collectors.toList());
|
- |
|
| 1532 |
|
- |
|
| 1533 |
brand.addAll(purchasebrands);
|
- |
|
| 1534 |
}
|
- |
|
| 1535 |
List<OurPurchaseItemModel> ourPurchaseItem = null;
|
- |
|
| 1536 |
if (timeValue != 0) {
|
- |
|
| 1537 |
if (timeValue == 1) {
|
- |
|
| 1538 |
ourPurchaseItem = warehouseScanRepository.selectOurPurchaseItemByBrand(warehouseIds, brand,
|
- |
|
| 1539 |
curDate.withDayOfMonth(1), curDate.plusDays(1));
|
- |
|
| 1540 |
|
- |
|
| 1541 |
} else if (timeValue == -1) {
|
- |
|
| 1542 |
|
- |
|
| 1543 |
ourPurchaseItem = warehouseScanRepository.selectOurPurchaseItemByBrand(warehouseIds, brand,
|
- |
|
| 1544 |
curDate.minusMonths(1).withDayOfMonth(1), curDate.withDayOfMonth(1));
|
- |
|
| 1545 |
|
- |
|
| 1546 |
} else {
|
- |
|
| 1547 |
ourPurchaseItem = warehouseScanRepository.selectOurPurchaseItemByBrand(warehouseIds, brand,
|
- |
|
| 1548 |
curDate.minusDays(timeValue), curDate);
|
- |
|
| 1549 |
|
- |
|
| 1550 |
}
|
- |
|
| 1551 |
} else {
|
- |
|
| 1552 |
ourPurchaseItem = warehouseScanRepository.selectTodayOurPurchaseItemByBrand(warehouseIds, brand, curDate);
|
- |
|
| 1553 |
}
|
- |
|
| 1554 |
LOGGER.info("ourPurchaseItem" + ourPurchaseItem);
|
- |
|
| 1555 |
|
- |
|
| 1556 |
model.addAttribute("ourPurchaseItem", ourPurchaseItem);
|
- |
|
| 1557 |
model.addAttribute("warehouseMap", warehouseMap);
|
- |
|
| 1558 |
|
- |
|
| 1559 |
return "inventory-listing-purchase-item";
|
- |
|
| 1560 |
|
- |
|
| 1561 |
}
|
- |
|
| 1562 |
|
- |
|
| 1563 |
@RequestMapping(value = "/getWarehouseWiseSecondaryBillingByBrand", method = RequestMethod.GET)
|
- |
|
| 1564 |
public String getWarehouseWiseSecondaryBillingByBrand(HttpServletRequest request,
|
- |
|
| 1565 |
@RequestParam(name = "brand", required = true, defaultValue = "") String brand, int timeValue, Model model)
|
- |
|
| 1566 |
throws Exception {
|
- |
|
| 1567 |
|
- |
|
| 1568 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
- |
|
| 1569 |
int dayOfMonth = curDate.getDayOfMonth();
|
- |
|
| 1570 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1);
|
- |
|
| 1571 |
int lengthOfMonth = YearMonth.from(startOfMonth.minusMonths(1)).lengthOfMonth();
|
- |
|
| 1572 |
|
- |
|
| 1573 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
- |
|
| 1574 |
SecondaeryOrderDateRange sr = null;
|
- |
|
| 1575 |
if (brand.equals("Total Values")) {
|
- |
|
| 1576 |
brand = null;
|
- |
|
| 1577 |
}
|
- |
|
| 1578 |
if (timeValue != 0) {
|
- |
|
| 1579 |
if (timeValue == 1) {
|
- |
|
| 1580 |
|
- |
|
| 1581 |
sr = getSecondaryModel(brand, curDate.withDayOfMonth(1), curDate.plusDays(1));
|
- |
|
| 1582 |
|
- |
|
| 1583 |
} else if (timeValue == 2) {
|
- |
|
| 1584 |
LOGGER.info("curDate" + curDate.withDayOfMonth(1).minusMonths(1));
|
- |
|
| 1585 |
LOGGER.info("curDate" + curDate.minusMonths(1).plusDays(Math.min(dayOfMonth, lengthOfMonth)));
|
- |
|
| 1586 |
|
- |
|
| 1587 |
sr = getSecondaryModel(brand, curDate.withDayOfMonth(1).minusMonths(1),
|
- |
|
| 1588 |
startOfMonth.minusMonths(1).plusDays(Math.min(dayOfMonth, lengthOfMonth)));
|
- |
|
| 1589 |
|
- |
|
| 1590 |
} else if (timeValue == -1) {
|
- |
|
| 1591 |
|
- |
|
| 1592 |
sr = getSecondaryModel(brand, curDate.minusMonths(1).withDayOfMonth(1), startOfMonth);
|
- |
|
| 1593 |
|
- |
|
| 1594 |
} else {
|
- |
|
| 1595 |
|
- |
|
| 1596 |
sr = getSecondaryModel(brand, curDate.minusDays(timeValue), curDate);
|
- |
|
| 1597 |
}
|
- |
|
| 1598 |
|
- |
|
| 1599 |
} else {
|
- |
|
| 1600 |
sr = getSecondaryModel(brand, curDate, curDate.plusDays(1));
|
- |
|
| 1601 |
}
|
- |
|
| 1602 |
|
- |
|
| 1603 |
Map<BrandRegionModel, Map<LocalDate, SecondaryWarehouseWiseOrderBilllingModel>> brandWarehouseOrderMap = sr
|
- |
|
| 1604 |
.getSecondaryModel().stream()
|
- |
|
| 1605 |
.collect(Collectors.groupingBy(x -> new BrandRegionModel(x.getWarehouseId(), x.getBrand()),
|
- |
|
| 1606 |
Collectors.collectingAndThen(Collectors.toList(),
|
- |
|
| 1607 |
x -> x.stream().collect(Collectors.toMap(y -> y.getBillingTimestamp(), y -> y)))));
|
- |
|
| 1608 |
|
- |
|
| 1609 |
Map<LocalDate, Integer> dateWiseTotal = sr.getSecondaryModel().stream().collect(
|
- |
|
| 1610 |
Collectors.groupingBy(x -> x.getBillingTimestamp(), Collectors.summingInt(x -> (int) x.getValue())));
|
- |
|
| 1611 |
|
- |
|
| 1612 |
Map<LocalDate, Integer> dateWiseQtyTotal = sr.getSecondaryModel().stream().collect(
|
- |
|
| 1613 |
Collectors.groupingBy(x -> x.getBillingTimestamp(), Collectors.summingInt(x -> (int) x.getQty())));
|
- |
|
| 1614 |
|
- |
|
| 1615 |
LOGGER.info("dateWiseTotal" + dateWiseTotal);
|
- |
|
| 1616 |
|
- |
|
| 1617 |
brandWarehouseOrderMap.entrySet().stream().forEach(x -> {
|
- |
|
| 1618 |
x.getKey().setTotal(x.getValue().entrySet().stream()
|
- |
|
| 1619 |
.collect(Collectors.summingInt(y -> (int) y.getValue().getValue())));
|
- |
|
| 1620 |
});
|
- |
|
| 1621 |
|
- |
|
| 1622 |
brandWarehouseOrderMap.entrySet().stream().forEach(x -> {
|
- |
|
| 1623 |
x.getKey().setQty(
|
- |
|
| 1624 |
x.getValue().entrySet().stream().collect(Collectors.summingInt(y -> (int) y.getValue().getQty())));
|
- |
|
| 1625 |
});
|
- |
|
| 1626 |
LOGGER.info("brandWarehouseOrderMap" + brandWarehouseOrderMap);
|
- |
|
| 1627 |
|
- |
|
| 1628 |
model.addAttribute("brandWarehouseOrderMap", brandWarehouseOrderMap);
|
- |
|
| 1629 |
model.addAttribute("dateWiseTotal", dateWiseTotal);
|
- |
|
| 1630 |
model.addAttribute("dateWiseQtyTotal", dateWiseQtyTotal);
|
- |
|
| 1631 |
model.addAttribute("dateRange", sr.getDateRange());
|
- |
|
| 1632 |
model.addAttribute("warehouseMap", warehouseMap);
|
- |
|
| 1633 |
return "secondary-warehouse-billing-order";
|
- |
|
| 1634 |
|
- |
|
| 1635 |
}
|
- |
|
| 1636 |
|
- |
|
| 1637 |
public SecondaeryOrderDateRange getSecondaryModel(String brand, LocalDateTime startDate, LocalDateTime endDate) {
|
- |
|
| 1638 |
|
- |
|
| 1639 |
SecondaeryOrderDateRange sr = new SecondaeryOrderDateRange();
|
- |
|
| 1640 |
List<SecondaryWarehouseWiseOrderBilllingModel> secondaryOrderbilling = orderRepository
|
- |
|
| 1641 |
.selectAllBilledOrderGroupByBrandWarehouse(brand, startDate, endDate).stream()
|
- |
|
| 1642 |
.sorted(Comparator.comparing(SecondaryWarehouseWiseOrderBilllingModel::getBillingTimestamp))
|
- |
|
| 1643 |
.collect(Collectors.toList());
|
- |
|
| 1644 |
long noOfDaysBetween = ChronoUnit.DAYS.between(startDate, endDate);
|
- |
|
| 1645 |
|
- |
|
| 1646 |
List<LocalDate> dateRange = Stream.iterate(startDate.toLocalDate(), date -> date.plusDays(1))
|
- |
|
| 1647 |
.limit(noOfDaysBetween).collect(Collectors.toList());
|
- |
|
| 1648 |
|
- |
|
| 1649 |
sr.setDateRange(dateRange);
|
- |
|
| 1650 |
sr.setSecondaryModel(secondaryOrderbilling);
|
- |
|
| 1651 |
|
- |
|
| 1652 |
return sr;
|
- |
|
| 1653 |
|
- |
|
| 1654 |
}
|
- |
|
| 1655 |
|
- |
|
| 1656 |
@RequestMapping(value = "/getSecondaryBillingItemByBrand", method = RequestMethod.GET)
|
- |
|
| 1657 |
public String getSecondaryBillingItemByBrand(HttpServletRequest request,
|
- |
|
| 1658 |
@RequestParam(name = "warehouseId", required = true, defaultValue = "0") int warehouseId,
|
- |
|
| 1659 |
@RequestParam(name = "brand", required = true, defaultValue = "") String brand,
|
- |
|
| 1660 |
@RequestParam List<LocalDate> date, Model model) throws Exception {
|
- |
|
| 1661 |
|
- |
|
| 1662 |
List<SecondaryOrderItemBillingModel> orderItemBilling = orderRepository
|
- |
|
| 1663 |
.selectAllBilledOrderItemByBrand(warehouseId, brand, date);
|
- |
|
| 1664 |
|
- |
|
| 1665 |
LOGGER.info("orderItemBilling" + orderItemBilling);
|
- |
|
| 1666 |
model.addAttribute("billedItem", orderItemBilling);
|
- |
|
| 1667 |
model.addAttribute("date", date);
|
- |
|
| 1668 |
model.addAttribute("brand", brand);
|
- |
|
| 1669 |
return "inventory-listing-billing-item";
|
- |
|
| 1670 |
|
- |
|
| 1671 |
}
|
- |
|
| 1672 |
|
- |
|
| 1673 |
@RequestMapping(value = "/getPartnerTertiaryItemByBrand", method = RequestMethod.GET)
|
- |
|
| 1674 |
public String getPartnerTertiaryItemByBrand(HttpServletRequest request,
|
- |
|
| 1675 |
@RequestParam(name = "warehouseIds", required = true, defaultValue = "0") List<Integer> warehouseIds,
|
- |
|
| 1676 |
@RequestParam(name = "brand", required = true, defaultValue = "") List<String> brand, int timeValue,
|
- |
|
| 1677 |
Model model) throws Exception {
|
- |
|
| 1678 |
model.addAttribute("warehouseId", warehouseIds);
|
- |
|
| 1679 |
LOGGER.info("warehouseIds" + warehouseIds);
|
- |
|
| 1680 |
|
- |
|
| 1681 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
- |
|
| 1682 |
if (warehouseIds.contains(0)) {
|
- |
|
| 1683 |
warehouseIds.addAll(warehouseMap.keySet());
|
- |
|
| 1684 |
}
|
- |
|
| 1685 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
- |
|
| 1686 |
int dayOfMonth = curDate.getDayOfMonth();
|
- |
|
| 1687 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1);
|
- |
|
| 1688 |
int lengthOfMonth = YearMonth.from(startOfMonth.minusMonths(1)).lengthOfMonth();
|
- |
|
| 1689 |
if (brand.contains("Total Values")) {
|
- |
|
| 1690 |
List<String> tertiaryBrands = fofoOrderRepository.selectGroupByBrandPartnerTertiary(warehouseIds).stream()
|
- |
|
| 1691 |
.map(x -> x.getBrand()).collect(Collectors.toList());
|
- |
|
| 1692 |
|
- |
|
| 1693 |
brand.addAll(tertiaryBrands);
|
- |
|
| 1694 |
}
|
- |
|
| 1695 |
List<BrandItemWiseTertiaryModel> tertiaryItem = null;
|
- |
|
| 1696 |
if (timeValue != 0) {
|
- |
|
| 1697 |
if (timeValue == 1) {
|
- |
|
| 1698 |
|
- |
|
| 1699 |
tertiaryItem = fofoOrderRepository.selectItemPartnerTertiaryByBrand(warehouseIds, brand,
|
- |
|
| 1700 |
curDate.withDayOfMonth(1), curDate.plusDays(1));
|
- |
|
| 1701 |
|
- |
|
| 1702 |
} else if (timeValue == 2) {
|
- |
|
| 1703 |
LOGGER.info("curDate" + startOfMonth.minusMonths(1));
|
- |
|
| 1704 |
LOGGER.info("curDate" + startOfMonth.minusMonths(1).plusDays(Math.min(dayOfMonth, lengthOfMonth)));
|
- |
|
| 1705 |
|
- |
|
| 1706 |
tertiaryItem = fofoOrderRepository.selectItemPartnerTertiaryByBrand(warehouseIds, brand,
|
- |
|
| 1707 |
startOfMonth.minusMonths(1),
|
- |
|
| 1708 |
startOfMonth.minusMonths(1).plusDays(Math.min(dayOfMonth, lengthOfMonth)));
|
- |
|
| 1709 |
|
- |
|
| 1710 |
} else if (timeValue == -1) {
|
- |
|
| 1711 |
LOGGER.info("date" + curDate.minusMonths(1).withDayOfMonth(1));
|
- |
|
| 1712 |
LOGGER.info("date" + curDate.minusMonths(1).withDayOfMonth(lengthOfMonth).plusDays(1));
|
- |
|
| 1713 |
|
- |
|
| 1714 |
tertiaryItem = fofoOrderRepository.selectItemPartnerTertiaryByBrand(warehouseIds, brand,
|
- |
|
| 1715 |
curDate.minusMonths(1).withDayOfMonth(1), startOfMonth);
|
- |
|
| 1716 |
} else {
|
- |
|
| 1717 |
tertiaryItem = fofoOrderRepository.selectItemPartnerTertiaryByBrand(warehouseIds, brand,
|
- |
|
| 1718 |
curDate.minusDays(timeValue), curDate);
|
- |
|
| 1719 |
}
|
- |
|
| 1720 |
|
- |
|
| 1721 |
} else {
|
- |
|
| 1722 |
tertiaryItem = fofoOrderRepository.selectTodayItemPartnerTertiaryByBrand(warehouseIds, brand, curDate);
|
- |
|
| 1723 |
}
|
- |
|
| 1724 |
LOGGER.info("tertiaryItem" + tertiaryItem);
|
- |
|
| 1725 |
|
- |
|
| 1726 |
model.addAttribute("tertiaryItem", tertiaryItem);
|
- |
|
| 1727 |
|
- |
|
| 1728 |
return "inventory-item-tertiary-item";
|
- |
|
| 1729 |
|
- |
|
| 1730 |
}
|
- |
|
| 1731 |
|
- |
|
| 1732 |
@RequestMapping(value = "/planogram")
|
- |
|
| 1733 |
public String Planogram(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
- |
|
| 1734 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 1735 |
String email = loginDetails.getEmailId();
|
- |
|
| 1736 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
- |
|
| 1737 |
List<FocusedModelByPassRequest> byPassRequest = null;
|
- |
|
| 1738 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
- |
|
| 1739 |
|
- |
|
| 1740 |
Set<Integer> authfofoIds = null;
|
- |
|
| 1741 |
|
- |
|
| 1742 |
List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
|
- |
|
| 1743 |
|
- |
|
| 1744 |
if (emails.contains(authUser.getEmailId())) {
|
- |
|
| 1745 |
authfofoIds = storeGuyMap.get("tarun.verma@smartdukaan.com");
|
- |
|
| 1746 |
LOGGER.info("fofoIds" + authfofoIds);
|
- |
|
| 1747 |
} else {
|
- |
|
| 1748 |
|
- |
|
| 1749 |
for (Position ps : positions) {
|
- |
|
| 1750 |
if (esclationType.contains(ps.getEscalationType())) {
|
- |
|
| 1751 |
authfofoIds = storeGuyMap.get(email);
|
- |
|
| 1752 |
break;
|
- |
|
| 1753 |
}
|
- |
|
| 1754 |
|
- |
|
| 1755 |
}
|
- |
|
| 1756 |
}
|
- |
|
| 1757 |
if (authfofoIds != null) {
|
- |
|
| 1758 |
byPassRequest = focusedModelByPassRepository.selectByStatusAndFofoIds(new ArrayList<>(authfofoIds),
|
- |
|
| 1759 |
ByPassRequestStatus.PENDING);
|
- |
|
| 1760 |
}
|
- |
|
| 1761 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
- |
|
| 1762 |
model.addAttribute("customRetailerMap", customRetailerMap);
|
- |
|
| 1763 |
model.addAttribute("byPassRequest", byPassRequest);
|
- |
|
| 1764 |
return "planogram";
|
- |
|
| 1765 |
}
|
- |
|
| 1766 |
|
- |
|
| 1767 |
@RequestMapping(value = "/byPassRequestAction", method = RequestMethod.PUT)
|
- |
|
| 1768 |
public String addAmountToWalletRequestRejected(HttpServletRequest request,
|
- |
|
| 1769 |
@RequestParam(name = "id", defaultValue = "0") int id, @RequestParam ByPassRequestStatus status,
|
- |
|
| 1770 |
@RequestParam(name = "reason", required = false) String reason, Model model) throws Exception {
|
- |
|
| 1771 |
|
- |
|
| 1772 |
FocusedModelByPassRequest byPassRequest = focusedModelByPassRepository.selectById(id);
|
- |
|
| 1773 |
if (status.equals(ByPassRequestStatus.APPROVED)) {
|
- |
|
| 1774 |
byPassRequest.setByPass(true);
|
- |
|
| 1775 |
byPassRequest.setStatus(ByPassRequestStatus.APPROVED);
|
- |
|
| 1776 |
byPassRequest.setUpdatedTimestamp(LocalDateTime.now());
|
- |
|
| 1777 |
byPassRequest.setReason(reason);
|
- |
|
| 1778 |
} else if (status.equals(ByPassRequestStatus.REJECTED)) {
|
- |
|
| 1779 |
byPassRequest.setByPass(false);
|
- |
|
| 1780 |
byPassRequest.setStatus(ByPassRequestStatus.REJECTED);
|
- |
|
| 1781 |
byPassRequest.setUpdatedTimestamp(LocalDateTime.now());
|
- |
|
| 1782 |
byPassRequest.setReason(reason);
|
- |
|
| 1783 |
}
|
- |
|
| 1784 |
|
- |
|
| 1785 |
com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(byPassRequest.getFofoId());
|
- |
|
| 1786 |
|
- |
|
| 1787 |
Address address = addressRepository.selectById(user.getAddressId());
|
- |
|
| 1788 |
|
- |
|
| 1789 |
String title = "Billing Request";
|
- |
|
| 1790 |
|
- |
|
| 1791 |
String message = String.format("Your Billing Request is " + status
|
- |
|
| 1792 |
+ ". Please ensure to order the missing focus models as soon as possible.");
|
- |
|
| 1793 |
|
- |
|
| 1794 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
- |
|
| 1795 |
sendNotificationModel.setCampaignName("Billing Request");
|
- |
|
| 1796 |
sendNotificationModel.setTitle(title);
|
- |
|
| 1797 |
sendNotificationModel.setMessage(message);
|
- |
|
| 1798 |
sendNotificationModel.setType("url");
|
- |
|
| 1799 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
- |
|
| 1800 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
- |
|
| 1801 |
sendNotificationModel.setMessageType(MessageType.notification);
|
- |
|
| 1802 |
sendNotificationModel
|
- |
|
| 1803 |
.setUserIds(Arrays.asList(userAccountRepository.selectUserIdByRetailerId(byPassRequest.getFofoId())));
|
- |
|
| 1804 |
|
- |
|
| 1805 |
notificationService.sendNotification(sendNotificationModel);
|
- |
|
| 1806 |
|
- |
|
| 1807 |
notificationService.sendWhatsappMessage(message, title, address.getPhoneNumber());
|
- |
|
| 1808 |
|
- |
|
| 1809 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
- |
|
| 1810 |
return "response";
|
- |
|
| 1811 |
}
|
- |
|
| 1812 |
|
- |
|
| 1813 |
@RequestMapping(value = "/highDemandItem", method = RequestMethod.GET)
|
- |
|
| 1814 |
public String highDemandItem(HttpServletRequest request, Model model) throws Exception {
|
- |
|
| 1815 |
List<HighDemandItem> hdis = highDemandItemsRepository.selectAll();
|
- |
|
| 1816 |
if (!hdis.isEmpty()) {
|
- |
|
| 1817 |
Map<Integer, Item> itemMap = this.getItemByCatalogId(hdis);
|
- |
|
| 1818 |
model.addAttribute("itemMap", itemMap);
|
- |
|
| 1819 |
}
|
- |
|
| 1820 |
|
- |
|
| 1821 |
model.addAttribute("hdis", hdis);
|
- |
|
| 1822 |
|
- |
|
| 1823 |
return "high_demand_item";
|
- |
|
| 1824 |
}
|
- |
|
| 1825 |
|
- |
|
| 1826 |
private Map<Integer, Item> getItemByCatalogId(List<HighDemandItem> hdis) {
|
- |
|
| 1827 |
Map<Integer, Item> itemMap = new HashMap<>();
|
- |
|
| 1828 |
for (HighDemandItem hdi : hdis) {
|
- |
|
| 1829 |
List<Item> items = itemRepository.selectAllByCatalogItemId(hdi.getCatalogId());
|
- |
|
| 1830 |
itemMap.put(items.get(0).getCatalogItemId(), items.get(0));
|
- |
|
| 1831 |
}
|
- |
|
| 1832 |
|
- |
|
| 1833 |
return itemMap;
|
- |
|
| 1834 |
}
|
- |
|
| 1835 |
|
- |
|
| 1836 |
@RequestMapping(value = "/addHighDemandItem", method = RequestMethod.POST)
|
- |
|
| 1837 |
public String addHighDemandItem(HttpServletRequest request, @RequestParam int catalogId, @RequestParam int qty,
|
- |
|
| 1838 |
Model model) throws Exception {
|
- |
|
| 1839 |
HighDemandItem hdi = highDemandItemsRepository.selectByFofoIdAndCatalogId(catalogId);
|
- |
|
| 1840 |
|
- |
|
| 1841 |
if (hdi == null) {
|
- |
|
| 1842 |
hdi = new HighDemandItem();
|
- |
|
| 1843 |
hdi.setCatalogId(catalogId);
|
- |
|
| 1844 |
hdi.setQty(qty);
|
- |
|
| 1845 |
hdi.setCreateTimestamp(LocalDateTime.now());
|
- |
|
| 1846 |
hdi.setUpdateTimestamp(LocalDateTime.now());
|
- |
|
| 1847 |
highDemandItemsRepository.persist(hdi);
|
- |
|
| 1848 |
}
|
- |
|
| 1849 |
|
- |
|
| 1850 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
- |
|
| 1851 |
return "response";
|
- |
|
| 1852 |
}
|
- |
|
| 1853 |
|
- |
|
| 1854 |
@RequestMapping(value = "/removeHighDemandItem", method = RequestMethod.DELETE)
|
- |
|
| 1855 |
public String removeHighDemandItem(HttpServletRequest request,
|
- |
|
| 1856 |
@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
- |
|
| 1857 |
highDemandItemsRepository.deleteById(id);
|
- |
|
| 1858 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
- |
|
| 1859 |
return "response";
|
- |
|
| 1860 |
}
|
- |
|
| 1861 |
|
- |
|
| 1862 |
@GetMapping(value = "/imei")
|
- |
|
| 1863 |
public String getImei(HttpServletRequest request, Model model, @RequestParam int fofoId, @RequestParam String query)
|
- |
|
| 1864 |
throws Exception {
|
- |
|
| 1865 |
|
- |
|
| 1866 |
List<String> serialNumber = inventoryItemRepository.selectAllByFofoId(fofoId, query).stream()
|
- |
|
| 1867 |
.map(x -> x.getSerialNumber()).collect(Collectors.toList());
|
- |
|
| 1868 |
LOGGER.info("serialNumber" + serialNumber);
|
- |
|
| 1869 |
LOGGER.info("query" + query);
|
- |
|
| 1870 |
|
- |
|
| 1871 |
model.addAttribute("response1", mvcResponseSender.createResponseString(serialNumber));
|
- |
|
| 1872 |
|
- |
|
| 1873 |
return "response";
|
- |
|
| 1874 |
}
|
- |
|
| 1875 |
|
- |
|
| 1876 |
@Autowired
|
- |
|
| 1877 |
private ObjectMapper objectMapper;
|
- |
|
| 1878 |
|
- |
|
| 1879 |
@RequestMapping(value = "/imei/validate", method = RequestMethod.GET)
|
- |
|
| 1880 |
public String validateImei(HttpServletRequest request, @RequestParam String imei, Model model) throws Exception {
|
- |
|
| 1881 |
boolean isImei = false;
|
- |
|
| 1882 |
|
- |
|
| 1883 |
try {
|
- |
|
| 1884 |
InventoryItem inventoryItem = inventoryItemRepository.selectBySerialNumber(imei);
|
- |
|
| 1885 |
|
- |
|
| 1886 |
isImei = true;
|
- |
|
| 1887 |
|
- |
|
| 1888 |
} catch (Exception e) {
|
- |
|
| 1889 |
isImei = false;
|
- |
|
| 1890 |
}
|
- |
|
| 1891 |
|
- |
|
| 1892 |
model.addAttribute("response1", objectMapper.writeValueAsString(isImei));
|
- |
|
| 1893 |
return "response";
|
- |
|
| 1894 |
}
|
- |
|
| 1895 |
|
- |
|
| 1896 |
@RequestMapping(value = "/createCombo", method = RequestMethod.GET)
|
- |
|
| 1897 |
public String createCombo(HttpServletRequest request, Model model) throws Exception {
|
- |
|
| 1898 |
|
- |
|
| 1899 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
- |
|
| 1900 |
|
- |
|
| 1901 |
List<ComboModel> comboModels = comboModelRepository.selectAll();
|
- |
|
| 1902 |
|
- |
|
| 1903 |
model.addAttribute("warehouseMap", warehouseMap);
|
- |
|
| 1904 |
model.addAttribute("comboModels", comboModels);
|
- |
|
| 1905 |
return "create-combo";
|
- |
|
| 1906 |
}
|
- |
|
| 1907 |
|
- |
|
| 1908 |
@RequestMapping(value = "/addCombo", method = RequestMethod.POST)
|
- |
|
| 1909 |
public String addCombo(HttpServletRequest request, @RequestBody Combo combo, Model model) throws Exception {
|
- |
|
| 1910 |
|
- |
|
| 1911 |
for (Integer warehouseId : combo.getWarehouseId()) {
|
- |
|
| 1912 |
|
- |
|
| 1913 |
ComboModel comboModel = comboModelRepository.selectByCatalogIdWarehouseIdAndQty(combo.getCatalogId(),
|
- |
|
| 1914 |
warehouseId, combo.getQty());
|
- |
|
| 1915 |
if (comboModel != null) {
|
- |
|
| 1916 |
List<ComboMappedModel> comboMappedModels = comboMappedModelRepository
|
- |
|
| 1917 |
.selectByComboId(comboModel.getId());
|
- |
|
| 1918 |
for (ComboMappedModel comboMappedModel : comboMappedModels) {
|
- |
|
| 1919 |
comboMappedModelRepository.delete(comboMappedModel);
|
- |
|
| 1920 |
}
|
- |
|
| 1921 |
|
- |
|
| 1922 |
comboModelRepository.delete(comboModel);
|
- |
|
| 1923 |
}
|
- |
|
| 1924 |
ComboModel cm = new ComboModel();
|
- |
|
| 1925 |
cm.setCatalogId(combo.getCatalogId());
|
- |
|
| 1926 |
cm.setQty(combo.getQty());
|
- |
|
| 1927 |
cm.setWarehouseId(warehouseId);
|
- |
|
| 1928 |
comboModelRepository.persist(cm);
|
- |
|
| 1929 |
|
- |
|
| 1930 |
LOGGER.info("cm" + cm);
|
- |
|
| 1931 |
|
- |
|
| 1932 |
for (MappedComboModel mcc : combo.getMappedComboModel()) {
|
- |
|
| 1933 |
ComboMappedModel cmm = new ComboMappedModel();
|
- |
|
| 1934 |
cmm.setComboCatalogId(mcc.getCatalogId());
|
- |
|
| 1935 |
cmm.setComboQty(mcc.getQty());
|
- |
|
| 1936 |
cmm.setComboId(cm.getId());
|
- |
|
| 1937 |
comboMappedModelRepository.persist(cmm);
|
- |
|
| 1938 |
|
- |
|
| 1939 |
}
|
- |
|
| 1940 |
|
- |
|
| 1941 |
}
|
- |
|
| 1942 |
|
- |
|
| 1943 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
- |
|
| 1944 |
|
- |
|
| 1945 |
return "response";
|
- |
|
| 1946 |
|
- |
|
| 1947 |
}
|
- |
|
| 1948 |
|
- |
|
| 1949 |
@RequestMapping(value = "/combo/remove", method = RequestMethod.POST)
|
- |
|
| 1950 |
public String removeCombo(HttpServletRequest request, @RequestParam int id, Model model) throws Exception {
|
- |
|
| 1951 |
comboMappedModelRepository.deleteByEquals(id);
|
- |
|
| 1952 |
comboModelRepository.deleteById(id);
|
- |
|
| 1953 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
- |
|
| 1954 |
|
99 |
|
| 1955 |
return "response";
|
100 |
List<EscalationType> esclationType = Arrays.asList(EscalationType.L3, EscalationType.L4);
|
| 1956 |
|
101 |
|
| - |
|
102 |
List<String> emails = Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com");
|
| - |
|
103 |
|
| - |
|
104 |
@Autowired
|
| - |
|
105 |
private CookiesProcessor cookiesProcessor;
|
| - |
|
106 |
|
| - |
|
107 |
@Autowired
|
| - |
|
108 |
@Qualifier("fofoInventoryService")
|
| - |
|
109 |
private InventoryService inventoryService;
|
| - |
|
110 |
|
| - |
|
111 |
@Autowired
|
| - |
|
112 |
TagListingRepository tagListingRepository;
|
| - |
|
113 |
|
| - |
|
114 |
@Autowired
|
| - |
|
115 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
| - |
|
116 |
|
| - |
|
117 |
@Autowired
|
| - |
|
118 |
private TagRankingRepository tagRankingRepository;
|
| - |
|
119 |
|
| - |
|
120 |
@Autowired
|
| - |
|
121 |
private InventoryItemRepository inventoryItemRepository;
|
| - |
|
122 |
|
| - |
|
123 |
@Autowired
|
| - |
|
124 |
private LiveDemoBillingRespository liveDemoBillingRespository;
|
| - |
|
125 |
|
| - |
|
126 |
@Autowired
|
| - |
|
127 |
private ItemRepository itemRepository;
|
| - |
|
128 |
|
| - |
|
129 |
@Autowired
|
| - |
|
130 |
private Gson gson;
|
| - |
|
131 |
|
| - |
|
132 |
@Autowired
|
| - |
|
133 |
private RetailerService retailerService;
|
| - |
|
134 |
|
| - |
|
135 |
@Autowired
|
| - |
|
136 |
private MVCResponseSender mvcResponseSender;
|
| - |
|
137 |
|
| - |
|
138 |
@Autowired
|
| - |
|
139 |
FofoStoreRepository fofoStoreRepository;
|
| - |
|
140 |
|
| - |
|
141 |
@Autowired
|
| - |
|
142 |
private OrderRepository orderRepository;
|
| - |
|
143 |
|
| - |
|
144 |
@Autowired
|
| - |
|
145 |
private NotifyItemRepository notifyItemRepository;
|
| - |
|
146 |
|
| - |
|
147 |
@Autowired
|
| - |
|
148 |
private NotifyColorChangeRepository notifyColorChangeRepository;
|
| - |
|
149 |
|
| - |
|
150 |
@Autowired
|
| - |
|
151 |
private NotifyOrderRespository notifyOrderRespository;
|
| - |
|
152 |
|
| - |
|
153 |
@Autowired
|
| - |
|
154 |
private NotificationService notificationService;
|
| - |
|
155 |
|
| - |
|
156 |
@Autowired
|
| - |
|
157 |
private NotifyMessageRepository notifyMessageRepository;
|
| - |
|
158 |
|
| - |
|
159 |
@Autowired
|
| - |
|
160 |
private UserAccountRepository userAccountRepository;
|
| - |
|
161 |
|
| - |
|
162 |
@Autowired
|
| - |
|
163 |
private OrderService orderService;
|
| - |
|
164 |
|
| - |
|
165 |
@Value("${saholic.api.host}")
|
| - |
|
166 |
private String host;
|
| - |
|
167 |
|
| - |
|
168 |
@Value("${saholic.api.port}")
|
| - |
|
169 |
private int port;
|
| - |
|
170 |
|
| - |
|
171 |
@Value("${saholic.api.webapp}")
|
| - |
|
172 |
private String webapp;
|
| - |
|
173 |
|
| - |
|
174 |
@Autowired
|
| - |
|
175 |
JavaMailSender mailSender;
|
| - |
|
176 |
|
| - |
|
177 |
@Autowired
|
| - |
|
178 |
private NotifyCancelOrderRepository notifyCancelOrderRepository;
|
| - |
|
179 |
|
| - |
|
180 |
@Autowired
|
| - |
|
181 |
private WarehousePurchaseOrderRepository warehousePurchaseOrderRepository;
|
| - |
|
182 |
|
| - |
|
183 |
@Autowired
|
| - |
|
184 |
private WarehouseScanRepository warehouseScanRepository;
|
| - |
|
185 |
|
| - |
|
186 |
@Autowired
|
| - |
|
187 |
private FofoOrderRepository fofoOrderRepository;
|
| - |
|
188 |
@Autowired
|
| - |
|
189 |
private Mongo mongoClient;
|
| - |
|
190 |
|
| - |
|
191 |
@Autowired
|
| - |
|
192 |
private FocusedModelByPassRepository focusedModelByPassRepository;
|
| - |
|
193 |
|
| - |
|
194 |
@Autowired
|
| - |
|
195 |
private CsService csService;
|
| - |
|
196 |
|
| - |
|
197 |
@Autowired
|
| - |
|
198 |
AuthRepository authRepository;
|
| - |
|
199 |
|
| - |
|
200 |
@Autowired
|
| - |
|
201 |
PositionRepository positionRepository;
|
| - |
|
202 |
|
| - |
|
203 |
@Autowired
|
| - |
|
204 |
ActivatedImeiRepository activatedImeiRepository;
|
| - |
|
205 |
|
| - |
|
206 |
@Autowired
|
| - |
|
207 |
HighDemandItemsRepository highDemandItemsRepository;
|
| - |
|
208 |
|
| - |
|
209 |
@Autowired
|
| - |
|
210 |
WebOfferRepository webOfferRepository;
|
| - |
|
211 |
|
| - |
|
212 |
@Autowired
|
| - |
|
213 |
ComboModelRepository comboModelRepository;
|
| - |
|
214 |
|
| - |
|
215 |
@Autowired
|
| - |
|
216 |
ComboMappedModelRepository comboMappedModelRepository;
|
| - |
|
217 |
|
| - |
|
218 |
@Autowired
|
| - |
|
219 |
private UserRepository userUserRepository;
|
| - |
|
220 |
|
| - |
|
221 |
@Autowired
|
| - |
|
222 |
private AddressRepository addressRepository;
|
| - |
|
223 |
|
| - |
|
224 |
@RequestMapping(value = "/getCurrentInventorySnapshot")
|
| - |
|
225 |
public String getCurrentAvailability(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, @RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model) throws ProfitMandiBusinessException {
|
| - |
|
226 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
227 |
Map<String, Object> map = inventoryService.getCurrentInventorySnapshot(loginDetails.getFofoId(), offset, limit, searchTerm);
|
| - |
|
228 |
model.addAllAttributes(map);
|
| - |
|
229 |
return "inventory-snapshot";
|
| - |
|
230 |
}
|
| - |
|
231 |
|
| - |
|
232 |
@RequestMapping(value = "/getBadInventorySnapshot")
|
| - |
|
233 |
public String getBadAvailability(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, @RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model) throws ProfitMandiBusinessException {
|
| - |
|
234 |
if (searchTerm == null) {
|
| - |
|
235 |
searchTerm = "";
|
| - |
|
236 |
}
|
| - |
|
237 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
238 |
Map<String, Object> map = inventoryService.getBadInventorySnapshot(loginDetails.getFofoId(), offset, limit, searchTerm);
|
| - |
|
239 |
model.addAllAttributes(map);
|
| - |
|
240 |
return "bad-inventory-snapshot";
|
| - |
|
241 |
}
|
| - |
|
242 |
|
| - |
|
243 |
@RequestMapping(value = "/getPaginatedCurrentInventorySnapshot")
|
| - |
|
244 |
public String getPaginatedCurrentInventorySnapshot(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, @RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model) throws ProfitMandiBusinessException {
|
| - |
|
245 |
if (searchTerm == null) {
|
| - |
|
246 |
searchTerm = "";
|
| - |
|
247 |
}
|
| - |
|
248 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
249 |
Map<String, Object> map = inventoryService.getPaginatedCurrentInventorySnapshot(loginDetails.getFofoId(), offset, limit, searchTerm);
|
| - |
|
250 |
model.addAllAttributes(map);
|
| - |
|
251 |
return "inventory-snapshot-paginated";
|
| - |
|
252 |
}
|
| - |
|
253 |
|
| - |
|
254 |
@RequestMapping(value = "/getCatalog")
|
| - |
|
255 |
public String getCatalog(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "20") int limit, @RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, @RequestParam(name = "itemId", required = false, defaultValue = "0") int itemId, @RequestParam(name = "accesories", required = false, defaultValue = "0") boolean accesories,
|
| - |
|
256 |
|
| - |
|
257 |
@RequestParam(name = "brand", required = false, defaultValue = "") String brand, Model model)
|
| - |
|
258 |
|
| - |
|
259 |
throws ProfitMandiBusinessException {
|
| - |
|
260 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
261 |
if (searchTerm == null) {
|
| - |
|
262 |
searchTerm = "";
|
| - |
|
263 |
}
|
| - |
|
264 |
|
| - |
|
265 |
Map<String, Object> map = inventoryService.getCatalog(loginDetails.getFofoId(), offset, limit, searchTerm, itemId, brand, accesories);
|
| - |
|
266 |
model.addAllAttributes(map);
|
| - |
|
267 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
| - |
|
268 |
|
| - |
|
269 |
return "catalog";
|
| - |
|
270 |
}
|
| - |
|
271 |
|
| - |
|
272 |
@RequestMapping(value = "/getWebOfferByCatalogId")
|
| - |
|
273 |
public String getCatalog(HttpServletRequest request, @RequestParam int catalogItemId, Model model)
|
| - |
|
274 |
|
| - |
|
275 |
throws ProfitMandiBusinessException {
|
| - |
|
276 |
|
| - |
|
277 |
List<WebOffer> webOffers = webOfferRepository.selectAllActiveOffers().get(catalogItemId);
|
| - |
|
278 |
|
| - |
|
279 |
model.addAttribute("webOffers", webOffers);
|
| - |
|
280 |
|
| - |
|
281 |
return "web-offer-model";
|
| - |
|
282 |
}
|
| - |
|
283 |
|
| - |
|
284 |
// This method is currently hardcoded to faciliate watches sold as gift.
|
| - |
|
285 |
private boolean hasGift(int fofoId) {
|
| - |
|
286 |
try {
|
| - |
|
287 |
return currentInventorySnapshotRepository.selectByItemIdAndFofoId(ProfitMandiConstants.GIFT_ID, fofoId).getAvailability() > 0;
|
| - |
|
288 |
} catch (ProfitMandiBusinessException e) {
|
| - |
|
289 |
return false;
|
| - |
|
290 |
}
|
| - |
|
291 |
}
|
| - |
|
292 |
|
| - |
|
293 |
@RequestMapping(value = "/getPaginatedCatalog")
|
| - |
|
294 |
public String getCatalogPaginated(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "20") int limit, @RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, @RequestParam(name = "itemId", required = false, defaultValue = "0") int itemId, @RequestParam(name = "accesories", required = false, defaultValue = "0") boolean accesories, @RequestParam(name = "brand", required = false, defaultValue = "") String brand, Model model) throws ProfitMandiBusinessException {
|
| - |
|
295 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
296 |
if (searchTerm == null) {
|
| - |
|
297 |
searchTerm = "";
|
| - |
|
298 |
}
|
| - |
|
299 |
Map<String, Object> map = inventoryService.getPaginatedCatalog(loginDetails.getFofoId(), offset, limit, searchTerm, itemId, brand, accesories);
|
| - |
|
300 |
model.addAllAttributes(map);
|
| - |
|
301 |
return "catalog-paginated";
|
| - |
|
302 |
}
|
| - |
|
303 |
|
| - |
|
304 |
@RequestMapping(value = "/checkItemAvailability")
|
| - |
|
305 |
public String getItemAvailability(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ITEM_ID) int itemId, Model model) throws ProfitMandiBusinessException {
|
| - |
|
306 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
307 |
CustomCurrentInventorySnapshot customCurrentInventorySnapshot = inventoryService.checkItemAvailability(itemId, loginDetails.getFofoId());
|
| - |
|
308 |
/*
|
| - |
|
309 |
* customCurrentInventorySnapshot
|
| - |
|
310 |
* .setIconUrl(Utils.getIconUrl(customCurrentInventorySnapshot.getCatalogItemId(
|
| - |
|
311 |
* ), host, port, webapp));
|
| - |
|
312 |
*/
|
| - |
|
313 |
model.addAttribute("currentInventorySnapshot", new Gson().toJson(customCurrentInventorySnapshot));
|
| - |
|
314 |
return "current-item-availability";
|
| - |
|
315 |
|
| - |
|
316 |
}
|
| - |
|
317 |
|
| - |
|
318 |
@RequestMapping(value = "/cart", method = RequestMethod.POST)
|
| - |
|
319 |
public String addToCart(HttpServletRequest request, @RequestParam(name = "cartData") String cartData, Model model) throws ProfitMandiBusinessException {
|
| - |
|
320 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
321 |
|
| - |
|
322 |
Map<String, Object> map = inventoryService.addToCart(cartData, loginDetails.getFofoId());
|
| - |
|
323 |
model.addAllAttributes(map);
|
| - |
|
324 |
return "cart";
|
| - |
|
325 |
}
|
| - |
|
326 |
|
| - |
|
327 |
@RequestMapping(value = "/validate-cart", method = RequestMethod.POST)
|
| - |
|
328 |
public String validateCart(HttpServletRequest request, HttpServletResponse response, @RequestParam(name = "cartData") String cartData, Model model) throws ProfitMandiBusinessException {
|
| - |
|
329 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
330 |
|
| - |
|
331 |
Map<String, Object> map = inventoryService.validateCart(cartData, loginDetails.getFofoId());
|
| - |
|
332 |
model.addAllAttributes(map);
|
| - |
|
333 |
return "validate-cart";
|
| - |
|
334 |
}
|
| - |
|
335 |
|
| - |
|
336 |
@RequestMapping(value = "/grnHistory")
|
| - |
|
337 |
public String getGrnHistory(HttpServletRequest request, @RequestParam(required = false) LocalDateTime startTime, @RequestParam(required = false) LocalDateTime endTime, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, @RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE, defaultValue = "") String purchaseReference, @RequestParam(name = "searchType", defaultValue = "") String searchType, Model model) throws ProfitMandiBusinessException {
|
| - |
|
338 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
339 |
Map<String, Object> map = inventoryService.getGrnHistory(loginDetails.getFofoId(), startTime, endTime, offset, limit, purchaseReference, searchType);
|
| - |
|
340 |
model.addAllAttributes(map);
|
| - |
|
341 |
return "grn-history";
|
| - |
|
342 |
}
|
| - |
|
343 |
|
| - |
|
344 |
@RequestMapping(value = "/downloadPurchaseInvoices")
|
| - |
|
345 |
public ResponseEntity<?> downloadPurchaseInvoices(HttpServletRequest request, @RequestParam(required = false) LocalDateTime startTime, @RequestParam(required = false) LocalDateTime endTime, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, @RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE, defaultValue = "") String purchaseReference, @RequestParam(name = "searchType", defaultValue = "") String searchType, Model model) throws ProfitMandiBusinessException {
|
| - |
|
346 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
347 |
Map<String, Object> map = inventoryService.getGrnHistory(loginDetails.getFofoId(), startTime, endTime, offset, limit, purchaseReference, searchType);
|
| - |
|
348 |
|
| - |
|
349 |
List<FofoOrder> fofoOrders = (List<FofoOrder>) map.get("saleHistories");
|
| - |
|
350 |
|
| - |
|
351 |
if (fofoOrders.size() == 0) {
|
| - |
|
352 |
throw new ProfitMandiBusinessException("Search criteria", "", "No orders found for criteria");
|
| - |
|
353 |
}
|
| - |
|
354 |
|
| - |
|
355 |
final HttpHeaders headers = new HttpHeaders();
|
| - |
|
356 |
headers.setContentType(MediaType.APPLICATION_PDF);
|
| - |
|
357 |
headers.set("Content-disposition", "inline; filename=invoices.pdf");
|
| - |
|
358 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
| - |
|
359 |
List<InvoicePdfModel> pdfModels = new ArrayList<>();
|
| - |
|
360 |
PdfUtils.generateAndWrite(pdfModels, byteArrayOutputStream);
|
| - |
|
361 |
headers.setContentLength(byteArrayOutputStream.toByteArray().length);
|
| - |
|
362 |
final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
| - |
|
363 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
| - |
|
364 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
| - |
|
365 |
}
|
| - |
|
366 |
|
| - |
|
367 |
@RequestMapping(value = "/getPaginatedGrnHistory")
|
| - |
|
368 |
public String getPaginatedGrnHistory(HttpServletRequest request, @RequestParam(required = false) LocalDateTime startTime, @RequestParam(required = false) LocalDateTime endTime, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, @RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE, defaultValue = "") String purchaseReference, @RequestParam(name = "searchType", defaultValue = "") String searchType, Model model) throws ProfitMandiBusinessException {
|
| - |
|
369 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
370 |
Map<String, Object> map = inventoryService.getPaginatedGrnHistory(loginDetails.getFofoId(), startTime, endTime, offset, limit);
|
| - |
|
371 |
model.addAllAttributes(map);
|
| - |
|
372 |
return "grn-history-paginated";
|
| - |
|
373 |
}
|
| - |
|
374 |
|
| - |
|
375 |
@RequestMapping(value = "/grnHistoryDetailByPurchaseId")
|
| - |
|
376 |
public String grnHistoryByPurchaseId(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.PURCHASE_ID) int purchaseId, Model model) throws ProfitMandiBusinessException {
|
| - |
|
377 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
378 |
Map<String, Object> map = inventoryService.getGrnHistoryDetail(loginDetails.getFofoId(), purchaseId, host, port, webapp);
|
| - |
|
379 |
model.addAllAttributes(map);
|
| - |
|
380 |
return "grn-details";
|
| - |
|
381 |
}
|
| - |
|
382 |
|
| - |
|
383 |
@RequestMapping(value = "/grnHistoryDetailByPurchaseReference")
|
| - |
|
384 |
public String grnHistoryByPurchaseReference(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE) String purchaseReference, Model model) throws ProfitMandiBusinessException {
|
| - |
|
385 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
386 |
Map<String, Object> map = inventoryService.getGrnHistoryDetail(loginDetails.getFofoId(), purchaseReference, host, port, webapp);
|
| - |
|
387 |
model.addAllAttributes(map);
|
| - |
|
388 |
return "grn-details";
|
| - |
|
389 |
}
|
| - |
|
390 |
|
| - |
|
391 |
@RequestMapping(value = "/activatedImeis")
|
| - |
|
392 |
public String activatedImeis(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
| - |
|
393 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
394 |
|
| - |
|
395 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByActivatedNotSold(loginDetails.getFofoId());
|
| - |
|
396 |
inventoryItems.stream().forEach(x -> {
|
| - |
|
397 |
try {
|
| - |
|
398 |
x.setItem(itemRepository.selectById(x.getItemId()));
|
| - |
|
399 |
} catch (Exception e) {
|
| - |
|
400 |
e.printStackTrace();
|
| - |
|
401 |
}
|
| - |
|
402 |
});
|
| - |
|
403 |
model.addAttribute("inventoryItems", inventoryItems);
|
| - |
|
404 |
return "activated-imeis";
|
| - |
|
405 |
}
|
| - |
|
406 |
|
| - |
|
407 |
@RequestMapping(value = "/activated-imeis-grn-pending")
|
| - |
|
408 |
public String activatedImeisGrnPending(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
| - |
|
409 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
410 |
|
| - |
|
411 |
List<Order> openOrders = orderRepository.selectGrnTimestampNull(loginDetails.getFofoId(), Arrays.asList(OrderStatus.SHIPPED_FROM_WH, OrderStatus.DELIVERY_SUCCESS));
|
| - |
|
412 |
List<ImeiActivationTimestampModel> imeiActivationTimestampModels = activatedImeiRepository.selectActivatedImeisByOrders(openOrders.stream().map(x -> x.getId()).collect(Collectors.toList()));
|
| - |
|
413 |
Map<Integer, Order> ordersMap = openOrders.stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| - |
|
414 |
model.addAttribute("ordersMap", ordersMap);
|
| - |
|
415 |
model.addAttribute("imeiActivationTimestampModels", imeiActivationTimestampModels);
|
| - |
|
416 |
return "activated-imeis-grn-pending";
|
| - |
|
417 |
}
|
| - |
|
418 |
|
| - |
|
419 |
@RequestMapping(value = "/view-invoices")
|
| - |
|
420 |
public String viewInvoices(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
| - |
|
421 |
return "view-dummy-invoices";
|
| - |
|
422 |
}
|
| - |
|
423 |
|
| - |
|
424 |
@RequestMapping(value = "/dummy-invoices")
|
| - |
|
425 |
public ResponseEntity<?> downloadInvoices(HttpServletRequest request, @RequestParam String serialNumber, Model model) throws ProfitMandiBusinessException {
|
| - |
|
426 |
byte[] bytes = null;
|
| - |
|
427 |
if (!imeis.contains(serialNumber)) {
|
| - |
|
428 |
|
| - |
|
429 |
InvoicePdfModel pdfModel = orderService.getDummyPdfModel(serialNumber);
|
| - |
|
430 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
| - |
|
431 |
PdfUtils.generateAndWrite(Arrays.asList(pdfModel), byteArrayOutputStream);
|
| - |
|
432 |
bytes = byteArrayOutputStream.toByteArray();
|
| - |
|
433 |
} else {
|
| - |
|
434 |
ClassPathResource resource = new ClassPathResource("/META-INF/" + serialNumber + ".pdf");
|
| - |
|
435 |
try {
|
| - |
|
436 |
bytes = FileUtils.readFileToByteArray(resource.getFile());
|
| - |
|
437 |
} catch (Exception e) {
|
| - |
|
438 |
|
| - |
|
439 |
}
|
| - |
|
440 |
}
|
| - |
|
441 |
final HttpHeaders headers = new HttpHeaders();
|
| - |
|
442 |
headers.setContentType(MediaType.APPLICATION_PDF);
|
| - |
|
443 |
headers.set("Content-disposition", "inline; filename=invoice-" + serialNumber + ".pdf");
|
| - |
|
444 |
headers.setContentLength(bytes.length);
|
| - |
|
445 |
final InputStream inputStream = new ByteArrayInputStream(bytes);
|
| - |
|
446 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
| - |
|
447 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
| - |
|
448 |
}
|
| - |
|
449 |
|
| - |
|
450 |
@RequestMapping(value = "/dummy-invoices-bulk")
|
| - |
|
451 |
public ResponseEntity<?> downloadInvoicesBulk(HttpServletRequest request, @RequestParam List<String> serialNumbers, Model model) throws Exception {
|
| - |
|
452 |
byte[] bytes = null;
|
| - |
|
453 |
List<Attachment> attachments = new ArrayList<>();
|
| - |
|
454 |
for (String serialNumber : serialNumbers) {
|
| - |
|
455 |
if (!imeis.contains(serialNumber)) {
|
| - |
|
456 |
InvoicePdfModel pdfModel = null;
|
| - |
|
457 |
try {
|
| - |
|
458 |
pdfModel = orderService.getDummyPdfModel(serialNumber);
|
| - |
|
459 |
} catch (Exception e) {
|
| - |
|
460 |
continue;
|
| - |
|
461 |
}
|
| - |
|
462 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
| - |
|
463 |
PdfUtils.generateAndWrite(Arrays.asList(pdfModel), byteArrayOutputStream);
|
| - |
|
464 |
bytes = byteArrayOutputStream.toByteArray();
|
| - |
|
465 |
} else {
|
| - |
|
466 |
ClassPathResource resource = new ClassPathResource("/META-INF/" + serialNumber + ".pdf");
|
| - |
|
467 |
try {
|
| - |
|
468 |
bytes = FileUtils.readFileToByteArray(resource.getFile());
|
| - |
|
469 |
} catch (Exception e) {
|
| - |
|
470 |
continue;
|
| - |
|
471 |
}
|
| - |
|
472 |
}
|
| - |
|
473 |
attachments.add(new Attachment("invoice-" + serialNumber + ".pdf", new ByteArrayResource(bytes)));
|
| - |
|
474 |
}
|
| - |
|
475 |
|
| - |
|
476 |
Utils.sendMailWithAttachments(mailSender, new String[]{"kuldeep.kumar@smartdukaan.com"}, null, "Invoices List", "PFA", attachments.toArray(new Attachment[attachments.size()]));
|
| - |
|
477 |
return new ResponseEntity<Boolean>(true, HttpStatus.OK);
|
| - |
|
478 |
}
|
| - |
|
479 |
|
| - |
|
480 |
@RequestMapping(value = "/getInventoryItemAgingByInterval", method = RequestMethod.POST)
|
| - |
|
481 |
public String getInventoryItemAgingByInterval(HttpServletRequest request, @RequestBody List<Integer> intervals, Model model, @RequestParam(name = "searchContent", defaultValue = "") String searchContent, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit) throws ProfitMandiBusinessException {
|
| - |
|
482 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
483 |
Map<String, Object> map = inventoryService.getPaginatedItemAgingByInterval(loginDetails.getFofoId(), intervals, searchContent, offset, limit);
|
| - |
|
484 |
model.addAllAttributes(map);
|
| - |
|
485 |
return "item-aging";
|
| - |
|
486 |
}
|
| - |
|
487 |
|
| - |
|
488 |
@RequestMapping(value = "/downloadInventoryItemAgingByInterval", method = RequestMethod.POST)
|
| - |
|
489 |
public ResponseEntity<?> downloadInventoryItemAgingByInterval(HttpServletRequest request, @RequestBody List<Integer> intervals, Model model) throws ProfitMandiBusinessException {
|
| - |
|
490 |
LOGGER.info("Request received at url{} with body {}", request.getRequestURI(), intervals);
|
| - |
|
491 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
492 |
|
| - |
|
493 |
List<InventoryItemAgingModel> inventoryItemAgingModels = inventoryService.getItemAgingByInterval(fofoDetails.getFofoId(), intervals);
|
| - |
|
494 |
|
| - |
|
495 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
| - |
|
496 |
ExcelUtils.writeInventoryItemAgingModels(inventoryItemAgingModels, intervals, byteArrayOutputStream);
|
| - |
|
497 |
|
| - |
|
498 |
final HttpHeaders headers = new HttpHeaders();
|
| - |
|
499 |
// private static final String CONTENT_TYPE_XLSX =
|
| - |
|
500 |
// "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
| - |
|
501 |
headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
| - |
|
502 |
// headers.set("Content-Type", "application/vnd.ms-excel");
|
| - |
|
503 |
headers.set("Content-disposition", "inline; filename=InventoryItemAging.xlsx");
|
| - |
|
504 |
headers.setContentLength(byteArrayOutputStream.toByteArray().length);
|
| - |
|
505 |
final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
| - |
|
506 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
| - |
|
507 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
| - |
|
508 |
}
|
| - |
|
509 |
|
| - |
|
510 |
@RequestMapping(value = "/aging-report", method = RequestMethod.GET)
|
| - |
|
511 |
public ResponseEntity<?> downloadInventoryItemAgingByInterval(HttpServletRequest request) throws ProfitMandiBusinessException {
|
| - |
|
512 |
|
| - |
|
513 |
List<Integer> intervals = Arrays.asList(5, 15, 30, 45);
|
| - |
|
514 |
List<InventoryItemAgingModel> inventoryItemAgingModels = inventoryService.getItemAgingByInterval(intervals).values().stream().flatMap(Collection::stream).collect(Collectors.toList());
|
| - |
|
515 |
LOGGER.info("Fofo Id {}", inventoryItemAgingModels.get(0).getFofoId());
|
| - |
|
516 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
| - |
|
517 |
ExcelUtils.writeInventoryItemAgingModels(inventoryItemAgingModels, intervals, byteArrayOutputStream);
|
| - |
|
518 |
|
| - |
|
519 |
final HttpHeaders headers = new HttpHeaders();
|
| - |
|
520 |
// private static final String CONTENT_TYPE_XLSX =
|
| - |
|
521 |
// "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
| - |
|
522 |
headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
| - |
|
523 |
// headers.set("Content-Type", "application/vnd.ms-excel");
|
| - |
|
524 |
headers.set("Content-disposition", "inline; filename=InventoryItemAging.xlsx");
|
| - |
|
525 |
headers.setContentLength(byteArrayOutputStream.toByteArray().length);
|
| - |
|
526 |
final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
| - |
|
527 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
| - |
|
528 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
| - |
|
529 |
}
|
| - |
|
530 |
|
| - |
|
531 |
@RequestMapping(value = "/featurePanel", method = RequestMethod.GET)
|
| - |
|
532 |
public String FeaturePanel(HttpServletRequest request, Model model) throws Exception {
|
| - |
|
533 |
|
| - |
|
534 |
List<TagRanking> tagRanking = null;
|
| - |
|
535 |
tagRanking = tagRankingRepository.getAllTagRanking();
|
| - |
|
536 |
LOGGER.info("tagRanking" + tagRanking);
|
| - |
|
537 |
if (!tagRanking.isEmpty()) {
|
| - |
|
538 |
Set<Integer> catalogIds = tagRanking.stream().map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
|
| - |
|
539 |
List<Item> items = itemRepository.selectAllByCatalogIds(catalogIds);
|
| - |
|
540 |
Map<Integer, String> catalogDescription = items.stream().collect(Collectors.toMap(x -> x.getCatalogItemId(), x -> x.getItemDescription(), (description1, description2) -> description1));
|
| - |
|
541 |
|
| - |
|
542 |
LOGGER.info("catalogDescription" + catalogDescription);
|
| - |
|
543 |
model.addAttribute("tagRanking", tagRanking);
|
| - |
|
544 |
model.addAttribute("catalogDescription", catalogDescription);
|
| - |
|
545 |
|
| - |
|
546 |
} else {
|
| - |
|
547 |
model.addAttribute("tagRanking", tagRanking);
|
| - |
|
548 |
|
| - |
|
549 |
}
|
| - |
|
550 |
|
| - |
|
551 |
return "feature";
|
| - |
|
552 |
|
| - |
|
553 |
}
|
| - |
|
554 |
|
| - |
|
555 |
@PostMapping(value = "/imei/upload")
|
| - |
|
556 |
public String uploadContent(HttpServletRequest request, @RequestPart("file") MultipartFile file, Model model) throws Exception {
|
| - |
|
557 |
/*
|
| - |
|
558 |
* if(brand==null) { throw new
|
| - |
|
559 |
* ProfitMandiBusinessException("Please select brand", "Brand empty",
|
| - |
|
560 |
* "Brand required"); }
|
| - |
|
561 |
*/
|
| - |
|
562 |
List<CSVRecord> masterDataList = readFile(file);
|
| - |
|
563 |
|
| - |
|
564 |
Map<String, LocalDateTime> imeisActivationMap = masterDataList.stream().collect(Collectors.toMap(x -> x.get(0).trim(), x -> {
|
| - |
|
565 |
if (!StringUtils.isEmpty(x.get(1).trim())) {
|
| - |
|
566 |
return LocalDateTime.parse((String) (x.get(1).trim()), formatter);
|
| - |
|
567 |
} else {
|
| - |
|
568 |
return null;
|
| - |
|
569 |
}
|
| - |
|
570 |
}));
|
| - |
|
571 |
inventoryService.addActivatedImeis(imeisActivationMap);
|
| - |
|
572 |
model.addAttribute("response1", true);
|
| - |
|
573 |
return "response";
|
| - |
|
574 |
}
|
| - |
|
575 |
|
| - |
|
576 |
private List<CSVRecord> readFile(MultipartFile file) throws Exception {
|
| - |
|
577 |
List<CSVRecord> records = null;
|
| - |
|
578 |
try (CSVParser parser = new CSVParser(new InputStreamReader(file.getInputStream()), CSVFormat.DEFAULT)) {
|
| - |
|
579 |
records = parser.getRecords();
|
| - |
|
580 |
if (records.size() < 2) {
|
| - |
|
581 |
throw new ProfitMandiBusinessException("Uploaded File", "", "No records Found");
|
| - |
|
582 |
}
|
| - |
|
583 |
records.remove(0);
|
| - |
|
584 |
} catch (Exception e) {
|
| - |
|
585 |
throw new ProfitMandiBusinessException("Parsing Failed", "parse failed", "file parse failed");
|
| - |
|
586 |
}
|
| - |
|
587 |
return records;
|
| - |
|
588 |
}
|
| - |
|
589 |
|
| - |
|
590 |
@RequestMapping(value = "/itemfeature", method = RequestMethod.POST)
|
| - |
|
591 |
public String Itemfeature(HttpServletRequest request, @RequestBody ItemFeatureDataModel itemFeatureDatatModel, Model model) throws Exception {
|
| - |
|
592 |
TagRanking tagRanking = tagRankingRepository.selectBycatalogItemId(itemFeatureDatatModel.getCatalogItemId());
|
| - |
|
593 |
LOGGER.info("tagRanking" + tagRanking);
|
| - |
|
594 |
if (tagRanking == null) {
|
| - |
|
595 |
tagRanking = new TagRanking();
|
| - |
|
596 |
tagRanking.setCatalogItemId(itemFeatureDatatModel.getCatalogItemId());
|
| - |
|
597 |
}
|
| - |
|
598 |
tagRanking.setFeature(itemFeatureDatatModel.getFeature());
|
| - |
|
599 |
tagRanking.setRankPoints(itemFeatureDatatModel.getRankPoints());
|
| - |
|
600 |
|
| - |
|
601 |
tagRankingRepository.persist(tagRanking);
|
| - |
|
602 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| - |
|
603 |
return "response";
|
| - |
|
604 |
}
|
| - |
|
605 |
|
| - |
|
606 |
@RequestMapping(value = "/removeFeature", method = RequestMethod.DELETE)
|
| - |
|
607 |
public String removeTagRankingEnteries(HttpServletRequest request, @RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
| - |
|
608 |
|
| - |
|
609 |
tagRankingRepository.deleteById(id);
|
| - |
|
610 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| - |
|
611 |
return "response";
|
| - |
|
612 |
}
|
| - |
|
613 |
|
| - |
|
614 |
@RequestMapping(value = "/getDemolistbyfofoId", method = RequestMethod.GET)
|
| - |
|
615 |
public String DemoListbyFofoId(HttpServletRequest request, @RequestParam(required = false, defaultValue = "0") int fofoId, Model model) throws Exception {
|
| - |
|
616 |
|
| - |
|
617 |
List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().map(x -> x.getId()).collect(Collectors.toList());
|
| - |
|
618 |
|
| - |
|
619 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
| - |
|
620 |
Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> customRetailerMap.get(x)).filter(x -> x != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
| - |
|
621 |
String customRetailers = JSONObject.valueToString(customRetailersMap.values());
|
| - |
|
622 |
List<String> serailNumberList = liveDemoBillingRespository.selectAllSerialNumber();
|
| - |
|
623 |
LOGGER.info("serailNumberList" + serailNumberList);
|
| - |
|
624 |
List<InventoryItem> inventoryItem = null;
|
| - |
|
625 |
List<InventoryItem> inventoryItem1 = new ArrayList<>();
|
| - |
|
626 |
if (fofoId > 0) {
|
| - |
|
627 |
List<Item> items = itemRepository.selectAllByBrand("Live Demo");
|
| - |
|
628 |
Set<Integer> itemIds = new HashSet<>();
|
| - |
|
629 |
for (Item Item : items) {
|
| - |
|
630 |
itemIds.add(Item.getId());
|
| - |
|
631 |
}
|
| - |
|
632 |
inventoryItem = inventoryItemRepository.selectByFofoIdItemIds(fofoId, itemIds);
|
| - |
|
633 |
|
| - |
|
634 |
Set<String> serial = new HashSet<>();
|
| - |
|
635 |
for (InventoryItem invItem : inventoryItem) {
|
| - |
|
636 |
if (!serailNumberList.contains(invItem.getSerialNumber())) {
|
| - |
|
637 |
inventoryItem1.add(invItem);
|
| - |
|
638 |
|
| - |
|
639 |
}
|
| - |
|
640 |
|
| - |
|
641 |
}
|
| - |
|
642 |
|
| - |
|
643 |
LOGGER.info("inventoyItem" + inventoryItem1);
|
| - |
|
644 |
model.addAttribute("customRetailers", customRetailers);
|
| - |
|
645 |
|
| - |
|
646 |
model.addAttribute("liveDemo", inventoryItem1);
|
| - |
|
647 |
CustomRetailer fofoIdsAndRetailerName = retailerService.getFofoRetailer(fofoId);
|
| - |
|
648 |
|
| - |
|
649 |
model.addAttribute("fofoIdsAndRetailerName", fofoIdsAndRetailerName);
|
| - |
|
650 |
|
| - |
|
651 |
}
|
| - |
|
652 |
|
| - |
|
653 |
else {
|
| - |
|
654 |
model.addAttribute("customRetailers", customRetailers);
|
| - |
|
655 |
model.addAttribute("liveDemo", inventoryItem1);
|
| - |
|
656 |
}
|
| - |
|
657 |
|
| - |
|
658 |
return "live_demo_billing";
|
| - |
|
659 |
|
| - |
|
660 |
}
|
| - |
|
661 |
|
| - |
|
662 |
@RequestMapping(value = "/enableliveDemoSerailNumber", method = RequestMethod.POST)
|
| - |
|
663 |
public String EnableliveDemoSerailNumber(HttpServletRequest request, @RequestParam String serial_number, Model model) throws Exception {
|
| - |
|
664 |
|
| - |
|
665 |
LiveDemoSerialNumber liveDemoSerialNumber = new LiveDemoSerialNumber();
|
| - |
|
666 |
liveDemoSerialNumber.setSerialNumber(serial_number);
|
| - |
|
667 |
|
| - |
|
668 |
liveDemoBillingRespository.persist(liveDemoSerialNumber);
|
| - |
|
669 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| - |
|
670 |
return "response";
|
| - |
|
671 |
}
|
| - |
|
672 |
|
| - |
|
673 |
@RequestMapping(value = "/getInProcessOrder", method = RequestMethod.GET)
|
| - |
|
674 |
public String getInProcessOrder(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
| - |
|
675 |
|
| - |
|
676 |
List<com.spice.profitmandi.dao.entity.transaction.Order> inProcessorder = orderRepository.selectAllOrder(OrderStatus.SUBMITTED_FOR_PROCESSING);
|
| - |
|
677 |
List<Integer> retailerIds = new ArrayList<>();
|
| - |
|
678 |
List<Integer> orderIds = new ArrayList<>();
|
| - |
|
679 |
if (!inProcessorder.isEmpty()) {
|
| - |
|
680 |
for (com.spice.profitmandi.dao.entity.transaction.Order order : inProcessorder) {
|
| - |
|
681 |
retailerIds.add(order.getRetailerId());
|
| - |
|
682 |
orderIds.add(order.getId());
|
| - |
|
683 |
|
| - |
|
684 |
}
|
| - |
|
685 |
|
| - |
|
686 |
List<NotifyOrder> notify = notifyOrderRespository.selectByorderIds(orderIds);
|
| - |
|
687 |
for (NotifyOrder notifyOrder : notify) {
|
| - |
|
688 |
|
| - |
|
689 |
Order orderdetail = orderRepository.selectById(notifyOrder.getOrderId());
|
| - |
|
690 |
if (!orderdetail.getStatus().equals(OrderStatus.SUBMITTED_FOR_PROCESSING)) {
|
| - |
|
691 |
notifyOrder.setStatus(NotifyStatus.rejected);
|
| - |
|
692 |
}
|
| - |
|
693 |
}
|
| - |
|
694 |
|
| - |
|
695 |
Map<Integer, Optional<NotifyOrder>> notifyOrders = notifyOrderRespository.selectByorderIds(orderIds).stream().collect(Collectors.groupingBy(NotifyOrder::getOrderId, Collectors.maxBy((x1, x2) -> x1.getId() - x2.getId())));
|
| - |
|
696 |
|
| - |
|
697 |
Map<Integer, NotifyCancel> notifyCancelOrders = notifyCancelOrderRepository.selectByOrderIds(orderIds).stream().collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
|
| - |
|
698 |
Map<Integer, String> storeIdAndFofoIdMap = fofoStoreRepository.selectByRetailerIds(retailerIds).stream().collect(Collectors.toMap(FofoStore::getId, FofoStore::getCode));
|
| - |
|
699 |
|
| - |
|
700 |
model.addAttribute("inProcessorder", inProcessorder);
|
| - |
|
701 |
model.addAttribute("storeIdAndFofoIdMap", storeIdAndFofoIdMap);
|
| - |
|
702 |
model.addAttribute("latestNotifyOrders", notifyOrders);
|
| - |
|
703 |
model.addAttribute("notifyCancelOrders", notifyCancelOrders);
|
| - |
|
704 |
} else {
|
| - |
|
705 |
model.addAttribute("inProcessorder", inProcessorder);
|
| - |
|
706 |
}
|
| - |
|
707 |
return "review_order";
|
| - |
|
708 |
}
|
| - |
|
709 |
|
| - |
|
710 |
@RequestMapping(value = "/getPaymentPendingOrder", method = RequestMethod.GET)
|
| - |
|
711 |
public String getPaymentPendingOrder(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
| - |
|
712 |
|
| - |
|
713 |
List<com.spice.profitmandi.dao.entity.transaction.Order> pendingPaymentorder = orderRepository.selectAllOrderDatesBetweenByStatus(LocalDateTime.now().minusMonths(3), LocalDateTime.now(), OrderStatus.PAYMENT_PENDING);
|
| - |
|
714 |
List<com.spice.profitmandi.dao.entity.transaction.Order> failedPaymentorder = orderRepository.selectAllOrderDatesBetweenByStatus(LocalDateTime.now().minusMonths(3), LocalDateTime.now(), OrderStatus.PAYMENT_FAILED);
|
| - |
|
715 |
pendingPaymentorder.addAll(failedPaymentorder);
|
| - |
|
716 |
model.addAttribute("pendingPaymentorder", pendingPaymentorder);
|
| - |
|
717 |
|
| - |
|
718 |
return "payment-pending-order";
|
| - |
|
719 |
}
|
| - |
|
720 |
|
| - |
|
721 |
@RequestMapping(value = "/getKeepInTabOrder", method = RequestMethod.GET)
|
| - |
|
722 |
public String getKeepInTabOrder(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
| - |
|
723 |
|
| - |
|
724 |
List<com.spice.profitmandi.dao.entity.transaction.Order> keepatab = orderRepository.selectAllOrder(OrderStatus.KEEP_A_TAB);
|
| - |
|
725 |
|
| - |
|
726 |
model.addAttribute("keepatab", keepatab);
|
| - |
|
727 |
|
| - |
|
728 |
return "keep-a-tab";
|
| - |
|
729 |
}
|
| - |
|
730 |
|
| - |
|
731 |
@RequestMapping(value = "/closeOrder", method = RequestMethod.POST)
|
| - |
|
732 |
public String closeOrder(HttpServletRequest request, @RequestParam int orderId, Model model) throws Exception {
|
| - |
|
733 |
|
| - |
|
734 |
Order order = orderRepository.selectById(orderId);
|
| - |
|
735 |
if (order != null) {
|
| - |
|
736 |
order.setStatus(OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY);
|
| - |
|
737 |
|
| - |
|
738 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| - |
|
739 |
|
| - |
|
740 |
} else {
|
| - |
|
741 |
model.addAttribute("response1", mvcResponseSender.createResponseString(false));
|
| - |
|
742 |
|
| - |
|
743 |
}
|
| - |
|
744 |
return "response";
|
| - |
|
745 |
}
|
| - |
|
746 |
|
| - |
|
747 |
@RequestMapping(value = "/getcancelOrderItems", method = RequestMethod.GET)
|
| - |
|
748 |
public String getcancelOrderItems(HttpServletRequest request, @RequestParam int itemId, Model model) throws Exception {
|
| - |
|
749 |
|
| - |
|
750 |
List<Order> inProcessselectedOrder = orderRepository.selectByItemIdOrderStatus(itemId, OrderStatus.SUBMITTED_FOR_PROCESSING);
|
| - |
|
751 |
|
| - |
|
752 |
List<Integer> retailerIds = new ArrayList<>();
|
| - |
|
753 |
for (com.spice.profitmandi.dao.entity.transaction.Order order : inProcessselectedOrder) {
|
| - |
|
754 |
retailerIds.add(order.getRetailerId());
|
| - |
|
755 |
|
| - |
|
756 |
}
|
| - |
|
757 |
|
| - |
|
758 |
Map<Integer, String> storeIdAndFofoIdMap = fofoStoreRepository.selectByRetailerIds(retailerIds).stream().collect(Collectors.toMap(FofoStore::getId, FofoStore::getCode));
|
| - |
|
759 |
|
| - |
|
760 |
model.addAttribute("inProcessCancelOrder", inProcessselectedOrder);
|
| - |
|
761 |
model.addAttribute("storeIdAndFofoIdMap", storeIdAndFofoIdMap);
|
| - |
|
762 |
|
| - |
|
763 |
return "cancel-order-modal";
|
| - |
|
764 |
}
|
| - |
|
765 |
|
| - |
|
766 |
@RequestMapping(value = "/cancelOrder", method = RequestMethod.POST)
|
| - |
|
767 |
public String cancelOrder(HttpServletRequest request, @RequestBody OrderCancellationModel orderCancellationModel, Model model) throws Exception {
|
| - |
|
768 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
769 |
LOGGER.info("orderId" + orderCancellationModel.getOrderIds());
|
| - |
|
770 |
|
| - |
|
771 |
try {
|
| - |
|
772 |
// List<Order> orders =
|
| - |
|
773 |
// orderRepository.selectByOrderIds(orderCancellationModel.getOrderIds());
|
| - |
|
774 |
|
| - |
|
775 |
List<Order> orders = orderRepository.selectByOrderIdsOrdersStatus(orderCancellationModel.getOrderIds(), OrderStatus.SUBMITTED_FOR_PROCESSING);
|
| - |
|
776 |
if (!orders.isEmpty()) {
|
| - |
|
777 |
for (Order order : orders) {
|
| - |
|
778 |
|
| - |
|
779 |
orderRepository.refundOrder(order.getId(), loginDetails.getEmailId(), orderCancellationModel.getReason(), OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY);
|
| - |
|
780 |
List<NotifyOrder> notifyOrders = notifyOrderRespository.selectByOrder(order.getId());
|
| - |
|
781 |
for (NotifyOrder notifyOrder : notifyOrders) {
|
| - |
|
782 |
if (notifyOrder.getStatus() == NotifyStatus.pending) {
|
| - |
|
783 |
notifyOrder.setStatus(NotifyStatus.rejected);
|
| - |
|
784 |
}
|
| - |
|
785 |
}
|
| - |
|
786 |
sendCancellationNotificationToPartner(order, orderCancellationModel.getReason());
|
| - |
|
787 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| - |
|
788 |
|
| - |
|
789 |
}
|
| - |
|
790 |
}
|
| - |
|
791 |
} catch (TransactionServiceException | TException e) {
|
| - |
|
792 |
model.addAttribute("response1", mvcResponseSender.createResponseString(false));
|
| - |
|
793 |
|
| - |
|
794 |
}
|
| - |
|
795 |
|
| - |
|
796 |
return "response";
|
| - |
|
797 |
}
|
| - |
|
798 |
|
| - |
|
799 |
private void sendCancellationNotificationToPartner(Order order, String reason) throws Exception {
|
| - |
|
800 |
Item item = itemRepository.selectById(order.getLineItem().getItemId());
|
| - |
|
801 |
|
| - |
|
802 |
String title = "Order Cancellation";
|
| - |
|
803 |
String message = String.format("Order %s %d(Pcs) has been cancelled", item.getItemDescription(), order.getLineItem().getQuantity());
|
| - |
|
804 |
|
| - |
|
805 |
com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(order.getRetailerId());
|
| - |
|
806 |
|
| - |
|
807 |
Address address = addressRepository.selectById(user.getAddressId());
|
| - |
|
808 |
|
| - |
|
809 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| - |
|
810 |
sendNotificationModel.setCampaignName(title);
|
| - |
|
811 |
sendNotificationModel.setTitle(message);
|
| - |
|
812 |
sendNotificationModel.setType("url");
|
| - |
|
813 |
sendNotificationModel.setMessage(reason);
|
| - |
|
814 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/orderDetails");
|
| - |
|
815 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
|
| - |
|
816 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| - |
|
817 |
int userId = userAccountRepository.selectUserIdByRetailerId(order.getRetailerId());
|
| - |
|
818 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
| - |
|
819 |
notificationService.sendNotification(sendNotificationModel);
|
| - |
|
820 |
|
| - |
|
821 |
// notificationService.sendWhatsappMessage(message, title,
|
| - |
|
822 |
// address.getPhoneNumber());
|
| - |
|
823 |
|
| - |
|
824 |
}
|
| - |
|
825 |
|
| - |
|
826 |
@RequestMapping(value = "/getNotifyItemColor", method = RequestMethod.GET)
|
| - |
|
827 |
public String getNotifyItemColor(HttpServletRequest request, @RequestParam int catalogItemId, @RequestParam int itemId, Model model) throws ProfitMandiBusinessException {
|
| - |
|
828 |
|
| - |
|
829 |
List<Item> availableColorItems = itemRepository.selectAllByCatalogItemId(catalogItemId);
|
| - |
|
830 |
Iterator<Item> itemsIterator = availableColorItems.iterator();
|
| - |
|
831 |
|
| - |
|
832 |
while (itemsIterator.hasNext()) {
|
| - |
|
833 |
Item item = itemsIterator.next();
|
| - |
|
834 |
TagListing itemTagListing = tagListingRepository.selectByItemId(item.getId());
|
| - |
|
835 |
|
| - |
|
836 |
if (itemTagListing == null) {
|
| - |
|
837 |
itemsIterator.remove();
|
| - |
|
838 |
|
| - |
|
839 |
}
|
| - |
|
840 |
|
| - |
|
841 |
else if (!itemTagListing.isActive()) {
|
| - |
|
842 |
itemsIterator.remove();
|
| - |
|
843 |
|
| - |
|
844 |
}
|
| - |
|
845 |
}
|
| - |
|
846 |
|
| - |
|
847 |
List<Order> inProcessselectedOrder = orderRepository.selectByItemIdOrderStatus(itemId, OrderStatus.SUBMITTED_FOR_PROCESSING);
|
| - |
|
848 |
List<Integer> retailerIds = new ArrayList<>();
|
| - |
|
849 |
|
| - |
|
850 |
for (com.spice.profitmandi.dao.entity.transaction.Order order : inProcessselectedOrder) {
|
| - |
|
851 |
retailerIds.add(order.getRetailerId());
|
| - |
|
852 |
|
| - |
|
853 |
}
|
| - |
|
854 |
|
| - |
|
855 |
Map<Integer, String> storeIdAndFofoIdMap = fofoStoreRepository.selectByRetailerIds(retailerIds).stream().collect(Collectors.toMap(FofoStore::getId, FofoStore::getCode));
|
| - |
|
856 |
LOGGER.info("item" + availableColorItems);
|
| - |
|
857 |
model.addAttribute("item", availableColorItems);
|
| - |
|
858 |
model.addAttribute("inProcessselectedOrder", inProcessselectedOrder);
|
| - |
|
859 |
model.addAttribute("storeIdAndFofoIdMap", storeIdAndFofoIdMap);
|
| - |
|
860 |
|
| - |
|
861 |
return "notify-order-modal";
|
| - |
|
862 |
}
|
| - |
|
863 |
|
| - |
|
864 |
@RequestMapping(value = "/notifyOrder", method = RequestMethod.POST)
|
| - |
|
865 |
public String NotifyOrder(HttpServletRequest request, @RequestBody NotifyOrderModel notifyOrderModel, Model model) throws Exception {
|
| - |
|
866 |
|
| - |
|
867 |
com.spice.profitmandi.dao.entity.transaction.NotifyItem notifyItem = null;
|
| - |
|
868 |
List<Integer> orderIds = new ArrayList<>();
|
| - |
|
869 |
|
| - |
|
870 |
NotifyColorChange notifytimestamp = new NotifyColorChange();
|
| - |
|
871 |
notifytimestamp.setCreated(LocalDateTime.now());
|
| - |
|
872 |
notifyColorChangeRepository.persist(notifytimestamp);
|
| - |
|
873 |
NotifyMessage notifyMessage = new NotifyMessage();
|
| - |
|
874 |
notifyMessage.setNotifyId(notifytimestamp.getId());
|
| - |
|
875 |
notifyMessage.setNotifyMessages(notifyOrderModel.getMessage());
|
| - |
|
876 |
notifyMessageRepository.persist(notifyMessage);
|
| - |
|
877 |
for (NotifyItemIdModel itemid : notifyOrderModel.getItemIds()) {
|
| - |
|
878 |
|
| - |
|
879 |
notifyItem = new com.spice.profitmandi.dao.entity.transaction.NotifyItem();
|
| - |
|
880 |
notifyItem.setItemId(itemid.getItemId());
|
| - |
|
881 |
notifyItem.setResponseTime(itemid.getResponseTime());
|
| - |
|
882 |
notifyItem.setProcuredDate(itemid.getProcuredTime());
|
| - |
|
883 |
notifyItem.setNotifyColorchangeId(notifytimestamp.getId());
|
| - |
|
884 |
notifyItemRepository.persist(notifyItem);
|
| - |
|
885 |
LOGGER.info("notifyItem" + notifyItem);
|
| - |
|
886 |
}
|
| - |
|
887 |
for (NotifyOrderIdModel st : notifyOrderModel.getOrderIds()) {
|
| - |
|
888 |
List<NotifyOrder> existingOrder = notifyOrderRespository.selectByOrder(st.getOrderId());
|
| - |
|
889 |
if (!existingOrder.isEmpty()) {
|
| - |
|
890 |
LOGGER.info("existingOrder" + existingOrder);
|
| - |
|
891 |
for (NotifyOrder notifyOrder : existingOrder) {
|
| - |
|
892 |
if (NotifyStatus.pending == notifyOrder.getStatus()) {
|
| - |
|
893 |
notifyOrder.setStatus(NotifyStatus.rejected);
|
| - |
|
894 |
notifyOrder.setUpdateTimestamp(LocalDateTime.now());
|
| - |
|
895 |
}
|
| - |
|
896 |
}
|
| - |
|
897 |
}
|
| - |
|
898 |
NotifyOrder orderStatus = new NotifyOrder();
|
| - |
|
899 |
orderStatus.setOrderId(st.getOrderId());
|
| - |
|
900 |
orderStatus.setNotifyId(notifytimestamp.getId());
|
| - |
|
901 |
orderStatus.setItemId(st.getOlditemId());
|
| - |
|
902 |
Order id = orderRepository.selectById(st.getOrderId());
|
| - |
|
903 |
orderStatus.setFofoId(id.getRetailerId());
|
| - |
|
904 |
orderStatus.setStatus(NotifyStatus.pending);
|
| - |
|
905 |
notifyOrderRespository.persist(orderStatus);
|
| - |
|
906 |
|
| - |
|
907 |
LOGGER.info("itemStatus" + orderStatus);
|
| - |
|
908 |
orderIds.add(st.getOrderId());
|
| - |
|
909 |
}
|
| - |
|
910 |
|
| - |
|
911 |
LOGGER.info("orderIds" + orderIds);
|
| - |
|
912 |
List<Order> orders = orderRepository.selectByOrderIds(orderIds);
|
| - |
|
913 |
for (Order order : orders) {
|
| - |
|
914 |
LOGGER.info("order" + order.getId());
|
| - |
|
915 |
|
| - |
|
916 |
String title = "Alert!";
|
| - |
|
917 |
|
| - |
|
918 |
NotifyMessage message = notifyMessageRepository.selectByNotifyId(notifytimestamp.getId());
|
| - |
|
919 |
|
| - |
|
920 |
com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(order.getRetailerId());
|
| - |
|
921 |
|
| - |
|
922 |
Address address = addressRepository.selectById(user.getAddressId());
|
| - |
|
923 |
|
| - |
|
924 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| - |
|
925 |
sendNotificationModel.setCampaignName("Notify Partner");
|
| - |
|
926 |
sendNotificationModel.setMessage(message.getNotifyMessages());
|
| - |
|
927 |
sendNotificationModel.setType("url");
|
| - |
|
928 |
sendNotificationModel.setTitle("Alert");
|
| - |
|
929 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifyOrder");
|
| - |
|
930 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
|
| - |
|
931 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| - |
|
932 |
int userId = userAccountRepository.selectUserIdByRetailerId(order.getRetailerId());
|
| - |
|
933 |
|
| - |
|
934 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
| - |
|
935 |
notificationService.sendNotification(sendNotificationModel);
|
| - |
|
936 |
|
| - |
|
937 |
// notificationService.sendWhatsappMessage(message.getNotifyMessages(), title,
|
| - |
|
938 |
// address.getPhoneNumber());
|
| - |
|
939 |
|
| - |
|
940 |
}
|
| - |
|
941 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| - |
|
942 |
return "response";
|
| - |
|
943 |
}
|
| - |
|
944 |
|
| - |
|
945 |
@RequestMapping(value = "/getAllNotifyOrder", method = RequestMethod.GET)
|
| - |
|
946 |
public String getAllNotifyOrder(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
| - |
|
947 |
List<NotifyOrder> notifyOrders = null;
|
| - |
|
948 |
List<com.spice.profitmandi.dao.entity.transaction.Order> inProcessorder = orderRepository.selectAllOrder(OrderStatus.SUBMITTED_FOR_PROCESSING);
|
| - |
|
949 |
|
| - |
|
950 |
List<Integer> orderIds = new ArrayList<>();
|
| - |
|
951 |
if (!inProcessorder.isEmpty()) {
|
| - |
|
952 |
for (com.spice.profitmandi.dao.entity.transaction.Order order : inProcessorder) {
|
| - |
|
953 |
|
| - |
|
954 |
orderIds.add(order.getId());
|
| - |
|
955 |
|
| - |
|
956 |
}
|
| - |
|
957 |
notifyOrders = notifyOrderRespository.selectByorderIds(orderIds);
|
| - |
|
958 |
Set<Integer> oldItemIds = new HashSet<>();
|
| - |
|
959 |
List<Integer> fofoIds = new ArrayList<>();
|
| - |
|
960 |
List<Integer> notifyIds = new ArrayList<>();
|
| - |
|
961 |
if (!notifyOrders.isEmpty()) {
|
| - |
|
962 |
for (NotifyOrder notifyOrder : notifyOrders) {
|
| - |
|
963 |
oldItemIds.add(notifyOrder.getItemId());
|
| - |
|
964 |
fofoIds.add(notifyOrder.getFofoId());
|
| - |
|
965 |
notifyIds.add(notifyOrder.getNotifyId());
|
| - |
|
966 |
}
|
| - |
|
967 |
|
| - |
|
968 |
List<NotifyColorChange> notifyColorChanges = notifyColorChangeRepository.selectByNotifyId(notifyIds);
|
| - |
|
969 |
Map<Integer, NotifyColorChange> notifyIdNotifyColorMap = this.notifyOrdersToNotifyId(notifyColorChanges);
|
| - |
|
970 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
| - |
|
971 |
Map<Integer, CustomRetailer> fofoIdsAndRetailerName = fofoIds.stream().distinct().map(x -> customRetailerMap.get(x)).filter(x -> x != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
| - |
|
972 |
Map<Integer, String> itemdescription = inventoryService.getItemIdDescriptionMap(oldItemIds);
|
| - |
|
973 |
|
| - |
|
974 |
model.addAttribute("notifyOrders", notifyOrders);
|
| - |
|
975 |
model.addAttribute("notifyIdNotifyColorMap", notifyIdNotifyColorMap);
|
| - |
|
976 |
model.addAttribute("itemdescription", itemdescription);
|
| - |
|
977 |
model.addAttribute("fofoIdsAndRetailerName", fofoIdsAndRetailerName);
|
| - |
|
978 |
|
| - |
|
979 |
} else {
|
| - |
|
980 |
model.addAttribute("notifyOrders", notifyOrders);
|
| - |
|
981 |
}
|
| - |
|
982 |
} else {
|
| - |
|
983 |
model.addAttribute("notifyOrders", notifyOrders);
|
| - |
|
984 |
}
|
| - |
|
985 |
return "notify_order";
|
| - |
|
986 |
}
|
| - |
|
987 |
|
| - |
|
988 |
private Map<Integer, NotifyColorChange> notifyOrdersToNotifyId(List<NotifyColorChange> notifyColorChanges) {
|
| - |
|
989 |
Map<Integer, NotifyColorChange> notifyIdNotifyColorMap = new HashMap<>();
|
| - |
|
990 |
for (NotifyColorChange notifyColorChange : notifyColorChanges) {
|
| - |
|
991 |
notifyIdNotifyColorMap.put(notifyColorChange.getId(), notifyColorChange);
|
| - |
|
992 |
}
|
| - |
|
993 |
return notifyIdNotifyColorMap;
|
| - |
|
994 |
}
|
| - |
|
995 |
|
| - |
|
996 |
@RequestMapping(value = "/getItems", method = RequestMethod.GET)
|
| - |
|
997 |
public String getItems(HttpServletRequest request, @RequestParam int catalogItemId, Model model) throws Exception {
|
| - |
|
998 |
|
| - |
|
999 |
Set<Integer> itemIds = itemRepository.selectAllByCatalogItemId(catalogItemId).stream().map(x -> x.getId()).collect(Collectors.toSet());
|
| - |
|
1000 |
|
| - |
|
1001 |
List<Order> notAvailableProcessingOrder = orderRepository.selectByItemIdsOrderStatus(itemIds, OrderStatus.SUBMITTED_FOR_PROCESSING);
|
| - |
|
1002 |
LOGGER.info("notAvailableProcessingOrder" + notAvailableProcessingOrder);
|
| - |
|
1003 |
|
| - |
|
1004 |
List<Integer> retailerIds = new ArrayList<>();
|
| - |
|
1005 |
for (com.spice.profitmandi.dao.entity.transaction.Order order : notAvailableProcessingOrder) {
|
| - |
|
1006 |
retailerIds.add(order.getRetailerId());
|
| - |
|
1007 |
|
| - |
|
1008 |
}
|
| - |
|
1009 |
|
| - |
|
1010 |
Map<Integer, String> storeIdAndFofoIdMap = fofoStoreRepository.selectByRetailerIds(retailerIds).stream().collect(Collectors.toMap(FofoStore::getId, FofoStore::getCode));
|
| - |
|
1011 |
|
| - |
|
1012 |
model.addAttribute("notAvailableProcessingOrder", notAvailableProcessingOrder);
|
| - |
|
1013 |
model.addAttribute("storeIdAndFofoIdMap", storeIdAndFofoIdMap);
|
| - |
|
1014 |
|
| - |
|
1015 |
return "partner-cancel-order-modal";
|
| - |
|
1016 |
}
|
| - |
|
1017 |
|
| - |
|
1018 |
@RequestMapping(value = "/notifyCancelOrder", method = RequestMethod.POST)
|
| - |
|
1019 |
public String NotifyCancelOrder(HttpServletRequest request, @RequestBody NotifyOrderModel notifyOrderModel, Model model) throws Exception {
|
| - |
|
1020 |
for (NotifyOrderIdModel st : notifyOrderModel.getOrderIds()) {
|
| - |
|
1021 |
LOGGER.info("orderId" + st.getOrderId());
|
| - |
|
1022 |
Order order = orderRepository.selectById(st.getOrderId());
|
| - |
|
1023 |
NotifyCancel nc = notifyCancelOrderRepository.selectByOrderId(st.getOrderId());
|
| - |
|
1024 |
if (nc == null) {
|
| - |
|
1025 |
nc = new NotifyCancel();
|
| - |
|
1026 |
nc.setOrderId(st.getOrderId());
|
| - |
|
1027 |
nc.setItemId(st.getOlditemId());
|
| - |
|
1028 |
nc.setFofoId(order.getRetailerId());
|
| - |
|
1029 |
nc.setCancellation(false);
|
| - |
|
1030 |
nc.setCreatedTimestamp(LocalDateTime.now());
|
| - |
|
1031 |
nc.setUpdatedTimestamp(LocalDateTime.now());
|
| - |
|
1032 |
notifyCancelOrderRepository.persist(nc);
|
| - |
|
1033 |
} else {
|
| - |
|
1034 |
nc.setOrderId(st.getOrderId());
|
| - |
|
1035 |
nc.setItemId(st.getOlditemId());
|
| - |
|
1036 |
nc.setFofoId(order.getRetailerId());
|
| - |
|
1037 |
nc.setCancellation(false);
|
| - |
|
1038 |
nc.setUpdatedTimestamp(LocalDateTime.now());
|
| - |
|
1039 |
notifyCancelOrderRepository.persist(nc);
|
| - |
|
1040 |
}
|
| - |
|
1041 |
|
| - |
|
1042 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| - |
|
1043 |
sendNotificationModel.setCampaignName("Notify Partner");
|
| - |
|
1044 |
sendNotificationModel.setMessage(notifyOrderModel.getMessage());
|
| - |
|
1045 |
sendNotificationModel.setType("url");
|
| - |
|
1046 |
sendNotificationModel.setTitle("Alert");
|
| - |
|
1047 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifyCancelOrder");
|
| - |
|
1048 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
|
| - |
|
1049 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| - |
|
1050 |
int userId = userAccountRepository.selectUserIdByRetailerId(order.getRetailerId());
|
| - |
|
1051 |
|
| - |
|
1052 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
| - |
|
1053 |
notificationService.sendNotification(sendNotificationModel);
|
| - |
|
1054 |
|
| - |
|
1055 |
}
|
| - |
|
1056 |
|
| - |
|
1057 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| - |
|
1058 |
return "response";
|
| - |
|
1059 |
}
|
| - |
|
1060 |
|
| - |
|
1061 |
@RequestMapping(value = "/getNotifiedCancelOrder", method = RequestMethod.GET)
|
| - |
|
1062 |
public String getNotifiedCancelOrder(HttpServletRequest request, Model model) throws Exception {
|
| - |
|
1063 |
|
| - |
|
1064 |
List<NotifyCancel> notifyCancels = notifyCancelOrderRepository.selectAllNonCancelOrder();
|
| - |
|
1065 |
if (!notifyCancels.isEmpty()) {
|
| - |
|
1066 |
List<Integer> retailerIds = new ArrayList<>();
|
| - |
|
1067 |
Set<Integer> itemIds = new HashSet<>();
|
| - |
|
1068 |
for (NotifyCancel nc : notifyCancels) {
|
| - |
|
1069 |
retailerIds.add(nc.getFofoId());
|
| - |
|
1070 |
itemIds.add(nc.getItemId());
|
| - |
|
1071 |
}
|
| - |
|
1072 |
|
| - |
|
1073 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
| - |
|
1074 |
|
| - |
|
1075 |
Map<Integer, CustomRetailer> fofoIdsAndRetailerName = retailerIds.stream().map(x -> customRetailerMap.get(x)).filter(x -> x != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
| - |
|
1076 |
Map<Integer, String> itemdescription = inventoryService.getItemIdDescriptionMap(itemIds);
|
| - |
|
1077 |
model.addAttribute("notifyCancels", notifyCancels);
|
| - |
|
1078 |
model.addAttribute("itemdescription", itemdescription);
|
| - |
|
1079 |
model.addAttribute("fofoIdsAndRetailerName", fofoIdsAndRetailerName);
|
| - |
|
1080 |
} else {
|
| - |
|
1081 |
|
| - |
|
1082 |
model.addAttribute("notifyCancels", notifyCancels);
|
| - |
|
1083 |
|
| - |
|
1084 |
}
|
| - |
|
1085 |
return "notify_cancel";
|
| - |
|
1086 |
}
|
| - |
|
1087 |
|
| - |
|
1088 |
@RequestMapping(value = "/getNotifyItems", method = RequestMethod.GET)
|
| - |
|
1089 |
public String getNotifyItems(HttpServletRequest request, @RequestParam int itemId, Model model) throws Exception {
|
| - |
|
1090 |
Item item = itemRepository.selectById(itemId);
|
| - |
|
1091 |
|
| - |
|
1092 |
List<Integer> itemIds = itemRepository.selectAllByCatalogItemId(item.getCatalogItemId()).stream().map(x -> x.getId()).collect(Collectors.toList());
|
| - |
|
1093 |
|
| - |
|
1094 |
List<NotifyCancel> ncs = notifyCancelOrderRepository.selectByItemIdsAndStatus(itemIds);
|
| - |
|
1095 |
List<Integer> retailerIds = new ArrayList<>();
|
| - |
|
1096 |
Map<Integer, Object> orders = new HashMap<>();
|
| - |
|
1097 |
for (NotifyCancel nc : ncs) {
|
| - |
|
1098 |
retailerIds.add(nc.getFofoId());
|
| - |
|
1099 |
Order od = orderRepository.selectById(nc.getOrderId());
|
| - |
|
1100 |
orders.put(nc.getOrderId(), od);
|
| - |
|
1101 |
}
|
| - |
|
1102 |
|
| - |
|
1103 |
Map<Integer, String> storeIdAndFofoIdMap = fofoStoreRepository.selectByRetailerIds(retailerIds).stream().collect(Collectors.toMap(FofoStore::getId, FofoStore::getCode));
|
| - |
|
1104 |
|
| - |
|
1105 |
model.addAttribute("notifyItems", ncs);
|
| - |
|
1106 |
model.addAttribute("orders", orders);
|
| - |
|
1107 |
model.addAttribute("storeIdAndFofoIdMap", storeIdAndFofoIdMap);
|
| - |
|
1108 |
|
| - |
|
1109 |
return "notify_cancel_order_modal";
|
| - |
|
1110 |
}
|
| - |
|
1111 |
|
| - |
|
1112 |
@RequestMapping(value = "/changeNotifyCancelRequest", method = RequestMethod.POST)
|
| - |
|
1113 |
public String changeNotifyCancelRequest(HttpServletRequest request, @RequestBody NotifyOrderModel notifyOrderModel, Model model) throws Exception {
|
| - |
|
1114 |
List<Integer> orderIds = notifyOrderModel.getOrderIds().stream().map(x -> x.getOrderId()).collect(Collectors.toList());
|
| - |
|
1115 |
|
| - |
|
1116 |
List<NotifyCancel> ncs = notifyCancelOrderRepository.selectByOrderIds(orderIds);
|
| - |
|
1117 |
for (NotifyCancel nc : ncs) {
|
| - |
|
1118 |
nc.setCancellation(true);
|
| - |
|
1119 |
}
|
| - |
|
1120 |
|
| - |
|
1121 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| - |
|
1122 |
return "response";
|
| - |
|
1123 |
}
|
| - |
|
1124 |
|
| - |
|
1125 |
@RequestMapping(value = "/getProducts", method = RequestMethod.GET)
|
| - |
|
1126 |
public String getProducts(HttpServletRequest request, Model model) throws ProfitMandiBusinessException, URISyntaxException, IOException {
|
| - |
|
1127 |
|
| - |
|
1128 |
return "product-detail";
|
| - |
|
1129 |
}
|
| - |
|
1130 |
|
| - |
|
1131 |
@RequestMapping(value = "/getProductInfo", method = RequestMethod.GET)
|
| - |
|
1132 |
public String getProductInfo(HttpServletRequest request, long catalogId, Model model) throws Exception {
|
| - |
|
1133 |
ContentPojo cp = mongoClient.getEntityById(catalogId);
|
| - |
|
1134 |
model.addAttribute("cp", cp);
|
| - |
|
1135 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| - |
|
1136 |
return "product-info";
|
| - |
|
1137 |
}
|
| - |
|
1138 |
|
| - |
|
1139 |
@RequestMapping(value = "/getProductCompareInfo", method = RequestMethod.GET)
|
| - |
|
1140 |
public String getProductCompareInfo(HttpServletRequest request, @RequestParam List<Long> catalogIds, Model model) throws Exception {
|
| - |
|
1141 |
List<ContentPojo> cps = new ArrayList<>();
|
| - |
|
1142 |
Set<Integer> cataogIds = catalogIds.stream().mapToInt(Long::intValue).boxed().collect(Collectors.toSet());
|
| - |
|
1143 |
LOGGER.info("tagListingMOP" + cataogIds);
|
| - |
|
1144 |
for (Long cId : catalogIds) {
|
| - |
|
1145 |
ContentPojo cp = mongoClient.getEntityById(cId);
|
| - |
|
1146 |
if (cp.getName() == null) {
|
| - |
|
1147 |
cp.setName(itemRepository.selectAllByCatalogItemId(cId.intValue()).get(0).getItemDescriptionNoColor());
|
| - |
|
1148 |
}
|
| - |
|
1149 |
List<Item> items = itemRepository.selectAllByCatalogItemId(cId.intValue());
|
| - |
|
1150 |
LOGGER.info("itemsMop" + items);
|
| - |
|
1151 |
int i = 0;
|
| - |
|
1152 |
for (Item item : items) {
|
| - |
|
1153 |
TagListing tagListing = tagListingRepository.selectByItemId(items.get(i).getId());
|
| - |
|
1154 |
|
| - |
|
1155 |
if (tagListing != null) {
|
| - |
|
1156 |
cp.setPrice(tagListing.getMop());
|
| - |
|
1157 |
|
| - |
|
1158 |
LOGGER.info("tagListingMOP" + tagListing);
|
| - |
|
1159 |
|
| - |
|
1160 |
break;
|
| - |
|
1161 |
|
| - |
|
1162 |
}
|
| - |
|
1163 |
i++;
|
| - |
|
1164 |
}
|
| - |
|
1165 |
cps.add(cp);
|
| - |
|
1166 |
|
| - |
|
1167 |
}
|
| - |
|
1168 |
|
| - |
|
1169 |
List<Map<String, String>> entityList = new ArrayList<>();
|
| - |
|
1170 |
for (ContentPojo cp : cps) {
|
| - |
|
1171 |
Map<String, String> specsMap = new HashMap<>();
|
| - |
|
1172 |
for (SpecificationGroup sg : cp.getDetailedSpecs()) {
|
| - |
|
1173 |
String title = sg.getTitle();
|
| - |
|
1174 |
for (Specification s : sg.getSpecs()) {
|
| - |
|
1175 |
String key = title + s.getName();
|
| - |
|
1176 |
specsMap.put(key, String.join(", ", s.getValues()));
|
| - |
|
1177 |
}
|
| - |
|
1178 |
}
|
| - |
|
1179 |
entityList.add(specsMap);
|
| - |
|
1180 |
|
| - |
|
1181 |
}
|
| - |
|
1182 |
|
| - |
|
1183 |
LOGGER.info("cps" + cps);
|
| - |
|
1184 |
model.addAttribute("cps", cps);
|
| - |
|
1185 |
model.addAttribute("catalogIds", gson.toJson(catalogIds, List.class));
|
| - |
|
1186 |
model.addAttribute("entityList", entityList);
|
| - |
|
1187 |
return "product-compare";
|
| - |
|
1188 |
}
|
| - |
|
1189 |
|
| - |
|
1190 |
@RequestMapping(value = "/inventory", method = RequestMethod.GET)
|
| - |
|
1191 |
public String Inventory(HttpServletRequest request, @RequestParam(name = "warehouseIds", required = true, defaultValue = "0") List<Integer> warehouseIds, Model model) throws Exception {
|
| - |
|
1192 |
model.addAttribute("warehouseId", warehouseIds);
|
| - |
|
1193 |
LOGGER.info("warehouseIds" + warehouseIds);
|
| - |
|
1194 |
|
| - |
|
1195 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| - |
|
1196 |
if (warehouseIds.contains(0)) {
|
| - |
|
1197 |
warehouseIds.addAll(warehouseMap.keySet());
|
| - |
|
1198 |
}
|
| - |
|
1199 |
|
| - |
|
1200 |
long poTodayValue = 0;
|
| - |
|
1201 |
long poThreedaysValue = 0;
|
| - |
|
1202 |
long poSevendaysValue = 0;
|
| - |
|
1203 |
long poTodayQty = 0;
|
| - |
|
1204 |
long poThreedaysQty = 0;
|
| - |
|
1205 |
long poSevendaysQty = 0;
|
| - |
|
1206 |
|
| - |
|
1207 |
List<OpenPoModel> openPO = warehousePurchaseOrderRepository.selectOpenPo(warehouseIds);
|
| - |
|
1208 |
for (OpenPoModel po : openPO) {
|
| - |
|
1209 |
poTodayValue += po.getTodayValue();
|
| - |
|
1210 |
poThreedaysValue += po.getThreedaysValue();
|
| - |
|
1211 |
poSevendaysValue += po.getSevendaysValue();
|
| - |
|
1212 |
poTodayQty += po.getTodayQty();
|
| - |
|
1213 |
poThreedaysQty += po.getThreedaysQty();
|
| - |
|
1214 |
poSevendaysQty += po.getSevendaysQty();
|
| - |
|
1215 |
}
|
| - |
|
1216 |
OpenPoModel poModel = new OpenPoModel();
|
| - |
|
1217 |
poModel.setBrand("Total Values");
|
| - |
|
1218 |
poModel.setTodayValue(poTodayValue);
|
| - |
|
1219 |
poModel.setThreedaysValue(poThreedaysValue);
|
| - |
|
1220 |
poModel.setSevendaysValue(poSevendaysValue);
|
| - |
|
1221 |
poModel.setSevendaysQty(poSevendaysQty);
|
| - |
|
1222 |
poModel.setThreedaysQty(poThreedaysQty);
|
| - |
|
1223 |
poModel.setTodayQty(poTodayQty);
|
| - |
|
1224 |
openPO.add(poModel);
|
| - |
|
1225 |
|
| - |
|
1226 |
long purtodayValue = 0;
|
| - |
|
1227 |
long purthreedaysValue = 0;
|
| - |
|
1228 |
long purlmsValue = 0;
|
| - |
|
1229 |
long purmtd = 0;
|
| - |
|
1230 |
long purtodayQty = 0;
|
| - |
|
1231 |
long purthreedaysQty = 0;
|
| - |
|
1232 |
long purlmsQty = 0;
|
| - |
|
1233 |
long purmtdQty = 0;
|
| - |
|
1234 |
|
| - |
|
1235 |
List<OurPurchaseModel> purchase = warehouseScanRepository.selectOurPurchase(warehouseIds);
|
| - |
|
1236 |
|
| - |
|
1237 |
for (OurPurchaseModel pm : purchase) {
|
| - |
|
1238 |
purtodayValue += pm.getTodayValue();
|
| - |
|
1239 |
purthreedaysValue += pm.getThreedaysValue();
|
| - |
|
1240 |
purlmsValue += pm.getLms();
|
| - |
|
1241 |
purmtd += pm.getMtd();
|
| - |
|
1242 |
purtodayQty += pm.getTodayQty();
|
| - |
|
1243 |
purthreedaysQty += pm.getThreedaysQty();
|
| - |
|
1244 |
purlmsQty += pm.getLmsQty();
|
| - |
|
1245 |
purmtdQty += pm.getMtdQty();
|
| - |
|
1246 |
}
|
| - |
|
1247 |
OurPurchaseModel omp = new OurPurchaseModel();
|
| - |
|
1248 |
omp.setBrand("Total Values");
|
| - |
|
1249 |
omp.setTodayValue(purtodayValue);
|
| - |
|
1250 |
omp.setThreedaysValue(purthreedaysValue);
|
| - |
|
1251 |
omp.setLms(purlmsValue);
|
| - |
|
1252 |
omp.setMtd(purmtd);
|
| - |
|
1253 |
omp.setTodayQty(purtodayQty);
|
| - |
|
1254 |
omp.setThreedaysQty(purthreedaysQty);
|
| - |
|
1255 |
omp.setLmsQty(purlmsQty);
|
| - |
|
1256 |
omp.setMtdQty(purmtdQty);
|
| - |
|
1257 |
purchase.add(omp);
|
| - |
|
1258 |
|
| - |
|
1259 |
List<BrandWiseTertiaryModel> tertiary = fofoOrderRepository.selectGroupByBrandPartnerTertiary(warehouseIds);
|
| - |
|
1260 |
long tertodayValue = 0;
|
| - |
|
1261 |
long terthreedaysValue = 0;
|
| - |
|
1262 |
long termtd = 0;
|
| - |
|
1263 |
long terlmtd = 0;
|
| - |
|
1264 |
long terlms = 0;
|
| - |
|
1265 |
long tertodayQty = 0;
|
| - |
|
1266 |
long terthreedaysQty = 0;
|
| - |
|
1267 |
long termtdQty = 0;
|
| - |
|
1268 |
long terlmtdQty = 0;
|
| - |
|
1269 |
long terlmsQty = 0;
|
| - |
|
1270 |
for (BrandWiseTertiaryModel btm : tertiary) {
|
| - |
|
1271 |
tertodayValue += btm.getTodayValue();
|
| - |
|
1272 |
terthreedaysValue += btm.getThreedaysValue();
|
| - |
|
1273 |
termtd += btm.getMtd();
|
| - |
|
1274 |
terlmtd += btm.getLmtd();
|
| - |
|
1275 |
terlms += btm.getLms();
|
| - |
|
1276 |
tertodayQty += btm.getTodayQty();
|
| - |
|
1277 |
terthreedaysQty += btm.getThreedaysQty();
|
| - |
|
1278 |
termtdQty += btm.getMtdQty();
|
| - |
|
1279 |
terlmtdQty += btm.getLmtdQty();
|
| - |
|
1280 |
terlmsQty += btm.getLmsQty();
|
| - |
|
1281 |
}
|
| - |
|
1282 |
BrandWiseTertiaryModel bwt = new BrandWiseTertiaryModel();
|
| - |
|
1283 |
bwt.setBrand("Total Values");
|
| - |
|
1284 |
bwt.setTodayValue(tertodayValue);
|
| - |
|
1285 |
bwt.setThreedaysValue(terthreedaysValue);
|
| - |
|
1286 |
bwt.setMtd(termtd);
|
| - |
|
1287 |
bwt.setLmtd(terlmtd);
|
| - |
|
1288 |
bwt.setLms(terlms);
|
| - |
|
1289 |
bwt.setTodayQty(tertodayQty);
|
| - |
|
1290 |
bwt.setThreedaysQty(terthreedaysQty);
|
| - |
|
1291 |
bwt.setMtdQty(termtdQty);
|
| - |
|
1292 |
bwt.setLmtdQty(terlmtdQty);
|
| - |
|
1293 |
bwt.setLmsQty(terlmsQty);
|
| - |
|
1294 |
tertiary.add(bwt);
|
| - |
|
1295 |
|
| - |
|
1296 |
List<SecondaryOrderBillingModel> billing = orderRepository.selectAllBilledOrderGroupByBrand(warehouseIds);
|
| - |
|
1297 |
long sectodayValue = 0;
|
| - |
|
1298 |
long secthreedaysValue = 0;
|
| - |
|
1299 |
long secmtd = 0;
|
| - |
|
1300 |
long seclmtd = 0;
|
| - |
|
1301 |
long seclms = 0;
|
| - |
|
1302 |
long sectodayQty = 0;
|
| - |
|
1303 |
long secthreedaysQty = 0;
|
| - |
|
1304 |
long secmtdQty = 0;
|
| - |
|
1305 |
long seclmtdQty = 0;
|
| - |
|
1306 |
long seclmsQty = 0;
|
| - |
|
1307 |
for (SecondaryOrderBillingModel sbm : billing) {
|
| - |
|
1308 |
sectodayValue += sbm.getTodayValue();
|
| - |
|
1309 |
secthreedaysValue += sbm.getThreedaysValue();
|
| - |
|
1310 |
secmtd += sbm.getMtd();
|
| - |
|
1311 |
seclmtd += sbm.getLmtd();
|
| - |
|
1312 |
seclms += sbm.getLms();
|
| - |
|
1313 |
sectodayQty += sbm.getTodayQty();
|
| - |
|
1314 |
secthreedaysQty += sbm.getThreedaysQty();
|
| - |
|
1315 |
secmtdQty += sbm.getMtdQty();
|
| - |
|
1316 |
seclmtdQty += sbm.getLmtdQty();
|
| - |
|
1317 |
seclmsQty += sbm.getLmsQty();
|
| - |
|
1318 |
}
|
| - |
|
1319 |
|
| - |
|
1320 |
SecondaryOrderBillingModel som = new SecondaryOrderBillingModel();
|
| - |
|
1321 |
som.setBrand("Total Values");
|
| - |
|
1322 |
som.setTodayValue(sectodayValue);
|
| - |
|
1323 |
som.setThreedaysValue(secthreedaysValue);
|
| - |
|
1324 |
som.setMtd(secmtd);
|
| - |
|
1325 |
som.setLmtd(seclmtd);
|
| - |
|
1326 |
som.setLms(seclms);
|
| - |
|
1327 |
som.setTodayQty(sectodayQty);
|
| - |
|
1328 |
som.setThreedaysQty(secthreedaysQty);
|
| - |
|
1329 |
som.setMtdQty(secmtdQty);
|
| - |
|
1330 |
som.setLmtdQty(seclmtdQty);
|
| - |
|
1331 |
som.setLmsQty(seclmsQty);
|
| - |
|
1332 |
billing.add(som);
|
| - |
|
1333 |
LOGGER.info("openPO" + openPO);
|
| - |
|
1334 |
LOGGER.info("purchase" + purchase);
|
| - |
|
1335 |
LOGGER.info("tertiary" + tertiary);
|
| - |
|
1336 |
LOGGER.info("billing" + billing);
|
| - |
|
1337 |
|
| - |
|
1338 |
LOGGER.info("warehouseIds" + warehouseIds);
|
| - |
|
1339 |
model.addAttribute("warehouseMap", warehouseMap);
|
| - |
|
1340 |
model.addAttribute("openPO", openPO);
|
| - |
|
1341 |
model.addAttribute("purchase", purchase);
|
| - |
|
1342 |
model.addAttribute("tertiary", tertiary);
|
| - |
|
1343 |
model.addAttribute("billing", billing);
|
| - |
|
1344 |
|
| - |
|
1345 |
return "inventory-listing";
|
| - |
|
1346 |
|
| - |
|
1347 |
}
|
| - |
|
1348 |
|
| - |
|
1349 |
@RequestMapping(value = "/getOpenPoItemByBrand", method = RequestMethod.GET)
|
| - |
|
1350 |
public String Inventory(HttpServletRequest request, @RequestParam(name = "warehouseIds", required = true, defaultValue = "0") List<Integer> warehouseIds, @RequestParam(name = "brand", required = true, defaultValue = "") List<String> brand, int timeValue, Model model) throws Exception {
|
| - |
|
1351 |
model.addAttribute("warehouseId", warehouseIds);
|
| - |
|
1352 |
LOGGER.info("warehouseIds" + warehouseIds);
|
| - |
|
1353 |
|
| - |
|
1354 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| - |
|
1355 |
if (warehouseIds.contains(0)) {
|
| - |
|
1356 |
warehouseIds.addAll(warehouseMap.keySet());
|
| - |
|
1357 |
}
|
| - |
|
1358 |
LOGGER.info("brand" + brand);
|
| - |
|
1359 |
|
| - |
|
1360 |
if (brand.contains("Total Values")) {
|
| - |
|
1361 |
List<String> poBrands = warehousePurchaseOrderRepository.selectOpenPo(warehouseIds).stream().map(x -> x.getBrand()).collect(Collectors.toList());
|
| - |
|
1362 |
|
| - |
|
1363 |
brand.addAll(poBrands);
|
| - |
|
1364 |
}
|
| - |
|
1365 |
|
| - |
|
1366 |
LOGGER.info("brand" + brand);
|
| - |
|
1367 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| - |
|
1368 |
List<OpenPoItemModel> openPOItem = null;
|
| - |
|
1369 |
if (timeValue != 0) {
|
| - |
|
1370 |
openPOItem = warehousePurchaseOrderRepository.selectOpenPoItem(warehouseIds, brand, curDate.minusDays(timeValue), curDate);
|
| - |
|
1371 |
} else {
|
| - |
|
1372 |
openPOItem = warehousePurchaseOrderRepository.selectTodayOpenPoItem(warehouseIds, brand, curDate);
|
| - |
|
1373 |
}
|
| - |
|
1374 |
LOGGER.info("openPOItem" + openPOItem);
|
| - |
|
1375 |
|
| - |
|
1376 |
model.addAttribute("openPOItem", openPOItem);
|
| - |
|
1377 |
|
| - |
|
1378 |
return "inventory-listing-po-item";
|
| - |
|
1379 |
|
| - |
|
1380 |
}
|
| - |
|
1381 |
|
| - |
|
1382 |
@RequestMapping(value = "/getOurPurchaseItemByBrand", method = RequestMethod.GET)
|
| - |
|
1383 |
public String getOurPurchaseItemByBrand(HttpServletRequest request, @RequestParam(name = "warehouseIds", required = true, defaultValue = "0") List<Integer> warehouseIds, @RequestParam(name = "brand", required = true, defaultValue = "") List<String> brand, int timeValue, Model model) throws Exception {
|
| - |
|
1384 |
model.addAttribute("warehouseId", warehouseIds);
|
| - |
|
1385 |
LOGGER.info("warehouseIds" + warehouseIds);
|
| - |
|
1386 |
|
| - |
|
1387 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| - |
|
1388 |
if (warehouseIds.contains(0)) {
|
| - |
|
1389 |
warehouseIds.addAll(warehouseMap.keySet());
|
| - |
|
1390 |
}
|
| - |
|
1391 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| - |
|
1392 |
|
| - |
|
1393 |
if (brand.contains("Total Values")) {
|
| - |
|
1394 |
List<String> purchasebrands = warehouseScanRepository.selectOurPurchase(warehouseIds).stream().map(x -> x.getBrand()).collect(Collectors.toList());
|
| - |
|
1395 |
|
| - |
|
1396 |
brand.addAll(purchasebrands);
|
| - |
|
1397 |
}
|
| - |
|
1398 |
List<OurPurchaseItemModel> ourPurchaseItem = null;
|
| - |
|
1399 |
if (timeValue != 0) {
|
| - |
|
1400 |
if (timeValue == 1) {
|
| - |
|
1401 |
ourPurchaseItem = warehouseScanRepository.selectOurPurchaseItemByBrand(warehouseIds, brand, curDate.withDayOfMonth(1), curDate.plusDays(1));
|
| - |
|
1402 |
|
| - |
|
1403 |
} else if (timeValue == -1) {
|
| - |
|
1404 |
|
| - |
|
1405 |
ourPurchaseItem = warehouseScanRepository.selectOurPurchaseItemByBrand(warehouseIds, brand, curDate.minusMonths(1).withDayOfMonth(1), curDate.withDayOfMonth(1));
|
| - |
|
1406 |
|
| - |
|
1407 |
} else {
|
| - |
|
1408 |
ourPurchaseItem = warehouseScanRepository.selectOurPurchaseItemByBrand(warehouseIds, brand, curDate.minusDays(timeValue), curDate);
|
| - |
|
1409 |
|
| - |
|
1410 |
}
|
| - |
|
1411 |
} else {
|
| - |
|
1412 |
ourPurchaseItem = warehouseScanRepository.selectTodayOurPurchaseItemByBrand(warehouseIds, brand, curDate);
|
| - |
|
1413 |
}
|
| - |
|
1414 |
LOGGER.info("ourPurchaseItem" + ourPurchaseItem);
|
| - |
|
1415 |
|
| - |
|
1416 |
model.addAttribute("ourPurchaseItem", ourPurchaseItem);
|
| - |
|
1417 |
model.addAttribute("warehouseMap", warehouseMap);
|
| - |
|
1418 |
|
| - |
|
1419 |
return "inventory-listing-purchase-item";
|
| - |
|
1420 |
|
| - |
|
1421 |
}
|
| - |
|
1422 |
|
| - |
|
1423 |
@RequestMapping(value = "/getWarehouseWiseSecondaryBillingByBrand", method = RequestMethod.GET)
|
| - |
|
1424 |
public String getWarehouseWiseSecondaryBillingByBrand(HttpServletRequest request, @RequestParam(name = "brand", required = true, defaultValue = "") String brand, int timeValue, Model model) throws Exception {
|
| - |
|
1425 |
|
| - |
|
1426 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| - |
|
1427 |
int dayOfMonth = curDate.getDayOfMonth();
|
| - |
|
1428 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1);
|
| - |
|
1429 |
int lengthOfMonth = YearMonth.from(startOfMonth.minusMonths(1)).lengthOfMonth();
|
| - |
|
1430 |
|
| - |
|
1431 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| - |
|
1432 |
SecondaeryOrderDateRange sr = null;
|
| - |
|
1433 |
if (brand.equals("Total Values")) {
|
| - |
|
1434 |
brand = null;
|
| - |
|
1435 |
}
|
| - |
|
1436 |
if (timeValue != 0) {
|
| - |
|
1437 |
if (timeValue == 1) {
|
| - |
|
1438 |
|
| - |
|
1439 |
sr = getSecondaryModel(brand, curDate.withDayOfMonth(1), curDate.plusDays(1));
|
| - |
|
1440 |
|
| - |
|
1441 |
} else if (timeValue == 2) {
|
| - |
|
1442 |
LOGGER.info("curDate" + curDate.withDayOfMonth(1).minusMonths(1));
|
| - |
|
1443 |
LOGGER.info("curDate" + curDate.minusMonths(1).plusDays(Math.min(dayOfMonth, lengthOfMonth)));
|
| - |
|
1444 |
|
| - |
|
1445 |
sr = getSecondaryModel(brand, curDate.withDayOfMonth(1).minusMonths(1), startOfMonth.minusMonths(1).plusDays(Math.min(dayOfMonth, lengthOfMonth)));
|
| - |
|
1446 |
|
| - |
|
1447 |
} else if (timeValue == -1) {
|
| - |
|
1448 |
|
| - |
|
1449 |
sr = getSecondaryModel(brand, curDate.minusMonths(1).withDayOfMonth(1), startOfMonth);
|
| - |
|
1450 |
|
| - |
|
1451 |
} else {
|
| - |
|
1452 |
|
| - |
|
1453 |
sr = getSecondaryModel(brand, curDate.minusDays(timeValue), curDate);
|
| - |
|
1454 |
}
|
| - |
|
1455 |
|
| - |
|
1456 |
} else {
|
| - |
|
1457 |
sr = getSecondaryModel(brand, curDate, curDate.plusDays(1));
|
| - |
|
1458 |
}
|
| - |
|
1459 |
|
| - |
|
1460 |
Map<BrandRegionModel, Map<LocalDate, SecondaryWarehouseWiseOrderBilllingModel>> brandWarehouseOrderMap = sr.getSecondaryModel().stream().collect(Collectors.groupingBy(x -> new BrandRegionModel(x.getWarehouseId(), x.getBrand()), Collectors.collectingAndThen(Collectors.toList(), x -> x.stream().collect(Collectors.toMap(y -> y.getBillingTimestamp(), y -> y)))));
|
| - |
|
1461 |
|
| - |
|
1462 |
Map<LocalDate, Integer> dateWiseTotal = sr.getSecondaryModel().stream().collect(
|
| - |
|
1463 |
Collectors.groupingBy(x -> x.getBillingTimestamp(), Collectors.summingInt(x -> (int) x.getValue())));
|
| - |
|
1464 |
|
| - |
|
1465 |
Map<LocalDate, Integer> dateWiseQtyTotal = sr.getSecondaryModel().stream().collect(
|
| - |
|
1466 |
Collectors.groupingBy(x -> x.getBillingTimestamp(), Collectors.summingInt(x -> (int) x.getQty())));
|
| - |
|
1467 |
|
| - |
|
1468 |
LOGGER.info("dateWiseTotal" + dateWiseTotal);
|
| - |
|
1469 |
|
| - |
|
1470 |
brandWarehouseOrderMap.entrySet().stream().forEach(x -> {
|
| - |
|
1471 |
x.getKey().setTotal(x.getValue().entrySet().stream().collect(Collectors.summingInt(y -> (int) y.getValue().getValue())));
|
| - |
|
1472 |
});
|
| - |
|
1473 |
|
| - |
|
1474 |
brandWarehouseOrderMap.entrySet().stream().forEach(x -> {
|
| - |
|
1475 |
x.getKey().setQty(
|
| - |
|
1476 |
x.getValue().entrySet().stream().collect(Collectors.summingInt(y -> (int) y.getValue().getQty())));
|
| - |
|
1477 |
});
|
| - |
|
1478 |
LOGGER.info("brandWarehouseOrderMap" + brandWarehouseOrderMap);
|
| - |
|
1479 |
|
| - |
|
1480 |
model.addAttribute("brandWarehouseOrderMap", brandWarehouseOrderMap);
|
| - |
|
1481 |
model.addAttribute("dateWiseTotal", dateWiseTotal);
|
| - |
|
1482 |
model.addAttribute("dateWiseQtyTotal", dateWiseQtyTotal);
|
| - |
|
1483 |
model.addAttribute("dateRange", sr.getDateRange());
|
| - |
|
1484 |
model.addAttribute("warehouseMap", warehouseMap);
|
| - |
|
1485 |
return "secondary-warehouse-billing-order";
|
| - |
|
1486 |
|
| - |
|
1487 |
}
|
| - |
|
1488 |
|
| - |
|
1489 |
public SecondaeryOrderDateRange getSecondaryModel(String brand, LocalDateTime startDate, LocalDateTime endDate) {
|
| - |
|
1490 |
|
| - |
|
1491 |
SecondaeryOrderDateRange sr = new SecondaeryOrderDateRange();
|
| 1957 |
}
|
1492 |
List<SecondaryWarehouseWiseOrderBilllingModel> secondaryOrderbilling = orderRepository.selectAllBilledOrderGroupByBrandWarehouse(brand, startDate, endDate).stream().sorted(Comparator.comparing(SecondaryWarehouseWiseOrderBilllingModel::getBillingTimestamp)).collect(Collectors.toList());
|
| - |
|
1493 |
long noOfDaysBetween = ChronoUnit.DAYS.between(startDate, endDate);
|
| - |
|
1494 |
|
| - |
|
1495 |
List<LocalDate> dateRange = Stream.iterate(startDate.toLocalDate(), date -> date.plusDays(1)).limit(noOfDaysBetween).collect(Collectors.toList());
|
| - |
|
1496 |
|
| - |
|
1497 |
sr.setDateRange(dateRange);
|
| - |
|
1498 |
sr.setSecondaryModel(secondaryOrderbilling);
|
| - |
|
1499 |
|
| - |
|
1500 |
return sr;
|
| - |
|
1501 |
|
| - |
|
1502 |
}
|
| - |
|
1503 |
|
| - |
|
1504 |
@RequestMapping(value = "/getSecondaryBillingItemByBrand", method = RequestMethod.GET)
|
| - |
|
1505 |
public String getSecondaryBillingItemByBrand(HttpServletRequest request, @RequestParam(name = "warehouseId", required = true, defaultValue = "0") int warehouseId, @RequestParam(name = "brand", required = true, defaultValue = "") String brand, @RequestParam List<LocalDate> date, Model model) throws Exception {
|
| - |
|
1506 |
|
| - |
|
1507 |
List<SecondaryOrderItemBillingModel> orderItemBilling = orderRepository.selectAllBilledOrderItemByBrand(warehouseId, brand, date);
|
| - |
|
1508 |
|
| - |
|
1509 |
LOGGER.info("orderItemBilling" + orderItemBilling);
|
| - |
|
1510 |
model.addAttribute("billedItem", orderItemBilling);
|
| - |
|
1511 |
model.addAttribute("date", date);
|
| - |
|
1512 |
model.addAttribute("brand", brand);
|
| - |
|
1513 |
return "inventory-listing-billing-item";
|
| - |
|
1514 |
|
| - |
|
1515 |
}
|
| - |
|
1516 |
|
| - |
|
1517 |
@RequestMapping(value = "/getPartnerTertiaryItemByBrand", method = RequestMethod.GET)
|
| - |
|
1518 |
public String getPartnerTertiaryItemByBrand(HttpServletRequest request, @RequestParam(name = "warehouseIds", required = true, defaultValue = "0") List<Integer> warehouseIds, @RequestParam(name = "brand", required = true, defaultValue = "") List<String> brand, int timeValue, Model model) throws Exception {
|
| - |
|
1519 |
model.addAttribute("warehouseId", warehouseIds);
|
| - |
|
1520 |
LOGGER.info("warehouseIds" + warehouseIds);
|
| - |
|
1521 |
|
| - |
|
1522 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| - |
|
1523 |
if (warehouseIds.contains(0)) {
|
| - |
|
1524 |
warehouseIds.addAll(warehouseMap.keySet());
|
| - |
|
1525 |
}
|
| - |
|
1526 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| - |
|
1527 |
int dayOfMonth = curDate.getDayOfMonth();
|
| - |
|
1528 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1);
|
| - |
|
1529 |
int lengthOfMonth = YearMonth.from(startOfMonth.minusMonths(1)).lengthOfMonth();
|
| - |
|
1530 |
if (brand.contains("Total Values")) {
|
| - |
|
1531 |
List<String> tertiaryBrands = fofoOrderRepository.selectGroupByBrandPartnerTertiary(warehouseIds).stream().map(x -> x.getBrand()).collect(Collectors.toList());
|
| - |
|
1532 |
|
| - |
|
1533 |
brand.addAll(tertiaryBrands);
|
| - |
|
1534 |
}
|
| - |
|
1535 |
List<BrandItemWiseTertiaryModel> tertiaryItem = null;
|
| - |
|
1536 |
if (timeValue != 0) {
|
| - |
|
1537 |
if (timeValue == 1) {
|
| - |
|
1538 |
|
| - |
|
1539 |
tertiaryItem = fofoOrderRepository.selectItemPartnerTertiaryByBrand(warehouseIds, brand, curDate.withDayOfMonth(1), curDate.plusDays(1));
|
| - |
|
1540 |
|
| - |
|
1541 |
} else if (timeValue == 2) {
|
| - |
|
1542 |
LOGGER.info("curDate" + startOfMonth.minusMonths(1));
|
| - |
|
1543 |
LOGGER.info("curDate" + startOfMonth.minusMonths(1).plusDays(Math.min(dayOfMonth, lengthOfMonth)));
|
| - |
|
1544 |
|
| - |
|
1545 |
tertiaryItem = fofoOrderRepository.selectItemPartnerTertiaryByBrand(warehouseIds, brand, startOfMonth.minusMonths(1), startOfMonth.minusMonths(1).plusDays(Math.min(dayOfMonth, lengthOfMonth)));
|
| - |
|
1546 |
|
| - |
|
1547 |
} else if (timeValue == -1) {
|
| - |
|
1548 |
LOGGER.info("date" + curDate.minusMonths(1).withDayOfMonth(1));
|
| - |
|
1549 |
LOGGER.info("date" + curDate.minusMonths(1).withDayOfMonth(lengthOfMonth).plusDays(1));
|
| - |
|
1550 |
|
| - |
|
1551 |
tertiaryItem = fofoOrderRepository.selectItemPartnerTertiaryByBrand(warehouseIds, brand, curDate.minusMonths(1).withDayOfMonth(1), startOfMonth);
|
| - |
|
1552 |
} else {
|
| - |
|
1553 |
tertiaryItem = fofoOrderRepository.selectItemPartnerTertiaryByBrand(warehouseIds, brand, curDate.minusDays(timeValue), curDate);
|
| - |
|
1554 |
}
|
| - |
|
1555 |
|
| - |
|
1556 |
} else {
|
| - |
|
1557 |
tertiaryItem = fofoOrderRepository.selectTodayItemPartnerTertiaryByBrand(warehouseIds, brand, curDate);
|
| - |
|
1558 |
}
|
| - |
|
1559 |
LOGGER.info("tertiaryItem" + tertiaryItem);
|
| - |
|
1560 |
|
| - |
|
1561 |
model.addAttribute("tertiaryItem", tertiaryItem);
|
| - |
|
1562 |
|
| - |
|
1563 |
return "inventory-item-tertiary-item";
|
| - |
|
1564 |
|
| - |
|
1565 |
}
|
| - |
|
1566 |
|
| - |
|
1567 |
@RequestMapping(value = "/planogram")
|
| - |
|
1568 |
public String Planogram(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
| - |
|
1569 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
1570 |
String email = loginDetails.getEmailId();
|
| - |
|
1571 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
| - |
|
1572 |
List<FocusedModelByPassRequest> byPassRequest = null;
|
| - |
|
1573 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
| - |
|
1574 |
|
| - |
|
1575 |
Set<Integer> authfofoIds = null;
|
| - |
|
1576 |
|
| - |
|
1577 |
List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
|
| - |
|
1578 |
|
| - |
|
1579 |
if (emails.contains(authUser.getEmailId())) {
|
| - |
|
1580 |
authfofoIds = storeGuyMap.get("tarun.verma@smartdukaan.com");
|
| - |
|
1581 |
LOGGER.info("fofoIds" + authfofoIds);
|
| - |
|
1582 |
} else {
|
| - |
|
1583 |
|
| - |
|
1584 |
for (Position ps : positions) {
|
| - |
|
1585 |
if (esclationType.contains(ps.getEscalationType())) {
|
| - |
|
1586 |
authfofoIds = storeGuyMap.get(email);
|
| - |
|
1587 |
break;
|
| - |
|
1588 |
}
|
| - |
|
1589 |
|
| - |
|
1590 |
}
|
| - |
|
1591 |
}
|
| - |
|
1592 |
if (authfofoIds != null) {
|
| - |
|
1593 |
byPassRequest = focusedModelByPassRepository.selectByStatusAndFofoIds(new ArrayList<>(authfofoIds), ByPassRequestStatus.PENDING);
|
| - |
|
1594 |
}
|
| - |
|
1595 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
| - |
|
1596 |
model.addAttribute("customRetailerMap", customRetailerMap);
|
| - |
|
1597 |
model.addAttribute("byPassRequest", byPassRequest);
|
| - |
|
1598 |
return "planogram";
|
| - |
|
1599 |
}
|
| - |
|
1600 |
|
| - |
|
1601 |
@RequestMapping(value = "/byPassRequestAction", method = RequestMethod.PUT)
|
| - |
|
1602 |
public String addAmountToWalletRequestRejected(HttpServletRequest request, @RequestParam(name = "id", defaultValue = "0") int id, @RequestParam ByPassRequestStatus status, @RequestParam(name = "reason", required = false) String reason, Model model) throws Exception {
|
| - |
|
1603 |
|
| - |
|
1604 |
FocusedModelByPassRequest byPassRequest = focusedModelByPassRepository.selectById(id);
|
| - |
|
1605 |
if (status.equals(ByPassRequestStatus.APPROVED)) {
|
| - |
|
1606 |
byPassRequest.setByPass(true);
|
| - |
|
1607 |
byPassRequest.setStatus(ByPassRequestStatus.APPROVED);
|
| - |
|
1608 |
byPassRequest.setUpdatedTimestamp(LocalDateTime.now());
|
| - |
|
1609 |
byPassRequest.setReason(reason);
|
| - |
|
1610 |
} else if (status.equals(ByPassRequestStatus.REJECTED)) {
|
| - |
|
1611 |
byPassRequest.setByPass(false);
|
| - |
|
1612 |
byPassRequest.setStatus(ByPassRequestStatus.REJECTED);
|
| - |
|
1613 |
byPassRequest.setUpdatedTimestamp(LocalDateTime.now());
|
| - |
|
1614 |
byPassRequest.setReason(reason);
|
| - |
|
1615 |
}
|
| - |
|
1616 |
|
| - |
|
1617 |
com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(byPassRequest.getFofoId());
|
| - |
|
1618 |
|
| - |
|
1619 |
Address address = addressRepository.selectById(user.getAddressId());
|
| - |
|
1620 |
|
| - |
|
1621 |
String title = "Billing Request";
|
| - |
|
1622 |
|
| - |
|
1623 |
String message = String.format("Your Billing Request is " + status + ". Please ensure to order the missing focus models as soon as possible.");
|
| - |
|
1624 |
|
| - |
|
1625 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| - |
|
1626 |
sendNotificationModel.setCampaignName("Billing Request");
|
| - |
|
1627 |
sendNotificationModel.setTitle(title);
|
| - |
|
1628 |
sendNotificationModel.setMessage(message);
|
| - |
|
1629 |
sendNotificationModel.setType("url");
|
| - |
|
1630 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
| - |
|
1631 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
| - |
|
1632 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| - |
|
1633 |
sendNotificationModel.setUserIds(Arrays.asList(userAccountRepository.selectUserIdByRetailerId(byPassRequest.getFofoId())));
|
| - |
|
1634 |
|
| - |
|
1635 |
notificationService.sendNotification(sendNotificationModel);
|
| - |
|
1636 |
|
| - |
|
1637 |
notificationService.sendWhatsappMessage(message, title, address.getPhoneNumber());
|
| - |
|
1638 |
|
| - |
|
1639 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| - |
|
1640 |
return "response";
|
| - |
|
1641 |
}
|
| - |
|
1642 |
|
| - |
|
1643 |
@RequestMapping(value = "/highDemandItem", method = RequestMethod.GET)
|
| - |
|
1644 |
public String highDemandItem(HttpServletRequest request, Model model) throws Exception {
|
| - |
|
1645 |
List<HighDemandItem> hdis = highDemandItemsRepository.selectAll();
|
| - |
|
1646 |
if (!hdis.isEmpty()) {
|
| - |
|
1647 |
Map<Integer, Item> itemMap = this.getItemByCatalogId(hdis);
|
| - |
|
1648 |
model.addAttribute("itemMap", itemMap);
|
| - |
|
1649 |
}
|
| - |
|
1650 |
|
| - |
|
1651 |
model.addAttribute("hdis", hdis);
|
| - |
|
1652 |
|
| - |
|
1653 |
return "high_demand_item";
|
| - |
|
1654 |
}
|
| - |
|
1655 |
|
| - |
|
1656 |
private Map<Integer, Item> getItemByCatalogId(List<HighDemandItem> hdis) {
|
| - |
|
1657 |
Map<Integer, Item> itemMap = new HashMap<>();
|
| - |
|
1658 |
for (HighDemandItem hdi : hdis) {
|
| - |
|
1659 |
List<Item> items = itemRepository.selectAllByCatalogItemId(hdi.getCatalogId());
|
| - |
|
1660 |
itemMap.put(items.get(0).getCatalogItemId(), items.get(0));
|
| - |
|
1661 |
}
|
| - |
|
1662 |
|
| - |
|
1663 |
return itemMap;
|
| - |
|
1664 |
}
|
| - |
|
1665 |
|
| - |
|
1666 |
@RequestMapping(value = "/addHighDemandItem", method = RequestMethod.POST)
|
| - |
|
1667 |
public String addHighDemandItem(HttpServletRequest request, @RequestParam int catalogId, @RequestParam int qty, Model model) throws Exception {
|
| - |
|
1668 |
HighDemandItem hdi = highDemandItemsRepository.selectByFofoIdAndCatalogId(catalogId);
|
| - |
|
1669 |
|
| - |
|
1670 |
if (hdi == null) {
|
| - |
|
1671 |
hdi = new HighDemandItem();
|
| - |
|
1672 |
hdi.setCatalogId(catalogId);
|
| - |
|
1673 |
hdi.setQty(qty);
|
| - |
|
1674 |
hdi.setCreateTimestamp(LocalDateTime.now());
|
| - |
|
1675 |
hdi.setUpdateTimestamp(LocalDateTime.now());
|
| - |
|
1676 |
highDemandItemsRepository.persist(hdi);
|
| - |
|
1677 |
}
|
| - |
|
1678 |
|
| - |
|
1679 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| - |
|
1680 |
return "response";
|
| - |
|
1681 |
}
|
| - |
|
1682 |
|
| - |
|
1683 |
@RequestMapping(value = "/removeHighDemandItem", method = RequestMethod.DELETE)
|
| - |
|
1684 |
public String removeHighDemandItem(HttpServletRequest request, @RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
| - |
|
1685 |
highDemandItemsRepository.deleteById(id);
|
| - |
|
1686 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| - |
|
1687 |
return "response";
|
| - |
|
1688 |
}
|
| - |
|
1689 |
|
| - |
|
1690 |
@GetMapping(value = "/imei")
|
| - |
|
1691 |
public String getImei(HttpServletRequest request, Model model, @RequestParam int fofoId, @RequestParam String query) throws Exception {
|
| - |
|
1692 |
|
| - |
|
1693 |
List<String> serialNumber = inventoryItemRepository.selectAllByFofoId(fofoId, query).stream().map(x -> x.getSerialNumber()).collect(Collectors.toList());
|
| - |
|
1694 |
LOGGER.info("serialNumber" + serialNumber);
|
| - |
|
1695 |
LOGGER.info("query" + query);
|
| - |
|
1696 |
|
| - |
|
1697 |
model.addAttribute("response1", mvcResponseSender.createResponseString(serialNumber));
|
| - |
|
1698 |
|
| - |
|
1699 |
return "response";
|
| - |
|
1700 |
}
|
| - |
|
1701 |
|
| - |
|
1702 |
@GetMapping(value = "/allimei")
|
| - |
|
1703 |
public String getAllImei(HttpServletRequest request, Model model, @RequestParam String query) throws Exception {
|
| - |
|
1704 |
|
| - |
|
1705 |
List<String> serialNumber = inventoryItemRepository.selectAll(query).stream().map(x -> x.getSerialNumber()).collect(Collectors.toList());
|
| - |
|
1706 |
LOGGER.info("serialNumber" + serialNumber);
|
| - |
|
1707 |
LOGGER.info("query" + query);
|
| - |
|
1708 |
|
| - |
|
1709 |
model.addAttribute("response1", mvcResponseSender.createResponseString(serialNumber));
|
| - |
|
1710 |
|
| - |
|
1711 |
return "response";
|
| - |
|
1712 |
}
|
| - |
|
1713 |
|
| - |
|
1714 |
@Autowired
|
| - |
|
1715 |
private ObjectMapper objectMapper;
|
| - |
|
1716 |
|
| - |
|
1717 |
@RequestMapping(value = "/imei/validate", method = RequestMethod.GET)
|
| - |
|
1718 |
public String validateImei(HttpServletRequest request, @RequestParam String imei, Model model) throws Exception {
|
| - |
|
1719 |
boolean isImei = false;
|
| - |
|
1720 |
|
| - |
|
1721 |
try {
|
| - |
|
1722 |
InventoryItem inventoryItem = inventoryItemRepository.selectBySerialNumber(imei);
|
| - |
|
1723 |
|
| - |
|
1724 |
isImei = true;
|
| - |
|
1725 |
|
| - |
|
1726 |
} catch (Exception e) {
|
| - |
|
1727 |
isImei = false;
|
| - |
|
1728 |
}
|
| - |
|
1729 |
|
| - |
|
1730 |
model.addAttribute("response1", objectMapper.writeValueAsString(isImei));
|
| - |
|
1731 |
return "response";
|
| - |
|
1732 |
}
|
| - |
|
1733 |
|
| - |
|
1734 |
@RequestMapping(value = "/createCombo", method = RequestMethod.GET)
|
| - |
|
1735 |
public String createCombo(HttpServletRequest request, Model model) throws Exception {
|
| - |
|
1736 |
|
| - |
|
1737 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| - |
|
1738 |
|
| - |
|
1739 |
List<ComboModel> comboModels = comboModelRepository.selectAll();
|
| - |
|
1740 |
|
| - |
|
1741 |
model.addAttribute("warehouseMap", warehouseMap);
|
| - |
|
1742 |
model.addAttribute("comboModels", comboModels);
|
| - |
|
1743 |
return "create-combo";
|
| - |
|
1744 |
}
|
| - |
|
1745 |
|
| - |
|
1746 |
@RequestMapping(value = "/addCombo", method = RequestMethod.POST)
|
| - |
|
1747 |
public String addCombo(HttpServletRequest request, @RequestBody Combo combo, Model model) throws Exception {
|
| - |
|
1748 |
|
| - |
|
1749 |
for (Integer warehouseId : combo.getWarehouseId()) {
|
| - |
|
1750 |
|
| - |
|
1751 |
ComboModel comboModel = comboModelRepository.selectByCatalogIdWarehouseIdAndQty(combo.getCatalogId(), warehouseId, combo.getQty());
|
| - |
|
1752 |
if (comboModel != null) {
|
| - |
|
1753 |
List<ComboMappedModel> comboMappedModels = comboMappedModelRepository.selectByComboId(comboModel.getId());
|
| - |
|
1754 |
for (ComboMappedModel comboMappedModel : comboMappedModels) {
|
| - |
|
1755 |
comboMappedModelRepository.delete(comboMappedModel);
|
| - |
|
1756 |
}
|
| - |
|
1757 |
|
| - |
|
1758 |
comboModelRepository.delete(comboModel);
|
| - |
|
1759 |
}
|
| - |
|
1760 |
ComboModel cm = new ComboModel();
|
| - |
|
1761 |
cm.setCatalogId(combo.getCatalogId());
|
| - |
|
1762 |
cm.setQty(combo.getQty());
|
| - |
|
1763 |
cm.setWarehouseId(warehouseId);
|
| - |
|
1764 |
comboModelRepository.persist(cm);
|
| - |
|
1765 |
|
| - |
|
1766 |
LOGGER.info("cm" + cm);
|
| - |
|
1767 |
|
| - |
|
1768 |
for (MappedComboModel mcc : combo.getMappedComboModel()) {
|
| - |
|
1769 |
ComboMappedModel cmm = new ComboMappedModel();
|
| - |
|
1770 |
cmm.setComboCatalogId(mcc.getCatalogId());
|
| - |
|
1771 |
cmm.setComboQty(mcc.getQty());
|
| - |
|
1772 |
cmm.setComboId(cm.getId());
|
| - |
|
1773 |
comboMappedModelRepository.persist(cmm);
|
| - |
|
1774 |
|
| - |
|
1775 |
}
|
| - |
|
1776 |
|
| - |
|
1777 |
}
|
| - |
|
1778 |
|
| - |
|
1779 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| - |
|
1780 |
|
| - |
|
1781 |
return "response";
|
| - |
|
1782 |
|
| - |
|
1783 |
}
|
| - |
|
1784 |
|
| - |
|
1785 |
@RequestMapping(value = "/combo/remove", method = RequestMethod.POST)
|
| - |
|
1786 |
public String removeCombo(HttpServletRequest request, @RequestParam int id, Model model) throws Exception {
|
| - |
|
1787 |
comboMappedModelRepository.deleteByEquals(id);
|
| - |
|
1788 |
comboModelRepository.deleteById(id);
|
| - |
|
1789 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| - |
|
1790 |
|
| - |
|
1791 |
return "response";
|
| - |
|
1792 |
|
| - |
|
1793 |
}
|
| 1958 |
}
|
1794 |
}
|