From 7573bdd9d99d52ee8b9df6b5707189ed6d54b2a7 Mon Sep 17 00:00:00 2001 From: Yangk Date: Fri, 8 May 2026 09:40:07 +0800 Subject: [PATCH] =?UTF-8?q?refactor(oa/erp):=20=E9=87=8D=E6=9E=84=E6=9C=88?= =?UTF-8?q?=E6=B1=87=E6=80=BB=E5=B7=A5=E6=97=B6=E7=BC=96=E7=A0=81=E7=94=9F?= =?UTF-8?q?=E6=88=90=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 集成远程编码规则服务替代原有手动编码逻辑 --- .../impl/ErpTimesheetSummaryServiceImpl.java | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/ruoyi-modules/ruoyi-oa/src/main/java/org/dromara/oa/erp/service/impl/ErpTimesheetSummaryServiceImpl.java b/ruoyi-modules/ruoyi-oa/src/main/java/org/dromara/oa/erp/service/impl/ErpTimesheetSummaryServiceImpl.java index dfb7bea9..9e3880c1 100644 --- a/ruoyi-modules/ruoyi-oa/src/main/java/org/dromara/oa/erp/service/impl/ErpTimesheetSummaryServiceImpl.java +++ b/ruoyi-modules/ruoyi-oa/src/main/java/org/dromara/oa/erp/service/impl/ErpTimesheetSummaryServiceImpl.java @@ -1,7 +1,9 @@ package org.dromara.oa.erp.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import org.apache.dubbo.config.annotation.DubboReference; import org.dromara.common.satoken.utils.LoginHelper; +import org.dromara.system.api.RemoteCodeRuleService; import org.dromara.common.core.utils.MapstructUtils; import org.dromara.common.core.utils.StringUtils; @@ -48,6 +50,9 @@ public class ErpTimesheetSummaryServiceImpl implements IErpTimesheetSummaryServi private final ErpTimesheetSummaryDetailMapper detailMapper; private final ErpTimesheetStandardMonthMapper standardMonthMapper; + @DubboReference + private RemoteCodeRuleService remoteCodeRuleService; + /** * 查询月汇总工时信息 * @@ -119,23 +124,9 @@ public class ErpTimesheetSummaryServiceImpl implements IErpTimesheetSummaryServi @Transactional(rollbackFor = Exception.class) public Boolean insertByBo(ErpTimesheetSummaryBo bo) { if (StringUtils.isBlank(bo.getSummaryCode())) { - // 生成规则:TS + 月份代码(yyyyMM) + 4位递增序列(0001) - String prefix = "TS" + bo.getMonthCode(); - ErpTimesheetSummary lastOne = baseMapper.selectOne(new LambdaQueryWrapper() - .likeRight(ErpTimesheetSummary::getSummaryCode, prefix) - .orderByDesc(ErpTimesheetSummary::getSummaryCode) - .last("limit 1")); - int nextNum = 1; - if (lastOne != null) { - String lastCode = lastOne.getSummaryCode(); - if (lastCode.length() >= 4) { - try { - nextNum = Integer.parseInt(lastCode.substring(lastCode.length() - 4)) + 1; - } catch (NumberFormatException ignored) { - } - } - } - bo.setSummaryCode(prefix + String.format("%04d", nextNum)); + // 使用远程编码规则服务生成编号 + String summaryCode = remoteCodeRuleService.selectCodeRuleCode("1033"); + bo.setSummaryCode(summaryCode); } if (bo.getUserId() == null) { bo.setUserId(LoginHelper.getUserId());