refactor(oa/erp): 重构月汇总工时编码生成逻辑

- 集成远程编码规则服务替代原有手动编码逻辑
dev
Yangk 2 months ago
parent 72bc701970
commit 7573bdd9d9

@ -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<ErpTimesheetSummary>()
.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());

Loading…
Cancel
Save