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
Hide 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,150 +95,224 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CaseEntity> impleme
...
@@ -91,150 +95,224 @@ 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
()))
{
}
String
payer
=
excelDataEntity
.
getPayUserName
();
// 第一步:处理原始数据
String
payee
=
excelDataEntity
.
getPayeeName
();
for
(
ExcelDataEntity
excelDataEntity
:
excelDataEntityList
)
{
double
amount
=
excelDataEntity
.
getAmount
();
if
(
StringUtils
.
isEmpty
(
excelDataEntity
.
getPayUserName
())
||
StringUtils
.
isEmpty
(
excelDataEntity
.
getPayeeName
()))
{
// 添加节点到并查集
continue
;
// 跳过无效记录
uf
.
makeSet
(
payer
);
}
uf
.
makeSet
(
payee
);
String
payer
=
excelDataEntity
.
getPayUserName
();
// 合并团体
String
payee
=
excelDataEntity
.
getPayeeName
();
uf
.
union
(
payer
,
payee
);
double
amount
=
excelDataEntity
.
getAmount
();
// 生成边的唯一标识
// 添加到并查集
String
edgeKey
=
payer
+
"-"
+
payee
;
uf
.
makeSet
(
payer
);
uf
.
makeSet
(
payee
);
// 检查是否已经存在这条边
uf
.
union
(
payer
,
payee
);
if
(
edgeMap
.
containsKey
(
edgeKey
))
{
// 如果存在,更新总笔数和总金额
// 处理边信息
EdgeVO
existingEdge
=
edgeMap
.
get
(
edgeKey
);
String
edgeKey
=
payer
+
"-"
+
payee
;
existingEdge
.
setTotalTransactions
(
existingEdge
.
getTotalTransactions
()
+
1
);
EdgeVO
existingEdge
=
edgeMap
.
get
(
edgeKey
);
existingEdge
.
setTotalAmount
(
existingEdge
.
getTotalAmount
()
+
amount
);
}
else
{
if
(
existingEdge
!=
null
)
{
// 如果不存在,创建新的边
// 更新现有边
String
edgeId
=
"line-"
+
payer
+
"-"
+
payee
;
existingEdge
.
setTotalTransactions
(
existingEdge
.
getTotalTransactions
()
+
1
);
EdgeVO
newEdge
=
new
EdgeVO
(
edgeId
,
payer
,
payee
,
1
,
amount
,
uf
.
find
(
payer
));
existingEdge
.
setTotalAmount
(
existingEdge
.
getTotalAmount
()
+
amount
);
edgeMap
.
put
(
edgeKey
,
newEdge
);
}
else
{
}
// 创建新边
}
String
edgeId
=
"line-"
+
payer
+
"-"
+
payee
;
});
EdgeVO
newEdge
=
new
EdgeVO
(
edgeId
,
payer
,
payee
,
1
,
amount
,
uf
.
find
(
payer
));
edgeMap
.
put
(
edgeKey
,
newEdge
);
// === 修复1:先完成所有过滤 ===
}
Set
<
String
>
validNodes
=
new
HashSet
<>();
// 有效节点集合
}
// 节点过滤
// 第二步:过滤节点
for
(
String
node
:
uf
.
getParent
().
keySet
())
{
Set
<
String
>
validNodes
=
new
HashSet
<>();
if
(
caseDTO
.
getPrincipal
()
!=
null
)
{
for
(
String
node
:
uf
.
getParent
().
keySet
())
{
if
(
caseDTO
.
getPrincipal
()
==
1
)
{
if
(
shouldIncludeNode
(
node
,
caseDTO
))
{
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
));
}
}
}
// 边过滤(同时检查两端节点有效性)
// 第三步:过滤边
for
(
EdgeVO
edge
:
edgeMap
.
values
())
{
List
<
EdgeVO
>
validEdges
=
new
ArrayList
<>();
// 检查两端节点是否有效
for
(
EdgeVO
edge
:
edgeMap
.
values
())
{
if
(!
validNodes
.
contains
(
edge
.
getSource
())
||
// 检查两端节点是否有效
!
validNodes
.
contains
(
edge
.
getTarget
()))
{
if
(!
validNodes
.
contains
(
edge
.
getSource
())
||
!
validNodes
.
contains
(
edge
.
getTarget
()))
{
continue
;
}
// 检查金额过滤条件
if
(
caseDTO
.
getMinAmount
()
!=
null
&&
caseDTO
.
getMaxAmount
()
!=
null
)
{
if
(
edge
.
getTotalAmount
()
<
caseDTO
.
getMinAmount
()
||
edge
.
getTotalAmount
()
>
caseDTO
.
getMaxAmount
())
{
continue
;
continue
;
}
}
}
// 金额/笔
数过滤
// 检查交易次
数过滤
条件
boolean
amountValid
=
true
;
if
(
caseDTO
.
getMinTransaction
()
!=
null
&&
caseDTO
.
getMaxTransaction
()
!=
null
)
{
if
(
caseDTO
.
getMinAmount
()
!=
null
&&
caseDTO
.
getMaxAmount
()
!=
null
)
{
if
(
edge
.
getTotalTransactions
()
<
caseDTO
.
getMinTransaction
()
||
amountValid
=
edge
.
getTotal
Amount
()
>
=
caseDTO
.
getM
inAmount
()
edge
.
getTotal
Transactions
()
>
caseDTO
.
getM
axTransaction
())
{
&&
edge
.
getTotalAmount
()
<=
caseDTO
.
getMaxAmount
()
;
continue
;
}
}
}
boolean
transValid
=
true
;
// 添加到有效边集合
if
(
caseDTO
.
getMinTransaction
()
!=
null
&&
caseDTO
.
getMaxTransaction
()
!=
null
)
{
validEdges
.
add
(
edge
);
transValid
=
edge
.
getTotalTransactions
()
>=
caseDTO
.
getMinTransaction
()
graph
.
addEdge
(
edge
);
&&
edge
.
getTotalTransactions
()
<=
caseDTO
.
getMaxTransaction
();
}
}
if
(
amountValid
||
transValid
)
{
// 第四步:重建过滤后的团体关系
graph
.
addEdge
(
edge
);
// 创建新的并查集用于过滤后的数据
}
UnionFindVO
filteredUf
=
new
UnionFindVO
();
}
validNodes
.
forEach
(
filteredUf:
:
makeSet
);
// === 修复2:基于过滤后数据重建团体 ===
// 用于按团体分组统计
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
);
}
}
// 处理有效边,更新团体关系
for
(
EdgeVO
edge
:
validEdges
)
{
// 更新过滤后的并查集
filteredUf
.
union
(
edge
.
getSource
(),
edge
.
getTarget
());
// 步骤2:仅用有效边更新团体关系
// 更新团体统计
UnionFindVO
filteredUf
=
new
UnionFindVO
();
// 新建过滤后的并查集
String
originalRoot
=
uf
.
find
(
edge
.
getSource
());
validNodes
.
forEach
(
filteredUf:
:
makeSet
);
groupTotalAmount
.
merge
(
originalRoot
,
edge
.
getTotalAmount
(),
Double:
:
sum
);
groupTotalTransactions
.
merge
(
originalRoot
,
edge
.
getTotalTransactions
(),
Integer:
:
sum
);
}
// 第五步:计算成员明细
Map
<
String
,
GroupDetailEntity
>
memberDetailMap
=
new
HashMap
<>();
for
(
EdgeVO
edge
:
graph
.
getEdges
())
{
// 初始化所有有效节点的成员明细
filteredUf
.
union
(
edge
.
getSource
(),
edge
.
getTarget
());
for
(
String
node
:
validNodes
)
{
memberDetailMap
.
put
(
node
,
new
GroupDetailEntity
(
node
));
}
// 更新团体统计
// 更新成员明细
String
root
=
filteredUf
.
find
(
edge
.
getSource
());
for
(
EdgeVO
edge
:
validEdges
)
{
groupTotalAmount
.
merge
(
root
,
edge
.
getTotalAmount
(),
Double:
:
sum
);
String
payer
=
edge
.
getSource
();
groupTotalTransactions
.
merge
(
root
,
edge
.
getTotalTransactions
(),
Integer:
:
sum
);
String
payee
=
edge
.
getTarget
();
double
amount
=
edge
.
getTotalAmount
();
// 更新付款人(转出)
GroupDetailEntity
payerDetail
=
memberDetailMap
.
get
(
payer
);
if
(
payerDetail
!=
null
)
{
payerDetail
.
addOutgoingTransaction
(
amount
);
payerDetail
.
incrementTransactionCount
(
edge
.
getTotalTransactions
());
}
}
// 步骤3:合并最终团体
// 更新收款人(转入)
for
(
String
node
:
validNodes
)
{
GroupDetailEntity
payeeDetail
=
memberDetailMap
.
get
(
payee
);
String
newRoot
=
filteredUf
.
find
(
node
);
if
(
payeeDetail
!=
null
)
{
String
oldRoot
=
uf
.
find
(
node
);
payeeDetail
.
addIncomingTransaction
(
amount
);
payeeDetail
.
incrementTransactionCount
(
edge
.
getTotalTransactions
());
}
}
if
(!
newRoot
.
equals
(
oldRoot
))
{
// 第六步:处理团体合并(因过滤可能改变团体结构)
// 合并团体
for
(
String
node
:
validNodes
)
{
Set
<
String
>
members
=
groupMembers
.
remove
(
oldRoot
);
String
originalRoot
=
uf
.
find
(
node
);
if
(
members
!=
null
)
{
String
newRoot
=
filteredUf
.
find
(
node
);
groupMembers
.
computeIfAbsent
(
newRoot
,
k
->
new
HashSet
<>()).
addAll
(
members
);
if
(!
originalRoot
.
equals
(
newRoot
))
{
// 合并团体
Set
<
String
>
members
=
groupMembers
.
remove
(
originalRoot
);
if
(
members
!=
null
)
{
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
;
}
}
graph
.
addGroup
(
new
GroupVO
(
// 收集成员明细
groupId
,
List
<
GroupDetailEntity
>
memberDetails
=
new
ArrayList
<>();
members
.
size
(),
for
(
String
member
:
members
)
{
groupTotalAmount
.
getOrDefault
(
groupId
,
0.0
),
GroupDetailEntity
detail
=
memberDetailMap
.
get
(
member
);
groupTotalTransactions
.
getOrDefault
(
groupId
,
0
)
if
(
detail
!=
null
)
{
));
memberDetails
.
add
(
detail
);
}
}
}
// 按用户名排序
memberDetails
.
sort
(
Comparator
.
comparing
(
GroupDetailEntity:
:
getUserName
));
// 添加团体对象
graph
.
addGroup
(
new
GroupVO
(
groupId
,
members
.
size
(),
groupTotalAmount
.
getOrDefault
(
groupId
,
0.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