From a8e4132c3e2e9c3b3fcb0360901b35571b6464ea Mon Sep 17 00:00:00 2001
From: hsy <1029150275@qq.com>
Date: 星期五, 28 八月 2026 10:13:01 +0800
Subject: [PATCH] feat: 综合业务模块功能补充与实体拓展

---
 src/main/java/com/ruoyi/approve/service/impl/FinReimbursementServiceImpl.java |   51 ++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/ruoyi/approve/service/impl/FinReimbursementServiceImpl.java b/src/main/java/com/ruoyi/approve/service/impl/FinReimbursementServiceImpl.java
index 1861d83..bdc217f 100644
--- a/src/main/java/com/ruoyi/approve/service/impl/FinReimbursementServiceImpl.java
+++ b/src/main/java/com/ruoyi/approve/service/impl/FinReimbursementServiceImpl.java
@@ -24,6 +24,8 @@
 import com.ruoyi.common.utils.OrderUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.project.system.service.ISysNoticeService;
+import com.ruoyi.project.system.service.ISysDeptService;
+import com.ruoyi.project.system.domain.SysDept;
 import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -60,6 +62,7 @@
     private final FinReimbursementDetailMapper finReimbursementDetailMapper;
     private final FileUtil fileUtil;
     private final ISysNoticeService sysNoticeService;
+    private final ISysDeptService sysDeptService;
     @Override
     public IPage<FinReimbursementVo> listPage(FinReimbursementDto finReimbursementDto, Page<FinReimbursementVo> page) {
         IPage<FinReimbursementVo> finReimbursementVoIPage = finReimbursementMapper.listPage(finReimbursementDto, page);
@@ -71,12 +74,17 @@
     }
 
     @Override
+    public List<FinReimbursementVo> list(FinReimbursementDto finReimbursementDto) {
+        return finReimbursementMapper.list(finReimbursementDto);
+    }
+
+    @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean add(FinReimbursementDto finReimbursementDto) {
         String billStatus = validateAddParam(finReimbursementDto);
 
         // 鐢熸垚鎶ラ攢鍗曞彿
-        String billNo = OrderUtils.countTodayByCreateTime(finReimbursementMapper, "BXD", "bill_no");
+        String billNo = OrderUtils.countTodayByCreateTime(finReimbursementMapper, "BXD", "bill_no", finReimbursementDto.getCreateTime() != null ? finReimbursementDto.getCreateTime() : LocalDateTime.now());
         List<FinReimbursementDetail> details = finReimbursementDto.getDetails();
         BigDecimal totalAmount = details.stream()
                 .map(FinReimbursementDetail::getAmount)
@@ -251,6 +259,13 @@
         vo.setDeptId(reimbursement.getDeptId());
         vo.setDeleted(reimbursement.getDeleted());
 
+        if (reimbursement.getDeptId() != null) {
+            SysDept dept = sysDeptService.selectDeptById(reimbursement.getDeptId());
+            if (dept != null) {
+                vo.setDeptName(dept.getDeptName());
+            }
+        }
+
         vo.setDetails(finReimbursementDetailMapper.selectList(
                 new LambdaQueryWrapper<FinReimbursementDetail>()
                         .eq(FinReimbursementDetail::getReimbursementId, reimbursement.getId())
@@ -274,6 +289,26 @@
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean delete(List<Long> ids) {
+        if (ids == null || ids.isEmpty()) {
+            throw new ServiceException("鍒犻櫎澶辫触锛岃閫夋嫨瑕佸垹闄ょ殑鏁版嵁");
+        }
+        // 鏌ヨ鎶ラ攢鍗曞叧鑱旂殑瀹℃壒瀹炰緥ID
+        List<FinReimbursement> reimbursements = finReimbursementMapper.selectList(
+                new LambdaQueryWrapper<FinReimbursement>()
+                        .in(FinReimbursement::getId, ids)
+                        .isNotNull(FinReimbursement::getApprovalInstanceId)
+        );
+        List<Long> approvalInstanceIds = reimbursements.stream()
+                .map(FinReimbursement::getApprovalInstanceId)
+                .filter(Objects::nonNull)
+                .distinct()
+                .collect(Collectors.toList());
+
+        // 鍒犻櫎鍏宠仈鐨勫鎵硅褰�
+        if (!approvalInstanceIds.isEmpty()) {
+            approvalInstanceService.delete(approvalInstanceIds);
+        }
+
         fileUtil.deleteStorageAttachmentsByApplicationAndRecordTypeAndRecordIds(ApplicationTypeEnum.FILE, RecordTypeEnum.FIN_REIMBURSEMENT, ids);
         //鍏堝垹闄ゆ槑缁�
         finReimbursementDetailMapper.delete(new LambdaQueryWrapper<FinReimbursementDetail>().in(FinReimbursementDetail::getReimbursementId, ids));
@@ -381,7 +416,7 @@
     private void startApproval(FinReimbursement reimbursement, FinReimbursementDto finReimbursementDto) {
         Long businessType = resolveBusinessType(finReimbursementDto.getReimbursementType());
         ApprovalInstanceDto approvalInstanceDto = new ApprovalInstanceDto();
-        approvalInstanceDto.setInstanceNo(OrderUtils.countTodayByCreateTime(approvalInstanceMapper, "SP", "instance_no"));
+        approvalInstanceDto.setInstanceNo(OrderUtils.countTodayByCreateTime(approvalInstanceMapper, "SP", "instance_no", approvalInstanceDto.getCreateTime() != null ? approvalInstanceDto.getCreateTime() : LocalDateTime.now()));
         approvalInstanceDto.setBusinessId(reimbursement.getId());
         approvalInstanceDto.setTemplateId(null);
         approvalInstanceDto.setTemplateName(TypeEnums.getLabelByValue(businessType) + "瀹℃壒");
@@ -494,10 +529,20 @@
         }
         String title = "鎶ラ攢瀹℃壒";
         String message = "瀹℃壒鍗曞彿 " + instance.getInstanceNo() + " 闇�瑕佹偍瀹℃壒";
-        String jumpPath = "/approvalInstance?id=" + instance.getId();
+        String jumpPath = getJumpPathByBusinessType(instance.getBusinessType(), instance.getId());
         sysNoticeService.simpleNoticeByUser(title, message, approverIds, jumpPath);
     }
 
+    private String getJumpPathByBusinessType(Long businessType, Long instanceId) {
+        if (TypeEnums.TRAVEL_REIMBURSEMENT_APPROVAL.getCode().equals(businessType)) {
+            return "/collaborativeApproval/ReimburseManage/travel-reimburse?id=" + instanceId;
+        }
+        if (TypeEnums.EXPENSE_APPROVAL.getCode().equals(businessType)) {
+            return "/collaborativeApproval/ReimburseManage/cost-reimburse?id=" + instanceId;
+        }
+        return "/approvalInstance?id=" + instanceId;
+    }
+
     private void resetApprovalFlow(FinReimbursement existing, Long reimbursementId) {
         if (existing == null || existing.getApprovalInstanceId() == null) {
             return;

--
Gitblit v1.9.3