diff --git a/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/service/impl/UnionReimburseExportServiceImpl.java b/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/service/impl/UnionReimburseExportServiceImpl.java index a04165b0..46bedabc 100644 --- a/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/service/impl/UnionReimburseExportServiceImpl.java +++ b/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/service/impl/UnionReimburseExportServiceImpl.java @@ -25,6 +25,7 @@ import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy; import lombok.extern.slf4j.Slf4j; import org.nutz.ioc.loader.annotation.Inject; import org.nutz.ioc.loader.annotation.IocBean; +import org.nutz.lang.util.NutMap; import java.io.InputStream; import java.io.OutputStream; import java.math.BigDecimal; @@ -182,35 +183,37 @@ public class UnionReimburseExportServiceImpl implements UnionReimburseExportServ * 历史单据也按申请时间参与排序,同一秒内用创建时间及主键确定顺序; * 不按打印顺序编号,也不按当前用户或报销状态过滤申请。 * - * @param form 已通过导出权限校验的报销申请 + * @param form 报销申请,使用其单据ID读取数据库中的申请日期 * @return 年月日加至少三位当日序号,例如 20261009001 */ @Override public String buildPrintSerialNo(UnionReimburse form) { - if (form.getCreateTime() == null || StrUtil.isBlank(form.getId())) { - throw new BaseException("报销申请时间或单据ID为空,无法生成打印流水号"); + if (form == null || StrUtil.isBlank(form.getId())) { + throw new BaseException("报销单据ID为空,无法生成打印流水号"); } - Date startTime = DateUtil.beginOfDay(form.getCreateTime()); - // 先对当日全部申请排序,再读取目标申请,避免过滤ID后序号始终为1。 + // 日期范围和编号前缀均取数据库原值,避免Java日期转换及参数绑定影响当天范围。 + // 先对目标申请当天的全部单据排序,再筛选目标ID,保持审核、汇总和打印的编号一致。 Sql sql = Sqls.create(""" - SELECT numbered.seq + SELECT DATE_FORMAT(numbered.createTime, '%Y%m%d') AS serialDate, numbered.seq FROM ( - SELECT id, ROW_NUMBER() OVER (ORDER BY createTime, createdAt, id) AS seq - FROM union_reimburse - WHERE createTime >= @startTime AND createTime < @endTime + SELECT info.id, info.createTime, + ROW_NUMBER() OVER (ORDER BY info.createTime, info.createdAt, info.id) AS seq + FROM union_reimburse info + INNER JOIN union_reimburse target ON target.id = @id + WHERE info.createTime >= DATE(target.createTime) + AND info.createTime < DATE_ADD(DATE(target.createTime), INTERVAL 1 DAY) ) numbered WHERE numbered.id = @id """); - sql.setParam("startTime", startTime); - sql.setParam("endTime", DateUtil.offsetDay(startTime, 1)); sql.setParam("id", form.getId()); - sql.setCallback(Sqls.callback.integer()); + sql.setCallback(Sqls.callback.map()); dao.execute(sql); - int sequence = sql.getInt(); - if (sequence < 1) { - throw new BaseException("未找到报销申请,无法生成打印流水号"); + NutMap result = sql.getObject(NutMap.class); + if (result == null || !(result.get("seq") instanceof Number sequence) + || sequence.longValue() < 1 || StrUtil.isBlank(result.getString("serialDate"))) { + throw new BaseException("未找到报销申请或申请时间为空,无法生成打印流水号"); } - return DateUtil.format(form.getCreateTime(), "yyyyMMdd") + String.format(Locale.ROOT, "%03d", sequence); + return result.getString("serialDate") + String.format(Locale.ROOT, "%03d", sequence.longValue()); } /** 平铺字段供两类模板复用,支付总额与发票总额分别计算,不使用第一条支付代替全部明细。 */ diff --git a/src/main/resources/views/platform/zhgh/dayofficework/unionReimburse/apply/index.html b/src/main/resources/views/platform/zhgh/dayofficework/unionReimburse/apply/index.html index 445e570f..f038df6c 100644 --- a/src/main/resources/views/platform/zhgh/dayofficework/unionReimburse/apply/index.html +++ b/src/main/resources/views/platform/zhgh/dayofficework/unionReimburse/apply/index.html @@ -1978,7 +1978,6 @@ layout("/layouts/platform.html"){ }, // 根据当前选择的报销项目获取管理端配置的提示内容。 getProjectTipByProject(projectCode) { - if (projectCode === "UNION_REIMBURSE_PROJECT_5") projectCode = "UNION_REIMBURSE_PROJECT_2" if (!this.descOptions || !Array.isArray(this.descOptions)) { return ''; } diff --git a/src/main/resources/views/platform/zhghh5/dayofficework/unionReimburse/apply/index.html b/src/main/resources/views/platform/zhghh5/dayofficework/unionReimburse/apply/index.html index 0016edd3..3a4fb986 100644 --- a/src/main/resources/views/platform/zhghh5/dayofficework/unionReimburse/apply/index.html +++ b/src/main/resources/views/platform/zhghh5/dayofficework/unionReimburse/apply/index.html @@ -2531,7 +2531,6 @@ layout("/layouts/platform_h5.html"){ }, // 根据当前选择的报销项目获取管理端配置的提示内容。 getProjectTipByProject(projectCode) { - if (projectCode === "UNION_REIMBURSE_PROJECT_5") projectCode = "UNION_REIMBURSE_PROJECT_2" if (!this.descOptions || !Array.isArray(this.descOptions)) { return "" }