蔡德晨 %!s(int64=5) %!d(string=hai) anos
pai
achega
5add80db1a

+ 14 - 20
src/main/java/com/jeeplus/modules/sg/overheadline/service/OverheadLineService.java

@@ -232,17 +232,14 @@ public class OverheadLineService {
 
    //架空线路保存数据
     @Transactional(readOnly = false)
-   public void saveJk(MultipartFile file,String name,String id,String projectId,String type) throws IOException, InvalidFormatException {
-       WbsItem wbsItem = itemService.get(id);
-       if(wbsItem == null){
-           WbsItem wbsItem1 = new WbsItem();
-           wbsItem1.setProjectId(projectId);
-           wbsItem1.setId(id);
-           wbsItem1.setItemName(name);
-           wbsItem1.setType(type);
-           wbsItem1.setDelFlag("0");
+   public void saveJk(MultipartFile file,WbsItem wbsItem) throws IOException, InvalidFormatException {
+       String id = wbsItem.getId();
+       String type = wbsItem.getType();
+       WbsItem wbsItem1 = itemService.get(id);
+       if(wbsItem1 == null){
+           wbsItem.setDelFlag("0");
            //保存项目
-           itemService.save(wbsItem1);
+           itemService.save(wbsItem);
        }
        List<JkxlDetailFee> jkxlDetailFees = overheadLineMapper.findList(id,type);
        if(jkxlDetailFees != null && jkxlDetailFees.size()>0){
@@ -386,17 +383,14 @@ public class OverheadLineService {
 
     //电缆线路保存数据
     @Transactional(readOnly = false)
-    public void saveDl(MultipartFile file,String name,String id,String projectId,String type) throws IOException, InvalidFormatException {
-        WbsItem wbsItem = itemService.get(id);
-        if(wbsItem == null){
-            WbsItem wbsItem1 = new WbsItem();
-            wbsItem1.setProjectId(projectId);
-            wbsItem1.setId(id);
-            wbsItem1.setItemName(name);
-            wbsItem1.setType(type);
-            wbsItem1.setDelFlag("0");
+    public void saveDl(MultipartFile file,WbsItem wbsItem) throws IOException, InvalidFormatException {
+        String id = wbsItem.getId();
+        String type = wbsItem.getType();
+        WbsItem wbsItem1 = itemService.get(id);
+        if(wbsItem1 == null){
+            wbsItem.setDelFlag("0");
             //保存项目
-            itemService.save(wbsItem1);
+            itemService.save(wbsItem);
         }
         List<JkxlDetailFee> jkxlDetailFees = overheadLineMapper.findList(id,type);
         if(jkxlDetailFees != null && jkxlDetailFees.size()>0){

+ 9 - 0
src/main/java/com/jeeplus/modules/sg/project/entity/WbsItem.java

@@ -9,6 +9,7 @@ public class WbsItem extends DataEntity<WbsItem> {
     private String id; //项目ID
     private String unit; //施工单位
     private String itemName; //项目名称
+    private String itemNo;   //项目编号
     private String projectId; //工程ID
     private String parentNode; //父节点
     private String type; //项目类型
@@ -85,4 +86,12 @@ public class WbsItem extends DataEntity<WbsItem> {
     public void setType(String type) {
         this.type = type;
     }
+
+    public String getItemNo() {
+        return itemNo;
+    }
+
+    public void setItemNo(String itemNo) {
+        this.itemNo = itemNo;
+    }
 }

+ 2 - 0
src/main/java/com/jeeplus/modules/sg/project/mapper/xml/ItemMapper.xml

@@ -83,6 +83,7 @@
 			del_flag,
 			item_name,
 			unit,
+			item_no,
 			type,
 			project_id,
 			parent_node
@@ -96,6 +97,7 @@
 			#{delFlag},
 			#{itemName},
 			#{unit},
+			#{itemNo},
 			#{type},
 			#{projectId},
 			#{parentNode}

+ 6 - 7
src/main/java/com/jeeplus/modules/sg/project/web/ProjectController.java

@@ -95,21 +95,20 @@ public class ProjectController extends BaseController {
      *数据导入
      */
     @RequestMapping("/import")
-    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 id = getId();
+        wbsItem.setId(id);
         try {
 //            保存数据到数据库
             if(type.equals("1")) {
-                overheadLineService.saveJk(file, projectName, id, projectId, type);
+                overheadLineService.saveJk(file,wbsItem);
             }
             if (type.equals("2")) {
-                overheadLineService.saveDl(file, projectName, id, projectId, type);
+                overheadLineService.saveDl(file,wbsItem);
             }
             if (type.equals("3")) {
-                substationService.save(file, projectName, id, projectId, type);
+                substationService.save(file,wbsItem);
             }
         } catch (RuntimeException e) {
             addMessage(redirectAttributes, "导入失败,"+e.getMessage());

+ 25 - 11
src/main/java/com/jeeplus/modules/sg/project/web/ProjectTemController.java

@@ -1,6 +1,7 @@
 package com.jeeplus.modules.sg.project.web;
 
 import com.jeeplus.common.json.AjaxJson;
+import com.jeeplus.common.utils.StringUtils;
 import com.jeeplus.core.web.BaseController;
 import com.jeeplus.modules.sg.overheadline.service.OverheadLineService;
 import com.jeeplus.modules.sg.project.entity.WbsItem;
@@ -64,7 +65,7 @@ public class ProjectTemController extends BaseController {
      */
     @ResponseBody
     @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();
         WbsProject wbsProject = new WbsProject();
         wbsProject.setProjectName(projectName);
@@ -74,18 +75,31 @@ public class ProjectTemController extends BaseController {
         try {
             for(int i = 0;i<itemTypes.length;i++) {
                 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")) {
                     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")) {
                     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")) {
                     String id = getId();
-                    substationService.save(file[i], itemNames[i], id, projectId, itemTypes[i]);
+                    wbsItem.setId(id);
+                    substationService.save(file[i],wbsItem);
                 }
             }
         } catch (RuntimeException e) {
@@ -110,21 +124,21 @@ public class ProjectTemController extends BaseController {
      *文件导入
      */
     @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();
+        wbsItem.setId(id);
         try {
 //            保存数据到数据库
             if(type.equals("1")) {
-                overheadLineService.saveJk(file, projectName, id, projectId, type);
+                overheadLineService.saveJk(file, wbsItem);
             }
             if (type.equals("2")) {
-                overheadLineService.saveDl(file, projectName, id, projectId, type);
+                overheadLineService.saveDl(file, wbsItem);
             }
             if (type.equals("3")) {
-                substationService.save(file, projectName, id, projectId, type);
+                substationService.save(file, wbsItem);
             }
         } catch (RuntimeException e) {
             addMessage(redirectAttributes, "导入失败,"+e.getMessage());

+ 7 - 10
src/main/java/com/jeeplus/modules/sg/substation/service/SubstationService.java

@@ -52,17 +52,14 @@ public class SubstationService {
 
 
 
-    public void save(MultipartFile file,String name,String id,String projectId,String type) throws IOException, InvalidFormatException {
-        WbsItem wbsItem = itemService.get(id);
-        if(wbsItem == null){
-            WbsItem wbsItem1 = new WbsItem();
-            wbsItem1.setProjectId(projectId);
-            wbsItem1.setId(id);
-            wbsItem1.setItemName(name);
-            wbsItem1.setType(type);
-            wbsItem1.setDelFlag("0");
+    public void save(MultipartFile file,WbsItem wbsItem) throws IOException, InvalidFormatException {
+        String id = wbsItem.getId();
+        String type = wbsItem.getType();
+        WbsItem wbsItem1 = itemService.get(id);
+        if(wbsItem1 == null){
+            wbsItem.setDelFlag("0");
             //保存项目
-            itemService.save(wbsItem1);
+            itemService.save(wbsItem);
         }
         List<JkxlDetailFee> jkxlDetailFees = overheadLineMapper.findList(id,type);
         if(jkxlDetailFees != null && jkxlDetailFees.size()>0){