Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dsk-operate-sys-cscec
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
fulixin
dsk-operate-sys-cscec
Commits
3f6ab6e8
Commit
3f6ab6e8
authored
Mar 04, 2024
by
lcl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
u
parent
b8417920
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
47 deletions
+55
-47
DataAnalysisComponent.java
...rc/main/java/com/dsk/component/DataAnalysisComponent.java
+53
-44
CbProjectFileMapper.xml
...i/src/main/resources/mapper/cscec/CbProjectFileMapper.xml
+2
-3
No files found.
dsk-module/dsk-biz-api/src/main/java/com/dsk/component/DataAnalysisComponent.java
View file @
3f6ab6e8
...
@@ -49,39 +49,42 @@ public class DataAnalysisComponent {
...
@@ -49,39 +49,42 @@ public class DataAnalysisComponent {
*/
*/
@Async
@Async
public
void
quantitySummaryDataAnalysis
(
CbProjectBaseBo
bo
)
throws
Exception
{
public
void
quantitySummaryDataAnalysis
(
CbProjectBaseBo
bo
)
throws
Exception
{
//查询工料汇总导入文件
//查询工料汇总导入文件
List
<
CbProjectFile
>
fileList
=
projectFileService
.
selectAnalysisList
(
bo
.
getProjectId
(),
CbProjectConstants
.
CB_TYPE_QUANTITY_SUMMARY
,
bo
.
getCbStage
());
List
<
CbProjectFile
>
fileList
=
projectFileService
.
selectAnalysisList
(
bo
.
getProjectId
(),
CbProjectConstants
.
CB_TYPE_QUANTITY_SUMMARY
,
bo
.
getCbStage
());
if
(
ObjectUtils
.
isEmpty
(
fileList
))
return
;
if
(
ObjectUtils
.
isEmpty
(
fileList
))
return
;
//文件处理
//文件处理
for
(
CbProjectFile
file
:
fileList
)
{
for
(
CbProjectFile
file
:
fileList
)
{
//文件下载
try
{
InputStream
inputStream
=
ossService
.
downFileIO
(
file
.
getFileOssId
());
//文件下载
if
(
ObjectUtil
.
isNull
(
inputStream
))
{
InputStream
inputStream
=
ossService
.
downFileIO
(
file
.
getFileOssId
());
file
.
setFileParseStatus
(
3
);
if
(
ObjectUtil
.
isNull
(
inputStream
))
{
file
.
setFailRemark
(
"文件数据不存在"
);
file
.
setFileParseStatus
(
3
);
projectFileService
.
updateById
(
file
);
file
.
setFailRemark
(
"文件数据不存在"
);
break
;
projectFileService
.
updateById
(
file
);
}
break
;
//解析数据
}
List
<
CbQuantitySummary
>
importList
=
new
ExcelUtils
<>(
CbQuantitySummary
.
class
).
importExcelAllSheet
(
inputStream
,
1
);
//解析数据
if
(
importList
.
isEmpty
())
{
List
<
CbQuantitySummary
>
importList
=
new
ExcelUtils
<>(
CbQuantitySummary
.
class
).
importExcelAllSheet
(
inputStream
,
1
);
file
.
setFileParseStatus
(
3
);
if
(
importList
.
isEmpty
())
{
file
.
setFailRemark
(
"表格中不存在待导入数据!"
);
file
.
setFileParseStatus
(
3
);
projectFileService
.
updateById
(
file
);
file
.
setFailRemark
(
"表格中不存在待导入数据!"
);
break
;
projectFileService
.
updateById
(
file
);
}
break
;
List
<
CbQuantitySummary
>
quantitySummaryList
=
importList
.
stream
().
parallel
()
}
.
filter
(
item
->
!
ObjectUtils
.
isEmpty
(
item
.
getCbName
()))
List
<
CbQuantitySummary
>
quantitySummaryList
=
importList
.
stream
().
parallel
()
.
peek
(
item
->
{
.
filter
(
item
->
!
ObjectUtils
.
isEmpty
(
item
.
getCbName
()))
item
.
setProjectId
(
bo
.
getProjectId
());
.
peek
(
item
->
{
item
.
setCbStage
(
bo
.
getCbStage
());
item
.
setProjectId
(
bo
.
getProjectId
());
item
.
setCbProjectFileId
(
file
.
getId
());
item
.
setCbStage
(
bo
.
getCbStage
());
}).
collect
(
Collectors
.
toList
());
item
.
setCbProjectFileId
(
file
.
getId
());
if
(
quantitySummaryList
.
isEmpty
())
{
}).
collect
(
Collectors
.
toList
());
throw
new
ServiceException
(
"表格中不存在有效数据!"
);
if
(
quantitySummaryList
.
isEmpty
())
{
}
throw
new
ServiceException
(
"表格中不存在有效数据!"
);
transactionTemplate
.
execute
(
status
->
{
}
try
{
transactionTemplate
.
execute
(
status
->
{
try
{
// //分批次插入
// //分批次插入
// if (quantitySummaryList.size() > 1000) {
// if (quantitySummaryList.size() > 1000) {
// int index = 0;
// int index = 0;
...
@@ -100,23 +103,29 @@ public class DataAnalysisComponent {
...
@@ -100,23 +103,29 @@ public class DataAnalysisComponent {
// throw new ServiceException("数据插入失败!");
// throw new ServiceException("数据插入失败!");
// }
// }
// }
// }
boolean
a
=
quantitySummaryService
.
batchInsert
(
quantitySummaryList
);
boolean
a
=
quantitySummaryService
.
batchInsert
(
quantitySummaryList
);
if
(!
a
)
{
if
(!
a
)
{
throw
new
ServiceException
(
"数据插入失败!"
);
throw
new
ServiceException
(
"数据插入失败!"
);
}
}
file
.
setFileParseStatus
(
2
);
file
.
setFileParseStatus
(
2
);
boolean
b
=
projectFileService
.
updateById
(
file
);
boolean
b
=
projectFileService
.
updateById
(
file
);
if
(!
b
)
{
if
(!
b
)
{
throw
new
ServiceException
(
"文件状态更新失败!"
);
throw
new
ServiceException
(
"文件状态更新失败!"
);
}
}
catch
(
Exception
e
)
{
status
.
setRollbackOnly
();
file
.
setFileParseStatus
(
3
);
file
.
setFailRemark
(
e
.
getMessage
());
projectFileService
.
updateById
(
file
);
}
}
}
catch
(
Exception
e
)
{
return
Boolean
.
TRUE
;
status
.
setRollbackOnly
();
});
file
.
setFileParseStatus
(
3
);
}
catch
(
Exception
e
)
{
file
.
setFailRemark
(
e
.
getMessage
());
file
.
setFileParseStatus
(
3
);
projectFileService
.
updateById
(
file
);
file
.
setFailRemark
(
e
.
getMessage
());
}
projectFileService
.
updateById
(
file
);
return
Boolean
.
TRUE
;
}
});
}
}
}
}
}
}
dsk-module/dsk-biz-api/src/main/resources/mapper/cscec/CbProjectFileMapper.xml
View file @
3f6ab6e8
...
@@ -17,12 +17,11 @@
...
@@ -17,12 +17,11 @@
id, project_id, cb_stage, cb_type, file_name, file_oss_id, file_oss_url, file_parse_status, fail_remark,
id, project_id, cb_stage, cb_type, file_name, file_oss_id, file_oss_url, file_parse_status, fail_remark,
del_flag, create_by, create_time, update_by, update_time
del_flag, create_by, create_time, update_by, update_time
FROM cb_project_file
FROM cb_project_file
WHERE (del_flag = 0 and file_parse_status = 1
WHERE del_flag = 0 and file_parse_status in (1,3) and project_id=#{projectId}
and project_id=#{projectId}
<if
test=
"cbStage != null"
>
<if
test=
"cbStage != null"
>
and cb_stage =#{cbStage}
and cb_stage =#{cbStage}
</if>
</if>
and cb_type = #{cbType}
)
and cb_type = #{cbType}
</select>
</select>
<update
id=
"removeById"
>
<update
id=
"removeById"
>
...
...
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