|
@@ -1,6 +1,7 @@
|
|
package com.jeeplus.modules.sg.project.web;
|
|
package com.jeeplus.modules.sg.project.web;
|
|
|
|
|
|
import com.jeeplus.common.json.AjaxJson;
|
|
import com.jeeplus.common.json.AjaxJson;
|
|
|
|
+import com.jeeplus.common.utils.StringUtils;
|
|
import com.jeeplus.core.web.BaseController;
|
|
import com.jeeplus.core.web.BaseController;
|
|
import com.jeeplus.modules.sg.overheadline.service.OverheadLineService;
|
|
import com.jeeplus.modules.sg.overheadline.service.OverheadLineService;
|
|
import com.jeeplus.modules.sg.project.entity.WbsItem;
|
|
import com.jeeplus.modules.sg.project.entity.WbsItem;
|
|
@@ -64,7 +65,7 @@ public class ProjectTemController extends BaseController {
|
|
*/
|
|
*/
|
|
@ResponseBody
|
|
@ResponseBody
|
|
@RequestMapping("/import")
|
|
@RequestMapping("/import")
|
|
- public HashMap importFile(@RequestParam(value = "file")MultipartFile[] file,String projectName,String[] itemNames,String[] itemTypes) throws IOException, InvalidFormatException {
|
|
|
|
|
|
+ public HashMap importFile(@RequestParam(value = "file")MultipartFile[] file,String projectName,String[] itemNames,String[] itemTypes,String[] units,String[] itemNo) throws IOException, InvalidFormatException {
|
|
HashMap map = new HashMap();
|
|
HashMap map = new HashMap();
|
|
WbsProject wbsProject = new WbsProject();
|
|
WbsProject wbsProject = new WbsProject();
|
|
wbsProject.setProjectName(projectName);
|
|
wbsProject.setProjectName(projectName);
|
|
@@ -74,18 +75,31 @@ public class ProjectTemController extends BaseController {
|
|
try {
|
|
try {
|
|
for(int i = 0;i<itemTypes.length;i++) {
|
|
for(int i = 0;i<itemTypes.length;i++) {
|
|
fileName = file[i].getOriginalFilename();
|
|
fileName = file[i].getOriginalFilename();
|
|
|
|
+ WbsItem wbsItem = new WbsItem();
|
|
|
|
+ wbsItem.setItemName(itemNames[i]);
|
|
|
|
+ wbsItem.setType(itemTypes[i]);
|
|
|
|
+ wbsItem.setProjectId(projectId);
|
|
|
|
+ if(StringUtils.isNotBlank(units[i])){
|
|
|
|
+ wbsItem.setUnit(units[i]);
|
|
|
|
+ }
|
|
|
|
+ if(StringUtils.isNotBlank(itemNo[i])){
|
|
|
|
+ wbsItem.setUnit(itemNo[i]);
|
|
|
|
+ }
|
|
// 保存数据到数据库
|
|
// 保存数据到数据库
|
|
if (itemTypes[i].equals("1")) {
|
|
if (itemTypes[i].equals("1")) {
|
|
String id = getId();
|
|
String id = getId();
|
|
- overheadLineService.saveJk(file[i], itemNames[i], id, projectId, itemTypes[i]);
|
|
|
|
|
|
+ wbsItem.setId(id);
|
|
|
|
+ overheadLineService.saveJk(file[i],wbsItem);
|
|
}
|
|
}
|
|
if (itemTypes[i].equals("2")) {
|
|
if (itemTypes[i].equals("2")) {
|
|
String id = getId();
|
|
String id = getId();
|
|
- overheadLineService.saveDl(file[i], itemNames[i], id, projectId, itemTypes[i]);
|
|
|
|
|
|
+ wbsItem.setId(id);
|
|
|
|
+ overheadLineService.saveDl(file[i],wbsItem);
|
|
}
|
|
}
|
|
if (itemTypes[i].equals("3")) {
|
|
if (itemTypes[i].equals("3")) {
|
|
String id = getId();
|
|
String id = getId();
|
|
- substationService.save(file[i], itemNames[i], id, projectId, itemTypes[i]);
|
|
|
|
|
|
+ wbsItem.setId(id);
|
|
|
|
+ substationService.save(file[i],wbsItem);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} catch (RuntimeException e) {
|
|
} catch (RuntimeException e) {
|
|
@@ -110,21 +124,21 @@ public class ProjectTemController extends BaseController {
|
|
*文件导入
|
|
*文件导入
|
|
*/
|
|
*/
|
|
@RequestMapping("/importfile")
|
|
@RequestMapping("/importfile")
|
|
- public String importFile(MultipartFile file, RedirectAttributes redirectAttributes, HttpServletRequest request, Model model) {
|
|
|
|
- String projectName = request.getParameter("name"); //项目名称
|
|
|
|
- String projectId = request.getParameter("projectId"); //工程ID
|
|
|
|
- String type = request.getParameter("type"); //工程类型
|
|
|
|
|
|
+ public String importFile(MultipartFile file,WbsItem wbsItem, RedirectAttributes redirectAttributes, HttpServletRequest request, Model model) {
|
|
|
|
+ String type = wbsItem.getType(); //项目类型
|
|
|
|
+ String projectId = wbsItem.getProjectId();
|
|
String id = getId();
|
|
String id = getId();
|
|
|
|
+ wbsItem.setId(id);
|
|
try {
|
|
try {
|
|
// 保存数据到数据库
|
|
// 保存数据到数据库
|
|
if(type.equals("1")) {
|
|
if(type.equals("1")) {
|
|
- overheadLineService.saveJk(file, projectName, id, projectId, type);
|
|
|
|
|
|
+ overheadLineService.saveJk(file, wbsItem);
|
|
}
|
|
}
|
|
if (type.equals("2")) {
|
|
if (type.equals("2")) {
|
|
- overheadLineService.saveDl(file, projectName, id, projectId, type);
|
|
|
|
|
|
+ overheadLineService.saveDl(file, wbsItem);
|
|
}
|
|
}
|
|
if (type.equals("3")) {
|
|
if (type.equals("3")) {
|
|
- substationService.save(file, projectName, id, projectId, type);
|
|
|
|
|
|
+ substationService.save(file, wbsItem);
|
|
}
|
|
}
|
|
} catch (RuntimeException e) {
|
|
} catch (RuntimeException e) {
|
|
addMessage(redirectAttributes, "导入失败,"+e.getMessage());
|
|
addMessage(redirectAttributes, "导入失败,"+e.getMessage());
|