提交 925554b9 作者: chenshiqiang

send data from excel to kafka for python

上级 a025c86b
...@@ -102,6 +102,7 @@ public class Knowledge implements Serializable { ...@@ -102,6 +102,7 @@ public class Knowledge implements Serializable {
* 知识库id * 知识库id
*/ */
private String kbKnowledgeId; private String kbKnowledgeId;
private String content;
/** /**
* 类型 * 类型
*/ */
......
...@@ -3,6 +3,8 @@ package com.zzsn.knowbase.kafka.cloudstream; ...@@ -3,6 +3,8 @@ package com.zzsn.knowbase.kafka.cloudstream;
import org.springframework.cloud.stream.annotation.Output; import org.springframework.cloud.stream.annotation.Output;
import org.springframework.messaging.MessageChannel; import org.springframework.messaging.MessageChannel;
import java.net.DatagramSocket;
/** /**
* @author chenshiqiang * @author chenshiqiang
* @Description 知识信息通道 * @Description 知识信息通道
...@@ -18,5 +20,6 @@ public interface KnowledgeChannel { ...@@ -18,5 +20,6 @@ public interface KnowledgeChannel {
@Output @Output
MessageChannel knowledgeContents(); MessageChannel knowledgeContents();
@Output
MessageChannel knowledgeExcelContents();
} }
...@@ -32,4 +32,10 @@ public class ProduceInfo { ...@@ -32,4 +32,10 @@ public class ProduceInfo {
Message<String> message = MessageBuilder.withPayload(msg).build(); Message<String> message = MessageBuilder.withPayload(msg).build();
channel.knowledgeContents().send(message); channel.knowledgeContents().send(message);
} }
public void sendKnowledgeExcelContents(KnowledgeMessage knowledgeMessage) {
String msg = JSON.toJSONString(knowledgeMessage);
Message<String> message = MessageBuilder.withPayload(msg).build();
channel.knowledgeExcelContents().send(message);
}
} }
...@@ -518,6 +518,9 @@ class KnowledgeServiceImpl implements IKnowledgeService { ...@@ -518,6 +518,9 @@ class KnowledgeServiceImpl implements IKnowledgeService {
continue; continue;
} }
if (StringUtils.isNotEmpty(info.get(1))) { if (StringUtils.isNotEmpty(info.get(1))) {
specialInformation.setContent(info.get(1));
//段落切分
specialInformation.setContents(Collections.singletonList(Content.builder() specialInformation.setContents(Collections.singletonList(Content.builder()
.contentId(codeGenerateUtil.geneIdNo(Constants.FINANCE, 8)) .contentId(codeGenerateUtil.geneIdNo(Constants.FINANCE, 8))
.content(info.get(1)).build())); .content(info.get(1)).build()));
...@@ -541,7 +544,7 @@ class KnowledgeServiceImpl implements IKnowledgeService { ...@@ -541,7 +544,7 @@ class KnowledgeServiceImpl implements IKnowledgeService {
BeanUtils.copyProperties(specialInformation, knowledgeMessage); BeanUtils.copyProperties(specialInformation, knowledgeMessage);
knowledgeMessage.setType(specialInformation.getTypeId()); knowledgeMessage.setType(specialInformation.getTypeId());
knowledgeMessage.setContents(specialInformation.getContents()); knowledgeMessage.setContents(specialInformation.getContents());
produceInfo.sendKnowledgeContents(knowledgeMessage); produceInfo.sendKnowledgeExcelContents(knowledgeMessage);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
log.error("处理异常"); log.error("处理异常");
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论