|
@@ -58,10 +58,12 @@ public class ProjectTemController extends BaseController {
|
|
|
*数据导入
|
|
|
*/
|
|
|
@RequestMapping("/import")
|
|
|
- public String importFile(MultipartFile file, RedirectAttributes redirectAttributes, HttpServletRequest request, Model model) {
|
|
|
+ public String importFile(MultipartFile[] file, RedirectAttributes redirectAttributes, HttpServletRequest request, Model model) {
|
|
|
String projectName = request.getParameter("projectName"); //项目名称
|
|
|
- String itemName = request.getParameter("itemName"); //项目名称
|
|
|
- String type = request.getParameter("type"); //工程类型
|
|
|
+ String itemNames = request.getParameter("itemName"); //项目名称
|
|
|
+ String types = request.getParameter("type"); //工程类型
|
|
|
+ String[] itemName = itemNames.split(",");
|
|
|
+ String[] type = types.split(",");
|
|
|
String id = getId();
|
|
|
WbsProject wbsProject = new WbsProject();
|
|
|
wbsProject.setProjectName(projectName);
|
|
@@ -70,12 +72,14 @@ public class ProjectTemController extends BaseController {
|
|
|
WbsProject wbsProject1 = wbsProjects.get(0);
|
|
|
String projectId = wbsProject1.getId();
|
|
|
try {
|
|
|
+ for(int i = 0;i<type.length;i++) {
|
|
|
// 保存数据到数据库
|
|
|
- if(type.equals("1")) {
|
|
|
- overheadLineService.saveJk(file,itemName, id, projectId, type);
|
|
|
- }
|
|
|
- if (type.equals("2")) {
|
|
|
- overheadLineService.saveDl(file,itemName, id, projectId, type);
|
|
|
+ if (type.equals("1")) {
|
|
|
+ overheadLineService.saveJk(file[i], itemName[i], id, projectId, type[i]);
|
|
|
+ }
|
|
|
+ if (type.equals("2")) {
|
|
|
+ overheadLineService.saveDl(file[i], itemName[i], id, projectId, type[i]);
|
|
|
+ }
|
|
|
}
|
|
|
} catch (RuntimeException e) {
|
|
|
addMessage(redirectAttributes, "导入失败,"+e.getMessage());
|