| 21561 |
ashik.ali |
1 |
package com.spice.profitmandi.web.controller;
|
| 21555 |
kshitij.so |
2 |
|
| 21574 |
ashik.ali |
3 |
import java.util.Arrays;
|
|
|
4 |
import java.util.List;
|
| 21555 |
kshitij.so |
5 |
|
| 21574 |
ashik.ali |
6 |
import javax.servlet.http.HttpServletRequest;
|
|
|
7 |
|
|
|
8 |
import org.slf4j.Logger;
|
|
|
9 |
import org.slf4j.LoggerFactory;
|
|
|
10 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 21555 |
kshitij.so |
11 |
import org.springframework.stereotype.Controller;
|
| 21574 |
ashik.ali |
12 |
import org.springframework.ui.Model;
|
| 21555 |
kshitij.so |
13 |
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
14 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
15 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 21574 |
ashik.ali |
16 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 21555 |
kshitij.so |
17 |
|
| 21574 |
ashik.ali |
18 |
import com.spice.profitmandi.common.model.CustomItem;
|
|
|
19 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
|
|
20 |
import com.spice.profitmandi.dao.repository.OrderRepository;
|
|
|
21 |
import com.spice.profitmandi.web.model.FofoDetails;
|
|
|
22 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 21555 |
kshitij.so |
23 |
|
|
|
24 |
@Controller
|
| 21574 |
ashik.ali |
25 |
public class OrderController {
|
| 21555 |
kshitij.so |
26 |
|
| 21574 |
ashik.ali |
27 |
private static final Logger LOGGER = LoggerFactory.getLogger(OrderController.class);
|
|
|
28 |
|
|
|
29 |
@Autowired
|
|
|
30 |
OrderRepository orderRepository;
|
|
|
31 |
|
|
|
32 |
@Autowired
|
|
|
33 |
MVCResponseSender mvcResponseSender;
|
|
|
34 |
|
|
|
35 |
@RequestMapping(value = "/orders", method = RequestMethod.POST)
|
|
|
36 |
public String orderByAirwayBillOrInvoiceNumber(HttpServletRequest request, @RequestParam(name = "airwayBillOrInvoiceNumber") String airwayBillOrInvoiceNumber, @RequestParam(name = ProfitMandiConstants.TYPE) String type, @ModelAttribute Model model) throws Exception{
|
|
|
37 |
FofoDetails fofoDetails = null;
|
|
|
38 |
fofoDetails = (FofoDetails)request.getSession(false).getAttribute(ProfitMandiConstants.FOFO_DETAILS);
|
|
|
39 |
if(ProfitMandiConstants.AIRWAY_BILL_NUMBER.equals(type) || ProfitMandiConstants.INVOICE_NUMBER.equals(type)){
|
|
|
40 |
List<CustomItem> customItems;
|
|
|
41 |
if(ProfitMandiConstants.AIRWAY_BILL_NUMBER.equals(type)){
|
|
|
42 |
customItems = orderRepository.selectByAirwayBillNumber(airwayBillOrInvoiceNumber, fofoDetails.getFofoId());
|
|
|
43 |
}else{
|
|
|
44 |
customItems = orderRepository.selectByInvoiceNumber(airwayBillOrInvoiceNumber, fofoDetails.getFofoId());
|
|
|
45 |
}
|
|
|
46 |
model.addAttribute("customItems", customItems);
|
|
|
47 |
return "orders";
|
|
|
48 |
}else{
|
|
|
49 |
LOGGER.error("Given type is not valid, please choose any one {}", Arrays.asList(ProfitMandiConstants.AIRWAY_BILL_NUMBER, ProfitMandiConstants.INVOICE_NUMBER));
|
|
|
50 |
return mvcResponseSender.createResponseString("RTLR_VE_1021", false, "/error");
|
|
|
51 |
}
|
| 21555 |
kshitij.so |
52 |
}
|
|
|
53 |
|
|
|
54 |
}
|