Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.jleaf.erp.sls.bo.generateverificationcode;
- import javax.persistence.Query;
- import org.jleaf.core.AbstractBusinessFunction;
- import org.jleaf.core.BusinessFunction;
- import org.jleaf.core.Dto;
- import org.jleaf.core.annotation.Info;
- import org.jleaf.core.annotation.InfoIn;
- import org.jleaf.core.annotation.InfoOut;
- import org.jleaf.core.dao.QueryBuilder;
- import org.jleaf.erp.inv.dao.VerificationItemDao;
- import org.jleaf.erp.inv.entity.VerificationHeader;
- import org.jleaf.erp.inv.entity.VerificationItem;
- import org.jleaf.erp.master.entity.ProductCustom;
- import org.jleaf.util.ValidationUtil;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- /**
- *
- * Henik, Jun 9, 2016
- *
- **/
- //@formatter:off
- @Service
- @InfoIn(value = {
- @Info(name = "tenantId", description = "tenant id", type = Long.class),
- @Info(name = "verificationId", description = "verification id", type = Long.class)
- })
- @InfoOut(value = {
- @Info(name = "count", description = "count verificationItemList", type = Long.class, required = false)
- })
- //@formatter:on
- public class CountGetVerificationItemListByVerificationHeader extends AbstractBusinessFunction implements BusinessFunction {
- @Autowired
- private VerificationItemDao verificationItemDao;
- @Override
- public String getDescription() {
- return "Count Get Verification Item List By Verification Header";
- }
- @Override
- public Dto execute(Dto inputDto) throws Exception {
- // Validation parameter input
- ValidationUtil.valDtoContainsKey(inputDto, "tenantId");
- ValidationUtil.valDtoContainsKey(inputDto, "verificationId");
- // Get Variable
- Long tenantId = inputDto.getLong("tenantId");
- Long verificationId = inputDto.getLong("verificationId");
- //@formatter:off
- QueryBuilder builder = new QueryBuilder();
- builder.add(" SELECT COUNT(1) ")
- .add(" FROM ").add(VerificationItem.TABLE_NAME).add(" A ")
- .add(" INNER JOIN ").add(VerificationHeader.TABLE_NAME).add(" B ON A.verification_id = B.verification_id ")
- .add(" LEFT OUTER JOIN ").add(ProductCustom.TABLE_NAME).add(" C ON A.product_id = C.product_id ")
- .add(" WHERE A.tenant_id = :tenantId ")
- .add(" AND A.verification_id = :verificationId ");
- //@formatter:on
- Query query = verificationItemDao.createNativeQuery(builder.toString());
- query.setParameter("tenantId", tenantId);
- query.setParameter("verificationId", verificationId);
- Object result = query.getSingleResult();
- Long count = 0L;
- if(result!=null){
- count = Long.valueOf( result.toString());
- }
- return new Dto().put("count", count);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement