Merge branch 'master' of http://14.103.246.124:16000/bonus/Bonus-Cloud-Material
This commit is contained in:
commit
6510eda512
|
|
@ -108,7 +108,7 @@ public class IwsCostPushServiceImpl implements IwsCostPushService {
|
|||
costDto.setMonth(month);
|
||||
|
||||
// 清除旧的费用计算数据
|
||||
// cleanSameMonthOldRecords(record);
|
||||
//cleanSameMonthOldRecords(record);
|
||||
|
||||
// 插入新的当前月份,并生成记录id
|
||||
iwsCostPushMapper.insertCalcMonthRecord(costDto);
|
||||
|
|
@ -195,11 +195,13 @@ public class IwsCostPushServiceImpl implements IwsCostPushService {
|
|||
// 获取已结算协议 ---- (工器具)本月租赁的区间费用明细
|
||||
settlementEquipmentCostsDetails = sltAgreementInfoService.selectPeriodCostList(new PeriodCostQueryDto()
|
||||
.setAgreementIds(settlementAgreementList.stream().map(IwsCostPushBean::getAgreementId).collect(Collectors.toList()))
|
||||
.setSettlementStatus("2")
|
||||
.setStartDate(firstDate).setEndDate(lastDate)
|
||||
.setSltManageType((byte) 1)
|
||||
);
|
||||
// 把区间计算的租赁费用覆盖已结算的用作展示
|
||||
for (SltAgreementInfo item : settlementEquipmentCosts) {
|
||||
item.setLeaseCost(BigDecimal.ZERO);
|
||||
Long agreementId = item.getAgreementId();
|
||||
List<PeriodCostResultVo> filterArray = settlementEquipmentCostsDetails.stream().filter(obj -> obj.getAgreementId().equals(agreementId)).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(filterArray)) {
|
||||
|
|
@ -224,12 +226,14 @@ public class IwsCostPushServiceImpl implements IwsCostPushService {
|
|||
// 获取已结算协议 ---- (安全工器具)的本月租赁区间费用明细
|
||||
settlementSafetyEquipmentCostsDetails = sltAgreementInfoService.selectPeriodCostList(new PeriodCostQueryDto()
|
||||
.setAgreementIds(safetySettlementAgreementList.stream().map(IwsCostPushBean::getAgreementId).collect(Collectors.toList()))
|
||||
.setSettlementStatus("2")
|
||||
.setStartDate(firstDate)
|
||||
.setEndDate(lastDate)
|
||||
.setSltManageType((byte) 2)
|
||||
);
|
||||
// 把区间计算的租赁费用覆盖已结算的用作展示
|
||||
for (SltAgreementInfo item : settlementSafetyEquipmentCosts) {
|
||||
item.setLeaseCost(BigDecimal.ZERO);
|
||||
Long agreementId = item.getAgreementId();
|
||||
List<PeriodCostResultVo> filterArray = settlementSafetyEquipmentCostsDetails.stream().filter(obj -> obj.getAgreementId().equals(agreementId)).collect(Collectors.toList());
|
||||
filterArray.removeIf(Objects::isNull);
|
||||
|
|
|
|||
|
|
@ -282,6 +282,11 @@ public interface SltAgreementInfoMapper {
|
|||
*/
|
||||
List<PeriodCostResultVo> selectLeasePeriodCostList(PeriodCostQueryDto queryDto);
|
||||
|
||||
/**
|
||||
* 查询区间费用计算结果 -- 已结算明细 -- 只查询租赁费用
|
||||
*/
|
||||
List<PeriodCostResultVo> selectLeasePeriodCostListBySltDetails(PeriodCostQueryDto queryDto);
|
||||
|
||||
/**
|
||||
* 查询区间费用-- 冲账记录表
|
||||
* @param queryDto 查询条件
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import com.bonus.material.settlement.domain.vo.SltInfoVo;
|
|||
import com.bonus.material.settlement.mapper.SltAgreementReduceMapper;
|
||||
import com.bonus.material.task.domain.TmTask;
|
||||
import com.bonus.material.task.mapper.TmTaskMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -54,6 +55,7 @@ import java.util.Objects;
|
|||
* @author xsheng
|
||||
* @date 2024-10-16
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
||||
|
||||
|
|
@ -1155,8 +1157,14 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
|||
queryDto.setSltManageType(settlementType);
|
||||
}
|
||||
|
||||
// 从数据库查询【基础数据】
|
||||
List<PeriodCostResultVo> rawResults = sltAgreementInfoMapper.selectLeasePeriodCostList(queryDto);
|
||||
List<PeriodCostResultVo> rawResults;
|
||||
if (StringUtils.isNotBlank(queryDto.getSettlementStatus()) && queryDto.getSettlementStatus().equals("2")) {
|
||||
// 从数据库slt_agreement_details表查询【已结算明细】
|
||||
rawResults = sltAgreementInfoMapper.selectLeasePeriodCostListBySltDetails(queryDto);
|
||||
} else {
|
||||
// 从数据库slt_agreement_info表查询【基础数据】
|
||||
rawResults = sltAgreementInfoMapper.selectLeasePeriodCostList(queryDto);
|
||||
}
|
||||
|
||||
// 从数据库查询【冲账数据】,冲账查询的时候直接过滤了协议和限制具体日期,所以不需要再进行范围过滤
|
||||
List<PeriodCostResultVo> markResults = sltAgreementInfoMapper.selectPeriodCostListForCharge(queryDto);
|
||||
|
|
@ -1173,6 +1181,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
|||
// 返回结果
|
||||
return periodCostResultVos;
|
||||
} catch (Exception e) {
|
||||
log.error("查询区间费用失败:", e);
|
||||
throw new ServiceException("查询区间费用失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
@ -1313,22 +1322,16 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
|||
// 计算租赁天数
|
||||
long leaseDays = calculateDaysBetween(calcStartTime, calcEndTime);
|
||||
|
||||
|
||||
// 计算租赁费用
|
||||
BigDecimal leaseCost = BigDecimal.ZERO;
|
||||
if (result.getComsumable() != null && result.getComsumable() == 1) {
|
||||
Date startTime =result.getStartTime();
|
||||
long startDays = calculateDaysBetween(startTime, calcEndTime);
|
||||
|
||||
if (result.getNum() == null) {
|
||||
result.setNum(BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
if(startDays >0) {
|
||||
if (isDateInRange(result.getStartTime(), inputStartDate, inputEndDate)) {
|
||||
// 消耗性物资直接计算购置价
|
||||
result.setConsumeCost(result.getNum().multiply(Optional.ofNullable(result.getBuyPrice()).orElse(BigDecimal.ZERO)));
|
||||
}
|
||||
|
||||
}
|
||||
if (result.getNum() != null && result.getLeasePrice() != null && leaseDays >= 1) {
|
||||
// 非消耗性物资按照租赁单价计算租赁费用
|
||||
|
|
|
|||
|
|
@ -1130,7 +1130,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
mt.type_name as model_name, mt.buy_price,
|
||||
mt1.type_name as type_name,
|
||||
sai.ma_id, sai.num, sai.lease_price, sai.start_time, sai.end_time,
|
||||
bai.is_slt AS is_settled,
|
||||
sai.is_slt AS is_settled,
|
||||
sai.slt_time AS settlement_time, sai.status,
|
||||
mt.unit_name as mt_unit_name, mt.comsumable,
|
||||
bai.remark
|
||||
|
|
@ -1271,4 +1271,75 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
and bai.agreement_code = #{agreementCode}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectLeasePeriodCostListBySltDetails" resultMap="PeriodCostResultMap">
|
||||
SELECT
|
||||
bai.agreement_id, bai.agreement_code, bai.unit_id,
|
||||
bu.unit_name,
|
||||
bai.project_id,
|
||||
bp.pro_name as project_name,
|
||||
sai.type_id,
|
||||
mt.type_name as model_name, mt.buy_price,
|
||||
mt1.type_name as type_name,
|
||||
sai.ma_id, sai.num, sai.price as lease_price, sai.start_time, sai.end_time,
|
||||
mt.unit_name as mt_unit_name, mt.comsumable,
|
||||
bai.remark
|
||||
FROM bm_agreement_info bai
|
||||
INNER JOIN slt_agreement_details sai ON bai.agreement_id = sai.apply_id
|
||||
LEFT JOIN bm_unit bu ON bai.unit_id = bu.unit_id
|
||||
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
|
||||
LEFT JOIN ma_type mt ON sai.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>
|
||||
bai.status = '1'
|
||||
AND mt.jiju_type = #{sltManageType}
|
||||
AND sai.slt_type = '1'
|
||||
<if test="agreementCode != null and agreementCode != ''">
|
||||
AND bai.agreement_code LIKE concat('%',#{agreementCode},'%')
|
||||
</if>
|
||||
<if test="agreementId != null and agreementId > 0">
|
||||
AND bai.agreement_id = #{agreementId}
|
||||
</if>
|
||||
<if test="agreementIds != null and agreementIds.size() > 0">
|
||||
AND bai.agreement_id IN
|
||||
<foreach collection="agreementIds" item="agreementId" open="(" separator="," close=")">
|
||||
#{agreementId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="typeIds != null and typeIds.size() > 0">
|
||||
AND sai.type_id IN
|
||||
<foreach collection="typeIds" item="typeId" open="(" separator="," close=")">
|
||||
#{typeId}
|
||||
</foreach>
|
||||
</if>
|
||||
<!-- 数据库层面的时间范围过滤 - 修正跨区间租赁逻辑 -->
|
||||
AND (
|
||||
<!-- 已结算协议:租赁期间与查询区间有交集 -->
|
||||
(bai.is_slt = 1 AND (
|
||||
<!-- 情况1:领料时间在查询区间内 -->
|
||||
(sai.start_time IS NOT NULL AND DATE(sai.start_time) >= #{startDate} AND DATE(sai.start_time) <= #{endDate})
|
||||
OR
|
||||
<!-- 情况2:退料时间在查询区间内 -->
|
||||
(sai.end_time IS NOT NULL AND DATE(sai.end_time) >= #{startDate} AND DATE(sai.end_time) <= #{endDate})
|
||||
OR
|
||||
<!-- 情况4:跨区间租赁(领料在区间前,退料/结算在区间后) -->
|
||||
(sai.start_time IS NOT NULL AND DATE(sai.start_time) < #{startDate} AND
|
||||
((sai.end_time IS NOT NULL AND DATE(sai.end_time) > #{endDate}) ))
|
||||
))
|
||||
OR
|
||||
<!-- 未结算协议:租赁期间与查询区间有交集 -->
|
||||
((bai.is_slt = 0 OR bai.is_slt IS NULL) AND (
|
||||
<!-- 情况1:领料时间在查询区间内 -->
|
||||
(sai.start_time IS NOT NULL AND DATE(sai.start_time) >= #{startDate} AND DATE(sai.start_time) <= #{endDate})
|
||||
OR
|
||||
<!-- 情况2:退料时间在查询区间内 -->
|
||||
(sai.end_time IS NOT NULL AND DATE(sai.end_time) >= #{startDate} AND DATE(sai.end_time) <= #{endDate})
|
||||
OR
|
||||
<!-- 情况3:跨区间租赁(领料在区间前,退料在区间后或未退料) -->
|
||||
(sai.start_time IS NOT NULL AND DATE(sai.start_time) < #{startDate} AND (sai.end_time IS NULL OR DATE(sai.end_time) > #{endDate}))
|
||||
))
|
||||
)
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue