| | |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | |
| | | app.setDeptName(dept.getDeptName()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public String generateApplicationCode(String prefix) { |
| | | String dateStr = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")); |
| | | |
| | | // 查询当天已生成的申请单号数量 |
| | | Long count = this.lambdaQuery() |
| | | .likeRight(OaApprovalApplications::getApplicationCode, prefix) |
| | | .ge(OaApprovalApplications::getCreateTime, LocalDate.now().atStartOfDay()) |
| | | .lt(OaApprovalApplications::getCreateTime, LocalDate.now().plusDays(1).atStartOfDay()) |
| | | .count(); |
| | | |
| | | // 生成4位序号,从0001开始 |
| | | int sequence = (count != null ? count.intValue() : 0) + 1; |
| | | String sequenceStr = String.format("%04d", sequence); |
| | | |
| | | return prefix + dateStr + sequenceStr; |
| | | } |
| | | } |