예제 #1
0
  protected PlanAndFactSumsByKindResult doGetTotalPlanAndFactSumsByKind(Phase contractPhase) {
    BigDecimal planShippedPayment = BigDecimal.ZERO;
    BigDecimal planReceivedPayment = BigDecimal.ZERO;
    BigDecimal planShippedGood = BigDecimal.ZERO;
    BigDecimal planReceivedGood = BigDecimal.ZERO;

    BigDecimal factShippedPayment = BigDecimal.ZERO;
    BigDecimal factReceivedPayment = BigDecimal.ZERO;
    BigDecimal factShippedGood = BigDecimal.ZERO;
    BigDecimal factReceivedGood = BigDecimal.ZERO;

    Projection projection =
        Projections.projectionList(
            Projections.sum("PlanSum"), // $NON-NLS-1$
            Projections.sum("FactSum"), // $NON-NLS-1$
            Projections.groupProperty("Kind")); // $NON-NLS-1$
    List<Object[]> phaseAgregateSums =
        OrmTemplate.getInstance()
            .findByCriteria(
                OrmTemplate.createCriteria(PhasePlanItem.class)
                    .setProjection(projection)
                    .add(Restrictions.eq("ContractPhase", contractPhase))); // $NON-NLS-1$

    for (Object[] agregateSum : phaseAgregateSums) {
      ItemKind kind = (ItemKind) agregateSum[2];
      if (kind == ItemKind.SHIPPED) {
        planShippedPayment = agregateSum[0] == null ? BigDecimal.ZERO : (BigDecimal) agregateSum[0];
        factShippedPayment = agregateSum[1] == null ? BigDecimal.ZERO : (BigDecimal) agregateSum[1];
        continue;
      }
      if (kind == ItemKind.RECEIVE) {
        planReceivedPayment =
            agregateSum[0] == null ? BigDecimal.ZERO : (BigDecimal) agregateSum[0];
        factReceivedPayment =
            agregateSum[1] == null ? BigDecimal.ZERO : (BigDecimal) agregateSum[1];
        continue;
      }
      if (kind == ItemKind.SHIPPEDGOOD) {
        planShippedGood = agregateSum[0] == null ? BigDecimal.ZERO : (BigDecimal) agregateSum[0];
        factShippedGood = agregateSum[1] == null ? BigDecimal.ZERO : (BigDecimal) agregateSum[1];
        continue;
      }
      if (kind == ItemKind.RECEIVEGOOD) {
        planReceivedGood = agregateSum[0] == null ? BigDecimal.ZERO : (BigDecimal) agregateSum[0];
        factReceivedGood = agregateSum[1] == null ? BigDecimal.ZERO : (BigDecimal) agregateSum[1];
      }
    }

    return new PlanAndFactSumsByKindResult(
        planShippedPayment,
        planReceivedPayment,
        planShippedGood,
        planReceivedGood,
        factShippedPayment,
        factReceivedPayment,
        factShippedGood,
        factReceivedGood);
  }
예제 #2
0
 private BigDecimal[] internalCalculateTotalPhaseSumByKind(Phase contractPhase) {
   Projection projection =
       Projections.projectionList(
           Projections.sum("PlanSum"),
           Projections.groupProperty("Kind")); // $NON-NLS-1$ //$NON-NLS-2$
   List<Object[]> phaseAgregateSums =
       OrmTemplate.getInstance()
           .findByCriteria(
               OrmTemplate.createCriteria(PhasePlanItem.class)
                   .setProjection(projection)
                   .add(Restrictions.eq("ContractPhase", contractPhase))); // $NON-NLS-1$
   return getSumsByKind(phaseAgregateSums);
 }