@Transactional @RequestMapping(value = "/saveBooking", method = RequestMethod.POST) public void saveBooking( HttpServletResponse httpservletResponse, @RequestParam("grnId") Integer grnId) { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date date = new Date(); String current = dateFormat.format(date); try { GrnVO grnVO = grnManager.get(grnId); // Update oders booking details OdersVO odersVO = oderManager.get(grnVO.getOrders().getOderId()); odersVO.setGrnQty(odersVO.getGrnQty() - grnVO.getQuantity()); odersVO.setBookingQty(odersVO.getBookingQty() + grnVO.getQuantity()); oderManager.update(odersVO); grnVO.setStatus("booking"); grnVO.setBookingDate(current); grnVO.setBookingUserId("1"); String status = grnManager.update(grnVO); if (grnVO != null) { writeJsonString(httpservletResponse, "{\"Data\":\"" + status + "\",\"success\":true}"); } else { writeJsonString(httpservletResponse, "{\"Data\":\"" + status + "\",\"success\":false}"); } } catch (Exception e) { System.out.print(e); getLogger().error(e.getMessage()); writeJsonString( httpservletResponse, "{\"Data\":\"" + e.getMessage() + "\",\"success\":false}"); } }
@RequestMapping(value = "/addGrn", method = RequestMethod.POST) public void addGin( HttpServletResponse httpservletResponse, @ModelAttribute GrnVO grnVO, @RequestParam("oderId") Integer oderId) { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date date = new Date(); String current = dateFormat.format(date); try { OdersVO oderVO = oderManager.get(oderId); /* * DailyOdersVO dailyOder = dailyOdersManager.getDailyOder(oderId, * current).get(0); dailyOder.setDayIss(dailyOder.getDayIss() + * grnVO.getQuantity()); */ Integer finalQuantity = oderVO.getAllowedQuantity() - grnVO.getQuantity(); if (finalQuantity >= 0) { // dailyOdersManager.update(dailyOder); // Update OderVO details oderVO.setAllowedQuantity(finalQuantity); oderVO.setGrnQty(oderVO.getGrnQty() + grnVO.getQuantity()); oderManager.update(oderVO); grnVO.setOrders(oderVO); grnVO.setDate(current); String status = grnManager.add(grnVO); System.out.print(status); writeJsonString(httpservletResponse, "{\"Data\":\"" + status + "\",\"success\":true}"); } else { writeJsonString( httpservletResponse, "{\"Data\":\"" + "Not enough" + "\",\"success\":false}"); } } catch (Exception e) { System.out.print(e); writeJsonString( httpservletResponse, "{\"Data\":\"" + e.getMessage() + "\",\"success\":false}"); } }
@RequestMapping(value = "/issuedGRN", method = RequestMethod.POST) public void issuedGRN( HttpServletResponse httpservletResponse, @RequestParam("grnId") Integer grnId) { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date date = new Date(); String current = dateFormat.format(date); try { GrnVO grnVO = grnManager.get(grnId); grnVO.setStatus("issued"); // Update Daily isseued DailyOdersVO dailyOder = dailyOdersManager.getDailyOder(grnVO.getOrders().getOderId(), current).get(0); dailyOder.setDayIss(dailyOder.getDayIss() + grnVO.getQuantity()); dailyOdersManager.update(dailyOder); OdersVO odersVO = grnVO.getOrders(); odersVO.setBookingQty(odersVO.getBookingQty() - grnVO.getQuantity()); odersVO.setGinQty(odersVO.getGinQty() + grnVO.getQuantity()); oderManager.update(odersVO); grnVO.setIssuedDate(current); grnVO.setIssuedUserId("1"); String status = grnManager.update(grnVO); if (grnVO != null) { writeJsonString(httpservletResponse, "{\"Data\":\"" + status + "\",\"success\":true}"); } else { writeJsonString(httpservletResponse, "{\"Data\":\"" + status + "\",\"success\":true}"); } } catch (Exception e) { getLogger().error(e.getMessage()); writeJsonString( httpservletResponse, "{\"Data\":\"" + e.getMessage() + "\",\"success\":false}"); } }