Pārlūkot izejas kodu

项目导入 修改 编号已存在更新

yurk 2 gadi atpakaļ
vecāks
revīzija
a00958b462

+ 10 - 3
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -2857,6 +2857,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                         if (subNames != null) {
                             for (String s : subNames) {
                                 if (!StringUtils.isEmpty(s)) {
+                                    subProjectMapper.delete(new QueryWrapper<SubProject>().eq("project_id",project.getId()));
                                     SubProject sp = new SubProject();
                                     sp.setName(s);
                                     sp.setProjectId(project.getId());
@@ -2873,6 +2874,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                             Participation p = new Participation();
                             Optional<User> first = userList.stream().filter(u -> u.getName().equals(value)).findFirst();
                             if (first.isPresent()) {
+                                //避免更新操作 想清楚之前存在的参与人
+                                participationMapper.delete(new QueryWrapper<Participation>().eq("project_id",project.getId()));
                                 p.setUserId(first.get().getId());
                                 p.setProjectId(project.getId());
                                 participationMapper.insert(p);
@@ -2898,6 +2901,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                                 Participation p = new Participation();
                                 Optional<User> first = userList.stream().filter(u -> u.getName().equals(str)).findFirst();
                                 if (first.isPresent()) {
+                                    participationMapper.delete(new QueryWrapper<Participation>().eq("project_id",project.getId()));
                                     p.setUserId(first.get().getId());
                                     p.setProjectId(project.getId());
                                     participationMapper.insert(p);
@@ -3285,13 +3289,13 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                         project.setProviderNames(nameString);
                     }
                     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-                    if (startDateCell !=null && !StringUtils.isEmpty(startDateCell.getDateCellValue())) {
+                    if (startDateCell !=null && startDateCell.getCellTypeEnum() == CellType.NUMERIC && !StringUtils.isEmpty(startDateCell.getDateCellValue())) {
                         project.setPlanStartDate(LocalDate.parse(sdf.format(startDateCell.getDateCellValue()), DateTimeFormatter.ofPattern("yyyy-MM-dd")));
                     }
                     if (endDateCell !=null && endDateCell.getCellTypeEnum() == CellType.NUMERIC && !StringUtils.isEmpty(endDateCell.getDateCellValue())) {
                         project.setPlanEndDate(LocalDate.parse(sdf.format(endDateCell.getDateCellValue()), DateTimeFormatter.ofPattern("yyyy-MM-dd")));
                     }
-                    if (amountCell !=null && amountCell.getCellTypeEnum() == CellType.NUMERIC && !StringUtils.isEmpty(amountCell.getStringCellValue())) {
+                    if (amountCell !=null  && !StringUtils.isEmpty(amountCell.getStringCellValue())) {
                         project.setContractAmount(Double.parseDouble(amountCell.getStringCellValue()));
                     }
                     if (isPublicCell != null && !StringUtils.isEmpty(isPublicCell.getStringCellValue())) {
@@ -3305,6 +3309,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                             if (subNames != null) {
                                 for (String s : subNames) {
                                     if (!StringUtils.isEmpty(s)) {
+                                        subProjectMapper.delete(new QueryWrapper<SubProject>().eq("project_id",project.getId()));
                                         SubProject sp = new SubProject();
                                         sp.setName(s);
                                         sp.setProjectId(project.getId());
@@ -3371,7 +3376,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                         }
                         if (buCell != null && !StringUtils.isEmpty(buCell.getStringCellValue())) {
                             projectSeparate.setBu(buCell.getStringCellValue());
-                        }
+                        }else projectSeparate.setBu("");
                         if (projectCategorySubCell != null && !StringUtils.isEmpty(projectCategorySubCell.getStringCellValue())) {
                             projectSeparate.setProjectCategorySub(projectCategorySubCell.getStringCellValue());
                         }
@@ -3389,6 +3394,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                             Participation p = new Participation();
                             Optional<User> first = userList.stream().filter(u -> u.getName().equals(value)).findFirst();
                             if (first.isPresent()) {
+                                participationMapper.delete(new QueryWrapper<Participation>().eq("project_id",project.getId()));
                                 p.setUserId(first.get().getId());
                                 p.setProjectId(project.getId());
                                 participationMapper.insert(p);
@@ -3414,6 +3420,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                                 Participation p = new Participation();
                                 Optional<User> first = userList.stream().filter(u -> u.getName().equals(str)).findFirst();
                                 if (first.isPresent()) {
+                                    participationMapper.delete(new QueryWrapper<Participation>().eq("project_id",project.getId()));
                                     p.setUserId(first.get().getId());
                                     p.setProjectId(project.getId());
                                     participationMapper.insert(p);