Browse Source

换表推送

lin 4 years ago
parent
commit
a306b996e0

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

@@ -3,6 +3,7 @@ package com.bz.smart_city.service.impl;
 import com.alibaba.fastjson.JSON;
 import com.bz.smart_city.commom.exception.ServiceException;
 import com.bz.smart_city.commom.model.ResultStatus;
+import com.bz.smart_city.commom.util.JacksonUtil;
 import com.bz.smart_city.commom.util.UserUtil;
 import com.bz.smart_city.dao.*;
 import com.bz.smart_city.dao.assistant.InstallListMapper;
@@ -16,6 +17,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 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;
@@ -59,6 +61,11 @@ public class WaterMeterMaintenanceLogServiceImpl implements WaterMeterMaintenanc
     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
     public int insert(WaterMeterMaintenanceLog waterMeterMaintenanceLog) {
@@ -220,6 +227,12 @@ public class WaterMeterMaintenanceLogServiceImpl implements WaterMeterMaintenanc
             }
             newDevice.setDateUpdate(LocalDateTime.now());
             deviceMapper.updateByPrimaryKeySelective(newDevice);
+
+
+            // 3、推送换表信息
+            String json = JacksonUtil.obj2String(waterMeterReplaceLog);
+            log.info("acceptData:" + json);
+            kafkaTemplate.send(acceptMeterReplaceTopic,json);
         } else {
             throw new ServiceException(-900, "该工单已经处理");
         }