Subversion Repositories SmartDukaan

Rev

Rev 23984 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 23984 Rev 24168
Line 4... Line 4...
4
import java.util.HashMap;
4
import java.util.HashMap;
5
import java.util.HashSet;
5
import java.util.HashSet;
6
import java.util.List;
6
import java.util.List;
7
import java.util.Map;
7
import java.util.Map;
8
import java.util.Set;
8
import java.util.Set;
-
 
9
import java.util.stream.Collectors;
9
 
10
 
10
import javax.servlet.http.HttpServletRequest;
11
import javax.servlet.http.HttpServletRequest;
11
 
12
 
12
import org.apache.logging.log4j.LogManager;
13
import org.apache.logging.log4j.LogManager;
13
import org.apache.logging.log4j.Logger;
14
import org.apache.logging.log4j.Logger;
14
import org.springframework.beans.factory.annotation.Autowired;
15
import org.springframework.beans.factory.annotation.Autowired;
15
import org.springframework.beans.factory.annotation.Qualifier;
16
import org.springframework.beans.factory.annotation.Qualifier;
16
import org.springframework.stereotype.Controller;
17
import org.springframework.stereotype.Controller;
17
import org.springframework.transaction.annotation.Transactional;
18
import org.springframework.transaction.annotation.Transactional;
18
import org.springframework.ui.Model;
19
import org.springframework.ui.Model;
-
 
20
import org.springframework.web.bind.annotation.PathVariable;
19
import org.springframework.web.bind.annotation.RequestBody;
21
import org.springframework.web.bind.annotation.RequestBody;
20
import org.springframework.web.bind.annotation.RequestMapping;
22
import org.springframework.web.bind.annotation.RequestMapping;
21
import org.springframework.web.bind.annotation.RequestMethod;
23
import org.springframework.web.bind.annotation.RequestMethod;
22
import org.springframework.web.bind.annotation.RequestParam;
24
import org.springframework.web.bind.annotation.RequestParam;
23
 
25
 
Line 39... Line 41...
39
import com.spice.profitmandi.dao.entity.nonbillable.PartnerCurrentInventorySnapshot;
41
import com.spice.profitmandi.dao.entity.nonbillable.PartnerCurrentInventorySnapshot;
40
import com.spice.profitmandi.dao.entity.nonbillable.ScanOutPartnerItem;
42
import com.spice.profitmandi.dao.entity.nonbillable.ScanOutPartnerItem;
41
import com.spice.profitmandi.dao.entity.nonbillable.Vendor;
43
import com.spice.profitmandi.dao.entity.nonbillable.Vendor;
42
import com.spice.profitmandi.dao.entity.nonbillable.Warehouse;
44
import com.spice.profitmandi.dao.entity.nonbillable.Warehouse;
43
import com.spice.profitmandi.dao.entity.user.Address;
45
import com.spice.profitmandi.dao.entity.user.Address;
44
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
-
 
45
import com.spice.profitmandi.dao.enumuration.nonbillable.InstructionItemStatus;
46
import com.spice.profitmandi.dao.enumuration.nonbillable.InstructionItemStatus;
46
import com.spice.profitmandi.dao.repository.dtr.RetailerRegisteredAddressRepository;
47
import com.spice.profitmandi.dao.repository.dtr.RetailerRegisteredAddressRepository;
47
import com.spice.profitmandi.dao.repository.dtr.RoleRepository;
48
import com.spice.profitmandi.dao.repository.dtr.RoleRepository;
48
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
49
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
49
import com.spice.profitmandi.dao.repository.dtr.UserRoleRepository;
50
import com.spice.profitmandi.dao.repository.dtr.UserRoleRepository;
Line 64... Line 65...
64
import com.spice.profitmandi.service.nonbillable.InventoryService;
65
import com.spice.profitmandi.service.nonbillable.InventoryService;
65
import com.spice.profitmandi.service.user.RetailerService;
66
import com.spice.profitmandi.service.user.RetailerService;
66
import com.spice.profitmandi.service.user.UserService;
67
import com.spice.profitmandi.service.user.UserService;
67
import com.spice.profitmandi.web.model.LoginDetails;
68
import com.spice.profitmandi.web.model.LoginDetails;
68
import com.spice.profitmandi.web.util.CookiesProcessor;
69
import com.spice.profitmandi.web.util.CookiesProcessor;
-
 
70
import com.spice.profitmandi.web.util.MVCResponseSender;
69
 
71
 
70
@Controller
72
@Controller
71
@Transactional
73
@Transactional
72
public class ItemController {
74
public class ItemController {
73
 
75
 
Line 76... Line 78...
76
	@Autowired
78
	@Autowired
77
	@Qualifier("nonbillableItemRepository")
79
	@Qualifier("nonbillableItemRepository")
78
	private ItemRepository itemRepository;
80
	private ItemRepository itemRepository;
79
 
81
 
80
	@Autowired
82
	@Autowired
-
 
83
	private MVCResponseSender mvcResponseSender;
-
 
84
 
-
 
85
	@Autowired
81
	@Qualifier("nonbillableInventoryService")
86
	@Qualifier("nonbillableInventoryService")
82
	private InventoryService inventoryService;
87
	private InventoryService inventoryService;
83
	@Autowired
88
	@Autowired
84
	private RoleRepository roleRepository;
89
	private RoleRepository roleRepository;
85
	@Autowired
90
	@Autowired
Line 388... Line 393...
388
			@RequestParam(name = "offset", defaultValue = "0") int offset,
393
			@RequestParam(name = "offset", defaultValue = "0") int offset,
389
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
394
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
390
			throws ProfitMandiBusinessException {
395
			throws ProfitMandiBusinessException {
391
		LOGGER.info("Request Received at url {} with body {}", request.getRequestURI(), scanInItemRequest);
396
		LOGGER.info("Request Received at url {} with body {}", request.getRequestURI(), scanInItemRequest);
392
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
397
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
393
		List<Integer> warehouseIds = userWarehouseRepository.selectWarehouseIdsByUserId(loginDetails.getFofoId());
-
 
394
		List<Item> items = itemRepository.selectAll();
-
 
395
		inventoryService.scanInItem(scanInItemRequest, loginDetails.getFofoId());
398
		inventoryService.scanInItem(scanInItemRequest, loginDetails.getFofoId());
396
		List<AdminCurrentInventorySnapshot> adminCurrentInventorySnapshots = adminCurrentInventorySnapshotRepository
-
 
397
				.selectAllByAdminId(loginDetails.getFofoId(), offset, limit);
399
		return getScanInItems(request, scanInItemRequest.getWarehouseId(), 0, 10, model);
398
		Map<Integer, String> itemIdDescriptionMap = this
-
 
399
				.adminCurrentInventorySnapshotsToItemIdDescriptionMap(adminCurrentInventorySnapshots);
-
 
400
		long size = adminCurrentInventorySnapshotRepository.selectAllCountByAdminId(loginDetails.getFofoId());
-
 
401
		if (!warehouseIds.isEmpty()) {
-
 
402
			model.addAttribute("warehouses", warehouseRepository.selectByIds(new HashSet<>(warehouseIds)));
-
 
403
		}
400
	}
-
 
401
 
404
		model.addAttribute("items", items);
402
	@RequestMapping(value = "/authorisedWarehouses", method = RequestMethod.GET)
405
		model.addAttribute("adminCurrentInventorySnapshots", adminCurrentInventorySnapshots);
403
	public String getAuthorisedWarehouses(HttpServletRequest request, Model model) throws Throwable {
406
		model.addAttribute("itemIdDescriptionMap", itemIdDescriptionMap);
404
		LOGGER.info("Request Received at url {}", request.getRequestURI());
407
		model.addAttribute("start", offset + 1);
405
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
408
		model.addAttribute("size", size);
-
 
409
		if (adminCurrentInventorySnapshots.size() < limit) {
406
		List<Integer> warehouseIds = userWarehouseRepository.selectWarehouseIdsByUserId(loginDetails.getFofoId());
410
			model.addAttribute("end", offset + adminCurrentInventorySnapshots.size());
407
		List<Warehouse> authorisedWarehouses = warehouseRepository.selectByIds(new HashSet<>(warehouseIds));
411
		} else {
-
 
412
			model.addAttribute("end", offset + limit);
408
		model.addAttribute("response", mvcResponseSender.createResponseString(authorisedWarehouses));
413
		}
-
 
414
		return "scan-in-items";
409
		return "response";
415
	}
410
	}
416
 
411
 
417
	@RequestMapping(value = "/getScanInItems", method = RequestMethod.GET)
412
	@RequestMapping(value = "/getScanInItems/{warehouseId}", method = RequestMethod.GET)
418
	public String getScanInItems(HttpServletRequest request,
413
	public String getScanInItems(HttpServletRequest request, @PathVariable int warehouseId,
419
			@RequestParam(name = "offset", defaultValue = "0") int offset,
414
			@RequestParam(name = "offset", defaultValue = "0") int offset,
420
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
415
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
421
			throws ProfitMandiBusinessException {
416
			throws ProfitMandiBusinessException {
422
		LOGGER.info("Request Received at url {}", request.getRequestURI());
417
		LOGGER.info("Request Received at url {}", request.getRequestURI());
423
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
418
		LOGGER.info("Warehouse Id is  {}", request.getRequestURI());
424
		List<Integer> warehouseIds = userWarehouseRepository.selectWarehouseIdsByUserId(loginDetails.getFofoId());
419
		Warehouse warehouse = warehouseRepository.selectById(warehouseId);
425
		List<Item> items = itemRepository.selectAll();
420
		List<Item> items = itemRepository.selectAll();
426
		List<AdminCurrentInventorySnapshot> adminCurrentInventorySnapshots = adminCurrentInventorySnapshotRepository
421
		List<AdminCurrentInventorySnapshot> adminCurrentInventorySnapshots = adminCurrentInventorySnapshotRepository
427
				.selectAllByAdminId(loginDetails.getFofoId(), offset, limit);
422
				.selectAllByWarehouseId(warehouseId, offset, limit);
428
		Map<Integer, String> itemIdDescriptionMap = this
423
		Map<Integer, String> itemIdDescriptionMap = this
429
				.adminCurrentInventorySnapshotsToItemIdDescriptionMap(adminCurrentInventorySnapshots);
424
				.adminCurrentInventorySnapshotsToItemIdDescriptionMap(adminCurrentInventorySnapshots);
430
		long size = adminCurrentInventorySnapshotRepository.selectAllCountByAdminId(loginDetails.getFofoId());
425
		long size = adminCurrentInventorySnapshotRepository.selectAllCountByWarehouseId(warehouseId);
431
		if (!warehouseIds.isEmpty()) {
-
 
432
			model.addAttribute("warehouses", warehouseRepository.selectByIds(new HashSet<>(warehouseIds)));
-
 
433
		}
-
 
434
		model.addAttribute("items", items);
426
		model.addAttribute("items", items);
-
 
427
		model.addAttribute("warehouse", warehouse);
435
		model.addAttribute("adminCurrentInventorySnapshots", adminCurrentInventorySnapshots);
428
		model.addAttribute("adminCurrentInventorySnapshots", adminCurrentInventorySnapshots);
436
		model.addAttribute("itemIdDescriptionMap", itemIdDescriptionMap);
429
		model.addAttribute("itemIdDescriptionMap", itemIdDescriptionMap);
437
		model.addAttribute("start", offset + 1);
430
		model.addAttribute("start", offset + 1);
438
		model.addAttribute("size", size);
431
		model.addAttribute("size", size);
439
		if (adminCurrentInventorySnapshots.size() < limit) {
432
		if (adminCurrentInventorySnapshots.size() < limit) {
Line 442... Line 435...
442
			model.addAttribute("end", offset + limit);
435
			model.addAttribute("end", offset + limit);
443
		}
436
		}
444
		return "scan-in-items";
437
		return "scan-in-items";
445
	}
438
	}
446
 
439
 
447
	@RequestMapping(value = "/getPaginatedScanInItems", method = RequestMethod.GET)
440
	@RequestMapping(value = "/getPaginatedScanInItems/{warehouseId}", method = RequestMethod.GET)
448
	public String getPaginatedScanInItems(HttpServletRequest request,
441
	public String getPaginatedScanInItems(HttpServletRequest request, @PathVariable int warehouseId,
449
			@RequestParam(name = "offset", defaultValue = "0") int offset,
442
			@RequestParam(name = "offset", defaultValue = "0") int offset,
450
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
443
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
451
			throws ProfitMandiBusinessException {
444
			throws ProfitMandiBusinessException {
452
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
-
 
453
		List<AdminCurrentInventorySnapshot> adminCurrentInventorySnapshots = adminCurrentInventorySnapshotRepository
445
		List<AdminCurrentInventorySnapshot> adminCurrentInventorySnapshots = adminCurrentInventorySnapshotRepository
454
				.selectAllByAdminId(loginDetails.getFofoId(), offset, limit);
446
				.selectAllByWarehouseId(warehouseId);
455
		Map<Integer, String> itemIdDescriptionMap = this
447
		Map<Integer, String> itemIdDescriptionMap = this
456
				.adminCurrentInventorySnapshotsToItemIdDescriptionMap(adminCurrentInventorySnapshots);
448
				.adminCurrentInventorySnapshotsToItemIdDescriptionMap(adminCurrentInventorySnapshots);
457
		model.addAttribute("adminCurrentInventorySnapshots", adminCurrentInventorySnapshots);
449
		model.addAttribute("adminCurrentInventorySnapshots", adminCurrentInventorySnapshots);
458
		model.addAttribute("itemIdDescriptionMap", itemIdDescriptionMap);
450
		model.addAttribute("itemIdDescriptionMap", itemIdDescriptionMap);
459
		return "scan-in-items-paginated";
451
		return "scan-in-items-paginated";
Line 581... Line 573...
581
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
573
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
582
			throws ProfitMandiBusinessException {
574
			throws ProfitMandiBusinessException {
583
		LOGGER.info("Request Received at url {} with body {}", request.getRequestURI(), instructionItemRequest);
575
		LOGGER.info("Request Received at url {} with body {}", request.getRequestURI(), instructionItemRequest);
584
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
576
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
585
		inventoryService.instructionItem(instructionItemRequest, loginDetails.getFofoId());
577
		inventoryService.instructionItem(instructionItemRequest, loginDetails.getFofoId());
586
		return this.getInstructionItems(request, offset, limit, model);
578
		return this.getInstructionItems(request, instructionItemRequest.getWarehouseId(), offset, limit, model);
587
	}
579
	}
588
 
580
 
589
	@RequestMapping(value = "/getInstructionItems", method = RequestMethod.GET)
581
	@RequestMapping(value = "/getInstructionItems/{warehouseId}", method = RequestMethod.GET)
590
	public String getInstructionItems(HttpServletRequest request,
582
	public String getInstructionItems(HttpServletRequest request, @PathVariable int warehouseId,
591
			@RequestParam(name = "offset", defaultValue = "0") int offset,
583
			@RequestParam(name = "offset", defaultValue = "0") int offset,
592
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
584
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
593
			throws ProfitMandiBusinessException {
585
			throws ProfitMandiBusinessException {
594
		LOGGER.info("Request Received at url {}", request.getRequestURI());
586
		LOGGER.info("Request Received at url {}", request.getRequestURI());
595
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
-
 
596
		List<InstructionItem> instructionItems = instructionItemRepository.selectAllByAdminId(loginDetails.getFofoId(),
587
		List<InstructionItem> instructionItems = instructionItemRepository.selectAllByWarehouseId(warehouseId, offset,
597
				offset, limit);
588
				limit);
598
		LOGGER.info("instructionItems" + instructionItems);
589
		LOGGER.info("instructionItems" + instructionItems);
599
		Set<Integer> instructionItemWarehouseIds = this.instructionItemsToWarehouseIds(instructionItems);
590
		Set<Integer> instructionItemWarehouseIds = this.instructionItemsToWarehouseIds(instructionItems);
600
		LOGGER.info("instructionItemWarehouseIds" + instructionItemWarehouseIds);
591
		LOGGER.info("instructionItemWarehouseIds" + instructionItemWarehouseIds);
601
		List<Warehouse> warehouses = new ArrayList<>();
-
 
602
		if (!instructionItemWarehouseIds.isEmpty()) {
-
 
603
 
-
 
604
			warehouses = warehouseRepository.selectByIds(instructionItemWarehouseIds);
592
		Warehouse warehouse = warehouseRepository.selectById(warehouseId);
605
 
593
 
606
		}
-
 
607
		Map<Integer, String> warehouseIdNameMap = this.warehouseIdNameMap(warehouses);
594
		Map<Integer, String> userIdStoreNameMap = retailerService.getAllFofoRetailerIdNameMap();
608
 
595
 
609
		List<Integer> warehouseIds = userWarehouseRepository.selectWarehouseIdsByUserId(loginDetails.getFofoId());
-
 
610
		if (!warehouseIds.isEmpty()) {
-
 
611
			model.addAttribute("warehouses", warehouseRepository.selectByIds(new HashSet<>(warehouseIds)));
-
 
612
			LOGGER.info(warehouseRepository.selectByIds(new HashSet<>(warehouseIds)) + "warehouseIdNameMap");
-
 
613
		}
-
 
614
 
-
 
615
		List<Integer> userIds = userRoleRepository
-
 
616
				.selectUserIdsByRoleId(roleRepository.selectByName(RoleType.FOFO_ADMIN.toString()).getId());
-
 
617
		Map<Integer, String> userIdEmailIdMap = userService.getAllUseUserIdEmailIdMap(userIds);
-
 
618
 
-
 
619
		model.addAttribute("fofoIdEmailIdMap", userIdEmailIdMap);
596
		model.addAttribute("userIdStoreNameMap", userIdStoreNameMap);
620
		long size = instructionItemRepository.selectCountByAdminId(loginDetails.getFofoId());
597
		long size = instructionItemRepository.selectCountByWarehouseId(warehouseId);
621
		model.addAttribute("warehouseIdNameMap", warehouseIdNameMap);
598
		model.addAttribute("warehouse", warehouse);
622
		model.addAttribute("instructionItems", instructionItems);
599
		model.addAttribute("instructionItems", instructionItems);
623
		model.addAttribute("start", offset + 1);
600
		model.addAttribute("start", offset + 1);
624
		model.addAttribute("size", size);
601
		model.addAttribute("size", size);
625
		if (instructionItems.size() < limit) {
602
		if (instructionItems.size() < limit) {
626
			model.addAttribute("end", offset + instructionItems.size());
603
			model.addAttribute("end", offset + instructionItems.size());
Line 629... Line 606...
629
		}
606
		}
630
 
607
 
631
		return "instruction-items";
608
		return "instruction-items";
632
	}
609
	}
633
 
610
 
634
	@RequestMapping(value = "/getPaginatedInstructionItems", method = RequestMethod.GET)
611
	@RequestMapping(value = "/getPaginatedInstructionItems/{warehouseId}", method = RequestMethod.GET)
635
	public String getPaginatedInstructionItems(HttpServletRequest request,
612
	public String getPaginatedInstructionItems(HttpServletRequest request, @PathVariable int warehouseId,
636
			@RequestParam(name = "offset", defaultValue = "0") int offset,
613
			@RequestParam(name = "offset", defaultValue = "0") int offset,
637
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
614
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
638
			throws ProfitMandiBusinessException {
615
			throws ProfitMandiBusinessException {
639
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
-
 
640
		List<InstructionItem> instructionItems = instructionItemRepository.selectAllByAdminId(loginDetails.getFofoId(),
616
		List<InstructionItem> instructionItems = instructionItemRepository.selectAllByWarehouseId(warehouseId, offset,
641
				offset, limit);
617
				limit);
642
 
618
 
643
		Set<Integer> warehouseIds = this.instructionItemsToWarehouseIds(instructionItems);
-
 
644
		List<Warehouse> warehouses = warehouseRepository.selectByIds(warehouseIds);
619
		Warehouse warehouse = warehouseRepository.selectById(warehouseId);
645
		Map<Integer, String> warehouseIdNameMap = this.warehouseIdNameMap(warehouses);
-
 
646
 
620
 
647
		model.addAttribute("warehouseIdNameMap", warehouseIdNameMap);
621
		model.addAttribute("warehouse", warehouse);
648
		model.addAttribute("instructionItems", instructionItems);
622
		model.addAttribute("instructionItems", instructionItems);
649
		return "scan-out-partner-items-paginated";
623
		return "scan-out-partner-items-paginated";
650
	}
624
	}
651
 
625
 
652
	@RequestMapping(value = "/scanOutPartnerItem", method = RequestMethod.POST)
626
	@RequestMapping(value = "/scanOutPartnerItem", method = RequestMethod.POST)
Line 686... Line 660...
686
		if (adminDeliveryNote.getCompleteTimestamp() != null) {
660
		if (adminDeliveryNote.getCompleteTimestamp() != null) {
687
			throw new ProfitMandiBusinessException(
661
			throw new ProfitMandiBusinessException(
688
					ProfitMandiConstants.DELIVERY_NOTE_ID + ", " + ProfitMandiConstants.FOFO_ID,
662
					ProfitMandiConstants.DELIVERY_NOTE_ID + ", " + ProfitMandiConstants.FOFO_ID,
689
					deliveryNoteId + ", " + loginDetails.getFofoId(), "NNBLBL_ITM_1002");
663
					deliveryNoteId + ", " + loginDetails.getFofoId(), "NNBLBL_ITM_1002");
690
		}
664
		}
691
		Warehouse warehouse = warehouseRepository.selectId(adminDeliveryNote.getWarehouseId());
665
		Warehouse warehouse = warehouseRepository.selectById(adminDeliveryNote.getWarehouseId());
692
		List<Integer> instructionItemIds = adminDeliveryNoteDetailRepository
666
		List<Integer> instructionItemIds = adminDeliveryNoteDetailRepository
693
				.selectInstructionItemIdsByDeliveryNoteId(deliveryNoteId);
667
				.selectInstructionItemIdsByDeliveryNoteId(deliveryNoteId);
694
		List<InstructionItemDetail> instructionItemDetails = instructionItemDetailRepository
668
		List<InstructionItemDetail> instructionItemDetails = instructionItemDetailRepository
695
				.selectByInstructionItemIds(new HashSet<>(instructionItemIds));
669
				.selectByInstructionItemIds(new HashSet<>(instructionItemIds));
696
		Map<Integer, Integer> itemIdQuantityMap = this
670
		Map<Integer, Integer> itemIdQuantityMap = this
Line 741... Line 715...
741
	public String getPendingInstructionItems(HttpServletRequest request,
715
	public String getPendingInstructionItems(HttpServletRequest request,
742
			@RequestParam(name = ProfitMandiConstants.WAREHOUSE_ID) int warehouseId,
716
			@RequestParam(name = ProfitMandiConstants.WAREHOUSE_ID) int warehouseId,
743
			@RequestParam(name = ProfitMandiConstants.USER_ID) int userId, Model model)
717
			@RequestParam(name = ProfitMandiConstants.USER_ID) int userId, Model model)
744
			throws ProfitMandiBusinessException {
718
			throws ProfitMandiBusinessException {
745
		LOGGER.info("Request Received at url {}", request.getRequestURI());
719
		LOGGER.info("Request Received at url {}", request.getRequestURI());
746
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
-
 
747
		List<InstructionItem> instructionItems = instructionItemRepository.selectByAdminIdWarehouseIdUserIdStatus(
720
		List<InstructionItem> instructionItems = instructionItemRepository.selectByWarehouseIdUserIdStatus(warehouseId,
748
				loginDetails.getFofoId(), warehouseId, userId, InstructionItemStatus.PENDING);
721
				userId, InstructionItemStatus.PENDING);
749
		Set<Integer> instructionItemIds = this.instructionItemsToInstructionItemIds(instructionItems);
722
		Set<Integer> instructionItemIds = this.instructionItemsToInstructionItemIds(instructionItems);
750
		List<InstructionItemDetail> instructionItemDetails = instructionItemDetailRepository
723
		List<InstructionItemDetail> instructionItemDetails = instructionItemDetailRepository
751
				.selectByInstructionItemIds(instructionItemIds);
724
				.selectByInstructionItemIds(instructionItemIds);
752
		Set<Integer> itemIds = this.instructionItemDetailsToItemIds(instructionItemDetails);
725
		Set<Integer> itemIds = this.instructionItemDetailsToItemIds(instructionItemDetails);
753
		Map<Integer, List<InstructionItemDetail>> instructionItemIdInstructionItemDetailsMap = this
726
		Map<Integer, List<InstructionItemDetail>> instructionItemIdInstructionItemDetailsMap = this
Line 759... Line 732...
759
		model.addAttribute("itemIdDescriptionMap", itemIdDescriptionMap);
732
		model.addAttribute("itemIdDescriptionMap", itemIdDescriptionMap);
760
		model.addAttribute("itemIdTypeMap", itemIdTypeMap);
733
		model.addAttribute("itemIdTypeMap", itemIdTypeMap);
761
		return "pending-instruction-items";
734
		return "pending-instruction-items";
762
	}
735
	}
763
 
736
 
764
	@RequestMapping(value = "/getScanOutItems", method = RequestMethod.GET)
737
	@RequestMapping(value = "/getScanOutItems/{warehouseId}", method = RequestMethod.GET)
765
	public String getScanOutItems(HttpServletRequest request,
738
	public String getScanOutItems(HttpServletRequest request, @PathVariable int warehouseId,
766
			@RequestParam(name = "offset", defaultValue = "0") int offset,
739
			@RequestParam(name = "offset", defaultValue = "0") int offset,
767
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
740
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
768
			throws ProfitMandiBusinessException {
741
			throws ProfitMandiBusinessException {
769
		LOGGER.info("Request Received at url {}", request.getRequestURI());
742
		LOGGER.info("Request Received at url {}", request.getRequestURI());
770
		// List<AdminCurrentInventorySnapshot> adminCurrentInventorySnapshots =
-
 
771
		// adminCurrentInventorySnapshotRepository.selectAll();
-
 
772
		// Set<Integer> adminIds = this.getAdminIds(adminCurrentInventorySnapshots);
743
		List<InstructionItem> instructionItems = instructionItemRepository.selectByWarehouseIdStatus(warehouseId,
773
		// Map<Integer, String> adminIdEmailIdMap =
744
				InstructionItemStatus.PENDING);
774
		// retailerService.getAllFofoRetailerIdEmailIdMap(adminIds);
745
		Map<Integer, String> fofoIdNameMap = retailerService.getFofoRetailerIdNameMap(
775
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
-
 
776
		List<InstructionItem> instructionItems = instructionItemRepository
746
				instructionItems.stream().map(InstructionItem::getFofoId).collect(Collectors.toList()));
777
				.selectByAdminIdStatus(loginDetails.getFofoId(), InstructionItemStatus.PENDING);
-
 
778
 
747
 
779
		List<Warehouse> warehouses = new ArrayList<>();
-
 
780
		Map<Integer, String> fofoIdEmailIdMap = new HashMap<>();
-
 
781
		if (!instructionItems.isEmpty()) {
-
 
782
			Set<Integer> warehouseIds = this.instructionItemsToWarehouseIds(instructionItems);
-
 
783
			warehouses = warehouseRepository.selectByIds(warehouseIds);
748
		Warehouse warehouse = warehouseRepository.selectById(warehouseId);
784
			Set<Integer> fofoIds = this.instructionItemsToFofoIds(instructionItems);
-
 
785
			fofoIdEmailIdMap = retailerService.getAllFofoRetailerIdEmailIdMap(fofoIds);
749
		long deliveryNotesCount = adminDeliveryNoteRepository.selectAllByWarehouseIdCount(warehouseId);
786
		}
-
 
787
 
750
 
788
		List<AdminDeliveryNote> adminDeliveryNotes = adminDeliveryNoteRepository.selectAll(offset, limit);
751
		List<AdminDeliveryNote> adminDeliveryNotes = null;
789
		Map<Integer, String> warehouseIdNameMap = new HashMap<>();
-
 
790
		if (!adminDeliveryNotes.isEmpty()) {
752
		if (deliveryNotesCount > 0) {
791
			List<Warehouse> adminDeliveryNoteWarehouses = warehouseRepository
753
			adminDeliveryNotes = adminDeliveryNoteRepository.selectAllByWarehouseId(warehouseId, offset, limit);
792
					.selectByIds(this.adminDeliveryNotesToWarehouseIds(adminDeliveryNotes));
-
 
793
			warehouseIdNameMap = this.warehouseIdNameMap(adminDeliveryNoteWarehouses);
-
 
794
			fofoIdEmailIdMap = retailerService
754
		} else {
795
					.getAllFofoRetailerIdEmailIdMap(this.adminDeliveryNotesToFofoIds(adminDeliveryNotes));
755
			adminDeliveryNotes = new ArrayList<>();
796
		}
756
		}
797
		long size = adminDeliveryNoteRepository.selectAllCount();
757
		long size = adminDeliveryNoteRepository.selectAllCount();
798
		// model.addAttribute("adminIdEmailIdMap", adminIdEmailIdMap);
758
		model.addAttribute("warehouse", warehouse);
799
		model.addAttribute("adminDeliveryNotes", adminDeliveryNotes);
759
		model.addAttribute("adminDeliveryNotes", adminDeliveryNotes);
800
		model.addAttribute("warehouses", warehouses);
-
 
801
		model.addAttribute("warehouseIdNameMap", warehouseIdNameMap);
-
 
802
		model.addAttribute("fofoIdEmailIdMap", fofoIdEmailIdMap);
760
		model.addAttribute("fofoIdNameMap", fofoIdNameMap);
803
		model.addAttribute("start", offset + 1);
761
		model.addAttribute("start", offset + 1);
804
		model.addAttribute("size", size);
762
		model.addAttribute("size", size);
805
		if (adminDeliveryNotes.size() < limit) {
763
		if (adminDeliveryNotes.size() < limit) {
806
			model.addAttribute("end", offset + adminDeliveryNotes.size());
764
			model.addAttribute("end", offset + adminDeliveryNotes.size());
807
		} else {
765
		} else {
Line 816... Line 774...
816
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
774
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
817
			throws ProfitMandiBusinessException {
775
			throws ProfitMandiBusinessException {
818
		LOGGER.info("Request Received at url {} with body {}", request.getRequestURI(), scanOutItemRequest);
776
		LOGGER.info("Request Received at url {} with body {}", request.getRequestURI(), scanOutItemRequest);
819
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
777
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
820
		inventoryService.scanOutItem(scanOutItemRequest, loginDetails.getFofoId());
778
		inventoryService.scanOutItem(scanOutItemRequest, loginDetails.getFofoId());
821
		return this.getScanOutItems(request, offset, limit, model);
779
		return this.getScanOutItems(request, scanOutItemRequest.getWarehouseId(), offset, limit, model);
822
	}
780
	}
823
 
781
 
824
	@RequestMapping(value = "/getPaginatedScanOutItems", method = RequestMethod.GET)
782
	@RequestMapping(value = "/getPaginatedScanOutItems", method = RequestMethod.GET)
825
	public String getPaginatedScanOutItems(HttpServletRequest request,
783
	public String getPaginatedScanOutItems(HttpServletRequest request,
826
			@RequestParam(name = "offset", defaultValue = "0") int offset,
784
			@RequestParam(name = "offset", defaultValue = "0") int offset,