Rev 23569 | Rev 30289 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.spice.profitmandi.web.controller;import java.util.List;import java.util.Map;import javax.servlet.http.HttpServletRequest;import org.apache.logging.log4j.Logger;import org.apache.logging.log4j.LogManager;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.transaction.annotation.Transactional;import org.springframework.ui.Model;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.RequestParam;import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;import com.spice.profitmandi.common.model.ProfitMandiConstants;import com.spice.profitmandi.dao.entity.transaction.Order;import com.spice.profitmandi.dao.repository.transaction.OrderRepository;import com.spice.profitmandi.service.inventory.PurchaseService;import com.spice.profitmandi.web.model.LoginDetails;import com.spice.profitmandi.web.util.CookiesProcessor;@Controller@Transactional(rollbackFor=Throwable.class)public class PurchaseController {private static final Logger LOGGER = LogManager.getLogger(PurchaseController.class);@Autowiredprivate PurchaseService purchaseService;@Autowiredprivate OrderRepository orderRepository;@Autowiredprivate CookiesProcessor cookiesProcessor;@RequestMapping(value = "/purchaseByInvoiceNumber", method = RequestMethod.GET)public String purchaseByAirwayBillOrInvoiceNumber(HttpServletRequest request,@RequestParam(name = ProfitMandiConstants.AIRWAY_BILL_OR_INVOICE_NUMBER)String airwayBillOrInvoiceNumber, Model model) throws ProfitMandiBusinessException{LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);LOGGER.info("Request Received at url {} with airwayBillOrInvoiceNumber {}", request.getRequestURI(), airwayBillOrInvoiceNumber);Map<String, Object> map = purchaseService.purchaseByInvoiceNumber(airwayBillOrInvoiceNumber, fofoDetails.getFofoId());model.addAllAttributes(map);return "purchase";}@RequestMapping(value = "/purchase", method = RequestMethod.GET)public String purchase(HttpServletRequest request) throws Exception{return "purchase";}@RequestMapping(value = "/pendingGrn", method = RequestMethod.GET)public String pendingGrn(HttpServletRequest request, Model model) throws ProfitMandiBusinessException{LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);LOGGER.info("Request Received at url {}", request.getRequestURI());List<Order> pendingGrns = orderRepository.selectShipmentToDeliveredByRetailerId(fofoDetails.getFofoId());model.addAttribute("pendingGrns", pendingGrns);return "pending-grn";}@RequestMapping(value = "/pendingGrnDetails", method = RequestMethod.GET)public String pendingGrnDetails(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ORDER_ID) int orderId, Model model) throws ProfitMandiBusinessException{LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);LOGGER.info("Request Received at url [{}] with orderId [{}]", request.getRequestURI(), orderId);model.addAttribute("pendingGrnDetails", purchaseService.getShippingDetailByOrderId(orderId, fofoDetails.getFofoId()));return "pending-grn-details";}}