浏览代码

excel导入

LAPTOP-FO2T5SIU\35838 9 月之前
父节点
当前提交
18d1e566e2

+ 44 - 4
pro-base/src/main/java/com/idea/buildManage/controller/MnpBuildingController.java

@@ -1,11 +1,16 @@
 package com.idea.buildManage.controller;
 
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageInfo;
 import com.idea.buildManage.dto.MnpBuildingDto;
+import com.idea.buildManage.excel.MnpBuildingExcel;
+import com.idea.buildManage.excel.MnpBuildingListener;
 import com.idea.buildManage.service.ParkRoomService;
 import com.idea.buildManage.model.MnpBuilding;
 import com.idea.buildManage.model.MnpBuildingExample;
 import com.idea.buildManage.service.MnpBuildingService;
+import com.idea.util.ExcelUtils;
 import com.rockstar.common.base.BaseController;
 import com.rockstar.common.domain.AjaxResult;
 import com.rockstar.frame.model.extend.DateTrans;
@@ -15,11 +20,10 @@ import com.rockstar.shiro.util.ShiroUtils;
 import io.swagger.annotations.Api;
 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 java.io.File;
 import java.util.Date;
 
 /**
@@ -100,4 +104,40 @@ public class MnpBuildingController extends BaseController {
 
         return modelService.excelListAll(model);
     }
+
+    /**
+     * 楼栋导入
+     * @param file
+     * @return
+     */
+    @PostMapping(value = "handleImport", produces = {"application/json;charset=UTF-8"})
+    @ResponseBody
+    public AjaxResult handleImport(@RequestParam("file") MultipartFile file) {
+        JSONObject jsonObject = new JSONObject();
+        MnpBuildingListener listener = new MnpBuildingListener(jsonObject);
+        try {
+            ExcelUtils excelUtils = new ExcelUtils();
+            File excel = excelUtils.multipartFileToFile(file);
+            if (null == excel) {
+                return AjaxResult.error("导入失败");
+            }
+            EasyExcel.read(excel, MnpBuildingExcel.class, listener).headRowNumber(1).sheet().doRead();
+            excel.delete();
+        } catch (Exception e) {
+            e.printStackTrace();
+            return AjaxResult.error(e.getMessage());
+        }
+        return AjaxResult.success(jsonObject);
+    }
+
+
+
+
+
+
+
+
+
+
+
 }

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

@@ -1,9 +1,16 @@
 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.MnpBuildingExcel;
+import com.idea.buildManage.excel.MnpBuildingListener;
+import com.idea.buildManage.excel.ParkFloorDiscExcel;
+import com.idea.buildManage.excel.ParkFloorDiscListener;
 import com.idea.buildManage.response.ParkFloorDiscRespson;
 import com.idea.buildManage.model.ParkFloorDisc;
 import com.idea.buildManage.service.ParkFloorDiscService;
+import com.idea.util.ExcelUtils;
 import com.rockstar.common.base.BaseController;
 import com.rockstar.common.domain.AjaxResult;
 import com.rockstar.frame.model.extend.DateTrans;
@@ -13,11 +20,10 @@ 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 java.io.File;
 import java.util.Date;
 
 /**
@@ -90,4 +96,31 @@ public class ParkFloorDiscController extends BaseController {
         return  result;
     }
 
+    /**
+     * 楼栋导入
+     * @param file
+     * @return
+     */
+    @PostMapping(value = "handleImport", produces = {"application/json;charset=UTF-8"})
+    @ResponseBody
+    public AjaxResult handleImport(@RequestParam("file") MultipartFile file) {
+        JSONObject jsonObject = new JSONObject();
+        ParkFloorDiscListener listener = new ParkFloorDiscListener(jsonObject);
+        try {
+            ExcelUtils excelUtils = new ExcelUtils();
+            File excel = excelUtils.multipartFileToFile(file);
+            if (null == excel) {
+                return AjaxResult.error("导入失败");
+            }
+            EasyExcel.read(excel, ParkFloorDiscExcel.class, listener).headRowNumber(1).sheet().doRead();
+            excel.delete();
+        } catch (Exception e) {
+            e.printStackTrace();
+            return AjaxResult.error(e.getMessage());
+        }
+        return AjaxResult.success(jsonObject);
+    }
+
+
+
 }

+ 68 - 0
pro-base/src/main/java/com/idea/buildManage/excel/MnpBuildingExcel.java

@@ -0,0 +1,68 @@
+package com.idea.buildManage.excel;
+
+import com.alibaba.excel.annotation.ExcelIgnore;
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.Data;
+
+@Data
+public class MnpBuildingExcel {
+
+    @ExcelProperty(value = "楼盘/小区名称")
+    private String groupName;
+
+    @ExcelProperty(value = "分期名称")
+    private String discName;
+
+    @ExcelProperty(value = "单元/楼栋号")
+    private String buildNum;
+
+    @ExcelProperty(value = "总面积(㎡)")
+    private String area;
+
+    @ExcelProperty(value = "住宅面积(㎡)")
+    private String residentialArea;
+
+    @ExcelProperty(value = "非住宅面积(㎡)")
+    private String unResidentialArea;
+
+    @ExcelProperty(value = "占地面积(㎡)")
+    private String coverAnArea;
+
+    @ExcelProperty(value = "地下面积(㎡)")
+    private String undergroundArea;
+
+    @ExcelProperty(value = "房号")
+    private String roomNum;
+
+    @ExcelProperty(value = "套数")
+    private String numberInfo;
+
+    @ExcelProperty(value = "总层数")
+    private String floors;
+
+    @ExcelProperty(value = "地上层数")
+    private String overgroundFloors;
+
+    @ExcelProperty(value = "地下层数")
+    private String undergroundFloors;
+
+    @ExcelProperty(value = "结构")
+    private String structure;
+
+    @ExcelProperty(value = "行政区划")
+    private String regionalismCode;
+
+    @ExcelProperty(value = "地号")
+    private String landCode;
+
+    @ExcelProperty(value = "备注")
+    private String remark;
+
+    @ExcelProperty(value = "标准价格参考层及差价系数备注说明")
+    private String priceRemark;
+
+    @ExcelIgnore
+    private String reason;
+
+
+}

+ 126 - 0
pro-base/src/main/java/com/idea/buildManage/excel/MnpBuildingListener.java

@@ -0,0 +1,126 @@
+package com.idea.buildManage.excel;
+
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.event.AnalysisEventListener;
+import com.alibaba.fastjson.JSONObject;
+import com.idea.buildManage.model.MnpBuilding;
+import com.idea.buildManage.service.MnpBuildingService;
+import com.idea.buildManage.service.ParkFloorDiscService;
+import com.idea.buildManage.service.ParkInfoService;
+import com.rockstar.frame.service.FrameUserService;
+import com.rockstar.system.service.SysDictService;
+import com.rockstar.util.StringUtils;
+import org.apache.commons.collections.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class MnpBuildingListener extends AnalysisEventListener<MnpBuildingExcel> {
+
+    private List<MnpBuilding> list = new ArrayList<>();
+
+    private List<MnpBuildingExcel> excelList = new ArrayList<>();
+
+    private List<MnpBuildingExcel> badList = new ArrayList<>();
+
+    Integer count;
+
+    private JSONObject jsonObject;
+
+    @Autowired
+    private MnpBuildingService buildingService;
+    @Autowired
+    private ParkFloorDiscService floorDiscService;
+    @Autowired
+    private ParkInfoService parkInfoService;
+    @Autowired
+    private SysDictService sysDictService;
+
+
+    public MnpBuildingListener(JSONObject jsonObject) {
+        this.jsonObject = jsonObject;
+    }
+
+
+    @Override
+    public void invoke(MnpBuildingExcel mnpBuildingExcel, AnalysisContext analysisContext) {
+        excelList.add(mnpBuildingExcel);
+    }
+
+    @Override
+    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
+
+        if(CollectionUtils.isNotEmpty(excelList)){
+            MnpBuilding data;
+            MnpBuildingExcel excel = null;
+            Map<String, String> discNameIdMap = floorDiscService.getNameIdMap();
+            Map<String, String> parkNameIdMap = parkInfoService.getNameIdMap();
+            for(int i = 0; i < excelList.size(); i++){
+                try {
+                    data = new MnpBuilding();
+                    excel = excelList.get(i);
+                    if (StringUtils.isEmpty(excel.getGroupName())) {
+                        throw new RuntimeException("楼盘/小区名称为空");
+                    }
+                    data.setGroupName(excel.getGroupName());
+                    if (StringUtils.isEmpty(excel.getDiscName())) {
+                        throw new RuntimeException("分期名称为空");
+                    }
+                    data.setDiscName(excel.getDiscName());
+                    if (StringUtils.isEmpty(excel.getBuildNum())) {
+                        throw new RuntimeException("单元楼栋号为空");
+                    }
+                    data.setBuildNum(excel.getBuildNum());
+                    // 判断小区是否存在
+                    if(StringUtils.isEmpty(parkNameIdMap.get(excel.getGroupName()))){
+                        throw new RuntimeException("楼盘/小区不存在");
+                    }
+                    data.setGroupId(parkNameIdMap.get(excel.getGroupName()));
+                    // 判断分期是否存在
+                    if(StringUtils.isEmpty(discNameIdMap.get(excel.getGroupName()))){
+                        throw new RuntimeException("分期不存在");
+                    }
+                    data.setDiscId(discNameIdMap.get(excel.getGroupName()));
+                    // 总面积
+                    if (StringUtils.isEmpty(excel.getArea())) {
+                        throw new RuntimeException("总面积为空");
+                    }
+                    // 住宅面积
+                    if (StringUtils.isEmpty(excel.getResidentialArea())) {
+                        throw new RuntimeException("住宅面积为空");
+                    }
+
+
+                    count = list.size();
+                    jsonObject.put("successCount", count);
+                    jsonObject.put("errorList", badList);
+                    jsonObject.put("errorCount", badList.size());
+                    //保存
+                    saveData();
+
+                    excelList.clear();
+                    list.clear();
+
+                }catch (Exception e){
+                    e.printStackTrace();
+                    String message = e.getMessage();
+                    excel.setReason(message);
+                    badList.add(excel);
+                }
+            }
+        }
+
+    }
+
+    private void saveData(){
+        if (CollectionUtils.isNotEmpty(list)) {
+            buildingService.insertBatch(list);
+        }
+    }
+
+
+}

+ 37 - 0
pro-base/src/main/java/com/idea/buildManage/excel/ParkFloorDiscExcel.java

@@ -0,0 +1,37 @@
+package com.idea.buildManage.excel;
+
+import com.alibaba.excel.annotation.ExcelIgnore;
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.Data;
+
+@Data
+public class ParkFloorDiscExcel {
+
+    @ExcelProperty(value = "楼盘/小区名称")
+    private String groupName;
+
+    @ExcelProperty(value = "分期名称")
+    private String name;
+
+    @ExcelProperty(value = "房屋买卖单价(元/㎡)")
+    private String unitPrice;
+
+    @ExcelProperty(value = "物业费单价(元/㎡)")
+    private String propertyUnitPrice;
+
+    @ExcelProperty(value = "住宅专项维修资金(元/㎡)")
+    private String maintenanceFunds;
+
+    @ExcelProperty(value = "认购金(元)")
+    private String subscriptionFunds;
+
+    @ExcelProperty(value = "共持比例")
+    private String proportion;
+
+    @ExcelProperty(value = "支付方式")
+    private String paymentMethods;
+
+    @ExcelIgnore
+    private String reason;
+
+}

+ 160 - 0
pro-base/src/main/java/com/idea/buildManage/excel/ParkFloorDiscListener.java

@@ -0,0 +1,160 @@
+package com.idea.buildManage.excel;
+
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.event.AnalysisEventListener;
+import com.alibaba.fastjson.JSONObject;
+import com.idea.buildManage.model.ParkFloorDisc;
+import com.idea.buildManage.service.ParkFloorDiscService;
+import com.idea.buildManage.service.ParkInfoService;
+import com.rockstar.system.service.SysDictService;
+import com.rockstar.util.StringUtils;
+import org.apache.commons.collections.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class ParkFloorDiscListener extends AnalysisEventListener<ParkFloorDiscExcel> {
+
+    private List<ParkFloorDisc> list = new ArrayList<>();
+
+    private List<ParkFloorDiscExcel> excelList = new ArrayList<>();
+
+    private List<ParkFloorDiscExcel> badList = new ArrayList<>();
+
+    Integer count;
+
+    private JSONObject jsonObject;
+
+    @Autowired
+    private ParkFloorDiscService floorDiscService;
+    @Autowired
+    private ParkInfoService parkInfoService;
+    @Autowired
+    private SysDictService sysDictService;
+
+
+    public ParkFloorDiscListener(JSONObject jsonObject) {
+        this.jsonObject = jsonObject;
+    }
+
+
+    @Override
+    public void invoke(ParkFloorDiscExcel parkFloorDiscExcel, AnalysisContext analysisContext) {
+        excelList.add(parkFloorDiscExcel);
+    }
+
+    @Override
+    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
+
+        if(CollectionUtils.isNotEmpty(excelList)){
+            ParkFloorDisc data;
+            ParkFloorDiscExcel excel = null;
+            Map<String, String> discNameIdMap = floorDiscService.getNameIdMap();
+            Map<String, String> parkNameIdMap = parkInfoService.getNameIdMap();
+
+            for(int i = 0; i < excelList.size(); i++){
+                try {
+                    data = new ParkFloorDisc();
+                    excel = excelList.get(i);
+                    if(StringUtils.isEmpty(excel.getGroupName())){
+                        throw new RuntimeException("楼盘/小区名称为空");
+                    }
+                    if(StringUtils.isEmpty(excel.getName())){
+                        throw new RuntimeException("楼分期名称为空");
+                    }
+                    // 判断小区是否存在
+                    if(StringUtils.isEmpty(parkNameIdMap.get(excel.getGroupName()))){
+                        throw new RuntimeException("楼盘/小区不存在");
+                    }
+                    data.setGroupId(parkNameIdMap.get(excel.getGroupName()));
+
+                    // 房屋买卖单价
+                    if (StringUtils.isNotEmpty(excel.getUnitPrice())) {
+                        try {
+                            data.setUnitPrice(new BigDecimal(excel.getUnitPrice()));
+                        } catch (NumberFormatException e) {
+                            throw new RuntimeException("房屋买卖单价(元/㎡)格式有误");
+                        }
+                    }
+
+                    // 物业费单价
+                    if (StringUtils.isNotEmpty(excel.getPropertyUnitPrice())) {
+                        try {
+                            data.setPropertyUnitPrice(new BigDecimal(excel.getPropertyUnitPrice()));
+                        } catch (NumberFormatException e) {
+                            throw new RuntimeException("物业费单价(元/㎡)格式有误");
+                        }
+                    }
+
+                    // 住宅专项维修资金
+                    if (StringUtils.isNotEmpty(excel.getMaintenanceFunds())) {
+                        try {
+                            data.setMaintenanceFunds(new BigDecimal(excel.getMaintenanceFunds()));
+                        } catch (NumberFormatException e) {
+                            throw new RuntimeException("住宅专项维修资金(元/㎡)格式有误");
+                        }
+                    }
+
+                    // 认购金
+                    if (StringUtils.isNotEmpty(excel.getSubscriptionFunds())) {
+                        try {
+                            data.setSubscriptionFunds(new BigDecimal(excel.getSubscriptionFunds()));
+                        } catch (NumberFormatException e) {
+                            throw new RuntimeException("认购金(元)格式有误");
+                        }
+                    }
+
+                    // 共持比例
+                    if (StringUtils.isNotEmpty(excel.getProportion())) {
+                        try {
+                            data.setProportion(Double.valueOf(excel.getProportion()));
+                        } catch (NumberFormatException e) {
+                            throw new RuntimeException("共持比例格式有误");
+                        }
+                    }
+
+                    // 支付方式
+                    if (StringUtils.isNotEmpty(excel.getPaymentMethods())) {
+                        try {
+                            data.setPaymentMethods(Integer.valueOf(excel.getPaymentMethods()));
+                        } catch (NumberFormatException e) {
+                            throw new RuntimeException("支付方式格式有误");
+                        }
+                    }
+
+                    count = list.size();
+                    jsonObject.put("successCount", count);
+                    jsonObject.put("errorList", badList);
+                    jsonObject.put("errorCount", badList.size());
+                    //保存
+                    saveData();
+
+                    excelList.clear();
+                    list.clear();
+
+                }catch (Exception e){
+                    e.printStackTrace();
+                    String message = e.getMessage();
+                    excel.setReason(message);
+                    badList.add(excel);
+                }
+            }
+
+
+
+        }
+
+
+    }
+
+    private void saveData(){
+        if (CollectionUtils.isNotEmpty(list)) {
+            floorDiscService.insertBatch(list);
+        }
+    }
+}

+ 4 - 0
pro-base/src/main/java/com/idea/buildManage/mapper/ParkFloorDiscExtendMapper.java

@@ -1,7 +1,9 @@
 package com.idea.buildManage.mapper;
 
+import com.idea.buildManage.model.ParkRoom;
 import com.idea.buildManage.response.ParkFloorDiscRespson;
 import com.idea.buildManage.model.ParkFloorDisc;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -11,4 +13,6 @@ public interface ParkFloorDiscExtendMapper {
 
     List<ParkFloorDisc> selectByGroupId(String id);
 
+    int insertBatch(@Param("list") List<ParkFloorDisc> record);
+
 }

+ 2 - 0
pro-base/src/main/java/com/idea/buildManage/mapper/ParkRoomExtendMapper.java

@@ -1,5 +1,6 @@
 package com.idea.buildManage.mapper;
 
+import com.idea.buildManage.model.MnpBuilding;
 import com.idea.buildManage.model.ParkRoom;
 import com.idea.buildManage.model.ParkRoomExample;
 import com.idea.buildManage.response.ParkRoomResponse;
@@ -13,5 +14,6 @@ public interface ParkRoomExtendMapper {
 
     List<ParkRoomResponse> selectByModel(ParkRoomResponse record);
 
+    int insertBatch(@Param("list") List<ParkRoom> record);
 
 }

+ 12 - 0
pro-base/src/main/java/com/idea/buildManage/service/MnpBuildingService.java

@@ -15,7 +15,9 @@ import com.rockstar.frame.model.extend.DateTrans;
 import com.rockstar.frame.model.extend.Tablepar;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
 
+import java.io.File;
 import java.util.List;
 
 @Service
@@ -143,4 +145,14 @@ public class MnpBuildingService implements BaseService<MnpBuilding, MnpBuildingE
        return extendMapper.selectByContractId(contractId);
     }
 
+    /**
+     * 批量插入
+     * @param list
+     */
+    public void insertBatch(List<MnpBuilding> list){
+        extendMapper.batchInsert(list);
+    }
+
+
+
 }

+ 14 - 0
pro-base/src/main/java/com/idea/buildManage/service/ParkFloorDiscService.java

@@ -20,7 +20,10 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 @Service
 public class ParkFloorDiscService implements BaseService<ParkFloorDisc, ParkFloorDiscExample> {
@@ -206,7 +209,18 @@ public class ParkFloorDiscService implements BaseService<ParkFloorDisc, ParkFloo
         return parkFloorDiscRespson;
     }
 
+    public Map<String,String> getNameIdMap() {
+        Map<String, String> map = new HashMap<>();
+        List<ParkFloorDisc> list = selectByExample(new ParkFloorDiscExample());
+        if (CollectionUtils.isNotEmpty(list)) {
+            map = list.stream().collect(Collectors.toMap(ParkFloorDisc::getName, ParkFloorDisc::getId, (v1, v2) ->v1));
+        }
+        return map;
+    }
 
+    public void insertBatch(List<ParkFloorDisc> list){
+
+    }
 
 
 }

+ 10 - 1
pro-base/src/main/java/com/idea/buildManage/service/ParkInfoService.java

@@ -18,11 +18,13 @@ import com.rockstar.system.model.SysGroupExample;
 import com.rockstar.system.service.SysGroupService;
 import com.rockstar.util.SnowflakeIdWorker;
 import com.rockstar.util.StringUtils;
+import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.beans.Transient;
 import java.util.*;
+import java.util.stream.Collectors;
 
 @Service
 public class ParkInfoService implements BaseService<ParkInfo, ParkInfoExample> {
@@ -344,6 +346,13 @@ public class ParkInfoService implements BaseService<ParkInfo, ParkInfoExample> {
         return map;
     }
 
-
+    public Map<String,String> getNameIdMap() {
+        Map<String, String> map = new HashMap<>();
+        List<ParkInfo> list = selectByExample(new ParkInfoExample());
+        if (CollectionUtils.isNotEmpty(list)) {
+            map = list.stream().collect(Collectors.toMap(ParkInfo::getGroupName, ParkInfo::getId, (v1, v2) ->v1));
+        }
+        return map;
+    }
 
 }

+ 75 - 0
pro-base/src/main/java/com/idea/util/ExcelUtils.java

@@ -0,0 +1,75 @@
+package com.idea.util;
+
+
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.ExcelReader;
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.event.AnalysisEventListener;
+import com.alibaba.excel.read.metadata.ReadSheet;
+import org.springframework.stereotype.Component;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+@Component
+public class ExcelUtils<E> {
+
+    /**
+     * 简单的表格导出工具
+     *
+     * @param list      导出到表格的数据
+     * @param resp      响应对象
+     * @param sheetName 工作表名称
+     * @return 是否导出成功
+     */
+    public boolean excelExport(List<E> list, HttpServletResponse resp, String sheetName) throws IOException {
+        //如果传入信息不正确,直接返回false
+        if (list == null || list.size() == 0 || resp == null) {
+            return false;
+        }
+        //获取传入数据的class对象
+        Class<?> clazz = list.get(0).getClass();
+        //如果工作表名称为空,默认修改为对象名称
+        if (sheetName == null || "".equals(sheetName)) {
+            sheetName = clazz.getSimpleName();
+        }
+        //使用EasyExcel导出数据到表格输出到前端
+        EasyExcel.write(resp.getOutputStream(), clazz).sheet(sheetName).doWrite(list);
+        return true;
+    }
+
+
+    /**
+     * @param inputStream 前端传输文件的输入流
+     * @param clazz       读取表格转换的对象class
+     * @return
+     */
+    public List<E> excelImport(InputStream inputStream, Class<?> clazz) {
+        return EasyExcel.read(inputStream).head(clazz).sheet().doReadSync();
+    }
+
+    /**
+     * @param inputStream 前端传输文件的输入流
+     * @param clazz       读取表格转换的对象class
+     * @param sheetName   读取表格的名称
+     * @return
+     */
+    public List<E> excelImport(InputStream inputStream, Class<?> clazz, String sheetName) {
+        return EasyExcel.read(inputStream).head(clazz).sheet(sheetName).doReadSync();
+    }
+
+    public File multipartFileToFile(MultipartFile file) throws Exception {
+        String fileName = file.getOriginalFilename();
+        String prefix = fileName.substring(fileName.lastIndexOf("."));
+        File file1 = File.createTempFile(fileName, prefix);
+        file.transferTo(file1);
+        return file1;
+    }
+
+}

+ 19 - 9
pro-base/src/main/resources/mybatis/buildManage/MnpBuildingExtendMapper.xml

@@ -2,17 +2,27 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.idea.buildManage.mapper.MnpBuildingExtendMapper">
   <insert id="batchInsert" parameterType="map">
-    <!--@mbg.generated-->
-    insert into idea_micronano_park.mnp_building
-    (ID, QYID, QYMC, SHXYDM, LPMC, LDMC, LCMC, LCQYMC, ROOMNO, ROOMCX, MJ, YT, REMARK, GXRID, GXR,
-    GXSJ, ROOMZP)
+    insert into mnp_building (id, group_id, group_name,
+    disc_id, disc_name, order_num,
+    build_num, construction_num, area,
+    residential_area, un_residential_area, cover_an_area,
+    underground_area, room_num, number_info,
+    floors, overground_floors, underground_floors,
+    structure, regionalism_code, land_code,
+    created_id, created_at, updated_at,
+    updated_id, remark, price_remark
+    )
     values
     <foreach collection="list" item="item" separator=",">
-      (#{item.id,jdbcType=VARCHAR}, #{item.qyid,jdbcType=VARCHAR}, #{item.qymc,jdbcType=VARCHAR},
-      #{item.shxydm,jdbcType=VARCHAR}, #{item.lpmc,jdbcType=VARCHAR}, #{item.ldmc,jdbcType=VARCHAR}, #{item.lcmc,jdbcType=VARCHAR},
-      #{item.lcqymc,jdbcType=VARCHAR}, #{item.roomno,jdbcType=VARCHAR}, #{item.roomcx,jdbcType=VARCHAR}, #{item.mj,jdbcType=DOUBLE},
-      #{item.yt,jdbcType=VARCHAR}, #{item.remark,jdbcType=VARCHAR}, #{item.gxrid,jdbcType=VARCHAR},
-      #{item.gxr,jdbcType=VARCHAR}, #{item.gxsj,jdbcType=TIMESTAMP}, #{item.roomzp,jdbcType=VARCHAR}
+      (#{id,jdbcType=VARCHAR}, #{groupId,jdbcType=VARCHAR}, #{groupName,jdbcType=VARCHAR},
+      #{discId,jdbcType=VARCHAR}, #{discName,jdbcType=VARCHAR}, #{orderNum,jdbcType=INTEGER},
+      #{buildNum,jdbcType=VARCHAR}, #{constructionNum,jdbcType=VARCHAR}, #{area,jdbcType=DOUBLE},
+      #{residentialArea,jdbcType=DOUBLE}, #{unResidentialArea,jdbcType=DOUBLE}, #{coverAnArea,jdbcType=DOUBLE},
+      #{undergroundArea,jdbcType=DOUBLE}, #{roomNum,jdbcType=VARCHAR}, #{numberInfo,jdbcType=VARCHAR},
+      #{floors,jdbcType=INTEGER}, #{overgroundFloors,jdbcType=INTEGER}, #{undergroundFloors,jdbcType=INTEGER},
+      #{structure,jdbcType=VARCHAR}, #{regionalismCode,jdbcType=VARCHAR}, #{landCode,jdbcType=VARCHAR},
+      #{createdId,jdbcType=VARCHAR}, #{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP},
+      #{updatedId,jdbcType=VARCHAR}, #{remark,jdbcType=LONGVARCHAR}, #{priceRemark,jdbcType=LONGVARCHAR}
       )
     </foreach>
   </insert>

+ 20 - 0
pro-base/src/main/resources/mybatis/buildManage/ParkFloorDiscExtendMapper.xml

@@ -31,4 +31,24 @@
         from park_floor_disc
         where group_id = #{id,jdbcType=VARCHAR}
     </select>
+
+    <insert id="insertBatch">
+        insert into park_floor_disc (id, name, group_id,
+                                     unit_price, property_unit_price, maintenance_funds,
+                                     subscription_funds, proportion, payment_methods,
+                                     created_id, created_at, updated_id,
+                                     updated_at)
+        values
+        <foreach collection="list" item="item" separator=",">
+            (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{groupId,jdbcType=VARCHAR},
+            #{unitPrice,jdbcType=DECIMAL}, #{propertyUnitPrice,jdbcType=DECIMAL}, #{maintenanceFunds,jdbcType=DECIMAL},
+            #{subscriptionFunds,jdbcType=DECIMAL}, #{proportion,jdbcType=DOUBLE}, #{paymentMethods,jdbcType=INTEGER},
+            #{createdId,jdbcType=VARCHAR}, #{createdAt,jdbcType=TIMESTAMP}, #{updatedId,jdbcType=VARCHAR},
+            #{updatedAt,jdbcType=TIMESTAMP})
+        </foreach>
+    </insert>
+
+
+
+
 </mapper>

+ 35 - 0
pro-base/src/main/resources/mybatis/buildManage/ParkRoomExtendMapper.xml

@@ -41,4 +41,39 @@
       </if>
     </where>
   </select>
+
+
+  <insert id="insertBatch">
+
+    insert into park_room (id, build_id, disc_id,
+                           group_id, room_no, floor,
+                           prediction_internal_area, prediction_share_area,
+                           prediction_build_area, prediction_land_area,
+                           actual_internal_area, actual_share_area, actual_build_area,
+                           actual_land_area, room_use, room_number,
+                           decoration_situation, house_type_id, house_type_picture,
+                           created_id, created_at, updated_at,
+                           updated_id, sale_status, sold_status,
+                           two_point_two, remark)
+    values
+    <foreach collection="list" item="item" separator=",">
+      (#{id,jdbcType=VARCHAR}, #{buildId,jdbcType=VARCHAR}, #{discId,jdbcType=VARCHAR},
+      #{groupId,jdbcType=VARCHAR}, #{roomNo,jdbcType=VARCHAR}, #{floor,jdbcType=VARCHAR},
+      #{predictionInternalArea,jdbcType=DOUBLE}, #{predictionShareArea,jdbcType=DOUBLE},
+      #{predictionBuildArea,jdbcType=DOUBLE}, #{predictionLandArea,jdbcType=DOUBLE},
+      #{actualInternalArea,jdbcType=DOUBLE}, #{actualShareArea,jdbcType=DOUBLE}, #{actualBuildArea,jdbcType=DOUBLE},
+      #{actualLandArea,jdbcType=DOUBLE}, #{roomUse,jdbcType=INTEGER}, #{roomNumber,jdbcType=VARCHAR},
+      #{decorationSituation,jdbcType=INTEGER}, #{houseTypeId,jdbcType=VARCHAR}, #{houseTypePicture,jdbcType=VARCHAR},
+      #{createdId,jdbcType=VARCHAR}, #{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP},
+      #{updatedId,jdbcType=VARCHAR}, #{saleStatus,jdbcType=INTEGER}, #{soldStatus,jdbcType=INTEGER},
+      #{twoPointTwo,jdbcType=VARCHAR}, #{remark,jdbcType=LONGVARCHAR})
+    </foreach>
+  </insert>
+
+
+
+
+
+
+
 </mapper>