liusheng
16 小时以前 3326b8c5a5b9a2133729e4cce8298cb549995f45
ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceFunddetailServiceImpl.java
@@ -1,6 +1,7 @@
package com.ruoyi.project.service.impl;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
@@ -276,6 +277,11 @@
        if (CollectionUtils.isEmpty(serviceFunddetails)) {
            throw new BaseException("算税条件为空,请检查后,再进行计算");
        }
        // 用于临时保存已经算好的"费用详情数据"
        List<ServiceFunddetail> temporarySave = new ArrayList<>();
        // 用于记录序号
        Map<String, Long> xhMap = new HashMap<>();
        // 先对serviceFunddetails排序
        Comparator<ServiceFunddetail> customComparator = Comparator.comparing(obj -> {
            if (ObjectUtils.isEmpty(obj.getTaxTime())) {
@@ -291,13 +297,13 @@
        log.info("算税的fundid的值为:{}", fundid);
        ServiceFund serviceFund1 = serviceFundMapper.selectById(fundid);
        log.info("fund表的fundtextime值为:{}", serviceFund1.getFundtaxtime());
//        //用于临时保存已经算好的"费用详情数据"
        List<ServiceFunddetail> temporarySave = new ArrayList<>();
        //保存总税前金额(用于更新fund表里的)
        BigDecimal pretaxcost = BigDecimal.valueOf(0.00);
        BigDecimal taxedcost = BigDecimal.valueOf(0.00);
        for (ServiceFunddetail serviceFunddetail : serviceFunddetails) {
            if (serviceFunddetail.getBeneficiaryname().equals("吴康松")) {
                System.out.println(serviceFunddetail);
            }
            if (StringUtils.isEmpty(serviceFunddetail.getIdcardno())) {
                logger.info("serviceFunddetail数据入参 : {}", serviceFunddetail);
                //如果身份证号为空,就不用查了,可能是医院的记录
@@ -324,9 +330,17 @@
            taxMoneyByItemEO.setFirstDay(firstDay);
            taxMoneyByItemEO.setIDCard(serviceFunddetail.getIdcardno());
            taxMoneyByItemEO.setTaxTime(new Date());
            //根据条件获取表中该条数据的”序号“最大值
            Long maxXH = serviceFunddetailMapper.getMaxXH(taxMoneyByItemEO);
            if (maxXH == null) {
                maxXH = 0L;
                maxXH = 1L;
            } else {
                maxXH = maxXH + 1;
            }
            //序号Map与数据库表里的xh同时不为空,那就以map里的为准
            if (ObjectUtils.isNotEmpty(xhMap)) {
                Long xhValue = xhMap.get(serviceFunddetail.getIdcardno());
                if (xhValue != null) maxXH = xhValue + 1;
            }
            TaxMoneyByItemEO taxMoneyVO = new TaxMoneyByItemEO();
@@ -336,14 +350,19 @@
                taxMoneyVO.setTaxTime(new Date());
            }
            taxMoneyVO.setFirstDay(firstDay);
            // 获取该身份证号在本月的所有记录
            taxMoneyVO.setFundID(serviceFunddetail.getFundid());
            taxMoneyVO.setIDCard(serviceFunddetail.getIdcardno());
            if (serviceFunddetail.getXh() != null) {
                taxMoneyVO.setXh(serviceFunddetail.getXh());
                serviceFunddetail.setXh(null);
                taxMoneyVO.setXh(maxXH);
                xhMap.put(serviceFunddetail.getIdcardno(), maxXH);
            } else {
                taxMoneyVO.setXh(maxXH + 1);
                taxMoneyVO.setXh(maxXH);
                xhMap.put(serviceFunddetail.getIdcardno(), maxXH);
            }
            //查出税前、税、税后的总额(不包含本次)
            logger.info("taxMoneyVO入参的值 : {}", taxMoneyVO);
            TaxMoneySumEO taxSum = serviceFunddetailMapper.getTaxSum(taxMoneyVO);
            logger.info("查询的taxSum的值 : {}", taxSum);
            if (ObjectUtils.isEmpty(taxSum)) {
@@ -365,11 +384,13 @@
                        taxSum.setTaxAmounts(taxAmounts.doubleValue());
                        taxSum.setTaxedAmounts(TaxedAmounts.doubleValue());
                    }
                    continue;
                }
            }
            //记录一下这个税前总额
            serviceFunddetail.setAllAmount(taxSum.getAmounts());
            if (serviceFunddetail.getXh() == null) {
                serviceFunddetail.setXh(maxXH + 1);
                serviceFunddetail.setXh(maxXH);
            }
            if (StringUtils.isEmpty(serviceFunddetail.getServicesscopename()) || !serviceFunddetail.getServicesscopename().contains("税后")) {