Advertisement
aadddrr

ValProductCanOnlyInOnePoConsignmentManual

May 25th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.96 KB | None | 0 0
  1. package org.jleaf.erp.purch.bo.po;
  2.  
  3. import java.util.List;
  4.  
  5. import javax.persistence.Query;
  6.  
  7. import org.jleaf.core.AbstractBusinessFunction;
  8. import org.jleaf.core.BusinessFunction;
  9. import org.jleaf.core.CoreException;
  10. import org.jleaf.core.Dto;
  11. import org.jleaf.core.annotation.ErrorList;
  12. import org.jleaf.core.annotation.Info;
  13. import org.jleaf.core.annotation.InfoIn;
  14. import org.jleaf.core.dao.QueryBuilder;
  15. import org.jleaf.erp.purch.entity.PurchaseOrder;
  16. import org.jleaf.erp.purch.entity.PurchaseOrderExt;
  17. import org.jleaf.erp.purch.entity.PurchaseOrderItem;
  18. import org.jleaf.erp.purch.entity.PurchaseOrderBalanceItem;
  19. import org.jleaf.erp.purch.PurchasingConstants;
  20. import org.jleaf.erp.purch.PurchasingExceptionConstants;
  21. import org.jleaf.erp.purch.dao.PurchaseOrderBalanceItemDao;
  22. import org.slf4j.Logger;
  23. import org.slf4j.LoggerFactory;
  24. import org.springframework.beans.factory.annotation.Autowired;
  25. import org.springframework.stereotype.Service;
  26.  
  27. // @formatter:off
  28. @Service
  29. @InfoIn(value = {
  30.         @Info(name = "productId", description = "product ID to check", type = Long.class)
  31. })
  32.  
  33. @ErrorList(errorKeys = {
  34.         PurchasingExceptionConstants.THERE_SOME_PRODUCT_ALREADY_USE_ANOTHER_TRANSACTION
  35. })
  36.  
  37. // @formatter:on
  38. public class ValProductCanOnlyInOnePoConsignmentManual extends AbstractBusinessFunction implements BusinessFunction {
  39.  
  40.     private static final Logger log = LoggerFactory.getLogger(ValProductCanOnlyInOnePoConsignmentManual.class);
  41.     @Autowired
  42.     private PurchaseOrderBalanceItemDao purchaseOrderBalanceItemDao;
  43.  
  44.     public String getDescription() {
  45.         return "Validasi Produk yang ada di PO konsinyasi manual untuk produk tersebut jika status item R / I";
  46.     }
  47.  
  48.     @SuppressWarnings("unchecked")
  49.     public Dto execute(Dto inputDto) throws Exception {
  50.  
  51.         log.info(" iya coy sudah masuk sini product nya " + inputDto);
  52.        
  53.         List<Object[]> result = null;
  54.        
  55.         QueryBuilder builder = new QueryBuilder();
  56.         builder.add(" SELECT D.doc_no ")
  57.         .add(" FROM ").add(PurchaseOrderBalanceItem.TABLE_NAME).add(" A ")
  58.         .add(" INNER JOIN ").add(PurchaseOrderItem.TABLE_NAME).add(" B ON A.po_item_id = B.po_item_id ")
  59.         .add(" INNER JOIN  ").add(PurchaseOrderExt.TABLE_NAME).add(" C ON B.po_id = C.po_id ")
  60.         .add(" INNER JOIN ").add(PurchaseOrder.TABLE_NAME).add(" D ON C.po_id = D.po_id ")
  61.         .add(" WHERE A.status_item IN (:RELEASED,:INPROGRESS) AND B.product_id = :productId ");
  62.        
  63.         Query query = purchaseOrderBalanceItemDao.createNativeQuery(builder.toString());
  64.         query.setParameter("productId", inputDto.getLong("productId"));
  65.         query.setParameter("RELEASED", PurchasingConstants.RELEASED_TRANSACTION);
  66.         query.setParameter("INPROGRESS", PurchasingConstants.IN_PROGRESS_TRANSACTION);
  67.  
  68.         result = query.getResultList();
  69.  
  70.         List<Object[]> list = result;
  71.    
  72.         if(list.size() > 0) {
  73.             throw new CoreException(PurchasingExceptionConstants.THERE_SOME_PRODUCT_ALREADY_USE_ANOTHER_TRANSACTION,"Purchase Order Item", "Product");
  74.         }
  75.        
  76.         return new Dto();
  77.        
  78.     }
  79.  
  80.    
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement