List of usage examples for org.hibernate Query setDate
@Deprecated @SuppressWarnings("unchecked") default Query<R> setDate(String name, Date val)
From source file:org.egov.services.instrument.InstrumentService.java
License:Open Source License
/** * returns List of InstrumentVouhcers dishonored from dishonoredFromDate to dishonoredToDate to get list of InstrumentVouchers * dishonored on a perticular date pass both as same Date * * @param dishonoredFromDate ,dishonoredToDate * @return List of InstrumentVouchers//from w ww . j av a 2s . co m */ public List<InstrumentVoucher> getBouncedCheques(final Date dishonoredFromDate, final Date dishonoredToDate) throws ApplicationRuntimeException { if (dishonoredFromDate == null || dishonoredToDate == null) throw new ApplicationRuntimeException("dishonoredFromDate and dishonoredToDate should not be null"); final Query qry = persistenceService.getSession().createQuery( "select iv from InstrumentVoucher iv inner join iv.instrumentHeaderId as ih where ih.statusId.description=:status" + " and ih in (select iih from InstrumentOtherDetails io inner join io.instrumentHeaderId as iih where io.modifiedDate>=:startDate and io.modifiedDate<=:endDate ) order by iv.instrumentHeaderId desc"); qry.setString("status", FinancialConstants.INSTRUMENT_DISHONORED_STATUS); qry.setDate("startDate", dishonoredFromDate); qry.setDate("endDate", dishonoredToDate); return qry.list(); }
From source file:org.egov.services.report.DEReportService.java
License:Open Source License
public Date getFinancialYearStartDate(final Date date) { CFinancialYear cFinancialYear = null; // if(LOGGER.isInfoEnabled()) LOGGER.info("Obtained session"); final Query query = persistenceService.getSession().createQuery( " from CFinancialYear cfinancialyear where cfinancialyear.startingDate <=:sDate and cfinancialyear.endingDate >=:eDate"); query.setDate("sDate", date); query.setDate("eDate", date); final ArrayList list = (ArrayList) query.list(); if (list.size() > 0) cFinancialYear = (CFinancialYear) list.get(0); if (null == cFinancialYear) throw new ApplicationRuntimeException("Financial Year Id does not exist."); return cFinancialYear.getStartingDate(); }
From source file:org.egov.tl.service.LicenseReportService.java
License:Open Source License
private Object getPendingRenewals(String licenseType, Long boundaryId, Long subcategoryId, Date date) { StringBuilder query = new StringBuilder(" select NVL(SUM(pren1)+SUM(pren2),0) from (SELECT ").append( " CASE WHEN expired = 0 AND months_between(dateofexpiry, ?)<1 THEN 1 ELSE 0 END AS pren1 , ") .append(" CASE WHEN expired = 1 AND months_between(dateofexpiry, ?)>-6 THEN 1 ELSE 0 END AS pren2 FROM ") .append(" (SELECT CASE WHEN ?<dateofexpiry THEN 0 ELSE 1 END AS expired,id_adm_bndry,dateofexpiry, license_type, id_status,id_sub_category ") .append(" FROM EGTL_license) lic ,EGTL_mstr_status status,eg_boundary boun ") .append(" WHERE lic.id_status=status.id_status AND status.status_name ='") .append(Constants.LICENSE_STATUS_ACTIVE).append("' AND lic.license_type='").append(licenseType) .append("' ").append(" AND boun.id_bndry = lic.id_adm_bndry "); if (boundaryId != null && boundaryId > 0) query.append(" and boun.id_bndry=").append(boundaryId); if (subcategoryId != null && subcategoryId > 0) query.append(" and lic.id_sub_category=").append(subcategoryId); query.append(" )"); Query hibQuery = persistenceService.getSession().createSQLQuery(String.valueOf(query)); hibQuery.setDate(0, date); hibQuery.setDate(1, date);//from www . j a v a2 s .com hibQuery.setDate(2, date); List result = hibQuery.list(); return result.get(0); }
From source file:org.egov.works.reports.service.WorkProgressRegisterService.java
License:Open Source License
private Query setParameterForDepartmentWiseReport(EstimateAbstractReport estimateAbstractReport, Query query) { if (estimateAbstractReport != null) { if (estimateAbstractReport.isSpillOverFlag()) { query.setBoolean("spilloverflag", true); }/*from w w w .java2s. c o m*/ if (estimateAbstractReport.getDepartment() != null) { query.setLong("department", estimateAbstractReport.getDepartment()); } if (estimateAbstractReport.getAdminSanctionFromDate() != null) { query.setDate("fromDate", estimateAbstractReport.getAdminSanctionFromDate()); } if (estimateAbstractReport.getAdminSanctionToDate() != null) { query.setDate("toDate", estimateAbstractReport.getAdminSanctionToDate()); } if (estimateAbstractReport.getScheme() != null) { query.setLong("scheme", estimateAbstractReport.getScheme()); } if (estimateAbstractReport.getSubScheme() != null) { query.setLong("subScheme", estimateAbstractReport.getSubScheme()); } if (estimateAbstractReport.getWorkCategory() != null) { query.setString("workcategory", estimateAbstractReport.getWorkCategory()); } if (estimateAbstractReport.getBeneficiary() != null) { query.setString("beneficiary", estimateAbstractReport.getBeneficiary()); } if (estimateAbstractReport.getNatureOfWork() != null) { query.setLong("natureofwork", estimateAbstractReport.getNatureOfWork()); } } return query; }
From source file:org.egov.works.reports.service.WorkProgressRegisterService.java
License:Open Source License
private Query setParameterForTypeOfWorkWiseReport(EstimateAbstractReport estimateAbstractReport, Query query) { if (estimateAbstractReport != null) { if (estimateAbstractReport.isSpillOverFlag()) { query.setBoolean("spilloverflag", true); }//from w w w. j a v a 2 s . c o m if (estimateAbstractReport.getTypeOfWork() != null) { query.setLong("typeofwork", estimateAbstractReport.getTypeOfWork()); } if (estimateAbstractReport.getSubTypeOfWork() != null) { query.setLong("subtypeofwork", estimateAbstractReport.getSubTypeOfWork()); } if (estimateAbstractReport.getDepartments() != null && !estimateAbstractReport.getDepartments().toString().equalsIgnoreCase("[null]")) { List<Long> departmentIds = new ArrayList<Long>(); for (Department dept : estimateAbstractReport.getDepartments()) { departmentIds.add(dept.getId()); } query.setParameterList("departmentIds", departmentIds); } if (estimateAbstractReport.getAdminSanctionFromDate() != null) { query.setDate("fromDate", estimateAbstractReport.getAdminSanctionFromDate()); } if (estimateAbstractReport.getAdminSanctionToDate() != null) { query.setDate("toDate", estimateAbstractReport.getAdminSanctionToDate()); } if (estimateAbstractReport.getScheme() != null) { query.setLong("scheme", estimateAbstractReport.getScheme()); } if (estimateAbstractReport.getSubScheme() != null) { query.setLong("subScheme", estimateAbstractReport.getSubScheme()); } if (estimateAbstractReport.getWorkCategory() != null) { query.setString("workcategory", estimateAbstractReport.getWorkCategory()); } if (estimateAbstractReport.getBeneficiary() != null) { query.setString("beneficiary", estimateAbstractReport.getBeneficiary()); } if (estimateAbstractReport.getNatureOfWork() != null) { query.setLong("natureofwork", estimateAbstractReport.getNatureOfWork()); } } return query; }
From source file:org.egov.works.services.impl.ContractorBillServiceImpl.java
License:Open Source License
@Override public List<EgBillregister> getListOfApprovedBillforEstimate(final AbstractEstimate estimate, final Date date) { List<EgBillregister> egBillRegisterList = null; Query query = null; if (estimate == null || date == null) throw new ApplicationRuntimeException("Invalid Arguments passed to getApprovedBillAmountforEstimate()"); else//from ww w . j a v a2 s. co m LOGGER.debug("Arguments passed to getListOfApprovedBillforEstimate() ||estimate " + estimate.getEstimateNumber() + "||date=" + date); if (estimate.getDepositCode() != null) { LOGGER.debug("Estimate is of DEPOSIT WORKS|| estimate Number " + estimate.getEstimateNumber()); query = persistenceService.getSession().createQuery( "select distinct egbr from MBHeader as mbh left outer join mbh.egBillregister egbr left outer join egbr.egBillregistermis egbrmis where mbh.workOrderEstimate.estimate.id=:estimateId and egbr.status.code=:code and trunc(egbr.billdate)<=trunc(:date) "); query.setLong("estimateId", estimate.getId()); query.setDate("date", date); query.setString("code", "APPROVED"); egBillRegisterList = query.list(); } else { LOGGER.debug("Estimate is of CAPITAL WORKS|| estimate Number " + estimate.getEstimateNumber()); query = persistenceService.getSession().createQuery( "select distinct egbr from MBHeader as mbh left outer join mbh.egBillregister egbr where mbh.workOrderEstimate.estimate.id=:estimateId " + "and egbr.status.code=:code and trunc(egbr.billdate)<=trunc(:date) "); query.setLong("estimateId", estimate.getId()); query.setDate("date", date); query.setString("code", "APPROVED"); egBillRegisterList = query.list(); } if (egBillRegisterList == null) egBillRegisterList = Collections.emptyList(); LOGGER.debug("Number of Approved bills for ||estimate " + estimate.getEstimateNumber() + "||date=" + date + "||is " + egBillRegisterList.size()); LOGGER.debug(">>>>>>End of getListOfApprovedBillforEstimate()>>>>>>"); return egBillRegisterList; }
From source file:org.egov.works.services.impl.ContractorBillServiceImpl.java
License:Open Source License
@Override public BigDecimal getBilledAmountForDate(final AbstractEstimate estimate, final Date asOnDate) { LOGGER.debug(/* w ww. j a v a 2 s .c o m*/ "<<<<<<<<<<<<<<< Start of getBilledAmountForDate(AbstractEstimate estimate,Date asOnDate >>>>>>>>>>>>>"); if (estimate == null || asOnDate == null) throw new ApplicationRuntimeException("Invalid Arguments passed to getApprovedBillAmountforEstimate()"); else LOGGER.debug( "Arguments passed to getBilledAmountForDate(AbstractEstimate estimate,Date asOnDate) ||estimate " + estimate + "||asOnDate=" + asOnDate); final List<Map<String, String>> voucherDetails = egovCommon .getExpenditureDetailsforProject(estimate.getProjectCode().getId(), asOnDate); LOGGER.debug("total voucher created for project code <<" + estimate.getProjectCode().getCode() + ">> is " + voucherDetails); final ArrayList<String> voucherNumbers = new ArrayList<>(); BigDecimal totalVoucherAmount = BigDecimal.ZERO; if (voucherDetails != null && !voucherDetails.isEmpty()) for (final Map<String, String> voucher : voucherDetails) { voucherNumbers.add(voucher.get("VoucherNumber")); totalVoucherAmount = totalVoucherAmount .add(BigDecimal.valueOf(Double.parseDouble(voucher.get("Amount")))); } LOGGER.debug("Total amount of vouchers(Contractor bills including overheads) | " + totalVoucherAmount); String queryString = "select sum(egbr.billamount) from MBHeader as mbh left outer join mbh.egBillregister egbr left outer join egbr.egBillregistermis egbrmis where mbh.workOrderEstimate.estimate.id=:estimateId " + "and trunc(egbr.billdate)<=trunc(:date) and egbr.status.code=:code"; if (!voucherNumbers.isEmpty()) queryString = queryString + " and egbrmis.voucherHeader.voucherNumber not in (:voucherNumbers)"; queryString = queryString + " group by mbh.workOrderEstimate.estimate.id"; final Query query = persistenceService.getSession().createQuery(queryString); query.setLong("estimateId", estimate.getId()); query.setDate("date", new Date()); query.setString("code", "APPROVED"); if (!voucherNumbers.isEmpty()) query.setParameterList("voucherNumbers", voucherNumbers); BigDecimal totalBillAmount = (BigDecimal) query.uniqueResult(); LOGGER.debug( "Total amount of contractor bills (Vouchers amount not included in this contractor bill amount) | " + totalBillAmount); if (totalBillAmount == null) totalBillAmount = BigDecimal.ZERO; LOGGER.debug( "End of getBilledAmountForDate(AbstractEstimate estimate,Date asOnDate) ||returned value is (including voucher amount and contractor bill)" + totalBillAmount.add(totalVoucherAmount)); return totalBillAmount.add(totalVoucherAmount); }
From source file:org.egov.works.services.impl.ContractorBillServiceImpl.java
License:Open Source License
@Override public BigDecimal getBilledAmount(final AbstractEstimate estimate) { if (estimate == null) throw new ApplicationRuntimeException("Invalid Arguments passed to getApprovedBillAmountforEstimate()"); LOGGER.debug("Arguments passed to getBilledAmount(AbstractEstimate estimate) ||estimate " + estimate.getEstimateNumber() + "||today date=" + new Date()); final List<Map<String, String>> voucherDetails = egovCommon .getExpenditureDetailsforProjectforFinYear(estimate.getProjectCode().getId(), new Date()); LOGGER.debug("total voucher created for project code <<" + estimate.getProjectCode().getCode() + ">> is " + voucherDetails);/*from w w w . j a v a2 s .c om*/ final ArrayList<String> voucherNumbers = new ArrayList<>(); BigDecimal totalVoucherAmount = BigDecimal.ZERO; if (voucherDetails != null && !voucherDetails.isEmpty()) for (final Map<String, String> voucher : voucherDetails) { voucherNumbers.add(voucher.get("VoucherNumber")); totalVoucherAmount = totalVoucherAmount .add(BigDecimal.valueOf(Double.parseDouble(voucher.get("Amount")))); } LOGGER.debug("Total amount of vouchers(Contractor bills including overheads) | " + totalVoucherAmount); String queryString = "select sum(egbr.billamount) from MBHeader as mbh left outer join mbh.egBillregister egbr left outer join egbr.egBillregistermis egbrmis where mbh.workOrderEstimate.estimate.id=:estimateId " + "and EXISTS (select 'true' from CFinancialYear cfinancialyear where trunc(cfinancialyear.startingDate)<=trunc(:date) and trunc(cfinancialyear.endingDate)>=trunc(:date) " + "and cfinancialyear.id=egbrmis.financialyear.id) and egbr.status.code=:code"; if (!voucherNumbers.isEmpty()) queryString = queryString + " and egbrmis.voucherHeader.voucherNumber not in (:voucherNumbers)"; queryString = queryString + " group by mbh.workOrderEstimate.estimate.id"; final Query query = persistenceService.getSession().createQuery(queryString); query.setLong("estimateId", estimate.getId()); query.setDate("date", new Date()); query.setString("code", "APPROVED"); if (!voucherNumbers.isEmpty()) query.setParameterList("voucherNumbers", voucherNumbers); BigDecimal totalBillAmount = (BigDecimal) query.uniqueResult(); LOGGER.debug( "Total amount of contractor bills (Vouchers amount not included in this contractor bill amount) | " + totalBillAmount); if (totalBillAmount == null) totalBillAmount = BigDecimal.ZERO; LOGGER.debug( "End of getBilledAmount(AbstractEstimate estimate) ||returned value is (including voucher amount and contractor bill)" + totalBillAmount.add(totalVoucherAmount)); return totalBillAmount.add(totalVoucherAmount); }
From source file:org.egov.works.services.impl.ContractorBillServiceImpl.java
License:Open Source License
@Override public List<EgBillregister> getListOfNonCancelledBillsforEstimate(final AbstractEstimate estimate, final Date date) { List<EgBillregister> egBillRegisterList = null; Query query = null; if (estimate == null || date == null) throw new ApplicationRuntimeException("Invalid Arguments passed to getApprovedBillAmountforEstimate()"); else/*from www . j a v a 2 s .co m*/ LOGGER.debug("Arguments passed to getListOfApprovedBillforEstimate() ||estimate " + estimate.getEstimateNumber() + "||date=" + date); if (estimate.getDepositCode() != null) { LOGGER.debug("Estimate is of DEPOSIT WORKS|| estimate Number " + estimate.getEstimateNumber()); query = persistenceService.getSession().createQuery( "select egbr from MBHeader as mbh left outer join mbh.egBillregister egbr left outer join egbr.egBillregistermis egbrmis where mbh.workOrderEstimate.estimate.id=:estimateId and egbr.status.code!=:code and trunc(egbr.billdate)<=trunc(:date) "); query.setLong("estimateId", estimate.getId()); query.setDate("date", date); query.setString("code", "CANCELLED"); egBillRegisterList = query.list(); } else { LOGGER.debug("Estimate is of CAPITAL WORKS|| estimate Number " + estimate.getEstimateNumber()); query = persistenceService.getSession().createQuery( "select egbr from MBHeader as mbh left outer join mbh.egBillregister egbr where mbh.workOrderEstimate.estimate.id=:estimateId " + "and egbr.status.code!=:code and trunc(egbr.billdate)<=trunc(:date) "); query.setLong("estimateId", estimate.getId()); query.setDate("date", date); query.setString("code", "CANCELLED"); egBillRegisterList = query.list(); } if (egBillRegisterList == null) egBillRegisterList = Collections.emptyList(); LOGGER.debug("Number of Approved bills for ||estimate " + estimate.getEstimateNumber() + "||date=" + date + "||is " + egBillRegisterList.size()); LOGGER.debug(">>>>>>End of getListOfApprovedBillforEstimate()>>>>>>"); return egBillRegisterList; }
From source file:org.egov.works.services.impl.ContractorBillServiceImpl.java
License:Open Source License
/** * @param - search current date, list of project code ids, accDetailTypeId * @return - returns sum of bill amount/*from w ww . ja va 2 s . c om*/ * @description -This method calculates the sum of bill amount for bills where voucher is not present */ public BigDecimal getTotalBillAmount(final Date asOnDate, final List<Integer> projectCodeIdsList) { List billAmountResult; BigDecimal totalBillAmount = BigDecimal.ZERO; final String payQuery = " SELECT coalesce(sum(br.BILLAMOUNT),0) AS \"Total Bill Amount\" FROM EG_BILLPAYEEDETAILS bpd, EG_BILLDETAILS bd, EG_BILLREGISTER br, EG_BILLREGISTERMIS mis " + " WHERE bpd.BILLDETAILID = bd.ID AND bd.BILLID = br.ID AND br.ID = mis.BILLID AND br.BILLSTATUS != '" + WorksConstants.CANCELLED_STATUS + "' " + "AND bpd.ACCOUNTDETAILTYPEID=(SELECT ID FROM ACCOUNTDETAILTYPE WHERE NAME='PROJECTCODE') AND bpd.ACCOUNTDETAILKEYID IN (:projCodeIds) AND br.BILLDATE <=:date " + "AND ((mis.VOUCHERHEADERID IS NULL) OR (mis.VOUCHERHEADERID IS NOT NULL AND EXISTS (SELECT id FROM voucherheader WHERE id=mis.VOUCHERHEADERID AND status=" + FinancialConstants.CANCELLEDVOUCHERSTATUS + ")))"; final Query query = persistenceService.getSession().createSQLQuery(payQuery); query.setParameterList("projCodeIds", projectCodeIdsList); query.setDate("date", asOnDate); billAmountResult = query.list(); for (final Object obj : billAmountResult) totalBillAmount = BigDecimal.valueOf(Double.valueOf(obj.toString())); return totalBillAmount; }