Explorar el Código

Merge branch 'master' of http://47.100.37.243:10080/wutt/manHourHousekeeper

ggooalice hace 2 años
padre
commit
1452ef4a42

+ 51 - 21
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -2763,6 +2763,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                         throw new Exception("项目名称不能为空");
                     }
                     Project project = new Project();
+                    boolean flag=false;
                     if (codeCell != null) {
                         String code = codeCell.getStringCellValue().trim().replaceAll("\\u00a0", "");
                         if (code.equals("项目编号") && rowIndex == 0) {
@@ -2790,7 +2791,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
 //                            throw new Exception("项目编号存在重复: " + code);
                                 existCodeList.add(code);
                                 //跳过编号重复的数据
-                                continue;
+                                flag=true;
                             }
                         }
                         project.setProjectCode(code);
@@ -2835,12 +2836,18 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     if (isPublicCell != null && !StringUtils.isEmpty(isPublicCell.getStringCellValue())) {
                         project.setIsPublic("是".equals(isPublicCell.getStringCellValue())?1:0);
                     }
-                    if(projectMapper.insert(project)>0){
-                        ProjectAuditor projectAuditor=new ProjectAuditor();
-                        projectAuditor.setAuditorId(project.getInchargerId());
-                        projectAuditor.setAuditorName(project.getInchargerName());
-                        projectAuditor.setProjectId(project.getId());
-                        projectAuditorMapper.insert(projectAuditor);
+                    if(flag){
+                        Project updateProject = projectMapper.selectList(new QueryWrapper<Project>().eq("project_code", project.getProjectCode()).eq("company_id", user.getCompanyId())).get(0);
+                        project.setId(updateProject.getId());
+                        projectMapper.updateById(project);
+                    }else {
+                        if(projectMapper.insert(project)>0){
+                            ProjectAuditor projectAuditor=new ProjectAuditor();
+                            projectAuditor.setAuditorId(project.getInchargerId());
+                            projectAuditor.setAuditorName(project.getInchargerName());
+                            projectAuditor.setProjectId(project.getId());
+                            projectAuditorMapper.insert(projectAuditor);
+                        }
                     }
                     importCount++;
                     //处理子项目
@@ -2850,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());
@@ -2866,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);
@@ -2891,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);
@@ -2905,7 +2916,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 msg.data = "成功导入"+importCount+"条数据。";
                 if (existCodeList.size() > 0) {
                     String collect = existCodeList.stream().collect(Collectors.joining(","));
-                    msg.data += "自动跳过"+existCodeList.size()+"条已存在项目编码:"+collect;
+                    msg.data += "自动更新"+existCodeList.size()+"条已存在项目编码:"+collect;
                 }
                 OperationRecord operationRecord=new OperationRecord();
                 operationRecord.setCompanyId(user.getCompanyId());
@@ -3097,6 +3108,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                         throw new Exception("项目名称不能为空");
                     }
                     Project project = new Project();
+                    boolean flag=false;
                     if (codeCell != null) {
                         String code = codeCell.getStringCellValue().trim().replaceAll("\\u00a0", "");
                         if (code.equals("项目编号") && rowIndex == 0) {
@@ -3129,7 +3141,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
 //                            throw new Exception("项目编号存在重复: " + code);
                                 existCodeList.add(code);
                                 //跳过编号重复的数据
-                                continue;
+                                flag=true;
                             }
                         }
                         project.setProjectCode(code);
@@ -3277,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())) {
@@ -3297,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());
@@ -3325,17 +3338,28 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                             }
                         }
                     }
-                    if(projectMapper.insert(project)>0){
-                        ProjectAuditor projectAuditor=new ProjectAuditor();
-                        projectAuditor.setAuditorId(project.getInchargerId());
-                        projectAuditor.setAuditorName(project.getInchargerName());
-                        projectAuditor.setProjectId(project.getId());
-                        projectAuditorMapper.insert(projectAuditor);
+                    if(flag){
+                        Project updateProject = projectMapper.selectList(new QueryWrapper<Project>().eq("project_code", project.getProjectCode()).eq("company_id", user.getCompanyId())).get(0);
+                        project.setId(updateProject.getId());
+                        projectMapper.updateById(project);
+                    }else {
+                        if(projectMapper.insert(project)>0){
+                            ProjectAuditor projectAuditor=new ProjectAuditor();
+                            projectAuditor.setAuditorId(project.getInchargerId());
+                            projectAuditor.setAuditorName(project.getInchargerName());
+                            projectAuditor.setProjectId(project.getId());
+                            projectAuditorMapper.insert(projectAuditor);
+                        }
                     }
                     Integer id = project.getId();
                     //处理威派格 垂直分表项目数据数据
                     if(company.getId()==936){
-                        ProjectSeparate projectSeparate=new ProjectSeparate();
+                        ProjectSeparate projectSeparate = projectSeparateMapper.selectById(id);
+                        boolean check=true;
+                        if(projectSeparate==null){
+                            projectSeparate=new ProjectSeparate();
+                            check=false;
+                        }
                         projectSeparate.setId(id);
                         if (warrantyStartDateCell !=null&& warrantyStartDateCell.getCellTypeEnum() == CellType.NUMERIC  && !StringUtils.isEmpty(warrantyStartDateCell.getDateCellValue())) {
                             projectSeparate.setWarrantyStartDate(LocalDate.parse(sdf.format(warrantyStartDateCell.getDateCellValue()), DateTimeFormatter.ofPattern("yyyy-MM-dd")));
@@ -3352,11 +3376,15 @@ 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());
                         }
-                        projectSeparateMapper.insert(projectSeparate);
+                        if(flag&&check){
+                           projectSeparateMapper.updateById(projectSeparate);
+                        }else {
+                            projectSeparateMapper.insert(projectSeparate);
+                        }
                     }
                     importCount++;
                     //参与人
@@ -3366,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);
@@ -3391,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);
@@ -3405,7 +3435,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 msg.data = "成功导入"+importCount+"条数据。";
                 if (existCodeList.size() > 0) {
                     String collect = existCodeList.stream().collect(Collectors.joining(","));
-                    msg.data += "自动跳过"+existCodeList.size()+"条已存在项目编码:"+collect;
+                    msg.data += "自动更新"+existCodeList.size()+"条已存在项目编码:"+collect;
                 }
                 OperationRecord operationRecord=new OperationRecord();
                 operationRecord.setCompanyId(user.getCompanyId());

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/resources/application-prod.yml

@@ -82,7 +82,7 @@ mybatis:
 upload:
   path: /www/staticproject/timesheet/upload/
 
-
+excludeUrls: /report/getReportListByToken