コード例 #1
1
  @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}");
    }
  }
コード例 #2
0
  @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}");
    }
  }