Commit ca97b857 authored by huyuchen's avatar huyuchen

huych-合同自动化代码提交

parent 4962db12
......@@ -68,6 +68,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.time.ZoneId;
......@@ -1427,10 +1428,19 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
if (Common.isEmpty(insert.getContractTerm())
&& Common.isNotNull(insert.getContractStart())
&& Common.isNotNull(insert.getContractEnd())) {
int monthDiff = DateUtil.getMonthDiff(insert.getContractStart(), insert.getContractEnd());
BigDecimal b = new BigDecimal(String.valueOf(monthDiff / 12.0));
b = b.setScale(1, BigDecimal.ROUND_HALF_UP);
insert.setContractTerm(String.valueOf(b));
//1.9.12合同年限优化
long daysDiff = DateUtil.getDaysDiff(insert.getContractStart(), insert.getContractEnd());
if (daysDiff < 0) {
insert.setContractTerm("0.0");
} else {
double years = daysDiff / 365.25; // 考虑闰年因素
BigDecimal b = BigDecimal.valueOf(years).setScale(2, RoundingMode.HALF_UP);
insert.setContractTerm(b.toString());
}
// int monthDiff = DateUtil.getMonthDiff(insert.getContractStart(), insert.getContractEnd());
// BigDecimal b = new BigDecimal(String.valueOf(monthDiff / 12.0));
// b = b.setScale(1, BigDecimal.ROUND_HALF_UP);
// insert.setContractTerm(String.valueOf(b));
}
// 核心保存
R<List<ErrorMessage>> info = this.setBaseInfo(insert, project);
......
......@@ -299,6 +299,7 @@ public class TEmployeeContractPreServiceImpl extends ServiceImpl<TEmployeeContra
.set(TEmployeeContractPre::getErrorInfo, errorMessage.getMessage())
.set(TEmployeeContractPre::getErrorTime, LocalDateTimeUtils.convertLDToDate(LocalDate.now()));
// 执行更新操作
errorMessage.setData(contractVO);
this.update(updateWrapper);
}
}
......
......@@ -11,8 +11,10 @@ import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
......@@ -965,6 +967,17 @@ public class DateUtil {
}
}
public static long getDaysDiff(Date startDate, Date endDate) {
if (startDate == null || endDate == null) return 0;
// 标准化为 LocalDate(忽略时间部分)
LocalDate start = startDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
LocalDate end = endDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
// 计算绝对天数差
return Math.abs(ChronoUnit.DAYS.between(start, end));
}
/**
* @param date1
* @param date2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment