Example usage for java.math BigDecimal doubleValue

List of usage examples for java.math BigDecimal doubleValue

Introduction

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

Prototype

@Override
public double doubleValue() 

Source Link

Document

Converts this BigDecimal to a double .

Usage

From source file:data.services.EventService.java

public void saveLog(Long evId, List<EntityCar> carList, List<IdealEntityParam> ieplist,
        List<EntityCar> cutCarList, Sequence seq) throws Exception {
    Logger log = Logger.getLogger(this.getClass());
    //Event ev = eventDao.find(evId);
    try {//from w  ww  . j  a v  a2 s  . c o m

        HashSet<String> iepuids = new HashSet();
        for (IdealEntityParam iep : ieplist) {
            iepuids.add(iep.getBaseParam().getUid());
        }

        List<BaseParam> bpList = baseParamService.getParams();

        HashMap<Long, String> genMap = subModelService.getGenerationUrls();

        HSSFWorkbook workbook = new HSSFWorkbook();
        Event ev = eventDao.find(evId);
        HashMap<Long, SubModel> bodyMap = subModelService.getBodies();

        HSSFCellStyle style = workbook.createCellStyle();
        //style.setFillBackgroundColor(HSSFColor.ORANGE.index);
        style.setFillForegroundColor(HSSFColor.ORANGE.index);
        style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);

        HSSFSheet idealEntitySheet = workbook.createSheet("? ??");
        HSSFSheet chosenSheet = workbook.createSheet(" ?");
        HSSFSheet cutedSheet = workbook.createSheet(" ?");
        HSSFSheet moneySheet = workbook.createSheet("  ");
        HSSFSheet instChosenSheet = workbook.createSheet("");
        int complectList = 1;

        int ierownum = 1;
        idealEntitySheet.createRow(ierownum++).createCell(0)
                .setCellValue(": " + ev.getName() + "; " + ev.getId() + ";");
        idealEntitySheet.createRow(ierownum++).createCell(0)
                .setCellValue("?: " + ev.getAuthor() + ";");
        idealEntitySheet.createRow(ierownum++).createCell(0)
                .setCellValue(": " + ev.getAddDate() + ";");
        idealEntitySheet.createRow(ierownum++).createCell(0)
                .setCellValue(": " + ev.getScene().getName() + ";");
        idealEntitySheet.createRow(ierownum++).createCell(0)
                .setCellValue(": " + ev.getMoney() + ";");
        idealEntitySheet.createRow(ierownum++).createCell(0)
                .setCellValue(" ???: " + ev.getPerception().getName() + ";");
        idealEntitySheet.createRow(ierownum++).createCell(0)
                .setCellValue(": " + ev.getRadical() + "(" + ev.getColor() + ")" + ";");
        idealEntitySheet.createRow(ierownum++).createCell(0)
                .setCellValue("?: " + seq.getRadCore() + ";");

        HSSFRow ierowhead = idealEntitySheet.createRow(ierownum++);
        ierowhead.createCell(0).setCellValue("? A1: ");
        ierowhead.createCell(1).setCellValue(ev.getStrategyA1().getName());
        ierowhead = idealEntitySheet.createRow(ierownum++);
        ierowhead.createCell(0).setCellValue("? B1: ");
        ierowhead.createCell(1).setCellValue(ev.getStrategyB1().getName());
        ierowhead = idealEntitySheet.createRow(ierownum++);
        ierowhead.createCell(0).setCellValue("?? : ");
        ierowhead.createCell(1).setCellValue(ev.getResourceType().getName());
        ierowhead = idealEntitySheet.createRow(ierownum++);
        ierowhead.createCell(0).setCellValue("?? -: ");
        ierowhead.createCell(1).setCellValue(ev.getParamTox1().getName());
        ierowhead = idealEntitySheet.createRow(ierownum++);
        ierowhead.createCell(0).setCellValue("?? ?: ");
        ierowhead.createCell(1).setCellValue(ev.getValueTox1().getName());
        ierowhead = idealEntitySheet.createRow(ierownum++);
        ierowhead.createCell(0).setCellValue(" ?: ");
        ierowhead.createCell(1).setCellValue(seq.getAllowance() + "%");
        ierowhead = idealEntitySheet.createRow(ierownum++);
        ierowhead.createCell(0).setCellValue("? A2: ");
        ierowhead.createCell(1).setCellValue(ev.getStrategyA2().getName());
        ierowhead = idealEntitySheet.createRow(ierownum++);
        ierowhead.createCell(0).setCellValue("? B2: ");
        ierowhead.createCell(1).setCellValue(ev.getStrategyB2().getName());
        ierowhead = idealEntitySheet.createRow(ierownum++);
        ierowhead.createCell(0).setCellValue("?? -, . ?: ");
        ierowhead.createCell(1).setCellValue(ev.getParamTox2().getName());
        ierowhead = idealEntitySheet.createRow(ierownum++);
        ierowhead.createCell(0).setCellValue("?? ?, . ?: ");
        ierowhead.createCell(1).setCellValue(ev.getValueTox2().getName());
        ierownum++;

        int phn = 1;
        HSSFRow paramsierowhead = idealEntitySheet.createRow(ierownum++);
        paramsierowhead.createCell(phn++).setCellValue("UID");
        paramsierowhead.createCell(phn++).setCellValue("?");
        paramsierowhead.createCell(phn++).setCellValue("?");
        paramsierowhead.createCell(phn++).setCellValue(" .");
        paramsierowhead.createCell(phn++).setCellValue("");
        paramsierowhead.createCell(phn++).setCellValue("?");
        paramsierowhead.createCell(phn++).setCellValue(" ?.");
        paramsierowhead.createCell(phn++).setCellValue("");

        int A = 0;
        int B = 0;
        for (IdealEntityParam iep : ieplist) {
            int pbn = 0;
            HSSFRow paramsierowbody = idealEntitySheet.createRow(ierownum++);
            paramsierowbody.createCell(pbn++).setCellValue(iep.getNumber());
            paramsierowbody.createCell(pbn++).setCellValue(iep.getBaseParam().getUid());
            paramsierowbody.createCell(pbn++).setCellValue(iep.getBaseParam().getName());
            paramsierowbody.createCell(pbn++).setCellValue(iep.getIepClass().getName());
            paramsierowbody.createCell(pbn++).setCellValue(iep.getAmin().doubleValue());
            paramsierowbody.createCell(pbn++).setCellValue(iep.getValueMin().doubleValue());
            paramsierowbody.createCell(pbn++).setCellValue(iep.getValueMax().doubleValue());
            paramsierowbody.createCell(pbn++).setCellValue(iep.getAmax().doubleValue());
            paramsierowbody.createCell(pbn++).setCellValue(StringAdapter.getString(iep.getRank()));
            if (Rank.A.equals(iep.getRank())) {
                A++;
            } else if (Rank.B.equals(iep.getRank())) {
                B++;
            }
        }
        ierownum++;
        ierowhead = idealEntitySheet.createRow(ierownum++);
        ierowhead.createCell(0).setCellValue("? -  ?:");
        ierowhead.createCell(1).setCellValue((double) A);
        ierowhead = idealEntitySheet.createRow(ierownum++);
        ierowhead.createCell(0).setCellValue("? -  B");
        ierowhead.createCell(1).setCellValue((double) B);
        ierownum++;
        ierowhead = idealEntitySheet.createRow(ierownum++);
        ierowhead.createCell(0).setCellValue("? :");
        ierowhead = idealEntitySheet.createRow(ierownum++);
        ierowhead.createCell(1).setCellValue("UID");
        ierowhead.createCell(2).setCellValue("?");
        for (SequenceValueRange svr : seq.getSequenceValueRanges()) {
            String uid = svr.getUid();

            if (!iepuids.contains(uid)) {
                ierowhead = idealEntitySheet.createRow(ierownum++);
                ierowhead.createCell(1).setCellValue(svr.getUid());
                ierowhead.createCell(2).setCellValue(baseParamService.getBaseParam(bpList, uid).getName());
            }
        }

        int rowheadNumCell = 0;
        HSSFRow rowhead = chosenSheet.createRow(0);
        rowhead.createCell(rowheadNumCell++).setCellValue("");
        rowhead.createCell(rowheadNumCell++).setCellValue("?");
        rowhead.createCell(rowheadNumCell++).setCellValue("");
        rowhead.createCell(rowheadNumCell++).setCellValue("?");
        rowhead.createCell(rowheadNumCell++).setCellValue("?");
        rowhead.createCell(rowheadNumCell++).setCellValue(" ?");
        rowhead.createCell(rowheadNumCell++).setCellValue("??");
        rowhead.createCell(rowheadNumCell++).setCellValue("?? ??");
        rowhead.createCell(rowheadNumCell++).setCellValue("? A");
        rowhead.createCell(rowheadNumCell++).setCellValue(" A");
        rowhead.createCell(rowheadNumCell++).setCellValue("? ? A ");
        rowhead.createCell(rowheadNumCell++).setCellValue("? B");
        rowhead.createCell(rowheadNumCell++).setCellValue(" ");
        rowhead.createCell(rowheadNumCell++).setCellValue("? ? B");
        rowhead.createCell(rowheadNumCell++).setCellValue("? ???");
        rowhead.createCell(rowheadNumCell++).setCellValue("? ?? ??");
        rowhead.createCell(rowheadNumCell++).setCellValue("? ?? ???");
        rowhead.createCell(rowheadNumCell++).setCellValue("? ?? ???");

        int numscell = 0;
        HSSFRow instrowhead = instChosenSheet.createRow(0);
        instrowhead.createCell(numscell++).setCellValue("");
        instrowhead.createCell(numscell++).setCellValue("?");
        instrowhead.createCell(numscell++).setCellValue("");
        instrowhead.createCell(numscell++).setCellValue("?");
        instrowhead.createCell(numscell++).setCellValue("?");
        instrowhead.createCell(numscell++).setCellValue(" ?");
        instrowhead.createCell(numscell++).setCellValue("??");
        instrowhead.createCell(numscell++).setCellValue("");
        instrowhead.createCell(numscell++).setCellValue("??");
        instrowhead.createCell(numscell++).setCellValue("??");
        instrowhead.createCell(numscell++).setCellValue("");
        instrowhead.createCell(numscell++).setCellValue("??");
        instrowhead.createCell(numscell++).setCellValue("??? 1");
        instrowhead.createCell(numscell++).setCellValue("??? 2");
        instrowhead.createCell(numscell++).setCellValue("? ???");
        instrowhead.createCell(numscell++).setCellValue("? ??");

        moneySheet.addMergedRegion(new CellRangeAddress(0, 0, 6, 13));
        moneySheet.addMergedRegion(new CellRangeAddress(0, 0, 14, 18));
        moneySheet.addMergedRegion(new CellRangeAddress(0, 0, 19, 26));
        moneySheet.addMergedRegion(new CellRangeAddress(0, 0, 27, 32));
        moneySheet.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
        moneySheet.addMergedRegion(new CellRangeAddress(0, 1, 1, 1));
        moneySheet.addMergedRegion(new CellRangeAddress(0, 1, 2, 2));
        moneySheet.addMergedRegion(new CellRangeAddress(0, 1, 3, 3));
        moneySheet.addMergedRegion(new CellRangeAddress(0, 1, 4, 4));
        moneySheet.addMergedRegion(new CellRangeAddress(0, 1, 5, 5));
        HSSFRow firstRowMoneyHead = moneySheet.createRow(0);
        HSSFRow secondRowMoneyHead = moneySheet.createRow(1);

        int frn = 0;
        firstRowMoneyHead.createCell(frn++).setCellValue("");
        firstRowMoneyHead.createCell(frn++).setCellValue("?");
        firstRowMoneyHead.createCell(frn++).setCellValue("");
        firstRowMoneyHead.createCell(frn++).setCellValue("?");
        firstRowMoneyHead.createCell(frn++).setCellValue("?");
        firstRowMoneyHead.createCell(frn++).setCellValue(" ?");
        firstRowMoneyHead.createCell(frn++).setCellValue("??? I");
        firstRowMoneyHead.createCell(frn + 7).setCellValue("?? I");
        firstRowMoneyHead.createCell(frn + 12).setCellValue("??? II");
        firstRowMoneyHead.createCell(frn + 20).setCellValue("?? II");

        int srn = 6;
        secondRowMoneyHead.createCell(srn++)
                .setCellValue("- ?? ??? ?");
        secondRowMoneyHead.createCell(srn++)
                .setCellValue("- ?? ??? ");
        secondRowMoneyHead.createCell(srn++).setCellValue(" ?");
        secondRowMoneyHead.createCell(srn++)
                .setCellValue(" ?? ?? ??? ?");
        secondRowMoneyHead.createCell(srn++)
                .setCellValue(" ?? ?? ??? ");
        secondRowMoneyHead.createCell(srn++).setCellValue("?  ??");
        secondRowMoneyHead.createCell(srn++).setCellValue("?  ?");
        secondRowMoneyHead.createCell(srn++).setCellValue("? ??");
        secondRowMoneyHead.createCell(srn++).setCellValue("? ?? ");
        secondRowMoneyHead.createCell(srn++).setCellValue("? ?? ???");
        secondRowMoneyHead.createCell(srn++).setCellValue("- ?? ");
        secondRowMoneyHead.createCell(srn++).setCellValue("");
        secondRowMoneyHead.createCell(srn++).setCellValue("? ?? ?");
        secondRowMoneyHead.createCell(srn++)
                .setCellValue("- ?? ??? ?");
        secondRowMoneyHead.createCell(srn++)
                .setCellValue("- ?? ??? ");
        secondRowMoneyHead.createCell(srn++).setCellValue(" ?");
        secondRowMoneyHead.createCell(srn++)
                .setCellValue(" ?? ?? ??? ?");
        secondRowMoneyHead.createCell(srn++)
                .setCellValue(" ?? ?? ??? ");
        secondRowMoneyHead.createCell(srn++).setCellValue("?  ??");
        secondRowMoneyHead.createCell(srn++).setCellValue("?  ?");
        secondRowMoneyHead.createCell(srn++).setCellValue("? ??");
        secondRowMoneyHead.createCell(srn++).setCellValue("? ?? ");
        secondRowMoneyHead.createCell(srn++).setCellValue("? ?? ???");
        secondRowMoneyHead.createCell(srn++).setCellValue("- ?? ");
        secondRowMoneyHead.createCell(srn++).setCellValue("");
        secondRowMoneyHead.createCell(srn++).setCellValue("? ?? ?");

        int n = 1;
        int optrownum = 1;
        if (!carList.isEmpty()) {
            //while (optrownum < 50000) {
            for (EntityCar car : carList) {
                if (optrownum > 60000) {
                    instChosenSheet = workbook.createSheet(" " + complectList++);
                    optrownum = 1;
                    numscell = 0;
                    instrowhead = instChosenSheet.createRow(0);
                    instrowhead.createCell(numscell++).setCellValue("");
                    instrowhead.createCell(numscell++).setCellValue("?");
                    instrowhead.createCell(numscell++).setCellValue("");
                    instrowhead.createCell(numscell++).setCellValue("?");
                    instrowhead.createCell(numscell++).setCellValue("?");
                    instrowhead.createCell(numscell++).setCellValue(" ?");
                    instrowhead.createCell(numscell++).setCellValue("??");
                    instrowhead.createCell(numscell++).setCellValue("");
                    instrowhead.createCell(numscell++).setCellValue("??");
                    instrowhead.createCell(numscell++).setCellValue("??");
                    instrowhead.createCell(numscell++).setCellValue("");
                    instrowhead.createCell(numscell++).setCellValue("??");
                    instrowhead.createCell(numscell++).setCellValue("??? 1");
                    instrowhead.createCell(numscell++).setCellValue("??? 2");
                    instrowhead.createCell(numscell++).setCellValue("? ???");
                    instrowhead.createCell(numscell++).setCellValue("? ??");
                }

                Car realCar = car.car;

                SubModel sm = bodyMap.get(car.car.getCmsqId());
                String body = "";
                if (sm != null) {
                    body = sm.getBody();
                }

                int m = n + 1;
                int bpropsCount = 0;

                int cn = 0;
                HSSFRow carRow = instChosenSheet.createRow(optrownum);
                carRow.createCell(cn++).setCellValue(StringAdapter.getString(car.car.getCarId()));
                carRow.createCell(cn++).setCellValue(StringAdapter.getString(car.getMarkTitle()));
                carRow.createCell(cn++).setCellValue(StringAdapter.getString(car.getModelTitle()));
                carRow.createCell(cn++).setCellValue(StringAdapter.getString(car.car.getCompletionTitle()));
                carRow.createCell(cn++).setCellValue(StringAdapter.getString(car.getCarTitle()));
                carRow.createCell(cn++).setCellValue(StringAdapter.getString(body));
                carRow.createCell(cn++).setCellValue(car.fullPrice.doubleValue());
                carRow.createCell(cn++).setCellValue("");

                carRow.createCell(cn + 6).setCellValue(car.dinamicRateA.add(car.dinamicRateB).doubleValue());
                optrownum++;

                /*carRow.createCell(3).setCellValue(renderDecimalNoPoint(car.basePrice).replace(".", ","));
                 carRow.createCell(6).setCellValue(StringAdapter.getString(car.staticRate).replace(".", ","));
                 carRow.createCell(7).setCellValue(StringAdapter.getString(car.staticRate.add(car.dinamicRate)).replace(".", ","));*/

                for (String uid : car.aprops.keySet()) {
                    EntityPropertyHolder eph = car.aprops.get(uid);

                    boolean alternatives = false;
                    List<EntityProperty> insttalledElems = eph.getActiveProperty();

                    if (insttalledElems.size() > 1) {
                        alternatives = true;
                    }

                    for (EntityProperty ep : insttalledElems) {
                        HSSFRow optRow = instChosenSheet.createRow(optrownum);
                        int on = 0;
                        optRow.createCell(on++).setCellValue(StringAdapter.getString(car.car.getCarId()));
                        optRow.createCell(on++).setCellValue(StringAdapter.getString(car.getMarkTitle()));
                        optRow.createCell(on++).setCellValue(StringAdapter.getString(car.getModelTitle()));
                        optRow.createCell(on++)
                                .setCellValue(StringAdapter.getString(car.car.getCompletionTitle()));
                        optRow.createCell(on++).setCellValue(StringAdapter.getString(car.getCarTitle()));
                        optRow.createCell(on++).setCellValue(body);
                        //optRow.createCell(on++).setCellValue(RenderSupport.renderDecimalNoPoint(ep.getPrice()).replace(".", ","));
                        optRow.createCell(on++).setCellValue(" - ");
                        HSSFCell uidCell = optRow.createCell(on++);
                        uidCell.setCellValue(uid);
                        if (alternatives) {
                            uidCell.setCellStyle(style);
                        }
                        optRow.createCell(on++).setCellValue("A");
                        optRow.createCell(on++).setCellValue(ep.sign);
                        optRow.createCell(on++).setCellValue(ep.type.getName());
                        optRow.createCell(on++).setCellValue(ep.name);
                        optRow.createCell(on++).setCellValue(ep.title);
                        optRow.createCell(on++).setCellValue(ep.value.doubleValue());
                        optRow.createCell(on++).setCellValue(eph.dinamicRate.doubleValue());
                        optrownum++;

                        /*optRow.createCell(1).setCellValue("A");
                         optRow.createCell(2).setCellValue(ep.type.getName());
                         optRow.createCell(3).setCellValue(ep.name);
                         optRow.createCell(4).setCellValue(ep.title);
                         optRow.createCell(5).setCellValue(StringAdapter.getString(ep.value).replace(".", ","));
                         optRow.createCell(6).setCellValue(StringAdapter.getString(eph.dinamicRate).replace(".", ","));
                         optRow.createCell(7).setCellValue(StringAdapter.getString(eph.staticRate).replace(".", ","));*/
                    }
                }

                for (String uid : car.bprops.keySet()) {
                    EntityPropertyHolder eph = car.bprops.get(uid);

                    boolean alternatives = false;
                    List<EntityProperty> insttalledElems = eph.getActiveProperty();

                    if (insttalledElems.size() > 1) {
                        alternatives = true;
                    }

                    if (!insttalledElems.isEmpty()) {
                        bpropsCount++;
                        for (EntityProperty ep : eph.getActiveProperty()) {
                            HSSFRow optRow = instChosenSheet.createRow(optrownum);
                            int on = 0;
                            optRow.createCell(on++).setCellValue(StringAdapter.getString(car.car.getCarId()));
                            optRow.createCell(on++).setCellValue(StringAdapter.getString(car.getMarkTitle()));
                            optRow.createCell(on++).setCellValue(StringAdapter.getString(car.getModelTitle()));
                            optRow.createCell(on++)
                                    .setCellValue(StringAdapter.getString(car.car.getCompletionTitle()));
                            optRow.createCell(on++).setCellValue(StringAdapter.getString(car.getCarTitle()));
                            optRow.createCell(on++).setCellValue(StringAdapter.getString(body));
                            //optRow.createCell(on++).setCellValue(RenderSupport.renderDecimalNoPoint(ep.getPrice()).replace(".", ","));
                            //optRow.createCell(on++).setCellValue(RenderSupport.renderDecimalNoPoint(ep.price));
                            optRow.createCell(on++).setCellValue(" - ");
                            HSSFCell uidCell = optRow.createCell(on++);
                            uidCell.setCellValue(uid);
                            if (alternatives) {
                                uidCell.setCellStyle(style);
                            }
                            optRow.createCell(on++).setCellValue("B");
                            optRow.createCell(on++).setCellValue(ep.sign);
                            optRow.createCell(on++).setCellValue(ep.type.getName());
                            optRow.createCell(on++).setCellValue(ep.name);
                            optRow.createCell(on++).setCellValue(ep.title);
                            optRow.createCell(on++).setCellValue(ep.value.doubleValue());
                            optRow.createCell(on++).setCellValue(eph.dinamicRate.doubleValue());
                            optrownum++;

                            /*HSSFRow optRow = instChosenSheet.createRow((short) optrownum);
                             HSSFCell uidCell = optRow.createCell(0);
                             uidCell.setCellValue(uid);
                             if(alternatives){
                             //optRow.createCell(8).setCellValue("");
                             uidCell.setCellStyle(style);
                             }
                             optRow.createCell(1).setCellValue("B");
                             optRow.createCell(2).setCellValue(ep.type.getName());
                             optRow.createCell(3).setCellValue(ep.name);
                             optRow.createCell(4).setCellValue(ep.title);
                             optRow.createCell(5).setCellValue(StringAdapter.getString(ep.value).replace(".", ","));
                             optRow.createCell(6).setCellValue(StringAdapter.getString(eph.dinamicRate).replace(".", ","));
                             optRow.createCell(7).setCellValue(StringAdapter.getString(eph.staticRate).replace(".", ","));
                             optrownum++;*/
                        }
                    } else {
                        BaseParam bp = baseParamService.getBaseParam(uid);
                        HSSFRow optRow = instChosenSheet.createRow(optrownum);
                        int on = 0;
                        optRow.createCell(on++).setCellValue(StringAdapter.getString(car.car.getCarId()));
                        optRow.createCell(on++).setCellValue(StringAdapter.getString(car.getMarkTitle()));
                        optRow.createCell(on++).setCellValue(StringAdapter.getString(car.getModelTitle()));
                        optRow.createCell(on++)
                                .setCellValue(StringAdapter.getString(car.car.getCompletionTitle()));
                        optRow.createCell(on++).setCellValue(StringAdapter.getString(car.getCarTitle()));
                        optRow.createCell(on++).setCellValue(StringAdapter.getString(body));
                        //optRow.createCell(on++).setCellValue(RenderSupport.renderDecimalNoPoint(ep.getPrice()).replace(".", ","));
                        optRow.createCell(on++).setCellValue(" - ");
                        HSSFCell uidCell = optRow.createCell(on++);
                        uidCell.setCellValue(uid);
                        optRow.createCell(on++).setCellValue("B");
                        optRow.createCell(on++).setCellValue(" - ");
                        optRow.createCell(on++).setCellValue(" - ");
                        optRow.createCell(on++).setCellValue(bp.getName());
                        optRow.createCell(on++).setCellValue(" - ");
                        optRow.createCell(on++).setCellValue("null");
                        optRow.createCell(on++).setCellValue(" - ");
                        optrownum++;
                    }
                }

                /*String aRate = " - ";
                if(car.dinamicRateA.compareTo(BigDecimal.valueOf(0))>0){
                aRate = StringAdapter.getString(car.dinamicRateA).replace(".", ",");
                }
                String acount = " - ";
                if(car.aprops.keySet().size()>0){
                acount = StringAdapter.getString(car.aprops.keySet().size());
                }*/
                String msA = " - ";
                BigDecimal medA = BigDecimal.valueOf(0);
                if (car.aprops.keySet().size() > 0) {
                    medA = car.dinamicRateA.divide(BigDecimal.valueOf(car.aprops.keySet().size()), 2,
                            RoundingMode.HALF_UP);
                    msA = StringAdapter.getString(medA).replace(".", ",");
                }

                /* String bRate = " - ";
                 if(car.dinamicRateB.compareTo(BigDecimal.valueOf(0))>0){
                bRate = StringAdapter.getString(car.dinamicRateB).replace(".", ",");
                 }*/
                String bcount = " - ";
                if (bpropsCount > 0) {
                    bcount = StringAdapter.getString(bpropsCount);
                }
                String msB = " - ";
                BigDecimal medB = BigDecimal.valueOf(0);
                if (bpropsCount > 0) {
                    medB = car.dinamicRateB.divide(BigDecimal.valueOf(bpropsCount), 2, RoundingMode.HALF_UP);
                    msB = StringAdapter.getString(medB).replace(".", ",");
                }

                /*String bsr = " - ";
                if(car.baseStaticRate2.compareTo(BigDecimal.valueOf(0))>0){
                bsr = StringAdapter.getString(car.baseStaticRate2).replace(".", ",");
                }
                String fsr = " - ";
                if(car.freeStaticRate2.compareTo(BigDecimal.valueOf(0))>0){
                fsr = StringAdapter.getString(car.freeStaticRate2).replace(".", ",");
                }
                String msr = " - ";
                if(car.monetaryStaticRate2.compareTo(BigDecimal.valueOf(0))>0){
                msr = StringAdapter.getString(car.monetaryStaticRate2).replace(".", ",");
                }*/

                Model model = realCar.getModel();

                HSSFRow rowbody = chosenSheet.createRow(n);
                int rowbodynum = 0;
                rowbody.createCell(rowbodynum++).setCellValue(StringAdapter.getString(car.car.getCarId()));
                rowbody.createCell(rowbodynum++).setCellValue(StringAdapter.getString(car.getMarkTitle()));
                rowbody.createCell(rowbodynum++).setCellValue(StringAdapter.getString(car.getModelTitle()));
                rowbody.createCell(rowbodynum++)
                        .setCellValue(StringAdapter.getString(car.car.getCompletionTitle()));
                HSSFCell nameCellWithLink = rowbody.createCell(rowbodynum++);
                nameCellWithLink.setCellValue(StringAdapter.getString(car.getCarTitle()));
                HSSFHyperlink link = new HSSFHyperlink(HSSFHyperlink.LINK_URL);
                link.setAddress("http://quto.ru/" + model.getMark().getUrl() + "/" + model.getUrl() + "/"
                        + genMap.get(realCar.getCmgqId()) + "/" + bodyMap.get(realCar.getCmsqId()).getUrl()
                        + "/" + realCar.getUrl());
                nameCellWithLink.setHyperlink(link);
                rowbody.createCell(rowbodynum++).setCellValue(StringAdapter.getString(body));
                rowbody.createCell(rowbodynum++).setCellValue(car.basePrice.doubleValue());
                rowbody.createCell(rowbodynum++).setCellValue(car.fullPrice.doubleValue());
                rowbody.createCell(rowbodynum++).setCellValue(car.dinamicRateA.doubleValue());
                rowbody.createCell(rowbodynum++).setCellValue((double) car.aprops.keySet().size());
                rowbody.createCell(rowbodynum++).setCellValue(medA.doubleValue());
                rowbody.createCell(rowbodynum++).setCellValue(car.dinamicRateB.doubleValue());
                rowbody.createCell(rowbodynum++).setCellValue((double) bpropsCount);
                rowbody.createCell(rowbodynum++).setCellValue(medB.doubleValue());
                rowbody.createCell(rowbodynum++).setCellValue(medA.add(medB).doubleValue());
                rowbody.createCell(rowbodynum++).setCellValue(car.baseStaticRate2.doubleValue());
                rowbody.createCell(rowbodynum++).setCellValue(car.freeStaticRate2.doubleValue());
                rowbody.createCell(rowbodynum++).setCellValue(car.monetaryStaticRate2.doubleValue());

                int rmbn = 0;
                HSSFRow rowMoneyBody = moneySheet.createRow(m);
                rowMoneyBody.createCell(rmbn++).setCellValue(StringAdapter.getString(car.car.getId()));
                rowMoneyBody.createCell(rmbn++).setCellValue(StringAdapter.getString(car.getMarkTitle()));
                rowMoneyBody.createCell(rmbn++).setCellValue(StringAdapter.getString(car.getModelTitle()));
                rowMoneyBody.createCell(rmbn++)
                        .setCellValue(StringAdapter.getString(car.car.getCompletionTitle()));
                rowMoneyBody.createCell(rmbn++).setCellValue(StringAdapter.getString(car.getCarTitle()));
                rowMoneyBody.createCell(rmbn++).setCellValue(StringAdapter.getString(body));
                rowMoneyBody.createCell(rmbn++).setCellValue((double) car.aprops.keySet().size());
                rowMoneyBody.createCell(rmbn++).setCellValue((double) bpropsCount);
                rowMoneyBody.createCell(rmbn++).setCellValue(car.basePrice.doubleValue());
                rowMoneyBody.createCell(rmbn++).setCellValue(car.aFund1.doubleValue());
                rowMoneyBody.createCell(rmbn++).setCellValue(car.bFund1.doubleValue());
                rowMoneyBody.createCell(rmbn++).setCellValue(car.aFund1.add(car.bFund1).doubleValue());
                rowMoneyBody.createCell(rmbn++).setCellValue(
                        ev.getMoney().subtract(car.aFund1.add(car.bFund1).add(car.basePrice)).doubleValue());
                rowMoneyBody.createCell(rmbn++)
                        .setCellValue(car.dinamicRateA.add(car.dinamicRateB).doubleValue());
                rowMoneyBody.createCell(rmbn++).setCellValue(car.baseStaticRate1.doubleValue());
                rowMoneyBody.createCell(rmbn++).setCellValue(car.freeStaticRate1.doubleValue());
                rowMoneyBody.createCell(rmbn++).setCellValue(car.payStaticCount1.doubleValue());
                rowMoneyBody.createCell(rmbn++).setCellValue(car.staticFund1.doubleValue());
                rowMoneyBody.createCell(rmbn++).setCellValue(car.monetaryStaticRate1.doubleValue());
                rowMoneyBody.createCell(rmbn++).setCellValue((double) car.aCount2);
                rowMoneyBody.createCell(rmbn++).setCellValue((double) car.bCount2);
                rowMoneyBody.createCell(rmbn++).setCellValue(car.basePrice.doubleValue());
                rowMoneyBody.createCell(rmbn++).setCellValue(car.aFund2.doubleValue());
                rowMoneyBody.createCell(rmbn++).setCellValue(car.bFund2.doubleValue());
                rowMoneyBody.createCell(rmbn++).setCellValue(car.aFund2.add(car.bFund2).doubleValue());
                rowMoneyBody.createCell(rmbn++).setCellValue(
                        ev.getMoney().subtract(car.aFund2.add(car.bFund2).add(car.basePrice)).doubleValue());
                rowMoneyBody.createCell(rmbn++)
                        .setCellValue(car.dinamicRateA.add(car.dinamicRateB).doubleValue());
                rowMoneyBody.createCell(rmbn++).setCellValue(car.baseStaticRate2.doubleValue());
                rowMoneyBody.createCell(rmbn++).setCellValue(car.freeStaticRate2.doubleValue());
                rowMoneyBody.createCell(rmbn++).setCellValue(car.payStaticCount2.doubleValue());
                rowMoneyBody.createCell(rmbn++).setCellValue(car.staticFund2.doubleValue());
                rowMoneyBody.createCell(rmbn++).setCellValue(car.monetaryStaticRate2.doubleValue());
                n++;

                HSSFRow carStaticRowHead = instChosenSheet.createRow(optrownum);
                int csn = 0;
                carStaticRowHead.createCell(csn++).setCellValue(StringAdapter.getString(car.car.getCarId()));
                carStaticRowHead.createCell(csn++).setCellValue(StringAdapter.getString(car.getMarkTitle()));
                carStaticRowHead.createCell(csn++).setCellValue(StringAdapter.getString(car.getModelTitle()));
                carStaticRowHead.createCell(csn++)
                        .setCellValue(StringAdapter.getString(car.car.getCompletionTitle()));
                carStaticRowHead.createCell(csn++).setCellValue(StringAdapter.getString(car.getCarTitle()));
                carStaticRowHead.createCell(csn++).setCellValue(StringAdapter.getString(body));
                //carStaticRowHead.createCell(3).setCellValue(RenderSupport.renderDecimalNoPoint(ep.getPrice()));
                carStaticRowHead.createCell(csn++).setCellValue(":");
                carStaticRowHead.createCell(csn + 7).setCellValue(car.staticRate.doubleValue());
                optrownum++;

                Map<String, List<EntityProperty>> StaticMap = car.staticProps;
                for (String uid : StaticMap.keySet()) {
                    List<EntityProperty> insttalledElems = StaticMap.get(uid);
                    if (insttalledElems != null && !insttalledElems.isEmpty()) {
                        boolean alternatives = false;

                        if (insttalledElems.size() > 1) {
                            alternatives = true;
                        }

                        for (EntityProperty ep : insttalledElems) {

                            String title = ep.title;
                            if (!ep.description.trim().equals("")) {
                                title += " - " + ep.description;
                            }

                            HSSFRow carStaticRow = instChosenSheet.createRow(optrownum);
                            int cson = 0;
                            carStaticRow.createCell(cson++)
                                    .setCellValue(StringAdapter.getString(car.car.getCarId()));
                            carStaticRow.createCell(cson++)
                                    .setCellValue(StringAdapter.getString(car.getMarkTitle()));
                            carStaticRow.createCell(cson++)
                                    .setCellValue(StringAdapter.getString(car.getModelTitle()));
                            carStaticRow.createCell(cson++)
                                    .setCellValue(StringAdapter.getString(car.car.getCompletionTitle()));
                            carStaticRow.createCell(cson++)
                                    .setCellValue(StringAdapter.getString(car.getCarTitle()));
                            carStaticRow.createCell(cson++).setCellValue(StringAdapter.getString(body));
                            //carStaticRow.createCell(cson++).setCellValue(StringAdapter.getString(ep.getPrice()).replace(".", ","));
                            carStaticRow.createCell(cson++).setCellValue(" - ");

                            HSSFCell uidCell = carStaticRow.createCell(cson++);
                            uidCell.setCellValue(uid);
                            if (alternatives) {
                                uidCell.setCellStyle(style);
                            }
                            //carStaticRow.createCell(5).setCellValue(uid);

                            carStaticRow.createCell(cson++).setCellValue("S");
                            carStaticRow.createCell(cson++).setCellValue(ep.sign);
                            carStaticRow.createCell(cson++).setCellValue(ep.type.getName());
                            carStaticRow.createCell(cson++).setCellValue(ep.name);
                            carStaticRow.createCell(cson++).setCellValue(title);
                            carStaticRow.createCell(cson++).setCellValue(ep.radicalValue);
                            carStaticRow.createCell(cson + 1).setCellValue(ep.value.doubleValue());

                            /*carStaticRow.createCell(1).setCellValue(ep.name);
                             carStaticRow.createCell(2).setCellValue(ep.title);
                             carStaticRow.createCell(3).setCellValue(ep.type.getName());
                                    
                             carStaticRow.createCell(5).setCellValue(StringAdapter.getString(ep.value).replace(".", ","));*/
                            optrownum++;
                        }
                    }
                }
                /*break;*/
            }
        }
        int k = 0;
        HSSFRow rowhead20 = cutedSheet.createRow(k++);
        HSSFRow rowhead21 = cutedSheet.createRow(k++);
        HSSFRow rowhead22 = cutedSheet.createRow(k++);
        int ccn = 0;
        rowhead20.createCell(0).setCellValue("UID ??");
        rowhead21.createCell(ccn++).setCellValue("");
        rowhead21.createCell(ccn++).setCellValue("?");
        rowhead21.createCell(ccn++).setCellValue("");
        rowhead21.createCell(ccn++).setCellValue("?");
        rowhead21.createCell(ccn++).setCellValue("?");
        rowhead21.createCell(ccn++).setCellValue(" ?");
        rowhead22.createCell(0).setCellValue(" ???");

        int cutoptrownum = 0;
        for (IdealEntityParam iep : ieplist) {
            rowhead20.createCell(ccn).setCellValue(StringAdapter.getString(iep.baseParam.getUid()));
            rowhead21.createCell(ccn).setCellValue(iep.number + "." + iep.baseParam.getName());
            rowhead22.createCell(ccn++).setCellValue(iep.aimBefore.doubleValue());
        }
        if (!cutCarList.isEmpty()) {
            for (EntityCar car : cutCarList) {
                SubModel sm = bodyMap.get(car.car.getCmsqId());
                String body = "";
                if (sm != null) {
                    body = sm.getBody();
                }
                HSSFRow rowbody = cutedSheet.createRow(k++);
                int con = 0;
                rowbody.createCell(con++).setCellValue(StringAdapter.getString(car.car.getCarId()));
                rowbody.createCell(con++).setCellValue(StringAdapter.getString(car.getMarkTitle()));
                rowbody.createCell(con++).setCellValue(StringAdapter.getString(car.getModelTitle()));
                rowbody.createCell(con++).setCellValue(StringAdapter.getString(car.car.getCompletionTitle()));
                rowbody.createCell(con++).setCellValue(StringAdapter.getString(car.getCarTitle()));
                rowbody.createCell(con).setCellValue(body);

                int num = 0;
                if (car.cutNum != null) {
                    num = car.cutNum;
                }
                String cutValue = car.cutVal;
                if (cutValue == null || cutValue.equals("null")) {
                    cutValue = "?     ";
                }

                try {
                    Double cutedValue = Double.valueOf(car.cutVal);
                    rowbody.createCell(con + num).setCellValue(cutedValue);
                } catch (Exception e) {
                    rowbody.createCell(con + num).setCellValue(cutValue.replace(".", ","));
                }

                /*HSSFRow carRow = instCutedSheet.createRow(cutoptrownum);
                carRow.createCell(0).setCellValue(StringAdapter.getString(car.car.getCarId()));
                carRow.createCell(1).setCellValue(StringAdapter.getString(car.getMarkTitle()));
                carRow.createCell(2).setCellValue(StringAdapter.getString(car.getModelTitle()));
                carRow.createCell(3).setCellValue(StringAdapter.getString(car.getCarTitle()));
                carRow.createCell(4).setCellValue(RenderSupport.renderDecimalNoPoint(car.basePrice).replace(".", ","));
                carRow.createCell(5).setCellValue(RenderSupport.renderDecimalNoPoint(car.fixPrice).replace(".", ","));
                carRow.createCell(6).setCellValue(StringAdapter.getString(car.dinamicRateA.add(car.dinamicRateB)).replace(".", ","));
                carRow.createCell(7).setCellValue(StringAdapter.getString(car.staticRate).replace(".", ","));
                carRow.createCell(8).setCellValue(StringAdapter.getString(car.staticRate.add(car.dinamicRateA.add(car.dinamicRateB))).replace(".", ","));
                cutoptrownum++;
                HSSFRow carRowHead = instCutedSheet.createRow(cutoptrownum);
                carRowHead.createCell(0).setCellValue(StringAdapter.getString(""));
                carRowHead.createCell(1).setCellValue(StringAdapter.getString(""));
                carRowHead.createCell(2).setCellValue(StringAdapter.getString("??"));
                carRowHead.createCell(3).setCellValue(StringAdapter.getString("?????"));
                carRowHead.createCell(4).setCellValue(StringAdapter.getString("???"));
                carRowHead.createCell(5).setCellValue(StringAdapter.getString("%"));
                carRowHead.createCell(6).setCellValue(StringAdapter.getString("??"));
                cutoptrownum++;*/
                /*for (PropertyName pn : car.car.getPropertyNames()) {
                 CarProperty p = pn.getCarProperty();
                 if (p != null) {
                 HSSFRow optRow = instCutedSheet.createRow((short) cutoptrownum);
                 if (p.getUid() != null) {
                 optRow.createCell(0).setCellValue(p.getUid());
                 } else {
                 optRow.createCell(0).setCellValue("? ");
                 }
                        
                 optRow.createCell(1).setCellValue("?");
                 if (p.getTitle() != null) {
                 optRow.createCell(2).setCellValue(p.getTitle());
                 } else {
                 optRow.createCell(2).setCellValue("? ");
                 }
                 if (pn.getPropertyNameValue() != null && !pn.getPropertyNameValue().equals("")) {
                 optRow.createCell(3).setCellValue(pn.getPropertyNameValue());
                 } else {
                 optRow.createCell(3).setCellValue("? ");
                 }
                 if (pn.getParamValue() != null && !pn.getParamValue().equals("")) {
                 optRow.createCell(4).setCellValue(pn.getParamValue());
                 } else {
                 optRow.createCell(4).setCellValue("? ");
                 }
                 if (pn.getPercentValue() != null && !pn.getPercentValue().equals("")) {
                 optRow.createCell(5).setCellValue(pn.getPercentValue());
                 } else {
                 optRow.createCell(5).setCellValue("? ");
                 }
                 if (pn.getRadical() != null && !pn.getRadical().equals("")) {
                 optRow.createCell(6).setCellValue(pn.getRadical());
                 } else {
                 optRow.createCell(6).setCellValue("? ");
                 }
                 cutoptrownum++;
                 }
                 }
                 List<Feature> flist = carService.getFeatures(car.car);
                 for (Feature f : flist) {
                 HSSFRow optRow = instCutedSheet.createRow((short) cutoptrownum);
                 if (f.getUid() != null) {
                 optRow.createCell(0).setCellValue(f.getUid());
                 } else {
                 optRow.createCell(0).setCellValue("? ");
                 }
                 optRow.createCell(1).setCellValue("??");
                 optRow.createCell(2).setCellValue("");
                 if (f.getTitle() != null) {
                 optRow.createCell(3).setCellValue(f.getTitle());
                 } else {
                 optRow.createCell(3).setCellValue("? ");
                 }
                 if (f.getParamValue() != null) {
                 optRow.createCell(4).setCellValue(f.getParamValue());
                 } else {
                 optRow.createCell(4).setCellValue("? ");
                 }
                 if (f.getPercentValue() != null) {
                 optRow.createCell(5).setCellValue(f.getPercentValue());
                 } else {
                 optRow.createCell(5).setCellValue("? ");
                 }
                 if (f.getRadical() != null) {
                 optRow.createCell(6).setCellValue(f.getRadical());
                 } else {
                 optRow.createCell(6).setCellValue("? ");
                 }
                 cutoptrownum++;
                 }*/
                /*for (CarOptionValue cov : car.car.getCarOptionValues()) {
                 CarCompletionOption cco = cov.getCCO();
                 if (cco != null) {
                 HSSFRow optRow = instCutedSheet.createRow((short) cutoptrownum);
                 if (cco.getUid() != null) {
                 optRow.createCell(0).setCellValue(cco.getUid());
                 } else {
                 optRow.createCell(0).setCellValue("? ");
                 }
                        
                 optRow.createCell(1).setCellValue("?");
                 if (cco.getTitle() != null) {
                 optRow.createCell(2).setCellValue(cco.getTitle());
                 } else {
                 optRow.createCell(2).setCellValue("? ");
                 }
                 if (cov.getTitle() != null) {
                 optRow.createCell(3).setCellValue(cov.getTitle());
                 } else {
                 optRow.createCell(3).setCellValue("? ");
                 }
                 if (cco.getParamValue() != null) {
                 optRow.createCell(4).setCellValue(cco.getParamValue());
                 } else {
                 optRow.createCell(4).setCellValue("? ");
                 }
                 if (cco.getPercentValue() != null) {
                 optRow.createCell(5).setCellValue(cco.getPercentValue());
                 } else {
                 optRow.createCell(5).setCellValue("? ");
                 }
                 if (cco.getRadical() != null) {
                 optRow.createCell(6).setCellValue(cco.getRadical());
                 } else {
                 optRow.createCell(6).setCellValue("? ");
                 }
                        
                 cutoptrownum++;
                 }
                 }
                 for (CarColorValue ccv : car.car.getCarColorValues()) {
                 Color col = ccv.getColor();
                 if (col != null) {
                 HSSFRow optRow = instCutedSheet.createRow((short) cutoptrownum);
                 if (col.getUid() != null) {
                 optRow.createCell(0).setCellValue(col.getUid());
                 } else {
                 optRow.createCell(0).setCellValue("? ");
                 }
                        
                 optRow.createCell(1).setCellValue("");
                 if (col.getTitle() != null) {
                 optRow.createCell(2).setCellValue(col.getTitle());
                 } else {
                 optRow.createCell(2).setCellValue("? ");
                 }
                 if (col.getName() != null) {
                 optRow.createCell(3).setCellValue(col.getName());
                 } else {
                 optRow.createCell(3).setCellValue("? ");
                 }
                 if (col.getParamValue() != null) {
                 optRow.createCell(4).setCellValue(col.getParamValue());
                 } else {
                 optRow.createCell(4).setCellValue("? ");
                 }
                 if (col.getPercentValue() != null) {
                 optRow.createCell(5).setCellValue(col.getPercentValue());
                 } else {
                 optRow.createCell(5).setCellValue("? ");
                 }
                 if (col.getRadical() != null) {
                 optRow.createCell(6).setCellValue(col.getRadical());
                 } else {
                 optRow.createCell(6).setCellValue("? ");
                 }
                        
                 cutoptrownum++;
                 }
                 }*/
                /*for(String uid:car.aprops.keySet()){
                 for(EntityProperty ep:car.aprops.get(uid).getPropList()){
                 HSSFRow optRow = instCutedSheet.createRow((short) cutoptrownum);
                 optRow.createCell(0).setCellValue(uid);
                 optRow.createCell(1).setCellValue(ep.name);
                 optRow.createCell(2).setCellValue(ep.title);
                 optRow.createCell(3).setCellValue(ep.type.getName());
                 optRow.createCell(4).setCellValue(StringAdapter.getString(ep.value));
                 cutoptrownum++;
                 }
                 }
                 for(String uid:car.bprops.keySet()){
                 for(EntityProperty ep:car.bprops.get(uid).getPropList()){
                 HSSFRow optRow = instCutedSheet.createRow((short) cutoptrownum);
                 optRow.createCell(0).setCellValue(uid);
                 optRow.createCell(1).setCellValue(ep.name);
                 optRow.createCell(2).setCellValue(ep.title);
                 optRow.createCell(3).setCellValue(ep.type.getName());
                 optRow.createCell(4).setCellValue(StringAdapter.getString(ep.value));
                 cutoptrownum++;
                 }
                 }*/
            }
        }
        File f = new File("/usr/local/etc/xls/" + evId + ".xls");
        if (f.exists()) {
            f.delete();
        }
        workbook.write(new FileOutputStream("/usr/local/etc/xls/" + evId + ".xls"));
    } catch (Exception e) {
        //log.warn("HSSFWorkbook.getXls()", e);
        throw new Exception(e);
    }
}

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

private List<TbFixEntrustContent> composeContent(List<TbFixEntrustContent> tbFixEntrustContentList) {

    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())

                        ) {//w  w w  . j a va2 s . com

                            flag = true;

                            break;

                        }

                    }

                }

            }

            if (flag) {

                continue;

            } else {

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

            }

            TbFixEntrustContent temp = tbFixEntrustContentList.get(i);

            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()));

                }

            }

            temp.setFixHourAll(d.doubleValue());

            temp.setFixHour(d2.doubleValue());

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

                tbFixEntrustContentListAdd.add(temp);

            }

        }

    }

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

        TbFixEntrustContent t = new TbFixEntrustContent();

        t.setStationName("");

        tbFixEntrustContentListAdd.add(t);

    }

    return tbFixEntrustContentListAdd;
}

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

private Double calcFavourAmount(Double itemTotal, Double favourRate) {

    BigDecimal d = new BigDecimal("0.00");

    if (null != itemTotal && null != favourRate && !favourRate.equals(1.00D)) {

        BigDecimal d_itemTotal = new BigDecimal(String.valueOf(itemTotal));

        BigDecimal d_favourRate = new BigDecimal(String.valueOf(favourRate));

        d = d_itemTotal.multiply(d_favourRate)
                .divide(new BigDecimal("1.00").subtract(d_favourRate), 2, BigDecimal.ROUND_HALF_UP)
                .setScale(2, BigDecimal.ROUND_HALF_UP);
    }/* w  w  w  .j  a v  a 2s.com*/

    return d.doubleValue();
}

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

public List<StatisticsTbFixBusinessVo> statisticsAll(TbBusinessBalance tbBusinessBalance) {

    List<TbBusinessBalance> listAll = this.findTbBusinessBalanceToGroup(tbBusinessBalance);

    List<StatisticsTbFixBusinessVo> statisticsTbFixBusinessVoList = new ArrayList<StatisticsTbFixBusinessVo>();

    StatisticsTbFixBusinessVo statisticsTbFixBusinessVo = new StatisticsTbFixBusinessVo();

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

        statisticsTbFixBusinessVo.setAllBalance(listAll.size());

        BigDecimal d_all = new BigDecimal("0.00");

        BigDecimal d_payed = new BigDecimal("0.00");

        BigDecimal d_owe = new BigDecimal("0.00");

        for (TbBusinessBalance t : listAll) {

            d_all = d_all.add(new BigDecimal(String.valueOf(t.getBalanceTotalAll())));

            d_payed = d_payed.add(new BigDecimal(String.valueOf(t.getShouldPayAmount())));

            d_owe = d_owe.add(new BigDecimal(String.valueOf(t.getOweAmount())));
        }/*from  w ww  .  j a v a 2s.  c o m*/

        statisticsTbFixBusinessVo.setBalanceItemAmount(d_all.doubleValue());

        statisticsTbFixBusinessVo.setBalanceItemPay(d_payed.doubleValue());

        statisticsTbFixBusinessVo.setBalanceItemOweAmount(d_owe.doubleValue());

        StatisticsTbFixBusinessVo st = tbReceiveFreeService.staticsTbReceiveFree(listAll);

        statisticsTbFixBusinessVo.setFreeBalance(st.getFreeBalance());

        statisticsTbFixBusinessVo.setBalanceItemFree(st.getBalanceItemFree());

        StatisticsTbFixBusinessVo reBalance = this.staticsReBalance(tbBusinessBalance);

        statisticsTbFixBusinessVo.setReBalance(reBalance.getCountNum());

        /**
         * ?E3
         */
        StatisticsTbFixBusinessVo s_balanceItemAmount_show = new StatisticsTbFixBusinessVo();

        s_balanceItemAmount_show.setStaticsShow("?");

        s_balanceItemAmount_show.setStaticsVal(statisticsTbFixBusinessVo.getBalanceItemAmount());

        // ?
        ActionContext.getContext().put("totalAll",
                new BigDecimal(statisticsTbFixBusinessVo.getBalanceItemAmount()).setScale(2,
                        BigDecimal.ROUND_HALF_UP));
        // ?
        BigDecimal substract = new BigDecimal(statisticsTbFixBusinessVo.getBalanceItemAmount())
                .divide(new BigDecimal(1.17d), 2, BigDecimal.ROUND_HALF_UP);

        StatisticsTbFixBusinessVo s_allBalance_show = new StatisticsTbFixBusinessVo();

        s_allBalance_show.setStaticsShow("");

        s_allBalance_show.setStaticsVal(statisticsTbFixBusinessVo.getAllBalance() + " " + "");

        StatisticsTbFixBusinessVo s_balanceItemPay_show = new StatisticsTbFixBusinessVo();

        s_balanceItemPay_show.setStaticsShow("?");

        s_balanceItemPay_show.setStaticsVal(statisticsTbFixBusinessVo.getBalanceItemAmount());

        StatisticsTbFixBusinessVo s_balanceItemOweAmount_show = new StatisticsTbFixBusinessVo();

        s_balanceItemOweAmount_show.setStaticsShow("?");

        s_balanceItemOweAmount_show.setStaticsVal(statisticsTbFixBusinessVo.getBalanceItemOweAmount());

        StatisticsTbFixBusinessVo s_freeBalance_show = new StatisticsTbFixBusinessVo();

        s_freeBalance_show.setStaticsShow("??");

        s_freeBalance_show.setStaticsVal(statisticsTbFixBusinessVo.getFreeBalance() + " " + "");

        StatisticsTbFixBusinessVo s_balanceItemFree_show = new StatisticsTbFixBusinessVo();

        s_balanceItemFree_show.setStaticsShow("???");

        s_balanceItemFree_show.setStaticsVal(statisticsTbFixBusinessVo.getBalanceItemFree());

        StatisticsTbFixBusinessVo s_reBalance_show = new StatisticsTbFixBusinessVo();

        s_reBalance_show.setStaticsShow("?");

        s_reBalance_show.setStaticsVal(statisticsTbFixBusinessVo.getReBalance() + " " + "");

        statisticsTbFixBusinessVoList.add(s_balanceItemAmount_show);

        statisticsTbFixBusinessVoList.add(s_allBalance_show);

        statisticsTbFixBusinessVoList.add(s_balanceItemPay_show);

        statisticsTbFixBusinessVoList.add(s_balanceItemOweAmount_show);

        statisticsTbFixBusinessVoList.add(s_freeBalance_show);

        statisticsTbFixBusinessVoList.add(s_balanceItemFree_show);

        statisticsTbFixBusinessVoList.add(s_reBalance_show);
    }

    return statisticsTbFixBusinessVoList;
}

From source file:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.UploadTable.java

/**
 * @param fld/*from   w  ww.ja v  a 2 s.c  o  m*/
 * @return values of the correct class for fld's setter.
 * @throws NoSuchMethodException
 * @throws InvocationTargetException
 * @throws IllegalArgumentException
 * @throws IllegalAccessException
 * @throws ParseException
 * 
 * Converts fld's string value to the correct class for the field being uploaded to.
 */
protected Object[] getArgForSetter(final UploadField ufld)
        throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, UploaderException {
    try {
        Object arg[] = new Object[1];
        Class<?> fldClass;
        //            if (tblClass.equals(DeterminationStatus.class) && ufld.getField().getName().equalsIgnoreCase("type"))
        //            {
        //                fldClass = Boolean.class;
        //            }
        //            else
        {
            fldClass = ufld.getSetter().getParameterTypes()[0];
        }
        String fldStr;
        if (ufld.getValueObject() == null) {
            fldStr = null;
        } else {
            fldStr = fldClass.equals(String.class) ? ufld.getValueObject() : ufld.getValueObject().trim();
        }
        if (fldClass == java.util.Calendar.class || fldClass == java.util.Date.class) {
            // There are problems with DateConverter (see DateConverter)
            if (fldStr == null || fldStr.equals("")) {
                arg[0] = null;
            } else {
                if (isDateWithPrecision(ufld.getField().getFieldInfo())) {
                    fldStr = dateConverter.adjustForPrecision(fldStr);
                } else {
                    //need to do this because even with lenient = false, Calendar.parse
                    //will still interpret '00/Jun/2004' as '31/May/2004'.
                    try {
                        UIFieldFormatterIFace.PartialDateEnum prec = dateConverter.getDatePrecision(fldStr);
                        if (prec.equals(UIFieldFormatterIFace.PartialDateEnum.Month)
                                || prec.equals(UIFieldFormatterIFace.PartialDateEnum.Year)) {
                            ParseException pex = new ParseException(
                                    UIRegistry.getResourceString("WB_UPLOAD_INVALID_FORMAT"), 0);
                            throw new UploaderException(pex, UploaderException.INVALID_DATA);
                        }
                    } catch (ParseException pex) {
                        //ignore. Problem should get caught in dateConverter.convert call below.
                    }
                }

                arg[0] = dateConverter.convert(fldStr);
            }
        } else if (fldClass == BigDecimal.class) {
            if (fldStr == null || fldStr.equals("")) {
                arg[0] = null;
            } else {
                if (!isLatLongFld(ufld)) {
                    if (!ufld.checkPrecisionAndScale(fldStr)) {
                        //System.out.println("bam");
                        throw new UploaderException(
                                String.format(getResourceString("WB_UPLOAD_INVALID_PREC_SCALE"),
                                        ufld.getPrecision() - ufld.getScale(), ufld.getScale()),
                                UploaderException.INVALID_DATA);
                    }
                } else {
                    boolean gotANumber = UIHelper.parseDoubleToBigDecimal(fldStr) != null;
                    if (!gotANumber) {
                        try {
                            fldStr = geoRefConverter.convert(StringUtils.stripToNull(fldStr),
                                    GeoRefFormat.D_PLUS_MINUS.name());
                        } catch (Exception ex) {
                            throw new UploaderException(ex, UploaderException.INVALID_DATA);
                        }
                    }
                }
                BigDecimal val = UIHelper.parseDoubleToBigDecimal(fldStr);
                if (StringUtils.isNotEmpty(fldStr) && val == null) {
                    throw new UploaderException(UIRegistry.getResourceString("WB_UPLOAD_INVALID_FORMAT"),
                            UploaderException.INVALID_DATA);
                }
                if (isLatLongFld(ufld)) {
                    Double maxVal = isLatFld(ufld) ? new Double("90") : new Double("180");
                    if (Math.abs(val.doubleValue()) > maxVal) {
                        throw new UploaderException(getResourceString("WB_UPLOAD_INVALID_GEOREF_VALUE"),
                                UploaderException.INVALID_DATA);
                    }
                }
                arg[0] = val;

            }
        } else if (fldClass == Boolean.class) {
            if (fldStr == null || fldStr.equals("")) {
                arg[0] = null;
            } else {
                int i;
                for (i = 0; i < WorkbenchTask.boolStrings.length; i++) {
                    if (fldStr.equalsIgnoreCase(WorkbenchTask.boolStrings[i]))
                        break;
                }
                if (i == WorkbenchTask.boolStrings.length) {
                    throw new UploaderException(getResourceString("WB_INVALID_BOOL_CELL_VALUE"),
                            UploaderException.INVALID_DATA);
                }
                arg[0] = i % 2 == 0 ? true : false;
            }
            //grotesquery
            //sorry, too much extra processing involved with maintaining one and only one current determination
            //to mess around with the isCurrent workbench mapping. An uploaded co is current or not current.
            //                if (tblClass.equals(DeterminationStatus.class)
            //                        && ufld.getField().getName().equalsIgnoreCase("type"))
            //                {
            //                    if (arg[0] == null) { throw new UploaderException(
            //                            getResourceString("WB_INVALID_BOOL_CELL_VALUE"),
            //                            UploaderException.INVALID_DATA); }
            //                    Boolean c = (Boolean) arg[0];
            //                    if (c)
            //                    {
            //                        arg[0] = DeterminationStatus.CURRENT;
            //                    }
            //                    else
            //                    {
            //                        arg[0] = DeterminationStatus.NOTCURRENT;
            //                    }
            //                }
        } else if (fldClass != String.class) {
            Class<?> stringArg[] = new Class<?>[1];
            stringArg[0] = String.class;
            Method converter = fldClass.getMethod("valueOf", stringArg);
            Object converterArg[] = new Object[1];
            converterArg[0] = fldStr;
            if (converterArg[0] != null) {
                arg[0] = converter.invoke(fldClass, converterArg);
            } else {
                arg[0] = null;
            }
        } else {
            UIFieldFormatterIFace formatter = ufld.getField().getFieldInfo().getFormatter();
            if (StringUtils.isBlank(fldStr)
                    && (formatter == null || !formatter.isIncrementer()/* || !formatter.isNumeric()*/)) {
                arg[0] = null;
            } else {
                Object val = fldStr;
                if (ufld.getField().getFieldInfo() != null) {
                    if (formatter != null) {
                        if (isUploadRoot && StringUtils.isBlank(fldStr) && formatter.isIncrementer()
                                && ufld.isAutoAssignForUpload()) {
                            if (!this.validatingValues || autoAssignedVal == null) {
                                if (autoAssignedVal == null) {
                                    if (prevAutoAssignedVal != null) {
                                        val = formatter.getNextNumber(formatter
                                                .formatFromUI(prevAutoAssignedVal.toString()).toString(), true);
                                    } else {
                                        val = formatter.getNextNumber(formatter.formatToUI("").toString());
                                    }
                                    // XXX timo - Need to check here for a null return value.
                                    autoAssignedVal = formatter.formatToUI(val);
                                    prevAutoAssignedVal = autoAssignedVal;
                                } else if (!this.validatingValues) {
                                    val = formatter.formatFromUI(autoAssignedVal);
                                }

                            }
                            if (autoAssignedField == null) {
                                autoAssignedField = ufld;
                            }
                        } else {
                            if (StringUtils.isBlank(fldStr)) {
                                if (ufld.isAutoAssignable()) {
                                    val = formatter.getNextNumber(formatter.formatToUI("").toString());
                                } else {
                                    val = null;
                                }
                            } else {
                                val = formatter.formatFromUI(fldStr);
                                if (!formatter.isValid((String) val)) {
                                    throw new UploaderException(
                                            UIRegistry.getResourceString("WB_UPLOAD_INVALID_FORMAT"),
                                            UploaderException.INVALID_DATA);
                                }
                            }
                        }
                    }
                }
                arg[0] = val;
            }
        }
        return arg;
    } catch (IllegalArgumentException ex) {
        throw new UploaderException(ex, UploaderException.INVALID_DATA);
    } catch (ParseException ex) {
        throw new UploaderException(ex, UploaderException.INVALID_DATA);
    }
}

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

public Map putXsdBalanceReportParamMap(Long id, HttpServletRequest request) {

    Map map = new HashMap();
    // ??//from  w w  w.  j  a v  a2s . com
    TbBusinessBalance tbBusinessBalance = this.findById(id);
    // ??
    TmStockOut tmStockOut = tmStockOutService.findById(tbBusinessBalance.getTmStockOut().getId());

    // ?
    TbCustomer tbCustomer = tbCustomerService.findById(tmStockOut.getCustomerBill());

    // ??
    TmCompany tmCompany = tmCompanyService.acquireUniqueTmCompany();

    // ??
    List<TbMaintianVo> maintianvos = new ArrayList<TbMaintianVo>();
    // ?
    List<TmStockOutDetVo> tmStockOutDetVos = tmStockOutService
            .getCustomerSellDetailByTmStockOutId(tmStockOut.getId(), Constants.BALANCE_ALL);

    // 
    List<TbBusinessBalanceItem> tbBusinessBalanceItemList = tbBusinessBalanceItemService
            .findGroupTbBusinessBalanceItemListByTbBusinessBalanceId(tbBusinessBalance.getId());
    // ?--??
    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) {

                    for (TbMaintianVo _tbMaintianVo : maintianvosTemp) {

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

                            flag = true;

                            break;

                        }

                    }

                }

            }

            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())) {

                    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.getIsFree().equals(1L))) {

                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", tbBusinessBalance.getBalanceCode());

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

    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);
    }

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

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

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

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

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

    // 
    reportParameters.put("remark", tbBusinessBalance.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("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(null));

    // ???-
    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);

        }

    }
    // ??
    reportParameters.put("soleAmount", new BigDecimal(reportParameters.get("totalAmount").toString())
            .subtract(new BigDecimal(reportParameters.get("taxAmount").toString())).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())) {

        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.jrxml");

    }

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

    return map;

}

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

public Map putEntrustBalanceReportParamMap(Long id, HttpServletRequest request) {

    Map map = new HashMap();
    // ?/* ww  w. j  av a 2  s.  com*/
    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:com.jeans.iservlet.controller.impl.ExportController.java

/**
 * ???/*  w ww .j av  a2s  .  c  o  m*/
 * 
 * @return
 * @throws IOException
 */
@RequestMapping(method = RequestMethod.POST, value = "/systems")
public ResponseEntity<byte[]> exportITSystems() throws IOException {
    StringBuilder fn = new StringBuilder(getCurrentCompany().getName());
    fn.append(" - ??(");
    Workbook wb = new XSSFWorkbook();
    Sheet sheet = wb.createSheet("?");
    // ?
    // 
    // ?10??
    Font tFont = sheet.getWorkbook().createFont();
    tFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
    tFont.setFontName("");
    tFont.setFontHeightInPoints((short) 10);
    // ?????????
    CellStyle cellStyleTitle = sheet.getWorkbook().createCellStyle();
    cellStyleTitle.setAlignment(CellStyle.ALIGN_CENTER);
    cellStyleTitle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    cellStyleTitle.setFont(tFont);
    cellStyleTitle.setDataFormat(HSSFDataFormat.getBuiltinFormat("text"));
    cellStyleTitle.setWrapText(false);
    // 20
    Row row = sheet.createRow(0);
    row.setHeightInPoints(20);
    Cell cell = null;
    for (int i = 0; i < ITSYSTEM_HEADERS.length; i++) {
        cell = row.createCell(i, Cell.CELL_TYPE_STRING);
        cell.setCellStyle(cellStyleTitle);
        cell.setCellValue(ITSYSTEM_HEADERS[i]);
        sheet.setColumnWidth(i, ITSYSTEM_HEADERS_WIDTH[i] * 256);
    }
    // ?????->?->????
    List<ITSystem> systems = new ArrayList<ITSystem>(systService.listSystems(getCurrentCompany(), null, null));
    Collections.sort(systems, new Comparator<ITSystem>() {

        @Override
        public int compare(ITSystem o1, ITSystem o2) {
            int ret = o1.getType().ordinal() - o2.getType().ordinal();
            if (ret == 0) {
                ret = Long.compare(o1.getOwner().getId(), o2.getOwner().getId());
                if (ret == 0) {
                    ret = Collator.getInstance(java.util.Locale.CHINA).compare(o1.getName(), o2.getName());
                }
            }
            return ret;
        }

    });
    // ??
    DataFormat df = sheet.getWorkbook().createDataFormat();
    // ?10?
    Font font = sheet.getWorkbook().createFont();
    font.setFontName("");
    font.setFontHeightInPoints((short) 10);
    // ?1???????
    CellStyle cellStyleString = sheet.getWorkbook().createCellStyle();
    cellStyleString.setAlignment(CellStyle.ALIGN_CENTER);
    cellStyleString.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    cellStyleString.setFont(font);
    cellStyleString.setDataFormat(HSSFDataFormat.getBuiltinFormat("text"));
    cellStyleString.setWrapText(false);
    // ?2????(yyyyMMdd)???
    CellStyle cellStyleDate = sheet.getWorkbook().createCellStyle();
    cellStyleDate.setAlignment(CellStyle.ALIGN_CENTER);
    cellStyleDate.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    cellStyleDate.setFont(font);
    cellStyleDate.setDataFormat(df.getFormat("yyyyMMdd"));
    cellStyleDate.setWrapText(false);
    // ?3??????(#)???
    CellStyle cellStyleQuantity = sheet.getWorkbook().createCellStyle();
    cellStyleQuantity.setAlignment(CellStyle.ALIGN_CENTER);
    cellStyleQuantity.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    cellStyleQuantity.setFont(font);
    cellStyleQuantity.setDataFormat(df.getFormat("0"));
    cellStyleQuantity.setWrapText(false);
    // ?4?????(#,##0.00_ )???
    CellStyle cellStyleCost = sheet.getWorkbook().createCellStyle();
    cellStyleCost.setAlignment(CellStyle.ALIGN_RIGHT);
    cellStyleCost.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    cellStyleCost.setFont(font);
    cellStyleCost.setDataFormat(df.getFormat("#,##0.00_ "));
    cellStyleCost.setWrapText(false);
    // sheet
    int rowNumber = 1;
    for (ITSystem system : systems) {
        // 20
        row = sheet.createRow(rowNumber);
        row.setHeightInPoints(20);
        // ?
        Set<SystemBranch> branches = system.getBranches();
        SystemBranch localBranch = null; // ??
        long localId = 0;
        if (getCurrentCompany().getLevel() == Company.BRANCH) {
            localId = getCurrentCompany().getSuperior().getId();
        } else {
            localId = getCurrentCompany().getId();
        }
        BigDecimal cost = new BigDecimal("0.0"); // 
        for (SystemBranch branch : branches) {
            cost.add(branch.getCost());
            if (branch.getCompany().getId() == localId) {
                localBranch = branch;
            }
        }
        boolean branched = (localBranch != null); // ?
        boolean owned = system.getOwner().getId() == getCurrentCompany().getId(); // ?????
        // 
        // 
        cell = row.createCell(0, Cell.CELL_TYPE_STRING);
        cell.setCellStyle(cellStyleString);
        cell.setCellValue(system.getType().getTitle());
        // ??
        cell = row.createCell(1, Cell.CELL_TYPE_STRING);
        cell.setCellStyle(cellStyleString);
        cell.setCellValue(system.getName());
        // 
        cell = row.createCell(2, Cell.CELL_TYPE_STRING);
        cell.setCellStyle(cellStyleString);
        cell.setCellValue(system.getAlias());
        // /?
        cell = row.createCell(3, Cell.CELL_TYPE_STRING);
        cell.setCellStyle(cellStyleString);
        cell.setCellValue(system.getModelOrVersion());
        // 
        cell = row.createCell(4, Cell.CELL_TYPE_STRING);
        cell.setCellStyle(cellStyleString);
        cell.setCellValue(system.getBrief());
        // ?
        cell = row.createCell(5, Cell.CELL_TYPE_STRING);
        cell.setCellStyle(cellStyleString);
        cell.setCellValue(ITSYSTEM_sLevel[system.getSecurityLevel()]);
        // ???
        cell = row.createCell(6, Cell.CELL_TYPE_STRING);
        cell.setCellStyle(cellStyleString);
        cell.setCellValue(system.getSecurityCode());
        // ?
        cell = row.createCell(7, Cell.CELL_TYPE_STRING);
        cell.setCellStyle(cellStyleString);
        cell.setCellValue(system.getUsersBrief());
        // 
        cell = row.createCell(8, Cell.CELL_TYPE_STRING);
        cell.setCellStyle(cellStyleString);
        cell.setCellValue(null == system.getProvider() ? "" : system.getProvider().getAlias());
        // ?
        cell = row.createCell(9, Cell.CELL_TYPE_STRING);
        cell.setCellStyle(cellStyleString);
        cell.setCellValue(system.getOwner().getAlias());
        // 
        cell = row.createCell(10, Cell.CELL_TYPE_STRING);
        cell.setCellStyle(cellStyleString);
        cell.setCellValue(system.getScope().getTitle(system.getOwner().getLevel()));
        // 
        cell = row.createCell(11, Cell.CELL_TYPE_STRING);
        cell.setCellStyle(cellStyleString);
        cell.setCellValue(system.getDeploy().getTitle());
        // 
        cell = row.createCell(12, Cell.CELL_TYPE_STRING);
        cell.setCellStyle(cellStyleString);
        cell.setCellValue(branched ? "" : "");
        if (branched) {
            // ?()
            cell = row.createCell(13, Cell.CELL_TYPE_NUMERIC);
            cell.setCellStyle(cellStyleCost);
            cell.setCellValue(localBranch.getCost().doubleValue());
            // ?
            cell = row.createCell(14, Cell.CELL_TYPE_STRING);
            cell.setCellStyle(cellStyleString);
            cell.setCellValue(localBranch.getStage().getTitle());
            // ?
            cell = row.createCell(15, Cell.CELL_TYPE_NUMERIC);
            cell.setCellStyle(cellStyleDate);
            Date ct = localBranch.getConstructedTime();
            if (null != ct) {
                cell.setCellValue(ct);
            }
            // ?
            cell = row.createCell(16, Cell.CELL_TYPE_NUMERIC);
            cell.setCellStyle(cellStyleDate);
            Date at = localBranch.getAbandonedTime();
            if (null != at) {
                cell.setCellValue(at);
            }
        }
        // ??
        cell = row.createCell(17, Cell.CELL_TYPE_NUMERIC);
        cell.setCellStyle(cellStyleQuantity);
        cell.setCellValue(system.getFreeMaintainMonths());
        if (owned) {
            // 
            cell = row.createCell(18, Cell.CELL_TYPE_NUMERIC);
            cell.setCellStyle(cellStyleQuantity);
            cell.setCellValue(branches.size());
            // ?)
            cell = row.createCell(19, Cell.CELL_TYPE_NUMERIC);
            cell.setCellStyle(cellStyleCost);
            cell.setCellValue(cost.doubleValue());
            // ??
            cell = row.createCell(20, Cell.CELL_TYPE_STRING);
            cell.setCellStyle(cellStyleString);
            cell.setCellValue(system.getStage().getTitle());
            // ?
            cell = row.createCell(21, Cell.CELL_TYPE_NUMERIC);
            cell.setCellStyle(cellStyleDate);
            Date ct = system.getConstructedTime();
            if (null != ct) {
                cell.setCellValue(ct);
            }
            // ?
            cell = row.createCell(22, Cell.CELL_TYPE_NUMERIC);
            cell.setCellStyle(cellStyleDate);
            Date at = system.getAbandonedTime();
            if (null != at) {
                cell.setCellValue(at);
            }
        }
        rowNumber++;
    }

    fn.append((new SimpleDateFormat("yyyyMMdd")).format(new Date())).append(").xlsx");
    String filename = null;
    if (isIE()) {
        filename = URLEncoder.encode(fn.toString(), "UTF-8").replaceAll("\\+", "%20");
    } else {
        filename = new String(fn.toString().getBytes("UTF-8"), "iso8859-1");
    }
    response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
    response.setHeader("Content-disposition", "attachment; filename=" + filename);
    BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream(), 4096);
    wb.write(out);
    wb.close();
    out.close();
    return null;
}

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

public List<TbBusinessBalance> findTbBusinessBalanceToGroupReceiveFree(TbBusinessBalance tbBusinessBalance) {

    String sql = "select new TbBusinessBalance(max(tbBusinessBalance.id),tbBusinessBalance.balanceCode,max(tbBusinessBalance.bananceDate),sum(tbBusinessBalance.balanceTotalAll),sum(tbBusinessBalance.shouldPayAmount),sum(tbBusinessBalance.workingHourTotalAll),sum(tbBusinessBalance.fixPartTotalAll),sum(tbBusinessBalance.solePartTotalAll)) from TbBusinessBalance tbBusinessBalance WHERE 1=1";

    String sqlDone = " and (tbBusinessBalance.workingHourFavourRate!=0 or tbBusinessBalance.fixPartFavourRate!=0 or tbBusinessBalance.solePartFavourRate!=0) or tbBusinessBalance.id in (select ti.tbBusinessBalance.id from TbBusinessBalanceItem ti where ti.balanceItemCode = 'QL' and ti.balanceItemTotal > 0)";

    String sqlConditionSelect = "select tbBusinessBalance from TbBusinessBalance tbBusinessBalance where 1=1";

    String sqlCondition = "";

    String sqlGroup = " group by tbBusinessBalance.balanceCode";

    if (null != tbBusinessBalance) {

        if (null != tbBusinessBalance.getId()) {

            /*//from   w  ww .  j  a v a2  s  . com
             * sqlCondition +=" and tbBusinessBalance.id = " +
             * tbBusinessBalance.getId();
             */

            TbBusinessBalance t = this.findById(tbBusinessBalance.getId());

            tbBusinessBalance.setBalanceCode(t.getBalanceCode());

        }

        if (null != tbBusinessBalance.getBalanceCode() && !"".equals(tbBusinessBalance.getBalanceCode())) {

            sqlCondition += " and tbBusinessBalance.balanceCode like '%" + tbBusinessBalance.getBalanceCode()
                    + "%'";

        }

        if (null != tbBusinessBalance.getEntrustCode() && !"".equals(tbBusinessBalance.getEntrustCode())) {

            sqlCondition += " and tbBusinessBalance.tbFixEntrust.entrustCode like '%"
                    + tbBusinessBalance.getEntrustCode() + "%'";

        }

        if (null != tbBusinessBalance.getBananceDateStart()) {
            sqlCondition += " and tbBusinessBalance.bananceDate>='"
                    + CommonMethod.parseDateToString(tbBusinessBalance.getBananceDateStart(), "yyyy-MM-dd")
                    + "'";
        }

        if (null != tbBusinessBalance.getBananceDateEnd()) {
            sqlCondition += " and tbBusinessBalance.bananceDate<='" + CommonMethod.parseDateToString(
                    CommonMethod.addDate(tbBusinessBalance.getBananceDateEnd(), 1), "yyyy-MM-dd") + "'";
        }

        if (null != tbBusinessBalance.getTmUser()) {

            if (null != tbBusinessBalance.getTmUser().getId()) {

                sqlCondition += " and tbBusinessBalance.tmUser.id=" + tbBusinessBalance.getTmUser().getId();

            }

        }
    }

    List<TbBusinessBalance> listCondition = tbBusinessBalanceDao
            .findBySQL(sqlConditionSelect + sqlCondition + sqlDone, null);

    List<TbBusinessBalance> list = tbBusinessBalanceDao.findBySQL(sql + sqlGroup, null);

    List<TbBusinessBalance> listReturn = new ArrayList<TbBusinessBalance>();

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

        for (int i = list.size() - 1; i >= 0; i--) {

            TbBusinessBalance ti = list.get(i);

            for (int j = listCondition.size() - 1; j >= 0; j--) {

                TbBusinessBalance tj = listCondition.get(j);

                if (ti.getBalanceCode().equals(tj.getBalanceCode())) {

                    ti.setTbFixEntrust(tj.getTbFixEntrust());

                    ti.setTmStockOut(tj.getTmStockOut());

                    ti.setOldPartDeal(tj.getOldPartDeal());

                    ti.setRemark(tj.getRemark());

                    ti.setTmUser(tj.getTmUser());

                    TbCustomer tbCustomer = null;

                    if (null != ti.getTbFixEntrust()) {

                        tbCustomer = ti.getTbFixEntrust().getTbCarInfo().getTbCustomer();
                    } else {
                        tbCustomer = tbCustomerService.findById(ti.getTmStockOut().getCustomerBill());
                    }

                    ti.setTbCustomer(tbCustomer);

                    ti.setXlgsfFavourAmount(this.calcItemFavourAmount(ti, "XLGSF"));

                    ti.setXlclfFavourAmount(this.calcItemFavourAmount(ti, "XLCLF"));

                    ti.setXsjeFavourAmount(this.calcItemFavourAmount(ti, "XSJE"));

                    List<TbBusinessBalance> tbbList = this
                            .findTbBusinessBalanceByBalanceCode(ti.getBalanceCode());

                    BigDecimal d = new BigDecimal("0.00");

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

                        for (TbBusinessBalance te : tbbList) {

                            List<TbBusinessBalanceItem> TbBusinessBalanceItemList = tbBusinessBalanceItemService
                                    .findTbBusinessBalanceItemListByTbBusinessBalanceId(te.getId());

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

                                for (TbBusinessBalanceItem item : TbBusinessBalanceItemList) {

                                    if ("QL".equals(item.getBalanceItemCode())) {

                                        d = d.add(new BigDecimal(String.valueOf(item.getBalanceItemTotal())));

                                    }
                                }

                            }
                        }
                    }

                    ti.setQlAmount(d.doubleValue());

                    listReturn.add(ti);

                    break;

                }
            }

        }

    }

    return listReturn;

}

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

public List<StatisticsTbFixBusinessVo> statisticsPayed(TbBusinessBalance tbBusinessBalance, Long type) {

    List<TbBusinessBalance> tbBusinessBalanceList = null;

    List<StatisticsTbFixBusinessVo> statisticsTbFixBusinessVoList = new ArrayList<StatisticsTbFixBusinessVo>();

    if (type.equals(1L)) {

        tbBusinessBalanceList = this.findTbBusinessBalanceNoOweGroup(tbBusinessBalance);

    } else {/*from ww  w .  j ava 2  s . com*/
        tbBusinessBalanceList = this.findTbBusinessBalanceOweGroup(tbBusinessBalance);
    }

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

        BigDecimal d1 = new BigDecimal("0.00");

        BigDecimal d2 = new BigDecimal("0.00");

        BigDecimal d1_owe = new BigDecimal("0.00");

        BigDecimal d2_owe = new BigDecimal("0.00");

        StatisticsTbFixBusinessVo statisticsTbFixBusinessVo1 = new StatisticsTbFixBusinessVo();

        StatisticsTbFixBusinessVo statisticsTbFixBusinessVo2 = new StatisticsTbFixBusinessVo();

        int i1 = 0;

        int i2 = 0;

        for (TbBusinessBalance t : tbBusinessBalanceList) {

            if (null != t.getTbFixEntrust()) {

                d1 = d1.add(new BigDecimal(String.valueOf(t.getBalanceTotalAll())));

                d1_owe = d1_owe.add(new BigDecimal(String.valueOf(t.getOweAmount())));

                i1++;
            } else {

                d2 = d2.add(new BigDecimal(String.valueOf(t.getBalanceTotalAll())));

                d2_owe = d2_owe.add(new BigDecimal(String.valueOf(t.getOweAmount())));

                i2++;
            }

        }

        statisticsTbFixBusinessVo1.setBalanceItemName("?");

        statisticsTbFixBusinessVo1.setCountNum(i1);

        statisticsTbFixBusinessVo1.setBalanceItemAmount(d1.doubleValue());

        statisticsTbFixBusinessVo1.setBalanceItemOweAmount(d1_owe.doubleValue());

        statisticsTbFixBusinessVo2.setBalanceItemName("?");

        statisticsTbFixBusinessVo2.setCountNum(i2);

        statisticsTbFixBusinessVo2.setBalanceItemAmount(d2.doubleValue());

        statisticsTbFixBusinessVoList.add(statisticsTbFixBusinessVo1);

        statisticsTbFixBusinessVoList.add(statisticsTbFixBusinessVo2);

        statisticsTbFixBusinessVo2.setBalanceItemOweAmount(d2_owe.doubleValue());
    }

    return statisticsTbFixBusinessVoList;
}