Exemplo n.º 1
0
  public void changeLocation(
      PalletTransferView palletManagementView,
      LocationItemView locationItemView,
      int stockInOutId) {
    log.debug("changeLocation().");
    try {
      MSLocationModel model = locationDAO.findByID(locationItemView.getId()); // toLocation
      PalletModel palletModel = palletDAO.findByID(palletManagementView.getId()); // fromPallet

      palletDAO.updateNewPalletTransferByChangeLocation(palletModel.getId(), model.getId());

      if (palletModel.getStatus() == 3) {
        // Print Tag
        palletDAO.updateLocationByStatusPrinted(palletModel.getMsLocationModel().getId());
      } else {
        // Find Location
        palletDAO.updateLocationByStatusLocated(model.getId());
      }

      // บวกของใหม่  ลบของเก่า
      palletDAO.updateLocationByOld(model.getId());
      //            palletDAO.updateLocationByNew(palletModel.getMsLocationModel().getId());

      saveOrUpdateStockInOutLine(palletModel, stockInOutId, model);

    } catch (Exception e) {
      log.debug("Exception : {}", e);
    }
  }
Exemplo n.º 2
0
  private void saveOrUpdateStockInOutLine(
      PalletModel palletModel, int stockInOutId, MSLocationModel toLocationId) {
    // jowjo
    StockInOutLineModel stockInOutLineModel = null;

    stockInOutLineModel =
        stockInOutLineDAO.findByPalletIdAndStockInOutId(palletModel.getId(), stockInOutId);
    int staffModel = (int) FacesUtil.getSession(false).getAttribute(AttributeName.STAFF.getName());

    try {
      if (!Utils.isNull(stockInOutLineModel) && !Utils.isZero(stockInOutLineModel.getId())) {
        log.debug("Update Stock In Out Line");
        stockInOutLineModel.setUpdateBy(staffModel);
        stockInOutLineModel.setUpdateDate(Utils.currentDate());
        stockInOutLineModel.setMsItemModel(palletModel.getMsItemModel());
        stockInOutLineModel.setPalletModel(palletModel);
        stockInOutLineModel.setMsLocationModel(toLocationId);
        stockInOutLineModel.setBarcode(palletModel.getPalletBarcode());
        stockInOutLineModel.setPreviousLocationId(palletModel.getMsLocationModel().getId());
        stockInOutLineDAO.update(stockInOutLineModel);
      } else {
        log.debug("Prsist Stock In Out Line");
        stockInOutLineModel = new StockInOutLineModel();

        stockInOutLineModel.setCreateBy(staffModel);
        stockInOutLineModel.setCreateDate(Utils.currentDate());
        stockInOutLineModel.setUpdateBy(staffModel);
        stockInOutLineModel.setUpdateDate(Utils.currentDate());
        stockInOutLineModel.setMsItemModel(palletModel.getMsItemModel());
        stockInOutLineModel.setPalletModel(palletModel);
        stockInOutLineModel.setMsLocationModel(toLocationId);
        stockInOutLineModel.setBarcode(palletModel.getPalletBarcode());
        stockInOutLineModel.setStockInOutModel(stockInOutDAO.findByID(stockInOutId));
        stockInOutLineModel.setPreviousLocationId(palletModel.getMsLocationModel().getId());
        stockInOutLineModel.setIsValid(1);
        stockInOutLineModel.setVersion(1);
        //               stockInOutLineModel.setQty(0);
        stockInOutLineDAO.persist(stockInOutLineModel);
      }
    } catch (Exception e) {
      log.debug("Exception error saveOrUpdateStockInOutLine : ", e);
    }
  }