Przeglądaj źródła

Merge remote-tracking branch 'origin/20210716' into 20210716

lihui001 3 lat temu
rodzic
commit
edbdaac6e8

+ 2 - 2
zoniot-rmcp/zoniot-rmcp-api/src/main/java/com/zcxk/rmcp/api/enums/RmcpErrorEnum.java

@@ -46,9 +46,9 @@ public enum RmcpErrorEnum implements RespCode {
      */
     DOOR_EXISTED(201007,"该单元户已安装水表"),
     /**
-     * 设备编号已经存在!
+     * 计划名称已经存在
      */
-    RMCP_PLAN_NAME_UNIQUE_ERROR(201008,"计划名称已经存在!"),
+    RMCP_PLAN_NAME_UNIQUE_ERROR(201008,"计划名称已经存在"),
 
     /**
      * 未找到相关数据

+ 1 - 1
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/excel/resolver/listener/InstallPlanListener.java

@@ -44,7 +44,7 @@ public class InstallPlanListener extends AnalysisEventListener<InstallPlanExcelD
             excelData.getFailNum().incrementAndGet();
             return;
         }
-        excelData.getSuccessNum().incrementAndGet();
+
         ResultMessage resultMessage = installPlanService.handleExcelData(data,excelData);
         if(resultMessage.getStatus()){
             excelData.getSuccessNum().incrementAndGet();

+ 5 - 4
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/excel/resolver/strategy/InstallHandleExcelStrategy.java

@@ -2,6 +2,7 @@ package com.zcxk.rmcp.web.excel.resolver.strategy;
 
 import com.alibaba.excel.EasyExcel;
 import com.alibaba.excel.ExcelReader;
+import com.alibaba.excel.exception.ExcelAnalysisException;
 import com.alibaba.excel.read.metadata.ReadSheet;
 import com.alibaba.fastjson.JSONObject;
 import com.zcxk.core.common.exception.BusinessException;
@@ -47,7 +48,7 @@ public class InstallHandleExcelStrategy implements HandleExcelStrategy {
         InstallImportListener listener = new InstallImportListener(installListService,data);
 
 
-        ReadSheet readSheet1 = EasyExcel.readSheet(0).head(InstallMeterData.class).headRowNumber(7).registerReadListener(listener).build();
+        ReadSheet readSheet1 = EasyExcel.readSheet("安装计划").head(InstallMeterData.class).headRowNumber(7).registerReadListener(listener).build();
         // 这里注意 一定要把sheet1 sheet2 一起传进去,不然有个问题就是03版的excel 会读取多次,浪费性能
         excelReader.read(readSheet1);
         // 这里千万别忘记关闭,读的时候会创建临时文件,到时磁盘会崩的
@@ -103,9 +104,9 @@ public class InstallHandleExcelStrategy implements HandleExcelStrategy {
 
     @Override
     public void handleException(ExcelData data, Exception e) {
-        if(e instanceof BusinessException){
-            sendExceptionMessage(data,((BusinessException) e).getMsg());
-        }{
+        if(e instanceof ExcelAnalysisException){
+            sendExceptionMessage(data,((ExcelAnalysisException) e).getMessage());
+        }else{
             sendExceptionMessage(data,"读取文件异常");
         }
     }

+ 5 - 4
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/excel/resolver/strategy/InstallPlanHandleExcelStrategy.java

@@ -2,6 +2,7 @@ package com.zcxk.rmcp.web.excel.resolver.strategy;
 
 import com.alibaba.excel.EasyExcel;
 import com.alibaba.excel.ExcelReader;
+import com.alibaba.excel.exception.ExcelAnalysisException;
 import com.alibaba.excel.read.metadata.ReadSheet;
 import com.alibaba.fastjson.JSONObject;
 import com.zcxk.core.common.exception.BusinessException;
@@ -52,7 +53,7 @@ public class InstallPlanHandleExcelStrategy implements HandleExcelStrategy {
         CommDataListener communityListener = new CommDataListener();
         CommDataListener orgListener = new CommDataListener();
 
-        ReadSheet readSheet1 = EasyExcel.readSheet(0).head(InstallPlanExcelData.class).headRowNumber(10).registerReadListener(listener).build();
+        ReadSheet readSheet1 = EasyExcel.readSheet("安装计划模板").head(InstallPlanExcelData.class).headRowNumber(10).registerReadListener(listener).build();
         ReadSheet readSheet2 = EasyExcel.readSheet("公司").head(CommImportData.class).registerReadListener(orgListener).build();
         ReadSheet readSheet3 = EasyExcel.readSheet("小区").head(CommImportData.class).registerReadListener(communityListener).build();
         ReadSheet readSheet4 = EasyExcel.readSheet("设备型号").head(CommImportData.class).registerReadListener(deviceTypeListener).build();
@@ -118,9 +119,9 @@ public class InstallPlanHandleExcelStrategy implements HandleExcelStrategy {
 
     @Override
     public void handleException(ExcelData data, Exception e) {
-        if(e instanceof BusinessException){
-            sendExceptionMessage(data,((BusinessException) e).getMsg());
-        }{
+        if(e instanceof ExcelAnalysisException){
+            sendExceptionMessage(data,((ExcelAnalysisException) e).getMessage());
+        }else{
             sendExceptionMessage(data,"读取文件异常");
         }
     }

+ 8 - 7
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/excel/resolver/strategy/WaterDeviceHandleExcelStrategy.java

@@ -2,6 +2,7 @@ package com.zcxk.rmcp.web.excel.resolver.strategy;
 
 import com.alibaba.excel.EasyExcel;
 import com.alibaba.excel.ExcelReader;
+import com.alibaba.excel.exception.ExcelAnalysisException;
 import com.alibaba.excel.read.metadata.ReadSheet;
 import com.alibaba.fastjson.JSONObject;
 import com.zcxk.core.common.exception.BusinessException;
@@ -55,10 +56,10 @@ public class WaterDeviceHandleExcelStrategy implements HandleExcelStrategy {
         CommDataListener communityListener = new CommDataListener();
         CommDataListener orgListener = new CommDataListener();
 
-        ReadSheet readSheet1 = EasyExcel.readSheet(0).head(DeviceImportData.class).headRowNumber(4).registerReadListener(deviceImportListener).build();
-        ReadSheet readSheet2 = EasyExcel.readSheet(1).head(CommImportData.class).registerReadListener(deviceTypeListener).build();
-        ReadSheet readSheet3 = EasyExcel.readSheet(2).head(CommImportData.class).registerReadListener(orgListener).build();
-        ReadSheet readSheet4 = EasyExcel.readSheet(3).head(CommImportData.class).registerReadListener(communityListener).build();
+        ReadSheet readSheet1 = EasyExcel.readSheet("档案管理-批量导入").head(DeviceImportData.class).headRowNumber(4).registerReadListener(deviceImportListener).build();
+        ReadSheet readSheet2 = EasyExcel.readSheet("设备类型").head(CommImportData.class).registerReadListener(deviceTypeListener).build();
+        ReadSheet readSheet3 = EasyExcel.readSheet("公司").head(CommImportData.class).registerReadListener(orgListener).build();
+        ReadSheet readSheet4 = EasyExcel.readSheet("小区").head(CommImportData.class).registerReadListener(communityListener).build();
         // 这里注意 一定要把sheet1 sheet2 一起传进去,不然有个问题就是03版的excel 会读取多次,浪费性能
         excelReader.read(readSheet1, readSheet2, readSheet3, readSheet4);
         // 这里千万别忘记关闭,读的时候会创建临时文件,到时磁盘会崩的
@@ -123,9 +124,9 @@ public class WaterDeviceHandleExcelStrategy implements HandleExcelStrategy {
 
     @Override
     public void handleException(ExcelData data, Exception e) {
-        if(e instanceof BusinessException){
-            sendExceptionMessage(data,((BusinessException) e).getMsg());
-        }{
+        if(e instanceof ExcelAnalysisException){
+            sendExceptionMessage(data,((ExcelAnalysisException) e).getMessage());
+        }else{
             sendExceptionMessage(data,"读取文件异常");
         }
     }

+ 6 - 5
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/service/install/impl/InstallPlanServiceImpl.java

@@ -1,5 +1,6 @@
 package com.zcxk.rmcp.web.service.install.impl;
 
+import com.alibaba.excel.exception.ExcelAnalysisException;
 import com.alibaba.fastjson.JSON;
 import com.github.pagehelper.PageHelper;
 import com.zcxk.core.common.enums.StatusEnum;
@@ -347,30 +348,30 @@ public class InstallPlanServiceImpl implements InstallPlanService {
     public InstallPlan createPlanExcel(ExcelData excelData) {
         InstallPlanInfoData infoData = excelData.getInstallPlanInfoData();
         if(installPlanMapper.findByNameUnique(excelData.getImportFile().getTenantId(),infoData.getInstallPlanName()) > 0){
-            throw BusinessException.builder(RmcpErrorEnum.RMCP_PLAN_NAME_UNIQUE_ERROR);
+            throw new ExcelAnalysisException(RmcpErrorEnum.RMCP_PLAN_NAME_UNIQUE_ERROR.getMessage());
         }
         // 2、小区查询
         Community community = null;
         if(StringUtils.isNotEmpty(infoData.getCommunityName())){
             community = communityService.findByName(excelData.getImportFile().getTenantId(),infoData.getCommunityName());
-            if (community == null) throw BusinessException.builder("小区不存在");
+            if (community == null) throw new ExcelAnalysisException("小区不存在");
         }
 
 
         // 3、公司部门查询
         Org companyOrg = orgService.findByName(excelData.getImportFile().getTenantId(),infoData.getCompanyName());
-        if (companyOrg == null) throw BusinessException.builder("公司不存在");
+        if (companyOrg == null) throw new ExcelAnalysisException("公司不存在");
 
         Org deptOrg = null;
         if(StringUtils.isNotEmpty(infoData.getDeptName())){
             deptOrg = orgService.findByParentIdAndName(companyOrg.getId(),infoData.getDeptName());
-            if (deptOrg == null) throw BusinessException.builder("部门不存在");
+            if (deptOrg == null) throw new ExcelAnalysisException("部门不存在");
         }
 
         // 4、产品(设备类型)查询
         String[] deviceType  = StringUtils.split(infoData.getDeviceTypeName(),"/");
         Product product = productService.getByName(deviceType[1],deviceType[2]);
-        if (product == null) throw BusinessException.builder("设备型号不存在");
+        if (product == null) throw new ExcelAnalysisException("设备型号不存在");
 
         InstallPlan installPlan = new InstallPlan();
         installPlan.setPlanName(infoData.getInstallPlanName());