Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.jleaf.erp.master.bo.ou;
- import java.util.List;
- import javax.persistence.Query;
- import org.jleaf.common.entity.OU;
- import org.jleaf.common.entity.PolicyOU;
- import org.jleaf.common.entity.UserRole;
- import org.jleaf.core.*;
- import org.jleaf.core.annotation.ErrorList;
- import org.jleaf.core.annotation.Info;
- import org.jleaf.core.annotation.InfoIn;
- import org.jleaf.core.annotation.InfoOut;
- import org.jleaf.core.dao.CriteriaHelper;
- import org.jleaf.core.dao.QueryBuilder;
- import org.jleaf.erp.master.dao.WarehouseDao;
- import org.jleaf.util.DtoUtil;
- 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 = "tenantId", type = Long.class, description = "Tenant Id"),
- // @Info(name = "ouId", description = "ou id", type = Long.class),
- @Info(name = "active", description = "active ", type = String.class),
- @Info(name = "userLoginId", description = "user login id", type = Long.class),
- @Info(name = "roleLoginId", description = "role login id", type = Long.class)
- })
- @InfoOut(value = {
- @Info(name = "outletList", description = "list outlet")
- })
- @ErrorList(errorKeys = {CoreExceptionConstants.DTO_CANNOT_NULL})
- //@formatter:on
- public class GetAuthorizedEmbeddedOutletListAdvance extends AbstractBusinessFunction implements BusinessFunction{
- private static final Logger log = LoggerFactory.getLogger(GetAuthorizedEmbeddedOutletListAdvance.class);
- @Autowired
- private WarehouseDao ouDao;
- @Override
- public String getDescription() {
- return " Get Embedded Outlet List Advance ";
- }
- @SuppressWarnings("unchecked")
- @Override
- public Dto execute(Dto inputDto) throws Exception{
- if (inputDto == null) {
- throw new CoreException(CoreExceptionConstants.DTO_CANNOT_NULL);
- }
- List<Object[]> result = null;
- QueryBuilder builder = new QueryBuilder();
- builder.add("SELECT E.outlet_id, E.ou_id, A.ou_code, A.ou_name, E.flg_internal, E.partner_id, E.warehouse_id, E.start_date_trx, E.flg_embedded, E.flg_accounts_receivable FROM ")
- .add(OU.TABLE_NAME)
- .add(" A INNER JOIN ")
- .add(UserRole.TABLE_NAME)
- .add(" C ON C.user_id = :userLoginId AND C.role_id = :roleLoginId ")
- .add(" INNER JOIN ")
- .add(PolicyOU.TABLE_NAME)
- .add(" D ON D.ou_id = A.ou_id AND D.policy_id = C.Policy_id ")
- .add(" INNER JOIN i_outlet ")
- .add(" E ON E.ou_id = A.ou_id ")
- // .add("WHERE A.ou_id = :ouId ")
- .add(" WHERE A.tenant_id = " + inputDto.getLong("tenantId"))
- .add(" AND E.flg_embedded = '" + GeneralConstants.YES + "' ")
- .add(" AND A.active = :activeStatus ")
- .add(" ORDER BY ou_code, ou_name ");
- Query query = ouDao.createNativeQuery(builder.toString());
- // query.setParameter("ouId", inputDto.getLong("ouId"));
- query.setParameter("userLoginId", inputDto.getLong("userLoginId"));
- query.setParameter("roleLoginId", inputDto.getLong("roleLoginId"));
- query.setParameter("activeStatus", inputDto.getString("active"));
- log.info("user login: "+inputDto.getLong("userLoginId"));
- log.info("role login: "+inputDto.getLong("roleLoginId"));
- log.info("Query for embedded outlet list>>>> "+builder.toString());
- result = query.getResultList();
- return new Dto().putList("outletList", DtoUtil.createDtoListFromArray(result,
- "id", "ouId", "ouCode", "ouName", "flagInternal", "partnerId", "warehouseId", "startDateTrx", "flgEmbedded", "flgAccountsReceivable"));
- }
- }
Add Comment
Please, Sign In to add comment