Example usage for java.math BigDecimal ROUND_HALF_UP

List of usage examples for java.math BigDecimal ROUND_HALF_UP

Introduction

In this page you can find the example usage for java.math BigDecimal ROUND_HALF_UP.

Prototype

int ROUND_HALF_UP

To view the source code for java.math BigDecimal ROUND_HALF_UP.

Click Source Link

Document

Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round up.

Usage

From source file:org.egov.ptis.service.es.CollectionIndexElasticSearchService.java

/**
 * Provides month wise DCB details across all ULBs
 * @param collectionDetailsRequest/*w w w  . j  a v  a 2s .co m*/
 * @param intervalType
 * @return list
 */
public List<MonthlyDCB> getMonthwiseDCBDetailsAcrossCities(
        final CollectionDetailsRequest collectionDetailsRequest, final String intervalType) {
    final List<MonthlyDCB> ulbWiseDetails = new ArrayList<>();
    Date fromDate = null;
    Date toDate = null;
    String monthName;
    Sum aggregateSum;
    Integer month;
    String aggregationField = StringUtils.EMPTY;
    Map<String, Object[]> monthwiseColl;
    Map<Integer, String> monthValuesMap = DateUtils.getAllMonthsWithFullNames();
    Map<String, BillCollectorIndex> wardWiseBillCollectors = new HashMap<>();
    if (StringUtils.isNotBlank(collectionDetailsRequest.getType()))
        aggregationField = getAggregrationField(collectionDetailsRequest);

    if (DASHBOARD_GROUPING_WARDWISE.equalsIgnoreCase(collectionDetailsRequest.getType()))
        wardWiseBillCollectors = getWardWiseBillCollectors(collectionDetailsRequest);
    final Map<String, Map<String, Object[]>> ulbwiseMonthlyCollMap = new HashMap<>();
    if (StringUtils.isNotBlank(collectionDetailsRequest.getFromDate())
            && StringUtils.isNotBlank(collectionDetailsRequest.getToDate())) {
        fromDate = DateUtils.getDate(collectionDetailsRequest.getFromDate(), DATE_FORMAT_YYYYMMDD);
        toDate = DateUtils
                .addDays(DateUtils.getDate(collectionDetailsRequest.getToDate(), DATE_FORMAT_YYYYMMDD), 1);
    }

    final Map<String, BigDecimal> totalDemandMap = getCollectionAndDemandValues(collectionDetailsRequest,
            fromDate, toDate, PROPERTY_TAX_INDEX_NAME, TOTAL_DEMAND, aggregationField);
    final Aggregations collAggr = getMonthwiseCollectionsForConsecutiveYears(collectionDetailsRequest, fromDate,
            toDate, true, intervalType, aggregationField);
    final StringTerms cityaggr = collAggr.get(BY_CITY);
    BigDecimal totalDemand;
    BigDecimal monthlyDemand;
    int noOfMonths;
    Object[] demandCollValues;

    for (final Terms.Bucket cityDetailsentry : cityaggr.getBuckets()) {
        monthwiseColl = new LinkedHashMap<>();
        final String ulbName = cityDetailsentry.getKeyAsString();
        noOfMonths = 0;
        totalDemand = totalDemandMap.get(ulbName);

        if (totalDemand == null)
            totalDemand = BigDecimal.ZERO;
        final Histogram dateaggs = cityDetailsentry.getAggregations().get(DATE_AGG);
        for (final Histogram.Bucket entry : dateaggs.getBuckets()) {
            if (noOfMonths == 0)
                noOfMonths = 1;
            demandCollValues = new Object[12];
            String[] dateArr = entry.getKeyAsString().split("T");
            month = Integer.valueOf(dateArr[0].split("-", 3)[1]);
            monthName = monthValuesMap.get(month);
            monthlyDemand = totalDemand.divide(BigDecimal.valueOf(12), BigDecimal.ROUND_HALF_UP)
                    .multiply(BigDecimal.valueOf(noOfMonths));
            aggregateSum = entry.getAggregations().get(CURRENT_TOTAL);

            if (BigDecimal.valueOf(aggregateSum.getValue()).setScale(0, BigDecimal.ROUND_HALF_UP)
                    .compareTo(BigDecimal.ZERO) > 0) {
                demandCollValues[0] = BigDecimal.valueOf(aggregateSum.getValue()).setScale(0,
                        BigDecimal.ROUND_HALF_UP);
                demandCollValues[1] = monthlyDemand;
                monthwiseColl.put(monthName, demandCollValues);
            }
            noOfMonths++;
        }
        ulbwiseMonthlyCollMap.put(ulbName, monthwiseColl);
    }
    setMonthlyDCBValues(ulbWiseDetails, ulbwiseMonthlyCollMap, wardWiseBillCollectors);
    return ulbWiseDetails;
}

From source file:org.egov.ptis.domain.service.property.PropertyService.java

/**
 * Converting sqr yards to sqr meters/*from ww  w  . j av  a 2s  .c om*/
 *
 * @param vacantLandArea
 * @return
 */
public BigDecimal convertYardToSquareMeters(final Float vacantLandArea) {
    Float areaInSqMts = vacantLandArea * SQUARE_YARD_TO_SQUARE_METER_VALUE;
    return new BigDecimal(areaInSqMts).setScale(2, BigDecimal.ROUND_HALF_UP);
}

From source file:net.cbtltd.rest.AbstractReservation.java

/**
 * Get quotes for a setted date//  ww w .  j ava2  s .c om
 * 
 * @param pos the point of sale code.
 * @param productid the ID of the property
 * @param fromDateString the date from which calculate a quote
 * @param todate the date to which calculate a quote
 * @param currency currency to calculate
 * @return quotes
 */
protected static synchronized QuoteResponse getQuotes(String pos, String productid, String fromDateString,
        String todate, String currency, Integer adults, Integer children) {

    if (productid == null || productid.isEmpty()) {
        throw new ServiceException(Error.product_id, productid);
    }
    if (!Time.isDateCorrectFormat(fromDateString)) {
        throw new ServiceException(Error.date_from, fromDateString);
    }
    if (!Time.isDateCorrectFormat(todate)) {
        throw new ServiceException(Error.date_to, todate);
    }

    SqlSession sqlSession = RazorServer.openSession();
    QuoteResponse response = new QuoteResponse();
    try {
        Product product = sqlSession.getMapper(ProductMapper.class).read(productid);
        if (product == null) {
            throw new ServiceException(Error.database_cannot_find, "product with [" + productid + "] id");
        }
        if (!Product.CREATED.equals(product.getState())) {
            throw new ServiceException(Error.product_inactive, "product with [" + productid + "] id");
        }
        if (StringUtils.isEmpty(currency) || !PaymentHelper.currencyExists(currency)) {
            currency = product.getCurrency();
        }
        Party channelPartnerParty = JSONService.getPartyWithPMCheck(sqlSession, pos, product.getSupplierid()); // this method checks agent's status and throws an exception in case of agent is inactive
        if (channelPartnerParty == null) {
            throw new ServiceException(Error.database_cannot_find, "channel partner with pos: [" + pos + "]");
        }
        product.setPhysicaladdress(ReservationService.getPropertyLocation(sqlSession, product));
        Integer propertyManagerId = Integer.valueOf(product.getSupplierid());
        if (propertyManagerId == null) {
            throw new ServiceException(Error.database_cannot_find,
                    "property manager ID for product id [" + product.getId() + "]");
        }
        PropertyManagerInfo propertyManagerInfo = sqlSession.getMapper(PropertyManagerInfoMapper.class)
                .readbypmid(propertyManagerId);

        if (propertyManagerInfo == null) {
            throw new ServiceException(Error.database_cannot_find,
                    "property manager info by PM ID [" + propertyManagerId + "]");
        }

        response.setFromTime(convertTime(propertyManagerInfo.getCheckInTime()));
        response.setToTime(convertTime(propertyManagerInfo.getCheckOutTime()));

        Date fromDate = JSONService.DF.parse(fromDateString);
        Date toDate = JSONService.DF.parse(todate);

        if (!toDate.after(fromDate)) {
            throw new ServiceException(Error.date_range);
        }

        Reservation reservation = new Reservation();
        reservation.setOrganizationid(product.getSupplierid());
        reservation.setProductid(productid);
        reservation.setFromdate(fromDate);
        reservation.setUnit(Unit.DAY);
        reservation.setTodate(toDate);
        reservation.setAltpartyid(product.getAltpartyid());
        reservation.setCurrency(currency);
        reservation.setAdult(adults);
        reservation.setChild(children);
        reservation.setAgentid(channelPartnerParty.getId());
        reservation.setQuotedetail(new ArrayList<net.cbtltd.shared.Price>());

        currency = PartyService.checkbookingnetCurrency(currency, propertyManagerInfo);

        ReservationPrice reservationPrice = new ReservationPrice();
        if (reservation.getAltpartyid() == null
                || !Arrays.asList(livePricingIds).contains(reservation.getAltpartyid())) {

            reservationPrice = ReservationService.computePrice(sqlSession, reservation, currency);

            response.setDamageInsurance(round(
                    PaymentService.convertCurrency(sqlSession, product.getCurrency(), reservation.getCurrency(),
                            product.getSecuritydeposit() != null ? product.getSecuritydeposit() : 0),
                    2, BigDecimal.ROUND_HALF_UP));
            response.setCleaningFee(round(
                    PaymentService.convertCurrency(sqlSession, product.getCurrency(), reservation.getCurrency(),
                            product.getCleaningfee() != null ? product.getCleaningfee() : 0),
                    2, BigDecimal.ROUND_HALF_UP));

            LOG.debug("Reservation [" + reservation.getId() + "] has not altparty ID.");
        } else {
            reservationPrice = PartnerService.readPrice(sqlSession, reservation, product.getAltid(), currency);

            if (reservationPrice.getTotal() == null || reservationPrice.getTotal() <= 0
                    || reservationPrice.getPrice() == null || reservationPrice.getPrice() <= 0) {
                throw new ServiceException(Error.product_not_available,
                        "Total or Price is null or less/equals 0 returned from handler");
            }

            reservationPrice = ReservationService.computeLivePrice(sqlSession, reservation, reservationPrice,
                    currency);

            response.setDamageInsurance(0.0);
            response.setCleaningFee(0.0);
        }

        if (reservationPrice.getTotal() == null || reservationPrice.getTotal() <= 0) {
            throw new ServiceException(Error.product_not_available,
                    "From:" + reservation.getFromdate() + "-" + reservation.getTodate());
        }

        if (reservationPrice.getQuoteDetails() == null) {
            reservationPrice.setQuoteDetails(new ArrayList<QuoteDetail>());
        }

        // add yield rules to quotes detail response
        if (reservation.getQuotedetail() != null && reservation.getQuotedetail().size() > 0) {
            for (Price price : reservation.getQuotedetail()) {
                if (price.getType() != null && price.getType().equals(Price.YIELD)) {
                    reservationPrice.getQuoteDetails().add(new QuoteDetail(String.valueOf(price.getValue()),
                            reservation.getCurrency(), price.getName(), Price.YIELD, "", true));
                }
            }
        }

        // Round response quoteDetail values to tenths
        for (QuoteDetail quoteDetail : reservationPrice.getQuoteDetails()) {
            Double amount = Double.valueOf(quoteDetail.getAmount());
            quoteDetail.setAmount(String.valueOf(round(amount, 2, BigDecimal.ROUND_HALF_UP)));
        }

        // Cancellation start

        Set<CancellationItem> cancellationItems = PaymentHelper.getCancellationItems(sqlSession, reservation);
        response.setCancellationItems(cancellationItems);

        // Cancellation end

        response.setReservationPrice(reservationPrice);

        String terms = propertyManagerInfo.getTermsLink() == null ? "" : propertyManagerInfo.getTermsLink();
        response.setTermsLink(terms);

        // Taxes calculation
        ArrayList<net.cbtltd.shared.Price> pricedetails = reservation.getQuotedetail();

        Double taxrate = 0.0;

        if (pricedetails != null) {
            Double tax = 0.0;
            for (net.cbtltd.shared.Price pricedetail : pricedetails) {
                pricedetail.setValue(NameId.round(pricedetail.getValue()));
                if (pricedetail.getValue() > 0.0 && (pricedetail.hasType(net.cbtltd.shared.Price.TAX_EXCLUDED)
                        || pricedetail.hasType(net.cbtltd.shared.Price.TAX_INCLUDED)
                        || pricedetail.hasType(net.cbtltd.shared.Price.TAX_ON_TAX))) {
                    tax += pricedetail.getValue();
                }
            }
            taxrate = (reservation.getQuote() == null || reservation.getQuote() <= 0.0 || tax == null) ? 0.0
                    : tax * 100 / (reservation.getQuote() - tax);
        }
        // End taxes

        response.setPrice(round(reservation.getPrice(), 2, BigDecimal.ROUND_HALF_UP));
        response.setQuote(round(reservation.getQuote(), 2, BigDecimal.ROUND_HALF_UP));
        response.setCurrency(reservation.getCurrency());
        response.setTax(round(taxrate, 2, BigDecimal.ROUND_HALF_UP));
        JSONService.LOG.debug("getDeposit " + product.getSupplierid() + ", " + fromDateString);
        response.setDeposit(
                round(ReservationService.getDeposit(sqlSession, reservation), 2, BigDecimal.ROUND_HALF_UP));

        PropertyManagerSupportCC propertyManagerSupportCC = sqlSession
                .getMapper(PropertyManagerSupportCCMapper.class)
                .readbypartyid(propertyManagerInfo.getPropertyManagerId());

        if (propertyManagerSupportCC == null) { // set all credit card types to false in case of inability to find the PropertyManagerSupportCC in DB 
            propertyManagerSupportCC = new PropertyManagerSupportCC();
            propertyManagerSupportCC.setNone(false);
            propertyManagerSupportCC.setPartyId(Integer.valueOf(product.getSupplierid()));
            propertyManagerSupportCC.setSupportAE(false);
            propertyManagerSupportCC.setSupportDINERSCLUB(false);
            propertyManagerSupportCC.setSupportDISCOVER(false);
            propertyManagerSupportCC.setSupportJCB(false);
            propertyManagerSupportCC.setSupportMC(false);
            propertyManagerSupportCC.setSupportVISA(false);
            LOG.error("cannot find propertyManagerSupportCC for PM [" + propertyManagerId + "] in database");
        }
        response.setPropertyManagerSupportCC(propertyManagerSupportCC);

        String chargeType = PaymentHelper.getChargeType(propertyManagerInfo, reservation);

        // Setting amounts to both of payments. If deposit is 100%, than second payment is 0.
        Double firstPayment = round(PaymentHelper.getFirstPayment(reservation, propertyManagerInfo), 2,
                BigDecimal.ROUND_HALF_UP);
        Double secondPayment = round(PaymentHelper.getSecondPayment(reservation, propertyManagerInfo), 2,
                BigDecimal.ROUND_HALF_UP);
        if (PaymentHelper.isDepositPaymentMethod(chargeType)) {
            response.setFirstPayment(firstPayment);
            DateFormat DF = new SimpleDateFormat("yyyy-MM-dd");
            response.setSecondPayment(round(PaymentHelper.getSecondPayment(reservation, propertyManagerInfo), 2,
                    BigDecimal.ROUND_HALF_UP));
            response.setSecondPaymentDate(
                    DF.format(PaymentHelper.getSecondChargeDate(reservation, propertyManagerInfo)));
        } else {
            response.setFirstPayment(firstPayment + secondPayment);
            response.setSecondPayment(0.0);
            response.setSecondPaymentDate("");
        }
        // end setting

        // Minstay calculation block
        if (PartyIds.PARTY_INTERHOME_ID.equals(product.getSupplierid())
                || PartyIds.PARTY_RENTALS_UNITED_ID.equals(product.getSupplierid())) {
            MinStay minstayAction = new MinStay(product.getSupplierid(), product.getId(), fromDate, toDate, 0);
            minstayAction = sqlSession.getMapper(PropertyMinStayMapper.class).readbyexample(minstayAction);
            if (minstayAction != null && minstayAction.getValue() != null && minstayAction.getValue() > 0) {
                response.setMinstay(minstayAction.getValue());
            }
        } else {
            Price checkInPrice = null;
            Price action = new Price();
            action.setPartyid(product.getSupplierid());
            action.setEntitytype(NameId.Type.Product.name());
            action.setEntityid(product.getId());
            action.setDate(fromDate);
            action.setTodate(toDate);
            action.setCurrency(currency);
            if (product.getUseonepricerow() != null && product.getUseonepricerow()) {
                checkInPrice = sqlSession.getMapper(PriceMapper.class).readexactmatch(action);
            } else {
                checkInPrice = sqlSession.getMapper(PriceMapper.class).getpropertydetailcheckinprice(action);
            }
            if (checkInPrice != null && checkInPrice.getMinStay() != null && checkInPrice.getMinStay() > 0) {
                response.setMinstay(checkInPrice.getMinStay());
            }
        }
        // End minstay         

        reservation.setCollisions(ReservationService.getCollisions(sqlSession, reservation));
        response.setPaymentSupported(PaymentHelper.isPaymentSupported(propertyManagerInfo));
        boolean available = sqlSession.getMapper(ReservationMapper.class).available(reservation);
        response.setAvailable(available && reservation.noCollisions());
        response.setImageUrl(ImageService.getProductDefaultImageURL(sqlSession, product.getId()));
        response.setPropertyName(product.getName());

        if (!available) {
            throw new ServiceException(Error.product_not_available);
        }
    } catch (ParseException x) {
        response.setErrorMessage(x.getMessage() == null ? "Null message" : x.getMessage());
        LOG.error(x.getMessage());
    } catch (Throwable x) {
        response.setPrice(0.0);
        response.setQuote(0.0);
        response.setErrorMessage(x.getMessage() == null ? "Null message" : x.getMessage());
        LOG.error(x.getMessage());
    } finally {
        sqlSession.close();
    }
    return response;
}

From source file:autoInsurance.BeiJPiccImpl.java

String round(String num) {
    BigDecimal big = new BigDecimal(num);
    BigDecimal result = big.divide(new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP);
    return result.toString();
}

From source file:fr.paris.lutece.plugins.suggest.web.SuggestJspBean.java

/**
 * Gets the form statistics page/*from ww w .j  av  a2s.c  om*/
 *
 * @param request
 *            the http request
 * @return the form test page
 */
public String getStatistics(HttpServletRequest request) {
    Plugin plugin = getPlugin();
    Locale locale = getLocale();
    Timestamp tFirstDateFilter = null;
    Timestamp tLastDateFilter = null;
    SuggestFilter suggestFilter = new SuggestFilter();
    suggestFilter.setIdState(Suggest.STATE_ENABLE);

    List<Suggest> listSuggest = SuggestHome.getSuggestList(suggestFilter, plugin);

    String strIdSuggest = request.getParameter(PARAMETER_ID_SUGGEST);
    String strFirstDateFilter = request.getParameter(PARAMETER_FIRST_DATE_FILTER);
    String strLastDateFilter = request.getParameter(PARAMETER_LAST_DATE_FILTER);
    String strIdCategory = request.getParameter(PARAMETER_ID_CATEGORY_FILTER);
    String strIdType = request.getParameter(PARAMETER_ID_TYPE_SUGGEST);

    int nIdCategory = SuggestUtils.getIntegerParameter(strIdCategory);
    int nIdType = SuggestUtils.getIntegerParameter(strIdType);

    if ((strIdSuggest != null) && !strIdSuggest.equals(EMPTY_STRING)) {
        _nIdSuggest = SuggestUtils.getIntegerParameter(strIdSuggest);
    } else if (listSuggest.size() > 0) {
        _nIdSuggest = listSuggest.get(0).getIdSuggest();
    }

    Suggest suggest = SuggestHome.findByPrimaryKey(_nIdSuggest, plugin);

    if ((strFirstDateFilter != null) && !strFirstDateFilter.equals("")) {
        try {
            tFirstDateFilter = new Timestamp(DateUtil.formatDate(strFirstDateFilter, locale).getTime());
        } catch (Exception e) {
            tFirstDateFilter = null;
        }
    }

    if ((strLastDateFilter != null) && !strLastDateFilter.equals("")) {
        try {
            tLastDateFilter = new Timestamp(DateUtil.formatDate(strLastDateFilter, locale).getTime());
        } catch (Exception e) {
            tLastDateFilter = null;
        }
    }

    // build Filter
    SubmitFilter filter = new SubmitFilter();
    filter.setIdSuggest(_nIdSuggest);
    filter.setDateFirst(tFirstDateFilter);
    filter.setDateLast(tLastDateFilter);
    filter.setIdCategory(nIdCategory);
    filter.setIdType(nIdType);

    // number of comments
    filter.setIdSuggestSubmitState(SuggestSubmit.STATE_PUBLISH);

    int nNbComments = _commentSubmitService.getCountCommentSubmit(filter, plugin);

    // number of votes
    filter.setIdSuggestSubmitState(SuggestSubmit.STATE_PUBLISH);

    int nNbVotes = 0;

    List<SuggestSubmit> listSuggestSubmit = _suggestSubmitService.getSuggestSubmitList(filter, plugin);
    List<String> listUsersKey = new ArrayList<String>();

    for (SuggestSubmit d : listSuggestSubmit) {
        nNbVotes += d.getNumberVote();

        if (!listUsersKey.contains(d.getLuteceUserKey())) {
            listUsersKey.add(d.getLuteceUserKey());
        }
    }

    // number of suggest submit
    filter.setIdSuggestSubmitState(SuggestSubmit.STATE_DISABLE);

    int nNbSuggestSubmitDisabled = _suggestSubmitService.getCountSuggestSubmit(filter, plugin);
    filter.setIdSuggestSubmitState(SuggestSubmit.STATE_WAITING_FOR_PUBLISH);

    int nNbSuggestSubmitWaiting = _suggestSubmitService.getCountSuggestSubmit(filter, plugin);
    filter.setIdSuggestSubmitState(SuggestSubmit.STATE_PUBLISH);

    int nNbSuggestSubmitPublished = _suggestSubmitService.getCountSuggestSubmit(filter, plugin);

    // high scores
    SuggestUtils.initSubmitFilterBySort(filter, SubmitFilter.SORT_BY_SCORE_DESC);

    int nNumberMaxSuggestSubmit = AppPropertiesService.getPropertyInt(PROPERTY_SUGGESTSUBMIT_HIGHSCORES, 10);
    listSuggestSubmit = _suggestSubmitService.getSuggestSubmitList(filter, plugin, nNumberMaxSuggestSubmit);

    ReferenceList refSuggestList = SuggestUtils.getRefListSuggest(listSuggest, false);

    Map<String, Object> model = new HashMap<String, Object>();

    model.put(MARK_FIRST_DATE_FILTER, (tFirstDateFilter == null) ? null : new Date(tFirstDateFilter.getTime()));
    model.put(MARK_LAST_DATE_FILTER, (tLastDateFilter == null) ? null : new Date(tLastDateFilter.getTime()));
    model.put(MARK_SUGGEST, suggest);

    if (nNbSuggestSubmitPublished != 0) {
        float fV = (float) nNbVotes / nNbSuggestSubmitPublished;
        float fC = (float) nNbComments / nNbSuggestSubmitPublished;

        BigDecimal bd = new BigDecimal(fV);
        bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP);

        BigDecimal bd2 = new BigDecimal(fC);
        bd2 = bd2.setScale(2, BigDecimal.ROUND_HALF_UP);

        model.put(MARK_NUMBER_VOTES, bd.toString());
        model.put(MARK_NUMBER_COMMENTS, bd2.toString());
    }

    if ((suggest.getCategories() != null) && !suggest.getCategories().isEmpty()) {
        ReferenceList refCategoryList = SuggestUtils.getRefListCategory(suggest.getCategories());
        SuggestUtils.addEmptyItem(refCategoryList);
        model.put(MARK_CATEGORY_LIST, refCategoryList);
        model.put(MARK_SUGGEST_SUBMIT_CATEGORY_SELECTED, nIdCategory);

        if (nIdCategory != SuggestUtils.CONSTANT_ID_NULL) {
            model.put(MARK_CATEGORY_FILTER, CategoryHome.findByPrimaryKey(nIdCategory, plugin));
        }
    }

    if ((suggest.getSuggestSubmitTypes() != null) && !suggest.getSuggestSubmitTypes().isEmpty()) {
        ReferenceList refSuggestSubmitTypes = SuggestUtils.getRefListType(suggest.getSuggestSubmitTypes());
        SuggestUtils.addEmptyItem(refSuggestSubmitTypes);
        model.put(MARK_SUGGEST_SUBMIT_TYPE_LIST, refSuggestSubmitTypes);
        model.put(MARK_SUGGEST_SUBMIT_TYPE_SELECTED, nIdType);

        if (nIdType != SuggestUtils.CONSTANT_ID_NULL) {
            model.put(MARK_TYPE_FILTER, SuggestSubmitTypeHome.findByPrimaryKey(nIdType, plugin));
        }
    }

    model.put(MARK_NUMBER_SUGGESTSUBMIT_DISABLED, nNbSuggestSubmitDisabled);
    model.put(MARK_NUMBER_SUGGESTSUBMIT_WAITING, nNbSuggestSubmitWaiting);
    model.put(MARK_NUMBER_SUGGESTSUBMIT_PUBLISHED, nNbSuggestSubmitPublished);
    model.put(MARK_NUMBER_USERS, listUsersKey.size());
    model.put(MARK_HIGH_SCORES, listSuggestSubmit);
    model.put(MARK_SUGGEST_LIST, refSuggestList);
    model.put(MARK_URL, AppPathService.getBaseUrl(request) + JSP_MANAGE_COMMENT_SUBMIT + "?id_suggest_submit=");

    HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_STATISTICS_SUGGEST, locale, model);

    return getAdminPage(template.getHtml());
}

From source file:com.selfsoft.business.service.impl.TbFixEntrustServiceImpl.java

public Map putEntrustBalanceReportParamMap(Long id, HttpServletRequest request) {

    Map map = new HashMap();
    // ?/*from   ww w. j  a va  2 s  .  co  m*/
    TbFixEntrust tbFixEntrust = this.findById(id);

    // ?
    TbCustomer tbCustomer = tbCustomerService.findById(tbFixEntrust.getTbCustomer().getId());
    // ?
    TbCarInfo tbCarInfo = tbCarInfoService.findById(tbFixEntrust.getTbCarInfo().getId());
    // ??
    TmCompany tmCompany = tmCompanyService.acquireUniqueTmCompany();

    // ?
    List<TbFixEntrustContent> tbFixEntrustContentList = tbFixEntrustContentService
            .findTbFixEnTrustContentListByTbFixEntrustId(tbFixEntrust.getId());

    /**
     * add 2010-12-17 ccr
     */
    List<TbFixEntrustContent> tbFixEntrustContentListPage = new ArrayList<TbFixEntrustContent>();

    List<TbFixEntrustContent> tbFixEntrustContentListTemp = new ArrayList<TbFixEntrustContent>();

    List<TbFixEntrustContent> tbFixEntrustContentListAdd = new ArrayList<TbFixEntrustContent>();

    if (null != tbFixEntrustContentList && tbFixEntrustContentList.size() > 0) {

        for (int i = 0; i < tbFixEntrustContentList.size(); i++) {

            boolean flag = false;

            if (tbFixEntrustContentListTemp.size() == 0) {

                tbFixEntrustContentListTemp.add(tbFixEntrustContentList.get(i));

            } else {
                if (tbFixEntrustContentListTemp.size() > 1) {

                    for (TbFixEntrustContent _tbFixEntrustContent : tbFixEntrustContentListTemp) {

                        if (_tbFixEntrustContent.getStationName()
                                .equals(tbFixEntrustContentList.get(i).getStationName())
                                && _tbFixEntrustContent.getTbWorkingInfo().getId()
                                        .equals(tbFixEntrustContentList.get(i).getTbWorkingInfo().getId())
                                && _tbFixEntrustContent.getFreesymbol()
                                        .equals(tbFixEntrustContentList.get(i).getFreesymbol())

                        ) {

                            flag = true;

                            break;

                        }

                    }

                }

            }

            if (flag) {

                continue;

            } else {

                tbFixEntrustContentListTemp.add(tbFixEntrustContentList.get(i));

            }

            TbFixEntrustContent temp = tbFixEntrustContentList.get(i);

            TbFixEntrustContent tempCopy = new TbFixEntrustContent();

            BigDecimal d = new BigDecimal(temp.getFixHourAll());

            BigDecimal d2 = new BigDecimal(temp.getFixHour());

            for (int j = i + 1; j < tbFixEntrustContentList.size(); j++) {

                if (temp.getStationName().equals(tbFixEntrustContentList.get(j).getStationName())
                        && temp.getTbWorkingInfo().getId()
                                .equals(tbFixEntrustContentList.get(j).getTbWorkingInfo().getId())
                        && temp.getFreesymbol().equals(tbFixEntrustContentList.get(j).getFreesymbol())) {

                    d = d.add(new BigDecimal(tbFixEntrustContentList.get(j).getFixHourAll()));

                    d2 = d2.add(new BigDecimal(tbFixEntrustContentList.get(j).getFixHour()));

                }

            }

            try {
                BeanUtils.copyProperties(tempCopy, temp);
            } catch (IllegalAccessException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            tempCopy.setFixHourAll(d.doubleValue());

            tempCopy.setFixHour(d2.doubleValue());

            if (!tempCopy.getFreesymbol().equals(1d) || !tempCopy.getFixHourAll().equals(0d)) {

                tbFixEntrustContentListAdd.add(tempCopy);

            }

        }

    }

    if (tbFixEntrustContentListAdd.size() == 0) {

        TbFixEntrustContent t = new TbFixEntrustContent();

        t.setStationName("");

        tbFixEntrustContentListAdd.add(t);

    }

    // ??
    /*
     * List<TbMaintianVo> maintianvos = tbMaintainPartContentService
     * .getTbMaintianDetailVosByEntrustId(tbFixEntrust.getId(),
     * Constants.BALANCE_ALL);
     */
    /* update by baijx ?? */
    //      List<TbMaintianVo> maintianvos = tbMaintainPartContentService
    //            .getTbMaintianDetailVosByEntrustIdPrint(tbFixEntrust.getId(),
    //                  Constants.BALANCE_ALL);
    List<TbMaintainPartContent> result = tbMaintainPartContentService
            .getViewEntrustMaintianContent(tbFixEntrust.getId());
    List<TbMaintianVo> maintianvos = null;

    if (result != null && result.size() > 0) {
        maintianvos = tbMaintainPartContentService.getTbMaintianDetailVos(result.get(0).getMaintainCode());

    }

    // ?
    List<TmStockOutDetVo> tmStockOutDetVos = tmStockOutService
            .getSellDetailByEntrustCode(tbFixEntrust.getEntrustCode(), Constants.BALANCE_ALL);
    // 
    // List<TbBusinessBalanceItem> tbBusinessBalanceItemList =
    // tbBusinessBalanceItemService.findGroupTbBusinessBalanceItemListByTbBusinessBalanceId(tbBusinessBalance.getId());
    List<TbBusinessBalanceItem> tbBusinessBalanceItemList = new ArrayList<TbBusinessBalanceItem>();
    // ???
    if (null == maintianvos) {
        maintianvos = new ArrayList<TbMaintianVo>();
    }

    if (null != tmStockOutDetVos && tmStockOutDetVos.size() > 0) {

        for (TmStockOutDetVo tmStockOutDetVo : tmStockOutDetVos) {

            TbMaintianVo tbMaintianVo = new TbMaintianVo();

            tbMaintianVo.setPartId(tmStockOutDetVo.getPartinfoId());

            tbMaintianVo.setHouseName(tmStockOutDetVo.getHouseName());

            tbMaintianVo.setPartCode(tmStockOutDetVo.getPartCode());

            tbMaintianVo.setPartName(tmStockOutDetVo.getPartName());

            tbMaintianVo.setUnitName(tmStockOutDetVo.getUnitName());

            tbMaintianVo.setPrice(tmStockOutDetVo.getPrice());

            tbMaintianVo.setPartQuantity(tmStockOutDetVo.getQuantity());

            tbMaintianVo.setTotal(tmStockOutDetVo.getTotal());

            tbMaintianVo.setIsFree(tmStockOutDetVo.getIsFree());

            maintianvos.add(tbMaintianVo);
        }

    }

    /**
     * add by ccr 2010-12-18
     */
    List<TbMaintianVo> maintianvosTemp = new ArrayList<TbMaintianVo>();

    List<TbMaintianVo> maintianvosAdd = new ArrayList<TbMaintianVo>();

    if (maintianvos.size() > 0) {

        for (int i = 0; i < maintianvos.size(); i++) {

            boolean flag = false;

            if (maintianvosTemp.size() == 0) {

                maintianvosTemp.add(maintianvos.get(i));

            } else {

                if (maintianvosTemp.size() > 1) {

                    int l = 0;

                    for (TbMaintianVo _tbMaintianVo : maintianvosTemp) {

                        if (_tbMaintianVo.getPartId().equals(maintianvos.get(i).getPartId())
                                && _tbMaintianVo.getIsFree().equals(maintianvos.get(i).getIsFree())
                                && _tbMaintianVo.getPrice().equals(maintianvos.get(i).getPrice())) {

                            // maintianvosTemp.set(l, maintianvos.get(i));

                            flag = true;

                            break;

                        }

                        l++;

                    }

                }

            }

            if (flag) {

                continue;

            } else {

                maintianvosTemp.add(maintianvos.get(i));

            }

            TbMaintianVo temp = maintianvos.get(i);

            BigDecimal d1 = new BigDecimal(temp.getPartQuantity());

            BigDecimal d2 = new BigDecimal(temp.getTotal());

            for (int j = i + 1; j < maintianvos.size(); j++) {

                if (temp.getPartId().equals(maintianvos.get(j).getPartId())
                        && temp.getIsFree().equals(maintianvos.get(j).getIsFree())
                        && temp.getPrice().equals(maintianvos.get(j).getPrice())) {

                    temp.setPrice(maintianvos.get(j).getPrice());

                    d1 = d1.add(new BigDecimal(maintianvos.get(j).getPartQuantity()));

                    d2 = d2.add(new BigDecimal(maintianvos.get(j).getTotal()));

                }

            }

            temp.setPartQuantity(d1.doubleValue());

            temp.setTotal(d2.doubleValue());

            if (!temp.getIsFree().equals(1L) || !temp.getPartQuantity().equals(0d)) {

                /*
                 * temp.setPrice(new BigDecimal(temp.getTotal()).divide(new
                 * BigDecimal(temp.getPartQuantity()),2,
                 * BigDecimal.ROUND_HALF_UP).setScale(2,
                 * BigDecimal.ROUND_HALF_UP).doubleValue());
                 */

                maintianvosAdd.add(temp);

            }

        }

    }

    TbCardHis tbCardHis = null;

    // if (null != tbCardHisService.findCardHisByBalanceId(tbBusinessBalance
    // .getId())
    // && tbCardHisService.findCardHisByBalanceId(
    // tbBusinessBalance.getId()).size() > 0) {
    //
    // tbCardHis = tbCardHisService.findCardHisByBalanceId(
    // tbBusinessBalance.getId()).get(0);
    //
    // }

    Map reportParameters = new HashMap();
    // ??
    reportParameters.put("balanceCode", "");
    // ?
    reportParameters.put("entrustCode", tbFixEntrust.getEntrustCode());

    if (null != tbCardHis) {

        reportParameters.put("oriCardSaving", tbCardHis.getOriCardSaving());

        reportParameters.put("giveMoney", Double.valueOf(tbCardHis.getGiveMoney()));

        reportParameters.put("aftCardSaving", tbCardHis.getAftCardSaving());

    } else {

        reportParameters.put("oriCardSaving", 0.00D);

        reportParameters.put("giveMoney", 0.00D);

        reportParameters.put("aftCardSaving", 0.00D);
    }

    if (null != tmStockOutDetVos && tmStockOutDetVos.size() > 0) {
        // ??
        reportParameters.put("stockOutCode", tmStockOutDetVos.get(0).getStockOutCode());
    }

    if ("?????".equals(tmCompany.getCompanyName().trim())) {

        reportParameters.put("stockOutCode",
                CommonMethod.parseDateToString(tbFixEntrust.getFixDate(), "yyyy-MM-dd HH:mm:ss"));
    }

    // ?
    reportParameters.put("licenseCode", tbCarInfo.getLicenseCode());

    if (null != tbCarInfo.getTmCarModelType()) {
        // 
        reportParameters.put("modelType", tbCarInfo.getTmCarModelType().getModelName());
    }

    // 
    reportParameters.put("customerName", tbCustomer.getCustomerName());

    // 
    reportParameters.put("balanceDate",
            CommonMethod.parseDateToString(tbFixEntrust.getFixDate(), "yyyy-MM-dd"));

    // 
    reportParameters.put("payPatten", "");

    // ?
    reportParameters.put("fixType", tbFixEntrust.getTmFixType().getFixType());

    // ?
    reportParameters.put("chassisCode", tbCarInfo.getChassisCode());

    // ??
    reportParameters.put("engineCode", tbCarInfo.getEngineCode());

    // 
    reportParameters.put("purchaseDate",
            CommonMethod.parseDateToString(tbCarInfo.getPurchaseDate(), "yyyy-MM-dd"));

    // ?
    reportParameters.put("phone",
            tbCustomer.getPhone() == null ? ""
                    : tbCustomer.getPhone().trim() + "  " + tbCustomer.getTelephone() == null ? ""
                            : tbCustomer.getTelephone().trim());

    // ?
    reportParameters.put("address", tbCustomer.getAddress());

    // 
    /*
     * reportParameters.put("kilo", tbCarInfo.getKilo() == null ? "" :
     * String .valueOf(tbCarInfo.getKilo()));
     */
    reportParameters.put("kilo", tbFixEntrust.getEnterStationKilo() == null ? ""
            : String.valueOf(tbFixEntrust.getEnterStationKilo()));

    // 
    reportParameters.put("remark", tbFixEntrust.getRemark());

    // ??
    reportParameters.put("companyName", tmCompany.getCompanyName());

    reportParameters.put("companyAddress", tmCompany.getCompanyAddress());

    reportParameters.put("companyPhone", tmCompany.getCompanyPhone());

    reportParameters.put("companyTaxCode", tmCompany.getTaxCode());

    reportParameters.put("companyAccount", tmCompany.getCompanyAccount());

    reportParameters.put("serviceLeader", tmCompany.getServiceLeader());

    reportParameters.put("companyZipCode", tmCompany.getCompanyZipCode());

    reportParameters.put("companyBankName", tmCompany.getBankName());
    // ??

    // ?
    reportParameters.put("userRealName", tbFixEntrust.getTmUser().getUserRealName());
    // 
    // reportParameters.put("jsUserRealName",
    // tbBusinessBalance.getTmUser().getUserRealName());
    // ?
    reportParameters.put("printDate", CommonMethod.parseDateToString(new Date(), "yyyy-MM-dd HH:mm:ss"));
    // ?
    reportParameters.put("SUBREPORT_DIR", request.getRealPath("/reportfiles/") + "/");
    // ???-

    reportParameters.put("subdatasource_0", new JRBeanCollectionDataSource(tbFixEntrustContentListAdd));

    // ???-
    // List<TbBusinessBalanceItem> tbBusinessBalanceItemListSend = new
    // ArrayList<TbBusinessBalanceItem>();
    //
    // if (null != tbBusinessBalanceItemList
    // && tbBusinessBalanceItemList.size() > 0) {
    //
    // for (TbBusinessBalanceItem tbBusinessBalanceItem :
    // tbBusinessBalanceItemList) {
    //
    // if ("XLCLF".equals(tbBusinessBalanceItem.getBalanceItemCode())) {
    //
    // reportParameters.put("xlclf",
    // tbBusinessBalanceItem.getBalanceItemTotal());
    //
    // continue;
    // }
    //
    // if ("XLGSF".equals(tbBusinessBalanceItem.getBalanceItemCode())) {
    //
    // reportParameters.put("xlgsf",
    // tbBusinessBalanceItem.getBalanceItemTotal());
    //
    // continue;
    // }
    //
    // if ("SE".equals(tbBusinessBalanceItem.getBalanceItemCode())) {
    //
    // reportParameters.put("taxAmount",
    // tbBusinessBalanceItem.getBalanceItemTotal());
    //
    // continue;
    // }
    //
    // if ("ZJE".equals(tbBusinessBalanceItem.getBalanceItemCode())) {
    //
    // reportParameters.put("totalAmount",
    // tbBusinessBalanceItem.getBalanceItemTotal());
    //
    // continue;
    // }
    // if ("XSJE".equals(tbBusinessBalanceItem.getBalanceItemCode())) {
    //
    // reportParameters.put("xsje",
    // tbBusinessBalanceItem.getBalanceItemTotal());
    //
    // continue;
    // }
    // tbBusinessBalanceItemListSend.add(tbBusinessBalanceItem);
    //
    // }
    //
    // }

    List<TbMaintainPartContent> tcList = tbMaintainPartContentService
            .getViewEntrustMaintianContent(tbFixEntrust.getId());

    if (null != tcList && tcList.size() > 0) {

        tbFixEntrust.setStockOutPartTotal(
                new BigDecimal(tcList.get(0).getTotalPrice()).setScale(2, BigDecimal.ROUND_HALF_UP));

    }

    tbFixEntrust.setFixHourTotal(new BigDecimal(
            tbFixEntrustContentService.countTbFixEnTrustContentByTbFixEntrustId(tbFixEntrust.getId()))
                    .setScale(2, BigDecimal.ROUND_HALF_UP));

    tbFixEntrust.setSolePartTotal(
            new BigDecimal(tmStockOutService.getTotalPriceByEntrustCode(tbFixEntrust.getEntrustCode()))
                    .setScale(2, BigDecimal.ROUND_HALF_UP));

    reportParameters.put("xlclf", tbFixEntrust.getStockOutPartTotal().doubleValue());

    reportParameters.put("xlgsf", tbFixEntrust.getFixHourTotal().doubleValue());

    reportParameters.put("xsje", tbFixEntrust.getSolePartTotal().doubleValue());

    tbFixEntrust.setAllTotal(tbFixEntrust.getFixHourTotal()
            .add(tbFixEntrust.getStockOutPartTotal().add(tbFixEntrust.getSolePartTotal())));

    // ??
    reportParameters.put("totalAmount", tbFixEntrust.getAllTotal().doubleValue());
    // ???
    // reportParameters.put("partFavourAmount",this.calcItemFavourAmount(tbBusinessBalance,
    // "XLCLF"));
    // ?
    // reportParameters.put("fixFavourAmount",this.calcItemFavourAmount(tbBusinessBalance,
    // "XLGSF"));
    // ?
    // reportParameters.put("soleFavourAmount",this.calcItemFavourAmount(tbBusinessBalance,
    // "XSJE"));
    // ??
    //reportParameters.put("subdatasource_1", new JRBeanCollectionDataSource(tbBusinessBalanceItemListSend));

    map.put("reportParameters", reportParameters);

    map.put("dataSourceList", maintianvosAdd);

    if ("?????".equals(tmCompany.getCompanyName().trim())) {

        reportParameters.put("purchaseDate",
                CommonMethod.parseDateToString(tbCarInfo.getProductDate(), "yyyy-MM-dd"));

        map.put("jrxmlPath", "/reportfiles/tbBusinessBalance_gxnndz.jrxml");

    } else if ("?".equals(tmCompany.getCompanyName().trim())) {

        map.put("jrxmlPath", "/reportfiles/tbBusinessBalance_hbhs.jrxml");
    }

    else {

        map.put("jrxmlPath", "/reportfiles/tbBusinessBalance_pre.jrxml");

    }

    map.put("reportTpl", "/tbMaintianVo_WXFL_pdf_tpl.properties");

    return map;

}

From source file:org.egov.ptis.domain.service.property.PropertyExternalService.java

public TaxCalculatorResponse calculateTaxes(TaxCalculatorRequest taxCalculatorRequest) throws ParseException {
    TaxCalculatorResponse taxCalculatorResponse = new TaxCalculatorResponse();
    BigDecimal taxVariance;//w w w .  j  a v a2  s  .c  o m
    BigDecimal arvVariance;
    final Map<String, Installment> currYearInstMap = propertyTaxUtil.getInstallmentsForCurrYear(new Date());
    PropertyService propService = beanProvider.getBean(PROP_SERVICE, PropertyService.class);
    BasicProperty basicProperty = basicPropertyDAO
            .getBasicPropertyByPropertyID(taxCalculatorRequest.getAssessmentNo());
    PropertyImpl propertyImpl = (PropertyImpl) basicProperty.getProperty();
    taxCalculatorResponse.setAssessmentNo(basicProperty.getUpicNo());
    taxCalculatorResponse.setZoneNo(basicProperty.getPropertyID().getZone().getBoundaryNum());

    if (propertyImpl != null) {
        if (StringUtils.isNotBlank(propertyImpl.getReferenceId()))
            taxCalculatorResponse.setReferenceId(propertyImpl.getReferenceId());

        Map<String, BigDecimal> calculationsMap = getARVAndTaxDetails(propService, propertyImpl,
                currYearInstMap.get(CURRENTYEAR_SECOND_HALF), false);
        taxCalculatorResponse.setExistingARV(calculationsMap.get(ARV));
        taxCalculatorResponse.setExistingHalfYearlyTax(calculationsMap.get(HALF_YEARLY_TAX));
        Date effectiveDate = DateUtils.getDate(TAX_CALCULATIONS_EFFECTIVE_DATE, DATE_FORMAT_DDMMYYY);
        propertyImpl.setReferenceId(taxCalculatorRequest.getReferenceId());
        prepareFloorDetailsForTaxCalculation(taxCalculatorRequest, propertyImpl, effectiveDate);
        Date completionDate = getCompletionDate(propService, propertyImpl);
        try {
            propService.createDemand(propertyImpl, completionDate);
        } catch (TaxCalculatorExeption e) {
            LOGGER.error("create : There are no Unit rates defined for chosen combinations", e);
        }
        calculationsMap = getARVAndTaxDetails(propService, propertyImpl,
                currYearInstMap.get(CURRENTYEAR_SECOND_HALF), true);
        taxCalculatorResponse.setCalculatedARV(calculationsMap.get(ARV));
        taxCalculatorResponse.setNewHalfYearlyTax(calculationsMap.get(HALF_YEARLY_TAX));

        if (taxCalculatorResponse.getExistingHalfYearlyTax().compareTo(ZERO) > 0)
            taxVariance = ((taxCalculatorResponse.getNewHalfYearlyTax()
                    .subtract(taxCalculatorResponse.getExistingHalfYearlyTax())).multiply(BIGDECIMAL_100))
                            .divide(taxCalculatorResponse.getExistingHalfYearlyTax(), 1,
                                    BigDecimal.ROUND_HALF_UP);
        else
            taxVariance = BIGDECIMAL_100;
        taxCalculatorResponse.setTaxVariance(taxVariance);
        if (taxCalculatorResponse.getExistingARV().compareTo(ZERO) > 0) {
            arvVariance = ((taxCalculatorResponse.getCalculatedARV()
                    .subtract(taxCalculatorResponse.getExistingARV())).multiply(BIGDECIMAL_100))
                            .divide(taxCalculatorResponse.getExistingARV(), 1, BigDecimal.ROUND_HALF_UP);
        } else
            arvVariance = BIGDECIMAL_100;
        taxCalculatorResponse.setArvVariance(arvVariance);
    }
    return taxCalculatorResponse;
}

From source file:com.genscript.gsscm.product.service.ProductService.java

@Transactional(readOnly = true)
public List<SearchItemDTO> getSearchItemInfo(final List<String> catalogNoList) {
    if (catalogNoList != null && catalogNoList.size() > 0) {
        List<SearchItemDTO> searchItemDTOList = new ArrayList<SearchItemDTO>();
        for (String catalogNo : catalogNoList) {
            Product product = productDao.findUniqueBy("catalogNo", catalogNo);
            SearchItemDTO searchItemDTO = new SearchItemDTO();
            searchItemDTO.setCatalogNo(catalogNo);
            if (product != null) {
                searchItemDTO.setPrefStorage(product.getPrefStorage());
                searchItemDTO.setPrefWarehouse(product.getPrefWarehouse());
                searchItemDTO.setClsId(product.getProductClsId());
                searchItemDTO.setClsName(productClassDao.get(product.getProductClsId()).getName());
                searchItemDTO.setCustomerInfo(product.getCustomerInfo());
                searchItemDTO.setFullDesc(product.getLongDesc());
                searchItemDTO.setDescription(product.getShortDesc());
                searchItemDTO.setScheduleShip(product.getLeadTime());
                searchItemDTO.setTaxStatus(product.getTaxable());
                searchItemDTO.setSellingNote(product.getSellingNote());
                if (product.getUnitCost() != null)
                    searchItemDTO//from  w ww  . j  a va  2 s .c o m
                            .setCost(product.getUnitCost().setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
                searchItemDTO.setName(product.getName());
                searchItemDTO.setUom(product.getUom());
            }
            searchItemDTOList.add(searchItemDTO);
        }
        return searchItemDTOList;
    }
    return null;
}

From source file:com.genscript.gsscm.product.service.ProductService.java

@Transactional(readOnly = true)
public SearchItemDTO getSearchItemInfo(final String catalogNo) {
    if (StringUtils.isNotBlank(catalogNo)) {
        SearchItemDTO searchItemDTO = new SearchItemDTO();
        Product product = productDao.findUniqueBy("catalogNo", catalogNo);
        searchItemDTO.setCatalogNo(catalogNo);
        if (product != null) {
            searchItemDTO.setPrefStorage(product.getPrefStorage());
            searchItemDTO.setPrefWarehouse(product.getPrefWarehouse());
            searchItemDTO.setClsId(product.getProductClsId());
            searchItemDTO.setClsName(productClassDao.get(product.getProductClsId()).getName());
            searchItemDTO.setCustomerInfo(product.getCustomerInfo());
            searchItemDTO.setFullDesc(product.getLongDesc());
            searchItemDTO.setDescription(product.getShortDesc());
            searchItemDTO.setScheduleShip(product.getLeadTime());
            searchItemDTO.setTaxStatus(product.getTaxable());
            searchItemDTO.setSellingNote(product.getSellingNote());
            if (product.getUnitCost() != null)
                searchItemDTO//from ww  w.  ja va 2s .com
                        .setCost(product.getUnitCost().setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
            searchItemDTO.setName(product.getName());
            searchItemDTO.setUom(product.getUom());
        }
        return searchItemDTO;
    }
    return null;
}