结算功能完善
This commit is contained in:
parent
1add2b914b
commit
7506398006
|
|
@ -4,6 +4,7 @@ import org.apache.commons.lang3.time.DateUtils;
|
||||||
|
|
||||||
import java.text.*;
|
import java.text.*;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.YearMonth;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.time.temporal.TemporalAdjusters;
|
import java.time.temporal.TemporalAdjusters;
|
||||||
|
|
@ -795,6 +796,19 @@ public class DateTimeHelper {
|
||||||
return lastDayOfMonth;
|
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) {
|
public static void main(String[] args) {
|
||||||
System.err.println(getTimeAfterThirtyDay());
|
System.err.println(getTimeAfterThirtyDay());
|
||||||
System.err.println(getNowTime());
|
System.err.println(getNowTime());
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ public class Inform {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CalcMonthlyService calcfourCostService;
|
private CalcMonthlyService calcfourCostService;
|
||||||
|
|
||||||
private final int CAL_DAY = 6;
|
private final int CAL_DAY = 9;
|
||||||
|
|
||||||
// @Scheduled(cron = "0 */1 * * * ? ") // 间隔5分钟执行
|
// @Scheduled(cron = "0 */1 * * * ? ") // 间隔5分钟执行
|
||||||
// @Scheduled(cron = "0 0 1 22 * ? ") // 每个月22日凌晨1点执行
|
// @Scheduled(cron = "0 0 1 22 * ? ") // 每个月22日凌晨1点执行
|
||||||
|
|
|
||||||
|
|
@ -225,7 +225,9 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
|
||||||
// 应结算金额
|
// 应结算金额
|
||||||
BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays);
|
BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays);
|
||||||
bean.setCosts(String.valueOf(costs));
|
bean.setCosts(String.valueOf(costs));
|
||||||
|
//实际结算天数
|
||||||
bean.setRealDays(realDays);
|
bean.setRealDays(realDays);
|
||||||
|
// 实际结算金额
|
||||||
bean.setRealCosts(String.valueOf(realCosts));
|
bean.setRealCosts(String.valueOf(realCosts));
|
||||||
}
|
}
|
||||||
return leaseList;
|
return leaseList;
|
||||||
|
|
@ -414,12 +416,12 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
|
||||||
Integer num = 0;
|
Integer num = 0;
|
||||||
//租赁费用列表
|
//租赁费用列表
|
||||||
for (AgreementInfo agreementInfo : list) {
|
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);
|
List<SltAgreementInfo> listMonth = getLeaseListMonth(agreementInfo, num);
|
||||||
leaseListMonth.addAll(listMonth);
|
leaseListMonth.addAll(listMonth);
|
||||||
} else {
|
} else {
|
||||||
// 查定时任务记录的数据
|
// 如果不传日期或传以往日期 则查定时任务记录的数据
|
||||||
List<SltAgreementInfo> listMonth = getLeaseJobListMonth(agreementInfo);
|
List<SltAgreementInfo> listMonth = getLeaseJobListMonth(agreementInfo);
|
||||||
leaseListMonth.addAll(listMonth);
|
leaseListMonth.addAll(listMonth);
|
||||||
}
|
}
|
||||||
|
|
@ -428,6 +430,10 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<SltAgreementInfo> getLeaseJobListMonth(AgreementInfo agreementInfo) {
|
private List<SltAgreementInfo> getLeaseJobListMonth(AgreementInfo agreementInfo) {
|
||||||
|
if (StringUtils.isBlank(agreementInfo.getEndTime())) {
|
||||||
|
String lastMonthYearMonth = DateTimeHelper.getLastMonthYearMonth();
|
||||||
|
agreementInfo.setEndTime(lastMonthYearMonth);
|
||||||
|
}
|
||||||
List<SltAgreementInfo> monthCosts = calMonthlyMapper.getMonthCosts(agreementInfo);
|
List<SltAgreementInfo> monthCosts = calMonthlyMapper.getMonthCosts(agreementInfo);
|
||||||
int num = 0;
|
int num = 0;
|
||||||
for (SltAgreementInfo monthCost : monthCosts) {
|
for (SltAgreementInfo monthCost : monthCosts) {
|
||||||
|
|
@ -446,22 +452,22 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
|
||||||
private List<SltAgreementInfo> getLeaseListMonth(AgreementInfo bean, Integer num) {
|
private List<SltAgreementInfo> getLeaseListMonth(AgreementInfo bean, Integer num) {
|
||||||
List<SltAgreementInfo> leaseList = new ArrayList<>();
|
List<SltAgreementInfo> leaseList = new ArrayList<>();
|
||||||
// for (AgreementInfo bean : list) {
|
// 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);
|
List<SltAgreementInfo> monthList = sltAgreementInfoMapper.getLeaseListMonthNotNull(bean);
|
||||||
for (SltAgreementInfo sltAgreementInfo : monthList) {
|
for (SltAgreementInfo sltAgreementInfo : monthList) {
|
||||||
AgreementInfo agreementInfo = new AgreementInfo();
|
AgreementInfo agreementInfo = new AgreementInfo();
|
||||||
agreementInfo.setAgreementId(bean.getAgreementId());
|
agreementInfo.setAgreementId(bean.getAgreementId());
|
||||||
agreementInfo.setCostBearingParty(sltAgreementInfo.getCostBearingParty());
|
agreementInfo.setCostBearingParty(sltAgreementInfo.getCostBearingParty());
|
||||||
agreementInfo.setStartTime(sltAgreementInfo.getBeginTime());
|
agreementInfo.setStartTime(sltAgreementInfo.getBeginTime());
|
||||||
agreementInfo.setIds(sltAgreementInfo.getIds());
|
agreementInfo.setIds(sltAgreementInfo.getIds());
|
||||||
sltAgreementInfo.setMonth(bean.getMonth());
|
sltAgreementInfo.setMonth(bean.getMonth());
|
||||||
sltAgreementInfo.setCodeNum(num++);
|
sltAgreementInfo.setCodeNum(num++);
|
||||||
agreementInfo.setEndTime(sltAgreementInfo.getOffTime());
|
agreementInfo.setEndTime(sltAgreementInfo.getOffTime());
|
||||||
List<SltAgreementInfo> leaseListOneMonth = getLeaseListOneMonth(agreementInfo, sltAgreementInfo);
|
List<SltAgreementInfo> leaseListOneMonth = getLeaseListOneMonth(agreementInfo, sltAgreementInfo);
|
||||||
sltAgreementInfo.setNode(leaseListOneMonth);
|
sltAgreementInfo.setNode(leaseListOneMonth);
|
||||||
}
|
}
|
||||||
leaseList.addAll(monthList);
|
leaseList.addAll(monthList);
|
||||||
} else {
|
/* } else {
|
||||||
List<SltAgreementInfo> oneOfList = sltAgreementInfoMapper.getLeaseListMonth(bean);
|
List<SltAgreementInfo> oneOfList = sltAgreementInfoMapper.getLeaseListMonth(bean);
|
||||||
for (SltAgreementInfo sltAgreementInfo : oneOfList) {
|
for (SltAgreementInfo sltAgreementInfo : oneOfList) {
|
||||||
AgreementInfo agreementInfo = new AgreementInfo();
|
AgreementInfo agreementInfo = new AgreementInfo();
|
||||||
|
|
@ -475,7 +481,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
|
||||||
sltAgreementInfo.setNode(leaseListOneMonth);
|
sltAgreementInfo.setNode(leaseListOneMonth);
|
||||||
}
|
}
|
||||||
leaseList.addAll(oneOfList);
|
leaseList.addAll(oneOfList);
|
||||||
}
|
}*/
|
||||||
// }
|
// }
|
||||||
return leaseList;
|
return leaseList;
|
||||||
}
|
}
|
||||||
|
|
@ -565,7 +571,9 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
|
||||||
// 应结算金额
|
// 应结算金额
|
||||||
BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays);
|
BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays);
|
||||||
bean.setCosts(String.valueOf(costs));
|
bean.setCosts(String.valueOf(costs));
|
||||||
|
//实际结算天数
|
||||||
bean.setRealDays(realDays);
|
bean.setRealDays(realDays);
|
||||||
|
// 实际结算金额
|
||||||
bean.setRealCosts(String.valueOf(realCosts));
|
bean.setRealCosts(String.valueOf(realCosts));
|
||||||
}
|
}
|
||||||
return leaseList;
|
return leaseList;
|
||||||
|
|
|
||||||
|
|
@ -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_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_project_lot bp ON bp.lot_id = bai.project_id
|
||||||
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
|
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
|
||||||
WHERE
|
WHERE 1=1
|
||||||
spm.month = DATE_FORMAT(#{endTime}, '%Y-%m')
|
<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>
|
||||||
<select id="getMonthDetails" resultType="com.bonus.sgzb.base.api.domain.SltAgreementInfo">
|
<select id="getMonthDetails" resultType="com.bonus.sgzb.base.api.domain.SltAgreementInfo">
|
||||||
SELECT
|
SELECT
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue