Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-mvp
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fangxinjiang
yifu-mvp
Commits
a736e392
Commit
a736e392
authored
Mar 20, 2025
by
fangxinjiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
项目规则配置-fxj
parent
72f7b228
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
26 deletions
+32
-26
TAutoMainRelServiceImpl.java
...1/yifu/archives/service/impl/TAutoMainRelServiceImpl.java
+32
-26
No files found.
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/impl/TAutoMainRelServiceImpl.java
View file @
a736e392
...
...
@@ -42,6 +42,7 @@ import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import
lombok.extern.log4j.Log4j2
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -336,6 +337,7 @@ public class TAutoMainRelServiceImpl extends ServiceImpl<TAutoMainRelMapper, TAu
* @param entity 包含要更新的关联信息的实体对象
* @return 返回一个表示操作结果的响应对象
*/
@Transactional
public
R
<
Boolean
>
updateAsso
(
TAutoMainRelAddVo
entity
)
{
// 获取当前用户信息
YifuUser
user
=
SecurityUtils
.
getUser
();
...
...
@@ -492,7 +494,11 @@ private R<Boolean> checkItemRepeat(List<SysAutoDictItem> autoDictItems, Map<Stri
}
/**
* @Author fxj
* @Description 功能概述:dictItemHandle 方法用于处理字典项的更新或新增操作,同时记录差异字段。
* @Date 17:09 2025/3/20
**/
private
void
dictItemHandle
(
YifuUser
user
,
TAutoMainRel
autoMainRel
,
SysAutoDict
autoDict
,
...
...
@@ -501,49 +507,49 @@ private R<Boolean> checkItemRepeat(List<SysAutoDictItem> autoDictItems, Map<Stri
List
<
SysAutoDictItem
>
oldAutoDictItems
)
{
if
(
Common
.
isNotNull
(
autoDictItems
)){
// 初始化旧字典项映射
Map
<
Long
,
SysAutoDictItem
>
oldItemMap
=
null
;
if
(
Common
.
isNotNull
(
oldAutoDictItems
)){
oldItemMap
=
oldAutoDictItems
.
stream
().
collect
(
Collectors
.
toMap
(
SysAutoDictItem:
:
getId
,
v
->
v
));
}
SysAutoDictItem
oldItem
;
String
diffKey
;
StringBuilder
difkeys
=
new
StringBuilder
(
""
);
List
<
String
>
ignore
=
new
ArrayLis
t
<>();
ignore
.
add
(
"value,
sortOrder"
);
// 初始化差异字段存储
Set
<
String
>
diffKeysSet
=
new
HashSe
t
<>();
List
<
String
>
ignoreFields
=
Arrays
.
asList
(
"value"
,
"
sortOrder"
);
for
(
SysAutoDictItem
sysAutoDictItem
:
autoDictItems
){
initDictItem
(
sysAutoDictItem
,
user
,
autoDict
,
autoMainRel
);
if
(
Common
.
isNotNull
(
sysAutoDictItem
.
getId
())){
oldItem
=
null
==
oldItemMap
?
null
:
oldItemMap
.
get
(
sysAutoDictItem
.
getId
());
if
(
Common
.
isNotNull
(
oldItem
)){
diffKey
=
HrEquator
.
comparisonValueIgnoreField
(
oldItem
,
sysAutoDictItem
,
ignore
);
if
(
Common
.
isNotNull
(
diffKey
)){
if
(
Common
.
isEmpty
(
difkeys
.
toString
())){
difkeys
.
append
(
diffKey
);
}
else
{
difkeys
.
append
(
CommonConstants
.
COMMA_STRING
);
difkeys
.
append
(
diffKey
);
}
if
(
Common
.
isNotNull
(
oldItem
))
{
diffKey
=
HrEquator
.
comparisonValueIgnoreField
(
oldItem
,
sysAutoDictItem
,
ignoreFields
);
if
(
Common
.
isNotNull
(
diffKey
))
{
diffKeysSet
.
add
(
diffKey
);
}
}
autoDictItemMapper
.
updateById
(
sysAutoDictItem
);
}
else
{
if
(
Common
.
isEmpty
(
difkeys
.
toString
())){
difkeys
.
append
(
itemsLabel
);
}
else
{
difkeys
.
append
(
CommonConstants
.
COMMA_STRING
);
difkeys
.
append
(
itemsLabel
);
try
{
autoDictItemMapper
.
updateById
(
sysAutoDictItem
);
}
catch
(
Exception
e
)
{
// 记录异常日志并继续处理其他项
log
.
error
(
"Failed to update dictionary item with ID: {}"
,
sysAutoDictItem
.
getId
(),
e
);
}
}
else
{
diffKeysSet
.
add
(
itemsLabel
);
sysAutoDictItem
.
setCreateTime
(
LocalDateTime
.
now
());
sysAutoDictItem
.
setCreateBy
(
user
.
getId
());
sysAutoDictItem
.
setCreateName
(
user
.
getNickname
());
autoDictItemMapper
.
insert
(
sysAutoDictItem
);
try
{
autoDictItemMapper
.
insert
(
sysAutoDictItem
);
}
catch
(
Exception
e
)
{
// 记录异常日志并继续处理其他项
log
.
error
(
"Failed to insert dictionary item: {}"
,
sysAutoDictItem
,
e
);
}
}
}
if
(!
Common
.
isEmpty
(
difkeys
.
toString
())){
String
[]
keys
=
difkeys
.
toString
().
split
(
CommonConstants
.
COMMA_STRING
);
String
keysStr
=
Arrays
.
stream
(
keys
).
distinct
().
collect
(
Collectors
.
joining
(
CommonConstants
.
COMMA_STRING
)
);
diffKeyMap
.
put
(
"postType"
,
keysStr
);
// 将差异字段集合转换为字符串并存入 diffKeyMap
if
(!
diffKeysSet
.
isEmpty
())
{
String
keysStr
=
String
.
join
(
CommonConstants
.
COMMA_STRING
,
diffKeysSet
);
diffKeyMap
.
put
(
"postType"
,
keysStr
);
}
}
}
...
...
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