浏览代码

资源分配导入 导出

yurk 3 年之前
父节点
当前提交
74c163a721

+ 12 - 11
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ProjectRequirementController.java

@@ -154,7 +154,7 @@ public class ProjectRequirementController {
             List<ProjectRequirement> projectRequirementList = projectRequirementMapper.selectList(null);
             List<ProjectRequirement> projectRequirements=new ArrayList<>();
             for (int rowIndex = 0; rowIndex <= rowNum; rowIndex++) {
-                XSSFRow row = sheet.getRow(rowIndex);
+                XSSFRow row = sheet.getRow(rowIndex+1);
                 if (row == null) {
                     continue;
                 }
@@ -164,23 +164,24 @@ public class ProjectRequirementController {
                 }
                 //项目编号	任务需求  人员需求
                 XSSFCell codeCell = row.getCell(0);
-                XSSFCell nameCell = row.getCell(1);
-                XSSFCell taskReqCell = row.getCell(2);
-                XSSFCell membReqCell = row.getCell(3);
-                if(nameCell==null&&codeCell==null){
-                    throw new Exception("项目编号以及名称不能同时不存在");
-                }
+                XSSFCell taskReqCell = row.getCell(1);
+                XSSFCell membReqCell = row.getCell(2);
+
                 if (codeCell != null)codeCell.setCellType(CellType.STRING);
-                if (nameCell != null)nameCell.setCellType(CellType.STRING);
                 if (taskReqCell != null)taskReqCell.setCellType(CellType.STRING);
                 if (membReqCell != null)membReqCell.setCellType(CellType.STRING);
                 ProjectRequirement projectRequirement=new ProjectRequirement();
+                if(codeCell==null){
+                    throw new Exception("项目编号/名称不能为空");
+                }
+                System.out.println(codeCell.getStringCellValue());
                 List<Project> list = projectList.stream().filter(project ->
                         (StringUtils.isEmpty(project.getProjectCode())?"":project.getProjectCode()).equals(codeCell.getStringCellValue())
-                        || (StringUtils.isEmpty(project.getProjectName())?"":project.getProjectName()).equals(nameCell.getStringCellValue())
+                        || (StringUtils.isEmpty(project.getProjectName())?"":project.getProjectName()).equals(codeCell.getStringCellValue())
                 ).collect(Collectors.toList());
-                if(StringUtils.isEmpty(list)){
-                    msg.setError("项目编号/名称"+codeCell.getStringCellValue()+"/"+nameCell.getStringCellValue()+"不存在");
+                if(list.size()<=0){
+                    msg.setError("项目编号/名称"+codeCell.getStringCellValue()+"不存在");
+                    return msg;
                 }else{
                     list.forEach(li->{
                         projectRequirement.setProjectId(li.getId());