Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-csf
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-csf
Commits
2e6662bf
Commit
2e6662bf
authored
Mar 02, 2026
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parent
31979699
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
119 additions
and
26 deletions
+119
-26
yd-csf-api/src/main/java/com/yd/csf/api/service/impl/ApiAppointmentFileServiceImpl.java
+119
-26
No files found.
yd-csf-api/src/main/java/com/yd/csf/api/service/impl/ApiAppointmentFileServiceImpl.java
View file @
2e6662bf
...
@@ -430,32 +430,125 @@ public class ApiAppointmentFileServiceImpl implements ApiAppointmentFileService
...
@@ -430,32 +430,125 @@ public class ApiAppointmentFileServiceImpl implements ApiAppointmentFileService
* @param appointmentDto
* @param appointmentDto
* @return
* @return
*/
*/
// public List<ApiConvertExcelPlanNameDto> convertExcelPlanName(ApiExcelImportAppointmentDto appointmentDto) {
public
List
<
ApiConvertExcelPlanNameDto
>
convertExcelPlanName
(
ApiExcelImportAppointmentDto
appointmentDto
)
{
// List<String> reqNameList = new ArrayList<>();
// 1. 收集所有需要查询的产品名称(去重)
// if (StringUtils.isNotBlank(appointmentDto.getPlanProductName())){
Set
<
String
>
queryNameSet
=
new
HashSet
<>();
// //主计划产品名称
// //繁转简
// 主计划名称
// reqNameList.add(ChineseTextConverter.traditionalToSimplified(appointmentDto.getPlanProductName()));
if
(
StringUtils
.
isNotBlank
(
appointmentDto
.
getPlanProductName
()))
{
// //简转繁
queryNameSet
.
add
(
ChineseTextConverter
.
traditionalToSimplified
(
appointmentDto
.
getPlanProductName
()));
// reqNameList.add(ChineseTextConverter.simplifiedToTraditional(appointmentDto.getPlanProductName()));
queryNameSet
.
add
(
ChineseTextConverter
.
simplifiedToTraditional
(
appointmentDto
.
getPlanProductName
()));
// }
}
// if (CollectionUtils.isEmpty(appointmentDto.getAdditionalDtoList())){
// for (ApiExcelImportAdditionalDto additionalDto : appointmentDto.getAdditionalDtoList()) {
// 附加计划名称
// //附加计划产品名称
if
(!
CollectionUtils
.
isEmpty
(
appointmentDto
.
getAdditionalDtoList
()))
{
// //繁转简
for
(
ApiExcelImportAdditionalDto
additionalDto
:
appointmentDto
.
getAdditionalDtoList
())
{
// reqNameList.add(ChineseTextConverter.traditionalToSimplified(additionalDto.getAddProductName()));
if
(
StringUtils
.
isNotBlank
(
additionalDto
.
getAddProductName
()))
{
// //简转繁
queryNameSet
.
add
(
ChineseTextConverter
.
traditionalToSimplified
(
additionalDto
.
getAddProductName
()));
// reqNameList.add(ChineseTextConverter.simplifiedToTraditional(additionalDto.getAddProductName()));
queryNameSet
.
add
(
ChineseTextConverter
.
simplifiedToTraditional
(
additionalDto
.
getAddProductName
()));
// }
}
// }
}
// ApiProductLaunchPageRequest request = new ApiProductLaunchPageRequest();
}
// request.setNameList(reqNameList);
// Result<IPage<ApiProductLaunchPageResponse>> result = apiProductLaunchFeignClient.page(request);
// 如果没有需要查询的名称,直接返回空
// if (!Objects.isNull(result.getData()) && !CollectionUtils.isEmpty(result.getData().getRecords())) {
if
(
queryNameSet
.
isEmpty
())
{
// List<ApiProductLaunchPageResponse> responses = result.getData().getRecords();
return
Collections
.
emptyList
();
//
}
// }
// }
// 2. 调用 Feign 批量查询产品上架信息
ApiProductLaunchPageRequest
pageRequest
=
new
ApiProductLaunchPageRequest
();
pageRequest
.
setTitleList
(
new
ArrayList
<>(
queryNameSet
));
// 设置分页参数,尽可能大一些以获取全部数据
pageRequest
.
setPageNo
(
1
);
pageRequest
.
setPageSize
(
1000
);
Result
<
IPage
<
ApiProductLaunchPageResponse
>>
result
=
apiProductLaunchFeignClient
.
page
(
pageRequest
);
if
(
result
==
null
||
result
.
getData
()
==
null
||
CollectionUtils
.
isEmpty
(
result
.
getData
().
getRecords
()))
{
log
.
warn
(
"未找到匹配的产品计划,查询名称列表:{}"
,
queryNameSet
);
return
Collections
.
emptyList
();
}
// 3. 建立标题 -> 产品ID的映射(注意:标题可能因繁简不同而重复,这里使用原始返回的标题作为key)
Map
<
String
,
String
>
titleToIdMap
=
result
.
getData
().
getRecords
().
stream
()
.
filter
(
record
->
StringUtils
.
isNotBlank
(
record
.
getTitle
()))
.
collect
(
Collectors
.
toMap
(
ApiProductLaunchPageResponse:
:
getTitle
,
ApiProductLaunchPageResponse:
:
getProductLaunchBizId
,
(
v1
,
v2
)
->
v1
// 如果标题重复,取第一个(实际不会重复)
));
// 4. 构建返回的 DTO
ApiConvertExcelPlanNameDto
dto
=
new
ApiConvertExcelPlanNameDto
();
// 处理主计划
String
mainPlanOriginal
=
appointmentDto
.
getPlanProductName
();
if
(
StringUtils
.
isNotBlank
(
mainPlanOriginal
))
{
dto
.
setMainPlanName
(
mainPlanOriginal
);
// 优先用原始名称精确匹配,否则尝试用转换后的名称匹配
String
mainId
=
titleToIdMap
.
get
(
mainPlanOriginal
);
if
(
mainId
==
null
)
{
// 尝试繁体/简体转换后的名称
mainId
=
titleToIdMap
.
get
(
ChineseTextConverter
.
traditionalToSimplified
(
mainPlanOriginal
));
if
(
mainId
==
null
)
{
mainId
=
titleToIdMap
.
get
(
ChineseTextConverter
.
simplifiedToTraditional
(
mainPlanOriginal
));
}
}
dto
.
setMainPlanId
(
mainId
);
// 设置查询时使用的名称列表(繁简体)
dto
.
setMainPlanNameList
(
Arrays
.
asList
(
ChineseTextConverter
.
traditionalToSimplified
(
mainPlanOriginal
),
ChineseTextConverter
.
simplifiedToTraditional
(
mainPlanOriginal
)
));
}
// 处理附加计划(最多支持两个,根据 DTO 定义)
if
(!
CollectionUtils
.
isEmpty
(
appointmentDto
.
getAdditionalDtoList
()))
{
int
size
=
appointmentDto
.
getAdditionalDtoList
().
size
();
// 第一个附加计划
if
(
size
>=
1
)
{
ApiExcelImportAdditionalDto
add1
=
appointmentDto
.
getAdditionalDtoList
().
get
(
0
);
String
addName1
=
add1
.
getAddProductName
();
dto
.
setAddPlanName1
(
addName1
);
// 查找ID
String
addId1
=
titleToIdMap
.
get
(
addName1
);
if
(
addId1
==
null
)
{
addId1
=
titleToIdMap
.
get
(
ChineseTextConverter
.
traditionalToSimplified
(
addName1
));
if
(
addId1
==
null
)
{
addId1
=
titleToIdMap
.
get
(
ChineseTextConverter
.
simplifiedToTraditional
(
addName1
));
}
}
dto
.
setAddPlanId1
(
addId1
);
dto
.
setAddPlanName1List
(
Arrays
.
asList
(
ChineseTextConverter
.
traditionalToSimplified
(
addName1
),
ChineseTextConverter
.
simplifiedToTraditional
(
addName1
)
));
}
// 第二个附加计划
if
(
size
>=
2
)
{
ApiExcelImportAdditionalDto
add2
=
appointmentDto
.
getAdditionalDtoList
().
get
(
1
);
String
addName2
=
add2
.
getAddProductName
();
dto
.
setAddPlanName2
(
addName2
);
String
addId2
=
titleToIdMap
.
get
(
addName2
);
if
(
addId2
==
null
)
{
addId2
=
titleToIdMap
.
get
(
ChineseTextConverter
.
traditionalToSimplified
(
addName2
));
if
(
addId2
==
null
)
{
addId2
=
titleToIdMap
.
get
(
ChineseTextConverter
.
simplifiedToTraditional
(
addName2
));
}
}
dto
.
setAddPlanId2
(
addId2
);
dto
.
setAddPlanName2List
(
Arrays
.
asList
(
ChineseTextConverter
.
traditionalToSimplified
(
addName2
),
ChineseTextConverter
.
simplifiedToTraditional
(
addName2
)
));
}
// 如果超过两个,可以打印日志提示,但根据 DTO 设计只取前两个
if
(
size
>
2
)
{
log
.
warn
(
"附加计划数量超过2个,只处理前两个,总数:{}"
,
size
);
}
}
return
Collections
.
singletonList
(
dto
);
}
/**
/**
...
...
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