소스 검색

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

lihui001 3 년 전
부모
커밋
85c6ccee41
14개의 변경된 파일127개의 추가작업 그리고 10개의 파일을 삭제
  1. 4 0
      zoniot-rmcp/zoniot-rmcp-api/src/main/java/com/zcxk/rmcp/api/enums/RmcpErrorEnum.java
  2. 5 3
      zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/dao/InstallPlanMapper.java
  3. 5 0
      zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/mapper/InstallPlanMapper.xml
  4. 11 1
      zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/mongo/MeterReadRecord.java
  5. 1 1
      zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/controller/ImportController.java
  6. 1 0
      zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/excel/model/InstallPlanInfoData.java
  7. 1 0
      zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/excel/resolver/HandleExcelStrategy.java
  8. 2 1
      zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/excel/resolver/ResolverExcelTemplate.java
  9. 4 3
      zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/excel/resolver/listener/InstallPlanListener.java
  10. 29 0
      zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/excel/resolver/strategy/InstallHandleExcelStrategy.java
  11. 28 1
      zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/excel/resolver/strategy/InstallPlanHandleExcelStrategy.java
  12. 28 0
      zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/excel/resolver/strategy/WaterDeviceHandleExcelStrategy.java
  13. 8 0
      zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/service/install/impl/InstallPlanServiceImpl.java
  14. BIN
      zoniot-rmcp/zoniot-rmcp-web/src/main/resources/excel/installPlanTemplate.xlsx

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

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

+ 5 - 3
zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/dao/InstallPlanMapper.java

@@ -30,9 +30,11 @@ public interface InstallPlanMapper {
 
     StatisticsDeviceStatusVo totalDeviceStatus(@Param("planId") Integer planId);
 
-    InstallDetailDto findDetail(@Param("planId")Integer planId);
+    InstallDetailDto findDetail(@Param("planId") Integer planId);
 
-    int updatePlanStatus(@Param("planId")Integer planId);
+    int updatePlanStatus(@Param("planId") Integer planId);
 
-    int updateAcceptStatus(@Param("planId")Integer planId);
+    int updateAcceptStatus(@Param("planId") Integer planId);
+
+    int findByNameUnique(@Param("tenantId") String tenantId, @Param("planName") String planName);
 }

+ 5 - 0
zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/mapper/InstallPlanMapper.xml

@@ -405,4 +405,9 @@
     WHERE id = #{planId}
     and door_num = (SELECT count(1) FROM rmcp_install_list WHERE install_plan_id =  #{planId} and is_accepted = 1)
   </update>
+
+  <select id="findByNameUnique" resultType="int">
+    select count(1) from rmcp_install_plan where status = 1 and plan_name = #{planName}
+    and tenant_id = #{tenantId}
+  </select>
 </mapper>

+ 11 - 1
zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/mongo/MeterReadRecord.java

@@ -20,7 +20,8 @@ import java.util.List;
 @Data
 @Document(collection = "rmcp_meter_read_record")
 @ToString
-public class MeterReadRecord extends BaseDO {
+public class MeterReadRecord  {
+    private Long id;
 
     @ApiModelProperty(value="年")
     private Integer year;
@@ -85,6 +86,15 @@ public class MeterReadRecord extends BaseDO {
     @ApiModelProperty(value="档案号")
     private String fileNo;
 
+    @ApiModelProperty(value="创建时间")
+    private Date createTime;
+
+    @ApiModelProperty(value="创建人名称")
+    private String creatorName;
+
+    @ApiModelProperty(value="修改时间")
+    private Date updateTime;
+
     @ApiModelProperty(value="抄表数据")
     private List<MeterReadInfo> data;
 

+ 1 - 1
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/controller/ImportController.java

@@ -39,7 +39,7 @@ public class ImportController {
             @ApiParam(value = "文件") @RequestParam MultipartFile file,
             HttpServletRequest request, HttpServletResponse response
     ) {
-        sendOperateLog(importType);
+        //sendOperateLog(importType);
         importFileService.importExcel(categoryId, importType, file);
         return AjaxMessage.success();
     }

+ 1 - 0
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/excel/model/InstallPlanInfoData.java

@@ -8,6 +8,7 @@ import lombok.Data;
  */
 @Data
 public class InstallPlanInfoData {
+    private String installPlanName;
     private String companyName;
     private String deptName;
     private String communityName;

+ 1 - 0
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/excel/resolver/HandleExcelStrategy.java

@@ -5,6 +5,7 @@ import com.zcxk.rmcp.web.excel.model.ExcelData;
 
 public interface HandleExcelStrategy {
     public void handle(ExcelData data);
+    public void handleException(ExcelData data, Exception e);
 
 }
 

+ 2 - 1
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/excel/resolver/ResolverExcelTemplate.java

@@ -27,8 +27,9 @@ public class ResolverExcelTemplate {
         try {
             handleExcelStrategy.handle(data);
         } catch (Exception e) {
-            e.printStackTrace();
+            //e.printStackTrace();
             log.error("read excel error = {} {}" , e.getMessage(), JSON.toJSON(e));
+            handleExcelStrategy.handleException(data,e);
         }finally {
             FileUtil.del(importFile.getImportFilePath());
         }

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

@@ -64,8 +64,8 @@ public class InstallPlanListener extends AnalysisEventListener<InstallPlanExcelD
     @Override
     public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
         log.info("解析到一条头数据:{}", JSON.toJSONString(headMap));
-
         String headName = headMap.get(2);
+        if(StringUtils.equals(headName,"计划名称*")) excelData.getInstallPlanInfoData().setInstallPlanName(headMap.get(3));
         if(StringUtils.equals(headName,"公司*")) excelData.getInstallPlanInfoData().setCompanyName(headMap.get(3));
         if(StringUtils.equals(headName,"部门")) excelData.getInstallPlanInfoData().setDeptName(headMap.get(3));
         if(StringUtils.equals(headName,"小区名称*")) excelData.getInstallPlanInfoData().setCommunityName(headMap.get(3));
@@ -80,11 +80,12 @@ public class InstallPlanListener extends AnalysisEventListener<InstallPlanExcelD
 
 
 
-    @Override
+    /*@Override
     public void onException(Exception exception, AnalysisContext context) throws Exception {
         log.info("InstallPlanListener 解析异常:{}", JSON.toJSONString(exception));
         // TODO: 2021/8/2 生成异常消息
-    }
+
+    }*/
 
     public List<InstallPlanExcelData> getData(){
         return list;

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

@@ -4,6 +4,7 @@ import com.alibaba.excel.EasyExcel;
 import com.alibaba.excel.ExcelReader;
 import com.alibaba.excel.read.metadata.ReadSheet;
 import com.alibaba.fastjson.JSONObject;
+import com.zcxk.core.common.exception.BusinessException;
 import com.zcxk.core.common.pojo.Message;
 import com.zcxk.rmcp.core.entity.ImportFile;
 import com.zcxk.rmcp.web.excel.download.adapter.InstallMeterExcelFillAdapter;
@@ -99,4 +100,32 @@ public class InstallHandleExcelStrategy implements HandleExcelStrategy {
         message.setUserId(data.getImportFile().getUserId());
         messageSendUtil.send(message);
     }
+
+    @Override
+    public void handleException(ExcelData data, Exception e) {
+        if(e instanceof BusinessException){
+            sendExceptionMessage(data,((BusinessException) e).getMsg());
+        }{
+            sendExceptionMessage(data,"读取文件异常");
+        }
+    }
+
+    private void sendExceptionMessage(ExcelData data,String content){
+
+        Map<String,String> variables = new HashMap<>();
+        variables.put("文档名称",data.getImportFile().getImportFileName());
+        variables.put("content", content);
+
+        Message message=new Message();
+        message.setStatus(1);
+        message.setCreateBy("system");
+        message.setTenantId(data.getImportFile().getTenantId());
+        message.setMessageContent(JSONObject.toJSONString(variables));
+        message.setMessageId(UUID.randomUUID().toString());
+        message.setMessageType(9);
+        message.setMessageTemplateId(10);
+        message.setChannel(0);
+        message.setUserId(data.getImportFile().getUserId());
+        messageSendUtil.send(message);
+    }
 }

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

@@ -4,6 +4,7 @@ import com.alibaba.excel.EasyExcel;
 import com.alibaba.excel.ExcelReader;
 import com.alibaba.excel.read.metadata.ReadSheet;
 import com.alibaba.fastjson.JSONObject;
+import com.zcxk.core.common.exception.BusinessException;
 import com.zcxk.core.common.pojo.Message;
 import com.zcxk.rmcp.core.entity.ImportFile;
 import com.zcxk.rmcp.web.excel.download.adapter.InstallPlanExcelFillAdapter;
@@ -51,7 +52,7 @@ public class InstallPlanHandleExcelStrategy implements HandleExcelStrategy {
         CommDataListener communityListener = new CommDataListener();
         CommDataListener orgListener = new CommDataListener();
 
-        ReadSheet readSheet1 = EasyExcel.readSheet(0).head(InstallPlanExcelData.class).headRowNumber(9).registerReadListener(listener).build();
+        ReadSheet readSheet1 = EasyExcel.readSheet(0).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();
@@ -115,5 +116,31 @@ public class InstallPlanHandleExcelStrategy implements HandleExcelStrategy {
         messageSendUtil.send(message);
     }
 
+    @Override
+    public void handleException(ExcelData data, Exception e) {
+        if(e instanceof BusinessException){
+            sendExceptionMessage(data,((BusinessException) e).getMsg());
+        }{
+            sendExceptionMessage(data,"读取文件异常");
+        }
+    }
 
+    private void sendExceptionMessage(ExcelData data,String content){
+
+        Map<String,String> variables = new HashMap<>();
+        variables.put("文档名称",data.getImportFile().getImportFileName());
+        variables.put("content", content);
+
+        Message message=new Message();
+        message.setStatus(1);
+        message.setCreateBy("system");
+        message.setTenantId(data.getImportFile().getTenantId());
+        message.setMessageContent(JSONObject.toJSONString(variables));
+        message.setMessageId(UUID.randomUUID().toString());
+        message.setMessageType(9);
+        message.setMessageTemplateId(10);
+        message.setChannel(0);
+        message.setUserId(data.getImportFile().getUserId());
+        messageSendUtil.send(message);
+    }
 }

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

@@ -4,6 +4,7 @@ import com.alibaba.excel.EasyExcel;
 import com.alibaba.excel.ExcelReader;
 import com.alibaba.excel.read.metadata.ReadSheet;
 import com.alibaba.fastjson.JSONObject;
+import com.zcxk.core.common.exception.BusinessException;
 import com.zcxk.core.common.pojo.Message;
 import com.zcxk.rmcp.core.entity.ImportFile;
 import com.zcxk.rmcp.web.excel.download.adapter.DeviceExcelFillAdapter;
@@ -120,4 +121,31 @@ public class WaterDeviceHandleExcelStrategy implements HandleExcelStrategy {
         messageSendUtil.send(message);
     }
 
+    @Override
+    public void handleException(ExcelData data, Exception e) {
+        if(e instanceof BusinessException){
+            sendExceptionMessage(data,((BusinessException) e).getMsg());
+        }{
+            sendExceptionMessage(data,"读取文件异常");
+        }
+    }
+
+    private void sendExceptionMessage(ExcelData data,String content){
+
+        Map<String,String> variables = new HashMap<>();
+        variables.put("文档名称",data.getImportFile().getImportFileName());
+        variables.put("content", content);
+
+        Message message=new Message();
+        message.setStatus(1);
+        message.setCreateBy("system");
+        message.setTenantId(data.getImportFile().getTenantId());
+        message.setMessageContent(JSONObject.toJSONString(variables));
+        message.setMessageId(UUID.randomUUID().toString());
+        message.setMessageType(9);
+        message.setMessageTemplateId(10);
+        message.setChannel(0);
+        message.setUserId(data.getImportFile().getUserId());
+        messageSendUtil.send(message);
+    }
 }

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

@@ -120,6 +120,10 @@ public class InstallPlanServiceImpl implements InstallPlanService {
         //TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
         Integer planId = null;
         try {
+            if (installPlanMapper.findByNameUnique(dto.getTenantId(), dto.getPlanName()) > 0) {
+                throw BusinessException.builder(RmcpErrorEnum.RMCP_PLAN_NAME_UNIQUE_ERROR);
+            }
+
 
             // 1、小区更新
             Community community = new Community();
@@ -342,6 +346,9 @@ public class InstallPlanServiceImpl implements InstallPlanService {
     @Override
     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);
+        }
         // 2、小区查询
         Community community = null;
         if(StringUtils.isNotEmpty(infoData.getCommunityName())){
@@ -366,6 +373,7 @@ public class InstallPlanServiceImpl implements InstallPlanService {
         if (product == null) throw BusinessException.builder("设备型号不存在");
 
         InstallPlan installPlan = new InstallPlan();
+        installPlan.setPlanName(infoData.getInstallPlanName());
         installPlan.setTenantId(excelData.getImportFile().getTenantId());
         //installPlan.setPlanName(infoData.getCommunityName());
         if(community!=null)installPlan.setCommunityId(community.getId());

BIN
zoniot-rmcp/zoniot-rmcp-web/src/main/resources/excel/installPlanTemplate.xlsx