社交紧密团体-节点修复
This commit is contained in:
parent
0f57cffe44
commit
bb3c6ddbc4
|
|
@ -68,11 +68,22 @@ export function getSocialCommunityList() {
|
||||||
return http.get(`/linkPrediction/triangle/community`)
|
return http.get(`/linkPrediction/triangle/community`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 社交紧密团体中社团内的
|
// 社交紧密团体中社团内的社团内部节点 从用户组中点击,只显示这两个用户的关系
|
||||||
|
export function getSocialCommunityDetailFromUserGroup(
|
||||||
|
relationId,
|
||||||
|
time = "2024-05-16 16:56:04"
|
||||||
|
) {
|
||||||
|
return http.get(`/linkPrediction/user_detail?relationId=${relationId}&time=${time}`)
|
||||||
|
}
|
||||||
// 社交紧密团体的社团内部节点
|
// 社交紧密团体的社团内部节点
|
||||||
export function getSocialCommunityDetailNodes(ids, time = "2024-05-16 16:56:04") {
|
export function getSocialCommunityDetailNodes(ids, relationId, time = "2024-05-16 16:56:04") {
|
||||||
return http.get(`/linkPrediction/triangle/community_detail?groupIds=${ids}&dateTime=${time}`)
|
if (relationId != -1) {
|
||||||
|
return http.get(
|
||||||
|
`/linkPrediction/triangle/community_detail?groupIds=${ids}&dateTime=${time}&relationId=${relationId}`
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return http.get(`/linkPrediction/triangle/community_detail?groupIds=${ids}&dateTime=${time}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//人物社交隐关系预测用户组列表
|
//人物社交隐关系预测用户组列表
|
||||||
|
|
|
||||||
|
|
@ -217,9 +217,13 @@ export const useSocialGroupsStore = defineStore("socialGroups", {
|
||||||
curComponent: "CommunityNode",
|
curComponent: "CommunityNode",
|
||||||
curSelecedGroupIds: [],
|
curSelecedGroupIds: [],
|
||||||
communityDetailNodeList: [],
|
communityDetailNodeList: [],
|
||||||
|
// 社交紧密团体的所有用户
|
||||||
|
communityAllNodeList: [],
|
||||||
timeList: [],
|
timeList: [],
|
||||||
// 当前需要高亮的用户id
|
// 当前需要高亮的用户id
|
||||||
curHighlightUserIdList: [],
|
curHighlightUserIdList: [],
|
||||||
|
// 当前的relationId
|
||||||
|
curRelationId: "",
|
||||||
// 记录点击边的时序列表
|
// 记录点击边的时序列表
|
||||||
clickEdgeTimeList: [],
|
clickEdgeTimeList: [],
|
||||||
// 记录是从边点的还是列表项中的点击
|
// 记录是从边点的还是列表项中的点击
|
||||||
|
|
@ -449,16 +453,29 @@ export const useSocialGroupsStore = defineStore("socialGroups", {
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
// 传递社交团体的数组,获取其详情
|
// 传递社交团体的数组,获取其详情
|
||||||
async initGraphCommunityDetailNode(ids, time = "2024-05-16 16:56:04") {
|
async initGraphCommunityDetailNode(ids, time = "2024-05-16 16:56:04", relationId = -1) {
|
||||||
this.curSelecedGroupIds = ids
|
this.curSelecedGroupIds = ids
|
||||||
const res = await getSocialCommunityDetailNodes(ids, time)
|
const res = await getSocialCommunityDetailNodes(ids, relationId, time)
|
||||||
if (res.code != 200) return
|
if (res.code != 200) return
|
||||||
console.log("index.js:",res.data)
|
console.log("index.js:",res.data)
|
||||||
|
const customStatisticsObj = Object.assign({}, res.data.communityStatistics)
|
||||||
|
//计算两个用户是否同属与同一个社团
|
||||||
|
if (
|
||||||
|
customStatisticsObj.groupCount == null &&
|
||||||
|
customStatisticsObj.hiddenInteractionCount == null
|
||||||
|
) {
|
||||||
|
customStatisticsObj.hiddenInteractionCount = 1
|
||||||
|
customStatisticsObj.groupCount = ids[0] === ids[1] ? 1 : 3
|
||||||
|
}
|
||||||
|
|
||||||
this.statisticsDetailList = this.statisticsDetailList.map((item) => ({
|
this.statisticsDetailList = this.statisticsDetailList.map((item) => ({
|
||||||
...item,
|
...item,
|
||||||
count: res.data.communityStatistics[item.key]
|
count: customStatisticsObj[item.key]
|
||||||
}))
|
}))
|
||||||
|
// 设置社交紧密团体的所有用户id
|
||||||
|
this.communityAllNodeList = res.data.userList
|
||||||
this.communityDetailNodeList = res.data.userRelation
|
this.communityDetailNodeList = res.data.userRelation
|
||||||
|
this.curHighlightUserIdList = res.data.predictNodes
|
||||||
},
|
},
|
||||||
|
|
||||||
// 修改timeList
|
// 修改timeList
|
||||||
|
|
@ -467,10 +484,10 @@ export const useSocialGroupsStore = defineStore("socialGroups", {
|
||||||
},
|
},
|
||||||
// 点击边,先获取需要的timeList
|
// 点击边,先获取需要的timeList
|
||||||
async getClickEdgeTimeList(ids, time = "2024-05-16 16:56:04") {
|
async getClickEdgeTimeList(ids, time = "2024-05-16 16:56:04") {
|
||||||
const res = await getSocialCommunityDetailNodes(ids, time)
|
const relationId = -1
|
||||||
|
const res = await getSocialCommunityDetailNodes(ids, relationId, time)
|
||||||
if (res.code != 200) return
|
if (res.code != 200) return
|
||||||
console.log("3.获取边中的timelist并设置成它")
|
console.log("3.获取边中的timelist并设置成它")
|
||||||
this.curHighlightUserIdList = res.data.predictNodes
|
|
||||||
this.setTimeList(res.data.timeList)
|
this.setTimeList(res.data.timeList)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,11 @@ const handlePointerDown = (e) => {
|
||||||
|
|
||||||
// 点击后输出当前时间
|
// 点击后输出当前时间
|
||||||
const currentTimes = TansTimestamp(currentTime.value, "YYYY-MM-DD HH:mm:ss")
|
const currentTimes = TansTimestamp(currentTime.value, "YYYY-MM-DD HH:mm:ss")
|
||||||
socialGroupsStore.initGraphCommunityDetailNode(socialGroupsStore.curSelecedGroupIds, currentTimes)
|
if(socialGroupsStore.curRelationId === "") {
|
||||||
|
socialGroupsStore.initGraphCommunityDetailNode(socialGroupsStore.curSelecedGroupIds, currentTimes)
|
||||||
|
} else {
|
||||||
|
socialGroupsStore.initGraphCommunityDetailNode(socialGroupsStore.curSelecedGroupIds, currentTimes, socialGroupsStore.curRelationId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 时间点指针按下事件
|
// 时间点指针按下事件
|
||||||
|
|
@ -201,7 +205,11 @@ const handlePointPointerDown = (e) => {
|
||||||
isDragging.value = false
|
isDragging.value = false
|
||||||
// 拖动结束时输出当前时间
|
// 拖动结束时输出当前时间
|
||||||
const currentTimes = TansTimestamp(currentTime.value, "YYYY-MM-DD HH:mm:ss")
|
const currentTimes = TansTimestamp(currentTime.value, "YYYY-MM-DD HH:mm:ss")
|
||||||
socialGroupsStore.initGraphCommunityDetailNode(socialGroupsStore.curSelecedGroupIds, currentTimes)
|
if(socialGroupsStore.curRelationId === "") {
|
||||||
|
socialGroupsStore.initGraphCommunityDetailNode(socialGroupsStore.curSelecedGroupIds, currentTimes)
|
||||||
|
} else {
|
||||||
|
socialGroupsStore.initGraphCommunityDetailNode(socialGroupsStore.curSelecedGroupIds, currentTimes, socialGroupsStore.curRelationId)
|
||||||
|
}
|
||||||
|
|
||||||
document.removeEventListener("pointermove", handlePointerMove)
|
document.removeEventListener("pointermove", handlePointerMove)
|
||||||
document.removeEventListener("pointerup", handlePointerUp)
|
document.removeEventListener("pointerup", handlePointerUp)
|
||||||
|
|
@ -239,28 +247,21 @@ const initChart = async () => {
|
||||||
else if (interactionTime > 30) return 10
|
else if (interactionTime > 30) return 10
|
||||||
else return 1
|
else return 1
|
||||||
}
|
}
|
||||||
// 添加边唯一标识集合,用于检测重复边
|
|
||||||
const edgeSet = new Set()
|
|
||||||
if (!Object.keys(socialGroupsStore.communityDetailNodeList).length) return
|
if (!Object.keys(socialGroupsStore.communityDetailNodeList).length) return
|
||||||
Object.entries(socialGroupsStore.communityDetailNodeList).forEach(([parentId, children]) => {
|
// 先获取到所有节点
|
||||||
|
socialGroupsStore.communityAllNodeList.forEach((item) => {
|
||||||
nodes.push({
|
nodes.push({
|
||||||
id: `parent_${parentId}`,
|
id: item.userId,
|
||||||
name: parentId
|
name: item.userName,
|
||||||
|
symbolSize: 40,
|
||||||
|
postNum: item.postNum,
|
||||||
|
fancy: item.fans
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
Object.entries(socialGroupsStore.communityDetailNodeList).forEach(([parentId, children]) => {
|
||||||
children.forEach((child) => {
|
children.forEach((child) => {
|
||||||
if (!nodes.some((n) => n.id === child.id)) {
|
|
||||||
nodes.push(child)
|
|
||||||
}
|
|
||||||
// 生成标准化边标识(排序后拼接,确保1-2和2-1视为同一条边)
|
|
||||||
const source = `parent_${parentId}`
|
|
||||||
const target = child.id
|
|
||||||
const edgeKey = [source, target].sort().join('-')
|
|
||||||
if(!edgeSet.has(edgeKey)){
|
|
||||||
edgeSet.add(edgeKey)
|
|
||||||
|
|
||||||
}
|
|
||||||
links.push({
|
links.push({
|
||||||
source: `parent_${parentId}`,
|
source: parentId,
|
||||||
target: child.id,
|
target: child.id,
|
||||||
edge: child.isHidden ? 1 : 0,
|
edge: child.isHidden ? 1 : 0,
|
||||||
interactionTimes: child.interactionTime,
|
interactionTimes: child.interactionTime,
|
||||||
|
|
@ -270,6 +271,8 @@ const initChart = async () => {
|
||||||
type: child.isHidden ? "dashed" : "solid" // 无互动=实线,有互动=虚线
|
type: child.isHidden ? "dashed" : "solid" // 无互动=实线,有互动=虚线
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -402,7 +405,8 @@ const initChart = async () => {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
">
|
">
|
||||||
<div style="color:#fff;letter-spacing: 0.14px;">
|
<div style="color:#fff;letter-spacing: 0.14px;">
|
||||||
<div >用户ID:${params.data.id}</div>
|
<div >用户名:${params.data.id}</div>
|
||||||
|
<div >用户名:${params.data.name}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>`
|
</div>`
|
||||||
}
|
}
|
||||||
|
|
@ -413,7 +417,7 @@ const initChart = async () => {
|
||||||
show: false,
|
show: false,
|
||||||
position: "middle",
|
position: "middle",
|
||||||
formatter: function (params) {
|
formatter: function (params) {
|
||||||
return params.data.interactionTimes
|
return `${params.data.interactionTimes}次互动`
|
||||||
},
|
},
|
||||||
fontSize: 14
|
fontSize: 14
|
||||||
},
|
},
|
||||||
|
|
@ -494,7 +498,7 @@ const highLightUserNodes = (newHiglightUserIdList) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
//等待所有节点添加完毕后再查找
|
//等待所有节点添加完毕后再查找
|
||||||
newHiglightUserIdList.forEach((id) => {
|
newHiglightUserIdList.forEach((id) => {
|
||||||
const index = chartsData.value.nodes.findIndex((node) => node.id === `parent_${id}`)
|
const index = chartsData.value.nodes.findIndex((node) => node.id === id)
|
||||||
console.log(index);
|
console.log(index);
|
||||||
|
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
|
|
|
||||||
|
|
@ -31,12 +31,14 @@ const handleClickNode = async (nodeInfo) => {
|
||||||
// 点击节点
|
// 点击节点
|
||||||
socialGroupsStore.initGraphCommunityDetailNode([nodeInfo.id])
|
socialGroupsStore.initGraphCommunityDetailNode([nodeInfo.id])
|
||||||
socialGroupsStore.curComponent = "detailNode"
|
socialGroupsStore.curComponent = "detailNode"
|
||||||
|
socialGroupsStore.curRelationId = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleClickEdge = async (edgeInfo) => {
|
const handleClickEdge = async (edgeInfo) => {
|
||||||
console.log("点击边");
|
console.log("点击边");
|
||||||
socialGroupsStore.curComponent = "detailNode"
|
socialGroupsStore.curComponent = "detailNode"
|
||||||
socialGroupsStore.clickEvent = "edge"
|
socialGroupsStore.clickEvent = "edge"
|
||||||
|
socialGroupsStore.curRelationId = ""
|
||||||
// 先设置socialGroupsStore.clickEdgeTimeList
|
// 先设置socialGroupsStore.clickEdgeTimeList
|
||||||
await socialGroupsStore.getClickEdgeTimeList([edgeInfo.source, edgeInfo.target])
|
await socialGroupsStore.getClickEdgeTimeList([edgeInfo.source, edgeInfo.target])
|
||||||
const lastTime = socialGroupsStore.timeList[socialGroupsStore.timeList.length - 1]
|
const lastTime = socialGroupsStore.timeList[socialGroupsStore.timeList.length - 1]
|
||||||
|
|
|
||||||
|
|
@ -87,9 +87,10 @@ const handleSelectedUserGroup = (group) => {
|
||||||
socialGroupsStore.clickEvent = "list"
|
socialGroupsStore.clickEvent = "list"
|
||||||
console.log("点击列表group:",group)
|
console.log("点击列表group:",group)
|
||||||
const groupIds = group.list.map((item)=>item.groupId)
|
const groupIds = group.list.map((item)=>item.groupId)
|
||||||
|
socialGroupsStore.curRelationId = group.relationId //保存当前点击的relationid,为了区分到底是从哪点进二级界面的
|
||||||
const length = group.timeList.length
|
const length = group.timeList.length
|
||||||
const lastTime = group.timeList[length - 1]
|
const lastTime = group.timeList[length - 1]
|
||||||
socialGroupsStore.initGraphCommunityDetailNode(groupIds, lastTime)
|
socialGroupsStore.initGraphCommunityDetailNode(groupIds, lastTime, group.relationId)
|
||||||
socialGroupsStore.setTimeList(group.timeList)
|
socialGroupsStore.setTimeList(group.timeList)
|
||||||
socialGroupsStore.getSocialGroupPostListByRelationId(group.relationId)
|
socialGroupsStore.getSocialGroupPostListByRelationId(group.relationId)
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user