chengf
2025-08-20 b4de49622a64e15d673f2716f126734e339e5977
service-fee/src/main/java/com/java110/fee/cmd/fee/ReportFeeCmd.java
@@ -22,10 +22,7 @@
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
@Java110Cmd(serviceCode = "fee.reportFeeCmd")
public class ReportFeeCmd extends Cmd {
@@ -56,49 +53,154 @@
        int currentYear = java.time.Year.now().getValue();
        feeQueryParams.setEndYear(currentYear + 2);
        int endYear = feeQueryParams.getEndYear();
        List<Map> result = reportFeeInnerServiceSMOImpl.repostPaidInFee(feeQueryParams);
        DictDto dictDto = new DictDto();
        dictDto.setTableName("pay_fee_config");
        dictDto.setTableColumns("fee_type_cd");
        List<DictDto> dictDtos = dictV1InnerServiceSMOImpl.queryDicts(dictDto);
        int doYear = endYear - startYear;
        List<List<FeeDto>> reportFeeDtoLists = new ArrayList<>();
        List<List<FeeDto>> reportFeeDtoLists = new LinkedList<>();
        reportFeeDtoLists.add(new LinkedList<FeeDto>());
        reportFeeDtoLists.add(new LinkedList<FeeDto>());
        reportFeeDtoLists.add(new LinkedList<FeeDto>());
        reportFeeDtoLists.add(new LinkedList<FeeDto>());
        int ind = 1;
        int[] arr = new int[endYear - startYear + 1];
        for (int i = startYear; i <= endYear; i++) {
            arr[i-startYear] = i;
        }
        for (DictDto dictDto1 : dictDtos) {//类型
            List<FeeDto> reportFeeDtos = new ArrayList<>();
            for (int i = startYear; i <= endYear; i++) {
                for (Map map : result) {
                    FeeDto feeDto = new FeeDto();
                    if (map.get("统计周期")!=null&&map.get("统计周期").equals(i)&&map.get("费用类型编码").equals(dictDto1.getStatusCd())){
                        feeDto.setCurYear((i)+"");
                        feeDto.setFeeTypeCdName(map.get("费用类型名称")+"");
                        double[] doubles = new double[doYear];
                        for (int j = startYear ; j <= endYear ; j++) {
                            if(map.get((j)+"年收费金额(元)")!=null){
                                doubles[j-startYear] = ((BigDecimal)map.get((j)+"年收费金额(元)")).doubleValue();
                            }
            List<FeeDto> reportFeeDtos = new LinkedList<>();//该类型的数组
            FeeDto feeDto = new FeeDto();
            LinkedList<FeeDto> feeDtos = new LinkedList<>();//总的
            int kg = 0;
            for (Map map : result){
                if(map.get("费用所属年份").equals("类型总计") && map.get("fee_type_cd").equals(dictDto1.getStatusCd())){
                    double[] doubles = new double[doYear - 1 + 20];
                    doubles[0] = ((BigDecimal) map.get("该年应缴总额")).doubleValue();
                    doubles[1] = ((BigDecimal) map.get("每月费用")).doubleValue();
                    doubles[2] = ((Long) map.get("应收月份数")).doubleValue();
                    doubles[3] = ((BigDecimal) map.get("当年收缴率(%)")).doubleValue();
                    doubles[4] = ((BigDecimal) map.get("折扣金额")).doubleValue();
                    int inde = 0;
                    for (int i : arr){
                        if(i < currentYear){
                            inde++;
                            doubles[i - startYear + 5] = ((BigDecimal) map.get(i + "年实缴")).doubleValue();
                        }
                        feeDto.setReport(doubles);
                        reportFeeDtos.add(feeDto);
                    }
//                    if(startYear == currentYear){
//                        for (int x = 1 ; x <= 12 ; x++){
//                            feeDto = new FeeDto();
//                            feeDto.setCurYear(startYear+"/"+x);
//                            feeDto.setFeeTypeCdName(dictDto1.getName());
//                            if(map.get(startYear + "年" + x + "月收费金额(元)")!=null){
//                                d
//                            }
//                        }
//                    }
                    doubles[inde + 5] =((BigDecimal) map.get("当年预算")).doubleValue();
                    doubles[inde + 6] =((BigDecimal) map.get(currentYear + "年实缴")).doubleValue();
                    doubles[inde + 7] =((BigDecimal) map.get("当年折扣总额")).doubleValue();
                    doubles[inde + 8] =((BigDecimal) map.get("当年欠款")).doubleValue();
                    for (int i = 1 ; i <= 12 ; i++){
                        doubles[inde + 8 + i] =((BigDecimal) map.get("当年"+i+"月实缴")).doubleValue();
                    }
                    feeDto.setCurYear(dictDto1.getName()+"总计");
                    feeDto.setReport(doubles);
                    feeDto.setCount(ind);
                }
            }
            reportFeeDtoLists.add(reportFeeDtos);
            if (feeDto.getCurYear() == null){
                feeDto.setCurYear("类型总计");
            }
            if (feeDto.getReport() == null){
                feeDto.setReport(new double[doYear - 1 + 20]);
            }
            if(feeDto.getFeeTypeCdName() == null) {
                feeDto.setFeeTypeCdName(dictDto1.getName());
            }
            LinkedList<FeeDto> feeDtos1 = new LinkedList<>();
            feeDtos1.add(feeDto);
            reportFeeDtoLists.add(feeDtos1);//添加总金额的
            feeDtos1 = new LinkedList<>();
            feeDto = new FeeDto();
            LinkedList<FeeDto> feeDtos2 = new LinkedList<>();
            for (int i = startYear; i <= endYear; i++) {//年份
                kg = 0;
                for (Map map : result){
                    if(map.get("费用所属年份").equals(i+"") && map.get("fee_type_cd").equals(dictDto1.getStatusCd())){
                        double[] doubles = new double[doYear - 1 + 20];
                        doubles[0] = ((BigDecimal) map.get("该年应缴总额")).doubleValue();
                        doubles[1] = ((BigDecimal) map.get("每月费用")).doubleValue();
                        doubles[2] = ((Long) map.get("应收月份数")).doubleValue();
                        doubles[3] = ((BigDecimal) map.get("当年收缴率(%)")).doubleValue();
                        doubles[4] = ((BigDecimal) map.get("折扣金额")).doubleValue();
                        int inde = 0;
                        for (int in : arr){
                            if(in < currentYear){
                                inde++;
                                doubles[in - startYear + 5] = ((BigDecimal) map.get(i + "年实缴")).doubleValue();
                            }
                        }
                        doubles[inde + 5] =((BigDecimal) map.get("当年预算")).doubleValue();
                        doubles[inde + 6] =((BigDecimal) map.get(currentYear + "年实缴")).doubleValue();
                        doubles[inde + 7] =((BigDecimal) map.get("当年折扣总额")).doubleValue();
                        doubles[inde + 8] =((BigDecimal) map.get("当年欠款")).doubleValue();
                        for (int in = 1 ; in <= 12 ; in++){
                            doubles[inde + 8 + in] =((BigDecimal) map.get("当年"+in+"月实缴")).doubleValue();
                        }
                        feeDto = new FeeDto();
                        feeDto.setFeeTypeCdName(dictDto1.getName());
                        feeDto.setCurYear(String.valueOf(i));
                        feeDto.setReport(doubles);
                        feeDto.setCount(ind);
                        feeDtos2.add(feeDto);
                        kg = 1;
                    }
                }
                if(kg == 0){
                    feeDto = new FeeDto();
                    feeDto.setFeeTypeCdName(dictDto1.getName());
                    feeDto.setCurYear(String.valueOf(i));
                    feeDto.setReport(new double[doYear - 1 + 20]);
                    feeDto.setCount(ind);
                    feeDtos2.add(feeDto);
                }
            }
            reportFeeDtoLists.add(feeDtos2);
            if (ind == 1){
                LinkedList linkedList = new LinkedList();
                FeeDto feeDto1 = new FeeDto();
                feeDto1.setCurYear("住宅物业费代收合计");
                linkedList.add(feeDto1);
                reportFeeDtoLists.add(linkedList);
            }
            if (ind == 2){
                LinkedList linkedList = new LinkedList();
                FeeDto feeDto1 = new FeeDto();
                feeDto1.setCurYear("商铺物业费代收合计");
                linkedList.add(feeDto1);
                reportFeeDtoLists.add(linkedList);
            }
            if (ind == 3){
                LinkedList linkedList = new LinkedList();
                FeeDto feeDto1 = new FeeDto();
                feeDto1.setCurYear("停车费合计(3+...+7)");
                linkedList.add(feeDto1);
                reportFeeDtoLists.add(linkedList);
            }
            if (ind == 8){
                LinkedList linkedList = new LinkedList();
                FeeDto feeDto1 = new FeeDto();
                feeDto1.setCurYear("其他类合计(8+...+22)");
                linkedList.add(feeDto1);
                reportFeeDtoLists.add(linkedList);
            }
            ind ++;
        }
        FeeDto feeDto = new FeeDto();
        feeDto.setRepostList(reportFeeDtoLists);
        feeDto.setYearArr(arr);
        feeDto.setLength(String.valueOf(doYear+12+1+5+4));
        ResultVo resultVo = new ResultVo(reportFeeDtoLists);
        ResultVo resultVo = new ResultVo(feeDto);
        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);