Browse Source

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

lihui001 3 years ago
parent
commit
ea0fa6e66e

+ 1 - 1
zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/dao/OrgMapper.java

@@ -58,7 +58,7 @@ public interface OrgMapper {
     * @param userCondition:
     * @return java.util.List<com.zcxk.rmcp.core.entity.Org>
     **/
-    List<Org> findList(@Param("userCondition") UserCondition userCondition);
+    List<Org> findList(@Param("orgType") String orgType,@Param("userCondition") UserCondition userCondition);
 
     /**
     * 根据名字查找

+ 1 - 0
zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/mapper/OrgMapper.xml

@@ -305,6 +305,7 @@
   <select id="findList" resultMap="BaseResultMap">
     select * from rmcp_org where STATUS = 1
     <if test="userCondition.tenantId != null">and TENANT_ID = #{userCondition.tenantId}</if>
+    <if test="orgType != null">and ORG_TYPE = #{orgType}</if>
   </select>
 
   <select id="findByName" resultMap="BaseResultMap">

+ 66 - 4
zoniot-rmcp/zoniot-rmcp-dap/src/main/java/com/bz/rmcp/dap/controller/RabbitMqMsgController.java

@@ -5,10 +5,12 @@ import com.bz.rmcp.dap.model.DeviceOrigDataDTO;
 import com.bz.rmcp.dap.model.OfflineData;
 import com.bz.rmcp.dap.mq.MqMessageSender;
 import com.bz.rmcp.dap.service.DeviceDataService;
+import io.swagger.annotations.ApiParam;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.Date;
@@ -37,11 +39,21 @@ public class RabbitMqMsgController {
     @PostMapping("sendDeviceData")
     public void sendDeviceData(){
         Map<String,Object> param = new HashMap<>();
-        param.put("currentQuantity",107.4);
-        param.put("valveState","1");
-        param.put("temp","0");
+
         param.put("WSV",90);
+        param.put("VOL",3.56);
+        param.put("FORCED","0");
+        param.put("DISTURB","0");
+        param.put("OVERDRAFT","0");
+        param.put("ALARM","0");
+        param.put("VOL_STATUS","0");
+        param.put("VALVE","01");
+
+        /*param.put("WSV",90);
+        param.put("VOL_STATUS","0");
         param.put("VALVE","01");
+        param.put("DISTURB","0");
+        param.put("REMOVE_STATUS","0");*/
 
         Map<Date,String> map = new HashMap<>();
         map.put(new Date(), JSON.toJSONString(param));
@@ -49,7 +61,7 @@ public class RabbitMqMsgController {
         DeviceOrigDataDTO dto = new DeviceOrigDataDTO();
         dto.setId(1L);
         dto.setAgentIdentifier("");
-        dto.setDeviceNo("11111111111");
+        dto.setDeviceNo("77777777");
         dto.setMode("");
         dto.setType("");
         dto.setManufacturer("");
@@ -62,4 +74,54 @@ public class RabbitMqMsgController {
 
         deviceDataService.saveDeviceData(dto);
     }
+
+    @PostMapping("sendDeviceLoraData")
+    public void sendDeviceLoraData(
+            @ApiParam(value = "设备编号", required = true) @RequestParam String deviceNo,
+            @ApiParam(value = "json", required = true) @RequestParam(defaultValue = "{\"VOL\":3.56,\"ALARM\":\"0\",\"VOL_STATUS\":\"0\",\"VALVE\":\"01\",\"WSV\":90,\"FORCED\":\"0\",\"DISTURB\":\"0\",\"OVERDRAFT\":\"0\"}") String json
+    ){
+        Map<String,Object> param  = JSON.parseObject(json, HashMap.class);
+        Map<Date,String> map = new HashMap<>();
+        map.put(new Date(), JSON.toJSONString(param));
+
+        DeviceOrigDataDTO dto = new DeviceOrigDataDTO();
+        dto.setId(1L);
+        dto.setAgentIdentifier("");
+        dto.setDeviceNo(deviceNo);
+        dto.setMode("");
+        dto.setType("");
+        dto.setManufacturer("");
+        dto.setOriginalDataFormat("");
+        dto.setOriginalData("");
+        dto.setParsedData(map);
+        dto.setEventTime(new Date());
+        dto.setReceiveTime(new Date());
+        deviceDataService.saveDeviceData(dto);
+
+    }
+
+    @PostMapping("sendDeviceNbData")
+    public void sendDeviceNbData(
+            @ApiParam(value = "设备编号", required = true) @RequestParam String deviceNo,
+            @ApiParam(value = "json", required = true) @RequestParam(defaultValue = "{\"REMOVE_STATUS\":\"0\",\"VOL_STATUS\":\"0\",\"VALVE\":\"01\",\"WSV\":90,\"DISTURB\":\"0\"}") String json
+    ){
+
+        Map<String,Object> param  = JSON.parseObject(json, HashMap.class);
+        Map<Date,String> map = new HashMap<>();
+        map.put(new Date(), JSON.toJSONString(param));
+
+        DeviceOrigDataDTO dto = new DeviceOrigDataDTO();
+        dto.setId(1L);
+        dto.setAgentIdentifier("");
+        dto.setDeviceNo(deviceNo);
+        dto.setMode("");
+        dto.setType("");
+        dto.setManufacturer("");
+        dto.setOriginalDataFormat("");
+        dto.setOriginalData("");
+        dto.setParsedData(map);
+        dto.setEventTime(new Date());
+        dto.setReceiveTime(new Date());
+        deviceDataService.saveDeviceData(dto);
+    }
 }

+ 1 - 1
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/config/ResourceServerConfig.java

@@ -21,7 +21,7 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
             .and()
             .authorizeRequests()
             .antMatchers("/swagger-ui.html","/webjars/**", "/swagger-resources/**",
-                    "/file/**","/test/test",
+                    "/file/**","/test/test","import/downloadFailFile",
                    "/v2/**")
             .permitAll() //配置不需要身份认证的请求路径
             .anyRequest().authenticated() //其他所有访问路径都需要身份认证

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

@@ -39,7 +39,7 @@ public class ImportController {
     @ApiOperation(value = "下载失败列表")
     public void downloadFailFile(
             @ApiParam(value = "id", required = true) @RequestParam(required = true) Integer objId,
-            @ApiParam(value = "access_token", required = true) @RequestParam(required = true) String accessToken,
+            @ApiParam(value = "access_token", required = false) @RequestParam(required = false) String access_token,
             HttpServletRequest request, HttpServletResponse response
     ) {
         importFileService.downloadFailFile(objId,response);

+ 1 - 1
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/excel/download/service/DeviceDownloadExcelServiceImpl.java

@@ -50,7 +50,7 @@ public class DeviceDownloadExcelServiceImpl implements DownloadExcelService {
         data.setDeviceImportDataList(new ArrayList<>());
         data.setProductDataList(convertProductData(productMapper.findList(data.getCategoryId())));
         data.setCommunityDataList(convertCommunityData(communityMapper.listCommunity(new Community(), UserUtil.getCurrentUser().getUserCondition())));
-        data.setOrgDataList(convertOrgData(orgMapper.findList(UserUtil.getCurrentUser().getUserCondition())));
+        data.setOrgDataList(convertOrgData(orgMapper.findList("company",UserUtil.getCurrentUser().getUserCondition())));
     }
 
     private List<CommImportData> convertCommunityData(List<CommunityVo> list){

+ 1 - 1
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/excel/download/service/InstallPlanExcelServiceImpl.java

@@ -43,7 +43,7 @@ public class InstallPlanExcelServiceImpl implements DownloadExcelService {
 
         data.setProductDataList(convertProductData(productMapper.findList(data.getCategoryId())));
         data.setCommunityDataList(convertCommunityData(communityMapper.listCommunity(new Community(), UserUtil.getCurrentUser().getUserCondition())));
-        data.setOrgDataList(convertOrgData(orgMapper.findList(UserUtil.getCurrentUser().getUserCondition())));
+        data.setOrgDataList(convertOrgData(orgMapper.findList("company",UserUtil.getCurrentUser().getUserCondition())));
     }
     private List<CommImportData> convertCommunityData(List<CommunityVo> list){
         return list.stream().map(vo ->new CommImportData(vo.getName(),Math.toIntExact(vo.getId()))).collect(Collectors.toList());

+ 17 - 7
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/excel/resolver/listener/DeviceImportListener.java

@@ -8,6 +8,7 @@ import com.zcxk.core.common.pojo.ResultMessage;
 import com.zcxk.rmcp.web.excel.model.DeviceImportData;
 import com.zcxk.rmcp.web.excel.model.ExcelData;
 import com.zcxk.rmcp.web.service.DeviceService;
+import com.zcxk.rmcp.web.util.Utils;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -27,26 +28,34 @@ public class DeviceImportListener extends AnalysisEventListener<DeviceImportData
     private ExcelData excelData;
 
 
-    public DeviceImportListener(DeviceService deviceService,ExcelData excelData) {
+    public DeviceImportListener(DeviceService deviceService, ExcelData excelData) {
         this.deviceService = deviceService;
         this.excelData = excelData;
     }
 
     @Override
     public void invoke(DeviceImportData data, AnalysisContext analysisContext) {
+        try {
+            if (Utils.checkObjFieldIsNull(data)
+            ) {
+                return;
+            }
+        } catch (IllegalAccessException e) {
+            e.printStackTrace();
+        }
         if (
                 data.getDeviceNo() == null || data.getDeviceTypeName() == null
-                && data.getMeterNo() == null || data.getCompanyOrgName() == null
+                        || data.getMeterNo() == null || data.getCompanyOrgName() == null
         ) {
             data.setRemark("必填项不能为空");
             list.add(data);
             excelData.getFailNum().incrementAndGet();
             return;
         }
-        ResultMessage resultMessage = deviceService.saveExcelData(data,excelData);
-        if(resultMessage.getStatus()){
+        ResultMessage resultMessage = deviceService.saveExcelData(data, excelData);
+        if (resultMessage.getStatus()) {
             excelData.getSuccessNum().incrementAndGet();
-        }else {
+        } else {
             data.setRemark(resultMessage.getMessage());
             list.add(data);
             excelData.getFailNum().incrementAndGet();
@@ -55,9 +64,10 @@ public class DeviceImportListener extends AnalysisEventListener<DeviceImportData
 
     @Override
     public void doAfterAllAnalysed(AnalysisContext analysisContext) {
-        log.info("批量导出设备完成 successNum = {},failNum = {}",excelData.getSuccessNum().get(),excelData.getFailNum().get());
+        log.info("批量导出设备完成 successNum = {},failNum = {}", excelData.getSuccessNum().get(), excelData.getFailNum().get());
     }
-    public List<DeviceImportData> getData(){
+
+    public List<DeviceImportData> getData() {
         return list;
     }
 

+ 22 - 0
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/util/Utils.java

@@ -0,0 +1,22 @@
+package com.zcxk.rmcp.web.util;
+
+import java.lang.reflect.Field;
+
+/**
+ * @author linqingwei
+ * @date 2021-08-25 20:01
+ */
+public class Utils {
+    public static boolean checkObjFieldIsNull(Object obj) throws IllegalAccessException {
+
+        boolean flag = true;
+        for(Field f : obj.getClass().getDeclaredFields()){
+            f.setAccessible(true);
+            if(f.get(obj) == null){
+                flag = false;
+                return flag;
+            }
+        }
+        return flag;
+    }
+}

+ 4 - 3
zoniot-rmcp/zoniot-rmcp-web/src/main/resources/application-sit.properties

@@ -88,9 +88,10 @@ spring.rabbitmq.template.mandatory=true
 spring.data.mongodb.uri=mongodb://10.0.0.63:27017/meter-reading-database
 logging.level.org.springframework.data.mongodb.core=DEBUG
 
-receive.exchange.name=messageExchangeTest
-dispath.routing.key=dipathKeyTest1
-dispath.queue=dispathTest1
+receive.exchange.name=messageExchange
+dispath.routing.key=dipathKey
+dispath.queue=dispath
+
 
 
 ribbon.OkToRetryOnAllOperations=false