提交 7116f7bf 作者: 925993793@qq.com

自定义专题-信息源绑定对接采集中心

上级 90b50cae
......@@ -31,12 +31,18 @@ public class SubjectInfoSourceMiddleMap implements Serializable {
/**专题id*/
@TableField("subject_id")
private String subjectId;
/**信息源id或信息源组id*/
/**信息源id*/
@TableField("info_source_id")
private String infoSourceId;
/**信息源名称*/
@TableField("info_source_name")
private String infoSourceName;
/**网址*/
@TableField("url")
private String url;
/**状态(1-已有;0-待配置)*/
@TableField("status")
private Integer status;
/**创建时间*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
......
......@@ -89,7 +89,7 @@ public interface InfoSourceMapper extends BaseMapper<InfoSource> {
* @author lkg
* @date 2025/1/6
*/
Page<SubjectBindDirectSourceVO> subjectBindDirectInfoSourceList(@Param("subjectId") String subjectId, Page<Map<String, Object>> page);
Page<SubjectBindDirectSourceVO> subjectBindDirectInfoSourceList(@Param("subjectId") String subjectId ,@Param("webSiteName") String webSiteName, Page<Map<String, Object>> page);
/**
......
......@@ -335,7 +335,7 @@
<select id="subjectBindDirectInfoSourceList" resultType="com.zzsn.event.vo.SubjectBindDirectSourceVO">
select a.*
<!--select a.*
from (
select iso.web_site_name as webSiteName, 1 as `status`
from info_source iso
......@@ -348,7 +348,13 @@
where subject_id = #{subjectId}
group by info_source_name
) a
order by a.status desc, a.webSiteName asc
order by a.status desc, a.webSiteName asc-->
select info_source_id as webSiteId,info_source_name as webSiteName, `status`
from subject_info_source_middle_map
where subject_id = #{subjectId}
<if test="webSiteName!=null and webSiteName != ''">
and info_source_name like CONCAT('%',#{webSiteName},'%')
</if>
</select>
<select id="infoSourcePageList" resultType="com.zzsn.event.vo.SubjectBindDirectSourceVO">
......
......@@ -60,12 +60,13 @@ public interface IInfoSourceService extends IService<InfoSource> {
* 专题绑定的定向信息源分页列表(专题绑定定向信息源时使用-研究中心)
*
* @param subjectId 专题id
* @param webSiteName 信息源名称
* @param pageNo 当前页
* @param pageSize 返回条数
* @author lkg
* @date 2025/1/4
*/
IPage<SubjectBindDirectSourceVO> subjectBindDirectSourcePageList(String subjectId, Integer pageNo, Integer pageSize);
IPage<SubjectBindDirectSourceVO> subjectBindDirectSourcePageList(String subjectId,String webSiteName, Integer pageNo, Integer pageSize);
/**
* 信息源分页列表(专题绑定定向信息源时使用-研究中心)
......
......@@ -127,10 +127,9 @@ public class InfoSourceServiceImpl extends ServiceImpl<InfoSourceMapper, InfoSou
}
@Override
public IPage<SubjectBindDirectSourceVO> subjectBindDirectSourcePageList(String subjectId, Integer pageNo, Integer pageSize) {
public IPage<SubjectBindDirectSourceVO> subjectBindDirectSourcePageList(String subjectId,String webSiteName, Integer pageNo, Integer pageSize) {
Page<Map<String, Object>> page = new Page<>(pageNo, pageSize);
Page<SubjectBindDirectSourceVO> pageList = baseMapper.subjectBindDirectInfoSourceList(subjectId, page);
List<SubjectBindDirectSourceVO> records = pageList.getRecords();
/*List<SubjectBindDirectSourceVO> records = pageList.getRecords();
if (CollectionUtils.isNotEmpty(records)) {
List<String> webSiteNames = records.stream().map(SubjectBindDirectSourceVO::getWebSiteName).collect(Collectors.toList());
List<InfoSource> bindSourceColumnList = this.subjectBindSourceColumnList(subjectId, webSiteNames);
......@@ -142,8 +141,8 @@ public class InfoSourceServiceImpl extends ServiceImpl<InfoSourceMapper, InfoSou
subjectBindDirectSourceVO.setChildren(infoSources);
}
}
}
return pageList;
}*/
return baseMapper.subjectBindDirectInfoSourceList(subjectId,webSiteName, page);
}
@Override
......
package com.zzsn.event.task;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zzsn.event.entity.InfoSource;
import com.zzsn.event.entity.SubjectInfoSourceMap;
import com.zzsn.event.entity.SubjectInfoSourceMiddleMap;
import com.zzsn.event.service.IInfoSourceService;
import com.zzsn.event.service.ISubjectInfoSourceMapService;
import com.zzsn.event.service.SubjectInfoSourceMiddleMapService;
import com.zzsn.event.util.HttpUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 待配置信息源,状态监控更新任务(和采集中心交互)
*
* @author lkg
* @date 2025/5/23
*/
@Slf4j
@Component
public class WaitConfigInfoSourceTask {
@Value("${infoSource.columnListByWait:}")
private String columnListByWait;
@Autowired
private ISubjectInfoSourceMapService subjectInfoSourceMapService;
@Autowired
private SubjectInfoSourceMiddleMapService subjectInfoSourceMiddleMapService;
@Autowired
private IInfoSourceService infoSourceService;
@Value("${scheduling.yjzxEnable:false}")
Boolean yjzxEnable;
/**
* 每6小时,执行一次
*/
@Scheduled(cron = "0 0 0/6 * * ?")
public void syncConfig() {
if(!yjzxEnable){
return;
}
List<SubjectInfoSourceMiddleMap> waitConfigSourceList = subjectInfoSourceMiddleMapService.list(
new LambdaQueryWrapper<SubjectInfoSourceMiddleMap>()
.eq(SubjectInfoSourceMiddleMap::getStatus, 0)
);
if (CollectionUtils.isNotEmpty(waitConfigSourceList)) {
for (SubjectInfoSourceMiddleMap middleMap : waitConfigSourceList) {
String subjectId = middleMap.getSubjectId();
String waitForConfigId = middleMap.getInfoSourceId();
JSONObject jsonObject = getColumnListByWait(waitForConfigId);
if (jsonObject != null) {
middleMap.setStatus(1);
middleMap.setInfoSourceId(jsonObject.getString("infoSourceId"));
middleMap.setInfoSourceName(jsonObject.getString("infoSourceName"));
subjectInfoSourceMiddleMapService.updateById(middleMap);
List<JSONObject> columnList = JSON.parseArray(jsonObject.getString("columnList"), JSONObject.class);
List<SubjectInfoSourceMap> list = new ArrayList<>();
List<InfoSource> infoSourceList = new ArrayList<>();
for (JSONObject column : columnList) {
SubjectInfoSourceMap sms = new SubjectInfoSourceMap();
sms.setSubjectId(subjectId);
sms.setSourceId(column.getString("id"));
sms.setType(1);
list.add(sms);
//信息源
InfoSource infoSource = new InfoSource();
infoSource.setId(column.getString("id"));
infoSource.setSiteName(column.getString("columnName"));
infoSource.setSiteUri(column.getString("columnAddress"));
infoSource.setWebSiteName(jsonObject.getString("infoSourceName"));
infoSourceList.add(infoSource);
}
subjectInfoSourceMapService.saveBatch(list);
if (CollectionUtils.isNotEmpty(infoSourceList)) {
infoSourceService.saveOrUpdateBatch(infoSourceList);
}
log.info("待配置信息源-{},对应已配置信息源-{},同步更新完成",waitForConfigId, jsonObject.getString("infoSourceId"));
}
}
}
}
private JSONObject getColumnListByWait(String waitConfigId) {
JSONObject result = null;
Map<String, String> variables = new HashMap<>();
variables.put("waitConfigId", waitConfigId);
String response = HttpUtil.doGet(columnListByWait, variables, null, "utf-8");
JSONObject jsonObject = JSONObject.parseObject(response);
if (jsonObject.getInteger("code") == 200) {
result = jsonObject.getJSONObject("result");
}
return result;
}
}
......@@ -15,6 +15,8 @@ import java.util.List;
public class SubjectBindDirectSourceVO {
/**专题id*/
private String subjectId;
/**信息源id*/
private String webSiteId;
/**信息源名称*/
private String webSiteName;
/**状态(1-已配置;0-待配置)*/
......
package com.zzsn.event.vo;
import lombok.Data;
import java.util.List;
/**
*
*
* @author lkg
* @date 2024/4/28
*/
@Data
public class SubjectBindSourceVO {
private String webSiteId;
private String webSiteName;
private List<String> columnIds;
}
......@@ -60,11 +60,11 @@ spring:
password: qwer@9988&zzsn
driver-class-name: com.mysql.cj.jdbc.Driver
elasticsearch:
uris: ["1.95.69.2:9200"]
# uris: ["1.95.38.69:9700","1.95.3.121:9200","1.95.87.177:9700"]
# uris: ["1.95.69.2:9200"]
uris: ["1.95.38.69:9700","1.95.3.121:9200","1.95.87.177:9700"]
username: elastic
password: elastic
# password: zzsn9988
# password: elastic
password: zzsn9988
connection-timeout: 300000
socket-timeout: 300000
cloud:
......@@ -177,3 +177,10 @@ clb:
data-permit:
dataPermitGetQueryEntityTest: http://1.95.77.159:10089/permission/
dataPermitGetQueryEntityProd: http://1.95.14.24:8060/
infoSource:
pageList: http://1.95.79.85:8823/baseSourceInfo/api/infoSource/pageList
columnList: http://1.95.79.85:8823/baseSourceInfo/api/infoSource/columnList
add: http://1.95.79.85:8823/baseSourceInfo/api/infoSource/addInfoSourceTask
waitInfoRemove: http://1.95.79.85:8823/baseSourceInfo/api/infoSource/waitInfoRemove
columnListByWait: http://1.95.79.85:8823/baseSourceInfo/api/infoSource/columnListByWait
columnDetail: http://1.95.79.85:8823/baseSourceInfo/api/infoSource/columnDetail
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论