Example usage for java.lang Double equals

List of usage examples for java.lang Double equals

Introduction

In this page you can find the example usage for java.lang Double equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares this object against the specified object.

Usage

From source file:ca.mudar.parkcatcher.ui.activities.MainActivity.java

@Override
public void onNewIntent(Intent intent) {
    initLocation = null;/*  w w  w.j  ava 2 s. c om*/

    Double latitude = intent.getDoubleExtra(Const.INTENT_EXTRA_GEO_LAT, Double.NaN);
    Double longitude = intent.getDoubleExtra(Const.INTENT_EXTRA_GEO_LNG, Double.NaN);

    if (!latitude.equals(Double.NaN) && !longitude.equals(Double.NaN)) {
        initLocation = new Location(Const.LOCATION_PROVIDER_INTENT);
        initLocation.setLatitude(latitude);
        initLocation.setLongitude(longitude);
        isCenterOnMyLocation = false;
    } else {
        isCenterOnMyLocation = true;
    }
}

From source file:com.hbc.api.trade.order.service.corder.COrderService.java

/**
 * @param order//from w  w w  .j a va  2 s . c om
 * @param paymentService
 * @param target
 */
private void setPriceInformation(OrderBean order, COrderDetailBean target) {
    PriceInfo priceInfo = new PriceInfo();
    OrderType orderType = OrderType.getType(order.getOrderType());
    if (OrderType.TRANSFER.equals(orderType)) {
        priceInfo.setCheckInPrice(order.getCheckInPrice());
    }
    priceInfo.setOrderPrice(OrderPal.getOrderPrice(order));

    priceInfo.setRefundablePrice(refundService.getRefundAmount(order.getOrderNo()));
    TradePayment tradePayment = paymentService.queryTradePaymentByOrderNoNoexp(order.getOrderNo(),
            PayStatus.SUCCESS);
    if (tradePayment != null) {
        if (OrderSource.GDS.value.equals(order.getOrderSource())) {
            priceInfo.setActualPay(order.getPriceTicket());
            priceInfo.setShouldPay(order.getPriceTicket());
            Double rprice = refundService.getRefundAmount(order.getOrderNo());
            if (rprice > 0) {
                priceInfo.setRefundablePrice(order.getPriceTicket());
            }
        } else {
            priceInfo.setActualPay(tradePayment.getPayActual() == null ? 0 : tradePayment.getPayActual());
            priceInfo.setShouldPay(tradePayment.getPayShould());
        }

        // ?
        List<TradeRefund> refundList = refundService.getAllRefunds(order.getOrderNo());
        priceInfo.setRefundPrice(0.0d);
        priceInfo.setCancelFee(getRefundFee(tradePayment, priceInfo.getRefundablePrice()));
        if (refundList != null && refundList.size() > 0) {
            Double refundPrice = 0.0;
            for (TradeRefund refund : refundList) {
                refundPrice += (refund.getRefundMoney() != null ? refund.getRefundMoney() : 0.0);
            }
            if (refundPrice.equals(order.getPriceChannel())) {
                refundPrice = order.getPriceTicket();
            }
            priceInfo.setRefundPrice(refundPrice);

            priceInfo.setCancelFee(getRefundFee(tradePayment, refundPrice));
        }
    } else {
        if (OrderSource.GDS.value.equals(order.getOrderSource())) {
            priceInfo.setShouldPay(order.getPriceTicket());
        } else {
            priceInfo.setShouldPay(order.getPriceChannel());
        }
    }
    target.setPriceInfo(priceInfo);
}

From source file:net.sourceforge.eclipsetrader.core.CurrencyConverter.java

public IStatus updateExchanges(IProgressMonitor monitor) {
    if (monitor != null)
        monitor.beginTask(Messages.CurrencyConverter_UpdatingTaskName, currencies.size() + 1);
    map.clear();//from   w ww .  ja v  a  2  s  .  c om

    Object[] symbols = currencies.toArray();
    for (int x = 0; x < symbols.length; x++) {
        for (int y = 0; y < symbols.length; y++) {
            if (x != y) {
                String s = (String) symbols[x] + (String) symbols[y];
                Double old = (Double) map.get(s);
                Double quote = downloadQuote(s);
                if (quote != null)
                    map.put(s, quote);
                else
                    map.remove(s);
                if (old == null && quote != null || old != null && !old.equals(quote))
                    setChanged();
                if (monitor != null && monitor.isCanceled())
                    return Status.CANCEL_STATUS;
            }
        }
        if (monitor != null)
            monitor.worked(1);
    }
    notifyObservers();

    save();
    if (monitor != null)
        monitor.worked(1);

    if (monitor != null)
        monitor.done();

    return Status.OK_STATUS;
}

From source file:com.jskj.assets.server.servcie.Yimiaodengji.YimiaodengjiService.java

@Override
public int saveYimiaotuihuodengji(Yimiaodengjitb yimiaodengji) {
    log.debug("insert yimiaodengji:" + yimiaodengji.getYmdjId());

    //??/*  w  ww .  ja va 2s.c om*/
    Backsale_detail_tbExample liebiaoexam = new Backsale_detail_tbExample();
    liebiaoexam.createCriteria().andBackDetailIdEqualTo(yimiaodengji.getXiangdanId());
    //??id??
    List<Backsale_detail_tb> yimiaolist = Backsale_detail_tbMapper.selectByExample(liebiaoexam);
    //??
    for (Backsale_detail_tb ym : yimiaolist) {
        liebiaoexam = new Backsale_detail_tbExample();
        liebiaoexam.createCriteria().andBackDetailIdEqualTo(ym.getBackDetailId());
        int stuts = ym.getStatus();
        //??? Backsale_detail_tb??3
        if (yimiaodengji.getQuantity().equals(ym.getQuantity())) {
            stuts = 4;//??4()
        } else if (ym.getBackDetailId().equals(yimiaodengji.getXiangdanId()) && ym.getStatus() == 3) {
            YiMiaotb yimiao = new YiMiaotb();
            yimiao = yimiaoMapper.selectByPrimaryKey(yimiaodengji.getYimiaoId());
            //??ID?
            YimiaodengjitbExample sqdexam = new YimiaodengjitbExample();
            sqdexam.createCriteria().andXiangdanIdEqualTo(ym.getBackDetailId()).andStatusEqualTo(4);//?4
            List<Yimiaodengjitb> sqdlist = mapper.selectByExample(sqdexam);
            Double chashu = 0d;
            Double shulian = chashu;

            //??            
            for (int i = 0; i < sqdlist.size(); i++) {
                //??
                chashu = Arith.decimal(chashu + sqdlist.get(i).getQuantity(), 5);
            }
            shulian = Arith.decimal(chashu + shulian, 5);
            Double strQuantity = Arith.round(Arith.mul(Arith.decimal(yimiaodengji.getQuantity() + shulian, 5),
                    Arith.div(1, yimiao.getYimiaoHuansuanlv(), 0)), 0);
            strQuantity = Arith.div(strQuantity, Arith.div(1, yimiao.getYimiaoHuansuanlv(), 0), 5);
            Double shul = strQuantity;
            //                    Double shul = Arith.decimal(yimiaodengji.getQuantity() + shulian, 5);
            if (!shul.equals(ym.getQuantity())) {
                stuts = 3;
                ym.setStatus(stuts);
                Backsale_detail_tbExample ymsqd = new Backsale_detail_tbExample();
                ymsqd.createCriteria().andBackDetailIdEqualTo(ym.getBackDetailId());
                Backsale_detail_tbMapper.updateByExample(ym, ymsqd);
            } else {
                stuts = 4;
            }

        }
        ym.setYouxiaoqi(yimiaodengji.getYouxiaoqi());
        ym.setPihao(yimiaodengji.getPihao());
        ym.setStatus(stuts);
        Backsale_detail_tbMapper.updateByExample(ym, liebiaoexam);

        /*barcode pool*/
        double num = yimiaodengji.getQuantity();
        Barcodepool pool = new Barcodepool();
        pool.setBarcodegroup(yimiaodengji.getBarcode());
        pool.setLabelId(yimiaodengji.getYimiaoId());
        pool.setQuantity(num);
        pool.setShenqingdanId(ym.getBacksaleId());
        pool.setXiangdanId(ym.getBackDetailId());
        pool.setStatus(6);//?
        barCodeService.saveBarCode(pool, true);
    }
    yimiaodengji.setStatus(4);//
    return mapper.insertSelective(yimiaodengji);
}

From source file:org.mifos.application.collectionsheet.struts.action.CollectionSheetEntryViewPostPreviewValidator.java

private ActionErrors validatePopulatedData(final CollectionSheetEntryView parent, final ActionErrors errors,
        final Locale locale) {
    List<CollectionSheetEntryView> children = parent.getCollectionSheetEntryChildren();

    ResourceBundle resources = ResourceBundle.getBundle(FilePaths.BULKENTRY_RESOURCE, locale);
    String acCollections = resources.getString(CollectionSheetEntryConstants.AC_COLLECTION);
    if (null != children) {
        for (CollectionSheetEntryView collectionSheetEntryView : children) {
            validatePopulatedData(collectionSheetEntryView, errors, locale);
        }/*  ww w .  j a  v  a 2s. co  m*/
    }
    for (LoanAccountsProductView accountView : parent.getLoanAccountDetails()) {
        if (accountView.isDisburseLoanAccountPresent() || accountView.getLoanAccountViews().size() > 1) {
            Double enteredAmount = 0.0;
            if (null != accountView.getEnteredAmount() && accountView.isValidAmountEntered()) {
                enteredAmount = getDoubleValue(accountView.getEnteredAmount());
            }
            Double enteredDisbursalAmount = 0.0;
            if (null != accountView.getDisBursementAmountEntered() && accountView.isValidDisbursementAmount()) {
                enteredDisbursalAmount = getDoubleValue(accountView.getDisBursementAmountEntered());
            }
            Double totalDueAmount = accountView.getTotalAmountDue();
            Double totalDisburtialAmount = accountView.getTotalDisburseAmount();
            if (totalDueAmount.doubleValue() <= 0.0 && totalDisburtialAmount > 0.0) {
                if (!accountView.isValidDisbursementAmount()
                        || !enteredDisbursalAmount.equals(totalDisburtialAmount)
                                && !enteredDisbursalAmount.equals(0.0)) {
                    errors.add(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT,
                            new ActionMessage(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT,
                                    accountView.getPrdOfferingShortName(),
                                    parent.getCustomerDetail().getDisplayName()));
                }
            }
            if (totalDisburtialAmount <= 0.0 && totalDueAmount > 0.0) {
                if (!accountView.isValidAmountEntered()
                        || !enteredAmount.equals(totalDueAmount) && !enteredAmount.equals(0.0)) {
                    errors.add(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT,
                            new ActionMessage(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT,
                                    accountView.getPrdOfferingShortName(),
                                    parent.getCustomerDetail().getDisplayName()));
                }
            }
            if (totalDueAmount.doubleValue() > 0.0 && totalDisburtialAmount > 0.0) {
                if (!accountView.isValidAmountEntered() || !accountView.isValidDisbursementAmount()
                        || accountView.getEnteredAmount() == null
                        || accountView.getDisBursementAmountEntered() == null
                        || enteredAmount.equals(0.0) && !enteredDisbursalAmount.equals(0.0)
                        || enteredDisbursalAmount.equals(0.0) && !enteredAmount.equals(0.0)
                        || enteredDisbursalAmount.equals(totalDisburtialAmount)
                                && !enteredAmount.equals(totalDueAmount)
                        || enteredAmount.equals(totalDueAmount)
                                && !enteredDisbursalAmount.equals(totalDisburtialAmount)
                        || !enteredAmount.equals(totalDueAmount)
                                && !enteredDisbursalAmount.equals(totalDisburtialAmount)
                                && !enteredDisbursalAmount.equals(0.0) && !enteredAmount.equals(0.0)) {
                    errors.add(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT,
                            new ActionMessage(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT,
                                    accountView.getPrdOfferingShortName(),
                                    parent.getCustomerDetail().getDisplayName()));
                }
            }
            if (totalDisburtialAmount <= 0.0 && totalDueAmount <= 0.0) {
                if (!accountView.isValidAmountEntered() || !accountView.isValidDisbursementAmount()
                        || !enteredDisbursalAmount.equals(0.0) || !enteredAmount.equals(0.0)) {
                    errors.add(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT,
                            new ActionMessage(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT,
                                    accountView.getPrdOfferingShortName(),
                                    parent.getCustomerDetail().getDisplayName()));
                }
            }
        }
    }
    for (SavingsAccountView savingsAccountView : parent.getSavingsAccountDetails()) {
        if (!savingsAccountView.isValidDepositAmountEntered()
                || !savingsAccountView.isValidWithDrawalAmountEntered()) {
            errors.add(CollectionSheetEntryConstants.ERRORINVALIDAMOUNT,
                    new ActionMessage(CollectionSheetEntryConstants.ERRORINVALIDAMOUNT,
                            savingsAccountView.getSavingsOfferingShortName(),
                            parent.getCustomerDetail().getDisplayName()));
        }
    }
    CustomerAccountView customerAccountView = parent.getCustomerAccountDetails();
    Double customerAccountAmountEntered = 0.0;
    if (null != customerAccountView.getCustomerAccountAmountEntered()
            && customerAccountView.isValidCustomerAccountAmountEntered()) {
        customerAccountAmountEntered = getDoubleValue(customerAccountView.getCustomerAccountAmountEntered());
    }
    if (!customerAccountView.isValidCustomerAccountAmountEntered() || !customerAccountAmountEntered
            .equals(customerAccountView.getTotalAmountDue().getAmountDoubleValue())
            && !customerAccountAmountEntered.equals(0.0)) {
        errors.add(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT,
                new ActionMessage(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT, acCollections,
                        parent.getCustomerDetail().getDisplayName()));
    }
    return errors;
}

From source file:edu.stanford.cfuller.colocalization3d.correction.PositionCorrector.java

/**
* Creates a correction from a set of objects whose positions should be the same in each channel.
* 
* @param imageObjects                  A Vector containing all the ImageObjects to be used for the correction
*                                      or in the order it appears in a multiwavelength image file.
* @return                              A Correction object that can be used to correct the positions of other objects based upon the standards provided.
*//*from   w  w w.ja  va 2s. c  o  m*/
public Correction getCorrection(java.util.List<ImageObject> imageObjects) {

    int referenceChannel = this.parameters.getIntValueForKey(REF_CH_PARAM);

    int channelToCorrect = this.parameters.getIntValueForKey(CORR_CH_PARAM);

    if (!this.parameters.hasKeyAndTrue(DET_CORR_PARAM)) {
        try {
            return Correction.readFromDisk(FileUtils.getCorrectionFilename(this.parameters));
        } catch (java.io.IOException e) {

            java.util.logging.Logger
                    .getLogger(edu.stanford.cfuller.colocalization3d.Colocalization3DMain.LOGGER_NAME)
                    .severe("Exception encountered while reading correction from disk: ");
            e.printStackTrace();

        } catch (ClassNotFoundException e) {

            java.util.logging.Logger
                    .getLogger(edu.stanford.cfuller.colocalization3d.Colocalization3DMain.LOGGER_NAME)
                    .severe("Exception encountered while reading correction from disk: ");
            e.printStackTrace();

        }

        return null;
    }

    int numberOfPointsToFit = this.parameters.getIntValueForKey(NUM_POINT_PARAM);

    RealMatrix correctionX = new Array2DRowRealMatrix(imageObjects.size(), numberOfCorrectionParameters);
    RealMatrix correctionY = new Array2DRowRealMatrix(imageObjects.size(), numberOfCorrectionParameters);
    RealMatrix correctionZ = new Array2DRowRealMatrix(imageObjects.size(), numberOfCorrectionParameters);

    RealVector distanceCutoffs = new ArrayRealVector(imageObjects.size(), 0.0);

    RealVector ones = new ArrayRealVector(numberOfPointsToFit, 1.0);

    RealVector distancesToObjects = new ArrayRealVector(imageObjects.size(), 0.0);

    RealMatrix allCorrectionParametersMatrix = new Array2DRowRealMatrix(numberOfPointsToFit,
            numberOfCorrectionParameters);

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

        RealVector ithPos = imageObjects.get(i).getPositionForChannel(referenceChannel);

        for (int j = 0; j < imageObjects.size(); j++) {

            double d = imageObjects.get(j).getPositionForChannel(referenceChannel).subtract(ithPos).getNorm();

            distancesToObjects.setEntry(j, d);

        }

        //the sorting becomes a bottleneck once the number of points gets large

        //reverse comparator so we can use the priority queue and get the max element at the head

        Comparator<Double> cdReverse = new Comparator<Double>() {

            public int compare(Double o1, Double o2) {

                if (o1.equals(o2))
                    return 0;
                if (o1 > o2)
                    return -1;
                return 1;
            }

        };

        PriorityQueue<Double> pq = new PriorityQueue<Double>(numberOfPointsToFit + 2, cdReverse);

        double maxElement = Double.MAX_VALUE;

        for (int p = 0; p < numberOfPointsToFit + 1; p++) {

            pq.add(distancesToObjects.getEntry(p));

        }

        maxElement = pq.peek();

        for (int p = numberOfPointsToFit + 1; p < distancesToObjects.getDimension(); p++) {

            double value = distancesToObjects.getEntry(p);

            if (value < maxElement) {

                pq.poll();

                pq.add(value);

                maxElement = pq.peek();

            }

        }

        double firstExclude = pq.poll();
        double lastDist = pq.poll();

        double distanceCutoff = (lastDist + firstExclude) / 2.0;

        distanceCutoffs.setEntry(i, distanceCutoff);

        RealVector xPositionsToFit = new ArrayRealVector(numberOfPointsToFit, 0.0);
        RealVector yPositionsToFit = new ArrayRealVector(numberOfPointsToFit, 0.0);
        RealVector zPositionsToFit = new ArrayRealVector(numberOfPointsToFit, 0.0);

        RealMatrix differencesToFit = new Array2DRowRealMatrix(numberOfPointsToFit,
                imageObjects.get(0).getPositionForChannel(referenceChannel).getDimension());

        int toFitCounter = 0;

        for (int j = 0; j < imageObjects.size(); j++) {
            if (distancesToObjects.getEntry(j) < distanceCutoff) {
                xPositionsToFit.setEntry(toFitCounter,
                        imageObjects.get(j).getPositionForChannel(referenceChannel).getEntry(0));
                yPositionsToFit.setEntry(toFitCounter,
                        imageObjects.get(j).getPositionForChannel(referenceChannel).getEntry(1));
                zPositionsToFit.setEntry(toFitCounter,
                        imageObjects.get(j).getPositionForChannel(referenceChannel).getEntry(2));

                differencesToFit.setRowVector(toFitCounter, imageObjects.get(j)
                        .getVectorDifferenceBetweenChannels(referenceChannel, channelToCorrect));

                toFitCounter++;
            }
        }

        RealVector x = xPositionsToFit.mapSubtractToSelf(ithPos.getEntry(0));
        RealVector y = yPositionsToFit.mapSubtractToSelf(ithPos.getEntry(1));

        allCorrectionParametersMatrix.setColumnVector(0, ones);
        allCorrectionParametersMatrix.setColumnVector(1, x);
        allCorrectionParametersMatrix.setColumnVector(2, y);
        allCorrectionParametersMatrix.setColumnVector(3, x.map(new Power(2)));
        allCorrectionParametersMatrix.setColumnVector(4, y.map(new Power(2)));
        allCorrectionParametersMatrix.setColumnVector(5, x.ebeMultiply(y));

        DecompositionSolver solver = (new QRDecomposition(allCorrectionParametersMatrix)).getSolver();

        RealVector cX = solver.solve(differencesToFit.getColumnVector(0));
        RealVector cY = solver.solve(differencesToFit.getColumnVector(1));
        RealVector cZ = solver.solve(differencesToFit.getColumnVector(2));

        correctionX.setRowVector(i, cX);
        correctionY.setRowVector(i, cY);
        correctionZ.setRowVector(i, cZ);

    }

    Correction c = new Correction(correctionX, correctionY, correctionZ, distanceCutoffs, imageObjects,
            referenceChannel, channelToCorrect);

    return c;

}

From source file:org.mobicents.servlet.restcomm.mscontrol.mgcp.MmsBridgeController.java

private void saveRecording() {
    final Sid accountId = recordingRequest.getAccountId();
    final Sid callId = recordingRequest.getCallId();
    final DaoManager daoManager = recordingRequest.getDaoManager();
    final Sid recordingSid = recordingRequest.getRecordingSid();
    final URI recordingUri = recordingRequest.getRecordingUri();
    final Configuration runtimeSettings = recordingRequest.getRuntimeSetting();
    Double duration;

    try {/*from   w w w .j a v a 2s.c o m*/
        duration = WavUtils.getAudioDuration(recordingUri);
    } catch (UnsupportedAudioFileException | IOException e) {
        logger.error("Could not measure recording duration: " + e.getMessage(), e);
        duration = 0.0;
    }

    if (duration.equals(0.0)) {
        if (logger.isInfoEnabled()) {
            logger.info("Call wraping up recording. File doesn't exist since duration is 0");
        }
        final DateTime end = DateTime.now();
        duration = new Double((end.getMillis() - recordStarted.getMillis()) / 1000);
    } else if (logger.isInfoEnabled()) {
        logger.info(
                "Call wraping up recording. File already exists, length: " + (new File(recordingUri).length()));
    }

    final Recording.Builder builder = Recording.builder();
    builder.setSid(recordingSid);
    builder.setAccountSid(accountId);
    builder.setCallSid(callId);
    builder.setDuration(duration);
    builder.setApiVersion(runtimeSettings.getString("api-version"));
    StringBuilder buffer = new StringBuilder();
    buffer.append("/").append(runtimeSettings.getString("api-version")).append("/Accounts/")
            .append(accountId.toString());
    buffer.append("/Recordings/").append(recordingSid.toString());
    builder.setUri(URI.create(buffer.toString()));
    final Recording recording = builder.build();
    RecordingsDao recordsDao = daoManager.getRecordingsDao();
    recordsDao.addRecording(recording);
}

From source file:org.sakaiproject.tool.gradebook.ui.FeedbackOptionsBean.java

private boolean isConflictWithLetterGrade(GradeMapping gradeMapping) {
    boolean valid = true;
    if (localGradebook.getGrade_type() != GradebookService.GRADE_TYPE_LETTER) {
        return valid;
    }// w ww  .j a v a2  s  . c o m
    if ((gradeMapping.getGradingScale() != null
            && (!gradeMapping.getGradingScale().getUid().equals("LetterGradeMapping")
                    && !gradeMapping.getGradingScale().getUid().equals("LetterGradePlusMinusMapping")))
            || (gradeMapping.getGradingScale() == null && (!gradeMapping.getName().equals("Letter Grades")
                    && !gradeMapping.getName().equals("Letter Grades with +/-")))) {
        return valid;
    }
    Map defaultMapping = gradeMapping.getDefaultBottomPercents();
    for (Iterator iter = gradeMapping.getGrades().iterator(); iter.hasNext();) {
        String grade = (String) iter.next();
        Double percentage = (Double) gradeMapping.getValue(grade);
        Double defautPercentage = (Double) defaultMapping.get(grade);
        if (log.isDebugEnabled())
            log.debug("checking if percentage is being changed for letter grade type gradebook: " + percentage
                    + " for validity");
        if (percentage == null) {
            FacesUtil.addUniqueErrorMessage(getLocalizedString("feedback_options_require_all_values"));
            valid = false;
        } else {
            if (!percentage.equals(defautPercentage)) {
                valid = false;
            }
        }
    }
    return valid;
}

From source file:com.jskj.assets.server.servcie.Yimiaodengji.YimiaodengjiService.java

@Override
public int saveYimiaodengji(Yimiaodengjitb yimiaodengji) {
    log.debug("insert yimiaodengji:" + yimiaodengji.getYmdjId());

    //??/* w  w w .j ava  2  s .c o  m*/
    YimiaoshenqingdantbExample liebiaoexam = new YimiaoshenqingdantbExample();
    liebiaoexam.createCriteria().andXiangdanIdEqualTo(yimiaodengji.getXiangdanId());
    //??id??
    List<Yimiaoshenqingdantb> yimiaolist = yimiaoshenqingdanMapper.selectByExample(liebiaoexam);
    //??
    for (Yimiaoshenqingdantb ym : yimiaolist) {
        liebiaoexam = new YimiaoshenqingdantbExample();
        liebiaoexam.createCriteria().andXiangdanIdEqualTo(ym.getXiangdanId());
        int stuts = ym.getStatus();
        if (yimiaodengji.getQuantity().equals(ym.getQuantity())) {
            stuts = 1;
        } else if (ym.getXiangdanId() == ym.getXiangdanId() && ym.getStatus() == 0) {

            YiMiaotb yimiao = new YiMiaotb();
            yimiao = yimiaoMapper.selectByPrimaryKey(yimiaodengji.getYimiaoId());
            //??ID?
            YimiaodengjitbExample sqdexam = new YimiaodengjitbExample();
            sqdexam.createCriteria().andXiangdanIdEqualTo(ym.getXiangdanId());
            List<Yimiaodengjitb> sqdlist = mapper.selectByExample(sqdexam);
            Double chashu = 0d;
            Double shulian = chashu;

            //??            
            for (int i = 0; i < sqdlist.size(); i++) {
                //??
                chashu = Arith.decimal(chashu + sqdlist.get(i).getQuantity(), 5);
            }
            Double strQuantity = Arith.round(Arith.mul(Arith.decimal(yimiaodengji.getQuantity() + chashu, 5),
                    Arith.div(1, yimiao.getYimiaoHuansuanlv(), 0)), 0);
            strQuantity = Arith.div(strQuantity, Arith.div(1, yimiao.getYimiaoHuansuanlv(), 0), 5);
            Double shul = strQuantity;
            //                    shulian = Arith.decimal(chashu + shulian, 5);
            //                    Double shul = Arith.decimal(yimiaodengji.getQuantity() + shulian, 5);
            if (!shul.equals(ym.getQuantity())) {
                stuts = 0;
                ym.setStatus(stuts);
                YimiaoshenqingdantbExample ymsqd = new YimiaoshenqingdantbExample();
                ymsqd.createCriteria().andXiangdanIdEqualTo(ym.getXiangdanId());
                yimiaoshenqingdanMapper.updateByExample(ym, ymsqd);
            } else {
                stuts = 1;
            }

        }
        ym.setStatus(stuts);
        yimiaoshenqingdanMapper.updateByExample(ym, liebiaoexam);

        /*barcode pool*/
        double num = yimiaodengji.getQuantity();
        Barcodepool pool = new Barcodepool();
        pool.setBarcodegroup(yimiaodengji.getBarcode());
        pool.setLabelId(yimiaodengji.getYimiaoId());
        pool.setQuantity(num);
        pool.setShenqingdanId(ym.getShenqingdanId());
        pool.setXiangdanId(ym.getXiangdanId());
        pool.setStatus(0);
        barCodeService.saveBarCode(pool, true);
    }
    yimiaodengji.setStatus(0);
    return mapper.insertSelective(yimiaodengji);
}

From source file:com.hbc.api.fund.biz.service.MISFundWithdrawService.java

/**
 * // w  w w  . ja v  a2 s. c  om
 * @param bossTransferGuideInfos
 * @param totalAmount
 * @param targetBossGuideId
 * @param targetBossGuideNo
 * @param targetAccountNo
 * @param targetBankNo
 * @param optId
 * @param optName
 */
private void validBossTransferGuideInfo(List<BossTransferGuideInfo> bossTransferGuideInfos, Double totalAmount,
        String targetBossGuideId, String targetBossGuideNo, String targetAccountNo, String targetBankNo,
        String optId, String optName) {
    if (bossTransferGuideInfos == null || bossTransferGuideInfos.size() <= 0 || totalAmount.compareTo(0.0d) <= 0
            || StringUtils.isBlank(targetBossGuideId) || StringUtils.isBlank(targetAccountNo)
            || StringUtils.isBlank(targetBossGuideNo) || StringUtils.isBlank(optId)
            || StringUtils.isBlank(optName) || StringUtils.isBlank(targetBankNo)) {
        throw new FundException(FundReturnCodeEnum.ERR_INSERT, "?");
    }

    Double allTotalAmountInlist = 0.0d;
    Iterator<BossTransferGuideInfo> bossTransferGuideInfosIterator = bossTransferGuideInfos.iterator();
    while (bossTransferGuideInfosIterator.hasNext()) {
        BossTransferGuideInfo bossTransferGuideInfo = (BossTransferGuideInfo) bossTransferGuideInfosIterator
                .next();
        allTotalAmountInlist = DoubleUtil.addDouble(allTotalAmountInlist, bossTransferGuideInfo.getAmount());
    }

    logger.info("BOSS-??|?:{} |?:{}", allTotalAmountInlist, totalAmount);
    if (!allTotalAmountInlist.equals(totalAmount)) {
        throw new FundException(FundReturnCodeEnum.ERR_INSERT, "???");
    }
}