Search in sources :

Example 1 with MasterOutputProductCriteria

use of com.qcadoo.mes.technologies.tree.traversing.MasterOutputProductCriteria in project mes by qcadoo.

the class ProductValidatorsTNFO method findCorruptedTechnologyNumbers.

// HQL form:
// -----------------------
// select
// toc.id as id,
// t.number as techNumber
// 
// from
// #technologies_technologyOperationComponent toc
// inner join toc.operationProductOutComponents opoc
// inner join opoc.product as p
// inner join toc.technology t
// left join toc.parent parentToc
// left join parentToc.operationProductInComponents opic
// 
// where
// (opoc.product.id = opic.product.id or (toc.parent is null and t.product.id = p.id))
// and t.state in ('02accepted', '05checked')
// and p.unit <> toc.productionInOneCycleUNIT
// and p.id = :productId
// 
// order by toc.id desc
private List<Entity> findCorruptedTechnologyNumbers(final Long productID) {
    MasterOutputProductCriteria criteria = MasterOutputProductCriteria.empty().withProdCriteria(idEq(productID)).withTechCriteria(in(TechnologyFields.STATE, Lists.newArrayList(TechnologyStateStringValues.ACCEPTED, TechnologyStateStringValues.CHECKED)));
    SearchCriteriaBuilder scb = mainTocOutputProductCriteriaBuilder.create(criteria);
    scb.add(neField(Aliases.OPERATION_OUTPUT_PRODUCT + "." + ProductFields.UNIT, Aliases.TOC + "." + TechnologyOperationComponentFieldsTNFO.PRODUCTION_IN_ONE_CYCLE_UNIT));
    scb.addOrder(desc("id"));
    SearchProjection techNumProjection = alias(field(Aliases.TECHNOLOGY + "." + TechnologyFields.NUMBER), "techNumber");
    SearchProjection projection = SearchProjections.list().add(techNumProjection).add(alias(id(), "id"));
    scb.setProjection(SearchProjections.distinct(projection));
    return scb.list().getEntities();
}
Also used : MasterOutputProductCriteria(com.qcadoo.mes.technologies.tree.traversing.MasterOutputProductCriteria) SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder) SearchProjection(com.qcadoo.model.api.search.SearchProjection)

Aggregations

MasterOutputProductCriteria (com.qcadoo.mes.technologies.tree.traversing.MasterOutputProductCriteria)1 SearchCriteriaBuilder (com.qcadoo.model.api.search.SearchCriteriaBuilder)1 SearchProjection (com.qcadoo.model.api.search.SearchProjection)1