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
29136673
Commit
29136673
authored
Aug 01, 2025
by
zhuxiang
Browse files
团体数据入库
parent
7ebfe4a1
Changes
11
Show whitespace changes
Inline
Side-by-side
src/main/java/com/platform/mapper/GroupDetailMapper.java
0 → 100644
View file @
29136673
package
com.platform.mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.platform.model.entity.GroupDetailEntity
;
import
org.apache.ibatis.annotations.Mapper
;
@Mapper
public
interface
GroupDetailMapper
extends
BaseMapper
<
GroupDetailEntity
>
{
}
src/main/java/com/platform/mapper/GroupMapper.java
0 → 100644
View file @
29136673
package
com.platform.mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.platform.model.entity.GroupEntity
;
import
org.apache.ibatis.annotations.Mapper
;
@Mapper
public
interface
GroupMapper
extends
BaseMapper
<
GroupEntity
>
{
}
src/main/java/com/platform/model/entity/GroupDetailEntity.java
0 → 100644
View file @
29136673
package
com.platform.model.entity
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
lombok.Data
;
@Data
@TableName
(
"group_detail"
)
public
class
GroupDetailEntity
{
@TableId
(
value
=
"id"
)
private
int
id
;
@TableField
(
"case_id"
)
private
int
caseId
;
private
String
userName
;
private
int
transactionCount
;
// 总交易次数
private
double
totalAmount
;
// 总交易金额(转出+转入)
private
double
outgoingAmount
;
// 转出金额
private
double
incomingAmount
;
// 转入金额
public
GroupDetailEntity
(
String
userName
)
{
this
.
userName
=
userName
;
}
public
void
addOutgoingTransaction
(
double
amount
)
{
this
.
outgoingAmount
+=
amount
;
this
.
totalAmount
+=
amount
;
}
public
void
addIncomingTransaction
(
double
amount
)
{
this
.
incomingAmount
+=
amount
;
this
.
totalAmount
+=
amount
;
}
public
void
incrementTransactionCount
(
int
count
)
{
this
.
transactionCount
+=
count
;
}
}
src/main/java/com/platform/model/entity/GroupEntity.java
0 → 100644
View file @
29136673
package
com.platform.model.entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
lombok.Data
;
@Data
@TableName
(
"group_info"
)
public
class
GroupEntity
{
@TableId
(
type
=
IdType
.
AUTO
)
private
int
id
;
private
int
caseId
;
private
String
groupName
;
private
int
groupSize
;
private
Double
totalAmount
;
private
int
totalTransactions
;
}
src/main/java/com/platform/model/vo/GroupVO.java
View file @
29136673
package
com.platform.model.vo
;
package
com.platform.model.vo
;
import
com.platform.model.entity.GroupDetailEntity
;
import
lombok.Data
;
import
lombok.Data
;
import
java.util.List
;
@Data
@Data
public
class
GroupVO
{
public
class
GroupVO
{
private
int
id
;
private
String
groupName
;
// 团体名
private
String
groupName
;
// 团体名
private
int
groupSize
;
// 团体人数
private
int
groupSize
;
// 团体人数
private
double
totalAmount
;
// 团体资金总量
private
double
totalAmount
;
// 团体资金总量
private
int
totalTransactions
;
// 交易总次数
private
int
totalTransactions
;
// 交易总次数
private
List
<
GroupDetailEntity
>
groupDetailList
;
// 成员明细列表
public
GroupVO
(
String
groupName
,
int
groupSize
,
double
totalAmount
,
int
totalTransactions
)
{
public
GroupVO
(
String
groupName
,
int
groupSize
,
double
totalAmount
,
int
totalTransactions
,
List
<
GroupDetailEntity
>
groupDetailList
)
{
this
.
groupName
=
groupName
;
this
.
groupName
=
groupName
;
this
.
groupSize
=
groupSize
;
this
.
groupSize
=
groupSize
;
this
.
totalAmount
=
totalAmount
;
this
.
totalAmount
=
totalAmount
;
this
.
totalTransactions
=
totalTransactions
;
this
.
totalTransactions
=
totalTransactions
;
this
.
groupDetailList
=
groupDetailList
;
}
}
}
}
src/main/java/com/platform/service/GroupDetailService.java
0 → 100644
View file @
29136673
package
com.platform.service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.platform.model.entity.GroupDetailEntity
;
public
interface
GroupDetailService
extends
IService
<
GroupDetailEntity
>
{
}
src/main/java/com/platform/service/GroupService.java
0 → 100644
View file @
29136673
package
com.platform.service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.platform.model.entity.GroupEntity
;
import
com.platform.model.vo.GroupVO
;
import
java.util.List
;
public
interface
GroupService
extends
IService
<
GroupEntity
>
{
void
saveGroup
(
int
id
,
List
<
GroupVO
>
groups
);
}
src/main/java/com/platform/service/impl/CaseServiceImpl.java
View file @
29136673
...
@@ -7,9 +7,11 @@ import com.platform.model.dto.CaseDTO;
...
@@ -7,9 +7,11 @@ import com.platform.model.dto.CaseDTO;
import
com.platform.model.dto.ExcelDataDTO
;
import
com.platform.model.dto.ExcelDataDTO
;
import
com.platform.model.entity.CaseEntity
;
import
com.platform.model.entity.CaseEntity
;
import
com.platform.model.entity.ExcelDataEntity
;
import
com.platform.model.entity.ExcelDataEntity
;
import
com.platform.model.entity.GroupDetailEntity
;
import
com.platform.model.vo.*
;
import
com.platform.model.vo.*
;
import
com.platform.service.CaseService
;
import
com.platform.service.CaseService
;
import
com.platform.service.ExcelDataService
;
import
com.platform.service.ExcelDataService
;
import
com.platform.service.GroupService
;
import
com.platform.utils.StringUtils
;
import
com.platform.utils.StringUtils
;
import
org.apache.commons.compress.utils.Lists
;
import
org.apache.commons.compress.utils.Lists
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -22,6 +24,8 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CaseEntity> impleme
...
@@ -22,6 +24,8 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CaseEntity> impleme
@Resource
@Resource
private
ExcelDataService
excelDataService
;
private
ExcelDataService
excelDataService
;
@Resource
private
GroupService
groupService
;
@Override
@Override
public
List
<
CaseVO
>
queryDataList
(
String
id
)
{
public
List
<
CaseVO
>
queryDataList
(
String
id
)
{
...
@@ -91,66 +95,65 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CaseEntity> impleme
...
@@ -91,66 +95,65 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CaseEntity> impleme
@Override
@Override
public
GraphVO
draw
(
CaseDTO
caseDTO
)
{
public
GraphVO
draw
(
CaseDTO
caseDTO
)
{
// 初始化
画布
// 初始化
返回对象
GraphVO
graph
=
new
GraphVO
();
GraphVO
graph
=
new
GraphVO
();
// 使用并查集来管理团体
// 使用并查集管理团体关系
UnionFindVO
uf
=
new
UnionFindVO
();
UnionFindVO
uf
=
new
UnionFindVO
();
// 使用Map来存储边的信息,键为payer-payee组合,值为Edge对象
// 存储边信息,键为payer-payee组合
Map
<
String
,
EdgeVO
>
edgeMap
=
new
HashMap
<>();
Map
<
String
,
EdgeVO
>
edgeMap
=
new
HashMap
<>();
// 查
看
案件
所有的人员
// 查
询
案件
数据
List
<
ExcelDataEntity
>
excelDataEntityList
=
excelDataService
.
queryList
(
caseDTO
);
List
<
ExcelDataEntity
>
excelDataEntityList
=
excelDataService
.
queryList
(
caseDTO
);
if
(
CollUtil
.
isNotEmpty
(
excelDataEntityList
))
{
excelDataEntityList
.
forEach
(
excelDataEntity
->
{
if
(
CollUtil
.
isEmpty
(
excelDataEntityList
))
{
if
(
StringUtils
.
isNotEmpty
(
excelDataEntity
.
getPayUserName
())
return
graph
;
// 无数据直接返回空图
&&
StringUtils
.
isNotEmpty
(
excelDataEntity
.
getPayeeName
()))
{
}
// 第一步:处理原始数据
for
(
ExcelDataEntity
excelDataEntity
:
excelDataEntityList
)
{
if
(
StringUtils
.
isEmpty
(
excelDataEntity
.
getPayUserName
())
||
StringUtils
.
isEmpty
(
excelDataEntity
.
getPayeeName
()))
{
continue
;
// 跳过无效记录
}
String
payer
=
excelDataEntity
.
getPayUserName
();
String
payer
=
excelDataEntity
.
getPayUserName
();
String
payee
=
excelDataEntity
.
getPayeeName
();
String
payee
=
excelDataEntity
.
getPayeeName
();
double
amount
=
excelDataEntity
.
getAmount
();
double
amount
=
excelDataEntity
.
getAmount
();
// 添加
节点
到并查集
// 添加到并查集
uf
.
makeSet
(
payer
);
uf
.
makeSet
(
payer
);
uf
.
makeSet
(
payee
);
uf
.
makeSet
(
payee
);
// 合并团体
uf
.
union
(
payer
,
payee
);
uf
.
union
(
payer
,
payee
);
// 生成边的唯一标识
// 处理边信息
String
edgeKey
=
payer
+
"-"
+
payee
;
String
edgeKey
=
payer
+
"-"
+
payee
;
// 检查是否已经存在这条边
if
(
edgeMap
.
containsKey
(
edgeKey
))
{
// 如果存在,更新总笔数和总金额
EdgeVO
existingEdge
=
edgeMap
.
get
(
edgeKey
);
EdgeVO
existingEdge
=
edgeMap
.
get
(
edgeKey
);
if
(
existingEdge
!=
null
)
{
// 更新现有边
existingEdge
.
setTotalTransactions
(
existingEdge
.
getTotalTransactions
()
+
1
);
existingEdge
.
setTotalTransactions
(
existingEdge
.
getTotalTransactions
()
+
1
);
existingEdge
.
setTotalAmount
(
existingEdge
.
getTotalAmount
()
+
amount
);
existingEdge
.
setTotalAmount
(
existingEdge
.
getTotalAmount
()
+
amount
);
}
else
{
}
else
{
// 如果不存在,
创建新
的
边
//
创建新边
String
edgeId
=
"line-"
+
payer
+
"-"
+
payee
;
String
edgeId
=
"line-"
+
payer
+
"-"
+
payee
;
EdgeVO
newEdge
=
new
EdgeVO
(
edgeId
,
payer
,
payee
,
1
,
amount
,
uf
.
find
(
payer
));
EdgeVO
newEdge
=
new
EdgeVO
(
edgeId
,
payer
,
payee
,
1
,
amount
,
uf
.
find
(
payer
));
edgeMap
.
put
(
edgeKey
,
newEdge
);
edgeMap
.
put
(
edgeKey
,
newEdge
);
}
}
}
}
});
// === 修复1:先完成所有过滤 ===
// 第二步:过滤节点
Set
<
String
>
validNodes
=
new
HashSet
<>();
// 有效节点集合
Set
<
String
>
validNodes
=
new
HashSet
<>();
// 节点过滤
for
(
String
node
:
uf
.
getParent
().
keySet
())
{
for
(
String
node
:
uf
.
getParent
().
keySet
())
{
if
(
caseDTO
.
getPrincipal
()
!=
null
)
{
if
(
shouldIncludeNode
(
node
,
caseDTO
))
{
if
(
caseDTO
.
getPrincipal
()
==
1
)
{
if
(
node
.
contains
(
"公司"
)
||
node
.
length
()
>
4
)
continue
;
}
else
{
if
(!
node
.
contains
(
"公司"
)
||
node
.
length
()
>
4
)
continue
;
}
}
validNodes
.
add
(
node
);
validNodes
.
add
(
node
);
graph
.
addNode
(
new
NodeVO
(
node
));
graph
.
addNode
(
new
NodeVO
(
node
));
}
}
}
// 边过滤(同时检查两端节点有效性)
// 第三步:过滤边
List
<
EdgeVO
>
validEdges
=
new
ArrayList
<>();
for
(
EdgeVO
edge
:
edgeMap
.
values
())
{
for
(
EdgeVO
edge
:
edgeMap
.
values
())
{
// 检查两端节点是否有效
// 检查两端节点是否有效
if
(!
validNodes
.
contains
(
edge
.
getSource
())
||
if
(!
validNodes
.
contains
(
edge
.
getSource
())
||
...
@@ -158,83 +161,158 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CaseEntity> impleme
...
@@ -158,83 +161,158 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CaseEntity> impleme
continue
;
continue
;
}
}
// 金额/笔数过滤
// 检查金额过滤条件
boolean
amountValid
=
true
;
if
(
caseDTO
.
getMinAmount
()
!=
null
&&
caseDTO
.
getMaxAmount
()
!=
null
)
{
if
(
caseDTO
.
getMinAmount
()
!=
null
&&
caseDTO
.
getMaxAmount
()
!=
null
)
{
amountValid
=
edge
.
getTotalAmount
()
>=
caseDTO
.
getMinAmount
()
if
(
edge
.
getTotalAmount
()
<
caseDTO
.
getMinAmount
()
||
&&
edge
.
getTotalAmount
()
<=
caseDTO
.
getMaxAmount
();
edge
.
getTotalAmount
()
>
caseDTO
.
getMaxAmount
())
{
continue
;
}
}
}
boolean
transValid
=
true
;
// 检查交易次数过滤条件
if
(
caseDTO
.
getMinTransaction
()
!=
null
&&
caseDTO
.
getMaxTransaction
()
!=
null
)
{
if
(
caseDTO
.
getMinTransaction
()
!=
null
&&
caseDTO
.
getMaxTransaction
()
!=
null
)
{
transValid
=
edge
.
getTotalTransactions
()
>=
caseDTO
.
getMinTransaction
()
if
(
edge
.
getTotalTransactions
()
<
caseDTO
.
getMinTransaction
()
||
&&
edge
.
getTotalTransactions
()
<=
caseDTO
.
getMaxTransaction
();
edge
.
getTotalTransactions
()
>
caseDTO
.
getMaxTransaction
())
{
continue
;
}
}
}
if
(
amountValid
||
transValid
)
{
// 添加到有效边集合
validEdges
.
add
(
edge
);
graph
.
addEdge
(
edge
);
graph
.
addEdge
(
edge
);
}
}
}
// === 修复2:基于过滤后数据重建团体 ===
// 第四步:重建过滤后的团体关系
// 创建新的并查集用于过滤后的数据
UnionFindVO
filteredUf
=
new
UnionFindVO
();
validNodes
.
forEach
(
filteredUf:
:
makeSet
);
// 用于按团体分组统计
Map
<
String
,
Set
<
String
>>
groupMembers
=
new
HashMap
<>();
Map
<
String
,
Set
<
String
>>
groupMembers
=
new
HashMap
<>();
Map
<
String
,
Double
>
groupTotalAmount
=
new
HashMap
<>();
Map
<
String
,
Double
>
groupTotalAmount
=
new
HashMap
<>();
Map
<
String
,
Integer
>
groupTotalTransactions
=
new
HashMap
<>();
Map
<
String
,
Integer
>
groupTotalTransactions
=
new
HashMap
<>();
// 步骤1:为每个有效节点创建独立
团体
// 初始化每个节点的
团体
for
(
String
node
:
validNodes
)
{
for
(
String
node
:
validNodes
)
{
String
root
=
uf
.
find
(
node
);
String
root
=
uf
.
find
(
node
);
groupMembers
.
computeIfAbsent
(
root
,
k
->
new
HashSet
<>()).
add
(
node
);
groupMembers
.
computeIfAbsent
(
root
,
k
->
new
HashSet
<>()).
add
(
node
);
}
}
// 步骤2:仅用有效边更新团体关系
// 处理有效边,更新团体关系
UnionFindVO
filteredUf
=
new
UnionFindVO
();
// 新建过滤后的并查集
for
(
EdgeVO
edge
:
validEdges
)
{
validNodes
.
forEach
(
filteredUf:
:
makeSet
);
// 更新过滤后的并查集
for
(
EdgeVO
edge
:
graph
.
getEdges
())
{
filteredUf
.
union
(
edge
.
getSource
(),
edge
.
getTarget
());
filteredUf
.
union
(
edge
.
getSource
(),
edge
.
getTarget
());
// 更新团体统计
// 更新团体统计
String
root
=
filteredUf
.
find
(
edge
.
getSource
());
String
originalRoot
=
uf
.
find
(
edge
.
getSource
());
groupTotalAmount
.
merge
(
root
,
edge
.
getTotalAmount
(),
Double:
:
sum
);
groupTotalAmount
.
merge
(
originalRoot
,
edge
.
getTotalAmount
(),
Double:
:
sum
);
groupTotalTransactions
.
merge
(
root
,
edge
.
getTotalTransactions
(),
Integer:
:
sum
);
groupTotalTransactions
.
merge
(
originalRoot
,
edge
.
getTotalTransactions
(),
Integer:
:
sum
);
}
// 第五步:计算成员明细
Map
<
String
,
GroupDetailEntity
>
memberDetailMap
=
new
HashMap
<>();
// 初始化所有有效节点的成员明细
for
(
String
node
:
validNodes
)
{
memberDetailMap
.
put
(
node
,
new
GroupDetailEntity
(
node
));
}
// 更新成员明细
for
(
EdgeVO
edge
:
validEdges
)
{
String
payer
=
edge
.
getSource
();
String
payee
=
edge
.
getTarget
();
double
amount
=
edge
.
getTotalAmount
();
// 更新付款人(转出)
GroupDetailEntity
payerDetail
=
memberDetailMap
.
get
(
payer
);
if
(
payerDetail
!=
null
)
{
payerDetail
.
addOutgoingTransaction
(
amount
);
payerDetail
.
incrementTransactionCount
(
edge
.
getTotalTransactions
());
}
}
// 步骤3:合并最终团体
// 更新收款人(转入)
GroupDetailEntity
payeeDetail
=
memberDetailMap
.
get
(
payee
);
if
(
payeeDetail
!=
null
)
{
payeeDetail
.
addIncomingTransaction
(
amount
);
payeeDetail
.
incrementTransactionCount
(
edge
.
getTotalTransactions
());
}
}
// 第六步:处理团体合并(因过滤可能改变团体结构)
for
(
String
node
:
validNodes
)
{
for
(
String
node
:
validNodes
)
{
String
originalRoot
=
uf
.
find
(
node
);
String
newRoot
=
filteredUf
.
find
(
node
);
String
newRoot
=
filteredUf
.
find
(
node
);
String
oldRoot
=
uf
.
find
(
node
);
if
(!
new
Root
.
equals
(
old
Root
))
{
if
(!
original
Root
.
equals
(
new
Root
))
{
// 合并团体
// 合并团体
Set
<
String
>
members
=
groupMembers
.
remove
(
ol
d
Root
);
Set
<
String
>
members
=
groupMembers
.
remove
(
o
rigina
lRoot
);
if
(
members
!=
null
)
{
if
(
members
!=
null
)
{
groupMembers
.
computeIfAbsent
(
newRoot
,
k
->
new
HashSet
<>()).
addAll
(
members
);
groupMembers
.
computeIfAbsent
(
newRoot
,
k
->
new
HashSet
<>()).
addAll
(
members
);
// 合并统计信息
if
(
groupTotalAmount
.
containsKey
(
originalRoot
))
{
groupTotalAmount
.
merge
(
newRoot
,
groupTotalAmount
.
get
(
originalRoot
),
Double:
:
sum
);
groupTotalAmount
.
remove
(
originalRoot
);
}
if
(
groupTotalTransactions
.
containsKey
(
originalRoot
))
{
groupTotalTransactions
.
merge
(
newRoot
,
groupTotalTransactions
.
get
(
originalRoot
),
Integer:
:
sum
);
groupTotalTransactions
.
remove
(
originalRoot
);
}
}
}
}
}
}
}
// === 修复3
:生成
最终
团体对象
===
// 第七步
:生成团体对象
for
(
Map
.
Entry
<
String
,
Set
<
String
>>
entry
:
groupMembers
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
Set
<
String
>>
entry
:
groupMembers
.
entrySet
())
{
String
groupId
=
entry
.
getKey
();
String
groupId
=
entry
.
getKey
();
Set
<
String
>
members
=
entry
.
getValue
();
Set
<
String
>
members
=
entry
.
getValue
();
// 跳过孤立节点
(可选)
// 跳过孤立节点
if
(
members
.
size
()
==
1
&&
!
hasConnections
(
members
,
graph
))
{
if
(
members
.
size
()
==
1
&&
!
hasConnections
(
members
,
graph
))
{
continue
;
continue
;
}
}
// 收集成员明细
List
<
GroupDetailEntity
>
memberDetails
=
new
ArrayList
<>();
for
(
String
member
:
members
)
{
GroupDetailEntity
detail
=
memberDetailMap
.
get
(
member
);
if
(
detail
!=
null
)
{
memberDetails
.
add
(
detail
);
}
}
// 按用户名排序
memberDetails
.
sort
(
Comparator
.
comparing
(
GroupDetailEntity:
:
getUserName
));
// 添加团体对象
graph
.
addGroup
(
new
GroupVO
(
graph
.
addGroup
(
new
GroupVO
(
groupId
,
groupId
,
members
.
size
(),
members
.
size
(),
groupTotalAmount
.
getOrDefault
(
groupId
,
0.0
),
groupTotalAmount
.
getOrDefault
(
groupId
,
0.0
),
groupTotalTransactions
.
getOrDefault
(
groupId
,
0
)
groupTotalTransactions
.
getOrDefault
(
groupId
,
0
),
memberDetails
));
));
}
}
}
//保存团体数据
groupService
.
saveGroup
(
caseDTO
.
getId
(),
graph
.
getGroups
());
return
graph
;
return
graph
;
}
}
// 节点过滤逻辑
private
boolean
shouldIncludeNode
(
String
node
,
CaseDTO
caseDTO
)
{
if
(
caseDTO
.
getPrincipal
()
==
null
)
{
return
true
;
// 无过滤条件时包含所有节点
}
if
(
caseDTO
.
getPrincipal
()
==
1
)
{
// 过滤掉收款人名称中带有公司的数据
return
!(
node
.
contains
(
"公司"
)
||
node
.
length
()
>
4
);
}
else
{
// 过滤掉收款人名称中不含公司的数据
return
node
.
contains
(
"公司"
)
||
node
.
length
()
>
4
;
}
}
// 检查团体是否有实际连接(非孤立节点)
// 检查团体是否有实际连接(非孤立节点)
private
boolean
hasConnections
(
Set
<
String
>
members
,
GraphVO
graph
)
{
private
boolean
hasConnections
(
Set
<
String
>
members
,
GraphVO
graph
)
{
return
graph
.
getEdges
().
stream
()
return
graph
.
getEdges
().
stream
()
...
...
src/main/java/com/platform/service/impl/GroupDetailServiceImpl.java
0 → 100644
View file @
29136673
package
com.platform.service.impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.platform.mapper.GroupDetailMapper
;
import
com.platform.model.entity.GroupDetailEntity
;
import
com.platform.service.GroupDetailService
;
import
org.springframework.stereotype.Service
;
@Service
public
class
GroupDetailServiceImpl
extends
ServiceImpl
<
GroupDetailMapper
,
GroupDetailEntity
>
implements
GroupDetailService
{
}
src/main/java/com/platform/service/impl/GroupServiceImpl.java
0 → 100644
View file @
29136673
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.GroupMapper
;
import
com.platform.model.entity.GroupDetailEntity
;
import
com.platform.model.entity.GroupEntity
;
import
com.platform.model.vo.GroupVO
;
import
com.platform.service.GroupDetailService
;
import
com.platform.service.GroupService
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
@Service
public
class
GroupServiceImpl
extends
ServiceImpl
<
GroupMapper
,
GroupEntity
>
implements
GroupService
{
@Resource
private
GroupDetailService
groupDetailService
;
@Override
public
void
saveGroup
(
int
id
,
List
<
GroupVO
>
groups
)
{
//先删除每个案例的团体数据
baseMapper
.
delete
(
new
LambdaQueryWrapper
<
GroupEntity
>()
.
eq
(
GroupEntity:
:
getCaseId
,
id
));
groupDetailService
.
remove
(
new
LambdaQueryWrapper
<
GroupDetailEntity
>()
.
eq
(
GroupDetailEntity:
:
getCaseId
,
id
));
//保存新的案例团体和
groups
.
forEach
(
groupVO
->
{
//初始化团体实体
GroupEntity
groupEntity
=
new
GroupEntity
();
groupEntity
.
setGroupSize
(
groupVO
.
getGroupSize
());
groupEntity
.
setGroupName
(
groupVO
.
getGroupName
());
groupEntity
.
setCaseId
(
id
);
groupEntity
.
setTotalAmount
(
groupVO
.
getTotalAmount
());
groupEntity
.
setTotalTransactions
(
groupVO
.
getTotalTransactions
());
//入库
save
(
groupEntity
);
System
.
out
.
println
(
groupEntity
.
getId
());
groupVO
.
setId
(
groupEntity
.
getId
());
List
<
GroupDetailEntity
>
groupDetailList
=
groupVO
.
getGroupDetailList
();
if
(
CollUtil
.
isNotEmpty
(
groupDetailList
))
{
groupDetailList
.
forEach
(
groupDetailEntity
->
groupDetailEntity
.
setCaseId
(
id
));
groupDetailService
.
saveBatch
(
groupDetailList
);
}
groupVO
.
setGroupDetailList
(
null
);
});
}
}
src/main/resources/com/platform/mapper/ExcelDataMapper.xml
View file @
29136673
...
@@ -29,6 +29,8 @@
...
@@ -29,6 +29,8 @@
excel_data
excel_data
where
where
use_flag = 1
use_flag = 1
and
case_id = #{id}
<if
test=
"startTime != null and endTime != ''"
>
<if
test=
"startTime != null and endTime != ''"
>
and time betwenn #{startTime} and #{endTime}
and time betwenn #{startTime} and #{endTime}
</if>
</if>
...
...
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