| Line 96... |
Line 96... |
| 96 |
|
96 |
|
| 97 |
@Controller
|
97 |
@Controller
|
| 98 |
@Transactional(rollbackFor = Throwable.class)
|
98 |
@Transactional(rollbackFor = Throwable.class)
|
| 99 |
public class IndentController {
|
99 |
public class IndentController {
|
| 100 |
|
100 |
|
| 101 |
private static final Logger LOGGER = LogManager.getLogger(IndentController.class);
|
101 |
private static final Logger LOGGER = LogManager.getLogger(IndentController.class);
|
| 102 |
private static final int WALLET_GATEWAY_ID = 8;
|
102 |
private static final int WALLET_GATEWAY_ID = 8;
|
| 103 |
private static final Set<Integer> defaultTags = new HashSet<Integer>(Arrays.asList(4));
|
103 |
private static final Set<Integer> defaultTags = new HashSet<Integer>(Arrays.asList(4));
|
| 104 |
|
104 |
|
| 105 |
private final List<OrderStatus> partnerPendingOrderList = Arrays.asList(OrderStatus.ACCEPTED,
|
105 |
private final List<OrderStatus> partnerPendingOrderList = Arrays.asList(OrderStatus.ACCEPTED,
|
| 106 |
OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.BILLED, OrderStatus.SHIPPED_FROM_WH,
|
106 |
OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.BILLED, OrderStatus.SHIPPED_FROM_WH,
|
| 107 |
OrderStatus.SHIPPED_TO_DESTINATION_CITY, OrderStatus.SHIPPED_TO_LOGST,
|
107 |
OrderStatus.SHIPPED_TO_DESTINATION_CITY, OrderStatus.SHIPPED_TO_LOGST,
|
| 108 |
OrderStatus.REACHED_DESTINATION_CITY);
|
108 |
OrderStatus.REACHED_DESTINATION_CITY);
|
| 109 |
|
109 |
|
| 110 |
private static final int PLANNING_OPEN_DAY = 20;
|
110 |
private static final int PLANNING_OPEN_DAY = 20;
|
| 111 |
private static final int PLANNING_CLOSE_DAY = 1;
|
111 |
private static final int PLANNING_CLOSE_DAY = 1;
|
| 112 |
|
112 |
|
| 113 |
private static final String PO_TITLE_STRING = "Alert - Stock Arriving at SD Warehouse";
|
113 |
private static final String PO_TITLE_STRING = "Alert - Stock Arriving at SD Warehouse";
|
| 114 |
|
114 |
|
| 115 |
@Autowired
|
115 |
@Autowired
|
| 116 |
WalletService walletService;
|
116 |
WalletService walletService;
|
| 117 |
|
117 |
|
| 118 |
@Autowired
|
118 |
@Autowired
|
| 119 |
BrandRegionMappingRepository brandRegionMappingRepository;
|
119 |
BrandRegionMappingRepository brandRegionMappingRepository;
|
| 120 |
|
120 |
|
| 121 |
@Autowired
|
121 |
@Autowired
|
| 122 |
private JavaMailSender googleMailSender;
|
122 |
private JavaMailSender googleMailSender;
|
| 123 |
|
123 |
|
| 124 |
@Autowired
|
124 |
@Autowired
|
| 125 |
private CookiesProcessor cookiesProcessor;
|
125 |
private CookiesProcessor cookiesProcessor;
|
| 126 |
|
126 |
|
| 127 |
@Autowired
|
127 |
@Autowired
|
| 128 |
private UserWalletRepository userWalletRepository;
|
128 |
private UserWalletRepository userWalletRepository;
|
| 129 |
|
129 |
|
| 130 |
@Autowired
|
130 |
@Autowired
|
| 131 |
private UserRepository userRepository;
|
131 |
private UserRepository userRepository;
|
| 132 |
|
132 |
|
| 133 |
@Autowired
|
133 |
@Autowired
|
| 134 |
FofoStoreRepository fofoStoreRepository;
|
134 |
FofoStoreRepository fofoStoreRepository;
|
| 135 |
|
135 |
|
| 136 |
@Autowired
|
136 |
@Autowired
|
| 137 |
private OrderRepository orderRepository;
|
137 |
private OrderRepository orderRepository;
|
| 138 |
|
138 |
|
| 139 |
@Autowired
|
139 |
@Autowired
|
| 140 |
private UserAccountRepository userAccountRepository;
|
140 |
private UserAccountRepository userAccountRepository;
|
| 141 |
|
141 |
|
| 142 |
@Autowired
|
142 |
@Autowired
|
| 143 |
private ItemRepository itemRepository;
|
143 |
private ItemRepository itemRepository;
|
| 144 |
|
144 |
|
| 145 |
@Autowired
|
145 |
@Autowired
|
| 146 |
private StockAllocationService stockAllocationService;
|
146 |
private StockAllocationService stockAllocationService;
|
| 147 |
|
147 |
|
| 148 |
@Autowired
|
148 |
@Autowired
|
| 149 |
private RetailerService retailerService;
|
149 |
private RetailerService retailerService;
|
| 150 |
|
150 |
|
| 151 |
@Autowired
|
151 |
@Autowired
|
| 152 |
private TagListingRepository tagListingRepository;
|
152 |
private TagListingRepository tagListingRepository;
|
| 153 |
|
153 |
|
| 154 |
@Autowired
|
154 |
@Autowired
|
| 155 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
155 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
| 156 |
|
156 |
|
| 157 |
@Autowired
|
157 |
@Autowired
|
| 158 |
private PurchaseRepository purchaseRepository;
|
158 |
private PurchaseRepository purchaseRepository;
|
| 159 |
|
159 |
|
| 160 |
@Autowired
|
160 |
@Autowired
|
| 161 |
private MVCResponseSender mvcResponseSender;
|
161 |
private MVCResponseSender mvcResponseSender;
|
| 162 |
|
162 |
|
| 163 |
@Autowired
|
163 |
@Autowired
|
| 164 |
private FocusedModelRepository focusedModelRepository;
|
164 |
private FocusedModelRepository focusedModelRepository;
|
| 165 |
|
165 |
|
| 166 |
@Autowired
|
166 |
@Autowired
|
| 167 |
private MonthlyPlannedRepository monthlyPlannedRepository;
|
167 |
private MonthlyPlannedRepository monthlyPlannedRepository;
|
| 168 |
|
168 |
|
| 169 |
@Autowired
|
169 |
@Autowired
|
| 170 |
private FofoOrderRepository fofoOrderRepository;
|
170 |
private FofoOrderRepository fofoOrderRepository;
|
| 171 |
|
171 |
|
| 172 |
@Autowired
|
172 |
@Autowired
|
| 173 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
173 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
| 174 |
|
174 |
|
| 175 |
@Autowired
|
175 |
@Autowired
|
| 176 |
private PlannedDetailRepository plannedDetailRepository;
|
176 |
private PlannedDetailRepository plannedDetailRepository;
|
| 177 |
|
177 |
|
| 178 |
@Autowired
|
178 |
@Autowired
|
| 179 |
RoleManager roleManager;
|
179 |
RoleManager roleManager;
|
| 180 |
|
180 |
|
| 181 |
@Autowired
|
181 |
@Autowired
|
| 182 |
PartnerTypeChangeRepository partnerTypeChangeRepository;
|
182 |
PartnerTypeChangeRepository partnerTypeChangeRepository;
|
| 183 |
|
183 |
|
| 184 |
@Autowired
|
184 |
@Autowired
|
| 185 |
private Mongo mongoClient;
|
185 |
private Mongo mongoClient;
|
| 186 |
|
186 |
|
| 187 |
@Autowired
|
187 |
@Autowired
|
| 188 |
private InventoryService inventoryService;
|
188 |
private InventoryService inventoryService;
|
| 189 |
|
189 |
|
| 190 |
@Autowired
|
190 |
@Autowired
|
| 191 |
private CsService1 csService1;
|
191 |
private CsService1 csService1;
|
| 192 |
|
192 |
|
| 193 |
@Autowired
|
193 |
@Autowired
|
| 194 |
private CsService csService;
|
194 |
private CsService csService;
|
| 195 |
|
195 |
|
| 196 |
@Autowired
|
196 |
@Autowired
|
| 197 |
private AuthRepository authRepository;
|
197 |
private AuthRepository authRepository;
|
| 198 |
@Autowired
|
198 |
@Autowired
|
| 199 |
WarehouseRepository warehouseRepository;
|
199 |
WarehouseRepository warehouseRepository;
|
| 200 |
@Autowired
|
200 |
@Autowired
|
| 201 |
private SuggestedPoRepository suggestedPoRepository;
|
201 |
private SuggestedPoRepository suggestedPoRepository;
|
| 202 |
|
202 |
|
| 203 |
@Autowired
|
203 |
@Autowired
|
| 204 |
private NotificationService notificationService;
|
204 |
private NotificationService notificationService;
|
| 205 |
|
205 |
|
| 206 |
@Autowired
|
206 |
@Autowired
|
| 207 |
private RegionRepository regionRepository;
|
207 |
private RegionRepository regionRepository;
|
| 208 |
|
208 |
|
| 209 |
@Autowired
|
209 |
@Autowired
|
| 210 |
private PartnerRegionRepository partnerRegionRepository;
|
210 |
private PartnerRegionRepository partnerRegionRepository;
|
| 211 |
|
211 |
|
| 212 |
@Autowired
|
212 |
@Autowired
|
| 213 |
private SaholicInventoryCISRepository saholicInventoryCISRepository;
|
213 |
private SaholicInventoryCISRepository saholicInventoryCISRepository;
|
| 214 |
|
214 |
|
| 215 |
@Autowired
|
215 |
@Autowired
|
| 216 |
private SaholicInventoryService saholicInventoryService;
|
216 |
private SaholicInventoryService saholicInventoryService;
|
| 217 |
|
217 |
|
| 218 |
@Autowired
|
218 |
@Autowired
|
| 219 |
private PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
219 |
private PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
| 220 |
@Autowired
|
220 |
@Autowired
|
| 221 |
private SuggestedPoDetailRepository suggestedPoDetailRepository;
|
221 |
private SuggestedPoDetailRepository suggestedPoDetailRepository;
|
| 222 |
|
222 |
|
| 223 |
@Autowired
|
223 |
@Autowired
|
| 224 |
SaholicCISTableRepository saholicCISTableRepository;
|
224 |
SaholicCISTableRepository saholicCISTableRepository;
|
| 225 |
|
225 |
|
| 226 |
@RequestMapping(value = "/open-indent/save", method = RequestMethod.POST)
|
226 |
@RequestMapping(value = "/open-indent/save", method = RequestMethod.POST)
|
| 227 |
public String saveOpenIndent(HttpServletRequest request, Model model, @RequestParam int catalogId,
|
227 |
public String saveOpenIndent(HttpServletRequest request, Model model, @RequestParam int catalogId,
|
| 228 |
@RequestParam int itemQty, @RequestParam int fofoId) throws Exception {
|
228 |
@RequestParam int itemQty, @RequestParam int fofoId) throws Exception {
|
| 229 |
if (fofoId == 0) {
|
229 |
if (fofoId == 0) {
|
| 230 |
|
230 |
|
| 231 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
231 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 232 |
fofoId = loginDetails.getFofoId();
|
232 |
fofoId = loginDetails.getFofoId();
|
| 233 |
|
233 |
|
| 234 |
}
|
234 |
}
|
| 235 |
|
235 |
|
| 236 |
LocalDate currentMonthDate = LocalDate.now();
|
236 |
LocalDate currentMonthDate = LocalDate.now();
|
| 237 |
MonthlyPlanned monthlyPlanned = null;
|
237 |
MonthlyPlanned monthlyPlanned = null;
|
| 238 |
|
238 |
|
| 239 |
if (LocalDate.now().isAfter(LocalDate.now().withDayOfMonth(PLANNING_OPEN_DAY))) {
|
239 |
if (LocalDate.now().isAfter(LocalDate.now().withDayOfMonth(PLANNING_OPEN_DAY))) {
|
| 240 |
currentMonthDate = LocalDate.now().plusMonths(1).withDayOfMonth(1);
|
240 |
currentMonthDate = LocalDate.now().plusMonths(1).withDayOfMonth(1);
|
| 241 |
monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, currentMonthDate);
|
241 |
monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, currentMonthDate);
|
| 242 |
LOGGER.info("monthlyPlanned" + monthlyPlanned);
|
242 |
LOGGER.info("monthlyPlanned" + monthlyPlanned);
|
| 243 |
saveMonthlyPlanned(monthlyPlanned, fofoId, currentMonthDate, catalogId, itemQty);
|
243 |
saveMonthlyPlanned(monthlyPlanned, fofoId, currentMonthDate, catalogId, itemQty);
|
| 244 |
}
|
244 |
}
|
| 245 |
model.addAttribute("response1", mvcResponseSender.createResponseString(false));
|
245 |
model.addAttribute("response1", mvcResponseSender.createResponseString(false));
|
| 246 |
return "response";
|
246 |
return "response";
|
| 247 |
}
|
247 |
}
|
| 248 |
|
248 |
|
| 249 |
private void saveMonthlyPlanned(MonthlyPlanned monthlyPlanned, int fofoId, LocalDate currentMonthDate,
|
249 |
private void saveMonthlyPlanned(MonthlyPlanned monthlyPlanned, int fofoId, LocalDate currentMonthDate,
|
| 250 |
int catalogId, int itemQty) {
|
250 |
int catalogId, int itemQty) {
|
| 251 |
if (monthlyPlanned == null) {
|
251 |
if (monthlyPlanned == null) {
|
| 252 |
monthlyPlanned = new MonthlyPlanned();
|
252 |
monthlyPlanned = new MonthlyPlanned();
|
| 253 |
monthlyPlanned.setFofoId(fofoId);
|
253 |
monthlyPlanned.setFofoId(fofoId);
|
| 254 |
monthlyPlanned.setYearMonth(currentMonthDate);
|
254 |
monthlyPlanned.setYearMonth(currentMonthDate);
|
| 255 |
monthlyPlannedRepository.persist(monthlyPlanned);
|
255 |
monthlyPlannedRepository.persist(monthlyPlanned);
|
| 256 |
PlannedDetail pd = new PlannedDetail();
|
256 |
PlannedDetail pd = new PlannedDetail();
|
| 257 |
pd.setCatalogId(catalogId);
|
257 |
pd.setCatalogId(catalogId);
|
| 258 |
pd.setPlannedId(monthlyPlanned.getId());
|
258 |
pd.setPlannedId(monthlyPlanned.getId());
|
| 259 |
pd.setQuantity(itemQty);
|
259 |
pd.setQuantity(itemQty);
|
| 260 |
pd.setUpdatedTimestamp(LocalDateTime.now());
|
260 |
pd.setUpdatedTimestamp(LocalDateTime.now());
|
| 261 |
plannedDetailRepository.persist(pd);
|
261 |
plannedDetailRepository.persist(pd);
|
| 262 |
|
262 |
|
| 263 |
} else {
|
263 |
} else {
|
| 264 |
PlannedDetail plannedDetail = plannedDetailRepository.selectByPlannedIdCatalogId(monthlyPlanned.getId(),
|
264 |
PlannedDetail plannedDetail = plannedDetailRepository.selectByPlannedIdCatalogId(monthlyPlanned.getId(),
|
| 265 |
catalogId);
|
265 |
catalogId);
|
| 266 |
if (plannedDetail == null) {
|
266 |
if (plannedDetail == null) {
|
| 267 |
plannedDetail = new PlannedDetail();
|
267 |
plannedDetail = new PlannedDetail();
|
| 268 |
plannedDetail.setCatalogId(catalogId);
|
268 |
plannedDetail.setCatalogId(catalogId);
|
| 269 |
plannedDetail.setPlannedId(monthlyPlanned.getId());
|
269 |
plannedDetail.setPlannedId(monthlyPlanned.getId());
|
| 270 |
plannedDetail.setQuantity(itemQty);
|
270 |
plannedDetail.setQuantity(itemQty);
|
| 271 |
plannedDetail.setUpdatedTimestamp(LocalDateTime.now());
|
271 |
plannedDetail.setUpdatedTimestamp(LocalDateTime.now());
|
| 272 |
plannedDetailRepository.persist(plannedDetail);
|
272 |
plannedDetailRepository.persist(plannedDetail);
|
| 273 |
} else if (itemQty == 0) {
|
273 |
} else if (itemQty == 0) {
|
| 274 |
plannedDetailRepository.delete(plannedDetail);
|
274 |
plannedDetailRepository.delete(plannedDetail);
|
| 275 |
|
275 |
|
| 276 |
} else {
|
276 |
} else {
|
| 277 |
plannedDetail.setCatalogId(catalogId);
|
277 |
plannedDetail.setCatalogId(catalogId);
|
| 278 |
plannedDetail.setQuantity(itemQty);
|
278 |
plannedDetail.setQuantity(itemQty);
|
| 279 |
plannedDetail.setUpdatedTimestamp(LocalDateTime.now());
|
279 |
plannedDetail.setUpdatedTimestamp(LocalDateTime.now());
|
| 280 |
}
|
280 |
}
|
| 281 |
|
281 |
|
| 282 |
}
|
282 |
}
|
| 283 |
|
283 |
|
| 284 |
}
|
284 |
}
|
| 285 |
|
285 |
|
| 286 |
@RequestMapping(value = "/open-indent/confirm", method = RequestMethod.POST)
|
286 |
@RequestMapping(value = "/open-indent/confirm", method = RequestMethod.POST)
|
| 287 |
public String confirmOpenIndent(HttpServletRequest request,
|
287 |
public String confirmOpenIndent(HttpServletRequest request,
|
| 288 |
@RequestParam(required = false, defaultValue = "0") int fofoId, Model model) throws Exception {
|
288 |
@RequestParam(required = false, defaultValue = "0") int fofoId, Model model) throws Exception {
|
| 289 |
|
289 |
|
| 290 |
if (fofoId == 0) {
|
290 |
if (fofoId == 0) {
|
| 291 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
291 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 292 |
fofoId = loginDetails.getFofoId();
|
292 |
fofoId = loginDetails.getFofoId();
|
| 293 |
}
|
293 |
}
|
| 294 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
294 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
| 295 |
|
295 |
|
| 296 |
LocalDate currentDate = LocalDate.now();
|
296 |
LocalDate currentDate = LocalDate.now();
|
| 297 |
LocalDate planningMonthDate = null;
|
297 |
LocalDate planningMonthDate = null;
|
| 298 |
MonthlyPlanned monthlyPlanned = null;
|
298 |
MonthlyPlanned monthlyPlanned = null;
|
| 299 |
if (currentDate.isAfter(currentDate.withDayOfMonth(PLANNING_OPEN_DAY))) {
|
299 |
if (currentDate.isAfter(currentDate.withDayOfMonth(PLANNING_OPEN_DAY))) {
|
| 300 |
planningMonthDate = LocalDate.now().plusMonths(1).withDayOfMonth(1);
|
300 |
planningMonthDate = LocalDate.now().plusMonths(1).withDayOfMonth(1);
|
| 301 |
monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, planningMonthDate);
|
301 |
monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, planningMonthDate);
|
| 302 |
|
302 |
|
| 303 |
confirmMonthlyPlanned(monthlyPlanned, customRetailer, fofoId);
|
303 |
confirmMonthlyPlanned(monthlyPlanned, customRetailer, fofoId);
|
| 304 |
}
|
304 |
}
|
| 305 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
305 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 306 |
|
306 |
|
| 307 |
return "response";
|
307 |
return "response";
|
| 308 |
}
|
308 |
}
|
| 309 |
|
309 |
|
| 310 |
private void confirmMonthlyPlanned(MonthlyPlanned monthlyPlanned, CustomRetailer customRetailer, int fofoId)
|
310 |
private void confirmMonthlyPlanned(MonthlyPlanned monthlyPlanned, CustomRetailer customRetailer, int fofoId)
|
| 311 |
throws Exception {
|
311 |
throws Exception {
|
| 312 |
List<PlannedDetail> plannedDetails = plannedDetailRepository.selectByPlannedId(monthlyPlanned.getId());
|
312 |
List<PlannedDetail> plannedDetails = plannedDetailRepository.selectByPlannedId(monthlyPlanned.getId());
|
| 313 |
|
313 |
|
| 314 |
List<PlannedModel> plannedModel = new ArrayList<>();
|
314 |
List<PlannedModel> plannedModel = new ArrayList<>();
|
| 315 |
for (PlannedDetail plannedDetail : plannedDetails) {
|
315 |
for (PlannedDetail plannedDetail : plannedDetails) {
|
| 316 |
|
316 |
|
| 317 |
List<Item> items = itemRepository.selectAllByCatalogItemId(plannedDetail.getCatalogId());
|
317 |
List<Item> items = itemRepository.selectAllByCatalogItemId(plannedDetail.getCatalogId());
|
| 318 |
String itemDesription = items.get(0).getItemDescriptionNoColor();
|
318 |
String itemDesription = items.get(0).getItemDescriptionNoColor();
|
| 319 |
PlannedModel pm = new PlannedModel();
|
319 |
PlannedModel pm = new PlannedModel();
|
| 320 |
pm.setItemDescription(itemDesription);
|
320 |
pm.setItemDescription(itemDesription);
|
| 321 |
pm.setStoreName(customRetailer.getBusinessName());
|
321 |
pm.setStoreName(customRetailer.getBusinessName());
|
| 322 |
pm.setQty(plannedDetail.getQuantity());
|
322 |
pm.setQty(plannedDetail.getQuantity());
|
| 323 |
pm.setFofoId(fofoId);
|
323 |
pm.setFofoId(fofoId);
|
| 324 |
plannedModel.add(pm);
|
324 |
plannedModel.add(pm);
|
| 325 |
LOGGER.info("plannedModel" + plannedModel);
|
325 |
LOGGER.info("plannedModel" + plannedModel);
|
| 326 |
|
326 |
|
| 327 |
}
|
327 |
}
|
| 328 |
List<String> ccemails = new ArrayList<>();
|
328 |
List<String> ccemails = new ArrayList<>();
|
| 329 |
LOGGER.info("ccemails" + ccemails);
|
329 |
LOGGER.info("ccemails" + ccemails);
|
| 330 |
Map<EscalationType, String> emailEsclationType = csService.getAuthUserAndEsclationTypeByPartnerId(fofoId);
|
330 |
Map<EscalationType, String> emailEsclationType = csService.getAuthUserAndEsclationTypeByPartnerId(fofoId);
|
| 331 |
LOGGER.info("emailEsclationType" + emailEsclationType);
|
331 |
LOGGER.info("emailEsclationType" + emailEsclationType);
|
| 332 |
if (emailEsclationType.get(EscalationType.L1) != null) {
|
332 |
if (emailEsclationType.get(EscalationType.L1) != null) {
|
| 333 |
ccemails.add(emailEsclationType.get(EscalationType.L1));
|
333 |
ccemails.add(emailEsclationType.get(EscalationType.L1));
|
| 334 |
}
|
334 |
}
|
| 335 |
|
335 |
|
| 336 |
if (emailEsclationType.get(EscalationType.L2) != null) {
|
336 |
if (emailEsclationType.get(EscalationType.L2) != null) {
|
| 337 |
|
337 |
|
| 338 |
ccemails.add(emailEsclationType.get(EscalationType.L2));
|
338 |
ccemails.add(emailEsclationType.get(EscalationType.L2));
|
| 339 |
}
|
339 |
}
|
| 340 |
LOGGER.info("ccemails" + ccemails);
|
340 |
LOGGER.info("ccemails" + ccemails);
|
| 341 |
List<String> bccemails = new ArrayList<>();
|
341 |
List<String> bccemails = new ArrayList<>();
|
| 342 |
bccemails.add(emailEsclationType.get(EscalationType.L3));
|
342 |
bccemails.add(emailEsclationType.get(EscalationType.L3));
|
| 343 |
LOGGER.info("bccemails" + bccemails);
|
343 |
LOGGER.info("bccemails" + bccemails);
|
| 344 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
|
344 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
|
| 345 |
Arrays.asList("Partner Id", "Partner Name", "Model Name", "Qty"),
|
345 |
Arrays.asList("Partner Id", "Partner Name", "Model Name", "Qty"),
|
| 346 |
plannedModel.stream()
|
346 |
plannedModel.stream()
|
| 347 |
.map(x -> Arrays.asList(x.getFofoId(), x.getStoreName(), x.getItemDescription(), x.getQty()))
|
347 |
.map(x -> Arrays.asList(x.getFofoId(), x.getStoreName(), x.getItemDescription(), x.getQty()))
|
| 348 |
.collect(Collectors.toList()));
|
348 |
.collect(Collectors.toList()));
|
| 349 |
LOGGER.info("baos" + baos);
|
349 |
LOGGER.info("baos" + baos);
|
| 350 |
Utils.sendMailWithAttachments(googleMailSender, new String[] { customRetailer.getEmail() },
|
350 |
Utils.sendMailWithAttachments(googleMailSender, new String[]{customRetailer.getEmail()},
|
| 351 |
ccemails.toArray(new String[ccemails.size()]), bccemails.toArray(new String[bccemails.size()]),
|
351 |
ccemails.toArray(new String[ccemails.size()]), bccemails.toArray(new String[bccemails.size()]),
|
| 352 |
"Planned Indent", "PFA",
|
352 |
"Planned Indent", "PFA",
|
| 353 |
new Attachment[] { new Attachment("PlannedIndent.csv", new ByteArrayResource(baos.toByteArray())), });
|
353 |
new Attachment[]{new Attachment("PlannedIndent.csv", new ByteArrayResource(baos.toByteArray())),});
|
| 354 |
|
354 |
|
| 355 |
}
|
355 |
}
|
| 356 |
|
356 |
|
| 357 |
@RequestMapping(value = "/indent/download", method = RequestMethod.GET)
|
357 |
@RequestMapping(value = "/indent/download", method = RequestMethod.GET)
|
| 358 |
public ResponseEntity<ByteArrayResource> downloadIndent(HttpServletRequest request, Model model,
|
358 |
public ResponseEntity<ByteArrayResource> downloadIndent(HttpServletRequest request, Model model,
|
| 359 |
@RequestParam(required = false, defaultValue = "0") int fofoId,
|
359 |
@RequestParam(required = false, defaultValue = "0") int fofoId,
|
| 360 |
@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
|
360 |
@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
|
| 361 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
361 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 362 |
Set<Integer> roleIds = loginDetails.getRoleIds();
|
362 |
Set<Integer> roleIds = loginDetails.getRoleIds();
|
| 363 |
LOGGER.info("Counter size is {}", counterSize);
|
363 |
LOGGER.info("Counter size is {}", counterSize);
|
| 364 |
LOGGER.info("Fofo Id is {}", fofoId);
|
364 |
LOGGER.info("Fofo Id is {}", fofoId);
|
| 365 |
|
365 |
|
| 366 |
if (roleManager.isAdmin(roleIds) || loginDetails.getFofoId() == fofoId) {
|
366 |
if (roleManager.isAdmin(roleIds) || loginDetails.getFofoId() == fofoId) {
|
| 367 |
List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().map(x -> x.getId())
|
367 |
List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().map(x -> x.getId())
|
| 368 |
.collect(Collectors.toList());
|
368 |
.collect(Collectors.toList());
|
| 369 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
369 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
| 370 |
Map<Integer, CustomRetailer> crm = fofoIds.stream().map(x -> customRetailerMap.get(x))
|
370 |
Map<Integer, CustomRetailer> crm = fofoIds.stream().map(x -> customRetailerMap.get(x))
|
| 371 |
.filter(x -> x != null).collect(Collectors.toList()).stream()
|
371 |
.filter(x -> x != null).collect(Collectors.toList()).stream()
|
| 372 |
.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
372 |
.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
| 373 |
List<StockAllocationModel> stockAllocationList = stockAllocationService.getStockAllocation(counterSize,
|
373 |
List<StockAllocationModel> stockAllocationList = stockAllocationService.getStockAllocation(counterSize,
|
| 374 |
true);
|
374 |
true);
|
| 375 |
Map<Integer, Integer> modelStockAllocationMap = stockAllocationList.stream()
|
375 |
Map<Integer, Integer> modelStockAllocationMap = stockAllocationList.stream()
|
| 376 |
.collect(Collectors.toMap(x -> x.getCatalogId(), x -> x.getQuantity()));
|
376 |
.collect(Collectors.toMap(x -> x.getCatalogId(), x -> x.getQuantity()));
|
| 377 |
|
377 |
|
| 378 |
Map<String, Integer> catalogUserQtyMap = new HashMap<>();
|
378 |
Map<String, Integer> catalogUserQtyMap = new HashMap<>();
|
| 379 |
currentInventorySnapshotRepository.selectByFofoId(fofoId).stream().forEach(x -> {
|
379 |
currentInventorySnapshotRepository.selectByFofoId(fofoId).stream().forEach(x -> {
|
| 380 |
int retailerId = x.getFofoId();
|
380 |
int retailerId = x.getFofoId();
|
| 381 |
int catalogId;
|
381 |
int catalogId;
|
| 382 |
try {
|
382 |
try {
|
| 383 |
catalogId = itemRepository.selectById(x.getItemId()).getCatalogItemId();
|
383 |
catalogId = itemRepository.selectById(x.getItemId()).getCatalogItemId();
|
| 384 |
String key = catalogId + "-" + retailerId;
|
384 |
String key = catalogId + "-" + retailerId;
|
| 385 |
if (!catalogUserQtyMap.containsKey(key)) {
|
385 |
if (!catalogUserQtyMap.containsKey(key)) {
|
| 386 |
catalogUserQtyMap.put(key, 0);
|
386 |
catalogUserQtyMap.put(key, 0);
|
| 387 |
}
|
387 |
}
|
| 388 |
catalogUserQtyMap.put(key, catalogUserQtyMap.get(key) + x.getAvailability());
|
388 |
catalogUserQtyMap.put(key, catalogUserQtyMap.get(key) + x.getAvailability());
|
| 389 |
} catch (ProfitMandiBusinessException e) {
|
389 |
} catch (ProfitMandiBusinessException e) {
|
| 390 |
// TODO Auto-generated catch block
|
390 |
// TODO Auto-generated catch block
|
| 391 |
throw new RuntimeException(e);
|
391 |
throw new RuntimeException(e);
|
| 392 |
}
|
392 |
}
|
| 393 |
});
|
393 |
});
|
| 394 |
|
394 |
|
| 395 |
List<Order> inTransitOrders = orderRepository.selectOrders(fofoIds, partnerPendingOrderList);
|
395 |
List<Order> inTransitOrders = orderRepository.selectOrders(fofoIds, partnerPendingOrderList);
|
| 396 |
Map<String, Integer> catalogUserInTransit = inTransitOrders.stream().collect(Collectors.groupingBy(x -> {
|
396 |
Map<String, Integer> catalogUserInTransit = inTransitOrders.stream().collect(Collectors.groupingBy(x -> {
|
| 397 |
try {
|
397 |
try {
|
| 398 |
return itemRepository.selectById(x.getLineItem().getItemId()).getCatalogItemId() + "-"
|
398 |
return itemRepository.selectById(x.getLineItem().getItemId()).getCatalogItemId() + "-"
|
| 399 |
+ x.getRetailerId();
|
399 |
+ x.getRetailerId();
|
| 400 |
} catch (ProfitMandiBusinessException e) {
|
400 |
} catch (ProfitMandiBusinessException e) {
|
| 401 |
// TODO Auto-generated catch block
|
401 |
// TODO Auto-generated catch block
|
| 402 |
return "";
|
402 |
return "";
|
| 403 |
}
|
403 |
}
|
| 404 |
}, Collectors.summingInt(x -> x.getLineItem().getQuantity())));
|
404 |
}, Collectors.summingInt(x -> x.getLineItem().getQuantity())));
|
| 405 |
|
405 |
|
| 406 |
Map<String, CatalogListingModel> catalogListingMap = new HashMap<>();
|
406 |
Map<String, CatalogListingModel> catalogListingMap = new HashMap<>();
|
| 407 |
|
407 |
|
| 408 |
List<TagListing> tagListings = tagListingRepository.selectAll(true);
|
408 |
List<TagListing> tagListings = tagListingRepository.selectAll(true);
|
| 409 |
Iterator<TagListing> iterator = tagListings.iterator();
|
409 |
Iterator<TagListing> iterator = tagListings.iterator();
|
| 410 |
while (iterator.hasNext()) {
|
410 |
while (iterator.hasNext()) {
|
| 411 |
TagListing tagListing = iterator.next();
|
411 |
TagListing tagListing = iterator.next();
|
| 412 |
Item item = itemRepository.selectById(tagListing.getItemId());
|
412 |
Item item = itemRepository.selectById(tagListing.getItemId());
|
| 413 |
int catalogId = item.getCatalogItemId();
|
413 |
int catalogId = item.getCatalogItemId();
|
| 414 |
if (item.getCategoryId() != 10006) {
|
414 |
if (item.getCategoryId() != 10006) {
|
| 415 |
continue;
|
415 |
continue;
|
| 416 |
}
|
416 |
}
|
| 417 |
|
417 |
|
| 418 |
int catalogStockAllocationQuantity = modelStockAllocationMap.containsKey(catalogId)
|
418 |
int catalogStockAllocationQuantity = modelStockAllocationMap.containsKey(catalogId)
|
| 419 |
? modelStockAllocationMap.get(catalogId)
|
419 |
? modelStockAllocationMap.get(catalogId)
|
| 420 |
: 0;
|
420 |
: 0;
|
| 421 |
for (int retailerId : fofoIds) {
|
421 |
for (int retailerId : fofoIds) {
|
| 422 |
String key = catalogId + "-" + retailerId;
|
422 |
String key = catalogId + "-" + retailerId;
|
| 423 |
if (catalogListingMap.containsKey(key)) {
|
423 |
if (catalogListingMap.containsKey(key)) {
|
| 424 |
continue;
|
424 |
continue;
|
| 425 |
}
|
425 |
}
|
| 426 |
int catalogInTransit = catalogUserInTransit.containsKey(key) ? catalogUserInTransit.get(key) : 0;
|
426 |
int catalogInTransit = catalogUserInTransit.containsKey(key) ? catalogUserInTransit.get(key) : 0;
|
| 427 |
int catalogInStock = catalogUserQtyMap.containsKey(key) ? catalogUserQtyMap.get(key) : 0;
|
427 |
int catalogInStock = catalogUserQtyMap.containsKey(key) ? catalogUserQtyMap.get(key) : 0;
|
| 428 |
if (catalogInTransit + catalogInStock == 0 && catalogStockAllocationQuantity == 0) {
|
428 |
if (catalogInTransit + catalogInStock == 0 && catalogStockAllocationQuantity == 0) {
|
| 429 |
continue;
|
429 |
continue;
|
| 430 |
}
|
430 |
}
|
| 431 |
CatalogListingModel catalogListingModel = new CatalogListingModel();
|
431 |
CatalogListingModel catalogListingModel = new CatalogListingModel();
|
| 432 |
catalogListingModel.setFofoId(retailerId);
|
432 |
catalogListingModel.setFofoId(retailerId);
|
| 433 |
catalogListingModel.setModelName(item.getModelName());
|
433 |
catalogListingModel.setModelName(item.getModelName());
|
| 434 |
catalogListingModel.setModelNumber(item.getModelNumber());
|
434 |
catalogListingModel.setModelNumber(item.getModelNumber());
|
| 435 |
catalogListingModel.setCatalogId(catalogId);
|
435 |
catalogListingModel.setCatalogId(catalogId);
|
| 436 |
catalogListingModel.setDp(tagListing.getSellingPrice());
|
436 |
catalogListingModel.setDp(tagListing.getSellingPrice());
|
| 437 |
catalogListingModel.setMop(tagListing.getMop());
|
437 |
catalogListingModel.setMop(tagListing.getMop());
|
| 438 |
catalogListingModel.setItemDescription(item.getItemDescriptionNoColor());
|
438 |
catalogListingModel.setItemDescription(item.getItemDescriptionNoColor());
|
| 439 |
catalogListingModel.setAllocatedQuantity(catalogStockAllocationQuantity);
|
439 |
catalogListingModel.setAllocatedQuantity(catalogStockAllocationQuantity);
|
| 440 |
catalogListingModel.setInTransitQuantity(catalogInTransit);
|
440 |
catalogListingModel.setInTransitQuantity(catalogInTransit);
|
| 441 |
catalogListingModel
|
441 |
catalogListingModel
|
| 442 |
.setToBeOrdered(catalogStockAllocationQuantity - catalogInTransit - catalogInStock);
|
442 |
.setToBeOrdered(catalogStockAllocationQuantity - catalogInTransit - catalogInStock);
|
| 443 |
catalogListingModel.setStockInHand(catalogInStock);
|
443 |
catalogListingModel.setStockInHand(catalogInStock);
|
| 444 |
catalogListingModel.setBrand(item.getBrand());
|
444 |
catalogListingModel.setBrand(item.getBrand());
|
| 445 |
catalogListingModel.setModelName(item.getModelName());
|
445 |
catalogListingModel.setModelName(item.getModelName());
|
| 446 |
catalogListingModel.setModelNumber(item.getModelNumber());
|
446 |
catalogListingModel.setModelNumber(item.getModelNumber());
|
| 447 |
catalogListingModel.setCategoryId(item.getCategoryId());
|
447 |
catalogListingModel.setCategoryId(item.getCategoryId());
|
| 448 |
catalogListingMap.put(key, catalogListingModel);
|
448 |
catalogListingMap.put(key, catalogListingModel);
|
| 449 |
}
|
449 |
}
|
| 450 |
}
|
450 |
}
|
| 451 |
List<List<?>> listOfRows = new ArrayList<>();
|
451 |
List<List<?>> listOfRows = new ArrayList<>();
|
| 452 |
for (CatalogListingModel clm : catalogListingMap.values()) {
|
452 |
for (CatalogListingModel clm : catalogListingMap.values()) {
|
| 453 |
CustomRetailer cr = crm.get(clm.getFofoId());
|
453 |
CustomRetailer cr = crm.get(clm.getFofoId());
|
| 454 |
listOfRows.add(Arrays.asList(cr.getPartnerId(), cr.getBusinessName(), clm.getCatalogId(),
|
454 |
listOfRows.add(Arrays.asList(cr.getPartnerId(), cr.getBusinessName(), clm.getCatalogId(),
|
| 455 |
clm.getBrand(), clm.getModelName(), clm.getModelNumber(), clm.getDp(), clm.getMop(),
|
455 |
clm.getBrand(), clm.getModelName(), clm.getModelNumber(), clm.getDp(), clm.getMop(),
|
| 456 |
clm.getAllocatedQuantity(), clm.getInTransitQuantity(), clm.getStockInHand(),
|
456 |
clm.getAllocatedQuantity(), clm.getInTransitQuantity(), clm.getStockInHand(),
|
| 457 |
clm.getToBeOrdered()));
|
457 |
clm.getToBeOrdered()));
|
| 458 |
}
|
458 |
}
|
| 459 |
ByteArrayOutputStream baos = FileUtil
|
459 |
ByteArrayOutputStream baos = FileUtil
|
| 460 |
.getCSVByteStream(
|
460 |
.getCSVByteStream(
|
| 461 |
Arrays.asList("StoreId", "StoreName", "Catalog Id", "Brand", "Model Name", "Model Number",
|
461 |
Arrays.asList("StoreId", "StoreName", "Catalog Id", "Brand", "Model Name", "Model Number",
|
| 462 |
"DP", "MOP", "Allocated Quantity", "In Transit", "Stock In hand", "Shortage"),
|
462 |
"DP", "MOP", "Allocated Quantity", "In Transit", "Stock In hand", "Shortage"),
|
| 463 |
listOfRows);
|
463 |
listOfRows);
|
| 464 |
HttpHeaders headers = new HttpHeaders();
|
464 |
HttpHeaders headers = new HttpHeaders();
|
| 465 |
headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
465 |
headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
| 466 |
headers.set("Content-disposition", "inline; filename=retailer-allocation.csv");
|
466 |
headers.set("Content-disposition", "inline; filename=retailer-allocation.csv");
|
| 467 |
return new ResponseEntity<ByteArrayResource>(new ByteArrayResource(baos.toByteArray()), headers,
|
467 |
return new ResponseEntity<ByteArrayResource>(new ByteArrayResource(baos.toByteArray()), headers,
|
| 468 |
HttpStatus.OK);
|
468 |
HttpStatus.OK);
|
| 469 |
}
|
469 |
}
|
| 470 |
return null;
|
470 |
return null;
|
| 471 |
|
471 |
|
| 472 |
}
|
472 |
}
|
| 473 |
|
473 |
|
| 474 |
@RequestMapping(value = "/itemsByCatalogId")
|
474 |
@RequestMapping(value = "/itemsByCatalogId")
|
| 475 |
public String getItemsByCatalogId(HttpServletRequest request, Model model,
|
475 |
public String getItemsByCatalogId(HttpServletRequest request, Model model,
|
| 476 |
@RequestParam(required = false) int catalogId, @RequestParam(required = false) int itemId)
|
476 |
@RequestParam(required = false) int catalogId, @RequestParam(required = false) int itemId)
|
| 477 |
throws ProfitMandiBusinessException {
|
477 |
throws ProfitMandiBusinessException {
|
| 478 |
if (catalogId == 0) {
|
478 |
if (catalogId == 0) {
|
| 479 |
catalogId = itemRepository.selectById(itemId).getCatalogItemId();
|
479 |
catalogId = itemRepository.selectById(itemId).getCatalogItemId();
|
| 480 |
}
|
480 |
}
|
| 481 |
List<Item> items = itemRepository.selectAllByCatalogItemId(catalogId);
|
481 |
List<Item> items = itemRepository.selectAllByCatalogItemId(catalogId);
|
| 482 |
LOGGER.info("Items {}", items);
|
482 |
LOGGER.info("Items {}", items);
|
| 483 |
Map<Integer, String> itemsColorMap = items.stream().filter(x -> x.getColorNatural().startsWith("f_"))
|
483 |
Map<Integer, String> itemsColorMap = items.stream().filter(x -> x.getColorNatural().startsWith("f_"))
|
| 484 |
.collect(Collectors.toMap(Item::getId, Item::getColor));
|
484 |
.collect(Collectors.toMap(Item::getId, Item::getColor));
|
| 485 |
Map<Integer, TagListing> tagsMap = tagListingRepository
|
485 |
Map<Integer, TagListing> tagsMap = tagListingRepository
|
| 486 |
.selectByItemIdsAndTagIds(items.stream().map(x -> x.getId()).collect(Collectors.toSet()), defaultTags)
|
486 |
.selectByItemIdsAndTagIds(items.stream().map(x -> x.getId()).collect(Collectors.toSet()), defaultTags)
|
| 487 |
.stream().collect(Collectors.toMap(TagListing::getItemId, x -> x));
|
487 |
.stream().collect(Collectors.toMap(TagListing::getItemId, x -> x));
|
| 488 |
LOGGER.info("Items color map {}", itemsColorMap);
|
488 |
LOGGER.info("Items color map {}", itemsColorMap);
|
| 489 |
JSONArray response = new JSONArray();
|
489 |
JSONArray response = new JSONArray();
|
| 490 |
itemsColorMap.keySet().stream().forEach(x -> {
|
490 |
itemsColorMap.keySet().stream().forEach(x -> {
|
| 491 |
response.put(new JSONObject().put("color", itemsColorMap.get(x)).put("id", x).put("active",
|
491 |
response.put(new JSONObject().put("color", itemsColorMap.get(x)).put("id", x).put("active",
|
| 492 |
tagsMap.get(x) == null ? false : tagsMap.get(x).isActive()));
|
492 |
tagsMap.get(x) == null ? false : tagsMap.get(x).isActive()));
|
| 493 |
});
|
493 |
});
|
| 494 |
model.addAttribute("response1", response.toString());
|
494 |
model.addAttribute("response1", response.toString());
|
| 495 |
return "response";
|
495 |
return "response";
|
| 496 |
|
496 |
|
| 497 |
}
|
497 |
}
|
| 498 |
|
498 |
|
| 499 |
@RequestMapping(value = "/hotdealsitemsByCatalogId")
|
499 |
@RequestMapping(value = "/hotdealsitemsByCatalogId")
|
| 500 |
public String getHotdealsitemsByCatalogId(HttpServletRequest request, Model model,
|
500 |
public String getHotdealsitemsByCatalogId(HttpServletRequest request, Model model,
|
| 501 |
@RequestParam(required = false) int catalogId, @RequestParam(required = false) int itemId)
|
501 |
@RequestParam(required = false) int catalogId, @RequestParam(required = false) int itemId)
|
| 502 |
throws ProfitMandiBusinessException {
|
502 |
throws ProfitMandiBusinessException {
|
| 503 |
if (catalogId == 0) {
|
503 |
if (catalogId == 0) {
|
| 504 |
catalogId = itemRepository.selectById(itemId).getCatalogItemId();
|
504 |
catalogId = itemRepository.selectById(itemId).getCatalogItemId();
|
| 505 |
}
|
505 |
}
|
| 506 |
List<Item> items = itemRepository.selectAllByCatalogItemId(catalogId);
|
506 |
List<Item> items = itemRepository.selectAllByCatalogItemId(catalogId);
|
| 507 |
LOGGER.info("Items {}", items);
|
507 |
LOGGER.info("Items {}", items);
|
| 508 |
Map<Integer, String> itemsColorMap = items.stream().filter(x -> x.getColorNatural().startsWith("f_"))
|
508 |
Map<Integer, String> itemsColorMap = items.stream().filter(x -> x.getColorNatural().startsWith("f_"))
|
| 509 |
.collect(Collectors.toMap(Item::getId, Item::getColor));
|
509 |
.collect(Collectors.toMap(Item::getId, Item::getColor));
|
| 510 |
Map<Integer, TagListing> tagsMap = tagListingRepository
|
510 |
Map<Integer, TagListing> tagsMap = tagListingRepository
|
| 511 |
.selectByItemIdsAndTagIds(items.stream().map(x -> x.getId()).collect(Collectors.toSet()), defaultTags)
|
511 |
.selectByItemIdsAndTagIds(items.stream().map(x -> x.getId()).collect(Collectors.toSet()), defaultTags)
|
| 512 |
.stream().collect(Collectors.toMap(TagListing::getItemId, x -> x));
|
512 |
.stream().collect(Collectors.toMap(TagListing::getItemId, x -> x));
|
| 513 |
LOGGER.info("Items color map {}", itemsColorMap);
|
513 |
LOGGER.info("Items color map {}", itemsColorMap);
|
| 514 |
JSONArray response = new JSONArray();
|
514 |
JSONArray response = new JSONArray();
|
| 515 |
itemsColorMap.keySet().stream().forEach(x -> {
|
515 |
itemsColorMap.keySet().stream().forEach(x -> {
|
| 516 |
response.put(new JSONObject().put("color", itemsColorMap.get(x)).put("id", x).put("hotDeals",
|
516 |
response.put(new JSONObject().put("color", itemsColorMap.get(x)).put("id", x).put("hotDeals",
|
| 517 |
tagsMap.get(x) == null ? false : tagsMap.get(x).isHotDeals()));
|
517 |
tagsMap.get(x) == null ? false : tagsMap.get(x).isHotDeals()));
|
| 518 |
});
|
518 |
});
|
| 519 |
model.addAttribute("response1", response.toString());
|
519 |
model.addAttribute("response1", response.toString());
|
| 520 |
return "response";
|
520 |
return "response";
|
| 521 |
|
521 |
|
| 522 |
}
|
522 |
}
|
| 523 |
|
523 |
|
| 524 |
private List<Order> filterValidOrders(List<Order> lastOrdersList) {
|
524 |
private List<Order> filterValidOrders(List<Order> lastOrdersList) {
|
| 525 |
int orderRemovedCount = 0;
|
525 |
int orderRemovedCount = 0;
|
| 526 |
Iterator<Order> orderIterator = lastOrdersList.iterator();
|
526 |
Iterator<Order> orderIterator = lastOrdersList.iterator();
|
| 527 |
while (orderIterator.hasNext()) {
|
527 |
while (orderIterator.hasNext()) {
|
| 528 |
Order o = orderIterator.next();
|
528 |
Order o = orderIterator.next();
|
| 529 |
if (o.getInvoiceNumber() != null) {
|
529 |
if (o.getInvoiceNumber() != null) {
|
| 530 |
try {
|
530 |
try {
|
| 531 |
purchaseRepository.selectByPurchaseReferenceAndFofoId(o.getInvoiceNumber(), o.getRetailerId());
|
531 |
purchaseRepository.selectByPurchaseReferenceAndFofoId(o.getInvoiceNumber(), o.getRetailerId());
|
| 532 |
orderIterator.remove();
|
532 |
orderIterator.remove();
|
| 533 |
orderRemovedCount++;
|
533 |
orderRemovedCount++;
|
| 534 |
} catch (Exception e) {
|
534 |
} catch (Exception e) {
|
| 535 |
|
535 |
|
| 536 |
}
|
536 |
}
|
| 537 |
}
|
537 |
}
|
| 538 |
}
|
538 |
}
|
| 539 |
LOGGER.info("Order removed count is {}", orderRemovedCount);
|
539 |
LOGGER.info("Order removed count is {}", orderRemovedCount);
|
| 540 |
return lastOrdersList;
|
540 |
return lastOrdersList;
|
| 541 |
}
|
541 |
}
|
| 542 |
|
542 |
|
| 543 |
// Clean up the saholic cis table
|
543 |
// Clean up the saholic cis table
|
| 544 |
@RequestMapping(value = "/indent/confirm-pause", method = RequestMethod.POST)
|
544 |
@RequestMapping(value = "/indent/confirm-pause", method = RequestMethod.POST)
|
| 545 |
public String updateTagListing(HttpServletRequest request, Model model, @RequestBody String jsonArrayString)
|
545 |
public String updateTagListing(HttpServletRequest request, Model model, @RequestBody String jsonArrayString)
|
| 546 |
throws Exception {
|
546 |
throws Exception {
|
| 547 |
JSONArray jsonArray = new JSONArray(jsonArrayString);
|
547 |
JSONArray jsonArray = new JSONArray(jsonArrayString);
|
| 548 |
for (int i = 0; i < jsonArray.length(); i++) {
|
548 |
for (int i = 0; i < jsonArray.length(); i++) {
|
| 549 |
JSONObject obj = jsonArray.getJSONObject(i);
|
549 |
JSONObject obj = jsonArray.getJSONObject(i);
|
| 550 |
|
550 |
|
| 551 |
TagListing tl = tagListingRepository.selectByItemId(obj.getInt("id"));
|
551 |
TagListing tl = tagListingRepository.selectByItemId(obj.getInt("id"));
|
| 552 |
if (tl == null) {
|
552 |
if (tl == null) {
|
| 553 |
continue;
|
553 |
continue;
|
| 554 |
} else {
|
554 |
} else {
|
| 555 |
tl.setActive(obj.getBoolean("active"));
|
555 |
tl.setActive(obj.getBoolean("active"));
|
| 556 |
if (!tl.isActive()) {
|
556 |
if (!tl.isActive()) {
|
| 557 |
saholicCISTableRepository.selectAllByItemId(tl.getItemId()).stream()
|
557 |
saholicCISTableRepository.selectAllByItemId(tl.getItemId()).stream()
|
| 558 |
.forEach(x -> saholicCISTableRepository.delete(x));
|
558 |
.forEach(x -> saholicCISTableRepository.delete(x));
|
| 559 |
}
|
559 |
}
|
| 560 |
}
|
560 |
}
|
| 561 |
}
|
561 |
}
|
| 562 |
model.addAttribute("response1", true);
|
562 |
model.addAttribute("response1", true);
|
| 563 |
return "response";
|
563 |
return "response";
|
| 564 |
}
|
564 |
}
|
| 565 |
|
565 |
|
| 566 |
@RequestMapping(value = "/indent/confirm-hotdeals-pause", method = RequestMethod.POST)
|
566 |
@RequestMapping(value = "/indent/confirm-hotdeals-pause", method = RequestMethod.POST)
|
| 567 |
public String hotdealUpdate(HttpServletRequest request, Model model, @RequestBody String jsonArrayString)
|
567 |
public String hotdealUpdate(HttpServletRequest request, Model model, @RequestBody String jsonArrayString)
|
| 568 |
throws Exception {
|
568 |
throws Exception {
|
| 569 |
JSONArray jsonArray = new JSONArray(jsonArrayString);
|
569 |
JSONArray jsonArray = new JSONArray(jsonArrayString);
|
| 570 |
for (int i = 0; i < jsonArray.length(); i++) {
|
570 |
for (int i = 0; i < jsonArray.length(); i++) {
|
| 571 |
JSONObject obj = jsonArray.getJSONObject(i);
|
571 |
JSONObject obj = jsonArray.getJSONObject(i);
|
| 572 |
|
572 |
|
| 573 |
TagListing tl = tagListingRepository.selectByItemId(obj.getInt("id"));
|
573 |
TagListing tl = tagListingRepository.selectByItemId(obj.getInt("id"));
|
| 574 |
if (tl == null) {
|
574 |
if (tl == null) {
|
| 575 |
continue;
|
575 |
continue;
|
| 576 |
} else {
|
576 |
} else {
|
| 577 |
tl.setHotDeals(obj.getBoolean("hotDeals"));
|
577 |
tl.setHotDeals(obj.getBoolean("hotDeals"));
|
| 578 |
tagListingRepository.persist(tl);
|
578 |
tagListingRepository.persist(tl);
|
| 579 |
}
|
579 |
}
|
| 580 |
}
|
580 |
}
|
| 581 |
model.addAttribute("response1", true);
|
581 |
model.addAttribute("response1", true);
|
| 582 |
return "response";
|
582 |
return "response";
|
| 583 |
}
|
583 |
}
|
| 584 |
|
584 |
|
| 585 |
@RequestMapping(value = "/indent/create-po", method = RequestMethod.POST)
|
585 |
@RequestMapping(value = "/indent/create-po", method = RequestMethod.POST)
|
| 586 |
public String raisePO(HttpServletRequest request, Model model) throws Exception {
|
586 |
public String raisePO(HttpServletRequest request, Model model) throws Exception {
|
| 587 |
boolean success = false;
|
587 |
boolean success = false;
|
| 588 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
588 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 589 |
int fofoId = loginDetails.getFofoId();
|
589 |
int fofoId = loginDetails.getFofoId();
|
| 590 |
List<ItemPriceQuantity> itemQuantities = this.getItemQuantities(fofoId);
|
590 |
List<ItemPriceQuantity> itemQuantities = this.getItemQuantities(fofoId);
|
| 591 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
591 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
| 592 |
Client userClient = new UserClient().getClient();
|
592 |
Client userClient = new UserClient().getClient();
|
| 593 |
double totalAmount = itemQuantities.stream().mapToDouble(x -> x.getQty() * x.getPrice()).sum();
|
593 |
double totalAmount = itemQuantities.stream().mapToDouble(x -> x.getQty() * x.getPrice()).sum();
|
| 594 |
|
594 |
|
| 595 |
if (totalAmount > 0) {
|
595 |
if (totalAmount > 0) {
|
| 596 |
userClient.addItemPricingToCart(customRetailer.getCartId(), itemQuantities);
|
596 |
userClient.addItemPricingToCart(customRetailer.getCartId(), itemQuantities);
|
| 597 |
User user = userRepository.selectById(loginDetails.getFofoId());
|
597 |
User user = userRepository.selectById(loginDetails.getFofoId());
|
| 598 |
userClient = new UserClient().getClient();
|
598 |
userClient = new UserClient().getClient();
|
| 599 |
LOGGER.info("Setting wallet amount in cart");
|
599 |
LOGGER.info("Setting wallet amount in cart");
|
| 600 |
long transactionId = userClient.createOrders(user.getActiveCartId(), "", 0, "", 0, loginDetails.getFofoId(),
|
600 |
long transactionId = userClient.createOrders(user.getActiveCartId(), "", 0, "", 0, loginDetails.getFofoId(),
|
| 601 |
7890, OrderSource.WEBSITE.getValue(), true);
|
601 |
7890, OrderSource.WEBSITE.getValue(), true);
|
| 602 |
LOGGER.info("Creating wallet payment for transactionId - {}", transactionId);
|
602 |
LOGGER.info("Creating wallet payment for transactionId - {}", transactionId);
|
| 603 |
createPayment(user, totalAmount, transactionId);
|
603 |
createPayment(user, totalAmount, transactionId);
|
| 604 |
TransactionService.Client transactionClient = new TransactionClient().getClient();
|
604 |
TransactionService.Client transactionClient = new TransactionClient().getClient();
|
| 605 |
transactionClient.changeTransactionStatus(transactionId, TransactionStatus.AUTHORIZED,
|
605 |
transactionClient.changeTransactionStatus(transactionId, TransactionStatus.AUTHORIZED,
|
| 606 |
"Payment received for the order", PickUpType.RUNNER.getValue(), OrderType.B2B, OrderSource.WEBSITE);
|
606 |
"Payment received for the order", PickUpType.RUNNER.getValue(), OrderType.B2B, OrderSource.WEBSITE);
|
| 607 |
transactionClient.changeTransactionStatus(Long.valueOf(transactionId), TransactionStatus.IN_PROCESS,
|
607 |
transactionClient.changeTransactionStatus(Long.valueOf(transactionId), TransactionStatus.IN_PROCESS,
|
| 608 |
"Paid fully through wallet", PickUpType.RUNNER.getValue(), OrderType.B2B, OrderSource.WEBSITE);
|
608 |
"Paid fully through wallet", PickUpType.RUNNER.getValue(), OrderType.B2B, OrderSource.WEBSITE);
|
| 609 |
LOGGER.info("Successfully created transaction: " + transactionId + " for amount: " + totalAmount);
|
609 |
LOGGER.info("Successfully created transaction: " + transactionId + " for amount: " + totalAmount);
|
| 610 |
transactionClient = new TransactionClient().getClient();
|
610 |
transactionClient = new TransactionClient().getClient();
|
| 611 |
transactionClient.markOrderForRegisteredGstInvoice(Collections.singletonList(Long.valueOf(transactionId)));
|
611 |
transactionClient.markOrderForRegisteredGstInvoice(Collections.singletonList(Long.valueOf(transactionId)));
|
| 612 |
try {
|
612 |
try {
|
| 613 |
transactionClient.enqueueTransactionInfoEmail(transactionId);
|
613 |
transactionClient.enqueueTransactionInfoEmail(transactionId);
|
| 614 |
} catch (Exception e1) {
|
614 |
} catch (Exception e1) {
|
| 615 |
e1.printStackTrace();
|
615 |
e1.printStackTrace();
|
| 616 |
LOGGER.error("Unable to update status of transaction. Thrift Exception:", e1);
|
616 |
LOGGER.error("Unable to update status of transaction. Thrift Exception:", e1);
|
| 617 |
}
|
617 |
}
|
| 618 |
resetCart(transactionClient.getTransaction(transactionId));
|
618 |
resetCart(transactionClient.getTransaction(transactionId));
|
| 619 |
}
|
619 |
}
|
| 620 |
model.addAttribute("response1", mvcResponseSender.createResponseString(success));
|
620 |
model.addAttribute("response1", mvcResponseSender.createResponseString(success));
|
| 621 |
return "response";
|
621 |
return "response";
|
| 622 |
}
|
622 |
}
|
| 623 |
|
623 |
|
| 624 |
private void createPayment(User user, double totalAmount, long transactionId)
|
624 |
private void createPayment(User user, double totalAmount, long transactionId)
|
| 625 |
throws NumberFormatException, PaymentException, TException {
|
625 |
throws NumberFormatException, PaymentException, TException {
|
| 626 |
List<Attribute> paymentAttributes = new ArrayList<Attribute>();
|
626 |
List<Attribute> paymentAttributes = new ArrayList<Attribute>();
|
| 627 |
in.shop2020.payments.PaymentService.Client paymentClient = new PaymentClient().getClient();
|
627 |
in.shop2020.payments.PaymentService.Client paymentClient = new PaymentClient().getClient();
|
| 628 |
paymentAttributes.add(new Attribute("payMethod", "7890"));
|
628 |
paymentAttributes.add(new Attribute("payMethod", "7890"));
|
| 629 |
long paymentId = paymentClient.createPayment(user.getId(), totalAmount, WALLET_GATEWAY_ID, transactionId,
|
629 |
long paymentId = paymentClient.createPayment(user.getId(), totalAmount, WALLET_GATEWAY_ID, transactionId,
|
| 630 |
false);
|
630 |
false);
|
| 631 |
paymentClient.updatePaymentDetails(paymentId, null, null, null, null, null, null, null, null,
|
631 |
paymentClient.updatePaymentDetails(paymentId, null, null, null, null, null, null, null, null,
|
| 632 |
PaymentStatus.SUCCESS, null, paymentAttributes);
|
632 |
PaymentStatus.SUCCESS, null, paymentAttributes);
|
| 633 |
}
|
633 |
}
|
| 634 |
|
634 |
|
| 635 |
@RequestMapping(value = "/indent/loadIndent")
|
635 |
@RequestMapping(value = "/indent/loadIndent")
|
| 636 |
public String loadOpenIndent(HttpServletRequest request, Model model,
|
636 |
public String loadOpenIndent(HttpServletRequest request, Model model,
|
| 637 |
@RequestParam(required = false, defaultValue = "0") int fofoId,
|
637 |
@RequestParam(required = false, defaultValue = "0") int fofoId,
|
| 638 |
@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
|
638 |
@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
|
| 639 |
|
639 |
|
| 640 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
640 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 641 |
Set<Integer> roleIds = loginDetails.getRoleIds();
|
641 |
Set<Integer> roleIds = loginDetails.getRoleIds();
|
| 642 |
LOGGER.info("Counter size is {}", counterSize);
|
642 |
LOGGER.info("Counter size is {}", counterSize);
|
| 643 |
LOGGER.info("Fofo Id is {}", fofoId);
|
643 |
LOGGER.info("Fofo Id is {}", fofoId);
|
| 644 |
boolean isAdmin = roleManager.isAdmin(roleIds);
|
644 |
boolean isAdmin = roleManager.isAdmin(roleIds);
|
| 645 |
|
645 |
|
| 646 |
List<String> brands = mongoClient.getMongoBrands(fofoId, null, 3).stream().map(x -> (String) x.get("name"))
|
646 |
List<String> brands = mongoClient.getMongoBrands(fofoId, null, 3).stream().map(x -> (String) x.get("name"))
|
| 647 |
.collect(Collectors.toList());
|
647 |
.collect(Collectors.toList());
|
| 648 |
|
648 |
|
| 649 |
Map<String, Object> equalsMap = new HashMap<>();
|
649 |
Map<String, Object> equalsMap = new HashMap<>();
|
| 650 |
equalsMap.put("categoryId", 10006);
|
650 |
equalsMap.put("categoryId", 10006);
|
| 651 |
equalsMap.put("brand", brands);
|
651 |
equalsMap.put("brand", brands);
|
| 652 |
Map<String, List<?>> notEqualsMap = new HashMap<>();
|
652 |
Map<String, List<?>> notEqualsMap = new HashMap<>();
|
| 653 |
|
653 |
|
| 654 |
Map<String, List<?>> notEqualsJoinMap = new HashMap<>();
|
654 |
Map<String, List<?>> notEqualsJoinMap = new HashMap<>();
|
| 655 |
Map<Integer, Integer> currentStockMap;
|
655 |
Map<Integer, Integer> currentStockMap;
|
| 656 |
|
656 |
|
| 657 |
if (!isAdmin && fofoId == 0) {
|
657 |
if (!isAdmin && fofoId == 0) {
|
| 658 |
fofoId = cookiesProcessor.getCookiesObject(request).getFofoId();
|
658 |
fofoId = cookiesProcessor.getCookiesObject(request).getFofoId();
|
| 659 |
Map<String, Object> equalsStockJoinMap = new HashMap<>();
|
659 |
Map<String, Object> equalsStockJoinMap = new HashMap<>();
|
| 660 |
equalsStockJoinMap.put("fofoId", fofoId);
|
660 |
equalsStockJoinMap.put("fofoId", fofoId);
|
| 661 |
currentStockMap = itemRepository
|
661 |
currentStockMap = itemRepository
|
| 662 |
.selectItems(CurrentInventorySnapshot.class, "id", "itemId", equalsMap, notEqualsMap,
|
662 |
.selectItems(CurrentInventorySnapshot.class, "id", "itemId", equalsMap, notEqualsMap,
|
| 663 |
equalsStockJoinMap, notEqualsJoinMap, "availability")
|
663 |
equalsStockJoinMap, notEqualsJoinMap, "availability")
|
| 664 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> (int) x.getAggregateValue()));
|
664 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> (int) x.getAggregateValue()));
|
| 665 |
LOGGER.info("currentStock");
|
665 |
LOGGER.info("currentStock");
|
| 666 |
} else {
|
666 |
} else {
|
| 667 |
if (fofoId == 0) {
|
667 |
if (fofoId == 0) {
|
| 668 |
|
668 |
|
| 669 |
Map<String, Object> equalsStockJoinMap = new HashMap<>();
|
669 |
Map<String, Object> equalsStockJoinMap = new HashMap<>();
|
| 670 |
equalsStockJoinMap.put("fofoId", fofoId);
|
670 |
equalsStockJoinMap.put("fofoId", fofoId);
|
| 671 |
|
671 |
|
| 672 |
currentStockMap = itemRepository
|
672 |
currentStockMap = itemRepository
|
| 673 |
.selectItems(CurrentInventorySnapshot.class, "id", "itemId", equalsMap, notEqualsMap,
|
673 |
.selectItems(CurrentInventorySnapshot.class, "id", "itemId", equalsMap, notEqualsMap,
|
| 674 |
equalsStockJoinMap, notEqualsJoinMap, "availability")
|
674 |
equalsStockJoinMap, notEqualsJoinMap, "availability")
|
| 675 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> (int) x.getAggregateValue()));
|
675 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> (int) x.getAggregateValue()));
|
| 676 |
|
676 |
|
| 677 |
} else {
|
677 |
} else {
|
| 678 |
|
678 |
|
| 679 |
Map<String, Object> equalsStockJoinMap = new HashMap<>();
|
679 |
Map<String, Object> equalsStockJoinMap = new HashMap<>();
|
| 680 |
equalsStockJoinMap.put("fofoId", fofoId);
|
680 |
equalsStockJoinMap.put("fofoId", fofoId);
|
| 681 |
|
681 |
|
| 682 |
currentStockMap = itemRepository
|
682 |
currentStockMap = itemRepository
|
| 683 |
.selectItems(CurrentInventorySnapshot.class, "id", "itemId", equalsMap, notEqualsMap,
|
683 |
.selectItems(CurrentInventorySnapshot.class, "id", "itemId", equalsMap, notEqualsMap,
|
| 684 |
equalsStockJoinMap, notEqualsJoinMap, "availability")
|
684 |
equalsStockJoinMap, notEqualsJoinMap, "availability")
|
| 685 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> (int) x.getAggregateValue()));
|
685 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> (int) x.getAggregateValue()));
|
| 686 |
|
686 |
|
| 687 |
}
|
687 |
}
|
| 688 |
}
|
688 |
}
|
| 689 |
|
689 |
|
| 690 |
LOGGER.info("currentStock" + currentStockMap);
|
690 |
LOGGER.info("currentStock" + currentStockMap);
|
| 691 |
|
691 |
|
| 692 |
Map<Integer, Integer> itemsInTransit = null;
|
692 |
Map<Integer, Integer> itemsInTransit = null;
|
| 693 |
List<TagListing> tagListings = tagListingRepository.selectAll(true);
|
693 |
List<TagListing> tagListings = tagListingRepository.selectAll(true);
|
| 694 |
if (!isAdmin) {
|
694 |
if (!isAdmin) {
|
| 695 |
tagListings = new ArrayList<>(tagListings);
|
695 |
tagListings = new ArrayList<>(tagListings);
|
| 696 |
List<Order> inTransitOrders = orderRepository.selectPendingGrnOrder(fofoId,
|
696 |
List<Order> inTransitOrders = orderRepository.selectPendingGrnOrder(fofoId,
|
| 697 |
OrderRepository.validOrderStatusList);
|
697 |
OrderRepository.validOrderStatusList);
|
| 698 |
inTransitOrders = this.filterValidOrders(inTransitOrders);
|
698 |
inTransitOrders = this.filterValidOrders(inTransitOrders);
|
| 699 |
itemsInTransit = inTransitOrders.stream().collect(Collectors.groupingBy(x -> x.getLineItem().getItemId(),
|
699 |
itemsInTransit = inTransitOrders.stream().collect(Collectors.groupingBy(x -> x.getLineItem().getItemId(),
|
| 700 |
Collectors.summingInt(x -> x.getLineItem().getQuantity())));
|
700 |
Collectors.summingInt(x -> x.getLineItem().getQuantity())));
|
| 701 |
} else {
|
701 |
} else {
|
| 702 |
itemsInTransit = new HashMap<>();
|
702 |
itemsInTransit = new HashMap<>();
|
| 703 |
}
|
703 |
}
|
| 704 |
|
704 |
|
| 705 |
int totalPcs = 0;
|
705 |
int totalPcs = 0;
|
| 706 |
|
706 |
|
| 707 |
float totalAmount = 0;
|
707 |
float totalAmount = 0;
|
| 708 |
Map<Integer, CatalogListingModel> catalogListingMap = new HashMap<>();
|
708 |
Map<Integer, CatalogListingModel> catalogListingMap = new HashMap<>();
|
| 709 |
List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId())
|
709 |
List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId())
|
| 710 |
.collect(Collectors.toList());
|
710 |
.collect(Collectors.toList());
|
| 711 |
|
711 |
|
| 712 |
LOGGER.info("regionIds" + regionIds);
|
712 |
LOGGER.info("regionIds" + regionIds);
|
| 713 |
Map<Integer, FocusedModel> focusedModelMap = focusedModelRepository.selectAllByRegionIds(regionIds).stream()
|
713 |
Map<Integer, FocusedModel> focusedModelMap = focusedModelRepository.selectAllByRegionIds(regionIds).stream()
|
| 714 |
.collect(Collectors.toMap(FocusedModel::getCatalogId, Function.identity()));
|
714 |
.collect(Collectors.toMap(FocusedModel::getCatalogId, Function.identity()));
|
| 715 |
LOGGER.info("focusedModelMap" + focusedModelMap);
|
715 |
LOGGER.info("focusedModelMap" + focusedModelMap);
|
| 716 |
LocalDate planningMonthDate = null;
|
716 |
LocalDate planningMonthDate = null;
|
| 717 |
MonthlyPlanned monthlyPlanned = null;
|
717 |
MonthlyPlanned monthlyPlanned = null;
|
| 718 |
List<Integer> fofoOrderIds = null;
|
718 |
List<Integer> fofoOrderIds = null;
|
| 719 |
LOGGER.info("localDate" + LocalDate.now());
|
719 |
LOGGER.info("localDate" + LocalDate.now());
|
| 720 |
if (LocalDate.now().isAfter(LocalDate.now().withDayOfMonth(PLANNING_OPEN_DAY))) {
|
720 |
if (LocalDate.now().isAfter(LocalDate.now().withDayOfMonth(PLANNING_OPEN_DAY))) {
|
| 721 |
planningMonthDate = LocalDate.now().plusMonths(1).withDayOfMonth(1);
|
721 |
planningMonthDate = LocalDate.now().plusMonths(1).withDayOfMonth(1);
|
| 722 |
monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, planningMonthDate);
|
722 |
monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, planningMonthDate);
|
| 723 |
LOGGER.info("monthlyPlanned2" + monthlyPlanned);
|
723 |
LOGGER.info("monthlyPlanned2" + monthlyPlanned);
|
| 724 |
fofoOrderIds = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
|
724 |
fofoOrderIds = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
|
| 725 |
LocalDateTime.now().minusDays(15), LocalDateTime.now()).stream().map(x -> x.getId())
|
725 |
LocalDateTime.now().minusDays(15), LocalDateTime.now()).stream().map(x -> x.getId())
|
| 726 |
.collect(Collectors.toList());
|
726 |
.collect(Collectors.toList());
|
| 727 |
|
727 |
|
| 728 |
model.addAttribute("planningMonth", LocalDate.now().plusMonths(1).getMonth());
|
728 |
model.addAttribute("planningMonth", LocalDate.now().plusMonths(1).getMonth());
|
| 729 |
} else {
|
729 |
} else {
|
| 730 |
planningMonthDate = LocalDate.now().withDayOfMonth(1);
|
730 |
planningMonthDate = LocalDate.now().withDayOfMonth(1);
|
| 731 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
731 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 732 |
monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, planningMonthDate);
|
732 |
monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, planningMonthDate);
|
| 733 |
model.addAttribute("planningMonth", planningMonthDate.getMonth());
|
733 |
model.addAttribute("planningMonth", planningMonthDate.getMonth());
|
| 734 |
model.addAttribute("mtd", true);
|
734 |
model.addAttribute("mtd", true);
|
| 735 |
model.addAttribute("freezed", true);
|
735 |
model.addAttribute("freezed", true);
|
| 736 |
fofoOrderIds = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
|
736 |
fofoOrderIds = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
|
| 737 |
curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX)).stream().map(x -> x.getId())
|
737 |
curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX)).stream().map(x -> x.getId())
|
| 738 |
.collect(Collectors.toList());
|
738 |
.collect(Collectors.toList());
|
| 739 |
LOGGER.info("monthlyPlanned1" + monthlyPlanned);
|
739 |
LOGGER.info("monthlyPlanned1" + monthlyPlanned);
|
| 740 |
}
|
740 |
}
|
| 741 |
|
741 |
|
| 742 |
Map<Integer, Integer> plannedDetailMap = null;
|
742 |
Map<Integer, Integer> plannedDetailMap = null;
|
| 743 |
if (monthlyPlanned != null) {
|
743 |
if (monthlyPlanned != null) {
|
| 744 |
plannedDetailMap = plannedDetailRepository.selectByPlannedId(monthlyPlanned.getId()).stream()
|
744 |
plannedDetailMap = plannedDetailRepository.selectByPlannedId(monthlyPlanned.getId()).stream()
|
| 745 |
.collect(Collectors.toMap(x -> x.getCatalogId(), x -> x.getQuantity()));
|
745 |
.collect(Collectors.toMap(x -> x.getCatalogId(), x -> x.getQuantity()));
|
| 746 |
|
746 |
|
| 747 |
}
|
747 |
}
|
| 748 |
LOGGER.info("plannedDetailMap" + plannedDetailMap);
|
748 |
LOGGER.info("plannedDetailMap" + plannedDetailMap);
|
| 749 |
|
749 |
|
| 750 |
LOGGER.info("fofoOrderIds" + fofoOrderIds);
|
750 |
LOGGER.info("fofoOrderIds" + fofoOrderIds);
|
| 751 |
Map<String, Object> equalsJoinMap = new HashMap<>();
|
751 |
Map<String, Object> equalsJoinMap = new HashMap<>();
|
| 752 |
|
752 |
|
| 753 |
equalsJoinMap.put("orderId", fofoOrderIds);
|
753 |
equalsJoinMap.put("orderId", fofoOrderIds);
|
| 754 |
Map<Integer, Integer> last15daysMap = null;
|
754 |
Map<Integer, Integer> last15daysMap = null;
|
| 755 |
if (fofoOrderIds != null && !fofoOrderIds.isEmpty()) {
|
755 |
if (fofoOrderIds != null && !fofoOrderIds.isEmpty()) {
|
| 756 |
|
756 |
|
| 757 |
last15daysMap = itemRepository
|
757 |
last15daysMap = itemRepository
|
| 758 |
.selectItems(FofoOrderItem.class, "id", "itemId", equalsMap, notEqualsMap, equalsJoinMap,
|
758 |
.selectItems(FofoOrderItem.class, "id", "itemId", equalsMap, notEqualsMap, equalsJoinMap,
|
| 759 |
notEqualsJoinMap, "quantity")
|
759 |
notEqualsJoinMap, "quantity")
|
| 760 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> (int) x.getAggregateValue()));
|
760 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> (int) x.getAggregateValue()));
|
| 761 |
}
|
761 |
}
|
| 762 |
LOGGER.info("last15daysMap" + last15daysMap);
|
762 |
LOGGER.info("last15daysMap" + last15daysMap);
|
| 763 |
|
763 |
|
| 764 |
Map<Integer, TagListing> taglistingMap = tagListings.stream()
|
764 |
Map<Integer, TagListing> taglistingMap = tagListings.stream()
|
| 765 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
765 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
| 766 |
List<Item> items = itemRepository.selectByIds(taglistingMap.keySet());
|
766 |
List<Item> items = itemRepository.selectByIds(taglistingMap.keySet());
|
| 767 |
Map<Integer, List<Item>> catalogIdItemMap = items.stream().collect(
|
767 |
Map<Integer, List<Item>> catalogIdItemMap = items.stream().collect(
|
| 768 |
Collectors.groupingBy(x -> x.getCatalogItemId(), Collectors.mapping(y -> y, Collectors.toList())));
|
768 |
Collectors.groupingBy(x -> x.getCatalogItemId(), Collectors.mapping(y -> y, Collectors.toList())));
|
| 769 |
LOGGER.info("catalogIdItemMap");
|
769 |
LOGGER.info("catalogIdItemMap");
|
| 770 |
|
770 |
|
| 771 |
Map<String, Object> equalsItemJoinMap = new HashMap<>();
|
771 |
Map<String, Object> equalsItemJoinMap = new HashMap<>();
|
| 772 |
equalsItemJoinMap.put("active", 1);
|
772 |
equalsItemJoinMap.put("active", 1);
|
| 773 |
List<IntegerIdAggregateValue> tagListingCatalogIds = itemRepository.selectItems(TagListing.class, "id",
|
773 |
List<IntegerIdAggregateValue> tagListingCatalogIds = itemRepository.selectItems(TagListing.class, "id",
|
| 774 |
"itemId", equalsMap, notEqualsMap, equalsItemJoinMap, notEqualsJoinMap, "tagId");
|
774 |
"itemId", equalsMap, notEqualsMap, equalsItemJoinMap, notEqualsJoinMap, "tagId");
|
| 775 |
LOGGER.info("tagListingCatalogIds");
|
775 |
LOGGER.info("tagListingCatalogIds");
|
| 776 |
for (IntegerIdAggregateValue catalogIdAggregateValue : tagListingCatalogIds) {
|
776 |
for (IntegerIdAggregateValue catalogIdAggregateValue : tagListingCatalogIds) {
|
| 777 |
int catalogId = catalogIdAggregateValue.getCatalogId();
|
777 |
int catalogId = catalogIdAggregateValue.getCatalogId();
|
| 778 |
Item item = catalogIdItemMap.get(catalogId).get(0);
|
778 |
Item item = catalogIdItemMap.get(catalogId).get(0);
|
| 779 |
TagListing tagListing = taglistingMap.get(item.getId());
|
779 |
TagListing tagListing = taglistingMap.get(item.getId());
|
| 780 |
CatalogListingModel catalogListingModel = catalogListingMap.get(catalogId);
|
780 |
CatalogListingModel catalogListingModel = catalogListingMap.get(catalogId);
|
| 781 |
if (!catalogListingMap.containsKey(catalogId)) {
|
781 |
if (!catalogListingMap.containsKey(catalogId)) {
|
| 782 |
catalogListingModel = new CatalogListingModel();
|
782 |
catalogListingModel = new CatalogListingModel();
|
| 783 |
catalogListingModel.setCatalogId(catalogId);
|
783 |
catalogListingModel.setCatalogId(catalogId);
|
| 784 |
catalogListingModel.setDp(tagListing.getSellingPrice());
|
784 |
catalogListingModel.setDp(tagListing.getSellingPrice());
|
| 785 |
catalogListingModel.setMop(tagListing.getMop());
|
785 |
catalogListingModel.setMop(tagListing.getMop());
|
| 786 |
catalogListingModel.setItemDescription(item.getItemDescriptionNoColor());
|
786 |
catalogListingModel.setItemDescription(item.getItemDescriptionNoColor());
|
| 787 |
if (plannedDetailMap != null) {
|
787 |
if (plannedDetailMap != null) {
|
| 788 |
|
788 |
|
| 789 |
Integer quantity = plannedDetailMap.get(catalogId);
|
789 |
Integer quantity = plannedDetailMap.get(catalogId);
|
| 790 |
if (quantity != null) {
|
790 |
if (quantity != null) {
|
| 791 |
catalogListingModel.setAllocatedQuantity(quantity);
|
791 |
catalogListingModel.setAllocatedQuantity(quantity);
|
| 792 |
}
|
792 |
}
|
| 793 |
}
|
793 |
}
|
| 794 |
|
794 |
|
| 795 |
if (last15daysMap != null) {
|
795 |
if (last15daysMap != null) {
|
| 796 |
Integer last15DaysSale = last15daysMap.get(catalogId);
|
796 |
Integer last15DaysSale = last15daysMap.get(catalogId);
|
| 797 |
|
797 |
|
| 798 |
if (last15DaysSale != null) {
|
798 |
if (last15DaysSale != null) {
|
| 799 |
catalogListingModel.setLast15DaysSale(last15DaysSale);
|
799 |
catalogListingModel.setLast15DaysSale(last15DaysSale);
|
| 800 |
} else {
|
800 |
} else {
|
| 801 |
catalogListingModel.setLast15DaysSale(0);
|
801 |
catalogListingModel.setLast15DaysSale(0);
|
| 802 |
}
|
802 |
}
|
| 803 |
} else {
|
803 |
} else {
|
| 804 |
catalogListingModel.setLast15DaysSale(0);
|
804 |
catalogListingModel.setLast15DaysSale(0);
|
| 805 |
}
|
805 |
}
|
| 806 |
|
806 |
|
| 807 |
catalogListingModel.setBrand(item.getBrand());
|
807 |
catalogListingModel.setBrand(item.getBrand());
|
| 808 |
if (item.getCategoryId() == 10006) {
|
808 |
if (item.getCategoryId() == 10006) {
|
| 809 |
catalogListingModel.setCategoryId(item.getCategoryId());
|
809 |
catalogListingModel.setCategoryId(item.getCategoryId());
|
| 810 |
}
|
810 |
}
|
| 811 |
|
811 |
|
| 812 |
FocusedModel fm = focusedModelMap.get(catalogId);
|
812 |
FocusedModel fm = focusedModelMap.get(catalogId);
|
| 813 |
if (fm != null) {
|
813 |
if (fm != null) {
|
| 814 |
catalogListingModel.setRecommendedQty(fm.getRecommendedQty());
|
814 |
catalogListingModel.setRecommendedQty(fm.getRecommendedQty());
|
| 815 |
catalogListingModel.setMinimumQty(fm.getMinimumQty());
|
815 |
catalogListingModel.setMinimumQty(fm.getMinimumQty());
|
| 816 |
|
816 |
|
| 817 |
} else {
|
817 |
} else {
|
| 818 |
catalogListingModel.setRecommendedQty(0);
|
818 |
catalogListingModel.setRecommendedQty(0);
|
| 819 |
catalogListingModel.setMinimumQty(0);
|
819 |
catalogListingModel.setMinimumQty(0);
|
| 820 |
}
|
820 |
}
|
| 821 |
|
821 |
|
| 822 |
catalogListingMap.put(catalogId, catalogListingModel);
|
822 |
catalogListingMap.put(catalogId, catalogListingModel);
|
| 823 |
|
823 |
|
| 824 |
}
|
824 |
}
|
| 825 |
int itemAvailability = 0;
|
825 |
int itemAvailability = 0;
|
| 826 |
if (currentStockMap != null) {
|
826 |
if (currentStockMap != null) {
|
| 827 |
Integer qty = currentStockMap.get(catalogId);
|
827 |
Integer qty = currentStockMap.get(catalogId);
|
| 828 |
itemAvailability = qty == null ? 0 : qty;
|
828 |
itemAvailability = qty == null ? 0 : qty;
|
| 829 |
catalogListingModel.setStockInHand(itemAvailability);
|
829 |
catalogListingModel.setStockInHand(itemAvailability);
|
| 830 |
} else {
|
830 |
} else {
|
| 831 |
catalogListingModel.setStockInHand(0);
|
831 |
catalogListingModel.setStockInHand(0);
|
| 832 |
}
|
832 |
}
|
| 833 |
Integer inTransitQuantity = itemsInTransit.get(item.getId());
|
833 |
Integer inTransitQuantity = itemsInTransit.get(item.getId());
|
| 834 |
int inTransitQty = (inTransitQuantity == null ? 0 : inTransitQuantity);
|
834 |
int inTransitQty = (inTransitQuantity == null ? 0 : inTransitQuantity);
|
| 835 |
catalogListingModel.setInTransitQuantity(catalogListingModel.getInTransitQuantity() + inTransitQty);
|
835 |
catalogListingModel.setInTransitQuantity(catalogListingModel.getInTransitQuantity() + inTransitQty);
|
| 836 |
if (plannedDetailMap != null) {
|
836 |
if (plannedDetailMap != null) {
|
| 837 |
if (plannedDetailMap.get(catalogId) != null) {
|
837 |
if (plannedDetailMap.get(catalogId) != null) {
|
| 838 |
|
838 |
|
| 839 |
int remaining = plannedDetailMap.get(catalogId) - catalogListingModel.getLast15DaysSale()
|
839 |
int remaining = plannedDetailMap.get(catalogId) - catalogListingModel.getLast15DaysSale()
|
| 840 |
+ catalogListingModel.getStockInHand() + catalogListingModel.getInTransitQuantity();
|
840 |
+ catalogListingModel.getStockInHand() + catalogListingModel.getInTransitQuantity();
|
| 841 |
LOGGER.info("remaning" + remaining);
|
841 |
LOGGER.info("remaning" + remaining);
|
| 842 |
|
842 |
|
| 843 |
if (remaining != 0) {
|
843 |
if (remaining != 0) {
|
| 844 |
catalogListingModel.setRemaining(remaining);
|
844 |
catalogListingModel.setRemaining(remaining);
|
| 845 |
} else {
|
845 |
} else {
|
| 846 |
catalogListingModel.setRemaining(0);
|
846 |
catalogListingModel.setRemaining(0);
|
| 847 |
}
|
847 |
}
|
| 848 |
}
|
848 |
}
|
| 849 |
}
|
849 |
}
|
| 850 |
}
|
850 |
}
|
| 851 |
|
851 |
|
| 852 |
Map<Integer, CustomRetailer> customRetailersMap = retailerService.getFofoRetailers(false);
|
852 |
Map<Integer, CustomRetailer> customRetailersMap = retailerService.getFofoRetailers(false);
|
| 853 |
if (fofoId > 0) {
|
853 |
if (fofoId > 0) {
|
| 854 |
CustomRetailer customRetailer = customRetailersMap.get(fofoId);
|
854 |
CustomRetailer customRetailer = customRetailersMap.get(fofoId);
|
| 855 |
model.addAttribute("retailerName",
|
855 |
model.addAttribute("retailerName",
|
| 856 |
customRetailer.getBusinessName() + "-" + customRetailer.getAddress().getCity());
|
856 |
customRetailer.getBusinessName() + "-" + customRetailer.getAddress().getCity());
|
| 857 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(fofoId);
|
857 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(fofoId);
|
| 858 |
model.addAttribute("retailerId", customRetailer.getPartnerId());
|
858 |
model.addAttribute("retailerId", customRetailer.getPartnerId());
|
| 859 |
model.addAttribute("counterSize", fs.getCounterSize().toString());
|
859 |
model.addAttribute("counterSize", fs.getCounterSize().toString());
|
| 860 |
} else {
|
860 |
} else {
|
| 861 |
model.addAttribute("counterSize", counterSize.toString());
|
861 |
model.addAttribute("counterSize", counterSize.toString());
|
| 862 |
}
|
862 |
}
|
| 863 |
String customRetailers = JSONObject.valueToString(customRetailersMap.values());
|
863 |
String customRetailers = JSONObject.valueToString(customRetailersMap.values());
|
| 864 |
|
864 |
|
| 865 |
List<CatalogListingModel> catalogModelList = new ArrayList<>(catalogListingMap.values());
|
865 |
List<CatalogListingModel> catalogModelList = new ArrayList<>(catalogListingMap.values());
|
| 866 |
|
866 |
|
| 867 |
Comparator<CatalogListingModel> firstCmp = Comparator.comparing(CatalogListingModel::getMinimumQty,
|
867 |
Comparator<CatalogListingModel> firstCmp = Comparator.comparing(CatalogListingModel::getMinimumQty,
|
| 868 |
Comparator.reverseOrder());
|
868 |
Comparator.reverseOrder());
|
| 869 |
LOGGER.info("monthlyPlanned" + monthlyPlanned);
|
869 |
LOGGER.info("monthlyPlanned" + monthlyPlanned);
|
| 870 |
model.addAttribute("catalogTagListings",
|
870 |
model.addAttribute("catalogTagListings",
|
| 871 |
catalogModelList.stream().sorted(firstCmp).collect(Collectors.toList()));
|
871 |
catalogModelList.stream().sorted(firstCmp).collect(Collectors.toList()));
|
| 872 |
model.addAttribute("isAdmin", roleManager.isAdmin(roleIds));
|
872 |
model.addAttribute("isAdmin", roleManager.isAdmin(roleIds));
|
| 873 |
model.addAttribute("brandStockPrices", this.getBrandStockPrices(loginDetails.getFofoId()));
|
873 |
model.addAttribute("brandStockPrices", this.getBrandStockPrices(loginDetails.getFofoId()));
|
| 874 |
model.addAttribute("previousPlanningMonth", planningMonthDate.minusMonths(1).getMonth());
|
874 |
model.addAttribute("previousPlanningMonth", planningMonthDate.minusMonths(1).getMonth());
|
| 875 |
model.addAttribute("currentPlanningMonth", planningMonthDate.getMonth());
|
875 |
model.addAttribute("currentPlanningMonth", planningMonthDate.getMonth());
|
| 876 |
|
876 |
|
| 877 |
model.addAttribute("customRetailers", customRetailers);
|
877 |
model.addAttribute("customRetailers", customRetailers);
|
| 878 |
model.addAttribute("totalAmount", totalAmount);
|
878 |
model.addAttribute("totalAmount", totalAmount);
|
| 879 |
model.addAttribute("monthlyPlanned", monthlyPlanned);
|
879 |
model.addAttribute("monthlyPlanned", monthlyPlanned);
|
| 880 |
model.addAttribute("totalPcs", totalPcs);
|
880 |
model.addAttribute("totalPcs", totalPcs);
|
| 881 |
return "open-indent";
|
881 |
return "open-indent";
|
| 882 |
|
882 |
|
| 883 |
}
|
883 |
}
|
| 884 |
|
884 |
|
| 885 |
private long resetCart(Transaction transaction) {
|
885 |
private long resetCart(Transaction transaction) {
|
| 886 |
long sum = 0;
|
886 |
long sum = 0;
|
| 887 |
Map<Long, Double> items = new HashMap<Long, Double>();
|
887 |
Map<Long, Double> items = new HashMap<Long, Double>();
|
| 888 |
for (in.shop2020.model.v1.order.Order order : transaction.getOrders()) {
|
888 |
for (in.shop2020.model.v1.order.Order order : transaction.getOrders()) {
|
| 889 |
sum += order.getGvAmount();
|
889 |
sum += order.getGvAmount();
|
| 890 |
for (LineItem lineitem : order.getLineitems()) {
|
890 |
for (LineItem lineitem : order.getLineitems()) {
|
| 891 |
Long itemId = lineitem.getItem_id();
|
891 |
Long itemId = lineitem.getItem_id();
|
| 892 |
Double quantity = items.get(itemId);
|
892 |
Double quantity = items.get(itemId);
|
| 893 |
if (quantity == null) {
|
893 |
if (quantity == null) {
|
| 894 |
quantity = lineitem.getQuantity();
|
894 |
quantity = lineitem.getQuantity();
|
| 895 |
} else {
|
895 |
} else {
|
| 896 |
quantity = quantity + lineitem.getQuantity();
|
896 |
quantity = quantity + lineitem.getQuantity();
|
| 897 |
}
|
897 |
}
|
| 898 |
items.put(itemId, quantity);
|
898 |
items.put(itemId, quantity);
|
| 899 |
}
|
899 |
}
|
| 900 |
}
|
900 |
}
|
| 901 |
|
901 |
|
| 902 |
LOGGER.debug("Items to reset in cart are: " + items);
|
902 |
LOGGER.debug("Items to reset in cart are: " + items);
|
| 903 |
|
903 |
|
| 904 |
try {
|
904 |
try {
|
| 905 |
Client userClient = new UserClient().getClient();
|
905 |
Client userClient = new UserClient().getClient();
|
| 906 |
userClient.resetCart(transaction.getShoppingCartid(), items);
|
906 |
userClient.resetCart(transaction.getShoppingCartid(), items);
|
| 907 |
} catch (TException e) {
|
907 |
} catch (TException e) {
|
| 908 |
LOGGER.error("Error while updating information in payment database.", e);
|
908 |
LOGGER.error("Error while updating information in payment database.", e);
|
| 909 |
} catch (ShoppingCartException e) {
|
909 |
} catch (ShoppingCartException e) {
|
| 910 |
LOGGER.error("Error while reseting the cart in cart database.", e);
|
910 |
LOGGER.error("Error while reseting the cart in cart database.", e);
|
| 911 |
} catch (Exception e) {
|
911 |
} catch (Exception e) {
|
| 912 |
LOGGER.error("Unexpected exception", e);
|
912 |
LOGGER.error("Unexpected exception", e);
|
| 913 |
}
|
913 |
}
|
| 914 |
return sum;
|
914 |
return sum;
|
| 915 |
}
|
915 |
}
|
| 916 |
|
916 |
|
| 917 |
private List<ItemPriceQuantity> getItemQuantities(int fofoId) throws ProfitMandiBusinessException {
|
917 |
private List<ItemPriceQuantity> getItemQuantities(int fofoId) throws ProfitMandiBusinessException {
|
| 918 |
List<ItemPriceQuantity> itemQuantities = new ArrayList<>();
|
918 |
List<ItemPriceQuantity> itemQuantities = new ArrayList<>();
|
| 919 |
/*
|
919 |
/*
|
| 920 |
* Map<Integer, ItemIdAvailability> itemCisMap = null; List<ItemIdAvailability>
|
920 |
* Map<Integer, ItemIdAvailability> itemCisMap = null; List<ItemIdAvailability>
|
| 921 |
* currentInventorySnapshots = currentInventorySnapshotRepository
|
921 |
* currentInventorySnapshots = currentInventorySnapshotRepository
|
| 922 |
* .selectItemsStock(fofoId); itemCisMap =
|
922 |
* .selectItemsStock(fofoId); itemCisMap =
|
| 923 |
* currentInventorySnapshots.stream().filter(x -> x.getAvailability() > 0)
|
923 |
* currentInventorySnapshots.stream().filter(x -> x.getAvailability() > 0)
|
| 924 |
* .collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
924 |
* .collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
| 925 |
* List<StockAllocationModel> stockAllocationList =
|
925 |
* List<StockAllocationModel> stockAllocationList =
|
| 926 |
* stockAllocationService.getStockAllocation(fofoId, true);
|
926 |
* stockAllocationService.getStockAllocation(fofoId, true);
|
| 927 |
*
|
927 |
*
|
| 928 |
* Map<Integer, StockAllocationModel> itemStockAllocationMap =
|
928 |
* Map<Integer, StockAllocationModel> itemStockAllocationMap =
|
| 929 |
* stockAllocationList.stream() .collect(Collectors.toMap(x -> x.catalogId(), x
|
929 |
* stockAllocationList.stream() .collect(Collectors.toMap(x -> x.catalogId(), x
|
| 930 |
* -> x)); Map<Integer, Integer> itemsInTransit = null;
|
930 |
* -> x)); Map<Integer, Integer> itemsInTransit = null;
|
| 931 |
* LOGGER.info("Item Stock Allocation Model Map {}", itemStockAllocationMap);
|
931 |
* LOGGER.info("Item Stock Allocation Model Map {}", itemStockAllocationMap);
|
| 932 |
* List<TagListing> tagListings = tagListingRepository.selectAll(false);
|
932 |
* List<TagListing> tagListings = tagListingRepository.selectAll(false);
|
| 933 |
* List<Order> inTransitOrders = orderRepository.selectOrders(fofoId,
|
933 |
* List<Order> inTransitOrders = orderRepository.selectOrders(fofoId,
|
| 934 |
* validOrderStatusList); inTransitOrders =
|
934 |
* validOrderStatusList); inTransitOrders =
|
| 935 |
* this.filterValidOrders(inTransitOrders); itemsInTransit =
|
935 |
* this.filterValidOrders(inTransitOrders); itemsInTransit =
|
| 936 |
* inTransitOrders.stream().collect(Collectors.groupingBy(x ->
|
936 |
* inTransitOrders.stream().collect(Collectors.groupingBy(x ->
|
| 937 |
* x.getLineItem().getItemId(), Collectors.summingInt(x ->
|
937 |
* x.getLineItem().getItemId(), Collectors.summingInt(x ->
|
| 938 |
* x.getLineItem().getQuantity())));
|
938 |
* x.getLineItem().getQuantity())));
|
| 939 |
*
|
939 |
*
|
| 940 |
* Iterator<TagListing> iterator = tagListings.iterator();
|
940 |
* Iterator<TagListing> iterator = tagListings.iterator();
|
| 941 |
*
|
941 |
*
|
| 942 |
* int toBeOrdered = 0; while (iterator.hasNext()) { TagListing tagListing =
|
942 |
* int toBeOrdered = 0; while (iterator.hasNext()) { TagListing tagListing =
|
| 943 |
* iterator.next(); LOGGER.info(" tagListing.setAllocatedQuantity {}",
|
943 |
* iterator.next(); LOGGER.info(" tagListing.setAllocatedQuantity {}",
|
| 944 |
* tagListing.getAllocatedQuantity()); if
|
944 |
* tagListing.getAllocatedQuantity()); if
|
| 945 |
* (!itemCisMap.containsKey(tagListing.getItemId()) &&
|
945 |
* (!itemCisMap.containsKey(tagListing.getItemId()) &&
|
| 946 |
* !itemStockAllocationMap.containsKey(tagListing.getItemId())) {
|
946 |
* !itemStockAllocationMap.containsKey(tagListing.getItemId())) {
|
| 947 |
* iterator.remove(); continue; } ItemIdAvailability itemIdAvailability =
|
947 |
* iterator.remove(); continue; } ItemIdAvailability itemIdAvailability =
|
| 948 |
* itemCisMap.get(tagListing.getItemId());
|
948 |
* itemCisMap.get(tagListing.getItemId());
|
| 949 |
* tagListing.setStockInHand(itemIdAvailability == null ? 0 :
|
949 |
* tagListing.setStockInHand(itemIdAvailability == null ? 0 :
|
| 950 |
* itemIdAvailability.getAvailability()); StockAllocationModel
|
950 |
* itemIdAvailability.getAvailability()); StockAllocationModel
|
| 951 |
* stockAllocationModel = itemStockAllocationMap.get(tagListing.getItemId());
|
951 |
* stockAllocationModel = itemStockAllocationMap.get(tagListing.getItemId());
|
| 952 |
*
|
952 |
*
|
| 953 |
* if (itemsInTransit.containsKey(tagListing.getItemId())) {
|
953 |
* if (itemsInTransit.containsKey(tagListing.getItemId())) {
|
| 954 |
* tagListing.setInTransitQuantity(itemsInTransit.get(tagListing.getItemId()));
|
954 |
* tagListing.setInTransitQuantity(itemsInTransit.get(tagListing.getItemId()));
|
| 955 |
* } else { tagListing.setInTransitQuantity(0); } if (stockAllocationModel !=
|
955 |
* } else { tagListing.setInTransitQuantity(0); } if (stockAllocationModel !=
|
| 956 |
* null) { tagListing.setAllocatedQuantity(stockAllocationModel.getQuantity());
|
956 |
* null) { tagListing.setAllocatedQuantity(stockAllocationModel.getQuantity());
|
| 957 |
* toBeOrdered = Math.max(tagListing.getAllocatedQuantity() -
|
957 |
* toBeOrdered = Math.max(tagListing.getAllocatedQuantity() -
|
| 958 |
* tagListing.getInTransitQuantity() - tagListing.getStockInHand(), 0); if
|
958 |
* tagListing.getInTransitQuantity() - tagListing.getStockInHand(), 0); if
|
| 959 |
* (toBeOrdered > 0) { ItemPriceQuantity ipq = new ItemPriceQuantity();
|
959 |
* (toBeOrdered > 0) { ItemPriceQuantity ipq = new ItemPriceQuantity();
|
| 960 |
* ipq.setItemId(tagListing.getItemId()); ipq.setQty((long) toBeOrdered);
|
960 |
* ipq.setItemId(tagListing.getItemId()); ipq.setQty((long) toBeOrdered);
|
| 961 |
* ipq.setPrice(tagListing.getSellingPrice()); itemQuantities.add(ipq); } } }
|
961 |
* ipq.setPrice(tagListing.getSellingPrice()); itemQuantities.add(ipq); } } }
|
| 962 |
*/
|
962 |
*/
|
| 963 |
return itemQuantities;
|
963 |
return itemQuantities;
|
| 964 |
|
964 |
|
| 965 |
}
|
965 |
}
|
| 966 |
|
966 |
|
| 967 |
@RequestMapping(value = "/indent/loadIndentPreviousMonth")
|
967 |
@RequestMapping(value = "/indent/loadIndentPreviousMonth")
|
| 968 |
public String previousMonthLoadOpenIndent(HttpServletRequest request, Model model,
|
968 |
public String previousMonthLoadOpenIndent(HttpServletRequest request, Model model,
|
| 969 |
@RequestParam(required = false, defaultValue = "0") int fofoId,
|
969 |
@RequestParam(required = false, defaultValue = "0") int fofoId,
|
| 970 |
@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
|
970 |
@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
|
| 971 |
LocalDate planMonthStart = null;
|
971 |
LocalDate planMonthStart = null;
|
| 972 |
if (LocalDate.now().isAfter(LocalDate.now().withDayOfMonth(PLANNING_OPEN_DAY))) {
|
972 |
if (LocalDate.now().isAfter(LocalDate.now().withDayOfMonth(PLANNING_OPEN_DAY))) {
|
| 973 |
planMonthStart = LocalDate.now().plusMonths(1).withDayOfMonth(1);
|
973 |
planMonthStart = LocalDate.now().plusMonths(1).withDayOfMonth(1);
|
| 974 |
} else {
|
974 |
} else {
|
| 975 |
planMonthStart = LocalDate.now().withDayOfMonth(1);
|
975 |
planMonthStart = LocalDate.now().withDayOfMonth(1);
|
| 976 |
}
|
976 |
}
|
| 977 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
977 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 978 |
Set<Integer> roleIds = loginDetails.getRoleIds();
|
978 |
Set<Integer> roleIds = loginDetails.getRoleIds();
|
| 979 |
LOGGER.info("Counter size is {}", counterSize);
|
979 |
LOGGER.info("Counter size is {}", counterSize);
|
| 980 |
LOGGER.info("Fofo Id is {}", fofoId);
|
980 |
LOGGER.info("Fofo Id is {}", fofoId);
|
| 981 |
boolean isAdmin = roleManager.isAdmin(roleIds);
|
981 |
boolean isAdmin = roleManager.isAdmin(roleIds);
|
| 982 |
|
982 |
|
| 983 |
List<String> brands = mongoClient.getMongoBrands(fofoId, null, 3).stream().map(x -> (String) x.get("name"))
|
983 |
List<String> brands = mongoClient.getMongoBrands(fofoId, null, 3).stream().map(x -> (String) x.get("name"))
|
| 984 |
.collect(Collectors.toList());
|
984 |
.collect(Collectors.toList());
|
| 985 |
|
985 |
|
| 986 |
Map<String, Object> equalsMap = new HashMap<>();
|
986 |
Map<String, Object> equalsMap = new HashMap<>();
|
| 987 |
equalsMap.put("categoryId", 10006);
|
987 |
equalsMap.put("categoryId", 10006);
|
| 988 |
equalsMap.put("brand", brands);
|
988 |
equalsMap.put("brand", brands);
|
| 989 |
Map<String, List<?>> notEqualsMap = new HashMap<>();
|
989 |
Map<String, List<?>> notEqualsMap = new HashMap<>();
|
| 990 |
|
990 |
|
| 991 |
Map<String, List<?>> notEqualsJoinMap = new HashMap<>();
|
991 |
Map<String, List<?>> notEqualsJoinMap = new HashMap<>();
|
| 992 |
Map<Integer, Integer> currentStockMap;
|
992 |
Map<Integer, Integer> currentStockMap;
|
| 993 |
|
993 |
|
| 994 |
if (!isAdmin && fofoId == 0) {
|
994 |
if (!isAdmin && fofoId == 0) {
|
| 995 |
fofoId = cookiesProcessor.getCookiesObject(request).getFofoId();
|
995 |
fofoId = cookiesProcessor.getCookiesObject(request).getFofoId();
|
| 996 |
Map<String, Object> equalsStockJoinMap = new HashMap<>();
|
996 |
Map<String, Object> equalsStockJoinMap = new HashMap<>();
|
| 997 |
equalsStockJoinMap.put("fofoId", fofoId);
|
997 |
equalsStockJoinMap.put("fofoId", fofoId);
|
| 998 |
currentStockMap = itemRepository
|
998 |
currentStockMap = itemRepository
|
| 999 |
.selectItems(CurrentInventorySnapshot.class, "id", "itemId", equalsMap, notEqualsMap,
|
999 |
.selectItems(CurrentInventorySnapshot.class, "id", "itemId", equalsMap, notEqualsMap,
|
| 1000 |
equalsStockJoinMap, notEqualsJoinMap, "availability")
|
1000 |
equalsStockJoinMap, notEqualsJoinMap, "availability")
|
| 1001 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> (int) x.getAggregateValue()));
|
1001 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> (int) x.getAggregateValue()));
|
| 1002 |
LOGGER.info("currentStock");
|
1002 |
LOGGER.info("currentStock");
|
| 1003 |
} else {
|
1003 |
} else {
|
| 1004 |
if (fofoId == 0) {
|
1004 |
if (fofoId == 0) {
|
| 1005 |
|
1005 |
|
| 1006 |
Map<String, Object> equalsStockJoinMap = new HashMap<>();
|
1006 |
Map<String, Object> equalsStockJoinMap = new HashMap<>();
|
| 1007 |
equalsStockJoinMap.put("fofoId", fofoId);
|
1007 |
equalsStockJoinMap.put("fofoId", fofoId);
|
| 1008 |
|
1008 |
|
| 1009 |
currentStockMap = itemRepository
|
1009 |
currentStockMap = itemRepository
|
| 1010 |
.selectItems(CurrentInventorySnapshot.class, "id", "itemId", equalsMap, notEqualsMap,
|
1010 |
.selectItems(CurrentInventorySnapshot.class, "id", "itemId", equalsMap, notEqualsMap,
|
| 1011 |
equalsStockJoinMap, notEqualsJoinMap, "availability")
|
1011 |
equalsStockJoinMap, notEqualsJoinMap, "availability")
|
| 1012 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> (int) x.getAggregateValue()));
|
1012 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> (int) x.getAggregateValue()));
|
| 1013 |
|
1013 |
|
| 1014 |
} else {
|
1014 |
} else {
|
| 1015 |
|
1015 |
|
| 1016 |
Map<String, Object> equalsStockJoinMap = new HashMap<>();
|
1016 |
Map<String, Object> equalsStockJoinMap = new HashMap<>();
|
| 1017 |
equalsStockJoinMap.put("fofoId", fofoId);
|
1017 |
equalsStockJoinMap.put("fofoId", fofoId);
|
| 1018 |
|
1018 |
|
| 1019 |
currentStockMap = itemRepository
|
1019 |
currentStockMap = itemRepository
|
| 1020 |
.selectItems(CurrentInventorySnapshot.class, "id", "itemId", equalsMap, notEqualsMap,
|
1020 |
.selectItems(CurrentInventorySnapshot.class, "id", "itemId", equalsMap, notEqualsMap,
|
| 1021 |
equalsStockJoinMap, notEqualsJoinMap, "availability")
|
1021 |
equalsStockJoinMap, notEqualsJoinMap, "availability")
|
| 1022 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> (int) x.getAggregateValue()));
|
1022 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> (int) x.getAggregateValue()));
|
| 1023 |
|
1023 |
|
| 1024 |
}
|
1024 |
}
|
| 1025 |
}
|
1025 |
}
|
| 1026 |
|
1026 |
|
| 1027 |
LOGGER.info("currentStock" + currentStockMap);
|
1027 |
LOGGER.info("currentStock" + currentStockMap);
|
| 1028 |
|
1028 |
|
| 1029 |
Map<Integer, Integer> itemsInTransit = null;
|
1029 |
Map<Integer, Integer> itemsInTransit = null;
|
| 1030 |
List<TagListing> tagListings = tagListingRepository.selectAll(true);
|
1030 |
List<TagListing> tagListings = tagListingRepository.selectAll(true);
|
| 1031 |
if (!isAdmin) {
|
1031 |
if (!isAdmin) {
|
| 1032 |
tagListings = new ArrayList<>(tagListings);
|
1032 |
tagListings = new ArrayList<>(tagListings);
|
| 1033 |
List<Order> inTransitOrders = orderRepository.selectPendingGrnOrder(fofoId,
|
1033 |
List<Order> inTransitOrders = orderRepository.selectPendingGrnOrder(fofoId,
|
| 1034 |
OrderRepository.validOrderStatusList);
|
1034 |
OrderRepository.validOrderStatusList);
|
| 1035 |
inTransitOrders = this.filterValidOrders(inTransitOrders);
|
1035 |
inTransitOrders = this.filterValidOrders(inTransitOrders);
|
| 1036 |
itemsInTransit = inTransitOrders.stream().collect(Collectors.groupingBy(x -> x.getLineItem().getItemId(),
|
1036 |
itemsInTransit = inTransitOrders.stream().collect(Collectors.groupingBy(x -> x.getLineItem().getItemId(),
|
| 1037 |
Collectors.summingInt(x -> x.getLineItem().getQuantity())));
|
1037 |
Collectors.summingInt(x -> x.getLineItem().getQuantity())));
|
| 1038 |
} else {
|
1038 |
} else {
|
| 1039 |
itemsInTransit = new HashMap<>();
|
1039 |
itemsInTransit = new HashMap<>();
|
| 1040 |
}
|
1040 |
}
|
| 1041 |
|
1041 |
|
| 1042 |
int totalPcs = 0;
|
1042 |
int totalPcs = 0;
|
| 1043 |
|
1043 |
|
| 1044 |
float totalAmount = 0;
|
1044 |
float totalAmount = 0;
|
| 1045 |
Map<Integer, CatalogListingModel> catalogListingMap = new HashMap<>();
|
1045 |
Map<Integer, CatalogListingModel> catalogListingMap = new HashMap<>();
|
| 1046 |
|
1046 |
|
| 1047 |
List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId())
|
1047 |
List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId())
|
| 1048 |
.collect(Collectors.toList());
|
1048 |
.collect(Collectors.toList());
|
| 1049 |
|
1049 |
|
| 1050 |
Map<Integer, FocusedModel> focusedModelMap = focusedModelRepository.selectAllByRegionIds(regionIds).stream()
|
1050 |
Map<Integer, FocusedModel> focusedModelMap = focusedModelRepository.selectAllByRegionIds(regionIds).stream()
|
| 1051 |
.collect(Collectors.toMap(FocusedModel::getCatalogId, Function.identity()));
|
1051 |
.collect(Collectors.toMap(FocusedModel::getCatalogId, Function.identity()));
|
| 1052 |
|
1052 |
|
| 1053 |
MonthlyPlanned monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId,
|
1053 |
MonthlyPlanned monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId,
|
| 1054 |
planMonthStart.minusMonths(1));
|
1054 |
planMonthStart.minusMonths(1));
|
| 1055 |
model.addAttribute("planningMonth", planMonthStart.minusMonths(1).getMonth());
|
1055 |
model.addAttribute("planningMonth", planMonthStart.minusMonths(1).getMonth());
|
| 1056 |
model.addAttribute("previousPlanningMonth", planMonthStart.minusMonths(1).getMonth());
|
1056 |
model.addAttribute("previousPlanningMonth", planMonthStart.minusMonths(1).getMonth());
|
| 1057 |
model.addAttribute("currentPlanningMonth", planMonthStart.getMonth());
|
1057 |
model.addAttribute("currentPlanningMonth", planMonthStart.getMonth());
|
| 1058 |
|
1058 |
|
| 1059 |
Map<Integer, Integer> plannedDetailMap = null;
|
1059 |
Map<Integer, Integer> plannedDetailMap = null;
|
| 1060 |
if (monthlyPlanned != null) {
|
1060 |
if (monthlyPlanned != null) {
|
| 1061 |
plannedDetailMap = plannedDetailRepository.selectByPlannedId(monthlyPlanned.getId()).stream()
|
1061 |
plannedDetailMap = plannedDetailRepository.selectByPlannedId(monthlyPlanned.getId()).stream()
|
| 1062 |
.collect(Collectors.toMap(x -> x.getCatalogId(), x -> x.getQuantity()));
|
1062 |
.collect(Collectors.toMap(x -> x.getCatalogId(), x -> x.getQuantity()));
|
| 1063 |
|
1063 |
|
| 1064 |
}
|
1064 |
}
|
| 1065 |
|
1065 |
|
| 1066 |
LOGGER.info("plannedDetailMap" + plannedDetailMap);
|
1066 |
LOGGER.info("plannedDetailMap" + plannedDetailMap);
|
| 1067 |
List<Integer> fofoOrderIds = fofoOrderRepository
|
1067 |
List<Integer> fofoOrderIds = fofoOrderRepository
|
| 1068 |
.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
|
1068 |
.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
|
| 1069 |
planMonthStart.minusMonths(1).atStartOfDay(), planMonthStart.atStartOfDay())
|
1069 |
planMonthStart.minusMonths(1).atStartOfDay(), planMonthStart.atStartOfDay())
|
| 1070 |
.stream().map(x -> x.getId()).collect(Collectors.toList());
|
1070 |
.stream().map(x -> x.getId()).collect(Collectors.toList());
|
| 1071 |
|
1071 |
|
| 1072 |
LOGGER.info("fofoOrderIds" + fofoOrderIds);
|
1072 |
LOGGER.info("fofoOrderIds" + fofoOrderIds);
|
| 1073 |
Map<String, Object> equalsJoinMap = new HashMap<>();
|
1073 |
Map<String, Object> equalsJoinMap = new HashMap<>();
|
| 1074 |
equalsJoinMap.put("orderId", fofoOrderIds);
|
1074 |
equalsJoinMap.put("orderId", fofoOrderIds);
|
| 1075 |
Map<Integer, Integer> lastMonthSaleMap = null;
|
1075 |
Map<Integer, Integer> lastMonthSaleMap = null;
|
| 1076 |
if (!fofoOrderIds.isEmpty()) {
|
1076 |
if (!fofoOrderIds.isEmpty()) {
|
| 1077 |
lastMonthSaleMap = itemRepository
|
1077 |
lastMonthSaleMap = itemRepository
|
| 1078 |
.selectItems(FofoOrderItem.class, "id", "itemId", equalsMap, notEqualsMap, equalsJoinMap,
|
1078 |
.selectItems(FofoOrderItem.class, "id", "itemId", equalsMap, notEqualsMap, equalsJoinMap,
|
| 1079 |
notEqualsJoinMap, "quantity")
|
1079 |
notEqualsJoinMap, "quantity")
|
| 1080 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> (int) x.getAggregateValue()));
|
1080 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> (int) x.getAggregateValue()));
|
| 1081 |
}
|
1081 |
}
|
| 1082 |
LOGGER.info("lastMonthSaleMap" + lastMonthSaleMap);
|
1082 |
LOGGER.info("lastMonthSaleMap" + lastMonthSaleMap);
|
| 1083 |
|
1083 |
|
| 1084 |
Map<Integer, TagListing> taglistingMap = tagListings.stream()
|
1084 |
Map<Integer, TagListing> taglistingMap = tagListings.stream()
|
| 1085 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
1085 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
| 1086 |
List<Item> items = itemRepository.selectByIds(taglistingMap.keySet());
|
1086 |
List<Item> items = itemRepository.selectByIds(taglistingMap.keySet());
|
| 1087 |
Map<Integer, List<Item>> catalogIdItemMap = items.stream().collect(
|
1087 |
Map<Integer, List<Item>> catalogIdItemMap = items.stream().collect(
|
| 1088 |
Collectors.groupingBy(x -> x.getCatalogItemId(), Collectors.mapping(y -> y, Collectors.toList())));
|
1088 |
Collectors.groupingBy(x -> x.getCatalogItemId(), Collectors.mapping(y -> y, Collectors.toList())));
|
| 1089 |
LOGGER.info("catalogIdItemMap");
|
1089 |
LOGGER.info("catalogIdItemMap");
|
| 1090 |
|
1090 |
|
| 1091 |
Map<String, Object> equalsItemJoinMap = new HashMap<>();
|
1091 |
Map<String, Object> equalsItemJoinMap = new HashMap<>();
|
| 1092 |
equalsItemJoinMap.put("active", 1);
|
1092 |
equalsItemJoinMap.put("active", 1);
|
| 1093 |
List<IntegerIdAggregateValue> tagListingCatalogIds = itemRepository.selectItems(TagListing.class, "id",
|
1093 |
List<IntegerIdAggregateValue> tagListingCatalogIds = itemRepository.selectItems(TagListing.class, "id",
|
| 1094 |
"itemId", equalsMap, notEqualsMap, equalsItemJoinMap, notEqualsJoinMap, "tagId");
|
1094 |
"itemId", equalsMap, notEqualsMap, equalsItemJoinMap, notEqualsJoinMap, "tagId");
|
| 1095 |
LOGGER.info("tagListingCatalogIds");
|
1095 |
LOGGER.info("tagListingCatalogIds");
|
| 1096 |
for (IntegerIdAggregateValue catalogIdAggregateValue : tagListingCatalogIds) {
|
1096 |
for (IntegerIdAggregateValue catalogIdAggregateValue : tagListingCatalogIds) {
|
| 1097 |
int catalogId = catalogIdAggregateValue.getCatalogId();
|
1097 |
int catalogId = catalogIdAggregateValue.getCatalogId();
|
| 1098 |
Item item = catalogIdItemMap.get(catalogId).get(0);
|
1098 |
Item item = catalogIdItemMap.get(catalogId).get(0);
|
| 1099 |
TagListing tagListing = taglistingMap.get(item.getId());
|
1099 |
TagListing tagListing = taglistingMap.get(item.getId());
|
| 1100 |
CatalogListingModel catalogListingModel = catalogListingMap.get(catalogId);
|
1100 |
CatalogListingModel catalogListingModel = catalogListingMap.get(catalogId);
|
| 1101 |
if (!catalogListingMap.containsKey(catalogId)) {
|
1101 |
if (!catalogListingMap.containsKey(catalogId)) {
|
| 1102 |
catalogListingModel = new CatalogListingModel();
|
1102 |
catalogListingModel = new CatalogListingModel();
|
| 1103 |
catalogListingModel.setCatalogId(catalogId);
|
1103 |
catalogListingModel.setCatalogId(catalogId);
|
| 1104 |
catalogListingModel.setDp(tagListing.getSellingPrice());
|
1104 |
catalogListingModel.setDp(tagListing.getSellingPrice());
|
| 1105 |
catalogListingModel.setMop(tagListing.getMop());
|
1105 |
catalogListingModel.setMop(tagListing.getMop());
|
| 1106 |
catalogListingModel.setItemDescription(item.getItemDescriptionNoColor());
|
1106 |
catalogListingModel.setItemDescription(item.getItemDescriptionNoColor());
|
| 1107 |
if (plannedDetailMap != null) {
|
1107 |
if (plannedDetailMap != null) {
|
| 1108 |
|
1108 |
|
| 1109 |
Integer quantity = plannedDetailMap.get(catalogId);
|
1109 |
Integer quantity = plannedDetailMap.get(catalogId);
|
| 1110 |
if (quantity != null) {
|
1110 |
if (quantity != null) {
|
| 1111 |
catalogListingModel.setAllocatedQuantity(quantity);
|
1111 |
catalogListingModel.setAllocatedQuantity(quantity);
|
| 1112 |
}
|
1112 |
}
|
| 1113 |
}
|
1113 |
}
|
| 1114 |
|
1114 |
|
| 1115 |
if (lastMonthSaleMap != null) {
|
1115 |
if (lastMonthSaleMap != null) {
|
| 1116 |
Integer lastMonthSale = lastMonthSaleMap.get(catalogId);
|
1116 |
Integer lastMonthSale = lastMonthSaleMap.get(catalogId);
|
| 1117 |
|
1117 |
|
| 1118 |
if (lastMonthSale != null) {
|
1118 |
if (lastMonthSale != null) {
|
| 1119 |
catalogListingModel.setLastMonthSaleMap(lastMonthSale);
|
1119 |
catalogListingModel.setLastMonthSaleMap(lastMonthSale);
|
| 1120 |
} else {
|
1120 |
} else {
|
| 1121 |
catalogListingModel.setLastMonthSaleMap(0);
|
1121 |
catalogListingModel.setLastMonthSaleMap(0);
|
| 1122 |
}
|
1122 |
}
|
| 1123 |
} else {
|
1123 |
} else {
|
| 1124 |
catalogListingModel.setLast15DaysSale(0);
|
1124 |
catalogListingModel.setLast15DaysSale(0);
|
| 1125 |
}
|
1125 |
}
|
| 1126 |
|
1126 |
|
| 1127 |
catalogListingModel.setBrand(item.getBrand());
|
1127 |
catalogListingModel.setBrand(item.getBrand());
|
| 1128 |
if (item.getCategoryId() == 10006) {
|
1128 |
if (item.getCategoryId() == 10006) {
|
| 1129 |
catalogListingModel.setCategoryId(item.getCategoryId());
|
1129 |
catalogListingModel.setCategoryId(item.getCategoryId());
|
| 1130 |
}
|
1130 |
}
|
| 1131 |
|
1131 |
|
| 1132 |
FocusedModel fm = focusedModelMap.get(catalogId);
|
1132 |
FocusedModel fm = focusedModelMap.get(catalogId);
|
| 1133 |
if (fm != null) {
|
1133 |
if (fm != null) {
|
| 1134 |
catalogListingModel.setRecommendedQty(fm.getRecommendedQty());
|
1134 |
catalogListingModel.setRecommendedQty(fm.getRecommendedQty());
|
| 1135 |
catalogListingModel.setMinimumQty(fm.getMinimumQty());
|
1135 |
catalogListingModel.setMinimumQty(fm.getMinimumQty());
|
| 1136 |
|
1136 |
|
| 1137 |
} else {
|
1137 |
} else {
|
| 1138 |
catalogListingModel.setRecommendedQty(0);
|
1138 |
catalogListingModel.setRecommendedQty(0);
|
| 1139 |
catalogListingModel.setMinimumQty(0);
|
1139 |
catalogListingModel.setMinimumQty(0);
|
| 1140 |
}
|
1140 |
}
|
| 1141 |
|
1141 |
|
| 1142 |
catalogListingMap.put(catalogId, catalogListingModel);
|
1142 |
catalogListingMap.put(catalogId, catalogListingModel);
|
| 1143 |
|
1143 |
|
| 1144 |
}
|
1144 |
}
|
| 1145 |
int itemAvailability = 0;
|
1145 |
int itemAvailability = 0;
|
| 1146 |
if (currentStockMap != null) {
|
1146 |
if (currentStockMap != null) {
|
| 1147 |
Integer qty = currentStockMap.get(catalogId);
|
1147 |
Integer qty = currentStockMap.get(catalogId);
|
| 1148 |
itemAvailability = qty == null ? 0 : qty;
|
1148 |
itemAvailability = qty == null ? 0 : qty;
|
| 1149 |
catalogListingModel.setStockInHand(itemAvailability);
|
1149 |
catalogListingModel.setStockInHand(itemAvailability);
|
| 1150 |
} else {
|
1150 |
} else {
|
| 1151 |
catalogListingModel.setStockInHand(0);
|
1151 |
catalogListingModel.setStockInHand(0);
|
| 1152 |
}
|
1152 |
}
|
| 1153 |
Integer inTransitQuantity = itemsInTransit.get(item.getId());
|
1153 |
Integer inTransitQuantity = itemsInTransit.get(item.getId());
|
| 1154 |
int inTransitQty = (inTransitQuantity == null ? 0 : inTransitQuantity);
|
1154 |
int inTransitQty = (inTransitQuantity == null ? 0 : inTransitQuantity);
|
| 1155 |
catalogListingModel.setInTransitQuantity(catalogListingModel.getInTransitQuantity() + inTransitQty);
|
1155 |
catalogListingModel.setInTransitQuantity(catalogListingModel.getInTransitQuantity() + inTransitQty);
|
| 1156 |
|
1156 |
|
| 1157 |
}
|
1157 |
}
|
| 1158 |
|
1158 |
|
| 1159 |
Map<Integer, CustomRetailer> customRetailersMap = retailerService.getFofoRetailers(false);
|
1159 |
Map<Integer, CustomRetailer> customRetailersMap = retailerService.getFofoRetailers(false);
|
| 1160 |
if (fofoId > 0) {
|
1160 |
if (fofoId > 0) {
|
| 1161 |
CustomRetailer customRetailer = customRetailersMap.get(fofoId);
|
1161 |
CustomRetailer customRetailer = customRetailersMap.get(fofoId);
|
| 1162 |
model.addAttribute("retailerName",
|
1162 |
model.addAttribute("retailerName",
|
| 1163 |
customRetailer.getBusinessName() + "-" + customRetailer.getAddress().getCity());
|
1163 |
customRetailer.getBusinessName() + "-" + customRetailer.getAddress().getCity());
|
| 1164 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(fofoId);
|
1164 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(fofoId);
|
| 1165 |
model.addAttribute("retailerId", customRetailer.getPartnerId());
|
1165 |
model.addAttribute("retailerId", customRetailer.getPartnerId());
|
| 1166 |
model.addAttribute("counterSize", fs.getCounterSize().toString());
|
1166 |
model.addAttribute("counterSize", fs.getCounterSize().toString());
|
| 1167 |
} else {
|
1167 |
} else {
|
| 1168 |
model.addAttribute("counterSize", counterSize.toString());
|
1168 |
model.addAttribute("counterSize", counterSize.toString());
|
| 1169 |
}
|
1169 |
}
|
| 1170 |
String customRetailers = JSONObject.valueToString(customRetailersMap.values());
|
1170 |
String customRetailers = JSONObject.valueToString(customRetailersMap.values());
|
| 1171 |
|
1171 |
|
| 1172 |
List<CatalogListingModel> catalogModelList = new ArrayList<>(catalogListingMap.values());
|
1172 |
List<CatalogListingModel> catalogModelList = new ArrayList<>(catalogListingMap.values());
|
| 1173 |
|
1173 |
|
| 1174 |
Comparator<CatalogListingModel> firstCmp = Comparator.comparing(CatalogListingModel::getMinimumQty,
|
1174 |
Comparator<CatalogListingModel> firstCmp = Comparator.comparing(CatalogListingModel::getMinimumQty,
|
| 1175 |
Comparator.reverseOrder());
|
1175 |
Comparator.reverseOrder());
|
| 1176 |
LOGGER.info("monthlyPlanned" + monthlyPlanned);
|
1176 |
LOGGER.info("monthlyPlanned" + monthlyPlanned);
|
| 1177 |
model.addAttribute("catalogTagListings",
|
1177 |
model.addAttribute("catalogTagListings",
|
| 1178 |
catalogModelList.stream().sorted(firstCmp).collect(Collectors.toList()));
|
1178 |
catalogModelList.stream().sorted(firstCmp).collect(Collectors.toList()));
|
| 1179 |
model.addAttribute("isAdmin", roleManager.isAdmin(roleIds));
|
1179 |
model.addAttribute("isAdmin", roleManager.isAdmin(roleIds));
|
| 1180 |
model.addAttribute("previousMonth", true);
|
1180 |
model.addAttribute("previousMonth", true);
|
| 1181 |
model.addAttribute("freezed", true);
|
1181 |
model.addAttribute("freezed", true);
|
| 1182 |
model.addAttribute("brandStockPrices", this.getBrandStockPrices(loginDetails.getFofoId()));
|
1182 |
model.addAttribute("brandStockPrices", this.getBrandStockPrices(loginDetails.getFofoId()));
|
| 1183 |
model.addAttribute("customRetailers", customRetailers);
|
1183 |
model.addAttribute("customRetailers", customRetailers);
|
| 1184 |
model.addAttribute("totalAmount", totalAmount);
|
1184 |
model.addAttribute("totalAmount", totalAmount);
|
| 1185 |
model.addAttribute("monthlyPlanned", monthlyPlanned);
|
1185 |
model.addAttribute("monthlyPlanned", monthlyPlanned);
|
| 1186 |
model.addAttribute("totalPcs", totalPcs);
|
1186 |
model.addAttribute("totalPcs", totalPcs);
|
| 1187 |
return "open-indent";
|
1187 |
return "open-indent";
|
| 1188 |
|
1188 |
|
| 1189 |
}
|
1189 |
}
|
| 1190 |
|
1190 |
|
| 1191 |
private Map<Integer, Item> getItemByCatalogId(List<FocusedModel> focusedModels) {
|
1191 |
private Map<Integer, Item> getItemByCatalogId(List<FocusedModel> focusedModels) {
|
| 1192 |
Map<Integer, Item> itemMap = new HashMap<>();
|
1192 |
Map<Integer, Item> itemMap = new HashMap<>();
|
| 1193 |
for (FocusedModel focusedModel : focusedModels) {
|
1193 |
for (FocusedModel focusedModel : focusedModels) {
|
| 1194 |
List<Item> items = itemRepository.selectAllByCatalogItemId(focusedModel.getCatalogId());
|
1194 |
List<Item> items = itemRepository.selectAllByCatalogItemId(focusedModel.getCatalogId());
|
| 1195 |
itemMap.put(items.get(0).getCatalogItemId(), items.get(0));
|
1195 |
itemMap.put(items.get(0).getCatalogItemId(), items.get(0));
|
| 1196 |
}
|
1196 |
}
|
| 1197 |
|
1197 |
|
| 1198 |
return itemMap;
|
1198 |
return itemMap;
|
| 1199 |
}
|
1199 |
}
|
| 1200 |
|
1200 |
|
| 1201 |
private Map<Integer, Region> getRegionByRegionId(List<FocusedModel> focusedModels) {
|
1201 |
private Map<Integer, Region> getRegionByRegionId(List<FocusedModel> focusedModels) {
|
| 1202 |
Map<Integer, Region> regionMap = new HashMap<>();
|
1202 |
Map<Integer, Region> regionMap = new HashMap<>();
|
| 1203 |
for (FocusedModel focusedModel : focusedModels) {
|
1203 |
for (FocusedModel focusedModel : focusedModels) {
|
| 1204 |
Region region = regionRepository.selectById(focusedModel.getRegionId());
|
1204 |
Region region = regionRepository.selectById(focusedModel.getRegionId());
|
| 1205 |
regionMap.put(region.getId(), region);
|
1205 |
regionMap.put(region.getId(), region);
|
| 1206 |
}
|
1206 |
}
|
| 1207 |
|
1207 |
|
| 1208 |
return regionMap;
|
1208 |
return regionMap;
|
| 1209 |
}
|
1209 |
}
|
| 1210 |
|
1210 |
|
| 1211 |
@RequestMapping(value = "/getFocusedModel", method = RequestMethod.GET)
|
1211 |
@RequestMapping(value = "/getFocusedModel", method = RequestMethod.GET)
|
| 1212 |
public String getFocusedModel(HttpServletRequest request,
|
1212 |
public String getFocusedModel(HttpServletRequest request,
|
| 1213 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
1213 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 1214 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
1214 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
| 1215 |
throws ProfitMandiBusinessException {
|
1215 |
throws ProfitMandiBusinessException {
|
| 1216 |
|
1216 |
|
| 1217 |
long size = 0;
|
1217 |
long size = 0;
|
| 1218 |
List<FocusedModel> focusedModels = focusedModelRepository.selectAll(offset, limit);
|
1218 |
List<FocusedModel> focusedModels = focusedModelRepository.selectAll(offset, limit);
|
| 1219 |
|
1219 |
|
| 1220 |
size = focusedModelRepository.selectAllCount();
|
1220 |
size = focusedModelRepository.selectAllCount();
|
| 1221 |
if (!focusedModels.isEmpty()) {
|
1221 |
if (!focusedModels.isEmpty()) {
|
| 1222 |
Map<Integer, Item> itemMap = this.getItemByCatalogId(focusedModels);
|
1222 |
Map<Integer, Item> itemMap = this.getItemByCatalogId(focusedModels);
|
| 1223 |
Map<Integer, Region> regionMap = this.getRegionByRegionId(focusedModels);
|
1223 |
Map<Integer, Region> regionMap = this.getRegionByRegionId(focusedModels);
|
| 1224 |
|
1224 |
|
| 1225 |
LOGGER.info("regionMap" + regionMap);
|
1225 |
LOGGER.info("regionMap" + regionMap);
|
| 1226 |
model.addAttribute("focusedModels", focusedModels);
|
1226 |
model.addAttribute("focusedModels", focusedModels);
|
| 1227 |
model.addAttribute("itemMap", itemMap);
|
1227 |
model.addAttribute("itemMap", itemMap);
|
| 1228 |
model.addAttribute("regionMap", regionMap);
|
1228 |
model.addAttribute("regionMap", regionMap);
|
| 1229 |
model.addAttribute("start", offset + 1);
|
1229 |
model.addAttribute("start", offset + 1);
|
| 1230 |
model.addAttribute("size", size);
|
1230 |
model.addAttribute("size", size);
|
| 1231 |
model.addAttribute("url", "/getPaginatedFocusedModel");
|
1231 |
model.addAttribute("url", "/getPaginatedFocusedModel");
|
| 1232 |
|
1232 |
|
| 1233 |
if (focusedModels.size() < limit) {
|
1233 |
if (focusedModels.size() < limit) {
|
| 1234 |
model.addAttribute("end", offset + focusedModels.size());
|
1234 |
model.addAttribute("end", offset + focusedModels.size());
|
| 1235 |
} else {
|
1235 |
} else {
|
| 1236 |
model.addAttribute("end", offset + limit);
|
1236 |
model.addAttribute("end", offset + limit);
|
| 1237 |
}
|
1237 |
}
|
| 1238 |
} else {
|
1238 |
} else {
|
| 1239 |
|
1239 |
|
| 1240 |
model.addAttribute("walletRequest", focusedModels);
|
1240 |
model.addAttribute("walletRequest", focusedModels);
|
| 1241 |
model.addAttribute("size", size);
|
1241 |
model.addAttribute("size", size);
|
| 1242 |
|
1242 |
|
| 1243 |
}
|
1243 |
}
|
| 1244 |
|
1244 |
|
| 1245 |
List<Region> regions = regionRepository.selectAll();
|
1245 |
List<Region> regions = regionRepository.selectAll();
|
| 1246 |
|
1246 |
|
| 1247 |
model.addAttribute("regions", regions);
|
1247 |
model.addAttribute("regions", regions);
|
| 1248 |
|
1248 |
|
| 1249 |
return "focused_model";
|
1249 |
return "focused_model";
|
| 1250 |
}
|
1250 |
}
|
| 1251 |
|
1251 |
|
| 1252 |
@RequestMapping(value = "/getPaginatedFocusedModel", method = RequestMethod.GET)
|
1252 |
@RequestMapping(value = "/getPaginatedFocusedModel", method = RequestMethod.GET)
|
| 1253 |
public String getPaginatedFocusedModel(HttpServletRequest request,
|
1253 |
public String getPaginatedFocusedModel(HttpServletRequest request,
|
| 1254 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
1254 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 1255 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
1255 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
| 1256 |
throws ProfitMandiBusinessException {
|
1256 |
throws ProfitMandiBusinessException {
|
| 1257 |
LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
|
1257 |
LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
|
| 1258 |
List<FocusedModel> focusedModels = focusedModelRepository.selectAll(offset, limit);
|
1258 |
List<FocusedModel> focusedModels = focusedModelRepository.selectAll(offset, limit);
|
| 1259 |
|
1259 |
|
| 1260 |
if (!focusedModels.isEmpty()) {
|
1260 |
if (!focusedModels.isEmpty()) {
|
| 1261 |
Map<Integer, Item> itemMap = this.getItemByCatalogId(focusedModels);
|
1261 |
Map<Integer, Item> itemMap = this.getItemByCatalogId(focusedModels);
|
| 1262 |
Map<Integer, Region> regionMap = this.getRegionByRegionId(focusedModels);
|
1262 |
Map<Integer, Region> regionMap = this.getRegionByRegionId(focusedModels);
|
| 1263 |
model.addAttribute("focusedModels", focusedModels);
|
1263 |
model.addAttribute("focusedModels", focusedModels);
|
| 1264 |
model.addAttribute("itemMap", itemMap);
|
1264 |
model.addAttribute("itemMap", itemMap);
|
| 1265 |
model.addAttribute("regionMap", regionMap);
|
1265 |
model.addAttribute("regionMap", regionMap);
|
| 1266 |
model.addAttribute("url", "/getPaginatedFocusedModel");
|
1266 |
model.addAttribute("url", "/getPaginatedFocusedModel");
|
| 1267 |
} else {
|
1267 |
} else {
|
| 1268 |
model.addAttribute("focusedModels", focusedModels);
|
1268 |
model.addAttribute("focusedModels", focusedModels);
|
| 1269 |
|
1269 |
|
| 1270 |
}
|
1270 |
}
|
| 1271 |
|
1271 |
|
| 1272 |
List<Region> regions = regionRepository.selectAll();
|
1272 |
List<Region> regions = regionRepository.selectAll();
|
| 1273 |
|
1273 |
|
| 1274 |
model.addAttribute("regions", regions);
|
1274 |
model.addAttribute("regions", regions);
|
| 1275 |
return "focused-model-paginated";
|
1275 |
return "focused-model-paginated";
|
| 1276 |
}
|
1276 |
}
|
| 1277 |
|
1277 |
|
| 1278 |
private List<BrandStockPrice> getBrandStockPrices(int fofoId) throws Exception {
|
1278 |
private List<BrandStockPrice> getBrandStockPrices(int fofoId) throws Exception {
|
| 1279 |
Map<String, BrandStockPrice> brandStockPricesMap = inventoryService.getBrandWiseStockValue(fofoId);
|
1279 |
Map<String, BrandStockPrice> brandStockPricesMap = inventoryService.getBrandWiseStockValue(fofoId);
|
| 1280 |
|
1280 |
|
| 1281 |
List<DBObject> mobileBrands = mongoClient.getMongoBrands(fofoId, "", 3);
|
1281 |
List<DBObject> mobileBrands = mongoClient.getMongoBrands(fofoId, "", 3);
|
| 1282 |
List<BrandStockPrice> brandStockPrices = new ArrayList<>();
|
1282 |
List<BrandStockPrice> brandStockPrices = new ArrayList<>();
|
| 1283 |
|
1283 |
|
| 1284 |
mobileBrands.stream().forEach(x -> {
|
1284 |
mobileBrands.stream().forEach(x -> {
|
| 1285 |
String brand = (String) x.get("name");
|
1285 |
String brand = (String) x.get("name");
|
| 1286 |
if (brandStockPricesMap.containsKey(brand)) {
|
1286 |
if (brandStockPricesMap.containsKey(brand)) {
|
| 1287 |
BrandStockPrice brandStockPrice = brandStockPricesMap.get(brand);
|
1287 |
BrandStockPrice brandStockPrice = brandStockPricesMap.get(brand);
|
| 1288 |
brandStockPrice.setBrandUrl((String) x.get("url"));
|
1288 |
brandStockPrice.setBrandUrl((String) x.get("url"));
|
| 1289 |
brandStockPrice.setRank(((Double) x.get("rank")).intValue());
|
1289 |
brandStockPrice.setRank(((Double) x.get("rank")).intValue());
|
| 1290 |
brandStockPrices.add(brandStockPrice);
|
1290 |
brandStockPrices.add(brandStockPrice);
|
| 1291 |
}
|
1291 |
}
|
| 1292 |
});
|
1292 |
});
|
| 1293 |
|
1293 |
|
| 1294 |
return brandStockPrices.stream().filter(x -> x.getTotalQty() > 0).sorted((x, y) -> x.getRank() - y.getRank())
|
1294 |
return brandStockPrices.stream().filter(x -> x.getTotalQty() > 0).sorted((x, y) -> x.getRank() - y.getRank())
|
| 1295 |
.collect(Collectors.toList());
|
1295 |
.collect(Collectors.toList());
|
| 1296 |
}
|
1296 |
}
|
| 1297 |
|
1297 |
|
| 1298 |
@RequestMapping(value = "/getPartnerAllocation")
|
1298 |
@RequestMapping(value = "/getPartnerAllocation")
|
| 1299 |
public String getPartnerAllocation(HttpServletRequest request, Model model) throws Exception {
|
1299 |
public String getPartnerAllocation(HttpServletRequest request, Model model) throws Exception {
|
| 1300 |
|
1300 |
|
| 1301 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
1301 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 1302 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
1302 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
| 1303 |
|
1303 |
|
| 1304 |
Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
|
1304 |
Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
|
| 1305 |
|
1305 |
|
| 1306 |
List<Integer> fofoIds = pp.get(authUser.getId());
|
1306 |
List<Integer> fofoIds = pp.get(authUser.getId());
|
| 1307 |
|
1307 |
|
| 1308 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
1308 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
| 1309 |
Map<Integer, CustomRetailer> crm = fofoIds.stream().map(x -> customRetailerMap.get(x)).filter(x -> x != null)
|
1309 |
Map<Integer, CustomRetailer> crm = fofoIds.stream().map(x -> customRetailerMap.get(x)).filter(x -> x != null)
|
| 1310 |
.collect(Collectors.toList()).stream().collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
1310 |
.collect(Collectors.toList()).stream().collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
| 1311 |
Map<Integer, FofoStore> fofoStoreMap = fofoStoreRepository.selectByRetailerIds(fofoIds).stream()
|
1311 |
Map<Integer, FofoStore> fofoStoreMap = fofoStoreRepository.selectByRetailerIds(fofoIds).stream()
|
| 1312 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
1312 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 1313 |
|
1313 |
|
| 1314 |
model.addAttribute("customRetailersMap", crm);
|
1314 |
model.addAttribute("customRetailersMap", crm);
|
| 1315 |
model.addAttribute("fofoStoreMap", fofoStoreMap);
|
1315 |
model.addAttribute("fofoStoreMap", fofoStoreMap);
|
| 1316 |
return "partners_allocation";
|
1316 |
return "partners_allocation";
|
| 1317 |
|
1317 |
|
| 1318 |
}
|
1318 |
}
|
| 1319 |
|
1319 |
|
| 1320 |
@RequestMapping(value = "/partnerPendingOrder")
|
1320 |
@RequestMapping(value = "/partnerPendingOrder")
|
| 1321 |
public String partnerPendingOrder(HttpServletRequest request, Model model) throws Exception {
|
1321 |
public String partnerPendingOrder(HttpServletRequest request, Model model) throws Exception {
|
| 1322 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
1322 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 1323 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
1323 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
| 1324 |
|
1324 |
|
| 1325 |
Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
|
1325 |
Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
|
| 1326 |
|
1326 |
|
| 1327 |
List<Integer> fofoIds = pp.get(authUser.getId());
|
1327 |
List<Integer> fofoIds = pp.get(authUser.getId());
|
| 1328 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
1328 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
| 1329 |
Map<Integer, CustomRetailer> crm = fofoIds.stream().map(x -> customRetailerMap.get(x)).filter(x -> x != null)
|
1329 |
Map<Integer, CustomRetailer> crm = fofoIds.stream().map(x -> customRetailerMap.get(x)).filter(x -> x != null)
|
| 1330 |
.collect(Collectors.toList()).stream().collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
1330 |
.collect(Collectors.toList()).stream().collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
| 1331 |
|
1331 |
|
| 1332 |
model.addAttribute("customRetailersMap", crm);
|
1332 |
model.addAttribute("customRetailersMap", crm);
|
| 1333 |
|
1333 |
|
| 1334 |
return "partner-po";
|
1334 |
return "partner-po";
|
| 1335 |
|
1335 |
|
| 1336 |
}
|
1336 |
}
|
| 1337 |
|
1337 |
|
| 1338 |
@RequestMapping(value = "/focusedModel", method = RequestMethod.POST)
|
1338 |
@RequestMapping(value = "/focusedModel", method = RequestMethod.POST)
|
| 1339 |
public String focusedModel(HttpServletRequest request, @RequestParam int catalogId,
|
1339 |
public String focusedModel(HttpServletRequest request, @RequestParam int catalogId,
|
| 1340 |
@RequestParam(name = "recommended", defaultValue = "0") int recommended,
|
1340 |
@RequestParam(name = "recommended", defaultValue = "0") int recommended,
|
| 1341 |
@RequestParam(name = "minimumQty", defaultValue = "0") int minimumQty,
|
1341 |
@RequestParam(name = "minimumQty", defaultValue = "0") int minimumQty,
|
| 1342 |
@RequestParam(name = "obvrecommend", defaultValue = "0") int obvrecommend,
|
1342 |
@RequestParam(name = "obvrecommend", defaultValue = "0") int obvrecommend,
|
| 1343 |
@RequestParam(name = "obvminimum", defaultValue = "0") int obvminimum, @RequestParam int regionId,
|
1343 |
@RequestParam(name = "obvminimum", defaultValue = "0") int obvminimum, @RequestParam int regionId,
|
| 1344 |
Model model) throws ProfitMandiBusinessException {
|
1344 |
Model model) throws ProfitMandiBusinessException {
|
| 1345 |
|
1345 |
|
| 1346 |
FocusedModel fm = new FocusedModel();
|
1346 |
FocusedModel fm = new FocusedModel();
|
| 1347 |
fm.setCatalogId(catalogId);
|
1347 |
fm.setCatalogId(catalogId);
|
| 1348 |
fm.setMinimumQty(minimumQty);
|
1348 |
fm.setMinimumQty(minimumQty);
|
| 1349 |
fm.setRecommendedQty(recommended);
|
1349 |
fm.setRecommendedQty(recommended);
|
| 1350 |
fm.setRegionId(regionId);
|
1350 |
fm.setRegionId(regionId);
|
| 1351 |
fm.setObsRecommendedQty(obvrecommend);
|
1351 |
fm.setObsRecommendedQty(obvrecommend);
|
| 1352 |
fm.setObsMinimumQty(obvminimum);
|
1352 |
fm.setObsMinimumQty(obvminimum);
|
| 1353 |
fm.setCreatedTimestamp(LocalDateTime.now());
|
1353 |
fm.setCreatedTimestamp(LocalDateTime.now());
|
| 1354 |
focusedModelRepository.persist(fm);
|
1354 |
focusedModelRepository.persist(fm);
|
| 1355 |
return "focused_model";
|
1355 |
return "focused_model";
|
| 1356 |
}
|
1356 |
}
|
| 1357 |
|
1357 |
|
| 1358 |
@RequestMapping(value = "/removeItem", method = RequestMethod.DELETE)
|
1358 |
@RequestMapping(value = "/removeItem", method = RequestMethod.DELETE)
|
| 1359 |
public String removeFocusedModelItem(HttpServletRequest request,
|
1359 |
public String removeFocusedModelItem(HttpServletRequest request,
|
| 1360 |
@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
1360 |
@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
| 1361 |
|
1361 |
|
| 1362 |
focusedModelRepository.deleteById(id);
|
1362 |
focusedModelRepository.deleteById(id);
|
| 1363 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
1363 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 1364 |
return "response";
|
1364 |
return "response";
|
| 1365 |
}
|
1365 |
}
|
| 1366 |
|
1366 |
|
| 1367 |
@RequestMapping(value = "/getPartnerloadContent")
|
1367 |
@RequestMapping(value = "/getPartnerloadContent")
|
| 1368 |
public String getPartnerloadContent(HttpServletRequest request, Model model,
|
1368 |
public String getPartnerloadContent(HttpServletRequest request, Model model,
|
| 1369 |
@RequestParam(required = false, defaultValue = "0") int fofoId,
|
1369 |
@RequestParam(required = false, defaultValue = "0") int fofoId,
|
| 1370 |
@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
|
1370 |
@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
|
| 1371 |
|
1371 |
|
| 1372 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
1372 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 1373 |
Set<Integer> roleIds = loginDetails.getRoleIds();
|
1373 |
Set<Integer> roleIds = loginDetails.getRoleIds();
|
| 1374 |
LOGGER.info("Counter size is {}", counterSize);
|
1374 |
LOGGER.info("Counter size is {}", counterSize);
|
| 1375 |
LOGGER.info("Fofo Id is {}", fofoId);
|
1375 |
LOGGER.info("Fofo Id is {}", fofoId);
|
| 1376 |
boolean isAdmin = roleManager.isAdmin(roleIds);
|
1376 |
boolean isAdmin = roleManager.isAdmin(roleIds);
|
| 1377 |
|
1377 |
|
| 1378 |
List<String> brands = mongoClient.getMongoBrands(fofoId, null, 3).stream().map(x -> (String) x.get("name"))
|
1378 |
List<String> brands = mongoClient.getMongoBrands(fofoId, null, 3).stream().map(x -> (String) x.get("name"))
|
| 1379 |
.collect(Collectors.toList());
|
1379 |
.collect(Collectors.toList());
|
| 1380 |
|
1380 |
|
| 1381 |
Map<String, Object> equalsMap = new HashMap<>();
|
1381 |
Map<String, Object> equalsMap = new HashMap<>();
|
| 1382 |
equalsMap.put("categoryId", 10006);
|
1382 |
equalsMap.put("categoryId", 10006);
|
| 1383 |
equalsMap.put("brand", brands);
|
1383 |
equalsMap.put("brand", brands);
|
| 1384 |
Map<String, List<?>> notEqualsMap = new HashMap<>();
|
1384 |
Map<String, List<?>> notEqualsMap = new HashMap<>();
|
| 1385 |
|
1385 |
|
| 1386 |
Map<String, List<?>> notEqualsJoinMap = new HashMap<>();
|
1386 |
Map<String, List<?>> notEqualsJoinMap = new HashMap<>();
|
| 1387 |
Map<Integer, Integer> currentStockMap;
|
1387 |
Map<Integer, Integer> currentStockMap;
|
| 1388 |
|
1388 |
|
| 1389 |
if (!isAdmin && fofoId == 0) {
|
1389 |
if (!isAdmin && fofoId == 0) {
|
| 1390 |
fofoId = cookiesProcessor.getCookiesObject(request).getFofoId();
|
1390 |
fofoId = cookiesProcessor.getCookiesObject(request).getFofoId();
|
| 1391 |
Map<String, Object> equalsStockJoinMap = new HashMap<>();
|
1391 |
Map<String, Object> equalsStockJoinMap = new HashMap<>();
|
| 1392 |
equalsStockJoinMap.put("fofoId", fofoId);
|
1392 |
equalsStockJoinMap.put("fofoId", fofoId);
|
| 1393 |
currentStockMap = itemRepository
|
1393 |
currentStockMap = itemRepository
|
| 1394 |
.selectItems(CurrentInventorySnapshot.class, "id", "itemId", equalsMap, notEqualsMap,
|
1394 |
.selectItems(CurrentInventorySnapshot.class, "id", "itemId", equalsMap, notEqualsMap,
|
| 1395 |
equalsStockJoinMap, notEqualsJoinMap, "availability")
|
1395 |
equalsStockJoinMap, notEqualsJoinMap, "availability")
|
| 1396 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> (int) x.getAggregateValue()));
|
1396 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> (int) x.getAggregateValue()));
|
| 1397 |
LOGGER.info("currentStock");
|
1397 |
LOGGER.info("currentStock");
|
| 1398 |
} else {
|
1398 |
} else {
|
| 1399 |
if (fofoId == 0) {
|
1399 |
if (fofoId == 0) {
|
| 1400 |
|
1400 |
|
| 1401 |
Map<String, Object> equalsStockJoinMap = new HashMap<>();
|
1401 |
Map<String, Object> equalsStockJoinMap = new HashMap<>();
|
| 1402 |
equalsStockJoinMap.put("fofoId", fofoId);
|
1402 |
equalsStockJoinMap.put("fofoId", fofoId);
|
| 1403 |
|
1403 |
|
| 1404 |
currentStockMap = itemRepository
|
1404 |
currentStockMap = itemRepository
|
| 1405 |
.selectItems(CurrentInventorySnapshot.class, "id", "itemId", equalsMap, notEqualsMap,
|
1405 |
.selectItems(CurrentInventorySnapshot.class, "id", "itemId", equalsMap, notEqualsMap,
|
| 1406 |
equalsStockJoinMap, notEqualsJoinMap, "availability")
|
1406 |
equalsStockJoinMap, notEqualsJoinMap, "availability")
|
| 1407 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> (int) x.getAggregateValue()));
|
1407 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> (int) x.getAggregateValue()));
|
| 1408 |
|
1408 |
|
| 1409 |
} else {
|
1409 |
} else {
|
| 1410 |
|
1410 |
|
| 1411 |
Map<String, Object> equalsStockJoinMap = new HashMap<>();
|
1411 |
Map<String, Object> equalsStockJoinMap = new HashMap<>();
|
| 1412 |
equalsStockJoinMap.put("fofoId", fofoId);
|
1412 |
equalsStockJoinMap.put("fofoId", fofoId);
|
| 1413 |
|
1413 |
|
| 1414 |
currentStockMap = itemRepository
|
1414 |
currentStockMap = itemRepository
|
| 1415 |
.selectItems(CurrentInventorySnapshot.class, "id", "itemId", equalsMap, notEqualsMap,
|
1415 |
.selectItems(CurrentInventorySnapshot.class, "id", "itemId", equalsMap, notEqualsMap,
|
| 1416 |
equalsStockJoinMap, notEqualsJoinMap, "availability")
|
1416 |
equalsStockJoinMap, notEqualsJoinMap, "availability")
|
| 1417 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> (int) x.getAggregateValue()));
|
1417 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> (int) x.getAggregateValue()));
|
| 1418 |
|
1418 |
|
| 1419 |
}
|
1419 |
}
|
| 1420 |
}
|
1420 |
}
|
| 1421 |
|
1421 |
|
| 1422 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
1422 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
| 1423 |
LOGGER.info("currentStock" + currentStockMap);
|
1423 |
LOGGER.info("currentStock" + currentStockMap);
|
| 1424 |
|
1424 |
|
| 1425 |
Map<Integer, Integer> itemsInTransit = null;
|
1425 |
Map<Integer, Integer> itemsInTransit = null;
|
| 1426 |
List<TagListing> tagListings = tagListingRepository.selectAll(true);
|
1426 |
List<TagListing> tagListings = tagListingRepository.selectAll(true);
|
| 1427 |
if (!isAdmin) {
|
1427 |
if (!isAdmin) {
|
| 1428 |
tagListings = new ArrayList<>(tagListings);
|
1428 |
tagListings = new ArrayList<>(tagListings);
|
| 1429 |
List<Order> inTransitOrders = orderRepository.selectPendingGrnOrder(fofoId,
|
1429 |
List<Order> inTransitOrders = orderRepository.selectPendingGrnOrder(fofoId,
|
| 1430 |
OrderRepository.validOrderStatusList);
|
1430 |
OrderRepository.validOrderStatusList);
|
| 1431 |
inTransitOrders = this.filterValidOrders(inTransitOrders);
|
1431 |
inTransitOrders = this.filterValidOrders(inTransitOrders);
|
| 1432 |
itemsInTransit = inTransitOrders.stream().collect(Collectors.groupingBy(x -> x.getLineItem().getItemId(),
|
1432 |
itemsInTransit = inTransitOrders.stream().collect(Collectors.groupingBy(x -> x.getLineItem().getItemId(),
|
| 1433 |
Collectors.summingInt(x -> x.getLineItem().getQuantity())));
|
1433 |
Collectors.summingInt(x -> x.getLineItem().getQuantity())));
|
| 1434 |
} else {
|
1434 |
} else {
|
| 1435 |
itemsInTransit = new HashMap<>();
|
1435 |
itemsInTransit = new HashMap<>();
|
| 1436 |
}
|
1436 |
}
|
| 1437 |
|
1437 |
|
| 1438 |
int totalPcs = 0;
|
1438 |
int totalPcs = 0;
|
| 1439 |
|
1439 |
|
| 1440 |
float totalAmount = 0;
|
1440 |
float totalAmount = 0;
|
| 1441 |
Map<Integer, CatalogListingModel> catalogListingMap = new HashMap<>();
|
1441 |
Map<Integer, CatalogListingModel> catalogListingMap = new HashMap<>();
|
| 1442 |
|
1442 |
|
| 1443 |
List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId())
|
1443 |
List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId())
|
| 1444 |
.collect(Collectors.toList());
|
1444 |
.collect(Collectors.toList());
|
| 1445 |
|
1445 |
|
| 1446 |
Map<Integer, FocusedModel> focusedModelMap = focusedModelRepository.selectAllByRegionIds(regionIds).stream()
|
1446 |
Map<Integer, FocusedModel> focusedModelMap = focusedModelRepository.selectAllByRegionIds(regionIds).stream()
|
| 1447 |
.collect(Collectors.toMap(FocusedModel::getCatalogId, Function.identity()));
|
1447 |
.collect(Collectors.toMap(FocusedModel::getCatalogId, Function.identity()));
|
| 1448 |
|
1448 |
|
| 1449 |
LocalDate currentMonthDate = LocalDate.now();
|
1449 |
LocalDate currentMonthDate = LocalDate.now();
|
| 1450 |
MonthlyPlanned monthlyPlanned = null;
|
1450 |
MonthlyPlanned monthlyPlanned = null;
|
| 1451 |
List<Integer> fofoOrderIds = null;
|
1451 |
List<Integer> fofoOrderIds = null;
|
| 1452 |
LOGGER.info("localDate" + LocalDate.now());
|
1452 |
LOGGER.info("localDate" + LocalDate.now());
|
| 1453 |
if (LocalDate.now().isAfter(LocalDate.now().withDayOfMonth(PLANNING_OPEN_DAY))) {
|
1453 |
if (LocalDate.now().isAfter(LocalDate.now().withDayOfMonth(PLANNING_OPEN_DAY))) {
|
| 1454 |
currentMonthDate = LocalDate.now().plusMonths(1).withDayOfMonth(1);
|
1454 |
currentMonthDate = LocalDate.now().plusMonths(1).withDayOfMonth(1);
|
| 1455 |
monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, currentMonthDate);
|
1455 |
monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, currentMonthDate);
|
| 1456 |
LOGGER.info("monthlyPlanned2" + monthlyPlanned);
|
1456 |
LOGGER.info("monthlyPlanned2" + monthlyPlanned);
|
| 1457 |
fofoOrderIds = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
|
1457 |
fofoOrderIds = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
|
| 1458 |
LocalDateTime.now().minusDays(15), LocalDateTime.now()).stream().map(x -> x.getId())
|
1458 |
LocalDateTime.now().minusDays(15), LocalDateTime.now()).stream().map(x -> x.getId())
|
| 1459 |
.collect(Collectors.toList());
|
1459 |
.collect(Collectors.toList());
|
| 1460 |
|
1460 |
|
| 1461 |
model.addAttribute("planningMonth", LocalDate.now().plusMonths(1).getMonth());
|
1461 |
model.addAttribute("planningMonth", LocalDate.now().plusMonths(1).getMonth());
|
| 1462 |
} else {
|
1462 |
} else {
|
| 1463 |
currentMonthDate = LocalDate.now().withDayOfMonth(1);
|
1463 |
currentMonthDate = LocalDate.now().withDayOfMonth(1);
|
| 1464 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
1464 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 1465 |
monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, currentMonthDate);
|
1465 |
monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, currentMonthDate);
|
| 1466 |
model.addAttribute("planningMonth", currentMonthDate.getMonth());
|
1466 |
model.addAttribute("planningMonth", currentMonthDate.getMonth());
|
| 1467 |
model.addAttribute("mtd", true);
|
1467 |
model.addAttribute("mtd", true);
|
| 1468 |
model.addAttribute("freezed", true);
|
1468 |
model.addAttribute("freezed", true);
|
| 1469 |
fofoOrderIds = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
|
1469 |
fofoOrderIds = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
|
| 1470 |
curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX)).stream().map(x -> x.getId())
|
1470 |
curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX)).stream().map(x -> x.getId())
|
| 1471 |
.collect(Collectors.toList());
|
1471 |
.collect(Collectors.toList());
|
| 1472 |
LOGGER.info("monthlyPlanned1" + monthlyPlanned);
|
1472 |
LOGGER.info("monthlyPlanned1" + monthlyPlanned);
|
| 1473 |
}
|
1473 |
}
|
| 1474 |
|
1474 |
|
| 1475 |
Map<Integer, Integer> plannedDetailMap = null;
|
1475 |
Map<Integer, Integer> plannedDetailMap = null;
|
| 1476 |
if (monthlyPlanned != null) {
|
1476 |
if (monthlyPlanned != null) {
|
| 1477 |
plannedDetailMap = plannedDetailRepository.selectByPlannedId(monthlyPlanned.getId()).stream()
|
1477 |
plannedDetailMap = plannedDetailRepository.selectByPlannedId(monthlyPlanned.getId()).stream()
|
| 1478 |
.collect(Collectors.toMap(x -> x.getCatalogId(), x -> x.getQuantity()));
|
1478 |
.collect(Collectors.toMap(x -> x.getCatalogId(), x -> x.getQuantity()));
|
| 1479 |
|
1479 |
|
| 1480 |
}
|
1480 |
}
|
| 1481 |
LOGGER.info("plannedDetailMap" + plannedDetailMap);
|
1481 |
LOGGER.info("plannedDetailMap" + plannedDetailMap);
|
| 1482 |
|
1482 |
|
| 1483 |
LOGGER.info("fofoOrderIds" + fofoOrderIds);
|
1483 |
LOGGER.info("fofoOrderIds" + fofoOrderIds);
|
| 1484 |
Map<String, Object> equalsJoinMap = new HashMap<>();
|
1484 |
Map<String, Object> equalsJoinMap = new HashMap<>();
|
| 1485 |
|
1485 |
|
| 1486 |
equalsJoinMap.put("orderId", fofoOrderIds);
|
1486 |
equalsJoinMap.put("orderId", fofoOrderIds);
|
| 1487 |
Map<Integer, Integer> last15daysMap = null;
|
1487 |
Map<Integer, Integer> last15daysMap = null;
|
| 1488 |
if (fofoOrderIds != null && !fofoOrderIds.isEmpty()) {
|
1488 |
if (fofoOrderIds != null && !fofoOrderIds.isEmpty()) {
|
| 1489 |
|
1489 |
|
| 1490 |
last15daysMap = itemRepository
|
1490 |
last15daysMap = itemRepository
|
| 1491 |
.selectItems(FofoOrderItem.class, "id", "itemId", equalsMap, notEqualsMap, equalsJoinMap,
|
1491 |
.selectItems(FofoOrderItem.class, "id", "itemId", equalsMap, notEqualsMap, equalsJoinMap,
|
| 1492 |
notEqualsJoinMap, "quantity")
|
1492 |
notEqualsJoinMap, "quantity")
|
| 1493 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> (int) x.getAggregateValue()));
|
1493 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> (int) x.getAggregateValue()));
|
| 1494 |
}
|
1494 |
}
|
| 1495 |
LOGGER.info("last15daysMap" + last15daysMap);
|
1495 |
LOGGER.info("last15daysMap" + last15daysMap);
|
| 1496 |
|
1496 |
|
| 1497 |
Map<Integer, TagListing> taglistingMap = tagListings.stream()
|
1497 |
Map<Integer, TagListing> taglistingMap = tagListings.stream()
|
| 1498 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
1498 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
| 1499 |
List<Item> items = itemRepository.selectByIds(taglistingMap.keySet());
|
1499 |
List<Item> items = itemRepository.selectByIds(taglistingMap.keySet());
|
| 1500 |
Map<Integer, List<Item>> catalogIdItemMap = items.stream().collect(
|
1500 |
Map<Integer, List<Item>> catalogIdItemMap = items.stream().collect(
|
| 1501 |
Collectors.groupingBy(x -> x.getCatalogItemId(), Collectors.mapping(y -> y, Collectors.toList())));
|
1501 |
Collectors.groupingBy(x -> x.getCatalogItemId(), Collectors.mapping(y -> y, Collectors.toList())));
|
| 1502 |
LOGGER.info("catalogIdItemMap");
|
1502 |
LOGGER.info("catalogIdItemMap");
|
| 1503 |
|
1503 |
|
| 1504 |
Map<String, Object> equalsItemJoinMap = new HashMap<>();
|
1504 |
Map<String, Object> equalsItemJoinMap = new HashMap<>();
|
| 1505 |
equalsItemJoinMap.put("active", 1);
|
1505 |
equalsItemJoinMap.put("active", 1);
|
| 1506 |
List<IntegerIdAggregateValue> tagListingCatalogIds = itemRepository.selectItems(TagListing.class, "id",
|
1506 |
List<IntegerIdAggregateValue> tagListingCatalogIds = itemRepository.selectItems(TagListing.class, "id",
|
| 1507 |
"itemId", equalsMap, notEqualsMap, equalsItemJoinMap, notEqualsJoinMap, "tagId");
|
1507 |
"itemId", equalsMap, notEqualsMap, equalsItemJoinMap, notEqualsJoinMap, "tagId");
|
| 1508 |
Map<Integer, Integer> ourStockAvailability = new HashMap<>();
|
1508 |
Map<Integer, Integer> ourStockAvailability = new HashMap<>();
|
| 1509 |
|
1509 |
|
| 1510 |
Map<Integer, List<Integer>> catalogItemIdMap = itemRepository
|
1510 |
Map<Integer, List<Integer>> catalogItemIdMap = itemRepository
|
| 1511 |
.selectAllByCatalogIds(new HashSet<>(
|
1511 |
.selectAllByCatalogIds(new HashSet<>(
|
| 1512 |
tagListingCatalogIds.stream().map(x -> x.getCatalogId()).collect(Collectors.toList())))
|
1512 |
tagListingCatalogIds.stream().map(x -> x.getCatalogId()).collect(Collectors.toList())))
|
| 1513 |
.stream().collect(Collectors.groupingBy(x -> x.getCatalogItemId(),
|
1513 |
.stream().collect(Collectors.groupingBy(x -> x.getCatalogItemId(),
|
| 1514 |
Collectors.mapping(y -> y.getId(), Collectors.toList())));
|
1514 |
Collectors.mapping(y -> y.getId(), Collectors.toList())));
|
| 1515 |
for (Entry<Integer, List<Integer>> catalogItem : catalogItemIdMap.entrySet()) {
|
1515 |
for (Entry<Integer, List<Integer>> catalogItem : catalogItemIdMap.entrySet()) {
|
| 1516 |
List<Integer> itemIds = catalogItem.getValue();
|
1516 |
List<Integer> itemIds = catalogItem.getValue();
|
| 1517 |
int availability = 0;
|
1517 |
int availability = 0;
|
| 1518 |
for (Integer itemId : itemIds) {
|
1518 |
for (Integer itemId : itemIds) {
|
| 1519 |
List<SaholicCISTable> saholicCISTableList = saholicCISTableRepository.selectByItemWarehouse(itemId,
|
1519 |
List<SaholicCISTable> saholicCISTableList = saholicCISTableRepository.selectByItemWarehouse(itemId,
|
| 1520 |
fofoStore.getWarehouseId());
|
1520 |
fofoStore.getWarehouseId());
|
| 1521 |
if (saholicCISTableList != null) {
|
1521 |
if (saholicCISTableList != null) {
|
| 1522 |
availability += saholicCISTableList.stream()
|
1522 |
availability += saholicCISTableList.stream()
|
| 1523 |
.collect(Collectors.summingInt(x -> x.getAvailability()));
|
1523 |
.collect(Collectors.summingInt(x -> x.getAvailability()));
|
| 1524 |
}
|
1524 |
}
|
| 1525 |
}
|
1525 |
}
|
| 1526 |
Integer catalogItemId = catalogItem.getKey();
|
1526 |
Integer catalogItemId = catalogItem.getKey();
|
| 1527 |
ourStockAvailability.put(catalogItemId, availability);
|
1527 |
ourStockAvailability.put(catalogItemId, availability);
|
| 1528 |
}
|
1528 |
}
|
| 1529 |
LOGGER.info("ourStockAvailability" + ourStockAvailability);
|
1529 |
LOGGER.info("ourStockAvailability" + ourStockAvailability);
|
| 1530 |
|
1530 |
|
| 1531 |
for (IntegerIdAggregateValue catalogIdAggregateValue : tagListingCatalogIds) {
|
1531 |
for (IntegerIdAggregateValue catalogIdAggregateValue : tagListingCatalogIds) {
|
| 1532 |
int catalogId = catalogIdAggregateValue.getCatalogId();
|
1532 |
int catalogId = catalogIdAggregateValue.getCatalogId();
|
| 1533 |
Item item = catalogIdItemMap.get(catalogId).get(0);
|
1533 |
Item item = catalogIdItemMap.get(catalogId).get(0);
|
| 1534 |
TagListing tagListing = taglistingMap.get(item.getId());
|
1534 |
TagListing tagListing = taglistingMap.get(item.getId());
|
| 1535 |
CatalogListingModel catalogListingModel = catalogListingMap.get(catalogId);
|
1535 |
CatalogListingModel catalogListingModel = catalogListingMap.get(catalogId);
|
| 1536 |
if (!catalogListingMap.containsKey(catalogId)) {
|
1536 |
if (!catalogListingMap.containsKey(catalogId)) {
|
| 1537 |
catalogListingModel = new CatalogListingModel();
|
1537 |
catalogListingModel = new CatalogListingModel();
|
| 1538 |
catalogListingModel.setCatalogId(catalogId);
|
1538 |
catalogListingModel.setCatalogId(catalogId);
|
| 1539 |
catalogListingModel.setDp(tagListing.getSellingPrice());
|
1539 |
catalogListingModel.setDp(tagListing.getSellingPrice());
|
| 1540 |
catalogListingModel.setMop(tagListing.getMop());
|
1540 |
catalogListingModel.setMop(tagListing.getMop());
|
| 1541 |
catalogListingModel.setItemDescription(item.getItemDescriptionNoColor());
|
1541 |
catalogListingModel.setItemDescription(item.getItemDescriptionNoColor());
|
| 1542 |
if (plannedDetailMap != null) {
|
1542 |
if (plannedDetailMap != null) {
|
| 1543 |
|
1543 |
|
| 1544 |
Integer quantity = plannedDetailMap.get(catalogId);
|
1544 |
Integer quantity = plannedDetailMap.get(catalogId);
|
| 1545 |
if (quantity != null) {
|
1545 |
if (quantity != null) {
|
| 1546 |
catalogListingModel.setAllocatedQuantity(quantity);
|
1546 |
catalogListingModel.setAllocatedQuantity(quantity);
|
| 1547 |
}
|
1547 |
}
|
| 1548 |
}
|
1548 |
}
|
| 1549 |
|
1549 |
|
| 1550 |
if (last15daysMap != null) {
|
1550 |
if (last15daysMap != null) {
|
| 1551 |
Integer last15DaysSale = last15daysMap.get(catalogId);
|
1551 |
Integer last15DaysSale = last15daysMap.get(catalogId);
|
| 1552 |
|
1552 |
|
| 1553 |
if (last15DaysSale != null) {
|
1553 |
if (last15DaysSale != null) {
|
| 1554 |
catalogListingModel.setLast15DaysSale(last15DaysSale);
|
1554 |
catalogListingModel.setLast15DaysSale(last15DaysSale);
|
| 1555 |
} else {
|
1555 |
} else {
|
| 1556 |
catalogListingModel.setLast15DaysSale(0);
|
1556 |
catalogListingModel.setLast15DaysSale(0);
|
| 1557 |
}
|
1557 |
}
|
| 1558 |
} else {
|
1558 |
} else {
|
| 1559 |
catalogListingModel.setLast15DaysSale(0);
|
1559 |
catalogListingModel.setLast15DaysSale(0);
|
| 1560 |
}
|
1560 |
}
|
| 1561 |
|
1561 |
|
| 1562 |
catalogListingModel.setBrand(item.getBrand());
|
1562 |
catalogListingModel.setBrand(item.getBrand());
|
| 1563 |
if (item.getCategoryId() == 10006) {
|
1563 |
if (item.getCategoryId() == 10006) {
|
| 1564 |
catalogListingModel.setCategoryId(item.getCategoryId());
|
1564 |
catalogListingModel.setCategoryId(item.getCategoryId());
|
| 1565 |
}
|
1565 |
}
|
| 1566 |
|
1566 |
|
| 1567 |
Integer ourStock = ourStockAvailability.get(catalogId);
|
1567 |
Integer ourStock = ourStockAvailability.get(catalogId);
|
| 1568 |
LOGGER.info("catalogId" + catalogId);
|
1568 |
LOGGER.info("catalogId" + catalogId);
|
| 1569 |
|
1569 |
|
| 1570 |
LOGGER.info("ourStock" + ourStock);
|
1570 |
LOGGER.info("ourStock" + ourStock);
|
| 1571 |
if (ourStock != null) {
|
1571 |
if (ourStock != null) {
|
| 1572 |
catalogListingModel.setOurStockQty(ourStock);
|
1572 |
catalogListingModel.setOurStockQty(ourStock);
|
| 1573 |
}
|
1573 |
}
|
| 1574 |
|
1574 |
|
| 1575 |
FocusedModel fm = focusedModelMap.get(catalogId);
|
1575 |
FocusedModel fm = focusedModelMap.get(catalogId);
|
| 1576 |
if (fm != null) {
|
1576 |
if (fm != null) {
|
| 1577 |
catalogListingModel.setRecommendedQty(fm.getRecommendedQty());
|
1577 |
catalogListingModel.setRecommendedQty(fm.getRecommendedQty());
|
| 1578 |
catalogListingModel.setMinimumQty(fm.getMinimumQty());
|
1578 |
catalogListingModel.setMinimumQty(fm.getMinimumQty());
|
| 1579 |
catalogListingModel.setObsRecommendedQty(fm.getObsRecommendedQty());
|
1579 |
catalogListingModel.setObsRecommendedQty(fm.getObsRecommendedQty());
|
| 1580 |
catalogListingModel.setObsMinimumQty(fm.getObsMinimumQty());
|
1580 |
catalogListingModel.setObsMinimumQty(fm.getObsMinimumQty());
|
| 1581 |
|
1581 |
|
| 1582 |
} else {
|
1582 |
} else {
|
| 1583 |
catalogListingModel.setRecommendedQty(0);
|
1583 |
catalogListingModel.setRecommendedQty(0);
|
| 1584 |
catalogListingModel.setMinimumQty(0);
|
1584 |
catalogListingModel.setMinimumQty(0);
|
| 1585 |
|
1585 |
|
| 1586 |
catalogListingModel.setObsRecommendedQty(0);
|
1586 |
catalogListingModel.setObsRecommendedQty(0);
|
| 1587 |
catalogListingModel.setObsMinimumQty(0);
|
1587 |
catalogListingModel.setObsMinimumQty(0);
|
| 1588 |
|
1588 |
|
| 1589 |
}
|
1589 |
}
|
| 1590 |
|
1590 |
|
| 1591 |
catalogListingMap.put(catalogId, catalogListingModel);
|
1591 |
catalogListingMap.put(catalogId, catalogListingModel);
|
| 1592 |
|
1592 |
|
| 1593 |
}
|
1593 |
}
|
| 1594 |
int itemAvailability = 0;
|
1594 |
int itemAvailability = 0;
|
| 1595 |
if (currentStockMap != null) {
|
1595 |
if (currentStockMap != null) {
|
| 1596 |
Integer qty = currentStockMap.get(catalogId);
|
1596 |
Integer qty = currentStockMap.get(catalogId);
|
| 1597 |
itemAvailability = qty == null ? 0 : qty;
|
1597 |
itemAvailability = qty == null ? 0 : qty;
|
| 1598 |
catalogListingModel.setStockInHand(itemAvailability);
|
1598 |
catalogListingModel.setStockInHand(itemAvailability);
|
| 1599 |
} else {
|
1599 |
} else {
|
| 1600 |
catalogListingModel.setStockInHand(0);
|
1600 |
catalogListingModel.setStockInHand(0);
|
| 1601 |
}
|
1601 |
}
|
| 1602 |
Integer inTransitQuantity = itemsInTransit.get(item.getId());
|
1602 |
Integer inTransitQuantity = itemsInTransit.get(item.getId());
|
| 1603 |
int inTransitQty = (inTransitQuantity == null ? 0 : inTransitQuantity);
|
1603 |
int inTransitQty = (inTransitQuantity == null ? 0 : inTransitQuantity);
|
| 1604 |
catalogListingModel.setInTransitQuantity(catalogListingModel.getInTransitQuantity() + inTransitQty);
|
1604 |
catalogListingModel.setInTransitQuantity(catalogListingModel.getInTransitQuantity() + inTransitQty);
|
| 1605 |
if (plannedDetailMap != null) {
|
1605 |
if (plannedDetailMap != null) {
|
| 1606 |
if (plannedDetailMap.get(catalogId) != null) {
|
1606 |
if (plannedDetailMap.get(catalogId) != null) {
|
| 1607 |
|
1607 |
|
| 1608 |
int remaining = plannedDetailMap.get(catalogId) - catalogListingModel.getLast15DaysSale()
|
1608 |
int remaining = plannedDetailMap.get(catalogId) - catalogListingModel.getLast15DaysSale()
|
| 1609 |
+ catalogListingModel.getStockInHand() + catalogListingModel.getInTransitQuantity();
|
1609 |
+ catalogListingModel.getStockInHand() + catalogListingModel.getInTransitQuantity();
|
| 1610 |
LOGGER.info("remaning" + remaining);
|
1610 |
LOGGER.info("remaning" + remaining);
|
| 1611 |
|
1611 |
|
| 1612 |
if (remaining != 0) {
|
1612 |
if (remaining != 0) {
|
| 1613 |
catalogListingModel.setRemaining(remaining);
|
1613 |
catalogListingModel.setRemaining(remaining);
|
| 1614 |
} else {
|
1614 |
} else {
|
| 1615 |
catalogListingModel.setRemaining(0);
|
1615 |
catalogListingModel.setRemaining(0);
|
| 1616 |
}
|
1616 |
}
|
| 1617 |
}
|
1617 |
}
|
| 1618 |
}
|
1618 |
}
|
| 1619 |
}
|
1619 |
}
|
| 1620 |
|
1620 |
|
| 1621 |
Map<Integer, CustomRetailer> customRetailersMap = retailerService.getFofoRetailers(false);
|
1621 |
Map<Integer, CustomRetailer> customRetailersMap = retailerService.getFofoRetailers(false);
|
| 1622 |
if (fofoId > 0) {
|
1622 |
if (fofoId > 0) {
|
| 1623 |
CustomRetailer customRetailer = customRetailersMap.get(fofoId);
|
1623 |
CustomRetailer customRetailer = customRetailersMap.get(fofoId);
|
| 1624 |
model.addAttribute("retailerName",
|
1624 |
model.addAttribute("retailerName",
|
| 1625 |
customRetailer.getBusinessName() + "-" + customRetailer.getAddress().getCity());
|
1625 |
customRetailer.getBusinessName() + "-" + customRetailer.getAddress().getCity());
|
| 1626 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(fofoId);
|
1626 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(fofoId);
|
| 1627 |
model.addAttribute("retailerId", customRetailer.getPartnerId());
|
1627 |
model.addAttribute("retailerId", customRetailer.getPartnerId());
|
| 1628 |
model.addAttribute("counterSize", fs.getCounterSize().toString());
|
1628 |
model.addAttribute("counterSize", fs.getCounterSize().toString());
|
| 1629 |
} else {
|
1629 |
} else {
|
| 1630 |
model.addAttribute("counterSize", counterSize.toString());
|
1630 |
model.addAttribute("counterSize", counterSize.toString());
|
| 1631 |
}
|
1631 |
}
|
| 1632 |
String customRetailers = JSONObject.valueToString(customRetailersMap.values());
|
1632 |
String customRetailers = JSONObject.valueToString(customRetailersMap.values());
|
| 1633 |
|
1633 |
|
| 1634 |
List<CatalogListingModel> catalogModelList = new ArrayList<>(catalogListingMap.values());
|
1634 |
List<CatalogListingModel> catalogModelList = new ArrayList<>(catalogListingMap.values());
|
| 1635 |
|
1635 |
|
| 1636 |
Comparator<CatalogListingModel> firstCmp = Comparator.comparing(CatalogListingModel::getMinimumQty,
|
1636 |
Comparator<CatalogListingModel> firstCmp = Comparator.comparing(CatalogListingModel::getMinimumQty,
|
| 1637 |
Comparator.reverseOrder());
|
1637 |
Comparator.reverseOrder());
|
| 1638 |
LOGGER.info("monthlyPlanned" + monthlyPlanned);
|
1638 |
LOGGER.info("monthlyPlanned" + monthlyPlanned);
|
| 1639 |
model.addAttribute("catalogTagListings",
|
1639 |
model.addAttribute("catalogTagListings",
|
| 1640 |
catalogModelList.stream().sorted(firstCmp).collect(Collectors.toList()));
|
1640 |
catalogModelList.stream().sorted(firstCmp).collect(Collectors.toList()));
|
| 1641 |
model.addAttribute("isAdmin", roleManager.isAdmin(roleIds));
|
1641 |
model.addAttribute("isAdmin", roleManager.isAdmin(roleIds));
|
| 1642 |
model.addAttribute("brandStockPrices", this.getBrandStockPrices(fofoId));
|
1642 |
model.addAttribute("brandStockPrices", this.getBrandStockPrices(fofoId));
|
| 1643 |
model.addAttribute("previousPlanningMonth", LocalDate.now().minusMonths(1).getMonth());
|
1643 |
model.addAttribute("previousPlanningMonth", LocalDate.now().minusMonths(1).getMonth());
|
| 1644 |
model.addAttribute("currentPlanningMonth", LocalDate.now().getMonth());
|
1644 |
model.addAttribute("currentPlanningMonth", LocalDate.now().getMonth());
|
| 1645 |
|
1645 |
|
| 1646 |
model.addAttribute("customRetailers", customRetailers);
|
1646 |
model.addAttribute("customRetailers", customRetailers);
|
| 1647 |
model.addAttribute("totalAmount", totalAmount);
|
1647 |
model.addAttribute("totalAmount", totalAmount);
|
| 1648 |
model.addAttribute("monthlyPlanned", monthlyPlanned);
|
1648 |
model.addAttribute("monthlyPlanned", monthlyPlanned);
|
| 1649 |
model.addAttribute("totalPcs", totalPcs);
|
1649 |
model.addAttribute("totalPcs", totalPcs);
|
| 1650 |
|
1650 |
|
| 1651 |
UserWallet userWallet = walletService.getUserWallet(fofoId);
|
1651 |
UserWallet userWallet = walletService.getUserWallet(fofoId);
|
| 1652 |
|
1652 |
|
| 1653 |
model.addAttribute("userWallet", userWallet);
|
1653 |
model.addAttribute("userWallet", userWallet);
|
| 1654 |
|
1654 |
|
| 1655 |
return "create-partner-po";
|
1655 |
return "create-partner-po";
|
| 1656 |
|
1656 |
|
| 1657 |
}
|
1657 |
}
|
| 1658 |
|
1658 |
|
| 1659 |
@RequestMapping(value = "/selectItemColor", method = RequestMethod.GET)
|
1659 |
@RequestMapping(value = "/selectItemColor", method = RequestMethod.GET)
|
| 1660 |
public String selectItemColor(HttpServletRequest request, @RequestParam int catalogId, Model model)
|
1660 |
public String selectItemColor(HttpServletRequest request, @RequestParam int catalogId, Model model)
|
| 1661 |
throws Exception {
|
1661 |
throws Exception {
|
| 1662 |
|
1662 |
|
| 1663 |
List<Item> selecteditems = itemRepository.selectAllByCatalogItemId(catalogId);
|
1663 |
List<Item> selecteditems = itemRepository.selectAllByCatalogItemId(catalogId);
|
| 1664 |
|
1664 |
|
| 1665 |
List<Item> items = new ArrayList<>();
|
1665 |
List<Item> items = new ArrayList<>();
|
| 1666 |
for (Item item : selecteditems) {
|
1666 |
for (Item item : selecteditems) {
|
| 1667 |
|
1667 |
|
| 1668 |
TagListing tagListing = tagListingRepository.selectByItemId(item.getId(), true);
|
1668 |
TagListing tagListing = tagListingRepository.selectByItemId(item.getId(), true);
|
| 1669 |
|
1669 |
|
| 1670 |
if (tagListing != null) {
|
1670 |
if (tagListing != null) {
|
| 1671 |
items.add(item);
|
1671 |
items.add(item);
|
| 1672 |
}
|
1672 |
}
|
| 1673 |
|
1673 |
|
| 1674 |
}
|
1674 |
}
|
| 1675 |
model.addAttribute("items", items);
|
1675 |
model.addAttribute("items", items);
|
| 1676 |
LOGGER.info("itemIdAndColorMap" + items);
|
1676 |
LOGGER.info("itemIdAndColorMap" + items);
|
| 1677 |
return "select-item-color";
|
1677 |
return "select-item-color";
|
| 1678 |
}
|
1678 |
}
|
| 1679 |
|
1679 |
|
| 1680 |
List<String> emails = Arrays.asList("kamini.sharma@smartdukaan.com", "neeraj.gupta@smartdukaan.com",
|
1680 |
List<String> emails = Arrays.asList("kamini.sharma@smartdukaan.com", "neeraj.gupta@smartdukaan.com",
|
| 1681 |
"niranjan.kala@smartdukaan.com", "amit.gupta@smartdukaan.com", "tejbeer.kaur@smartdukaan.com");
|
1681 |
"niranjan.kala@smartdukaan.com", "amit.gupta@smartdukaan.com", "tejbeer.kaur@smartdukaan.com");
|
| 1682 |
|
1682 |
|
| 1683 |
@Autowired
|
1683 |
@Autowired
|
| 1684 |
private PositionRepository positionRepository;
|
1684 |
private PositionRepository positionRepository;
|
| 1685 |
|
1685 |
|
| 1686 |
@Autowired
|
1686 |
@Autowired
|
| 1687 |
private PartnerTypeChangeService partnerTypeChangeService;
|
1687 |
private PartnerTypeChangeService partnerTypeChangeService;
|
| 1688 |
|
1688 |
|
| 1689 |
@Autowired
|
1689 |
@Autowired
|
| 1690 |
private com.spice.profitmandi.service.transaction.TransactionService transactionService;
|
1690 |
private com.spice.profitmandi.service.transaction.TransactionService transactionService;
|
| 1691 |
|
1691 |
|
| 1692 |
@Autowired
|
1692 |
@Autowired
|
| 1693 |
private CategoryRepository categoryRepository;
|
1693 |
private CategoryRepository categoryRepository;
|
| 1694 |
|
1694 |
|
| 1695 |
@Autowired
|
1695 |
@Autowired
|
| 1696 |
private BrandLimitRepository brandLimitRepository;
|
1696 |
private BrandLimitRepository brandLimitRepository;
|
| 1697 |
|
1697 |
|
| 1698 |
@Autowired
|
1698 |
|
| 1699 |
//This is alternate proxy to auth to enable Spring Caching
|
1699 |
private List<OrderStatus> orderStatusList = Arrays.asList(OrderStatus.SUBMITTED_FOR_PROCESSING,
|
| 1700 |
private CsService1 authService1;
|
1700 |
OrderStatus.ACCEPTED);
|
| 1701 |
|
1701 |
|
| 1702 |
private List<OrderStatus> orderStatusList = Arrays.asList(OrderStatus.SUBMITTED_FOR_PROCESSING,
|
1702 |
public static final Map<String, Double> Brand_Amount_Limit = new HashMap<>();
|
| 1703 |
OrderStatus.ACCEPTED);
|
1703 |
|
| 1704 |
|
1704 |
static {
|
| 1705 |
public static final Map<String, Double> Brand_Amount_Limit = new HashMap<>();
|
1705 |
|
| 1706 |
|
1706 |
Brand_Amount_Limit.put("accessories", 10000.00);
|
| 1707 |
static {
|
1707 |
Brand_Amount_Limit.put("TV", 27000.00);
|
| 1708 |
|
1708 |
}
|
| 1709 |
Brand_Amount_Limit.put("accessories", 10000.00);
|
1709 |
|
| 1710 |
Brand_Amount_Limit.put("TV", 27000.00);
|
1710 |
@RequestMapping(value = "/getPartnersBrandWiseDetail", method = RequestMethod.GET)
|
| 1711 |
}
|
1711 |
public String getPartnersBrandWiseDetail(HttpServletRequest request, Model model) throws Exception {
|
| 1712 |
|
1712 |
|
| 1713 |
@RequestMapping(value = "/getPartnersBrandWiseDetail", method = RequestMethod.GET)
|
1713 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 1714 |
public String getPartnersBrandWiseDetail(HttpServletRequest request, Model model) throws Exception {
|
1714 |
String email = loginDetails.getEmailId();
|
| 1715 |
|
1715 |
|
| 1716 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
1716 |
List<String> brands = Arrays.asList("Vivo", "Samsung", "Oppo", "Tecno", "Itel", "OnePlus", "Lava", "Realme",
|
| 1717 |
String email = loginDetails.getEmailId();
|
1717 |
"Xiaomi", "Nokia");
|
| 1718 |
|
1718 |
|
| 1719 |
List<String> brands = Arrays.asList("Vivo", "Samsung", "Oppo", "Tecno", "Itel", "OnePlus", "Lava", "Realme",
|
1719 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
| 1720 |
"Xiaomi", "Nokia");
|
1720 |
Set<Integer> fofoIds = csService1.getAuthFofoIds(email, true);
|
| 1721 |
|
1721 |
|
| 1722 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
1722 |
Map<Integer, PartnerDailyInvestment> partnerDailyInvestmentMap = new HashMap<>();
|
| 1723 |
Set<Integer> fofoIds = csService1.getAuthFofoIds(email, true);
|
1723 |
|
| 1724 |
|
1724 |
Map<Integer, Map<String, Double>> fofoIdBrandAmountMap = new HashMap<>();
|
| 1725 |
Map<Integer, PartnerDailyInvestment> partnerDailyInvestmentMap = new HashMap<>();
|
1725 |
|
| 1726 |
|
1726 |
Map<Integer, InStockAccessoriesTvFofoIdModel> inStockAccessTv = new HashMap<>();
|
| 1727 |
Map<Integer, Map<String, Double>> fofoIdBrandAmountMap = new HashMap<>();
|
1727 |
Map<Integer, InStockAccessoriesTvFofoIdModel> pendingIndentAccessTv = new HashMap<>();
|
| 1728 |
|
1728 |
Map<Integer, InStockAccessoriesTvFofoIdModel> grnPendingAccessTvOrders = new HashMap<>();
|
| 1729 |
Map<Integer, InStockAccessoriesTvFofoIdModel> inStockAccessTv = new HashMap<>();
|
1729 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
| 1730 |
Map<Integer, InStockAccessoriesTvFofoIdModel> pendingIndentAccessTv = new HashMap<>();
|
1730 |
Map<Integer, CustomRetailer> customRetailers = new HashMap<>();
|
| 1731 |
Map<Integer, InStockAccessoriesTvFofoIdModel> grnPendingAccessTvOrders = new HashMap<>();
|
1731 |
Map<Integer, PartnerType> fofoIdPartnerTypeMap = new HashMap<>();
|
| 1732 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
1732 |
|
| 1733 |
Map<Integer, CustomRetailer> customRetailers = new HashMap<>();
|
1733 |
if (fofoIds != null && fofoIds.size() > 0) {
|
| 1734 |
Map<Integer, PartnerType> fofoIdPartnerTypeMap = new HashMap<>();
|
1734 |
List<Integer> fofoIdList = new ArrayList<>(fofoIds);
|
| 1735 |
|
1735 |
|
| 1736 |
if (fofoIds != null && fofoIds.size() > 0) {
|
1736 |
Map<Integer, ActivationType> partnerActivationType = fofoStoreRepository.selectByRetailerIds(fofoIdList)
|
| 1737 |
List<Integer> fofoIdList = new ArrayList<>(fofoIds);
|
1737 |
.stream().collect(Collectors.toMap(x -> x.getId(), x -> x.getActivationType()));
|
| 1738 |
|
1738 |
//Only L3 and above can change the accessType
|
| 1739 |
Map<Integer, ActivationType> partnerActivationType = fofoStoreRepository.selectByRetailerIds(fofoIdList)
|
1739 |
boolean canChangeActionType = positionRepository.selectAll(authUser.getId())
|
| 1740 |
.stream().collect(Collectors.toMap(x -> x.getId(), x -> x.getActivationType()));
|
1740 |
.stream().filter(x -> x.getEscalationType().isGreaterThanEqualTo(EscalationType.L3)).count() > 0;
|
| 1741 |
|
1741 |
model.addAttribute("canChangeActivationType", canChangeActionType);
|
| 1742 |
model.addAttribute("partnerActivationType", partnerActivationType);
|
1742 |
model.addAttribute("partnerActivationType", partnerActivationType);
|
| 1743 |
model.addAttribute("activationTypes", ActivationType.values());
|
1743 |
model.addAttribute("activationTypes", ActivationType.values());
|
| 1744 |
|
1744 |
|
| 1745 |
Map<Integer, FofoReportingModel> partnerSalesHeadersMap = csService.getPartnerIdSalesHeaders();
|
1745 |
Map<Integer, FofoReportingModel> partnerSalesHeadersMap = csService.getPartnerIdSalesHeaders();
|
| 1746 |
|
1746 |
|
| 1747 |
model.addAttribute("partnerSalesHeadersMap", partnerSalesHeadersMap);
|
1747 |
model.addAttribute("partnerSalesHeadersMap", partnerSalesHeadersMap);
|
| 1748 |
|
1748 |
|
| 1749 |
Map<Integer, Map<String, Float>> partnerBrandLimitMap = brandLimitRepository.selectAllPartnerBrandLimit()
|
1749 |
Map<Integer, Map<String, Float>> partnerBrandLimitMap = brandLimitRepository.selectAllPartnerBrandLimit()
|
| 1750 |
.stream().collect(Collectors.groupingBy(x -> x.getFofoId(),
|
1750 |
.stream().collect(Collectors.groupingBy(x -> x.getFofoId(),
|
| 1751 |
Collectors.toMap(x -> x.getBrand(), x -> x.getBrandLimit())));
|
1751 |
Collectors.toMap(x -> x.getBrand(), x -> x.getBrandLimit())));
|
| 1752 |
|
1752 |
|
| 1753 |
model.addAttribute("partnerBrandLimitMap", partnerBrandLimitMap);
|
1753 |
model.addAttribute("partnerBrandLimitMap", partnerBrandLimitMap);
|
| 1754 |
customRetailers = fofoIds.stream().map(x -> customRetailerMap.get(x)).filter(x -> x != null)
|
1754 |
customRetailers = fofoIds.stream().map(x -> customRetailerMap.get(x)).filter(x -> x != null)
|
| 1755 |
.collect(Collectors.toList()).stream().collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
1755 |
.collect(Collectors.toList()).stream().collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
| 1756 |
Map<Integer, Map<String, Double>> inStockBrandModel = new HashMap<>();
|
1756 |
Map<Integer, Map<String, Double>> inStockBrandModel;
|
| 1757 |
Map<Integer, Map<String, Double>> pendingIndent = new HashMap<>();
|
1757 |
Map<Integer, Map<String, Double>> pendingIndent;
|
| 1758 |
Map<Integer, Map<String, Double>> grnPendingOrders = new HashMap<>();
|
1758 |
Map<Integer, Map<String, Double>> grnPendingOrders;
|
| 1759 |
|
1759 |
|
| 1760 |
// mobile
|
1760 |
// mobile
|
| 1761 |
inStockBrandModel = currentInventorySnapshotRepository.selectSumInStockMobiletabletGroupByBrand(fofoIdList)
|
1761 |
inStockBrandModel = currentInventorySnapshotRepository.selectSumInStockMobiletabletGroupByBrand(fofoIdList)
|
| 1762 |
.stream()
|
1762 |
.stream()
|
| 1763 |
.collect(Collectors.groupingBy(InStockBrandFofoIdModel::getFofoId,
|
1763 |
.collect(Collectors.groupingBy(InStockBrandFofoIdModel::getFofoId,
|
| 1764 |
Collectors.groupingBy(InStockBrandFofoIdModel::getBrand,
|
1764 |
Collectors.groupingBy(InStockBrandFofoIdModel::getBrand,
|
| 1765 |
Collectors.summingDouble(InStockBrandFofoIdModel::getAmount))));
|
1765 |
Collectors.summingDouble(InStockBrandFofoIdModel::getAmount))));
|
| 1766 |
|
1766 |
|
| 1767 |
pendingIndent = transactionService.getInTransitOrders(fofoIdList).stream()
|
1767 |
pendingIndent = transactionService.getInTransitOrders(fofoIdList).stream()
|
| 1768 |
.filter(x -> x.getLineItem().getItem().getCategoryId() == ProfitMandiConstants.MOBILE_CATEGORY_ID)
|
1768 |
.filter(x -> x.getLineItem().getItem().getCategoryId() == ProfitMandiConstants.MOBILE_CATEGORY_ID)
|
| 1769 |
.collect(Collectors.groupingBy(x -> x.getRetailerId(),
|
1769 |
.collect(Collectors.groupingBy(x -> x.getRetailerId(),
|
| 1770 |
Collectors.groupingBy(y -> y.getLineItem().getBrand(),
|
1770 |
Collectors.groupingBy(y -> y.getLineItem().getBrand(),
|
| 1771 |
Collectors.summingDouble(y -> (double) y.getTotalAmount()))));
|
1771 |
Collectors.summingDouble(y -> (double) y.getTotalAmount()))));
|
| 1772 |
|
1772 |
|
| 1773 |
grnPendingOrders = orderRepository.selectPendingGrnOrders(fofoIdList).stream()
|
1773 |
grnPendingOrders = orderRepository.selectPendingGrnOrders(fofoIdList).stream()
|
| 1774 |
.filter(x -> x.getLineItem().getItem().getCategoryId() == ProfitMandiConstants.MOBILE_CATEGORY_ID)
|
1774 |
.filter(x -> x.getLineItem().getItem().getCategoryId() == ProfitMandiConstants.MOBILE_CATEGORY_ID)
|
| 1775 |
.collect(Collectors.groupingBy(x -> x.getRetailerId(),
|
1775 |
.collect(Collectors.groupingBy(x -> x.getRetailerId(),
|
| 1776 |
Collectors.groupingBy(y -> y.getLineItem().getBrand(),
|
1776 |
Collectors.groupingBy(y -> y.getLineItem().getBrand(),
|
| 1777 |
Collectors.summingDouble(y -> (double) y.getTotalAmount()))));
|
1777 |
Collectors.summingDouble(y -> (double) y.getTotalAmount()))));
|
| 1778 |
|
1778 |
|
| 1779 |
// accessories
|
1779 |
// accessories
|
| 1780 |
inStockAccessTv = currentInventorySnapshotRepository.selectSumInStockAccessoriesAndTv(fofoIdList).stream()
|
1780 |
inStockAccessTv = currentInventorySnapshotRepository.selectSumInStockAccessoriesAndTv(fofoIdList).stream()
|
| 1781 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
1781 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 1782 |
|
1782 |
|
| 1783 |
pendingIndentAccessTv = orderRepository.selectAllPendingIndentAccessoriesTvGroupByFofoId(fofoIdList)
|
1783 |
pendingIndentAccessTv = orderRepository.selectAllPendingIndentAccessoriesTvGroupByFofoId(fofoIdList)
|
| 1784 |
.stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
1784 |
.stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 1785 |
|
1785 |
|
| 1786 |
grnPendingAccessTvOrders = orderRepository.selectAllGrnPendingAccessoriesTvGroupByFofoId(fofoIdList)
|
1786 |
grnPendingAccessTvOrders = orderRepository.selectAllGrnPendingAccessoriesTvGroupByFofoId(fofoIdList)
|
| 1787 |
.stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
1787 |
.stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 1788 |
|
1788 |
|
| 1789 |
for (Entry<Integer, CustomRetailer> customRetailer : customRetailers.entrySet()) {
|
1789 |
for (Entry<Integer, CustomRetailer> customRetailer : customRetailers.entrySet()) {
|
| 1790 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(customRetailer.getKey(),
|
1790 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(customRetailer.getKey(),
|
| 1791 |
LocalDate.now());
|
1791 |
LocalDate.now());
|
| 1792 |
fofoIdPartnerTypeMap.put(customRetailer.getKey(), partnerType);
|
1792 |
fofoIdPartnerTypeMap.put(customRetailer.getKey(), partnerType);
|
| 1793 |
|
1793 |
|
| 1794 |
Map<String, Double> stockBrand = inStockBrandModel.get(customRetailer.getKey());
|
1794 |
Map<String, Double> stockBrand = inStockBrandModel.get(customRetailer.getKey());
|
| 1795 |
Map<String, Double> pendingIndentBrand = pendingIndent.get(customRetailer.getKey());
|
1795 |
Map<String, Double> pendingIndentBrand = pendingIndent.get(customRetailer.getKey());
|
| 1796 |
Map<String, Double> grnBrand = grnPendingOrders.get(customRetailer.getKey());
|
1796 |
Map<String, Double> grnBrand = grnPendingOrders.get(customRetailer.getKey());
|
| 1797 |
double totalAmount = 0;
|
1797 |
double totalAmount = 0;
|
| 1798 |
|
1798 |
|
| 1799 |
Map<String, Double> brandAmountMap = new HashMap<>();
|
1799 |
Map<String, Double> brandAmountMap = new HashMap<>();
|
| 1800 |
for (String brand : brands) {
|
1800 |
for (String brand : brands) {
|
| 1801 |
|
1801 |
|
| 1802 |
double stockValue = 0;
|
1802 |
double stockValue = 0;
|
| 1803 |
double pendingValue = 0;
|
1803 |
double pendingValue = 0;
|
| 1804 |
double grnValue = 0;
|
1804 |
double grnValue = 0;
|
| 1805 |
if (stockBrand != null) {
|
1805 |
if (stockBrand != null) {
|
| 1806 |
|
1806 |
|
| 1807 |
if (stockBrand.get(brand) != null) {
|
1807 |
if (stockBrand.get(brand) != null) {
|
| 1808 |
stockValue = stockBrand.get(brand);
|
1808 |
stockValue = stockBrand.get(brand);
|
| 1809 |
}
|
1809 |
}
|
| 1810 |
}
|
1810 |
}
|
| 1811 |
|
1811 |
|
| 1812 |
if (pendingIndentBrand != null) {
|
1812 |
if (pendingIndentBrand != null) {
|
| 1813 |
if (pendingIndentBrand.get(brand) != null) {
|
1813 |
if (pendingIndentBrand.get(brand) != null) {
|
| 1814 |
pendingValue = pendingIndentBrand.get(brand);
|
1814 |
pendingValue = pendingIndentBrand.get(brand);
|
| 1815 |
}
|
1815 |
}
|
| 1816 |
}
|
1816 |
}
|
| 1817 |
|
1817 |
|
| 1818 |
if (grnBrand != null) {
|
1818 |
if (grnBrand != null) {
|
| 1819 |
if (grnBrand.get(brand) != null) {
|
1819 |
if (grnBrand.get(brand) != null) {
|
| 1820 |
grnValue = grnBrand.get(brand);
|
1820 |
grnValue = grnBrand.get(brand);
|
| 1821 |
}
|
1821 |
}
|
| 1822 |
}
|
1822 |
}
|
| 1823 |
|
1823 |
|
| 1824 |
totalAmount = stockValue + pendingValue + grnValue;
|
1824 |
totalAmount = stockValue + pendingValue + grnValue;
|
| 1825 |
|
1825 |
|
| 1826 |
brandAmountMap.put(brand, totalAmount);
|
1826 |
brandAmountMap.put(brand, totalAmount);
|
| 1827 |
|
1827 |
|
| 1828 |
}
|
1828 |
}
|
| 1829 |
|
1829 |
|
| 1830 |
fofoIdBrandAmountMap.put(customRetailer.getKey(), brandAmountMap);
|
1830 |
fofoIdBrandAmountMap.put(customRetailer.getKey(), brandAmountMap);
|
| 1831 |
|
1831 |
|
| 1832 |
}
|
1832 |
}
|
| 1833 |
|
1833 |
|
| 1834 |
List<PartnerDailyInvestment> partnerDailyInvestments = partnerDailyInvestmentRepository
|
1834 |
List<PartnerDailyInvestment> partnerDailyInvestments = partnerDailyInvestmentRepository
|
| 1835 |
.selectAll(new ArrayList<>(fofoIdList), LocalDate.now().minusDays(1));
|
1835 |
.selectAll(new ArrayList<>(fofoIdList), LocalDate.now().minusDays(1));
|
| 1836 |
if (!partnerDailyInvestments.isEmpty()) {
|
1836 |
if (!partnerDailyInvestments.isEmpty()) {
|
| 1837 |
partnerDailyInvestmentMap = partnerDailyInvestments.stream()
|
1837 |
partnerDailyInvestmentMap = partnerDailyInvestments.stream()
|
| 1838 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
1838 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 1839 |
}
|
1839 |
}
|
| 1840 |
|
1840 |
|
| 1841 |
}
|
1841 |
}
|
| 1842 |
|
1842 |
//Only L3 and above can change the activationType
|
| 1843 |
model.addAttribute("customRetailers", customRetailers);
|
1843 |
|
| 1844 |
|
1844 |
model.addAttribute("customRetailers", customRetailers);
|
| 1845 |
LOGGER.info("fofoIdBrandAmountMap" + fofoIdBrandAmountMap);
|
1845 |
|
| 1846 |
|
1846 |
LOGGER.info("fofoIdBrandAmountMap" + fofoIdBrandAmountMap);
|
| 1847 |
model.addAttribute("partnerDailyInvestmentMap", partnerDailyInvestmentMap);
|
1847 |
|
| 1848 |
|
1848 |
model.addAttribute("partnerDailyInvestmentMap", partnerDailyInvestmentMap);
|
| 1849 |
model.addAttribute("brands", brands);
|
1849 |
|
| 1850 |
|
1850 |
model.addAttribute("brands", brands);
|
| 1851 |
model.addAttribute("brandAmountLimit", Brand_Amount_Limit);
|
1851 |
|
| 1852 |
model.addAttribute("fofoIdBrandAmountMap", fofoIdBrandAmountMap);
|
1852 |
model.addAttribute("brandAmountLimit", Brand_Amount_Limit);
|
| 1853 |
|
1853 |
model.addAttribute("fofoIdBrandAmountMap", fofoIdBrandAmountMap);
|
| 1854 |
model.addAttribute("inStockAccessTv", inStockAccessTv);
|
1854 |
|
| 1855 |
model.addAttribute("pendingIndentAccessTv", pendingIndentAccessTv);
|
1855 |
model.addAttribute("inStockAccessTv", inStockAccessTv);
|
| 1856 |
model.addAttribute("grnPendingAccessTvOrders", grnPendingAccessTvOrders);
|
1856 |
model.addAttribute("pendingIndentAccessTv", pendingIndentAccessTv);
|
| 1857 |
model.addAttribute("fofoIdPartnerTypeMap", fofoIdPartnerTypeMap);
|
1857 |
model.addAttribute("grnPendingAccessTvOrders", grnPendingAccessTvOrders);
|
| 1858 |
return "partner-brandwise-detail";
|
1858 |
model.addAttribute("fofoIdPartnerTypeMap", fofoIdPartnerTypeMap);
|
| 1859 |
}
|
1859 |
|
| 1860 |
|
1860 |
|
| 1861 |
@RequestMapping(value = "/changeActivationType", method = RequestMethod.POST)
|
1861 |
return "partner-brandwise-detail";
|
| 1862 |
public String changeActivationType(HttpServletRequest request, @RequestParam String code,
|
1862 |
}
|
| 1863 |
@RequestParam ActivationType activationType, Model model) throws Exception {
|
1863 |
|
| 1864 |
|
1864 |
@RequestMapping(value = "/changeActivationType", method = RequestMethod.POST)
|
| 1865 |
FofoStore fofoStore = fofoStoreRepository.selectByStoreCode(code);
|
1865 |
public String changeActivationType(HttpServletRequest request, @RequestParam String code,
|
| 1866 |
|
1866 |
@RequestParam ActivationType activationType, Model model) throws Exception {
|
| 1867 |
fofoStore.setActivationType(activationType);
|
1867 |
|
| 1868 |
|
1868 |
FofoStore fofoStore = fofoStoreRepository.selectByStoreCode(code);
|
| 1869 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
1869 |
|
| 1870 |
return "response";
|
1870 |
fofoStore.setActivationType(activationType);
|
| 1871 |
|
1871 |
|
| 1872 |
}
|
1872 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 1873 |
|
1873 |
return "response";
|
| 1874 |
@RequestMapping(value = "/createPo", method = RequestMethod.POST)
|
1874 |
|
| 1875 |
public String createPo(HttpServletRequest request, @RequestBody SuggestedPoModel monthlyPoModel, Model model)
|
1875 |
}
|
| 1876 |
throws Exception {
|
1876 |
|
| 1877 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
1877 |
@RequestMapping(value = "/createPo", method = RequestMethod.POST)
|
| 1878 |
SuggestedPo mp = new SuggestedPo();
|
1878 |
public String createPo(HttpServletRequest request, @RequestBody SuggestedPoModel monthlyPoModel, Model model)
|
| 1879 |
mp.setFofoId(monthlyPoModel.getFofoId());
|
1879 |
throws Exception {
|
| 1880 |
mp.setCreateTimestamp(LocalDateTime.now());
|
1880 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 1881 |
mp.setStatus("open");
|
1881 |
SuggestedPo mp = new SuggestedPo();
|
| 1882 |
mp.setAuthId(loginDetails.getEmailId());
|
1882 |
mp.setFofoId(monthlyPoModel.getFofoId());
|
| 1883 |
suggestedPoRepository.persist(mp);
|
1883 |
mp.setCreateTimestamp(LocalDateTime.now());
|
| 1884 |
|
1884 |
mp.setStatus("open");
|
| 1885 |
for (SuggestedPoIdModel poId : monthlyPoModel.getPoIds()) {
|
1885 |
mp.setAuthId(loginDetails.getEmailId());
|
| 1886 |
SuggestedPoDetail mpd = new SuggestedPoDetail();
|
1886 |
suggestedPoRepository.persist(mp);
|
| 1887 |
mpd.setItemId(poId.getItemId());
|
1887 |
|
| 1888 |
mpd.setQuantity(poId.getQty());
|
1888 |
for (SuggestedPoIdModel poId : monthlyPoModel.getPoIds()) {
|
| 1889 |
mpd.setUpdatedTimestamp(LocalDateTime.now());
|
1889 |
SuggestedPoDetail mpd = new SuggestedPoDetail();
|
| 1890 |
mpd.setPoId(mp.getId());
|
1890 |
mpd.setItemId(poId.getItemId());
|
| 1891 |
suggestedPoDetailRepository.persist(mpd);
|
1891 |
mpd.setQuantity(poId.getQty());
|
| 1892 |
}
|
1892 |
mpd.setUpdatedTimestamp(LocalDateTime.now());
|
| 1893 |
|
1893 |
mpd.setPoId(mp.getId());
|
| 1894 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
1894 |
suggestedPoDetailRepository.persist(mpd);
|
| 1895 |
sendNotificationModel.setCampaignName("Alert");
|
1895 |
}
|
| 1896 |
sendNotificationModel.setMessage("Suggested Po");
|
1896 |
|
| 1897 |
sendNotificationModel.setType("url");
|
1897 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| 1898 |
sendNotificationModel.setTitle("Alert");
|
1898 |
sendNotificationModel.setCampaignName("Alert");
|
| 1899 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/partnerPo/" + mp.getId());
|
1899 |
sendNotificationModel.setMessage("Suggested Po");
|
| 1900 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
|
1900 |
sendNotificationModel.setType("url");
|
| 1901 |
sendNotificationModel.setMessageType(MessageType.notification);
|
1901 |
sendNotificationModel.setTitle("Alert");
|
| 1902 |
int userId = userAccountRepository.selectUserIdByRetailerId(monthlyPoModel.getFofoId());
|
1902 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/partnerPo/" + mp.getId());
|
| 1903 |
|
1903 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
|
| 1904 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
1904 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| 1905 |
notificationService.sendNotification(sendNotificationModel);
|
1905 |
int userId = userAccountRepository.selectUserIdByRetailerId(monthlyPoModel.getFofoId());
|
| 1906 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
1906 |
|
| 1907 |
|
1907 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
| 1908 |
return "response";
|
1908 |
notificationService.sendNotification(sendNotificationModel);
|
| 1909 |
}
|
1909 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 1910 |
|
1910 |
|
| 1911 |
@RequestMapping(value = "/getPartnerShortageStock", method = RequestMethod.GET)
|
1911 |
return "response";
|
| 1912 |
public String getPartnerShortageStock(HttpServletRequest request,
|
1912 |
}
|
| 1913 |
@RequestParam(required = false, defaultValue = "") String brand, @RequestParam int fofoId, Model model)
|
1913 |
|
| 1914 |
throws Exception {
|
1914 |
@RequestMapping(value = "/getPartnerShortageStock", method = RequestMethod.GET)
|
| 1915 |
|
1915 |
public String getPartnerShortageStock(HttpServletRequest request,
|
| 1916 |
Map<Integer, Map<Integer, List<SaholicPOItem>>> warehousePoItemAvailabilityMap = saholicInventoryService
|
1916 |
@RequestParam(required = false, defaultValue = "") String brand, @RequestParam int fofoId, Model model)
|
| 1917 |
.getSaholicPOItems();
|
1917 |
throws Exception {
|
| 1918 |
|
1918 |
|
| 1919 |
List<FocusedModelShortageModel> focusedModelShortageList = new ArrayList<>();
|
1919 |
Map<Integer, Map<Integer, List<SaholicPOItem>>> warehousePoItemAvailabilityMap = saholicInventoryService
|
| 1920 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
1920 |
.getSaholicPOItems();
|
| 1921 |
Map<Integer, Integer> processingOrderMap = null;
|
1921 |
|
| 1922 |
Map<Integer, Integer> catalogIdAndQtyMap = null;
|
1922 |
List<FocusedModelShortageModel> focusedModelShortageList = new ArrayList<>();
|
| 1923 |
Map<Integer, Integer> grnPendingOrdersMap = null;
|
1923 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
| 1924 |
|
1924 |
Map<Integer, Integer> processingOrderMap = null;
|
| 1925 |
List<PartnerStockDescriptionModel> inStocks = new ArrayList<>();
|
1925 |
Map<Integer, Integer> catalogIdAndQtyMap = null;
|
| 1926 |
|
1926 |
Map<Integer, Integer> grnPendingOrdersMap = null;
|
| 1927 |
List<PartnerStockDescriptionModel> grnPendings = new ArrayList<>();
|
1927 |
|
| 1928 |
|
1928 |
List<PartnerStockDescriptionModel> inStocks = new ArrayList<>();
|
| 1929 |
List<PartnerStockDescriptionModel> pendingIndents = new ArrayList<>();
|
1929 |
|
| 1930 |
|
1930 |
List<PartnerStockDescriptionModel> grnPendings = new ArrayList<>();
|
| 1931 |
Map<Integer, Integer> currentInventorySnapshot = currentInventorySnapshotRepository.selectByFofoId(fofoId)
|
1931 |
|
| 1932 |
.stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x.getAvailability()));
|
1932 |
List<PartnerStockDescriptionModel> pendingIndents = new ArrayList<>();
|
| 1933 |
|
1933 |
|
| 1934 |
if (!currentInventorySnapshot.isEmpty()) {
|
1934 |
Map<Integer, Integer> currentInventorySnapshot = currentInventorySnapshotRepository.selectByFofoId(fofoId)
|
| 1935 |
if (!brand.equals("undefined") && !brand.equals("accessories") && !brand.equals("TV")) {
|
1935 |
.stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x.getAvailability()));
|
| 1936 |
catalogIdAndQtyMap = itemRepository.selectByIds(currentInventorySnapshot.keySet()).stream()
|
1936 |
|
| 1937 |
.filter(x -> x.getBrand().equals(brand))
|
1937 |
if (!currentInventorySnapshot.isEmpty()) {
|
| 1938 |
.collect(Collectors.groupingBy(x -> x.getCatalogItemId(),
|
1938 |
if (!brand.equals("undefined") && !brand.equals("accessories") && !brand.equals("TV")) {
|
| 1939 |
Collectors.summingInt(x -> currentInventorySnapshot.get(x.getId()))));
|
1939 |
catalogIdAndQtyMap = itemRepository.selectByIds(currentInventorySnapshot.keySet()).stream()
|
| 1940 |
|
1940 |
.filter(x -> x.getBrand().equals(brand))
|
| 1941 |
} else {
|
1941 |
.collect(Collectors.groupingBy(x -> x.getCatalogItemId(),
|
| 1942 |
catalogIdAndQtyMap = itemRepository.selectByIds(currentInventorySnapshot.keySet()).stream()
|
1942 |
Collectors.summingInt(x -> currentInventorySnapshot.get(x.getId()))));
|
| 1943 |
.collect(Collectors.groupingBy(x -> x.getCatalogItemId(),
|
1943 |
|
| 1944 |
Collectors.summingInt(x -> currentInventorySnapshot.get(x.getId()))));
|
1944 |
} else {
|
| 1945 |
}
|
1945 |
catalogIdAndQtyMap = itemRepository.selectByIds(currentInventorySnapshot.keySet()).stream()
|
| 1946 |
inStocks.addAll(getBrandItemwiseDescription(brand, catalogIdAndQtyMap));
|
1946 |
.collect(Collectors.groupingBy(x -> x.getCatalogItemId(),
|
| 1947 |
}
|
1947 |
Collectors.summingInt(x -> currentInventorySnapshot.get(x.getId()))));
|
| 1948 |
|
1948 |
}
|
| 1949 |
Map<Integer, Integer> grnPendingOrders = orderRepository.selectPendingGrnOrders(fofoId).stream()
|
1949 |
inStocks.addAll(getBrandItemwiseDescription(brand, catalogIdAndQtyMap));
|
| 1950 |
.collect(Collectors.groupingBy(x -> x.getLineItem().getItemId(),
|
1950 |
}
|
| 1951 |
Collectors.summingInt(x -> x.getLineItem().getQuantity())));
|
1951 |
|
| 1952 |
if (!grnPendingOrders.isEmpty()) {
|
1952 |
Map<Integer, Integer> grnPendingOrders = orderRepository.selectPendingGrnOrders(fofoId).stream()
|
| 1953 |
|
1953 |
.collect(Collectors.groupingBy(x -> x.getLineItem().getItemId(),
|
| 1954 |
if (!brand.equals("undefined") && !brand.equals("accessories") && !brand.equals("TV")) {
|
1954 |
Collectors.summingInt(x -> x.getLineItem().getQuantity())));
|
| 1955 |
grnPendingOrdersMap = itemRepository.selectByIds(grnPendingOrders.keySet()).stream()
|
1955 |
if (!grnPendingOrders.isEmpty()) {
|
| 1956 |
.filter(x -> x.getBrand().equals(brand))
|
1956 |
|
| 1957 |
.collect(Collectors.groupingBy(x -> x.getCatalogItemId(),
|
1957 |
if (!brand.equals("undefined") && !brand.equals("accessories") && !brand.equals("TV")) {
|
| 1958 |
Collectors.summingInt(x -> grnPendingOrders.get(x.getId()))));
|
1958 |
grnPendingOrdersMap = itemRepository.selectByIds(grnPendingOrders.keySet()).stream()
|
| 1959 |
|
1959 |
.filter(x -> x.getBrand().equals(brand))
|
| 1960 |
} else {
|
1960 |
.collect(Collectors.groupingBy(x -> x.getCatalogItemId(),
|
| 1961 |
grnPendingOrdersMap = itemRepository.selectByIds(grnPendingOrders.keySet()).stream()
|
1961 |
Collectors.summingInt(x -> grnPendingOrders.get(x.getId()))));
|
| 1962 |
.collect(Collectors.groupingBy(x -> x.getCatalogItemId(),
|
1962 |
|
| 1963 |
Collectors.summingInt(x -> grnPendingOrders.get(x.getId()))));
|
1963 |
} else {
|
| 1964 |
}
|
1964 |
grnPendingOrdersMap = itemRepository.selectByIds(grnPendingOrders.keySet()).stream()
|
| 1965 |
grnPendings.addAll(getBrandItemwiseDescription(brand, grnPendingOrdersMap));
|
1965 |
.collect(Collectors.groupingBy(x -> x.getCatalogItemId(),
|
| 1966 |
|
1966 |
Collectors.summingInt(x -> grnPendingOrders.get(x.getId()))));
|
| 1967 |
}
|
1967 |
}
|
| 1968 |
|
1968 |
grnPendings.addAll(getBrandItemwiseDescription(brand, grnPendingOrdersMap));
|
| 1969 |
Map<Integer, Integer> processingOrder = orderRepository.selectOrders(fofoId, orderStatusList).stream()
|
1969 |
|
| 1970 |
.collect(Collectors.groupingBy(x -> x.getLineItem().getItemId(),
|
1970 |
}
|
| 1971 |
Collectors.summingInt(x -> x.getLineItem().getQuantity())));
|
1971 |
|
| 1972 |
if (!processingOrder.isEmpty()) {
|
1972 |
Map<Integer, Integer> processingOrder = orderRepository.selectOrders(fofoId, orderStatusList).stream()
|
| 1973 |
if (!brand.equals("undefined") && !brand.equals("accessories") && !brand.equals("TV")) {
|
1973 |
.collect(Collectors.groupingBy(x -> x.getLineItem().getItemId(),
|
| 1974 |
processingOrderMap = itemRepository.selectByIds(processingOrder.keySet()).stream()
|
1974 |
Collectors.summingInt(x -> x.getLineItem().getQuantity())));
|
| 1975 |
.filter(x -> x.getBrand().equals(brand)).collect(Collectors.groupingBy(
|
1975 |
if (!processingOrder.isEmpty()) {
|
| 1976 |
x -> x.getCatalogItemId(), Collectors.summingInt(x -> processingOrder.get(x.getId()))));
|
1976 |
if (!brand.equals("undefined") && !brand.equals("accessories") && !brand.equals("TV")) {
|
| 1977 |
|
1977 |
processingOrderMap = itemRepository.selectByIds(processingOrder.keySet()).stream()
|
| 1978 |
} else {
|
1978 |
.filter(x -> x.getBrand().equals(brand)).collect(Collectors.groupingBy(
|
| 1979 |
processingOrderMap = itemRepository.selectByIds(processingOrder.keySet()).stream()
|
1979 |
x -> x.getCatalogItemId(), Collectors.summingInt(x -> processingOrder.get(x.getId()))));
|
| 1980 |
.collect(Collectors.groupingBy(x -> x.getCatalogItemId(),
|
1980 |
|
| 1981 |
Collectors.summingInt(x -> processingOrder.get(x.getId()))));
|
1981 |
} else {
|
| 1982 |
}
|
1982 |
processingOrderMap = itemRepository.selectByIds(processingOrder.keySet()).stream()
|
| 1983 |
pendingIndents.addAll(getBrandItemwiseDescription(brand, processingOrderMap));
|
1983 |
.collect(Collectors.groupingBy(x -> x.getCatalogItemId(),
|
| 1984 |
|
1984 |
Collectors.summingInt(x -> processingOrder.get(x.getId()))));
|
| 1985 |
}
|
1985 |
}
|
| 1986 |
|
1986 |
pendingIndents.addAll(getBrandItemwiseDescription(brand, processingOrderMap));
|
| 1987 |
List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId())
|
1987 |
|
| 1988 |
.collect(Collectors.toList());
|
1988 |
}
|
| 1989 |
LOGGER.info("regionIds" + regionIds);
|
1989 |
|
| 1990 |
if (regionIds.size() == 0) {
|
1990 |
List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId())
|
| 1991 |
LOGGER.info("No region found for partner {}", fofoId);
|
1991 |
.collect(Collectors.toList());
|
| 1992 |
|
1992 |
LOGGER.info("regionIds" + regionIds);
|
| 1993 |
}
|
1993 |
if (regionIds.size() == 0) {
|
| 1994 |
Map<Integer, Optional<Integer>> focusedCatalogIdAndQtyMap = focusedModelRepository
|
1994 |
LOGGER.info("No region found for partner {}", fofoId);
|
| 1995 |
.selectAllByRegionIds(regionIds).stream().collect(Collectors.groupingBy(FocusedModel::getCatalogId,
|
1995 |
|
| 1996 |
Collectors.mapping(FocusedModel::getObsMinimumQty, Collectors.maxBy(Integer::compareTo))));
|
1996 |
}
|
| 1997 |
|
1997 |
Map<Integer, Optional<Integer>> focusedCatalogIdAndQtyMap = focusedModelRepository
|
| 1998 |
for (Map.Entry<Integer, Optional<Integer>> entry : focusedCatalogIdAndQtyMap.entrySet()) {
|
1998 |
.selectAllByRegionIds(regionIds).stream().collect(Collectors.groupingBy(FocusedModel::getCatalogId,
|
| 1999 |
List<Item> items = itemRepository.selectAllByCatalogItemId(entry.getKey());
|
1999 |
Collectors.mapping(FocusedModel::getObsMinimumQty, Collectors.maxBy(Integer::compareTo))));
|
| 2000 |
|
2000 |
|
| 2001 |
if (brand.equals("undefined") || items.get(0).getBrand().equals(brand)) {
|
2001 |
for (Map.Entry<Integer, Optional<Integer>> entry : focusedCatalogIdAndQtyMap.entrySet()) {
|
| 2002 |
|
2002 |
List<Item> items = itemRepository.selectAllByCatalogItemId(entry.getKey());
|
| 2003 |
FocusedModelShortageModel fm = this.getFocusedModelShortage(entry.getValue().get(), entry.getKey(),
|
2003 |
|
| 2004 |
processingOrderMap, grnPendingOrdersMap, catalogIdAndQtyMap, fofoId,
|
2004 |
if (brand.equals("undefined") || items.get(0).getBrand().equals(brand)) {
|
| 2005 |
warehousePoItemAvailabilityMap, items, customRetailer);
|
2005 |
|
| 2006 |
|
2006 |
FocusedModelShortageModel fm = this.getFocusedModelShortage(entry.getValue().get(), entry.getKey(),
|
| 2007 |
focusedModelShortageList.add(fm);
|
2007 |
processingOrderMap, grnPendingOrdersMap, catalogIdAndQtyMap, fofoId,
|
| 2008 |
} else if (brand.equals("accessories")) {
|
2008 |
warehousePoItemAvailabilityMap, items, customRetailer);
|
| 2009 |
|
2009 |
|
| 2010 |
if (items.get(0).getCategoryId() != ProfitMandiConstants.MOBILE_CATEGORY_ID) {
|
2010 |
focusedModelShortageList.add(fm);
|
| 2011 |
if (items.get(0).getCategoryId() != 0) {
|
2011 |
} else if (brand.equals("accessories")) {
|
| 2012 |
Category category = categoryRepository.selectById(items.get(0).getCategoryId());
|
2012 |
|
| 2013 |
|
2013 |
if (items.get(0).getCategoryId() != ProfitMandiConstants.MOBILE_CATEGORY_ID) {
|
| 2014 |
if (category.getParentCategoryId() == 10011) {
|
2014 |
if (items.get(0).getCategoryId() != 0) {
|
| 2015 |
FocusedModelShortageModel fm = this.getFocusedModelShortage(entry.getValue().get(),
|
2015 |
Category category = categoryRepository.selectById(items.get(0).getCategoryId());
|
| 2016 |
entry.getKey(), processingOrderMap, grnPendingOrdersMap, catalogIdAndQtyMap, fofoId,
|
2016 |
|
| 2017 |
warehousePoItemAvailabilityMap, items, customRetailer);
|
2017 |
if (category.getParentCategoryId() == 10011) {
|
| 2018 |
|
2018 |
FocusedModelShortageModel fm = this.getFocusedModelShortage(entry.getValue().get(),
|
| 2019 |
focusedModelShortageList.add(fm);
|
2019 |
entry.getKey(), processingOrderMap, grnPendingOrdersMap, catalogIdAndQtyMap, fofoId,
|
| 2020 |
|
2020 |
warehousePoItemAvailabilityMap, items, customRetailer);
|
| 2021 |
}
|
2021 |
|
| 2022 |
}
|
2022 |
focusedModelShortageList.add(fm);
|
| 2023 |
|
2023 |
|
| 2024 |
}
|
2024 |
}
|
| 2025 |
|
2025 |
}
|
| 2026 |
} else if (brand.equals("TV")) {
|
2026 |
|
| 2027 |
|
2027 |
}
|
| 2028 |
if (items.get(0).getCategoryId() != ProfitMandiConstants.MOBILE_CATEGORY_ID) {
|
2028 |
|
| 2029 |
LOGGER.info("items.get(0).getCategoryId()" + items.get(0).getCategoryId());
|
2029 |
} else if (brand.equals("TV")) {
|
| 2030 |
if (items.get(0).getCategoryId() != 0) {
|
2030 |
|
| 2031 |
|
2031 |
if (items.get(0).getCategoryId() != ProfitMandiConstants.MOBILE_CATEGORY_ID) {
|
| 2032 |
Category category = categoryRepository.selectById(items.get(0).getCategoryId());
|
2032 |
LOGGER.info("items.get(0).getCategoryId()" + items.get(0).getCategoryId());
|
| 2033 |
|
2033 |
if (items.get(0).getCategoryId() != 0) {
|
| 2034 |
if (category.getParentCategoryId() == 14200) {
|
2034 |
|
| 2035 |
FocusedModelShortageModel fm = this.getFocusedModelShortage(entry.getValue().get(),
|
2035 |
Category category = categoryRepository.selectById(items.get(0).getCategoryId());
|
| 2036 |
entry.getKey(), processingOrderMap, grnPendingOrdersMap, catalogIdAndQtyMap, fofoId,
|
2036 |
|
| 2037 |
warehousePoItemAvailabilityMap, items, customRetailer);
|
2037 |
if (category.getParentCategoryId() == 14200) {
|
| 2038 |
|
2038 |
FocusedModelShortageModel fm = this.getFocusedModelShortage(entry.getValue().get(),
|
| 2039 |
focusedModelShortageList.add(fm);
|
2039 |
entry.getKey(), processingOrderMap, grnPendingOrdersMap, catalogIdAndQtyMap, fofoId,
|
| 2040 |
|
2040 |
warehousePoItemAvailabilityMap, items, customRetailer);
|
| 2041 |
}
|
2041 |
|
| 2042 |
}
|
2042 |
focusedModelShortageList.add(fm);
|
| 2043 |
|
2043 |
|
| 2044 |
}
|
2044 |
}
|
| 2045 |
|
2045 |
}
|
| 2046 |
}
|
2046 |
|
| 2047 |
|
2047 |
}
|
| 2048 |
}
|
2048 |
|
| 2049 |
|
2049 |
}
|
| 2050 |
LOGGER.info("focusedModelShortageList" + focusedModelShortageList);
|
2050 |
|
| 2051 |
|
2051 |
}
|
| 2052 |
model.addAttribute("focusedModelShortageList", focusedModelShortageList);
|
2052 |
|
| 2053 |
|
2053 |
LOGGER.info("focusedModelShortageList" + focusedModelShortageList);
|
| 2054 |
model.addAttribute("inStocks", inStocks);
|
2054 |
|
| 2055 |
|
2055 |
model.addAttribute("focusedModelShortageList", focusedModelShortageList);
|
| 2056 |
model.addAttribute("grnPendings", grnPendings);
|
2056 |
|
| 2057 |
|
2057 |
model.addAttribute("inStocks", inStocks);
|
| 2058 |
model.addAttribute("pendingIndents", pendingIndents);
|
2058 |
|
| 2059 |
|
2059 |
model.addAttribute("grnPendings", grnPendings);
|
| 2060 |
model.addAttribute("customRetailer", customRetailer);
|
2060 |
|
| 2061 |
|
2061 |
model.addAttribute("pendingIndents", pendingIndents);
|
| 2062 |
model.addAttribute("brand", brand);
|
2062 |
|
| 2063 |
|
2063 |
model.addAttribute("customRetailer", customRetailer);
|
| 2064 |
if (brand.equals("undefined")) {
|
2064 |
|
| 2065 |
|
2065 |
model.addAttribute("brand", brand);
|
| 2066 |
Map<String, List<FocusedModelShortageModel>> focusedModelShortageBrandMap = focusedModelShortageList
|
2066 |
|
| 2067 |
.stream().collect(Collectors.groupingBy(x -> x.getBrandName()));
|
2067 |
if (brand.equals("undefined")) {
|
| 2068 |
|
2068 |
|
| 2069 |
Map<String, List<PartnerStockDescriptionModel>> inStockBrandMap = inStocks.stream()
|
2069 |
Map<String, List<FocusedModelShortageModel>> focusedModelShortageBrandMap = focusedModelShortageList
|
| 2070 |
.collect(Collectors.groupingBy(x -> x.getBrand()));
|
2070 |
.stream().collect(Collectors.groupingBy(x -> x.getBrandName()));
|
| 2071 |
|
2071 |
|
| 2072 |
LOGGER.info("inStockBrandMap" + inStockBrandMap);
|
2072 |
Map<String, List<PartnerStockDescriptionModel>> inStockBrandMap = inStocks.stream()
|
| 2073 |
|
2073 |
.collect(Collectors.groupingBy(x -> x.getBrand()));
|
| 2074 |
Map<String, List<PartnerStockDescriptionModel>> grnPendingBrandMap = grnPendings.stream()
|
2074 |
|
| 2075 |
.collect(Collectors.groupingBy(x -> x.getBrand()));
|
2075 |
LOGGER.info("inStockBrandMap" + inStockBrandMap);
|
| 2076 |
|
2076 |
|
| 2077 |
LOGGER.info("grnPendingBrandMap" + grnPendingBrandMap);
|
2077 |
Map<String, List<PartnerStockDescriptionModel>> grnPendingBrandMap = grnPendings.stream()
|
| 2078 |
|
2078 |
.collect(Collectors.groupingBy(x -> x.getBrand()));
|
| 2079 |
Map<String, List<PartnerStockDescriptionModel>> pendingIndentBrandMap = pendingIndents.stream()
|
2079 |
|
| 2080 |
.collect(Collectors.groupingBy(x -> x.getBrand()));
|
2080 |
LOGGER.info("grnPendingBrandMap" + grnPendingBrandMap);
|
| 2081 |
|
2081 |
|
| 2082 |
LOGGER.info("pendingIndentBrandMap" + pendingIndentBrandMap);
|
2082 |
Map<String, List<PartnerStockDescriptionModel>> pendingIndentBrandMap = pendingIndents.stream()
|
| 2083 |
|
2083 |
.collect(Collectors.groupingBy(x -> x.getBrand()));
|
| 2084 |
model.addAttribute("inStockBrandMap", inStockBrandMap);
|
2084 |
|
| 2085 |
|
2085 |
LOGGER.info("pendingIndentBrandMap" + pendingIndentBrandMap);
|
| 2086 |
model.addAttribute("grnPendingBrandMap", grnPendingBrandMap);
|
2086 |
|
| 2087 |
|
2087 |
model.addAttribute("inStockBrandMap", inStockBrandMap);
|
| 2088 |
model.addAttribute("focusedModelShortageBrandMap", focusedModelShortageBrandMap);
|
2088 |
|
| 2089 |
|
2089 |
model.addAttribute("grnPendingBrandMap", grnPendingBrandMap);
|
| 2090 |
model.addAttribute("pendingIndentBrandMap", pendingIndentBrandMap);
|
2090 |
|
| 2091 |
|
2091 |
model.addAttribute("focusedModelShortageBrandMap", focusedModelShortageBrandMap);
|
| 2092 |
}
|
2092 |
|
| 2093 |
return "partner-stock";
|
2093 |
model.addAttribute("pendingIndentBrandMap", pendingIndentBrandMap);
|
| 2094 |
|
2094 |
|
| 2095 |
}
|
2095 |
}
|
| 2096 |
|
2096 |
return "partner-stock";
|
| 2097 |
private List<PartnerStockDescriptionModel> getBrandItemwiseDescription(String brand,
|
2097 |
|
| 2098 |
Map<Integer, Integer> catalogIdAndQtyMap) throws ProfitMandiBusinessException {
|
2098 |
}
|
| 2099 |
List<PartnerStockDescriptionModel> inStocks = new ArrayList<>();
|
2099 |
|
| 2100 |
|
2100 |
private List<PartnerStockDescriptionModel> getBrandItemwiseDescription(String brand,
|
| 2101 |
for (Entry<Integer, Integer> inStock : catalogIdAndQtyMap.entrySet()) {
|
2101 |
Map<Integer, Integer> catalogIdAndQtyMap) throws ProfitMandiBusinessException {
|
| 2102 |
List<Item> items = itemRepository.selectAllByCatalogItemId(inStock.getKey());
|
2102 |
List<PartnerStockDescriptionModel> inStocks = new ArrayList<>();
|
| 2103 |
|
2103 |
|
| 2104 |
if (brand.equals("accessories")) {
|
2104 |
for (Entry<Integer, Integer> inStock : catalogIdAndQtyMap.entrySet()) {
|
| 2105 |
if (items.get(0).getCategoryId() != ProfitMandiConstants.MOBILE_CATEGORY_ID) {
|
2105 |
List<Item> items = itemRepository.selectAllByCatalogItemId(inStock.getKey());
|
| 2106 |
|
2106 |
|
| 2107 |
if (items.get(0).getCategoryId() != 0) {
|
2107 |
if (brand.equals("accessories")) {
|
| 2108 |
Category category = categoryRepository.selectById(items.get(0).getCategoryId());
|
2108 |
if (items.get(0).getCategoryId() != ProfitMandiConstants.MOBILE_CATEGORY_ID) {
|
| 2109 |
|
2109 |
|
| 2110 |
if (category.getParentCategoryId() == 10011) {
|
2110 |
if (items.get(0).getCategoryId() != 0) {
|
| 2111 |
PartnerStockDescriptionModel psdp = new PartnerStockDescriptionModel();
|
2111 |
Category category = categoryRepository.selectById(items.get(0).getCategoryId());
|
| 2112 |
psdp.setBrand(items.get(0).getBrand());
|
2112 |
|
| 2113 |
psdp.setItemDescription(items.get(0).getBrand() + " " + items.get(0).getModelName() + " "
|
2113 |
if (category.getParentCategoryId() == 10011) {
|
| 2114 |
+ items.get(0).getModelNumber());
|
2114 |
PartnerStockDescriptionModel psdp = new PartnerStockDescriptionModel();
|
| 2115 |
psdp.setQty(inStock.getValue());
|
2115 |
psdp.setBrand(items.get(0).getBrand());
|
| 2116 |
inStocks.add(psdp);
|
2116 |
psdp.setItemDescription(items.get(0).getBrand() + " " + items.get(0).getModelName() + " "
|
| 2117 |
}
|
2117 |
+ items.get(0).getModelNumber());
|
| 2118 |
}
|
2118 |
psdp.setQty(inStock.getValue());
|
| 2119 |
|
2119 |
inStocks.add(psdp);
|
| 2120 |
}
|
2120 |
}
|
| 2121 |
|
2121 |
}
|
| 2122 |
} else if (brand.equals("TV")) {
|
2122 |
|
| 2123 |
if (items.get(0).getCategoryId() != ProfitMandiConstants.MOBILE_CATEGORY_ID) {
|
2123 |
}
|
| 2124 |
|
2124 |
|
| 2125 |
if (items.get(0).getCategoryId() != 0) {
|
2125 |
} else if (brand.equals("TV")) {
|
| 2126 |
Category category = categoryRepository.selectById(items.get(0).getCategoryId());
|
2126 |
if (items.get(0).getCategoryId() != ProfitMandiConstants.MOBILE_CATEGORY_ID) {
|
| 2127 |
|
2127 |
|
| 2128 |
if (category.getParentCategoryId() == 14200) {
|
2128 |
if (items.get(0).getCategoryId() != 0) {
|
| 2129 |
PartnerStockDescriptionModel psdp = new PartnerStockDescriptionModel();
|
2129 |
Category category = categoryRepository.selectById(items.get(0).getCategoryId());
|
| 2130 |
psdp.setBrand(items.get(0).getBrand());
|
2130 |
|
| 2131 |
psdp.setItemDescription(items.get(0).getBrand() + " " + items.get(0).getModelName() + " "
|
2131 |
if (category.getParentCategoryId() == 14200) {
|
| 2132 |
+ items.get(0).getModelNumber());
|
2132 |
PartnerStockDescriptionModel psdp = new PartnerStockDescriptionModel();
|
| 2133 |
psdp.setQty(inStock.getValue());
|
2133 |
psdp.setBrand(items.get(0).getBrand());
|
| 2134 |
inStocks.add(psdp);
|
2134 |
psdp.setItemDescription(items.get(0).getBrand() + " " + items.get(0).getModelName() + " "
|
| 2135 |
}
|
2135 |
+ items.get(0).getModelNumber());
|
| 2136 |
}
|
2136 |
psdp.setQty(inStock.getValue());
|
| 2137 |
|
2137 |
inStocks.add(psdp);
|
| 2138 |
}
|
2138 |
}
|
| 2139 |
|
2139 |
}
|
| 2140 |
} else {
|
2140 |
|
| 2141 |
PartnerStockDescriptionModel psdp = new PartnerStockDescriptionModel();
|
2141 |
}
|
| 2142 |
psdp.setBrand(items.get(0).getBrand());
|
2142 |
|
| 2143 |
psdp.setItemDescription(items.get(0).getBrand() + " " + items.get(0).getModelName() + " "
|
2143 |
} else {
|
| 2144 |
+ items.get(0).getModelNumber());
|
2144 |
PartnerStockDescriptionModel psdp = new PartnerStockDescriptionModel();
|
| 2145 |
psdp.setQty(inStock.getValue());
|
2145 |
psdp.setBrand(items.get(0).getBrand());
|
| 2146 |
inStocks.add(psdp);
|
2146 |
psdp.setItemDescription(items.get(0).getBrand() + " " + items.get(0).getModelName() + " "
|
| 2147 |
}
|
2147 |
+ items.get(0).getModelNumber());
|
| 2148 |
|
2148 |
psdp.setQty(inStock.getValue());
|
| 2149 |
}
|
2149 |
inStocks.add(psdp);
|
| 2150 |
|
2150 |
}
|
| 2151 |
return inStocks;
|
2151 |
|
| 2152 |
}
|
2152 |
}
|
| 2153 |
|
2153 |
|
| 2154 |
private FocusedModelShortageModel getFocusedModelShortage(int qty, int catalogId,
|
2154 |
return inStocks;
|
| 2155 |
Map<Integer, Integer> processingOrderMap, Map<Integer, Integer> grnPendingOrdersMap,
|
2155 |
}
|
| 2156 |
Map<Integer, Integer> catalogIdAndQtyMap, int fofoId,
|
2156 |
|
| 2157 |
Map<Integer, Map<Integer, List<SaholicPOItem>>> warehousePoItemAvailabilityMap, List<Item> items,
|
2157 |
private FocusedModelShortageModel getFocusedModelShortage(int qty, int catalogId,
|
| 2158 |
CustomRetailer customRetailer) throws ProfitMandiBusinessException {
|
2158 |
Map<Integer, Integer> processingOrderMap, Map<Integer, Integer> grnPendingOrdersMap,
|
| 2159 |
|
2159 |
Map<Integer, Integer> catalogIdAndQtyMap, int fofoId,
|
| 2160 |
int minQty = qty;
|
2160 |
Map<Integer, Map<Integer, List<SaholicPOItem>>> warehousePoItemAvailabilityMap, List<Item> items,
|
| 2161 |
int inStockQty = 0;
|
2161 |
CustomRetailer customRetailer) throws ProfitMandiBusinessException {
|
| 2162 |
int processingQty = 0;
|
2162 |
|
| 2163 |
int grnPendingQty = 0;
|
2163 |
int minQty = qty;
|
| 2164 |
int allColorNetAvailability = 0;
|
2164 |
int inStockQty = 0;
|
| 2165 |
int allColorPoAvailability = 0;
|
2165 |
int processingQty = 0;
|
| 2166 |
if (processingOrderMap != null) {
|
2166 |
int grnPendingQty = 0;
|
| 2167 |
processingQty = (processingOrderMap.get(catalogId) == null) ? 0 : processingOrderMap.get(catalogId);
|
2167 |
int allColorNetAvailability = 0;
|
| 2168 |
|
2168 |
int allColorPoAvailability = 0;
|
| 2169 |
}
|
2169 |
if (processingOrderMap != null) {
|
| 2170 |
if (grnPendingOrdersMap != null) {
|
2170 |
processingQty = (processingOrderMap.get(catalogId) == null) ? 0 : processingOrderMap.get(catalogId);
|
| 2171 |
grnPendingQty = (grnPendingOrdersMap.get(catalogId) == null) ? 0 : grnPendingOrdersMap.get(catalogId);
|
2171 |
|
| 2172 |
|
2172 |
}
|
| 2173 |
}
|
2173 |
if (grnPendingOrdersMap != null) {
|
| 2174 |
if (catalogIdAndQtyMap != null) {
|
2174 |
grnPendingQty = (grnPendingOrdersMap.get(catalogId) == null) ? 0 : grnPendingOrdersMap.get(catalogId);
|
| 2175 |
inStockQty = (catalogIdAndQtyMap.get(catalogId) == null) ? 0 : catalogIdAndQtyMap.get(catalogId);
|
2175 |
|
| 2176 |
|
2176 |
}
|
| 2177 |
}
|
2177 |
if (catalogIdAndQtyMap != null) {
|
| 2178 |
|
2178 |
inStockQty = (catalogIdAndQtyMap.get(catalogId) == null) ? 0 : catalogIdAndQtyMap.get(catalogId);
|
| 2179 |
int grnStockQty = grnPendingQty + inStockQty;
|
2179 |
|
| 2180 |
int totalQty = processingQty + grnPendingQty + inStockQty;
|
2180 |
}
|
| 2181 |
|
2181 |
|
| 2182 |
int shortageQty = minQty - totalQty;
|
2182 |
int grnStockQty = grnPendingQty + inStockQty;
|
| 2183 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
2183 |
int totalQty = processingQty + grnPendingQty + inStockQty;
|
| 2184 |
|
2184 |
|
| 2185 |
Map<Integer, List<SaholicPOItem>> poItemAvailabilityMap = warehousePoItemAvailabilityMap
|
2185 |
int shortageQty = minQty - totalQty;
|
| 2186 |
.get(fofoStore.getWarehouseId());
|
2186 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
| 2187 |
|
2187 |
|
| 2188 |
for (Item it : items) {
|
2188 |
Map<Integer, List<SaholicPOItem>> poItemAvailabilityMap = warehousePoItemAvailabilityMap
|
| 2189 |
List<SaholicCISTable> currentAvailability = saholicCISTableRepository.selectByItemWarehouse(it.getId(),
|
2189 |
.get(fofoStore.getWarehouseId());
|
| 2190 |
fofoStore.getWarehouseId());
|
2190 |
|
| 2191 |
List<SaholicPOItem> poItemAvailability = null;
|
2191 |
for (Item it : items) {
|
| 2192 |
|
2192 |
List<SaholicCISTable> currentAvailability = saholicCISTableRepository.selectByItemWarehouse(it.getId(),
|
| 2193 |
if (poItemAvailabilityMap != null) {
|
2193 |
fofoStore.getWarehouseId());
|
| 2194 |
poItemAvailability = poItemAvailabilityMap.get(it.getId());
|
2194 |
List<SaholicPOItem> poItemAvailability = null;
|
| 2195 |
}
|
2195 |
|
| 2196 |
if (currentAvailability != null) {
|
2196 |
if (poItemAvailabilityMap != null) {
|
| 2197 |
allColorNetAvailability += currentAvailability.stream()
|
2197 |
poItemAvailability = poItemAvailabilityMap.get(it.getId());
|
| 2198 |
.collect(Collectors.summingInt(SaholicCISTable::getNetAvailability));
|
2198 |
}
|
| 2199 |
}
|
2199 |
if (currentAvailability != null) {
|
| 2200 |
|
2200 |
allColorNetAvailability += currentAvailability.stream()
|
| 2201 |
if (poItemAvailability != null) {
|
2201 |
.collect(Collectors.summingInt(SaholicCISTable::getNetAvailability));
|
| 2202 |
allColorPoAvailability += poItemAvailability.stream()
|
2202 |
}
|
| 2203 |
.collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty));
|
2203 |
|
| 2204 |
}
|
2204 |
if (poItemAvailability != null) {
|
| 2205 |
|
2205 |
allColorPoAvailability += poItemAvailability.stream()
|
| 2206 |
}
|
2206 |
.collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty));
|
| 2207 |
|
2207 |
}
|
| 2208 |
FocusedModelShortageModel fm = new FocusedModelShortageModel();
|
2208 |
|
| 2209 |
fm.setFofoId(fofoId);
|
2209 |
}
|
| 2210 |
fm.setStoreCode(fofoStore.getCode());
|
2210 |
|
| 2211 |
fm.setStoreName(customRetailer.getBusinessName());
|
2211 |
FocusedModelShortageModel fm = new FocusedModelShortageModel();
|
| 2212 |
fm.setBrandName(items.get(0).getBrand());
|
2212 |
fm.setFofoId(fofoId);
|
| 2213 |
fm.setModelName(items.get(0).getModelName());
|
2213 |
fm.setStoreCode(fofoStore.getCode());
|
| 2214 |
fm.setModelNumber(items.get(0).getModelNumber());
|
2214 |
fm.setStoreName(customRetailer.getBusinessName());
|
| 2215 |
fm.setGrnStockQty(grnStockQty);
|
2215 |
fm.setBrandName(items.get(0).getBrand());
|
| 2216 |
fm.setPendingIndentQty(processingQty);
|
2216 |
fm.setModelName(items.get(0).getModelName());
|
| 2217 |
fm.setShortageQty(shortageQty);
|
2217 |
fm.setModelNumber(items.get(0).getModelNumber());
|
| 2218 |
fm.setPoAvailability(allColorPoAvailability);
|
2218 |
fm.setGrnStockQty(grnStockQty);
|
| 2219 |
fm.setItemName(items.get(0).getBrand() + items.get(0).getModelNumber() + items.get(0).getModelName());
|
2219 |
fm.setPendingIndentQty(processingQty);
|
| 2220 |
fm.setAvailability(allColorNetAvailability);
|
2220 |
fm.setShortageQty(shortageQty);
|
| 2221 |
return fm;
|
2221 |
fm.setPoAvailability(allColorPoAvailability);
|
| 2222 |
|
2222 |
fm.setItemName(items.get(0).getBrand() + items.get(0).getModelNumber() + items.get(0).getModelName());
|
| 2223 |
}
|
2223 |
fm.setAvailability(allColorNetAvailability);
|
| 2224 |
|
2224 |
return fm;
|
| 2225 |
@RequestMapping(value = "/indent/send-po-notification", method = RequestMethod.GET)
|
2225 |
|
| 2226 |
public String SendPONotification(HttpServletRequest request, Model model) {
|
2226 |
}
|
| 2227 |
model.addAttribute("warehouses", ProfitMandiConstants.WAREHOUSE_MAP);
|
2227 |
|
| 2228 |
return "send-po-notification";
|
2228 |
@RequestMapping(value = "/indent/send-po-notification", method = RequestMethod.GET)
|
| 2229 |
}
|
2229 |
public String SendPONotification(HttpServletRequest request, Model model) {
|
| 2230 |
|
2230 |
model.addAttribute("warehouses", ProfitMandiConstants.WAREHOUSE_MAP);
|
| 2231 |
@RequestMapping(value = "/indent/send-po-notification", method = RequestMethod.POST)
|
2231 |
return "send-po-notification";
|
| 2232 |
public String sendPONotification(HttpServletRequest request, @RequestBody POItemWarehouseModel poItemWarehouseModel,
|
2232 |
}
|
| 2233 |
Model model) throws Exception {
|
2233 |
|
| 2234 |
|
2234 |
@RequestMapping(value = "/indent/send-po-notification", method = RequestMethod.POST)
|
| 2235 |
Map<Integer, Item> selectedCatalogItemMap = itemRepository
|
2235 |
public String sendPONotification(HttpServletRequest request, @RequestBody POItemWarehouseModel poItemWarehouseModel,
|
| 2236 |
.selectAllByCatalogIds(new HashSet<>(poItemWarehouseModel.getCatalogIds())).stream()
|
2236 |
Model model) throws Exception {
|
| 2237 |
.collect(Collectors.toMap(x -> x.getCatalogItemId(), x -> x, (existing, replacement) -> existing));
|
2237 |
|
| 2238 |
|
2238 |
Map<Integer, Item> selectedCatalogItemMap = itemRepository
|
| 2239 |
Set<String> brands = selectedCatalogItemMap.values().stream().map(x -> x.getBrand().toLowerCase())
|
2239 |
.selectAllByCatalogIds(new HashSet<>(poItemWarehouseModel.getCatalogIds())).stream()
|
| 2240 |
.collect(Collectors.toSet());
|
2240 |
.collect(Collectors.toMap(x -> x.getCatalogItemId(), x -> x, (existing, replacement) -> existing));
|
| 2241 |
|
2241 |
|
| 2242 |
int warehouseId = poItemWarehouseModel.getWarehouseId();
|
2242 |
Set<String> brands = selectedCatalogItemMap.values().stream().map(x -> x.getBrand().toLowerCase())
|
| 2243 |
for (String brand : brands) {
|
2243 |
.collect(Collectors.toSet());
|
| 2244 |
List<String> modelNames = selectedCatalogItemMap.entrySet().stream()
|
2244 |
|
| 2245 |
.filter(x -> x.getValue().getBrand().toLowerCase().equals(brand))
|
2245 |
int warehouseId = poItemWarehouseModel.getWarehouseId();
|
| 2246 |
.map(x -> x.getValue().getItemDescriptionNoColor()).collect(Collectors.toList());
|
2246 |
for (String brand : brands) {
|
| 2247 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
2247 |
List<String> modelNames = selectedCatalogItemMap.entrySet().stream()
|
| 2248 |
sendNotificationModel.setCampaignName("SendPo");
|
2248 |
.filter(x -> x.getValue().getBrand().toLowerCase().equals(brand))
|
| 2249 |
sendNotificationModel.setTitle(String.format(PO_TITLE_STRING));
|
2249 |
.map(x -> x.getValue().getItemDescriptionNoColor()).collect(Collectors.toList());
|
| 2250 |
sendNotificationModel.setMessage(String.join(", ", modelNames));
|
2250 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| 2251 |
sendNotificationModel.setType("url");
|
2251 |
sendNotificationModel.setCampaignName("SendPo");
|
| 2252 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
2252 |
sendNotificationModel.setTitle(String.format(PO_TITLE_STRING));
|
| 2253 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
2253 |
sendNotificationModel.setMessage(String.join(", ", modelNames));
|
| 2254 |
sendNotificationModel.setMessageType(MessageType.notification);
|
2254 |
sendNotificationModel.setType("url");
|
| 2255 |
|
2255 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
| 2256 |
List<BrandRegionMapping> brandRegionMappings = brandRegionMappingRepository.selectAll().stream()
|
2256 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
| 2257 |
.filter(x -> brand.equals(x.getBrand().toLowerCase()) && x.getFromWarehouseId() == warehouseId
|
2257 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| 2258 |
&& !x.isAccessory())
|
2258 |
|
| 2259 |
.collect(Collectors.toList());
|
2259 |
List<BrandRegionMapping> brandRegionMappings = brandRegionMappingRepository.selectAll().stream()
|
| 2260 |
List<Integer> toWarehouseIds = brandRegionMappings.stream().map(x -> x.getToWarehouseId())
|
2260 |
.filter(x -> brand.equals(x.getBrand().toLowerCase()) && x.getFromWarehouseId() == warehouseId
|
| 2261 |
.collect(Collectors.toList());
|
2261 |
&& !x.isAccessory())
|
| 2262 |
|
2262 |
.collect(Collectors.toList());
|
| 2263 |
List<Integer> fofoIds = fofoStoreRepository.selectByWarehouseIds(toWarehouseIds).stream()
|
2263 |
List<Integer> toWarehouseIds = brandRegionMappings.stream().map(x -> x.getToWarehouseId())
|
| 2264 |
.filter(x -> !x.isInternal() && x.isActive()).map(x -> x.getId()).collect(Collectors.toList());
|
2264 |
.collect(Collectors.toList());
|
| 2265 |
|
2265 |
|
| 2266 |
List<Integer> userIds = userAccountRepository.selectUserIdsByRetailerIds(fofoIds);
|
2266 |
List<Integer> fofoIds = fofoStoreRepository.selectByWarehouseIds(toWarehouseIds).stream()
|
| 2267 |
sendNotificationModel.setUserIds(userIds);
|
2267 |
.filter(x -> !x.isInternal() && x.isActive()).map(x -> x.getId()).collect(Collectors.toList());
|
| 2268 |
notificationService.sendNotification(sendNotificationModel);
|
2268 |
|
| 2269 |
}
|
2269 |
List<Integer> userIds = userAccountRepository.selectUserIdsByRetailerIds(fofoIds);
|
| 2270 |
model.addAttribute("response1", true);
|
2270 |
sendNotificationModel.setUserIds(userIds);
|
| 2271 |
return "response";
|
2271 |
notificationService.sendNotification(sendNotificationModel);
|
| 2272 |
}
|
2272 |
}
|
| - |
|
2273 |
model.addAttribute("response1", true);
|
| - |
|
2274 |
return "response";
|
| - |
|
2275 |
}
|
| 2273 |
|
2276 |
|
| 2274 |
}
|
2277 |
}
|
| 2275 |
|
2278 |
|