修改因算税时间一税,导致获取历史数据不准的问题(加上xh字段)
个税汇总里的功能,删除时一个fund时,将相应的fund的“算税时间” 和"funddetail"表里的“算税时间”、“序号”置空
已修改9个文件
110 ■■■■ 文件已修改
ruoyi-project/src/main/java/com/ruoyi/project/domain/ServiceFunddetail.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-project/src/main/java/com/ruoyi/project/domain/ServiceFunddetailVO.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-project/src/main/java/com/ruoyi/project/domain/vo/TaxMoneyByItemEO.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-project/src/main/java/com/ruoyi/project/mapper/ServiceFunddetailMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceFundServiceImpl.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceFunddetailServiceImpl.java 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceFundtaxServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-project/src/main/resources/mapper/project/ServiceFundMapper.xml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-project/src/main/resources/mapper/project/ServiceFunddetailMapper.xml 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-project/src/main/java/com/ruoyi/project/domain/ServiceFunddetail.java
@@ -216,7 +216,9 @@
    @Excel(name = "发票张数")
    private Long invoicecount;
    /** $column.columnComment */
    /**
     * $column.columnComment
     */
    @ApiModelProperty("$column.columnComment")
    @Excel(name = "上传时间")
    private BigDecimal reimbursementamount;
@@ -337,14 +339,16 @@
     * 附件文件地址
     */
    @ApiModelProperty("附件文件地址")
    @TableField(value = "annexfiles",updateStrategy = FieldStrategy.IGNORED)
    @TableField(value = "annexfiles", updateStrategy = FieldStrategy.IGNORED)
    private String annexfiles;
    /**
     * 附件文件地址
     */
    /** 发票附件 */
    @TableField(value = "invoicefiles",updateStrategy =FieldStrategy.IGNORED)
    /**
     * 发票附件
     */
    @TableField(value = "invoicefiles", updateStrategy = FieldStrategy.IGNORED)
    @ApiModelProperty("发票附件")
    @Excel(name = "发票附件")
    private String invoicefiles;
@@ -382,5 +386,11 @@
    @ApiModelProperty("部门名称")
    private String deptName;
    /**
     * 序号
     */
    @ApiModelProperty("序号")
    private Long xh;
}
ruoyi-project/src/main/java/com/ruoyi/project/domain/ServiceFunddetailVO.java
@@ -288,6 +288,12 @@
    private String servicesscope;
    /**
     * 序号
     */
    @ApiModelProperty("序号")
    private Long xh;
    /**
     * 服务范围名称
     */
    @ApiModelProperty("服务范围名称")
ruoyi-project/src/main/java/com/ruoyi/project/domain/vo/TaxMoneyByItemEO.java
@@ -42,4 +42,9 @@
     */
    private Long fundID;
    /**
     * 序号
     */
    private Long xh;
}
ruoyi-project/src/main/java/com/ruoyi/project/mapper/ServiceFunddetailMapper.java
@@ -55,6 +55,8 @@
    TaxMoneySumEO getTaxSum(TaxMoneyByItemEO taxMoneyByItemEO);
    Long getMaxXH(TaxMoneyByItemEO taxMoneyByItemEO);
    List<ServiceFunddetail> totlaTax(List<Long> fundids);
}
ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceFundServiceImpl.java
@@ -708,7 +708,7 @@
    @Override
    public List<SpFinancialExpensesFundOut> getExpertfeeList(SpSelectExpertfee spSelectExpertfee) {
        log.info("spSelectExpertfee的入参为:{}",spSelectExpertfee);
        log.info("spSelectExpertfee的入参为:{}", spSelectExpertfee);
        return serviceFundMapper.getExpertfeeList(spSelectExpertfee.getPaApplyType(), spSelectExpertfee.getPfundtaxid(), spSelectExpertfee.getDonorname(), spSelectExpertfee.getPadepartid(), spSelectExpertfee.getPausername());
    }
@@ -1190,6 +1190,14 @@
    @Transactional(rollbackFor = Exception.class)
    public Boolean updateFundTaxIdById(Long id, Long fundTaxId) {
        return serviceFundMapper.updateFundTaxIdById(id, fundTaxId);
        //将fund里的算税时间,与详情里的版税时间全清空
        Boolean aBoolean = serviceFundMapper.updateFundTaxIdById(id, fundTaxId);
        ServiceFunddetail serviceFunddetail = new ServiceFunddetail();
        serviceFunddetail.setFundid(id);
        serviceFunddetail.setTaxTime(null);
        serviceFunddetail.setXh(null);
        boolean b = serviceFunddetailMapper.updateTaxTime(serviceFunddetail);
        return b;
    }
}
ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceFunddetailServiceImpl.java
@@ -276,13 +276,23 @@
        if (CollectionUtils.isEmpty(serviceFunddetails)) {
            throw new BaseException("算税条件为空,请检查后,再进行计算");
        }
        // 先对serviceFunddetails排序
        Comparator<ServiceFunddetail> customComparator = Comparator.comparing(obj -> {
            if (ObjectUtils.isEmpty(obj.getTaxTime())) {
                return 1; // 返回1表示字段为空的对象排在后面
            } else {
                return 0; // 返回0表示字段不为空的对象保持原顺序
            }
        });
        Collections.sort(serviceFunddetails, customComparator);
        //这个是为了获取fund_tax_time
        Long fundid = serviceFunddetails.get(0).getFundid();
        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);
@@ -309,8 +319,16 @@
            //获取当月的第一天
            Date firstDay = Date.from(LocalDate.now().with(TemporalAdjusters.firstDayOfMonth()).atStartOfDay(ZoneId.systemDefault()).toInstant());
//            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//            String firstDatStr = dateFormat.format(firstDay);
            //获取到当前人的本月算税序号最大值
            TaxMoneyByItemEO taxMoneyByItemEO = new TaxMoneyByItemEO();
            taxMoneyByItemEO.setFirstDay(firstDay);
            taxMoneyByItemEO.setIDCard(serviceFunddetail.getIdcardno());
            taxMoneyByItemEO.setTaxTime(new Date());
            Long maxXH = serviceFunddetailMapper.getMaxXH(taxMoneyByItemEO);
            if (maxXH == null) {
                maxXH = 0L;
            }
            TaxMoneyByItemEO taxMoneyVO = new TaxMoneyByItemEO();
            if (serviceFund1.getFundtaxtime() != null) {
                taxMoneyVO.setTaxTime(serviceFund1.getFundtaxtime());
@@ -320,6 +338,11 @@
            taxMoneyVO.setFirstDay(firstDay);
            taxMoneyVO.setFundID(serviceFunddetail.getFundid());
            taxMoneyVO.setIDCard(serviceFunddetail.getIdcardno());
            if (serviceFunddetail.getXh() != null) {
                taxMoneyVO.setXh(serviceFunddetail.getXh());
            } else {
                taxMoneyVO.setXh(maxXH + 1);
            }
            //查出税前、税、税后的总额(不包含本次)
            TaxMoneySumEO taxSum = serviceFunddetailMapper.getTaxSum(taxMoneyVO);
            logger.info("查询的taxSum的值 : {}", taxSum);
@@ -344,6 +367,9 @@
                    }
                    continue;
                }
            }
            if (serviceFunddetail.getXh() == null) {
                serviceFunddetail.setXh(maxXH + 1);
            }
            if (StringUtils.isEmpty(serviceFunddetail.getServicesscopename()) || !serviceFunddetail.getServicesscopename().contains("税后")) {
@@ -373,10 +399,11 @@
                logger.info("打印税前serviceFunddetail3数据 :{}", serviceFunddetail3);
                // 将该条数据更新
                boolean b = this.updateById(serviceFunddetail3);
                pretaxcost = pretaxcost.add(BigDecimal.valueOf(serviceFunddetail.getAmount()));
                taxedcost = taxedcost.add(BigDecimal.valueOf(serviceFunddetail.getTaxedamount()));
                // 把该数据,放到临时的集合中
//                // 把该数据,放到临时的集合中
                temporarySave.add(serviceFunddetail3);
            } else if (serviceFunddetail.getServicesscopename().contains("税后")) {
                logger.info("计算税后信息开始:{}", serviceFunddetail);
@@ -403,11 +430,16 @@
                    serviceFunddetail3.setTaxTime(serviceFund1.getFundtaxtime());
                }
                logger.info("打印serviceFunddetail3:{}", serviceFunddetail3);
                //获取到当前人的本月算税序号最大值
                TaxMoneyByItemEO byItemEO = new TaxMoneyByItemEO();
                byItemEO.setFirstDay(firstDay);
                byItemEO.setIDCard(serviceFunddetail.getIdcardno());
                byItemEO.setTaxTime(new Date());
                // 将该条数据更新
                updateById(serviceFunddetail3);
                pretaxcost = pretaxcost.add(BigDecimal.valueOf(serviceFunddetail3.getAmount()));
                taxedcost = taxedcost.add(BigDecimal.valueOf(serviceFunddetail3.getTaxedamount()));
                // 把该数据,放到临时的集合中
//                // 把该数据,放到临时的集合中
                temporarySave.add(serviceFunddetail3);
            }
        }
ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceFundtaxServiceImpl.java
@@ -14,6 +14,7 @@
import com.ruoyi.project.service.IServiceFundService;
import com.ruoyi.project.service.IServiceFunddetailService;
import com.ruoyi.project.service.IServiceFundtaxService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -26,6 +27,7 @@
 * @author ruoyi
 * @date 2024-03-13
 */
@Slf4j
@Service
public class ServiceFundtaxServiceImpl extends ServiceImpl<ServiceFundtaxMapper, ServiceFundtax> implements IServiceFundtaxService {
@@ -158,11 +160,13 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean batchFundTax(FundTaxVO fundTaxVO) {
        log.info("批量算税的fundTaxVO入参为:{}", fundTaxVO);
        if (fundTaxVO.getFundTaxId() == null) {
            throw new BaseException("分批算税出问题了,请检查后再进行计算");
        }
        if (fundTaxVO.getAddOrupdate() == 1) {
            Integer maxFundTaxId = serviceFundtaxMapper.getMaxFundTaxId();
            log.info("批量算税的maxFundTaxId为:{}", maxFundTaxId);
            if (fundTaxVO.getFundTaxId() != maxFundTaxId.longValue()) {
                throw new BaseException("该批数据不能算税");
            }
ruoyi-project/src/main/resources/mapper/project/ServiceFundMapper.xml
@@ -277,7 +277,8 @@
    <update id="updateFundTaxIdById">
        update service_fund
        <set>
            fund_tax_id = #{fundTaxId}
            fund_tax_id = #{fundTaxId},
            fundtaxtime = null
        </set>
        where id = #{id}
    </update>
ruoyi-project/src/main/resources/mapper/project/ServiceFunddetailMapper.xml
@@ -64,11 +64,13 @@
        <result property="invoicefiles" column="InvoiceFiles"/>
        <result property="deptId" column="dept_id"/>
        <result property="deptName" column="dept_name"/>
        <result property="xh" column="xh"/>
    </resultMap>
    <sql id="selectServiceFunddetailVo">
        select ID,
               fundID,
               xh,
               InfoId,
               DonorNo,
               dept_id,
@@ -265,6 +267,7 @@
        update com.ruoyi.project.domain.
        <set>
            tax_time = #{taxTime},
            xh = #{xh}
        </set>
        where fundID = #{fundid}
    </update>
@@ -275,7 +278,8 @@
        FROM service_funddetail a,
             service_fund b
        where a.FundID = b.id
          and a.tax_time &lt; #{taxTime}
          and a.tax_time &lt;= #{taxTime}
          and a.xh &lt; #{xh}
          and a.tax_time >= #{firstDay}
          and TRIM(a.IDCardNo) = #{IDCard}
          and a.del_flag != 1
@@ -286,6 +290,16 @@
          and b.del_flag != 1
          and b.ApplyType in (1
            , 2)
    </select>
    <select id="getMaxXH" parameterType="com.ruoyi.project.domain.vo.TaxMoneyByItemEO"
            resultType="Long">
        SELECT max(xh)
        FROM service_funddetail
        where tax_time &lt;= #{taxTime}
          and tax_time >= #{firstDay}
          and TRIM(IDCardNo) = #{IDCard}
          and del_flag != 1
    </select>
    <select id="totlaTax" resultType="com.ruoyi.project.domain.ServiceFunddetail">
@@ -303,4 +317,4 @@
        call `SP_STAT_BONUS`(#{PABEGTIME,mode=IN,jdbcType=VARCHAR},#{PAENDTIME,mode=IN,jdbcType=VARCHAR},#{PADEPTNO,mode=IN,jdbcType=VARCHAR},#{PAUSERNO,mode=IN,jdbcType=VARCHAR},#{PABONUSTYPE,mode=IN,jdbcType=VARCHAR})
    </select>
</mapper>
</mapper>