Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
JingnengService
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王亚宁
JingnengService
Commits
260f4e35
Commit
260f4e35
authored
Jul 19, 2024
by
liangyb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#20240719 评标工具-项目解析结构化数据保存数据失败
parent
ae0fc601
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
5 deletions
+24
-5
com.gx.obe.service/src/main/java/com/gx/obe/server/management/struct_new/service/impl/ObeEvaluationContentServiceImpl.java
...uct_new/service/impl/ObeEvaluationContentServiceImpl.java
+24
-5
No files found.
com.gx.obe.service/src/main/java/com/gx/obe/server/management/struct_new/service/impl/ObeEvaluationContentServiceImpl.java
View file @
260f4e35
...
...
@@ -2,14 +2,12 @@ package com.gx.obe.server.management.struct_new.service.impl;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.gx.obe.server.common.utils.CollectionUtils
;
import
com.gx.obe.server.common.utils.ExceptionUtil
;
import
com.gx.obe.server.common.utils.IDUtils
;
import
com.gx.obe.server.common.utils.StringUtils
;
import
com.gx.obe.server.common.utils.*
;
import
com.gx.obe.server.management.struct_new.dao.*
;
import
com.gx.obe.server.management.struct_new.entity.*
;
import
com.gx.obe.server.management.struct_new.service.ObeEvaluationContentService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.dao.DataIntegrityViolationException
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -177,6 +175,27 @@ public class ObeEvaluationContentServiceImpl extends ServiceImpl<ObeEvaluationCo
return
obeEvaluationContentMapper
.
selectList
(
queryWrapper
);
}
/**
* 捕获重复ID的异常,重新生成UUID并重试插入
* @param templateTableList tableList
* @param attempt 尝试次数
*/
private
void
dataIntegrityViolationHandle
(
List
<
ObeTemplateTable
>
templateTableList
,
int
attempt
)
throws
RuntimeException
{
if
(
attempt
>
3
)
{
// 如果重试次数超过3次,抛出异常或其他处理方式
throw
new
RuntimeException
(
"Failed to insert data after multiple attempts"
);
}
try
{
int
inserted
=
obeTemplateTableMapper
.
insertByBatch
(
templateTableList
);
ExceptionUtil
.
equal
(
inserted
,
templateTableList
.
size
());
}
catch
(
DataIntegrityViolationException
ex
){
// 捕获重复ID的异常,重新生成UUID并重试插入
for
(
ObeTemplateTable
data
:
templateTableList
)
{
data
.
setId
(
UuidUtils
.
getUUID
());
}
dataIntegrityViolationHandle
(
templateTableList
,
attempt
+
1
);
}
}
/**
* @param structDateInfo
* @Description: 保存结构化信息数据
...
...
@@ -187,7 +206,7 @@ public class ObeEvaluationContentServiceImpl extends ServiceImpl<ObeEvaluationCo
public
boolean
saveStructDateInfo
(
StructDateInfo
structDateInfo
)
{
List
<
ObeTemplateTable
>
templateTableList
=
structDateInfo
.
getTemplateTableList
();
if
(
CollectionUtils
.
isNotNull
(
templateTableList
))
ExceptionUtil
.
equal
(
obeTemplateTableMapper
.
insertByBatch
(
templateTableList
),
templateTableList
.
size
()
);
dataIntegrityViolationHandle
(
templateTableList
,
1
);
List
<
ObeModelData
>
modelDataList
=
structDateInfo
.
getModelDataList
();
if
(
CollectionUtils
.
isNotNull
(
modelDataList
))
...
...
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