コード例 #1
0
  @Override
  public List<MaintenanceSpendBySupplier> getMaintenanceSpendBetweenTwoDates(Date from, Date to) {
    Date fromDate = dateTimeFormatHelper.resetTimeAndMonthStart(from);
    Date toDate = dateTimeFormatHelper.resetTimeAndMonthEnd(to);
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(toDate);
    // Set time fields to last hour:minute:second:millisecond
    calendar.set(Calendar.HOUR_OF_DAY, 23);
    calendar.set(Calendar.MINUTE, 59);
    calendar.set(Calendar.SECOND, 59);
    calendar.set(Calendar.MILLISECOND, 999);

    Query maintenanceSpendListQuery = new Query();
    maintenanceSpendListQuery.addCriteria(
        Criteria.where("transactionDate")
            .exists(true)
            .andOperator(
                Criteria.where("transactionDate").gte(fromDate),
                Criteria.where("transactionDate").lte(calendar.getTime())));

    /*
    List<MaintenanceSpendBySupplier> maintenanceSpendList = mongoOperation.find(maintenanceSpendListQuery, MaintenanceSpendBySupplier.class);

    System.out.println(" MaintenanceSpendBySupplierRepository - GENERAL QUERY - Start= " + to + " | To= " + to);
    if (maintenanceSpendList.isEmpty()) {
    System.out.println("MaintenanceSpendBySupplierRepository  - GENERAL QUERY - NO MATCHING RECORDS FOUND");
    }

    for (MaintenanceSpendBySupplier maintenanceSpend : maintenanceSpendList) {
    System.out.println(" MaintenanceSpendBySupplierRepository - GENERAL QUERY - Date= " + maintenanceSpend.getTransactionDate() + " | Cost= " + maintenanceSpend.getMaintenanceCost() + " | Truck= " + maintenanceSpend.getTruckId() + " | Supplier" + maintenanceSpend.getSupplierId());
    }
    System.out.println("--==--");
    */
    return mongoOperation.find(maintenanceSpendListQuery, MaintenanceSpendBySupplier.class);
  }
コード例 #2
0
 @Override
 public List<MaintenanceSpendBySupplier> getMaintenanceSpendBySupplierBetweenTwoDates(
     ServiceProvider serviceProvider, Date from, Date to) {
   Date fromDate = dateTimeFormatHelper.resetTimeAndMonthStart(from);
   Date toDate = dateTimeFormatHelper.resetTimeAndMonthEnd(to);
   Calendar calendar = Calendar.getInstance();
   calendar.setTime(toDate);
   // Set time fields to last hour:minute:second:millisecond
   calendar.set(Calendar.HOUR_OF_DAY, 23);
   calendar.set(Calendar.MINUTE, 59);
   calendar.set(Calendar.SECOND, 59);
   calendar.set(Calendar.MILLISECOND, 999);
   return getSupplierMaintenanceSpend(serviceProvider, fromDate, calendar.getTime());
 }
コード例 #3
0
  @Override
  public List<MaintenanceSpendBySupplier> getMaintenanceSpendByTruckForMonth(
      Truck truck, Date month) {
    Date from = dateTimeFormatHelper.resetTimeAndMonthStart(month);
    Date to = dateTimeFormatHelper.resetTimeAndMonthEnd(month);
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(to);
    // Set time fields to last hour:minute:second:millisecond
    calendar.set(Calendar.HOUR_OF_DAY, 23);
    calendar.set(Calendar.MINUTE, 59);
    calendar.set(Calendar.SECOND, 59);
    calendar.set(Calendar.MILLISECOND, 999);

    return getTruckMaintenanceSpend(truck, from, calendar.getTime());
  }