Преглед на файлове

换表推送和阀门控制

lin преди 4 години
родител
ревизия
d1b94cfbff

+ 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);
 }

+ 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);
 }

+ 40 - 0
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;
@@ -1545,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);
+    }
 }

+ 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>