From b30f4c40c77a940a2a749a676e901787f55040b0 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期五, 06 十一月 2026 11:48:25 +0800
Subject: [PATCH] 流程优化
---
src/main/java/com/ruoyi/projectManagement/service/impl/handle/InfoHandleService.java | 38 +++++++++++++++++++++++++++++++++++++-
1 files changed, 37 insertions(+), 1 deletions(-)
diff --git a/src/main/java/com/ruoyi/projectManagement/service/impl/handle/InfoHandleService.java b/src/main/java/com/ruoyi/projectManagement/service/impl/handle/InfoHandleService.java
index 4a5aed5..4592366 100644
--- a/src/main/java/com/ruoyi/projectManagement/service/impl/handle/InfoHandleService.java
+++ b/src/main/java/com/ruoyi/projectManagement/service/impl/handle/InfoHandleService.java
@@ -9,6 +9,7 @@
import com.ruoyi.basic.service.CustomerFollowUpFileService;
import com.ruoyi.common.enums.PlanStageEnum;
import com.ruoyi.common.enums.ReviewStatusEnum;
+import com.ruoyi.common.enums.IsDeleteEnum;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.projectManagement.dto.InfoStageDto;
import com.ruoyi.projectManagement.dto.PlanStageDto;
@@ -19,11 +20,13 @@
import com.ruoyi.projectManagement.service.PlanService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.transaction.annotation.Transactional;
import jakarta.validation.constraints.NotNull;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
@@ -45,9 +48,17 @@
private final CustomerFollowUpFileService customerFollowUpFileService;
+ private final NamedParameterJdbcTemplate jdbc;
+
@Transactional(rollbackFor = Exception.class)
public Long save(@NotNull SaveInfoDto saveInfoDto) {
Info info = BeanUtil.copyProperties(saveInfoDto, Info.class);
+
+ if (info.getPlanStartTime() != null && info.getPlanEndTime() != null
+ && info.getPlanEndTime().isBefore(info.getPlanStartTime())) {
+ throw new ServiceException("棰勮缁撴潫鏃堕棿涓嶈兘鏃╀簬棰勮寮�濮嬫椂闂�");
+ }
+ bindProjectCategory(info);
// 闄勪欢鐗规畩澶勭悊
String attachmentIds = StrUtil.join(",", Optional.ofNullable(saveInfoDto.getAttachmentIds()).orElse(Collections.emptyList()));
@@ -70,13 +81,34 @@
infoMapper.insert(info);
} else {
Info existing = infoMapper.selectById(info.getId());
- if (existing == null) throw new ServiceException("椤圭洰涓嶅瓨鍦�");
+ if (existing == null || Integer.valueOf(IsDeleteEnum.DELETED.getCode()).equals(existing.getIsDelete())) {
+ throw new ServiceException("椤圭洰涓嶅瓨鍦ㄦ垨宸插垹闄�");
+ }
if (!StrUtil.isBlank(existing.getCurrentPhase()) && !"鏈紑濮�".equals(existing.getCurrentPhase())) {
throw new ServiceException("椤圭洰寮�濮嬪悗锛岄」鐩熀鏈俊鎭�佽礋璐d汉鍜岄」鐩粡鐞嗗潎涓嶅彲淇敼");
}
infoMapper.updateById(info);
}
return info.getId();
+ }
+
+ private void bindProjectCategory(Info info) {
+ if (info.getProjectCategoryId() != null) {
+ List<String> names = jdbc.queryForList("""
+ select category_name from project_management_category
+ where id=:id and is_deleted=0
+ """, Map.of("id", info.getProjectCategoryId()), String.class);
+ if (names.isEmpty()) throw new ServiceException("椤圭洰鍒嗙被涓嶅瓨鍦ㄦ垨宸插垹闄�");
+ info.setProjectClassification(names.getFirst());
+ return;
+ }
+ if (!StrUtil.isBlank(info.getProjectClassification())) {
+ List<Long> ids = jdbc.queryForList("""
+ select id from project_management_category
+ where category_name=:name and is_deleted=0 order by id
+ """, Map.of("name", info.getProjectClassification().trim()), Long.class);
+ if (ids.size() == 1) info.setProjectCategoryId(ids.getFirst());
+ }
}
@Transactional
@@ -86,6 +118,9 @@
public SaveInfoDto getInfoById(@NotNull Long id) {
Info info = infoMapper.selectById(id);
+ if (info == null || Integer.valueOf(IsDeleteEnum.DELETED.getCode()).equals(info.getIsDelete())) {
+ throw new ServiceException("椤圭洰涓嶅瓨鍦ㄦ垨宸插垹闄�");
+ }
return convert(info);
}
@@ -107,6 +142,7 @@
public List<SaveInfoDto> getSubordinateInfo(@NotNull Long id) {
LambdaQueryWrapper<Info> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Info::getProjectManagementInfoParentId, id);
+ queryWrapper.eq(Info::getIsDelete, IsDeleteEnum.NOT_DELETED.getCode());
queryWrapper.orderByAsc(Info::getCreateTime);
List<Info> infoList = infoMapper.selectList(queryWrapper);
return infoList.stream().map(this::convert).collect(Collectors.toList());
--
Gitblit v1.9.3