lin vor 3 Jahren
Ursprung
Commit
c2f74b0d1e

+ 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,"计划名称已经存在"),
 
     /**
      * 未找到相关数据

+ 4 - 3
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;
@@ -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,"读取文件异常");
         }
     }

+ 4 - 3
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;
@@ -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,"读取文件异常");
         }
     }

+ 4 - 3
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;
@@ -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());