添加冲账功能并优化区间费用计算
- 在 PeriodCostResultVo 中添加 markTime 字段,用于冲账日期- 在 SltAgreementInfoMapper 中添加 selectPeriodCostListForCharge 方法,用于查询冲账记录- 更新 SltAgreementInfoMapper.xml,添加新的 SQL 查询语句 - 修改 SltAgreementInfoServiceImpl 中的查询逻辑,加入冲账数据处理 - 优化区间费用汇总功能,增加对未填写协议编号的校验
This commit is contained in:
parent
4ca2b3e091
commit
c3253543ce
|
|
@ -59,6 +59,9 @@ public class PeriodCostResultVo {
|
|||
@ApiModelProperty(value = "采购单价 原值")
|
||||
private BigDecimal buyPrice;
|
||||
|
||||
@ApiModelProperty(value = "冲账日期,必须区间计算开始日期与冲账日期一致才冲账")
|
||||
private Date markTime;
|
||||
|
||||
@ApiModelProperty(value = "计算开始时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date calcStartTime;
|
||||
|
|
|
|||
|
|
@ -281,4 +281,11 @@ public interface SltAgreementInfoMapper {
|
|||
* @return 区间费用计算结果列表
|
||||
*/
|
||||
List<PeriodCostResultVo> selectLeasePeriodCostList(PeriodCostQueryDto queryDto);
|
||||
|
||||
/**
|
||||
* 查询区间费用-- 冲账记录表
|
||||
* @param queryDto 查询条件
|
||||
* @return 冲账记录
|
||||
*/
|
||||
List<PeriodCostResultVo> selectPeriodCostListForCharge(PeriodCostQueryDto queryDto);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1148,11 +1148,20 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
|||
// 从数据库查询基础数据
|
||||
List<PeriodCostResultVo> rawResults = sltAgreementInfoMapper.selectLeasePeriodCostList(queryDto);
|
||||
|
||||
// 从数据库查询冲账数据,冲账查询的时候直接过滤了协议和限制具体日期,所以不需要再进行范围过滤
|
||||
List<PeriodCostResultVo> markResults = sltAgreementInfoMapper.selectPeriodCostListForCharge(queryDto);
|
||||
|
||||
// 先过滤掉不在查询范围内的数据
|
||||
List<PeriodCostResultVo> filteredResults = filterDataInRange(rawResults, queryDto.getStartDate(), queryDto.getEndDate());
|
||||
|
||||
// 进行时间及费用计算统计
|
||||
return calculatePeriodCosts(filteredResults, queryDto.getStartDate(), queryDto.getEndDate());
|
||||
List<PeriodCostResultVo> periodCostResultVos = calculatePeriodCosts(filteredResults, queryDto.getStartDate(), queryDto.getEndDate());
|
||||
|
||||
// 添加冲账数据
|
||||
periodCostResultVos.addAll(markResults);
|
||||
|
||||
// 返回结果
|
||||
return periodCostResultVos;
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("查询区间费用失败:" + e.getMessage());
|
||||
}
|
||||
|
|
@ -1447,6 +1456,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
|||
// 按协议ID分组汇总
|
||||
return aggregateByAgreement(detailList, queryDto.getStartDate(), queryDto.getEndDate());
|
||||
} catch (Exception e) {
|
||||
System.err.println(e);
|
||||
throw new ServiceException("查询区间费用汇总失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
@ -1546,6 +1556,13 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
|||
summaryList.add(summary);
|
||||
}
|
||||
|
||||
if (!summaryList.isEmpty()) {
|
||||
List<PeriodCostSummaryVo> collect = summaryList.stream().filter(item -> Objects.isNull(item.getAgreementCode())).collect(Collectors.toList());
|
||||
if (!collect.isEmpty()) {
|
||||
throw new ServiceException("存在未填写协议编号的协议");
|
||||
}
|
||||
}
|
||||
|
||||
// 按协议编号排序
|
||||
summaryList.sort(Comparator.comparing(PeriodCostSummaryVo::getAgreementCode));
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="remark" column="remark"/>
|
||||
<result property="comsumable" column="comsumable"/>
|
||||
<result property="buyPrice" column="buy_price"/>
|
||||
<result property="leaseDays" column="lease_day"/>
|
||||
<result property="markTime" column="mark_time"/>
|
||||
<result property="leaseCost" column="lease_cost"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSltAgreementInfoVo">
|
||||
|
|
@ -1241,4 +1244,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</if>
|
||||
ORDER BY bai.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectPeriodCostListForCharge" parameterType="com.bonus.material.settlement.domain.dto.PeriodCostQueryDto" resultMap="PeriodCostResultMap">
|
||||
select
|
||||
ptc.agreement_id, bai.agreement_code, ptc.type_id, ptc.lease_num as num, ptc.start_time, ptc.end_time, ptc.day as lease_day,
|
||||
ptc.price, ptc.lease_money as lease_cost, ptc.cost_type, ptc.mark_time, mt.type_name as model_name, mt1.type_name as type_name
|
||||
from project_temp_cost ptc
|
||||
inner join bm_agreement_info bai on ptc.agreement_id = bai.agreement_id
|
||||
LEFT JOIN ma_type mt ON ptc.type_id = mt.type_id AND mt.`level` = '4'
|
||||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id AND mt1.`level` = '3'
|
||||
where ptc.mark_time = #{startDate}
|
||||
<if test="agreementId != null">
|
||||
and ptc.agreement_id = #{agreementId}
|
||||
</if>
|
||||
<if test="agreementCode != null">
|
||||
and bai.agreement_code = #{agreementCode}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue