Beispiel #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}");
    }
  }
Beispiel #2
0
  @RequestMapping(value = "/getGRNFromOderId", method = RequestMethod.GET)
  public void getGRNFromOderId(
      HttpServletResponse httpservletResponse,
      @RequestParam String oderId,
      @RequestParam String status) {

    try {
      List<GrnVO> valueObj = grnManager.getGRNFromOderId(oderId, status);
      if (valueObj != null && valueObj.size() > 0) {
        ObjectMapper mapper = new ObjectMapper();
        ObjectNode objectNode = new ObjectNode(mapper.getNodeFactory());
        JsonObjectUtil<GrnVO> jsonUtil = new JsonObjectUtil<GrnVO>();
        String m = jsonUtil.getJsonObjectDataDetail(valueObj, 1);
        ArrayNode node = mapper.readValue(m, ArrayNode.class);
        objectNode.put("Data", node);
        objectNode.put("success", true);
        writeJson(httpservletResponse, objectNode, mapper);
      } else {
        writeJsonString(httpservletResponse, "{\"Data\":\"Empty\",\"success\":false}");
      }
    } catch (Exception e) {
      getLogger().error(e.getMessage());
      writeJsonString(
          httpservletResponse, "{\"Data\":\"" + e.getMessage() + "\",\"success\":false}");
    }
  }
Beispiel #3
0
  @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}");
    }
  }
Beispiel #4
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}");
    }
  }