结算功能完善

This commit is contained in:
liang.chao 2024-08-09 10:59:52 +08:00
parent 1add2b914b
commit 7506398006
4 changed files with 51 additions and 23 deletions

View File

@ -4,6 +4,7 @@ import org.apache.commons.lang3.time.DateUtils;
import java.text.*;
import java.time.LocalDate;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;
@ -795,6 +796,19 @@ public class DateTimeHelper {
return lastDayOfMonth;
}
// 获取上个月的年月
public static String getLastMonthYearMonth() {
// 获取当前时间的年月
YearMonth now = YearMonth.now();
// 减去一个月
YearMonth lastMonth = now.minusMonths(1);
// 将YearMonth对象格式化为字符串
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
return lastMonth.format(formatter);
}
public static void main(String[] args) {
System.err.println(getTimeAfterThirtyDay());
System.err.println(getNowTime());

View File

@ -13,7 +13,7 @@ public class Inform {
@Autowired
private CalcMonthlyService calcfourCostService;
private final int CAL_DAY = 6;
private final int CAL_DAY = 9;
// @Scheduled(cron = "0 */1 * * * ? ") // 间隔5分钟执行
// @Scheduled(cron = "0 0 1 22 * ? ") // 每个月22日凌晨1点执行

View File

@ -225,7 +225,9 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
// 应结算金额
BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays);
bean.setCosts(String.valueOf(costs));
//实际结算天数
bean.setRealDays(realDays);
// 实际结算金额
bean.setRealCosts(String.valueOf(realCosts));
}
return leaseList;
@ -414,12 +416,12 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
Integer num = 0;
//租赁费用列表
for (AgreementInfo agreementInfo : list) {
// 如果不选择具体日期或者选择了最新月份则需要查数据
if (agreementInfo.getStartTime() == null || DateTimeHelper.getNowMonth().equals(DateTimeHelper.getNowMonth(DateTimeHelper.parse(agreementInfo.getEndTime(), "yyyy-MM")))) {
// 如果选择了最新月份则需要查数据
if (agreementInfo.getStartTime() != null && agreementInfo.getEndTime() != null && DateTimeHelper.getNowMonth().equals(DateTimeHelper.getNowMonth(DateTimeHelper.parse(agreementInfo.getEndTime(), "yyyy-MM")))) {
List<SltAgreementInfo> listMonth = getLeaseListMonth(agreementInfo, num);
leaseListMonth.addAll(listMonth);
} else {
// 查定时任务记录的数据
// 如果不传日期或传以往日期 查定时任务记录的数据
List<SltAgreementInfo> listMonth = getLeaseJobListMonth(agreementInfo);
leaseListMonth.addAll(listMonth);
}
@ -428,6 +430,10 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
}
private List<SltAgreementInfo> getLeaseJobListMonth(AgreementInfo agreementInfo) {
if (StringUtils.isBlank(agreementInfo.getEndTime())) {
String lastMonthYearMonth = DateTimeHelper.getLastMonthYearMonth();
agreementInfo.setEndTime(lastMonthYearMonth);
}
List<SltAgreementInfo> monthCosts = calMonthlyMapper.getMonthCosts(agreementInfo);
int num = 0;
for (SltAgreementInfo monthCost : monthCosts) {
@ -446,7 +452,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
private List<SltAgreementInfo> getLeaseListMonth(AgreementInfo bean, Integer num) {
List<SltAgreementInfo> leaseList = new ArrayList<>();
// for (AgreementInfo bean : list) {
if (StringUtils.isNotBlank(bean.getStartTime()) && StringUtils.isNotBlank(bean.getEndTime())) {
// if (StringUtils.isNotBlank(bean.getStartTime()) && StringUtils.isNotBlank(bean.getEndTime())) {
List<SltAgreementInfo> monthList = sltAgreementInfoMapper.getLeaseListMonthNotNull(bean);
for (SltAgreementInfo sltAgreementInfo : monthList) {
AgreementInfo agreementInfo = new AgreementInfo();
@ -461,7 +467,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
sltAgreementInfo.setNode(leaseListOneMonth);
}
leaseList.addAll(monthList);
} else {
/* } else {
List<SltAgreementInfo> oneOfList = sltAgreementInfoMapper.getLeaseListMonth(bean);
for (SltAgreementInfo sltAgreementInfo : oneOfList) {
AgreementInfo agreementInfo = new AgreementInfo();
@ -475,7 +481,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
sltAgreementInfo.setNode(leaseListOneMonth);
}
leaseList.addAll(oneOfList);
}
}*/
// }
return leaseList;
}
@ -565,7 +571,9 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
// 应结算金额
BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays);
bean.setCosts(String.valueOf(costs));
//实际结算天数
bean.setRealDays(realDays);
// 实际结算金额
bean.setRealCosts(String.valueOf(realCosts));
}
return leaseList;

View File

@ -40,8 +40,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN bm_agreement_info bai ON pmc.agreement_id = bai.agreement_id
LEFT JOIN bm_project_lot bp ON bp.lot_id = bai.project_id
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
WHERE
spm.month = DATE_FORMAT(#{endTime}, '%Y-%m')
WHERE 1=1
<if test="endTime != null and endTime != ''">
and spm.month = DATE_FORMAT(#{endTime}, '%Y-%m')
</if>
AND pmc.agreement_id = #{agreementId}
<if test="costBearingParty != null and costBearingParty != ''">
and pmc.cost_bearing_party = #{costBearingParty}
</if>
</select>
<select id="getMonthDetails" resultType="com.bonus.sgzb.base.api.domain.SltAgreementInfo">
SELECT