| Line 9... |
Line 9... |
| 9 |
import java.util.HashSet;
|
9 |
import java.util.HashSet;
|
| 10 |
import java.util.Iterator;
|
10 |
import java.util.Iterator;
|
| 11 |
import java.util.List;
|
11 |
import java.util.List;
|
| 12 |
import java.util.Map;
|
12 |
import java.util.Map;
|
| 13 |
import java.util.Set;
|
13 |
import java.util.Set;
|
| - |
|
14 |
import java.util.function.Predicate;
|
| - |
|
15 |
import java.util.stream.Collectors;
|
| 14 |
|
16 |
|
| 15 |
import javax.servlet.http.HttpServletRequest;
|
17 |
import javax.servlet.http.HttpServletRequest;
|
| 16 |
import javax.servlet.http.HttpServletResponse;
|
18 |
import javax.servlet.http.HttpServletResponse;
|
| 17 |
|
19 |
|
| 18 |
import org.json.JSONObject;
|
20 |
import org.json.JSONObject;
|
| Line 21... |
Line 23... |
| 21 |
import org.springframework.beans.factory.annotation.Autowired;
|
23 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 22 |
import org.springframework.beans.factory.annotation.Value;
|
24 |
import org.springframework.beans.factory.annotation.Value;
|
| 23 |
import org.springframework.core.io.InputStreamResource;
|
25 |
import org.springframework.core.io.InputStreamResource;
|
| 24 |
import org.springframework.http.HttpHeaders;
|
26 |
import org.springframework.http.HttpHeaders;
|
| 25 |
import org.springframework.http.HttpStatus;
|
27 |
import org.springframework.http.HttpStatus;
|
| 26 |
import org.springframework.http.MediaType;
|
- |
|
| 27 |
import org.springframework.http.ResponseEntity;
|
28 |
import org.springframework.http.ResponseEntity;
|
| 28 |
import org.springframework.stereotype.Controller;
|
29 |
import org.springframework.stereotype.Controller;
|
| 29 |
import org.springframework.transaction.annotation.Transactional;
|
30 |
import org.springframework.transaction.annotation.Transactional;
|
| 30 |
import org.springframework.ui.Model;
|
31 |
import org.springframework.ui.Model;
|
| 31 |
import org.springframework.web.bind.annotation.RequestBody;
|
32 |
import org.springframework.web.bind.annotation.RequestBody;
|
| 32 |
import org.springframework.web.bind.annotation.RequestMapping;
|
33 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 33 |
import org.springframework.web.bind.annotation.RequestMethod;
|
34 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 34 |
import org.springframework.web.bind.annotation.RequestParam;
|
35 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 35 |
|
36 |
|
| 36 |
import com.google.gson.Gson;
|
37 |
import com.google.gson.Gson;
|
| 37 |
import com.spice.profitmandi.common.ResponseCodeHolder;
|
- |
|
| 38 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
38 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 39 |
import com.spice.profitmandi.common.model.CartFofo;
|
39 |
import com.spice.profitmandi.common.model.CartFofo;
|
| 40 |
import com.spice.profitmandi.common.model.CustomCurrentInventorySnapshot;
|
40 |
import com.spice.profitmandi.common.model.CustomCurrentInventorySnapshot;
|
| 41 |
import com.spice.profitmandi.common.model.InventoryItemAgingModel;
|
41 |
import com.spice.profitmandi.common.model.InventoryItemAgingModel;
|
| 42 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
42 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| Line 144... |
Line 144... |
| 144 |
model.addAttribute("searchTerm",searchTerm);
|
144 |
model.addAttribute("searchTerm",searchTerm);
|
| 145 |
return "bad-inventory-snapshot";
|
145 |
return "bad-inventory-snapshot";
|
| 146 |
}
|
146 |
}
|
| 147 |
|
147 |
|
| 148 |
@RequestMapping(value = "/getPaginatedCurrentInventorySnapshot")
|
148 |
@RequestMapping(value = "/getPaginatedCurrentInventorySnapshot")
|
| 149 |
public String getCurrentAvailabilityPaginated(HttpServletRequest request,@RequestParam(name = "offset",defaultValue="0") int offset, @RequestParam(name = "limit", defaultValue="10") int limit, @RequestParam(name = "searchTerm", required=false, defaultValue="") String searchTerm , Model model) throws Exception{
|
149 |
public String getCurrentAvailabilityPaginated(HttpServletRequest request, @RequestParam(name = "offset", defaultValue="0") int offset, @RequestParam(name = "limit", defaultValue="10") int limit, @RequestParam(name = "searchTerm", required=false, defaultValue="") String searchTerm , Model model) throws Exception{
|
| 150 |
LoginDetails fofoDetails;
|
150 |
LoginDetails fofoDetails;
|
| 151 |
try {
|
151 |
try {
|
| 152 |
fofoDetails = cookiesProcessor.getCookiesObject(request);
|
152 |
fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 153 |
} catch (ProfitMandiBusinessException e) {
|
153 |
} catch (ProfitMandiBusinessException e) {
|
| 154 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
154 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
| Line 481... |
Line 481... |
| 481 |
model.addAttribute("purchaseReference",purchase.getPurchaseReference());
|
481 |
model.addAttribute("purchaseReference",purchase.getPurchaseReference());
|
| 482 |
return "grn-details";
|
482 |
return "grn-details";
|
| 483 |
}
|
483 |
}
|
| 484 |
|
484 |
|
| 485 |
@RequestMapping(value = "/getInventoryItemAgingByInterval", method = RequestMethod.POST)
|
485 |
@RequestMapping(value = "/getInventoryItemAgingByInterval", method = RequestMethod.POST)
|
| - |
|
486 |
public String getInventoryItemAgingByInterval(HttpServletRequest request, @RequestBody List<Integer> intervals, Model model, @RequestParam(name = "searchContent", defaultValue = "") String searchContent, @RequestParam(name = "offset",defaultValue="0") int offset, @RequestParam(name = "limit", defaultValue="10") int limit) throws Exception{
|
| - |
|
487 |
LoginDetails fofoDetails;
|
| - |
|
488 |
try {
|
| - |
|
489 |
fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
490 |
} catch (ProfitMandiBusinessException e) {
|
| - |
|
491 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
| - |
|
492 |
return "response";
|
| - |
|
493 |
}
|
| - |
|
494 |
try{
|
| - |
|
495 |
this.validateIntervals(intervals);
|
| - |
|
496 |
} catch (ProfitMandiBusinessException e) {
|
| - |
|
497 |
LOGGER.error("Unable to get valid interval values", e);
|
| - |
|
498 |
return "response";
|
| - |
|
499 |
}
|
| - |
|
500 |
|
| - |
|
501 |
List<InventoryItemAgingModel> inventoryItemAgingModels = inventoryItemAgingService.getItemAgingByInterval(fofoDetails.getFofoId(), intervals);
|
| - |
|
502 |
|
| - |
|
503 |
if(!searchContent.isEmpty()){
|
| - |
|
504 |
Predicate<InventoryItemAgingModel> searchContentPredicate = new Predicate<InventoryItemAgingModel>() {
|
| - |
|
505 |
@Override
|
| - |
|
506 |
public boolean test(InventoryItemAgingModel inventoryItemAgingModel) {
|
| - |
|
507 |
if(!searchContent.contains(" ")){
|
| - |
|
508 |
return this.search(inventoryItemAgingModel, searchContent);
|
| - |
|
509 |
}else{
|
| - |
|
510 |
String[] searchContents = searchContent.split(" ");
|
| - |
|
511 |
for(String element : searchContents){
|
| - |
|
512 |
return this.search(inventoryItemAgingModel, element);
|
| - |
|
513 |
}
|
| - |
|
514 |
}
|
| - |
|
515 |
return false;
|
| - |
|
516 |
}
|
| - |
|
517 |
private boolean search(InventoryItemAgingModel inventoryItemAgingModel, String searchContent){
|
| - |
|
518 |
if(inventoryItemAgingModel.getBrand() != null && !inventoryItemAgingModel.getBrand().isEmpty() && inventoryItemAgingModel.getBrand().contains(searchContent)){
|
| - |
|
519 |
return true;
|
| - |
|
520 |
}
|
| - |
|
521 |
if(inventoryItemAgingModel.getModelName() != null && !inventoryItemAgingModel.getModelName().isEmpty() && inventoryItemAgingModel.getModelName().contains(searchContent)){
|
| - |
|
522 |
return true;
|
| - |
|
523 |
}
|
| - |
|
524 |
if(inventoryItemAgingModel.getModelNumber() != null && !inventoryItemAgingModel.getModelNumber().isEmpty() && inventoryItemAgingModel.getModelNumber().contains(searchContent)){
|
| - |
|
525 |
return true;
|
| - |
|
526 |
}
|
| - |
|
527 |
if(inventoryItemAgingModel.getColor() != null && !inventoryItemAgingModel.getColor().isEmpty() && inventoryItemAgingModel.getColor().contains(searchContent)){
|
| - |
|
528 |
return true;
|
| - |
|
529 |
}
|
| - |
|
530 |
return false;
|
| - |
|
531 |
}
|
| - |
|
532 |
};
|
| - |
|
533 |
inventoryItemAgingModels = inventoryItemAgingModels.stream().filter(searchContentPredicate).collect(Collectors.toList());
|
| - |
|
534 |
}
|
| - |
|
535 |
|
| - |
|
536 |
List<InventoryItemAgingModel> paginatedInventoryItemModels = new ArrayList<>();
|
| - |
|
537 |
if((offset + limit) > inventoryItemAgingModels.size()){
|
| - |
|
538 |
limit = inventoryItemAgingModels.size();
|
| - |
|
539 |
}
|
| - |
|
540 |
for(int index = offset; index < limit; index++){
|
| - |
|
541 |
paginatedInventoryItemModels.add(inventoryItemAgingModels.get(index));
|
| - |
|
542 |
}
|
| - |
|
543 |
|
| - |
|
544 |
model.addAttribute("inventoryItemAgingModels", paginatedInventoryItemModels);
|
| - |
|
545 |
model.addAttribute("intervals", intervals);
|
| - |
|
546 |
model.addAttribute("start", offset);
|
| - |
|
547 |
model.addAttribute("size", inventoryItemAgingModels.size());
|
| - |
|
548 |
int end = 0;
|
| - |
|
549 |
if (paginatedInventoryItemModels.size() < limit){
|
| - |
|
550 |
end = offset + paginatedInventoryItemModels.size();
|
| - |
|
551 |
}else{
|
| - |
|
552 |
end = offset + limit;
|
| - |
|
553 |
}
|
| - |
|
554 |
model.addAttribute("end", end);
|
| - |
|
555 |
return "item-aging";
|
| - |
|
556 |
}
|
| - |
|
557 |
|
| - |
|
558 |
@RequestMapping(value = "/downloadInventoryItemAgingByInterval", method = RequestMethod.POST)
|
| 486 |
public ResponseEntity<?> getInventoryItemAgingByInterval(HttpServletRequest request, @RequestBody List<Integer> intervals, Model model) throws Exception{
|
559 |
public ResponseEntity<?> downloadInventoryItemAgingByInterval(HttpServletRequest request, @RequestBody List<Integer> intervals, Model model) throws Exception{
|
| 487 |
LoginDetails fofoDetails;
|
560 |
LoginDetails fofoDetails;
|
| 488 |
try {
|
561 |
try {
|
| 489 |
fofoDetails = cookiesProcessor.getCookiesObject(request);
|
562 |
fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 490 |
} catch (ProfitMandiBusinessException e) {
|
563 |
} catch (ProfitMandiBusinessException e) {
|
| 491 |
//model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
564 |
//model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|