| Line 2... |
Line 2... |
| 2 |
|
2 |
|
| 3 |
import java.io.ByteArrayInputStream;
|
3 |
import java.io.ByteArrayInputStream;
|
| 4 |
import java.io.ByteArrayOutputStream;
|
4 |
import java.io.ByteArrayOutputStream;
|
| 5 |
import java.io.InputStream;
|
5 |
import java.io.InputStream;
|
| 6 |
import java.time.LocalDateTime;
|
6 |
import java.time.LocalDateTime;
|
| - |
|
7 |
import java.util.Arrays;
|
| - |
|
8 |
import java.util.HashSet;
|
| 7 |
import java.util.List;
|
9 |
import java.util.List;
|
| 8 |
import java.util.Map;
|
10 |
import java.util.Map;
|
| 9 |
|
11 |
|
| 10 |
import javax.servlet.http.HttpServletRequest;
|
12 |
import javax.servlet.http.HttpServletRequest;
|
| 11 |
|
13 |
|
| Line 30... |
Line 32... |
| 30 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
32 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 31 |
import com.spice.profitmandi.common.model.SchemeModel;
|
33 |
import com.spice.profitmandi.common.model.SchemeModel;
|
| 32 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
34 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
| 33 |
import com.spice.profitmandi.common.util.StringUtils;
|
35 |
import com.spice.profitmandi.common.util.StringUtils;
|
| 34 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
36 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
| - |
|
37 |
import com.spice.profitmandi.dao.entity.fofo.SchemeItem;
|
| 35 |
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
|
38 |
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
|
| 36 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
39 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
| - |
|
40 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 37 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
41 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
| - |
|
42 |
import com.spice.profitmandi.dao.repository.fofo.SchemeItemRepository;
|
| 38 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
43 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 39 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
44 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
| 40 |
import com.spice.profitmandi.web.model.LoginDetails;
|
45 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 41 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
46 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 42 |
|
47 |
|
| Line 51... |
Line 56... |
| 51 |
|
56 |
|
| 52 |
@Autowired
|
57 |
@Autowired
|
| 53 |
private SchemeRepository schemeRepository;
|
58 |
private SchemeRepository schemeRepository;
|
| 54 |
|
59 |
|
| 55 |
@Autowired
|
60 |
@Autowired
|
| - |
|
61 |
private SchemeItemRepository schemeItemRepository;
|
| - |
|
62 |
|
| - |
|
63 |
@Autowired
|
| 56 |
private CookiesProcessor cookiesProcessor;
|
64 |
private CookiesProcessor cookiesProcessor;
|
| 57 |
|
65 |
|
| 58 |
@Autowired
|
66 |
@Autowired
|
| 59 |
private InventoryService inventoryService;
|
67 |
private InventoryService inventoryService;
|
| - |
|
68 |
|
| - |
|
69 |
@Autowired
|
| - |
|
70 |
private TagListingRepository tagListingRepository;
|
| 60 |
|
71 |
|
| 61 |
@Autowired
|
72 |
@Autowired
|
| 62 |
PurchaseRepository purchaseRepository;
|
73 |
PurchaseRepository purchaseRepository;
|
| 63 |
|
74 |
|
| 64 |
@RequestMapping(value = "/createScheme", method = RequestMethod.GET)
|
75 |
@RequestMapping(value = "/createScheme", method = RequestMethod.GET)
|
| Line 74... |
Line 85... |
| 74 |
Map<Integer, String> itemIdItemDescriptionMap = inventoryService.getAllTagListingItemIdItemDescriptionMap(brand);
|
85 |
Map<Integer, String> itemIdItemDescriptionMap = inventoryService.getAllTagListingItemIdItemDescriptionMap(brand);
|
| 75 |
model.addAttribute("itemIdItemDescriptionMap", itemIdItemDescriptionMap);
|
86 |
model.addAttribute("itemIdItemDescriptionMap", itemIdItemDescriptionMap);
|
| 76 |
//model.addAttribute("brands", inventoryService.getAllBrands());
|
87 |
//model.addAttribute("brands", inventoryService.getAllBrands());
|
| 77 |
return "tag-listing-items-description";
|
88 |
return "tag-listing-items-description";
|
| 78 |
}
|
89 |
}
|
| - |
|
90 |
|
| - |
|
91 |
@RequestMapping(value = "/schemes/update-schemes-page", method = RequestMethod.GET)
|
| - |
|
92 |
public String updateShcemes(HttpServletRequest request) throws ProfitMandiBusinessException {
|
| - |
|
93 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
94 |
if(!loginDetails.getRoleTypes().contains(RoleType.FOFO_ADMIN)) {
|
| - |
|
95 |
throw new ProfitMandiBusinessException("User", loginDetails.getEmailId(), "Unauthorised access");
|
| - |
|
96 |
}
|
| - |
|
97 |
return "update-schemes-page";
|
| - |
|
98 |
}
|
| - |
|
99 |
|
| - |
|
100 |
@RequestMapping(value = "/schemes/update", method = RequestMethod.POST)
|
| - |
|
101 |
public String updateShcemes(HttpServletRequest request, @RequestParam List<Integer> schemeIds, @RequestParam List<Integer> itemIds) throws ProfitMandiBusinessException {
|
| - |
|
102 |
for(int schemeId : schemeIds) {
|
| - |
|
103 |
if(schemeRepository.selectById(schemeId) != null)
|
| - |
|
104 |
for(int itemId : itemIds) {
|
| - |
|
105 |
if(tagListingRepository.selectByItemIdsAndTagIds(new HashSet<>(Arrays.asList(itemId)), new HashSet<>(Arrays.asList(4,7))).size() > 0) {
|
| - |
|
106 |
SchemeItem si = new SchemeItem();
|
| - |
|
107 |
si.setItemId(itemId);
|
| - |
|
108 |
si.setSchemeId(schemeId);
|
| - |
|
109 |
try {
|
| - |
|
110 |
schemeItemRepository.persist(si);
|
| - |
|
111 |
} catch (Exception e) {
|
| - |
|
112 |
LOGGER.info("Scheme aleady exist");
|
| - |
|
113 |
}
|
| - |
|
114 |
} else {
|
| - |
|
115 |
throw new ProfitMandiBusinessException("ItemId", itemId,"Invalid Item Id");
|
| - |
|
116 |
}
|
| - |
|
117 |
}
|
| - |
|
118 |
}
|
| - |
|
119 |
return "response";
|
| - |
|
120 |
}
|
| 79 |
|
121 |
|
| 80 |
|
122 |
|
| 81 |
@RequestMapping(value = "/createScheme", method = RequestMethod.POST)
|
123 |
@RequestMapping(value = "/createScheme", method = RequestMethod.POST)
|
| 82 |
public String createScheme(HttpServletRequest request, @RequestBody CreateSchemeRequest createSchemeRequest, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
124 |
public String createScheme(HttpServletRequest request, @RequestBody CreateSchemeRequest createSchemeRequest, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
| 83 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
125 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|