瀏覽代碼

Merge branch '20200908' of http://114.135.61.188:53000/ZONIOT/water-iot into 20200908

Xiaojh 4 年之前
父節點
當前提交
fab15c78cf
共有 19 個文件被更改,包括 240 次插入43 次删除
  1. 2 1
      smart-city-platform/src/main/java/com/bz/smart_city/commom/security/WebSecurityConfig.java
  2. 11 0
      smart-city-platform/src/main/java/com/bz/smart_city/controller/DeviceController.java
  3. 3 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/DeviceValveRecordMapper.java
  4. 14 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/ValveCommandRequestDTO.java
  5. 21 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/udip/CommandRspNotifyResult.java
  6. 3 0
      smart-city-platform/src/main/java/com/bz/smart_city/entity/WaterMeterErrorDays.java
  7. 3 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/DeviceService.java
  8. 1 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/DeviceValveRecordService.java
  9. 75 27
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceServiceImpl.java
  10. 4 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceValveRecordServiceImpl.java
  11. 11 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/WaterMeterReplaceLogServiceImpl.java
  12. 23 10
      smart-city-platform/src/main/java/com/bz/smart_city/service/udip/EasylinkinUtils.java
  13. 10 3
      smart-city-platform/src/main/java/com/bz/smart_city/service/udip/GdAgentUtils.java
  14. 51 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/udip/UdipEtlDataCommandService.java
  15. 1 0
      smart-city-platform/src/main/resources/application-dev.properties
  16. 1 0
      smart-city-platform/src/main/resources/application-prd.properties
  17. 1 0
      smart-city-platform/src/main/resources/application-sit.properties
  18. 1 1
      smart-city-platform/src/main/resources/application.properties
  19. 4 0
      smart-city-platform/src/main/resources/mapper/DeviceValveRecordMapper.xml

+ 2 - 1
smart-city-platform/src/main/java/com/bz/smart_city/commom/security/WebSecurityConfig.java

@@ -102,7 +102,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                 .antMatchers("/printinvoice/InvoicePrintRequest","/common/getAllArea","/mobile/assistant/getMeterTypes")
                 .antMatchers("/waterMeter/getMeterByDeviceNo")
                 .antMatchers("/device/synArchies","/installPlan/syncPlan")
-                .antMatchers("/druid/**").antMatchers("/syncData/**");
+                .antMatchers("/druid/**").antMatchers("/syncData/**")
+                .antMatchers("/device/valve/update");
 
     }
 

+ 11 - 0
smart-city-platform/src/main/java/com/bz/smart_city/controller/DeviceController.java

@@ -5,6 +5,7 @@ import com.bz.smart_city.commom.model.Pagination;
 import com.bz.smart_city.commom.model.ResultStatus;
 import com.bz.smart_city.commom.util.UserUtil;
 import com.bz.smart_city.dto.*;
+import com.bz.smart_city.dto.udip.CommandRspNotifyResult;
 import com.bz.smart_city.entity.Device;
 import com.bz.smart_city.entity.WaterRelatedDevice;
 import com.bz.smart_city.service.BuildingService;
@@ -368,4 +369,14 @@ public class DeviceController {
         return new AjaxMessage<>(ResultStatus.OK,msg);
     }
 
+    @ResponseBody
+    @PostMapping("/valve/update")
+    @ApiOperation(value = "开关阀门")
+    public AjaxMessage valveUpdate(
+            @ApiParam(value = "结果", required = true) @RequestBody(required = true) CommandRspNotifyResult result
+    ) {
+        deviceService.valveUpdate(result);
+        return new AjaxMessage(ResultStatus.OK);
+    }
+
 }

+ 3 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/DeviceValveRecordMapper.java

@@ -2,10 +2,13 @@ package com.bz.smart_city.dao;
 
 import com.bz.smart_city.entity.DeviceValveRecord;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 @Mapper
 public interface DeviceValveRecordMapper {
     int insertSelective(DeviceValveRecord record);
 
     int updateByPrimaryKeySelective(DeviceValveRecord record);
+
+    DeviceValveRecord findByCommandId(@Param("commandId") String commandId);
 }

+ 14 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/ValveCommandRequestDTO.java

@@ -0,0 +1,14 @@
+package com.bz.smart_city.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@ApiModel("阀门命令请求")
+@Data
+public class ValveCommandRequestDTO {
+    @ApiModelProperty(name = "水表编码,设备唯一标识" , required = true)
+    String meterCode;
+    @ApiModelProperty(name = "阀门状态  0:关阀 1:开阀" , required = true)
+    String valveStatus;
+}

+ 21 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/udip/CommandRspNotifyResult.java

@@ -0,0 +1,21 @@
+package com.bz.smart_city.dto.udip;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class CommandRspNotifyResult implements Serializable {
+
+    @ApiModelProperty("指令ID")
+    String commandId;
+    @ApiModelProperty(value = "水司编码")
+    private String companyCode;
+    @ApiModelProperty(value = "水表编码,设备唯一标识")
+    private String meterCode;
+    @ApiModelProperty(value = "操作结果。0:失败;1:成功")
+    private String resultCode;
+    @ApiModelProperty(value = "阀门状态。0:开阀;1: 关阀;2:阀门异常;-1:不带阀门")
+    private String valveStatus;
+}

+ 3 - 0
smart-city-platform/src/main/java/com/bz/smart_city/entity/WaterMeterErrorDays.java

@@ -26,6 +26,9 @@ public class WaterMeterErrorDays {
     @ApiModelProperty(value="异常结束时间")
     private Integer endDate;
 
+    @ApiModelProperty(value="水表读数")
+    private Double meterReading;
+
     @ApiModelProperty(value="状态")
     private Integer status;
 

+ 3 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/DeviceService.java

@@ -9,6 +9,7 @@ import com.bz.smart_city.dto.*;
 import com.bz.smart_city.dto.assistant.InstallListDTO;
 import com.bz.smart_city.dto.assistant.PlanBuildingDTO;
 import com.bz.smart_city.dto.assistant.PlanCommunityDTO;
+import com.bz.smart_city.dto.udip.CommandRspNotifyResult;
 import com.bz.smart_city.entity.Device;
 import com.bz.smart_city.entity.ProgramItem;
 import com.bz.smart_city.entity.Site;
@@ -130,4 +131,6 @@ public interface DeviceService{
     List<DeviceDto> queryDeviceInfoList(String deviceNo, String waterMeterNo);
 
     Integer syncDevice(Long deviceId);
+
+    void valveUpdate(CommandRspNotifyResult result);
 }

+ 1 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/DeviceValveRecordService.java

@@ -8,4 +8,5 @@ public interface DeviceValveRecordService{
 
     int updateByPrimaryKeySelective(DeviceValveRecord record);
 
+    DeviceValveRecord findByCommandId(String commandId);
 }

+ 75 - 27
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceServiceImpl.java

@@ -12,6 +12,7 @@ import com.bz.smart_city.dto.*;
 import com.bz.smart_city.dto.assistant.InstallListDTO;
 import com.bz.smart_city.dto.assistant.PlanBuildingDTO;
 import com.bz.smart_city.dto.assistant.PlanCommunityDTO;
+import com.bz.smart_city.dto.udip.CommandRspNotifyResult;
 import com.bz.smart_city.dto.udip.DataCommandRequestDTO;
 import com.bz.smart_city.entity.*;
 import com.bz.smart_city.excel.download.GdDeviceDownloadExcelTemplate;
@@ -1395,6 +1396,7 @@ public  class DeviceServiceImpl implements DeviceService {
     @Override
     public void setValve(Long deviceId) {
         Device device = deviceMapper.findByDeviceId(deviceId);
+        DeviceTypeDto deviceTypeDto = deviceTypeMapper.getById(device.getDeviceType());
         WaterMeterErrorDays waterMeterErrorDays = waterMeterErrorDaysMapper.findByDeviceId(deviceId);
         String sendValveStatus = "0";
 
@@ -1406,36 +1408,41 @@ public  class DeviceServiceImpl implements DeviceService {
             }
         }
 
-        if(device.getDeviceType()==30){
-            //1、下发开关阀门
-            Map<String,Object> map = new HashMap<>();
-            Map<String,Object> paras = new HashMap<>();
-            paras.put("electronicNo",device.getWaterMeterNo());
-            paras.put("valveStatus", sendValveStatus);//阀门状态  0:关阀 1:开阀
-            map.put("params", paras);
-            map.put("method", "WriteValve");
-            easylinkinUtils.sendDownlink(device.getDeviceNo(),map);
-        }else if(device.getDeviceType()==19)
+        ValveCommandRequestDTO valveCommandRequest = new ValveCommandRequestDTO();
+        valveCommandRequest.setValveStatus(sendValveStatus);
+
+        //1、下发开关阀门
+        if(StringUtils.equals("lora188",deviceTypeDto.getEnModel())){
+            valveCommandRequest.setMeterCode(device.getWaterMeterNo());
+            easylinkinUtils.sendDownlink(device.getDeviceNo(),valveCommandRequest);
+        }else if(StringUtils.equals("hxgd",deviceTypeDto.getEnModel()))
         {
-            Boolean valveStatus = false;
-            if(sendValveStatus.equals("1")){
-                valveStatus = true;
-            }
-            gdAgentUtils.setMeterValve(deviceId,valveStatus);
-        }else
+            valveCommandRequest.setMeterCode(String.valueOf(deviceId));
+            gdAgentUtils.setMeterValve(valveCommandRequest);
+        }
+        else if(StringUtils.equals("hengxin-nb",deviceTypeDto.getEnModel()))
+        {
+            valveCommandRequest.setMeterCode(device.getWaterMeterNo());
+            udipEtlDataCommandService.commandSendV2(device.getUdipId(),valveCommandRequest);
+        }
+        else if(StringUtils.equals("ningbo-nb",deviceTypeDto.getEnModel()))
+        {
+            valveCommandRequest.setMeterCode(device.getWaterMeterNo());
+            JSONObject commandResult = udipEtlDataCommandService.commandSendV2(device.getUdipId(),valveCommandRequest);
+
+            //2、插入开关阀门记录
+            DeviceValveRecord deviceValveRecord = new DeviceValveRecord();
+            deviceValveRecord.setDeviceId(deviceId);
+            deviceValveRecord.setSendValveStatus(Integer.valueOf(sendValveStatus));
+            deviceValveRecord.setSendStatus(1);
+            deviceValveRecord.setCommandId(commandResult.getString("commandId"));
+            deviceValveRecord.setRemark("");
+            deviceValveRecordService.insertSelective(deviceValveRecord);
+        }else if(StringUtils.equals("NB-TJ2.0",deviceTypeDto.getEnModel()))
         {
             if (device.getUdipId() != null && !"".equals(device.getUdipId())) {
-                //1、下发开关阀门
-                Map<String,Object> map = new HashMap<>();
-                map.put("electronicNo","AAAAAAAAAAAAAA");
-                map.put("valveStatus", sendValveStatus);//阀门状态  0:关阀 1:开阀
-                DataCommandRequestDTO dataCommandRequest = new DataCommandRequestDTO();
-                dataCommandRequest.setDeviceId(device.getUdipId());
-                dataCommandRequest.setUnitIdentifier(device.getDeviceNo());
-                dataCommandRequest.setReceiveTime(new Date());
-                dataCommandRequest.setMethod("WriteValve");
-                dataCommandRequest.setParams(map);
-                JSONObject commandResult = udipEtlDataCommandService.commandSend(dataCommandRequest);
+                valveCommandRequest.setMeterCode(device.getDeviceNo());
+                JSONObject commandResult = udipEtlDataCommandService.commandSend(device.getUdipId(),valveCommandRequest);
 
                 //2、插入开关阀门记录
                 DeviceValveRecord deviceValveRecord = new DeviceValveRecord();
@@ -1447,6 +1454,8 @@ public  class DeviceServiceImpl implements DeviceService {
                 deviceValveRecord.setRemark("");
                 deviceValveRecordService.insertSelective(deviceValveRecord);
             }
+        }else {
+
         }
 
 
@@ -1537,4 +1546,43 @@ public  class DeviceServiceImpl implements DeviceService {
             return 0;
         }
     }
+
+    @Override
+    public void valveUpdate(CommandRspNotifyResult result) {
+        log.info("begin valveUpdate result={}",JSON.toJSONString(result));
+        DeviceValveRecord deviceValveRecord = deviceValveRecordService.findByCommandId(result.getCommandId());
+        if (deviceValveRecord != null) {
+
+            WaterMeterErrorDays waterMeterErrorDays = waterMeterErrorDaysMapper.findByDeviceId(deviceValveRecord.getDeviceId());
+            Integer valveStatus = 0;
+            if("0".equals(result.getValveStatus())){
+                valveStatus = 1;//0开,1关,2故障
+            }else if("1".equals(result.getValveStatus())) {
+                valveStatus = 0;
+            }else {
+
+            }
+            deviceValveRecord.setCommandStatus(result.getResultCode());
+            deviceValveRecord.setDateUpdate(LocalDateTime.now());
+            deviceValveRecordService.updateByPrimaryKeySelective(deviceValveRecord);
+
+
+
+
+            WaterMeterErrorDays waterMeterErrorDayUpdate = new WaterMeterErrorDays();
+            waterMeterErrorDayUpdate.setDeviceId(deviceValveRecord.getDeviceId());
+            if (waterMeterErrorDays != null) {
+                waterMeterErrorDayUpdate.setValveStatus(valveStatus);
+                waterMeterErrorDaysMapper.updateByPrimaryKeySelective(waterMeterErrorDayUpdate);
+            }else {
+                waterMeterErrorDayUpdate.setValveButtonStatus(1);
+                waterMeterErrorDayUpdate.setValveStatus(valveStatus);
+                waterMeterErrorDayUpdate.setStatus(1);
+                waterMeterErrorDaysMapper.insert(waterMeterErrorDayUpdate);
+            }
+        }
+
+
+        log.info("end valveUpdate");
+    }
 }

+ 4 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceValveRecordServiceImpl.java

@@ -30,4 +30,8 @@ public class DeviceValveRecordServiceImpl implements DeviceValveRecordService{
         return deviceValveRecordMapper.updateByPrimaryKeySelective(record);
     }
 
+    @Override
+    public DeviceValveRecord findByCommandId(String commandId) {
+        return deviceValveRecordMapper.findByCommandId(commandId);
+    }
 }

+ 11 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/WaterMeterReplaceLogServiceImpl.java

@@ -6,6 +6,7 @@ import com.bz.smart_city.commom.model.Pagination;
 import com.bz.smart_city.commom.model.ResultStatus;
 import com.bz.smart_city.commom.util.AssistantUserUtil;
 import com.bz.smart_city.commom.util.ExcelUtil;
+import com.bz.smart_city.commom.util.JacksonUtil;
 import com.bz.smart_city.commom.util.UserUtil;
 import com.bz.smart_city.dao.ChannelDeviceTypeUseMapper;
 import com.bz.smart_city.dao.DeviceMapper;
@@ -23,6 +24,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.apache.kafka.clients.ClientUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.kafka.core.KafkaTemplate;
 import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
@@ -56,6 +58,11 @@ public class WaterMeterReplaceLogServiceImpl implements WaterMeterReplaceLogServ
     private HlhtService hlhtService;
     @Value("${sync.customer.linhe.id}")
     private Integer linheCustomerId;
+    @Autowired(required = false)
+    KafkaTemplate<String, Object> kafkaTemplate;
+
+    @Value("${com.zcxk.kafka.accept_meter_replace.topic}")
+    private String acceptMeterReplaceTopic;
 
 
     @Override
@@ -242,6 +249,10 @@ public class WaterMeterReplaceLogServiceImpl implements WaterMeterReplaceLogServ
         newDevice.setDateUpdate(LocalDateTime.now());
         deviceMapper.updateByPrimaryKeySelective(newDevice);
 
+        // 3、推送换表信息
+        String json = JacksonUtil.obj2String(waterMeterReplaceLog);
+        log.info("acceptData:" + json);
+        kafkaTemplate.send(acceptMeterReplaceTopic,json);
 
         log.info("end submitWaterMeterReplace");
     }

+ 23 - 10
smart-city-platform/src/main/java/com/bz/smart_city/service/udip/EasylinkinUtils.java

@@ -2,6 +2,7 @@ package com.bz.smart_city.service.udip;
 
 import com.bz.smart_city.commom.exception.ServiceException;
 import com.bz.smart_city.commom.util.HttpRequest;
+import com.bz.smart_city.dto.ValveCommandRequestDTO;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
@@ -14,16 +15,9 @@ import java.util.Map;
 @Service
 public class EasylinkinUtils {
 
-    public void sendDownlink(String deviceNo, Map<String, Object> mapData){
-        Lora188Parser lora188Parser = new Lora188Parser();
-        Map<String,Object> resultMap = lora188Parser.protocolToRawData(mapData);
-        Integer status = (Integer) resultMap.get("status");
-        String data = "";
-        if(status == 1){
-            data = (String) resultMap.get("data");
-        }else {
-            throw new ServiceException(-900, "协议解析错误");
-        }
+    public void sendDownlink(String deviceNo, ValveCommandRequestDTO valveCommandRequestDTO){
+
+        String data = parser(valveCommandRequestDTO);
 
         String url = "http://api.easylinkin.com/api/v1/application/downlink?";
         Map<String,Object> map = new HashMap<>();
@@ -48,4 +42,23 @@ public class EasylinkinUtils {
         }
 
     }
+
+    private String parser(ValveCommandRequestDTO valveCommandRequest){
+        Map<String,Object> map = new HashMap<>();
+        Map<String,Object> paras = new HashMap<>();
+        paras.put("electronicNo",valveCommandRequest.getMeterCode());
+        paras.put("valveStatus", valveCommandRequest.getValveStatus());//阀门状态  0:关阀 1:开阀
+        map.put("params", paras);
+        map.put("method", "WriteValve");
+        Lora188Parser lora188Parser = new Lora188Parser();
+        Map<String,Object> resultMap = lora188Parser.protocolToRawData(map);
+        Integer status = (Integer) resultMap.get("status");
+        String data = "";
+        if(status == 1){
+            data = (String) resultMap.get("data");
+            return data;
+        }else {
+            throw new ServiceException(-900, "协议解析错误");
+        }
+    }
 }

+ 10 - 3
smart-city-platform/src/main/java/com/bz/smart_city/service/udip/GdAgentUtils.java

@@ -6,6 +6,7 @@ import com.bz.smart_city.commom.model.AjaxMessage;
 import com.bz.smart_city.dao.ConcentratorCheckMapper;
 import com.bz.smart_city.dao.WaterRelatedDeviceMapper;
 import com.bz.smart_city.dto.DeviceDto;
+import com.bz.smart_city.dto.ValveCommandRequestDTO;
 import com.bz.smart_city.entity.ConcentratorCheck;
 import com.bz.smart_city.entity.Device;
 import com.bz.smart_city.service.ConcentratorCheckService;
@@ -155,11 +156,17 @@ public class GdAgentUtils {
         return null;
     }
     //开关阀门
-    public Integer setMeterValve(Long deviceId, Boolean valveStatus){
-        log.info("begin setMeterValve deviceId={},valveStatus={}",deviceId,valveStatus);
+    public Integer setMeterValve(ValveCommandRequestDTO valveCommandRequest){
+        log.info("begin setMeterValve valveCommandRequest={},",JSON.toJSONString(valveCommandRequest));
+
+        Boolean valveStatus = false;
+        if(valveCommandRequest.getValveStatus().equals("1")){
+            valveStatus = true;
+        }
+
         String url = gdAgentUrl+"/readmeter/setMeterValve?deviceId={deviceId}&valveStatus={valveStatus}";
         Map<String,String> map = new HashMap<String,String>();
-        map.put("deviceId",deviceId.toString());
+        map.put("deviceId",valveCommandRequest.getMeterCode());
         map.put("valveStatus",valveStatus.toString());
         ConcentratorInfo concentratorInfo = restTemplate.getForObject(url, ConcentratorInfo.class,map);
         log.info("concentratorInfo ={}", JSON.toJSONString(concentratorInfo));

+ 51 - 1
smart-city-platform/src/main/java/com/bz/smart_city/service/udip/UdipEtlDataCommandService.java

@@ -7,6 +7,7 @@ import com.bz.smart_city.commom.util.HttpClientUtils;
 import com.bz.smart_city.commom.util.HttpRequest;
 import com.bz.smart_city.dto.DeviceTypeDto;
 import com.bz.smart_city.dto.UdipUnitDTO;
+import com.bz.smart_city.dto.ValveCommandRequestDTO;
 import com.bz.smart_city.dto.udip.DataCommandRequestDTO;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import lombok.extern.slf4j.Slf4j;
@@ -15,6 +16,9 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import java.io.IOException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 
 @Slf4j
 @Service
@@ -24,7 +28,53 @@ public class UdipEtlDataCommandService {
     @Autowired
     ObjectMapper objectMapper;
 
-    public JSONObject commandSend(DataCommandRequestDTO dataCommandRequest){
+    public JSONObject commandSend(String udipId, ValveCommandRequestDTO valveCommandRequest){
+
+        Map<String,Object> map = new HashMap<>();
+        map.put("electronicNo","AAAAAAAAAAAAAA");
+        map.put("valveStatus", valveCommandRequest.getValveStatus());//阀门状态  0:关阀 1:开阀
+        DataCommandRequestDTO dataCommandRequest = new DataCommandRequestDTO();
+        dataCommandRequest.setDeviceId(udipId);
+        dataCommandRequest.setUnitIdentifier(valveCommandRequest.getMeterCode());
+        dataCommandRequest.setReceiveTime(new Date());
+        dataCommandRequest.setMethod("WriteValve");
+        dataCommandRequest.setParams(map);
+
+        String url = unitUrl+"/center/command/send";
+        try {
+            String json = objectMapper.writeValueAsString(dataCommandRequest);
+            log.info("udipUnit json:"+ json);
+            //String result = HttpRequest.doPost(url, JSON.toJSONString(json));
+            String result = HttpClientUtils.doPostWithJson(url, json);
+            log.info("msg result=" + result);
+            JSONObject jsonObject = JSONObject.parseObject(result);
+            Integer status = jsonObject.getInteger("status");
+            if(status == 0){
+                JSONObject data = jsonObject.getJSONObject("data");
+                //return data.getString("commandId");
+                return data;
+            }else {
+                log.debug(jsonObject.getString("msg"));
+                throw new ServiceException(-900, jsonObject.getString("msg"));
+            }
+        } catch (Exception e) {
+            log.debug(e.getMessage());
+            throw new ServiceException(-900, "下发指令错误");
+        }
+    }
+
+    public JSONObject commandSendV2(String udipId, ValveCommandRequestDTO valveCommandRequest){
+
+        Map<String,Object> map = new HashMap<>();
+        map.put("meterCode",valveCommandRequest.getMeterCode());
+        map.put("valveStatus", valveCommandRequest.getValveStatus());//阀门状态  0:关阀 1:开阀
+        DataCommandRequestDTO dataCommandRequest = new DataCommandRequestDTO();
+        dataCommandRequest.setDeviceId(udipId);
+        dataCommandRequest.setUnitIdentifier(valveCommandRequest.getMeterCode());
+        dataCommandRequest.setReceiveTime(new Date());
+        dataCommandRequest.setMethod("WriteValve");
+        dataCommandRequest.setParams(map);
+
         String url = unitUrl+"/center/command/send";
         try {
             String json = objectMapper.writeValueAsString(dataCommandRequest);

+ 1 - 0
smart-city-platform/src/main/resources/application-dev.properties

@@ -130,6 +130,7 @@ spring.kafka.producer.buffer-memory=40960
 com.zcxk.kafka.alarm.topic=sc_alarm_topic_dev
 com.zcxk.kafka.card.topic=sc_card_topic_dev
 com.zcxk.kafka.accept_add_account.topic=sc_accept_add_account_topic_dev
+com.zcxk.kafka.accept_meter_replace.topic=sc_accept_meter_replace_topic_dev
 #\u9AD8\u5FB7\u5730\u56FE
 geomap.apikey=bb218fd3700b37dd1e02872365cab4d5
 geomap.api.url=https://restapi.amap.com/v3/geocode/geo

+ 1 - 0
smart-city-platform/src/main/resources/application-prd.properties

@@ -92,6 +92,7 @@ com.zcxk.kafka.alarm.topic=sc_alarm_topic
 com.zcxk.kafka.card.topic=sc_card_topic
 com.zcxk.redis.websocket.topic=sc_websocket_topic
 com.zcxk.kafka.accept_add_account.topic=sc_accept_add_account_topic
+com.zcxk.kafka.accept_meter_replace.topic=sc_accept_meter_replace_topic
 
 # quartz
 spring.quartz.job-store-type=jdbc

+ 1 - 0
smart-city-platform/src/main/resources/application-sit.properties

@@ -127,6 +127,7 @@ spring.kafka.consumer.enable-auto-commit=true
 com.zcxk.kafka.alarm.topic=sc_alarm_topic_sit
 com.zcxk.kafka.card.topic=sc_card_topic_sit
 com.zcxk.kafka.accept_add_account.topic=sc_accept_add_account_topic_sit
+com.zcxk.kafka.accept_meter_replace.topic=sc_accept_meter_replace_topic_sit
 #kafka producer config
 spring.kafka.producer.retries=0
 spring.kafka.producer.batch-size=4096

+ 1 - 1
smart-city-platform/src/main/resources/application.properties

@@ -1,2 +1,2 @@
 #开发环境:dev  测试环境:sit  线上环境:prd  演示环境:uat
-spring.profiles.active=prd
+spring.profiles.active=dev

+ 4 - 0
smart-city-platform/src/main/resources/mapper/DeviceValveRecordMapper.xml

@@ -136,4 +136,8 @@
     </set>
     where id = #{id}
   </update>
+
+  <select id="findByCommandId" resultMap="BaseResultMap">
+    select <include refid="Base_Column_List"/> from sc_device_valve_record where status = 1 and command_id = #{commandId}
+  </select>
 </mapper>