Commit 0f302dad39b52961b57e3e5728e94c7a7cc458df

Authored by 王通
1 parent 3850fbd3

1.加入kafka传电子路单至数据中台

src/main/java/com/bsth/entity/ScheduleRealInfoVo.java
@@ -154,12 +154,10 @@ public class ScheduleRealInfoVo implements Serializable{ @@ -154,12 +154,10 @@ public class ScheduleRealInfoVo implements Serializable{
154 /** 关联的公司名称 */ 154 /** 关联的公司名称 */
155 private String gsName; 155 private String gsName;
156 /** 关联的公司编码 */ 156 /** 关联的公司编码 */
157 - @JsonIgnore  
158 private String gsBm; 157 private String gsBm;
159 /** 关联的分公司名称 */ 158 /** 关联的分公司名称 */
160 private String fgsName; 159 private String fgsName;
161 /** 关联的分公司编码 */ 160 /** 关联的分公司编码 */
162 - @JsonIgnore  
163 private String fgsBm; 161 private String fgsBm;
164 /** 出场顺序号 */ 162 /** 出场顺序号 */
165 @JsonIgnore 163 @JsonIgnore
src/main/java/com/bsth/server_rs/schedule/real/ScheduleRealService.java
@@ -33,8 +33,11 @@ import org.springframework.beans.BeanUtils; @@ -33,8 +33,11 @@ import org.springframework.beans.BeanUtils;
33 import org.springframework.beans.factory.InitializingBean; 33 import org.springframework.beans.factory.InitializingBean;
34 import org.springframework.beans.factory.annotation.Autowired; 34 import org.springframework.beans.factory.annotation.Autowired;
35 import org.springframework.kafka.core.KafkaTemplate; 35 import org.springframework.kafka.core.KafkaTemplate;
  36 +import org.springframework.kafka.support.SendResult;
36 import org.springframework.messaging.Message; 37 import org.springframework.messaging.Message;
37 import org.springframework.stereotype.Component; 38 import org.springframework.stereotype.Component;
  39 +import org.springframework.util.concurrent.ListenableFuture;
  40 +import org.springframework.util.concurrent.ListenableFutureCallback;
38 41
39 import javax.ws.rs.*; 42 import javax.ws.rs.*;
40 import javax.ws.rs.core.MediaType; 43 import javax.ws.rs.core.MediaType;
@@ -331,12 +334,24 @@ public class ScheduleRealService implements InitializingBean { @@ -331,12 +334,24 @@ public class ScheduleRealService implements InitializingBean {
331 ObjectMapper mapper = new ObjectMapper(); 334 ObjectMapper mapper = new ObjectMapper();
332 String json = mapper.writeValueAsString(data); 335 String json = mapper.writeValueAsString(data);
333 logger.info(json); 336 logger.info(json);
334 - kafkaTemplate.send("PDGJ_JQDD", json); 337 + ListenableFuture<SendResult<String, String>> future = kafkaTemplate.send("PDGJ_JQDD", json);
  338 + future.addCallback(new ListenableFutureCallback<SendResult<String, String>>() {
  339 +
  340 + @Override
  341 + public void onSuccess(SendResult<String, String> result) {
  342 +
  343 + }
  344 +
  345 + @Override
  346 + public void onFailure(Throwable ex) {
  347 + logger.error("kafka发送电子路单异常", ex);
  348 + }
  349 + });
335 } 350 }
336 } catch (Exception e) { 351 } catch (Exception e) {
337 logger.error("kafka发电子路单调度异常", e); 352 logger.error("kafka发电子路单调度异常", e);
338 } 353 }
339 } 354 }
340 - }, 1, 4, TimeUnit.MINUTES); 355 + }, 30, 240, TimeUnit.SECONDS);
341 } 356 }
342 } 357 }
src/main/resources/application-prod.properties
@@ -30,7 +30,7 @@ spring.redis.password=bsth_control_001 @@ -30,7 +30,7 @@ spring.redis.password=bsth_control_001
30 spring.redis.port=28008 30 spring.redis.port=28008
31 31
32 #kafka 32 #kafka
33 -spring.kafka.bootstrap-servers=106.54.221.120:9092 33 +spring.kafka.bootstrap-servers=47.102.42.244:9092
34 spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer 34 spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer
35 spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer 35 spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer
36 spring.kafka.producer.buffer-memory=33554432 36 spring.kafka.producer.buffer-memory=33554432