Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
邬吉朋
relation
Commits
e59d956f
Commit
e59d956f
authored
Aug 01, 2025
by
zhuxiang
Browse files
团体画布接口
parent
9c02f656
Changes
10
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/platform/controller/GroupController.java
View file @
e59d956f
...
...
@@ -43,4 +43,9 @@ public class GroupController extends BaseController {
return
Result
.
data
(
groupDetailService
.
queryMacDetail
(
mac
));
}
@GetMapping
(
"/draw/{groupId}"
)
public
Result
draw
(
@PathVariable
String
groupId
)
{
return
Result
.
data
(
groupDetailService
.
draw
(
groupId
));
}
}
src/main/java/com/platform/mapper/ExcelDataMapper.java
View file @
e59d956f
...
...
@@ -5,6 +5,7 @@ import com.platform.model.dto.CaseDTO;
import
com.platform.model.entity.ExcelDataEntity
;
import
com.platform.model.vo.ExcelDataVO
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
...
...
@@ -19,4 +20,7 @@ public interface ExcelDataMapper extends BaseMapper<ExcelDataEntity> {
List
<
ExcelDataVO
>
queryByCaseId
(
String
id
);
List
<
ExcelDataEntity
>
queryList
(
CaseDTO
caseDTO
);
List
<
ExcelDataEntity
>
queryListByPayUserList
(
@Param
(
"userList"
)
List
<
String
>
userList
,
@Param
(
"caseId"
)
int
caseId
);
}
src/main/java/com/platform/mapper/GroupDetailMapper.java
View file @
e59d956f
...
...
@@ -2,6 +2,7 @@ package com.platform.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.platform.model.dto.GroupDetailDTO
;
import
com.platform.model.entity.ExcelDataEntity
;
import
com.platform.model.entity.GroupDetailEntity
;
import
com.platform.model.vo.GroupDetailVO
;
import
org.apache.ibatis.annotations.Mapper
;
...
...
@@ -15,4 +16,11 @@ public interface GroupDetailMapper extends BaseMapper<GroupDetailEntity> {
List
<
GroupDetailVO
>
queryIp
(
GroupDetailDTO
groupDetailDTO
);
List
<
GroupDetailVO
>
queryMac
(
GroupDetailDTO
groupDetailDTO
);
/**
* 根据团体id查看团体明细
* @param groupId
* @return
*/
List
<
String
>
queryUserList
(
String
groupId
);
}
src/main/java/com/platform/model/vo/EdgeVO.java
View file @
e59d956f
...
...
@@ -39,4 +39,12 @@ public class EdgeVO {
this
.
account
=
account
;
}
public
EdgeVO
(
String
id
,
String
source
,
String
target
,
int
totalTransactions
,
double
totalAmount
)
{
this
.
id
=
id
;
this
.
source
=
source
;
this
.
target
=
target
;
this
.
totalTransactions
=
totalTransactions
;
this
.
totalAmount
=
totalAmount
;
}
}
src/main/java/com/platform/service/ExcelDataService.java
View file @
e59d956f
...
...
@@ -46,4 +46,6 @@ public interface ExcelDataService extends IService<ExcelDataEntity> {
List
<
ExcelDataEntity
>
queryListByCaseId
(
String
id
);
List
<
ExcelDataEntity
>
queryList
(
CaseDTO
caseDTO
);
List
<
ExcelDataEntity
>
queryListByPayUserList
(
List
<
String
>
userList
,
int
caseId
);
}
src/main/java/com/platform/service/GroupDetailService.java
View file @
e59d956f
...
...
@@ -3,6 +3,7 @@ package com.platform.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.platform.model.dto.GroupDetailDTO
;
import
com.platform.model.entity.GroupDetailEntity
;
import
com.platform.model.vo.GraphVO
;
import
com.platform.model.vo.GroupDetailVO
;
import
java.util.List
;
...
...
@@ -17,4 +18,6 @@ public interface GroupDetailService extends IService<GroupDetailEntity> {
List
<
GroupDetailVO
>
queryMac
(
GroupDetailDTO
groupDetailDTO
);
List
<
GroupDetailEntity
>
queryMacDetail
(
String
mac
);
GraphVO
draw
(
String
groupId
);
}
src/main/java/com/platform/service/impl/ExcelDataServiceImpl.java
View file @
e59d956f
...
...
@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.platform.mapper.ExcelDataMapper
;
import
com.platform.model.dto.CaseDTO
;
import
com.platform.model.dto.ExcelDataDTO
;
import
com.platform.model.entity.ExcelDataEntity
;
import
com.platform.model.vo.ExcelDataVO
;
import
com.platform.service.ExcelDataService
;
...
...
@@ -60,4 +59,9 @@ public class ExcelDataServiceImpl extends ServiceImpl<ExcelDataMapper, ExcelData
public
List
<
ExcelDataEntity
>
queryList
(
CaseDTO
caseDTO
)
{
return
baseMapper
.
queryList
(
caseDTO
);
}
@Override
public
List
<
ExcelDataEntity
>
queryListByPayUserList
(
List
<
String
>
userList
,
int
caseId
)
{
return
baseMapper
.
queryListByPayUserList
(
userList
,
caseId
);
}
}
src/main/java/com/platform/service/impl/GroupDetailServiceImpl.java
View file @
e59d956f
package
com.platform.service.impl
;
import
cn.hutool.core.collection.CollUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.platform.mapper.GroupDetailMapper
;
import
com.platform.model.dto.GroupDetailDTO
;
import
com.platform.model.entity.ExcelDataEntity
;
import
com.platform.model.entity.GroupDetailEntity
;
import
com.platform.model.entity.GroupEntity
;
import
com.platform.model.vo.EdgeVO
;
import
com.platform.model.vo.GraphVO
;
import
com.platform.model.vo.GroupDetailVO
;
import
com.platform.model.vo.NodeVO
;
import
com.platform.service.ExcelDataService
;
import
com.platform.service.GroupDetailService
;
import
com.platform.service.GroupService
;
import
com.platform.utils.StringUtils
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
javax.annotation.Resource
;
import
java.util.*
;
@Service
public
class
GroupDetailServiceImpl
extends
ServiceImpl
<
GroupDetailMapper
,
GroupDetailEntity
>
implements
GroupDetailService
{
@Resource
private
GroupService
groupService
;
@Resource
private
ExcelDataService
excelDataService
;
@Override
public
List
<
GroupDetailEntity
>
queryList
(
GroupDetailDTO
groupDetailDTO
)
{
return
baseMapper
.
selectList
(
new
LambdaQueryWrapper
<
GroupDetailEntity
>()
...
...
@@ -41,4 +56,70 @@ public class GroupDetailServiceImpl extends ServiceImpl<GroupDetailMapper, Group
return
baseMapper
.
selectList
(
new
LambdaQueryWrapper
<
GroupDetailEntity
>()
.
eq
(
GroupDetailEntity:
:
getMac
,
mac
));
}
@Override
public
GraphVO
draw
(
String
groupId
)
{
//查看group信息
GroupEntity
groupEntity
=
groupService
.
getById
(
groupId
);
if
(
groupEntity
==
null
)
{
return
null
;
}
// 创建图
GraphVO
graph
=
new
GraphVO
();
// 使用Map来存储边的信息,键为payer-payee组合,值为Edge对象
Map
<
String
,
EdgeVO
>
edgeMap
=
new
HashMap
<>();
// 使用Set去重
Set
<
String
>
uniqueNodes
=
new
HashSet
<>();
//根据团体id查看团体明细
List
<
String
>
userList
=
baseMapper
.
queryUserList
(
groupId
);
if
(
CollUtil
.
isNotEmpty
(
userList
))
{
List
<
ExcelDataEntity
>
excelDataEntityList
=
excelDataService
.
queryListByPayUserList
(
userList
,
groupEntity
.
getCaseId
());
// 遍历结果集
for
(
ExcelDataEntity
excelDataEntity
:
excelDataEntityList
)
{
String
payer
=
excelDataEntity
.
getPayUserName
();
String
payee
=
excelDataEntity
.
getPayeeName
();
double
amount
=
excelDataEntity
.
getAmount
();
if
(
StringUtils
.
isEmpty
(
payee
)
||
StringUtils
.
isEmpty
(
payer
))
{
continue
;
}
// 添加节点
uniqueNodes
.
add
(
payer
);
uniqueNodes
.
add
(
payee
);
// 生成边的唯一标识
String
edgeKey
=
payer
+
"-"
+
payee
;
// 检查是否已经存在这条边
if
(
edgeMap
.
containsKey
(
edgeKey
))
{
// 如果存在,更新总笔数和总金额
EdgeVO
existingEdge
=
edgeMap
.
get
(
edgeKey
);
existingEdge
.
setTotalTransactions
(
existingEdge
.
getTotalTransactions
()
+
1
);
existingEdge
.
setTotalAmount
(
existingEdge
.
getTotalAmount
()
+
amount
);
}
else
{
// 如果不存在,创建新的边
String
edgeId
=
"line-"
+
payer
+
"-"
+
payee
;
EdgeVO
newEdge
=
new
EdgeVO
(
edgeId
,
payer
,
payee
,
1
,
amount
);
edgeMap
.
put
(
edgeKey
,
newEdge
);
}
}
// 添加去重后的节点
for
(
String
node
:
uniqueNodes
)
{
graph
.
addNode
(
new
NodeVO
(
node
));
}
// 添加边
for
(
EdgeVO
edge
:
edgeMap
.
values
())
{
graph
.
addEdge
(
edge
);
}
return
graph
;
}
return
null
;
}
}
src/main/resources/com/platform/mapper/ExcelDataMapper.xml
View file @
e59d956f
...
...
@@ -38,4 +38,22 @@
and time betwenn #{startTime} and #{endTime}
</if>
</select>
<select
id=
"queryListByPayUserList"
resultType=
"com.platform.model.entity.ExcelDataEntity"
>
select
pay_user_name payUserName,
payee_name payeeName,
amount amount
from
excel_data
where
use_flag = 1
and
case_id = #{caseId}
and
pay_user_name in
<foreach
collection=
"userList"
item=
"userName"
open=
"("
separator=
","
close=
")"
>
#{userName}
</foreach>
</select>
</mapper>
src/main/resources/com/platform/mapper/GroupDetailMapper.xml
View file @
e59d956f
...
...
@@ -30,4 +30,13 @@
GROUP BY
mac
</select>
<select
id=
"queryUserList"
resultType=
"java.lang.String"
>
select
user_name
from
group_detail
where
group_id = #{groupId}
</select>
</mapper>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment