Procházet zdrojové kódy

修改阀门上报信息

hym před 4 roky
rodič
revize
e56d65b5dd

+ 17 - 0
smart-city-platform/src/main/java/com/bz/smart_city/controller/PlatformApiController.java

@@ -2,6 +2,7 @@ package com.bz.smart_city.controller;
 
 import com.bz.smart_city.commom.model.AjaxMessage;
 import com.bz.smart_city.commom.model.ResultStatus;
+import com.bz.smart_city.commom.util.MessageSend.JSONUtils;
 import com.bz.smart_city.commom.util.UserUtil;
 import com.bz.smart_city.dto.LoginUser;
 import com.bz.smart_city.dto.TodayDynamicDto;
@@ -10,8 +11,13 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.kafka.core.KafkaTemplate;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.HashMap;
+import java.util.Map;
+
 @RestController
 @ResponseBody
 @RequestMapping("/platform")
@@ -19,6 +25,10 @@ import org.springframework.web.bind.annotation.*;
 public class PlatformApiController {
     @Autowired
     private PlatformAapiService platformAapiService;
+    @Autowired
+    KafkaTemplate<String, Object> kafkaTemplate;
+    @Value("${billing.valveStatus.receiving}")
+    private String billingValveStatusReceiving;
     @PostMapping ("/updateMeterNo")
     @ApiOperation(value = "同步档案号")
     public AjaxMessage updateMeterNo(
@@ -43,4 +53,11 @@ public class PlatformApiController {
         System.out.println(waterMeterElectronicNumber);
         return new AjaxMessage<>(ResultStatus.OK,waterMeterElectronicNumber);
     }
+    @GetMapping  ("/testKafka")
+    public void testKafka(String meterNo,String meterStatus){
+        Map<String,Object> valveMessage=new HashMap<>();
+        valveMessage.put("meterNo",meterNo);
+        valveMessage.put("meterStatus",meterStatus);
+        kafkaTemplate.send(billingValveStatusReceiving, JSONUtils.obj2json(valveMessage));
+    }
 }

+ 3 - 2
smart-city-platform/src/main/java/com/bz/smart_city/kafka/consumer/ValveStatusReceiver.java

@@ -25,17 +25,18 @@ public class ValveStatusReceiver {
     private String billingValveStatusReceiving;
     @Autowired
     KafkaTemplate<String, Object> kafkaTemplate;
-    @KafkaListener(topics = {"${com.zcxk.kafka.card.topic}"})
+    @KafkaListener(topics = {"${com.zcxk.kafka.accept_valve_state.topic}"})
     public void pushValveStatusMessage(String message) {
         OperatingValveRecord operatingValveRecord=new OperatingValveRecord();
         operatingValveRecord.setStatus(1);
         List<OperatingValveRecord> operatingValveRecords = operatingValveRecordMapper.selectList(operatingValveRecord);
         OperatingValveRecord operatingValveRecordMessage=null;
+        log.info("上报水表信息");
         if(operatingValveRecords.size()>0){
             ValveControlDataDto valveControlDataDto = JSONUtils.json2pojo(message, ValveControlDataDto.class);
             boolean flag=false;
             for (OperatingValveRecord valveRecord : operatingValveRecords) {
-                if(valveRecord.getWaterNo().equals(valveControlDataDto.getMeterNo())
+                    if(valveRecord.getWaterNo().equals(valveControlDataDto.getMeterNo())
                         &&valveRecord.getCustomerId().equals(valveControlDataDto.getCustomerId())){
                     flag=true;
                     operatingValveRecordMessage=valveRecord;

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

@@ -118,9 +118,9 @@ websocket.so.backlog=100
 
 system.water.meter.lora.code=LORAWM
 #kafka配置
-spring.kafka.bootstrap-servers=193.112.139.7:9092
+spring.kafka.bootstrap-servers=114.135.61.188:36377
 #kafka消费者配置
-spring.kafka.consumer.group-id=api-group-dev
+spring.kafka.consumer.group-id=api-group-dev8
 spring.kafka.consumer.auto-offset-reset=latest
 spring.kafka.consumer.enable-auto-commit=true
 #kafka生产者配置
@@ -131,7 +131,7 @@ 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
-com.zcxk.kafka.valve.status.topic=sc_valve_status_billing
+com.zcxk.kafka.accept_valve_state.topic=sc_accept_valve_state_topic_sit
 billing.valveStatus.receiving=billing_valveStatus_receiving
 #\u9AD8\u5FB7\u5730\u56FE
 geomap.apikey=bb218fd3700b37dd1e02872365cab4d5

+ 1 - 1
smart-city-platform/src/main/resources/mapper/OperatingValveRecordMapper.xml

@@ -144,6 +144,6 @@
     </select>
     <update id="updateStatus">
         update sc_operating_valve_record set status=0,update_date=now() where water_file_no=#{waterFileNo}
-        and customer_id=#{customerId}
+        and customer_id=#{customerId} and status=1
     </update>
 </mapper>

+ 4 - 0
water_query_api/pom.xml

@@ -112,6 +112,10 @@
             <artifactId>guava</artifactId>
             <version>20.0</version>
         </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis</artifactId>
+        </dependency>
     </dependencies>
 
     <build>

+ 18 - 0
water_query_api/src/main/resources/application-dev.properties

@@ -25,6 +25,24 @@ spring.servlet.multipart.max-file-size=100MB
 spring.servlet.multipart.max-request-size=100MB
 spring.servlet.multipart.location=e:/test/files
 
+#spring.redis.password=123456
+spring.redis.sentinel.master=mymaster
+spring.redis.sentinel.nodes=10.0.0.71:26379,10.0.0.72:26379,10.0.0.73:26379
+#连接超时时间
+spring.redis.timeout=6000ms
+##Redis数据库索引(默认为0)
+spring.redis.database=0
+## 连接池配置,springboot2.0中直接使用jedis或者lettuce配置连接池,默认为lettuce连接池
+##连接池最大连接数(使用负值表示没有限制)
+spring.redis.jedis.pool.max-active=8
+##连接池最大阻塞等待时间(使用负值表示没有限制)
+spring.redis.jedis.pool.max-wait=-1s
+##连接池中的最大空闲连接
+spring.redis.jedis.pool.max-idle=8
+##接池中的最小空闲连接
+spring.redis.jedis.pool.min-idle=0
+
+