Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-oss
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xingmin
yd-oss
Commits
25d87c00
Commit
25d87c00
authored
Mar 23, 2026
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parent
ffc1a049
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
2 deletions
+73
-2
yd-oss-api/src/main/java/com/yd/oss/api/service/impl/ApiRelObjectMaterialServiceImpl.java
+73
-2
No files found.
yd-oss-api/src/main/java/com/yd/oss/api/service/impl/ApiRelObjectMaterialServiceImpl.java
View file @
25d87c00
...
...
@@ -15,6 +15,10 @@ import com.yd.oss.feign.request.ApiRelObjectMaterialUploadSubmitRequest;
import
com.yd.oss.feign.response.ApiRelObjectMaterialPageResponse
;
import
com.yd.oss.service.model.RelObjectMaterial
;
import
com.yd.oss.service.service.IRelObjectMaterialService
;
import
com.yd.user.feign.client.sysdict.ApiSysDictFeignClient
;
import
com.yd.user.feign.request.sysdict.GetDictTypeListRequest
;
import
com.yd.user.feign.response.sysdict.GetDictItemListByDictTypeResponse
;
import
com.yd.user.feign.response.sysdict.GetDictTypeListResponse
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
...
...
@@ -22,8 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Service
...
...
@@ -36,6 +39,9 @@ public class ApiRelObjectMaterialServiceImpl implements ApiRelObjectMaterialServ
@Autowired
private
ApiOssFileService
apiOssFileService
;
@Autowired
private
ApiSysDictFeignClient
apiSysDictFeignClient
;
/**
* 分页列表查询-对象材料关系表信息
* @param request
...
...
@@ -45,6 +51,71 @@ public class ApiRelObjectMaterialServiceImpl implements ApiRelObjectMaterialServ
public
Result
<
IPage
<
ApiRelObjectMaterialPageResponse
>>
page
(
ApiRelObjectMaterialPageRequest
request
)
{
Page
<
ApiRelObjectMaterialPageResponse
>
page
=
new
Page
<>(
request
.
getPageNo
(),
request
.
getPageSize
());
IPage
<
ApiRelObjectMaterialPageResponse
>
iPage
=
iRelObjectMaterialService
.
page
(
page
,
request
);
// 如果没有数据,直接返回
if
(
iPage
==
null
||
CollectionUtils
.
isEmpty
(
iPage
.
getRecords
()))
{
return
Result
.
success
(
iPage
);
}
// 收集需要翻译的字典编码
Set
<
String
>
dataPersonSet
=
new
HashSet
<>();
Set
<
String
>
dataTypeSet
=
new
HashSet
<>();
for
(
ApiRelObjectMaterialPageResponse
record
:
iPage
.
getRecords
())
{
if
(
record
.
getDataPerson
()
!=
null
)
{
dataPersonSet
.
add
(
record
.
getDataPerson
());
}
if
(
record
.
getDataType
()
!=
null
)
{
dataTypeSet
.
add
(
record
.
getDataType
());
}
}
// 构建字典类型列表,批量查询
List
<
String
>
dictTypes
=
new
ArrayList
<>();
dictTypes
.
add
(
"oss_data_person"
);
dictTypes
.
add
(
"oss_data_type"
);
GetDictTypeListRequest
dictRequest
=
new
GetDictTypeListRequest
();
dictRequest
.
setTypeList
(
dictTypes
);
Result
<
List
<
GetDictTypeListResponse
>>
dictResult
=
apiSysDictFeignClient
.
getByDictTypeList
(
dictRequest
);
if
(
dictResult
==
null
||
dictResult
.
getCode
()
!=
200
||
CollectionUtils
.
isEmpty
(
dictResult
.
getData
()))
{
log
.
warn
(
"字典查询失败,无法翻译名称"
);
return
Result
.
success
(
iPage
);
}
// 构建字典映射:dictType -> (itemValue -> itemLabel)
Map
<
String
,
Map
<
String
,
String
>>
dictMapping
=
new
HashMap
<>();
for
(
GetDictTypeListResponse
dictTypeResp
:
dictResult
.
getData
())
{
String
dictType
=
dictTypeResp
.
getDictType
();
List
<
GetDictItemListByDictTypeResponse
>
itemList
=
dictTypeResp
.
getDictItemList
();
if
(
CollectionUtils
.
isEmpty
(
itemList
))
{
continue
;
}
Map
<
String
,
String
>
valueToLabel
=
itemList
.
stream
()
.
filter
(
item
->
item
.
getStatus
()
==
1
)
// 只取启用状态
.
collect
(
Collectors
.
toMap
(
GetDictItemListByDictTypeResponse:
:
getItemValue
,
GetDictItemListByDictTypeResponse:
:
getItemLabel
,
(
existing
,
replacement
)
->
existing
));
dictMapping
.
put
(
dictType
,
valueToLabel
);
}
// 获取两个字典的映射
Map
<
String
,
String
>
personMap
=
dictMapping
.
getOrDefault
(
"oss_data_person"
,
Collections
.
emptyMap
());
Map
<
String
,
String
>
typeMap
=
dictMapping
.
getOrDefault
(
"oss_data_type"
,
Collections
.
emptyMap
());
// 填充名称
for
(
ApiRelObjectMaterialPageResponse
record
:
iPage
.
getRecords
())
{
String
dataPerson
=
record
.
getDataPerson
();
if
(
dataPerson
!=
null
)
{
record
.
setDataPersonName
(
personMap
.
get
(
dataPerson
));
}
String
dataType
=
record
.
getDataType
();
if
(
dataType
!=
null
)
{
record
.
setDataTypeName
(
typeMap
.
get
(
dataType
));
}
}
return
Result
.
success
(
iPage
);
}
...
...
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