From 178b4ee9f38a8b38b1cb5321fee25a6038b39df9 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期三, 19 二月 2025 11:05:28 +0800
Subject: [PATCH] 中标单位id设为null

---
 business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java |   41 +++++++++++++++++++++++++++++++++++------
 1 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java b/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java
index 29b6407..2dba310 100644
--- a/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java
+++ b/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java
@@ -42,6 +42,7 @@
 import com.ycl.service.FileService;
 import com.ycl.service.ProjectInfoService;
 import com.ycl.service.ProjectInfoWinUnitService;
+import com.ycl.service.ProjectInfoYearPlanService;
 import com.ycl.system.mapper.SysDeptMapper;
 import lombok.RequiredArgsConstructor;
 import org.apache.commons.codec.Charsets;
@@ -79,6 +80,7 @@
 
     private final ProjectInfoMapper projectInfoMapper;
     private final ProjectInfoWinUnitService projectInfoWinUnitService;
+    private final ProjectInfoYearPlanService projectInfoYearPlanService;
     private final ProjectInvestmentFundingMapper investmentFundingMapper;
     private final ProjectInvestmentInfoMapper investmentInfoMapper;
     private final ProjectInvestmentPolicyComplianceMapper policyMapper;
@@ -105,7 +107,6 @@
         ProjectInfo entity = ProjectInfoForm.getEntityByForm(form, null);
         Long userId = SecurityUtils.getUserId();
         Long deptId = SecurityUtils.getDeptId();
-        List<ProjectInfoWinUnitForm> projectInfoWinUnitForm = form.getWinUnitList();
         entity.setProjectOwnerUnit(deptId);
         entity.setCreateBy(userId);
         entity.setUpdateBy(userId);
@@ -124,9 +125,13 @@
         fileService.saveBatch(fileList);
 
         //娣诲姞椤圭洰涓爣鍗曚綅
-        saveUnit(projectInfoWinUnitForm);
+        saveUnit(entity.getId(),form.getWinUnitList());
+        //娣诲姞骞村害鎶曡祫璁″垝
+//        saveYearPlan(entity.getId(),form.getYearPlanList());
         return Result.ok("娣诲姞鎴愬姛").data(entity.getId());
     }
+
+
 
     public void addPlan(Long projectInfoId) {
         Plan plan = new Plan();
@@ -177,22 +182,42 @@
         unitWrapper.eq("project_info_id",form.getId());
         projectInfoWinUnitService.remove(unitWrapper);
         //娣诲姞椤圭洰涓爣鍗曚綅
-        saveUnit(projectInfoWinUnitForm);
+        saveUnit(entity.getId(),projectInfoWinUnitForm);
 
+        //淇敼骞村害鎶曡祫璁″垝
+        //鍒犻櫎鍘熸暟鎹�
+//        List<ProjectInfoYearPlanForm> projectInfoYearPlanForm = form.getYearPlanList();
+        QueryWrapper<ProjectInfoYearPlan> yearPlanWrapper = new QueryWrapper<>();
+        unitWrapper.eq("project_info_id",form.getId());
+        projectInfoWinUnitService.remove(unitWrapper);
+        //娣诲姞骞村害鎶曡祫璁″垝
+        saveUnit(entity.getId(),projectInfoWinUnitForm);
         return Result.ok("淇敼鎴愬姛");
     }
 
-    private void saveUnit(List<ProjectInfoWinUnitForm> projectInfoWinUnitForm) {
+    private void saveUnit(Long id,List<ProjectInfoWinUnitForm> projectInfoWinUnitForm) {
         List<ProjectInfoWinUnit> projectInfoWinUnits = new ArrayList<>();
         for (ProjectInfoWinUnitForm winUnitForm : projectInfoWinUnitForm) {
             ProjectInfoWinUnit projectInfoWinUnit = ProjectInfoWinUnitForm.getEntityByForm(winUnitForm, null);
+            projectInfoWinUnit.setId(null);
+            projectInfoWinUnit.setProjectInfoId(id);
             projectInfoWinUnits.add(projectInfoWinUnit);
         }
         if (!CollectionUtils.isEmpty(projectInfoWinUnits)) {
             projectInfoWinUnitService.saveBatch(projectInfoWinUnits);
         }
     }
-
+    private void saveYearPlan(Long id, List<ProjectInfoYearPlanForm> yearPlanList) {
+        List<ProjectInfoYearPlan> projectInfoYearPlans = new ArrayList<>();
+        for (ProjectInfoYearPlanForm yearPlanForm : yearPlanList) {
+            ProjectInfoYearPlan yearPlan = ProjectInfoYearPlanForm.getEntityByForm(yearPlanForm, null);
+            yearPlan.setProjectInfoId(id);
+            projectInfoYearPlans.add(yearPlan);
+        }
+        if (!CollectionUtils.isEmpty(projectInfoYearPlans)) {
+            projectInfoYearPlanService.saveBatch(projectInfoYearPlans);
+        }
+    }
     /**
      * 鎵归噺鍒犻櫎
      *
@@ -219,6 +244,7 @@
         policyMapper.delete(new QueryWrapper<ProjectInvestmentPolicyCompliance>().eq("project_id", id));
         unitRegistrationInfoMapper.delete(new QueryWrapper<ProjectUnitRegistrationInfo>().eq("project_id", id));
         projectInfoWinUnitService.remove(new QueryWrapper<ProjectInfoWinUnit>().eq("project_info_id",id));
+        projectInfoYearPlanService.remove(new QueryWrapper<ProjectInfoYearPlan>().eq("project_info_id",id));
 
         List<String> types = new ArrayList<>();
         types.add(FileTypeEnum.PROJECT_INFO.getType());
@@ -327,13 +353,16 @@
 
         List<File> files = fileMapper.selectList(fileQueryWrapper);
         vo.setFileList(files);
+
+        //涓爣鍗曚綅
         List<ProjectInfoWinUnitVO> unitVOS = new ArrayList<>();
         List<ProjectInfoWinUnit> unitList = projectInfoWinUnitService.list(new QueryWrapper<ProjectInfoWinUnit>().eq("project_info_id", id));
         for (ProjectInfoWinUnit projectInfoWinUnit : unitList) {
             ProjectInfoWinUnitVO unitVO = ProjectInfoWinUnitVO.getVoByEntity(projectInfoWinUnit,null);
+            unitVO.setId(null);
             unitVOS.add(unitVO);
         }
-        vo.setWinUnitVOList(unitVOS);
+        vo.setWinUnitList(unitVOS);
         return Result.ok().data(vo);
     }
 

--
Gitblit v1.8.0