| Line 15... |
Line 15... |
| 15 |
import org.json.JSONObject;
|
15 |
import org.json.JSONObject;
|
| 16 |
import org.slf4j.Logger;
|
16 |
import org.slf4j.Logger;
|
| 17 |
import org.slf4j.LoggerFactory;
|
17 |
import org.slf4j.LoggerFactory;
|
| 18 |
import org.springframework.beans.factory.annotation.Autowired;
|
18 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 19 |
import org.springframework.beans.factory.annotation.Value;
|
19 |
import org.springframework.beans.factory.annotation.Value;
|
| - |
|
20 |
import org.springframework.http.ResponseEntity;
|
| 20 |
import org.springframework.stereotype.Controller;
|
21 |
import org.springframework.stereotype.Controller;
|
| 21 |
import org.springframework.transaction.annotation.Transactional;
|
22 |
import org.springframework.transaction.annotation.Transactional;
|
| 22 |
import org.springframework.ui.Model;
|
23 |
import org.springframework.ui.Model;
|
| - |
|
24 |
import org.springframework.web.bind.annotation.RequestBody;
|
| 23 |
import org.springframework.web.bind.annotation.RequestMapping;
|
25 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| - |
|
26 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 24 |
import org.springframework.web.bind.annotation.RequestParam;
|
27 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 25 |
|
28 |
|
| 26 |
import com.google.gson.Gson;
|
29 |
import com.google.gson.Gson;
|
| - |
|
30 |
import com.spice.profitmandi.common.ResponseCodeHolder;
|
| 27 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
31 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 28 |
import com.spice.profitmandi.common.model.CartFofo;
|
32 |
import com.spice.profitmandi.common.model.CartFofo;
|
| 29 |
import com.spice.profitmandi.common.model.CustomCurrentInventorySnapshot;
|
33 |
import com.spice.profitmandi.common.model.CustomCurrentInventorySnapshot;
|
| - |
|
34 |
import com.spice.profitmandi.common.model.InventoryItemAgingModel;
|
| 30 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
35 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| - |
|
36 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
| 31 |
import com.spice.profitmandi.common.util.StringUtils;
|
37 |
import com.spice.profitmandi.common.util.StringUtils;
|
| 32 |
import com.spice.profitmandi.common.util.Utils;
|
38 |
import com.spice.profitmandi.common.util.Utils;
|
| - |
|
39 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 33 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
40 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 34 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
41 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
| 35 |
import com.spice.profitmandi.dao.entity.fofo.FofoItemId;
|
42 |
import com.spice.profitmandi.dao.entity.fofo.FofoItemId;
|
| 36 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
43 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
| 37 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
44 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
| Line 40... |
Line 47... |
| 40 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
47 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 41 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
48 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 42 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
49 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
| 43 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
50 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
| 44 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
51 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| - |
|
52 |
import com.spice.profitmandi.service.aging.InventoryItemAgingService;
|
| 45 |
import com.spice.profitmandi.service.pricing.PricingService;
|
53 |
import com.spice.profitmandi.service.pricing.PricingService;
|
| 46 |
import com.spice.profitmandi.web.model.LoginDetails;
|
54 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 47 |
import com.spice.profitmandi.web.response.ValidateCart;
|
55 |
import com.spice.profitmandi.web.response.ValidateCart;
|
| 48 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
56 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 49 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
57 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| Line 76... |
Line 84... |
| 76 |
CookiesProcessor cookiesProcessor;
|
84 |
CookiesProcessor cookiesProcessor;
|
| 77 |
|
85 |
|
| 78 |
@Autowired
|
86 |
@Autowired
|
| 79 |
PricingService pricingService;
|
87 |
PricingService pricingService;
|
| 80 |
|
88 |
|
| - |
|
89 |
@Autowired
|
| - |
|
90 |
InventoryItemAgingService inventoryItemAgingService;
|
| - |
|
91 |
|
| - |
|
92 |
@Autowired
|
| - |
|
93 |
ResponseSender<?> responseSender;
|
| - |
|
94 |
|
| 81 |
@Value("${saholic.api.host}")
|
95 |
@Value("${saholic.api.host}")
|
| 82 |
private String host;
|
96 |
private String host;
|
| 83 |
@Value("${saholic.api.port}")
|
97 |
@Value("${saholic.api.port}")
|
| 84 |
private int port;
|
98 |
private int port;
|
| 85 |
@Value("${saholic.api.webapp}")
|
99 |
@Value("${saholic.api.webapp}")
|
| Line 111... |
Line 125... |
| 111 |
return "inventory-snapshot";
|
125 |
return "inventory-snapshot";
|
| 112 |
}
|
126 |
}
|
| 113 |
|
127 |
|
| 114 |
@RequestMapping(value = "/getBadInventorySnapshot")
|
128 |
@RequestMapping(value = "/getBadInventorySnapshot")
|
| 115 |
public String getBadAvailability(HttpServletRequest request,@RequestParam(name = "offset",defaultValue="0") int offset, @RequestParam(name = "limit", defaultValue="10") int limit , @RequestParam(name = "searchTerm", required=false, defaultValue="") String searchTerm ,Model model) throws Exception{
|
129 |
public String getBadAvailability(HttpServletRequest request,@RequestParam(name = "offset",defaultValue="0") int offset, @RequestParam(name = "limit", defaultValue="10") int limit , @RequestParam(name = "searchTerm", required=false, defaultValue="") String searchTerm ,Model model) throws Exception{
|
| 116 |
LoginDetails fofoDetails;
|
- |
|
| 117 |
try {
|
130 |
try {
|
| 118 |
fofoDetails = cookiesProcessor.getCookiesObject(request);
|
131 |
cookiesProcessor.getCookiesObject(request);
|
| 119 |
} catch (ProfitMandiBusinessException e) {
|
132 |
} catch (ProfitMandiBusinessException e) {
|
| 120 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
133 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
| 121 |
return "response";
|
134 |
return "response";
|
| 122 |
}
|
135 |
}
|
| 123 |
model.addAttribute("badInventorySnapshot",new ArrayList<>());
|
136 |
model.addAttribute("badInventorySnapshot",new ArrayList<>());
|
| Line 204... |
Line 217... |
| 204 |
model.addAttribute("mopPriceMap", mopPriceMap);
|
217 |
model.addAttribute("mopPriceMap", mopPriceMap);
|
| 205 |
return "catalog-paginated";
|
218 |
return "catalog-paginated";
|
| 206 |
}
|
219 |
}
|
| 207 |
|
220 |
|
| 208 |
|
221 |
|
| 209 |
|
- |
|
| 210 |
private Set<CustomCurrentInventorySnapshot> getCustomCurrentInventorySnapshots(List<Object[]> rows){
|
- |
|
| 211 |
Set<CustomCurrentInventorySnapshot> currentInventorySnapshots = new HashSet<>();
|
- |
|
| 212 |
for(Object[] row : rows){
|
- |
|
| 213 |
currentInventorySnapshots.add(this.createCustomCurrentInventorySnapshop(row));
|
- |
|
| 214 |
}
|
- |
|
| 215 |
return currentInventorySnapshots;
|
- |
|
| 216 |
}
|
- |
|
| 217 |
|
- |
|
| 218 |
private String getVaildName(String name){
|
222 |
private String getVaildName(String name){
|
| 219 |
return name!=null?name:"";
|
223 |
return name!=null?name:"";
|
| 220 |
}
|
224 |
}
|
| 221 |
|
225 |
|
| 222 |
private CustomCurrentInventorySnapshot createCustomCurrentInventorySnapshop(Object[] row)
|
226 |
private CustomCurrentInventorySnapshot createCustomCurrentInventorySnapshop(Object[] row)
|
| Line 468... |
Line 472... |
| 468 |
model.addAttribute("grnDetails", this.grnHistoryDetails(purchase, fofoDetails.getFofoId()));
|
472 |
model.addAttribute("grnDetails", this.grnHistoryDetails(purchase, fofoDetails.getFofoId()));
|
| 469 |
model.addAttribute("purchaseId",purchase.getId());
|
473 |
model.addAttribute("purchaseId",purchase.getId());
|
| 470 |
model.addAttribute("purchaseReference",purchase.getPurchaseReference());
|
474 |
model.addAttribute("purchaseReference",purchase.getPurchaseReference());
|
| 471 |
return "grn-details";
|
475 |
return "grn-details";
|
| 472 |
}
|
476 |
}
|
| - |
|
477 |
|
| - |
|
478 |
@RequestMapping(value = "/getInventoryItemAgingByInterval", method = RequestMethod.POST)
|
| - |
|
479 |
public ResponseEntity<?> getInventoryItemAgingByInterval(HttpServletRequest request, @RequestBody List<Integer> intervals, Model model) throws Exception{
|
| - |
|
480 |
LoginDetails fofoDetails;
|
| - |
|
481 |
try {
|
| - |
|
482 |
fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
483 |
} catch (ProfitMandiBusinessException e) {
|
| - |
|
484 |
//model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
| - |
|
485 |
return responseSender.badRequest(e);
|
| - |
|
486 |
}
|
| - |
|
487 |
try{
|
| - |
|
488 |
this.validateIntervals(intervals);
|
| - |
|
489 |
} catch (ProfitMandiBusinessException e) {
|
| - |
|
490 |
LOGGER.error("Unable to get valid interval values", e);
|
| - |
|
491 |
return responseSender.badRequest(e);
|
| - |
|
492 |
}
|
| - |
|
493 |
List<InventoryItemAgingModel> inventoryItemAgingModels = inventoryItemAgingService.getItemAgingByInterval(fofoDetails.getFofoId(), intervals);
|
| - |
|
494 |
//return responseSender.ok(inventoryItemAgingModels);
|
| - |
|
495 |
ExcelUtils.writeInventoryItemAgingModels(inventoryItemAgingModels, intervals);
|
| - |
|
496 |
return responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
|
| - |
|
497 |
}
|
| - |
|
498 |
|
| - |
|
499 |
|
| - |
|
500 |
private void validateIntervals(List<Integer> intervals)throws ProfitMandiBusinessException{
|
| - |
|
501 |
if(intervals.isEmpty()){
|
| - |
|
502 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.INTERVAL, intervals , "VE_1010");
|
| - |
|
503 |
}
|
| - |
|
504 |
int max = intervals.get(0);
|
| - |
|
505 |
for(int index = 1; index < intervals.size(); index++){
|
| - |
|
506 |
if(intervals.get(index) <= max){
|
| - |
|
507 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.INTERVAL, intervals, "VE_1011");
|
| - |
|
508 |
}
|
| - |
|
509 |
max = intervals.get(index);
|
| - |
|
510 |
}
|
| - |
|
511 |
}
|
| 473 |
|
512 |
|
| 474 |
private Map<Integer, Map<String, Object>> grnHistoryDetails(Purchase purchase, int fofoId){
|
513 |
private Map<Integer, Map<String, Object>> grnHistoryDetails(Purchase purchase, int fofoId){
|
| 475 |
Set<Integer> itemIds = new HashSet<>();
|
514 |
Set<Integer> itemIds = new HashSet<>();
|
| 476 |
Set<Item> inventoryItemDetails = new HashSet<>();
|
515 |
Set<Item> inventoryItemDetails = new HashSet<>();
|
| 477 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByPurchaseId(purchase.getId());
|
516 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByPurchaseId(purchase.getId());
|