Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.jleaf.erp.purch.bo.po;
- import java.util.List;
- import javax.persistence.Query;
- import org.jleaf.core.AbstractBusinessFunction;
- import org.jleaf.core.BusinessFunction;
- import org.jleaf.core.CoreException;
- import org.jleaf.core.Dto;
- import org.jleaf.core.annotation.ErrorList;
- import org.jleaf.core.annotation.Info;
- import org.jleaf.core.annotation.InfoIn;
- import org.jleaf.core.dao.QueryBuilder;
- import org.jleaf.erp.purch.entity.PurchaseOrder;
- import org.jleaf.erp.purch.entity.PurchaseOrderExt;
- import org.jleaf.erp.purch.entity.PurchaseOrderItem;
- import org.jleaf.erp.purch.entity.PurchaseOrderBalanceItem;
- import org.jleaf.erp.purch.PurchasingConstants;
- import org.jleaf.erp.purch.PurchasingExceptionConstants;
- import org.jleaf.erp.purch.dao.PurchaseOrderBalanceItemDao;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- // @formatter:off
- @Service
- @InfoIn(value = {
- @Info(name = "productId", description = "product ID to check", type = Long.class)
- })
- @ErrorList(errorKeys = {
- PurchasingExceptionConstants.THERE_SOME_PRODUCT_ALREADY_USE_ANOTHER_TRANSACTION
- })
- // @formatter:on
- public class ValProductCanOnlyInOnePoConsignmentManual extends AbstractBusinessFunction implements BusinessFunction {
- private static final Logger log = LoggerFactory.getLogger(ValProductCanOnlyInOnePoConsignmentManual.class);
- @Autowired
- private PurchaseOrderBalanceItemDao purchaseOrderBalanceItemDao;
- public String getDescription() {
- return "Validasi Produk yang ada di PO konsinyasi manual untuk produk tersebut jika status item R / I";
- }
- @SuppressWarnings("unchecked")
- public Dto execute(Dto inputDto) throws Exception {
- log.info(" iya coy sudah masuk sini product nya " + inputDto);
- List<Object[]> result = null;
- QueryBuilder builder = new QueryBuilder();
- builder.add(" SELECT D.doc_no ")
- .add(" FROM ").add(PurchaseOrderBalanceItem.TABLE_NAME).add(" A ")
- .add(" INNER JOIN ").add(PurchaseOrderItem.TABLE_NAME).add(" B ON A.po_item_id = B.po_item_id ")
- .add(" INNER JOIN ").add(PurchaseOrderExt.TABLE_NAME).add(" C ON B.po_id = C.po_id ")
- .add(" INNER JOIN ").add(PurchaseOrder.TABLE_NAME).add(" D ON C.po_id = D.po_id ")
- .add(" WHERE A.status_item IN (:RELEASED,:INPROGRESS) AND B.product_id = :productId ");
- Query query = purchaseOrderBalanceItemDao.createNativeQuery(builder.toString());
- query.setParameter("productId", inputDto.getLong("productId"));
- query.setParameter("RELEASED", PurchasingConstants.RELEASED_TRANSACTION);
- query.setParameter("INPROGRESS", PurchasingConstants.IN_PROGRESS_TRANSACTION);
- result = query.getResultList();
- List<Object[]> list = result;
- if(list.size() > 0) {
- throw new CoreException(PurchasingExceptionConstants.THERE_SOME_PRODUCT_ALREADY_USE_ANOTHER_TRANSACTION,"Purchase Order Item", "Product");
- }
- return new Dto();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement