LAPTOP-FO2T5SIU\35838 9 mēneši atpakaļ
vecāks
revīzija
600149b246

+ 1 - 1
pro-base/src/main/java/com/idea/buildManage/controller/ParkFloorDiscController.java

@@ -102,7 +102,7 @@ public class ParkFloorDiscController extends BaseController {
     }
 
     /**
-     * 楼栋导入
+     * 分期导入
      * @param file
      * @return
      */

+ 1 - 1
pro-base/src/main/java/com/idea/buildManage/controller/ParkInfoController.java

@@ -133,7 +133,7 @@ public class ParkInfoController extends BaseController {
     }
 
     /**
-     * 楼导入
+     * 楼导入
      * @param file
      * @return
      */

+ 46 - 4
pro-base/src/main/java/com/idea/buildManage/controller/ParkRoomController.java

@@ -1,25 +1,35 @@
 package com.idea.buildManage.controller;
 
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageInfo;
+import com.idea.buildManage.excel.ParkInfoExcel;
+import com.idea.buildManage.excel.ParkInfoListener;
+import com.idea.buildManage.excel.ParkRoomExcel;
+import com.idea.buildManage.excel.ParkRoomListener;
 import com.idea.buildManage.model.ParkRoom;
 import com.idea.buildManage.response.ParkRoomResponse;
+import com.idea.buildManage.service.MnpBuildingService;
+import com.idea.buildManage.service.ParkFloorDiscService;
+import com.idea.buildManage.service.ParkInfoService;
 import com.idea.buildManage.service.ParkRoomService;
+import com.idea.util.ExcelUtils;
 import com.rockstar.common.base.BaseController;
 import com.rockstar.common.domain.AjaxResult;
 import com.rockstar.frame.model.extend.DateTrans;
 import com.rockstar.frame.model.extend.TableSplitResult;
 import com.rockstar.frame.model.extend.Tablepar;
 import com.rockstar.shiro.util.ShiroUtils;
+import com.rockstar.system.service.SysDictService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
+import java.io.File;
 import java.util.Date;
 import java.util.List;
 
@@ -34,6 +44,14 @@ public class ParkRoomController extends BaseController {
     //主表
     @Autowired
     private ParkRoomService modelService;
+    @Autowired
+    private MnpBuildingService buildingService;
+    @Autowired
+    private ParkFloorDiscService floorDiscService;
+    @Autowired
+    private ParkInfoService parkInfoService;
+    @Autowired
+    private SysDictService sysDictService;
 
 
     @PostMapping(value = "list",produces = {"application/json;charset=UTF-8"})
@@ -117,5 +135,29 @@ public class ParkRoomController extends BaseController {
         return modelService.getAreaByIds(ids);
     }
 
+    /**
+     * 房间导入
+     * @param file
+     * @return
+     */
+    @PostMapping(value = "handleImport", produces = {"application/json;charset=UTF-8"})
+    @ResponseBody
+    public AjaxResult handleImport(@RequestParam("file") MultipartFile file) {
+        JSONObject jsonObject = new JSONObject();
+        ParkRoomListener listener = new ParkRoomListener(modelService,buildingService,floorDiscService,parkInfoService,sysDictService,jsonObject);
+        try {
+            ExcelUtils excelUtils = new ExcelUtils();
+            File excel = excelUtils.multipartFileToFile(file);
+            if (null == excel) {
+                return AjaxResult.error("导入失败");
+            }
+            EasyExcel.read(excel, ParkRoomExcel.class, listener).headRowNumber(1).sheet().doRead();
+            excel.delete();
+        } catch (Exception e) {
+            e.printStackTrace();
+            return AjaxResult.error(e.getMessage());
+        }
+        return AjaxResult.success(jsonObject);
+    }
 
 }

+ 10 - 14
pro-base/src/main/java/com/idea/buildManage/excel/MnpBuildingListener.java

@@ -87,10 +87,10 @@ public class MnpBuildingListener extends AnalysisEventListener<MnpBuildingExcel>
                     }
                     data.setGroupId(parkNameIdMap.get(excel.getGroupName()));
                     // 判断分期是否存在
-                    if(StringUtils.isEmpty(discNameIdMap.get(excel.getGroupName()))){
+                    if(StringUtils.isEmpty(discNameIdMap.get(excel.getDiscName()))){
                         throw new RuntimeException("分期不存在");
                     }
-                    data.setDiscId(discNameIdMap.get(excel.getGroupName()));
+                    data.setDiscId(discNameIdMap.get(excel.getDiscName()));
                     // 总面积
                     if (StringUtils.isEmpty(excel.getArea())) {
                         throw new RuntimeException("总面积为空");
@@ -137,21 +137,17 @@ public class MnpBuildingListener extends AnalysisEventListener<MnpBuildingExcel>
                         throw new RuntimeException("地下面积格式有误");
                     }
                     // 房号
-                    if (StringUtils.isNotEmpty(excel.getRoomNum())) {
-                        data.setRoomNum(excel.getRoomNum());
-                    }
-                    // 房号
-                    if (StringUtils.isNotEmpty(excel.getRoomNum())) {
+                    if (StringUtils.isEmpty(excel.getRoomNum())) {
                         throw new RuntimeException("房号为空");
                     }
                     data.setRoomNum(excel.getRoomNum());
                     // 套数
-                    if (StringUtils.isNotEmpty(excel.getNumberInfo())) {
+                    if (StringUtils.isEmpty(excel.getNumberInfo())) {
                         throw new RuntimeException("套数为空");
                     }
                     data.setNumberInfo(excel.getNumberInfo());
                     // 总层数
-                    if (StringUtils.isNotEmpty(excel.getFloors())) {
+                    if (StringUtils.isEmpty(excel.getFloors())) {
                         throw new RuntimeException("总层数为空");
                     }
                     try {
@@ -160,7 +156,7 @@ public class MnpBuildingListener extends AnalysisEventListener<MnpBuildingExcel>
                         throw new RuntimeException("总层数格式有误");
                     }
                     // 地上层数
-                    if (StringUtils.isNotEmpty(excel.getOvergroundFloors())) {
+                    if (StringUtils.isEmpty(excel.getOvergroundFloors())) {
                         throw new RuntimeException("地上层数为空");
                     }
                     try {
@@ -169,7 +165,7 @@ public class MnpBuildingListener extends AnalysisEventListener<MnpBuildingExcel>
                         throw new RuntimeException("地上层数格式有误");
                     }
                     // 地下层数
-                    if (StringUtils.isNotEmpty(excel.getUndergroundFloors())) {
+                    if (StringUtils.isEmpty(excel.getUndergroundFloors())) {
                         throw new RuntimeException("地下层数为空");
                     }
                     try {
@@ -178,7 +174,7 @@ public class MnpBuildingListener extends AnalysisEventListener<MnpBuildingExcel>
                         throw new RuntimeException("地下层数格式有误");
                     }
                     // 结构
-                    if (StringUtils.isNotEmpty(excel.getStructure())) {
+                    if (StringUtils.isEmpty(excel.getStructure())) {
                         throw new RuntimeException("结构为空");
                     }
                     for (Map<String, String> stringStringMap : buildStructure) {
@@ -191,12 +187,12 @@ public class MnpBuildingListener extends AnalysisEventListener<MnpBuildingExcel>
                         throw new RuntimeException("第" + (i + 3) + "行,入驻类型格式有误");
                     }
                     // 行政区划
-                    if (StringUtils.isNotEmpty(excel.getRegionalismCode())) {
+                    if (StringUtils.isEmpty(excel.getRegionalismCode())) {
                         throw new RuntimeException("行政区划为空");
                     }
                     data.setRegionalismCode(excel.getRegionalismCode());
                     // 地号
-                    if (StringUtils.isNotEmpty(excel.getLandCode())) {
+                    if (StringUtils.isEmpty(excel.getLandCode())) {
                         throw new RuntimeException("地号为空");
                     }
                     data.setLandCode(excel.getLandCode());

+ 1 - 0
pro-base/src/main/java/com/idea/buildManage/excel/ParkInfoListener.java

@@ -90,6 +90,7 @@ public class ParkInfoListener extends AnalysisEventListener<ParkInfoExcel> {
                         throw new RuntimeException("预销售许可证编号为空");
                     }
                     data.setPreSalesLicenseNumber(excel.getPreSalesLicenseNumber());
+                    // TODO: 2024/9/11 开发公司 
                     // 楼盘面积测绘状态
                     if(StringUtils.isEmpty(excel.getAreaStatus())){
                         throw new RuntimeException("性质为空");

+ 33 - 33
pro-base/src/main/java/com/idea/buildManage/excel/ParkRoomListener.java

@@ -38,8 +38,9 @@ public class ParkRoomListener extends AnalysisEventListener<ParkRoomExcel> {
     private SysDictService sysDictService;
 
 
-    public ParkRoomListener(MnpBuildingService buildingService, ParkFloorDiscService floorDiscService,
-                            ParkInfoService parkInfoService, SysDictService sysDictService, JSONObject jsonObject) {
+    public ParkRoomListener(ParkRoomService roomService, MnpBuildingService buildingService, ParkFloorDiscService floorDiscService,
+                            ParkInfoService parkInfoService,SysDictService sysDictService, JSONObject jsonObject) {
+        this.roomService = roomService;
         this.buildingService = buildingService;
         this.floorDiscService = floorDiscService;
         this.parkInfoService = parkInfoService;
@@ -90,14 +91,15 @@ public class ParkRoomListener extends AnalysisEventListener<ParkRoomExcel> {
                     }
                     data.setGroupId(parkNameIdMap.get(excel.getGroupName()));
                     // 判断分期是否存在
-                    if(StringUtils.isEmpty(discNameIdMap.get(excel.getGroupName()))){
+                    if(StringUtils.isEmpty(discNameIdMap.get(excel.getDiscName()))){
                         throw new RuntimeException("分期不存在");
                     }
-                    data.setDiscId(discNameIdMap.get(excel.getGroupName()));
+                    data.setDiscId(discNameIdMap.get(excel.getDiscName()));
                     // 判断楼栋是否存在
                     if(StringUtils.isEmpty(buildNameIdMap.get(excel.getBuildNum()))){
                         throw new RuntimeException("楼栋不存在");
                     }
+                    data.setBuildId(buildNameIdMap.get(excel.getBuildNum()));
                     // 户室号
                     if (StringUtils.isEmpty(excel.getRoomNo())) {
                         throw new RuntimeException("户室号为空");
@@ -183,50 +185,48 @@ public class ParkRoomListener extends AnalysisEventListener<ParkRoomExcel> {
                     }
                     // 用途
                     if (StringUtils.isNotEmpty(excel.getRoomUse())) {
-                        throw new RuntimeException("用途为空");
-                    }
-                    for (Map<String, String> stringStringMap : houseUsage) {
-                        if (stringStringMap.get("label").equals(excel.getRoomUse())) {
-                            data.setRoomUse(Integer.valueOf(stringStringMap.get("value")));
+                        for (Map<String, String> stringStringMap : houseUsage) {
+                            if (stringStringMap.get("label").equals(excel.getRoomUse())) {
+                                data.setRoomUse(Integer.valueOf(stringStringMap.get("value")));
+                            }
+                        }
+                        // 没匹配上的情况
+                        if(data.getRoomUse() == null){
+                            throw new RuntimeException("用途格式有误");
                         }
-                    }
-                    // 没匹配上的情况
-                    if(data.getRoomUse() == null){
-                        throw new RuntimeException("用途格式有误");
                     }
                     // 户编号
-                    if (StringUtils.isNotEmpty(excel.getRoomNumber())) {
+                    if (StringUtils.isEmpty(excel.getRoomNumber())) {
                         throw new RuntimeException("户编号为空");
                     }
                     data.setRoomNumber(excel.getRoomNumber());
                     // 装修情况
                     if (StringUtils.isNotEmpty(excel.getDecorationSituation())) {
-                        throw new RuntimeException("装修情况为空");
-                    }
-                    for (Map<String, String> stringStringMap : decorationSituation) {
-                        if (stringStringMap.get("label").equals(excel.getDecorationSituation())) {
-                            data.setDecorationSituation(Integer.valueOf(stringStringMap.get("value")));
+                        for (Map<String, String> stringStringMap : decorationSituation) {
+                            if (stringStringMap.get("label").equals(excel.getDecorationSituation())) {
+                                data.setDecorationSituation(Integer.valueOf(stringStringMap.get("value")));
+                            }
+                        }
+                        // 没匹配上的情况
+                        if(data.getDecorationSituation() == null){
+                            throw new RuntimeException("装修情况格式有误");
                         }
                     }
-                    // 没匹配上的情况
-                    if(data.getDecorationSituation() == null){
-                        throw new RuntimeException("装修情况格式有误");
-                    }
-                    data.setRemark(excel.getRemark());
                     // 可售状态
                     if (StringUtils.isNotEmpty(excel.getSaleStatus())) {
-                        throw new RuntimeException("可售状态为空");
-                    }
-                    for (Map<String, String> stringStringMap : saleStatus) {
-                        if (stringStringMap.get("label").equals(excel.getSaleStatus())) {
-                            data.setSaleStatus(Integer.valueOf(stringStringMap.get("value")));
+                        for (Map<String, String> stringStringMap : saleStatus) {
+                            if (stringStringMap.get("label").equals(excel.getSaleStatus())) {
+                                data.setSaleStatus(Integer.valueOf(stringStringMap.get("value")));
+                            }
+                        }
+                        // 没匹配上的情况
+                        if(data.getSaleStatus() == null){
+                            throw new RuntimeException("可售状态格式有误");
                         }
                     }
-                    // 没匹配上的情况
-                    if(data.getSaleStatus() == null){
-                        throw new RuntimeException("可售状态格式有误");
-                    }
+                    // TODO: 2024/9/11 户型处理 
                     data.setId(IdUtil.simpleUUID());
+                    data.setRemark(excel.getRemark());
                     data.setCreatedId(ShiroUtils.getUserId());
                     data.setCreatedAt(new Date());
                     list.add(data);