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
f4046bfe
Commit
f4046bfe
authored
Jan 14, 2026
by
zhangxingmin
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/test' into test
parents
23d6ff8e
adcf8573
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
88 additions
and
100 deletions
+88
-100
yd-csf-api/src/main/java/com/yd/csf/api/controller/ApiPolicyFollowController.java
+88
-100
No files found.
yd-csf-api/src/main/java/com/yd/csf/api/controller/ApiPolicyFollowController.java
View file @
f4046bfe
...
...
@@ -12,7 +12,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import
com.yd.auth.core.dto.AuthUserDto
;
import
com.yd.auth.core.utils.SecurityUtil
;
import
com.yd.common.enums.CommonEnum
;
import
com.yd.common.enums.ResultCode
;
import
com.yd.common.exception.BusinessException
;
import
com.yd.common.result.Result
;
import
com.yd.common.utils.RandomStringGenerator
;
...
...
@@ -29,7 +28,8 @@ import com.yd.csf.service.service.*;
import
com.yd.csf.service.vo.PolicyFollowDetailVO
;
import
com.yd.csf.service.vo.PolicyFollowRecordVO
;
import
com.yd.csf.service.vo.PolicyFollowVO
;
import
com.yd.product.feign.client.expectedcommissionratio.ApiExpectedCommissionRatioFeignClient
;
import
com.yd.insurance.base.feign.client.insurancereconciliationcompany.ApiInsuranceReconciliationCompanyFeignClient
;
import
com.yd.insurance.base.feign.request.insurancereconciliationcompany.ApiInsuranceReconciliationCompanyPageRequest
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
org.apache.commons.collections4.CollectionUtils
;
...
...
@@ -46,7 +46,6 @@ import javax.servlet.ServletOutputStream;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.math.BigDecimal
;
import
java.text.DecimalFormat
;
import
java.text.ParseException
;
import
java.util.*
;
import
java.util.stream.Collectors
;
...
...
@@ -64,19 +63,11 @@ public class ApiPolicyFollowController {
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
ApiPolicyFollowController
.
class
);
private
final
DecimalFormat
decimalFormat
=
new
DecimalFormat
(
"#,##0.00"
);
@Resource
private
PolicyFollowService
policyFollowService
;
@Resource
private
PolicyService
policyService
;
@Resource
private
PolicyBrokerService
policyBrokerService
;
@Resource
private
PolicyDataListener
policyDataListener
;
@Resource
private
CommissionExpectedService
commissionExpectedService
;
@Resource
private
CustomerService
customerService
;
@Resource
private
ReconciliationCompanyService
reconciliationCompanyService
;
...
...
@@ -87,7 +78,7 @@ public class ApiPolicyFollowController {
@Resource
private
PolicyReportPdfService
policyReportPdfService
;
@Resource
private
Api
ExpectedCommissionRatioFeignClient
apiExpectedCommissionRatio
FeignClient
;
private
Api
InsuranceReconciliationCompanyFeignClient
apiInsuranceReconciliationCompany
FeignClient
;
@PostMapping
(
"/upload/excel"
)
...
...
@@ -129,7 +120,7 @@ public class ApiPolicyFollowController {
List
<
PolicyExcelDTO
>
dtoList
=
policyDataListener
.
getList
();
// 校验保单号是否
存在
// 校验保单号是否
重复
String
validateMsg
=
validatePolicyNo
(
dtoList
);
if
(
StringUtils
.
isNotBlank
(
validateMsg
))
return
Result
.
fail
(
ErrorCode
.
OPERATION_ERROR
.
getCode
(),
validateMsg
);
...
...
@@ -137,44 +128,31 @@ public class ApiPolicyFollowController {
validateMsg
=
validateField
(
dtoList
);
if
(
StringUtils
.
isNotBlank
(
validateMsg
))
return
Result
.
fail
(
ErrorCode
.
OPERATION_ERROR
.
getCode
(),
validateMsg
);
//
保存
对账公司
//
查询
对账公司
Set
<
String
>
reconciliationCompanyNames
=
dtoList
.
stream
()
.
map
(
PolicyExcelDTO:
:
getReconciliationCompany
)
.
filter
(
StringUtils:
:
isNotBlank
)
.
collect
(
Collectors
.
toSet
());
List
<
ReconciliationCompany
>
reconciliationCompanyList
=
saveReconciliationCompany
(
reconciliationCompanyNames
);
// 通过 Feign Client 获取对账公司数据
List
<
ReconciliationCompany
>
reconciliationCompanyList
=
getReconciliationCompaniesByNames
(
reconciliationCompanyNames
);
// 关联对账公司
Map
<
String
,
String
>
reconciliationCompanyMap
=
reconciliationCompanyList
.
stream
()
.
collect
(
Collectors
.
toMap
(
ReconciliationCompany:
:
getCompanyName
,
ReconciliationCompany:
:
getReconciliationCompanyBizId
));
.
collect
(
Collectors
.
toMap
(
ReconciliationCompany:
:
getCompanyName
,
ReconciliationCompany:
:
getReconciliationCompanyBizId
,
(
v1
,
v2
)
->
v1
));
// 转换为PolicyFollow对象
List
<
PolicyFollowDTO
>
list
=
convertToObj
(
dtoList
,
reconciliationCompanyMap
);
List
<
PolicyFollow
>
policyFollowList
=
new
ArrayList
<>();
List
<
Policy
>
policyList
=
new
ArrayList
<>();
List
<
PolicyBroker
>
policyBrokerList
=
new
ArrayList
<>();
for
(
PolicyFollowDTO
policyFollow
:
list
)
{
policyFollowList
.
add
(
policyFollow
.
getPolicyFollow
());
policyBrokerList
.
addAll
(
policyFollow
.
getBrokerList
());
// policyList.add(policyFollow.getPolicy());
reconciliationCompanyNames
.
add
(
policyFollow
.
getPolicy
().
getReconciliationCompany
());
}
policyFollowService
.
saveBatch
(
policyFollowList
);
// policyService.saveBatch(policyList);
policyBrokerService
.
saveBatch
(
policyBrokerList
);
// 获取当前登录用户的ID
AuthUserDto
currentLoginUser
=
SecurityUtil
.
getCurrentLoginUser
();
String
loginUserId
=
currentLoginUser
.
getId
().
toString
();
// todo 保存预计来佣, 查询产品获取预计来佣比例
// List<CommissionExpected> commissionExpectedList = new ArrayList<>();
// for (CommissionExcelDTO commissionExcelDTO : dataList) {
// CommissionExpected commissionExpected = CommissionExcelDTO.convertToCommissionExpectedObj(commissionExcelDTO, loginUserId);
// commissionExpected.setReconciliationCompanyBizId(reconciliationCompanyMap.get(commissionExcelDTO.getReconciliationCompany()));
// commissionExpectedList.add(commissionExpected);
// }
// commissionExpectedService.saveBatch(commissionExpectedList);
return
Result
.
success
(
true
);
}
...
...
@@ -236,37 +214,43 @@ public class ApiPolicyFollowController {
}
private
String
validateField
(
List
<
PolicyExcelDTO
>
dataList
)
{
String
validateMsg
=
""
;
// 校验必填字段是否为空
for
(
PolicyExcelDTO
excelDTO
:
dataList
)
{
StringBuilder
validateMsg
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
dataList
.
size
();
i
++)
{
PolicyExcelDTO
excelDTO
=
dataList
.
get
(
i
);
int
rowNum
=
i
+
1
;
if
(
StringUtils
.
isBlank
(
excelDTO
.
getPolicyNo
()))
{
validateMsg
=
"第"
+
(
dataList
.
indexOf
(
excelDTO
)
+
1
)
+
"行保单号为空\n"
;
validateMsg
.
append
(
"第"
).
append
(
rowNum
).
append
(
"行保单号为空\n"
)
;
}
if
(
StringUtils
.
isBlank
(
excelDTO
.
getReconciliationCompany
()))
{
validateMsg
=
"第"
+
(
dataList
.
indexOf
(
excelDTO
)
+
1
)
+
"行对账公司为空\n"
;
validateMsg
.
append
(
"第"
).
append
(
rowNum
).
append
(
"行对账公司为空\n"
)
;
}
if
(
StringUtils
.
isBlank
(
excelDTO
.
getProductName
()))
{
validateMsg
=
"第"
+
(
dataList
.
indexOf
(
excelDTO
)
+
1
)
+
"行产品名称为空\n"
;
validateMsg
.
append
(
"第"
).
append
(
rowNum
).
append
(
"行产品名称为空\n"
)
;
}
if
(
StringUtils
.
isBlank
(
excelDTO
.
getInsuranceCompany
()))
{
validateMsg
=
"第"
+
(
dataList
.
indexOf
(
excelDTO
)
+
1
)
+
"行保险公司为空\n"
;
validateMsg
.
append
(
"第"
).
append
(
rowNum
).
append
(
"行保险公司为空\n"
)
;
}
if
(
StringUtils
.
isBlank
(
excelDTO
.
getPolicyHolder
()))
{
validateMsg
=
"第"
+
(
dataList
.
indexOf
(
excelDTO
)
+
1
)
+
"行保单持有人为空\n"
;
validateMsg
.
append
(
"第"
).
append
(
rowNum
).
append
(
"行保单持有人为空\n"
)
;
}
if
(
StringUtils
.
isBlank
(
excelDTO
.
getInsured
()))
{
validateMsg
=
"第"
+
(
dataList
.
indexOf
(
excelDTO
)
+
1
)
+
"行受保人为空\n"
;
validateMsg
.
append
(
"第"
).
append
(
rowNum
).
append
(
"行受保人为空\n"
)
;
}
if
(
StringUtils
.
isBlank
(
excelDTO
.
getInitialPremium
()))
{
validateMsg
=
"第"
+
(
dataList
.
indexOf
(
excelDTO
)
+
1
)
+
"行首期保费为空\n"
;
validateMsg
.
append
(
"第"
).
append
(
rowNum
).
append
(
"行首期保费为空\n"
)
;
}
}
return
validateMsg
;
return
validateMsg
.
toString
()
;
}
private
List
<
PolicyFollowDTO
>
convertToObj
(
List
<
PolicyExcelDTO
>
list
,
Map
<
String
,
String
>
reconciliationCompanyMap
)
throws
ParseException
{
List
<
PolicyFollowDTO
>
policyFollowDTOList
=
new
ArrayList
<>();
// 获取当前登录用户的ID
AuthUserDto
currentLoginUser
=
SecurityUtil
.
getCurrentLoginUser
();
String
loginUserId
=
currentLoginUser
.
getId
().
toString
();
// 获取所有保单持有人
Set
<
String
>
customerNames
=
list
.
stream
()
.
map
(
PolicyExcelDTO:
:
getPolicyHolder
)
...
...
@@ -287,7 +271,13 @@ public class ApiPolicyFollowController {
PolicyFollow
policyFollow
=
new
PolicyFollow
();
BeanUtils
.
copyProperties
(
policyExcelDTO
,
policyFollow
);
policyFollow
.
setPolicyBizId
(
policyBizId
);
// policyFollow.setInitialPremium(decimalFormat.parse(policyExcelDTO.getInitialPremium()));
policyFollow
.
setCreatorId
(
loginUserId
);
policyFollow
.
setCreateTime
(
new
Date
());
policyFollow
.
setUpdaterId
(
loginUserId
);
policyFollow
.
setUpdateTime
(
new
Date
());
if
(
StringUtils
.
isNotBlank
(
policyExcelDTO
.
getInitialPremium
()))
{
policyFollow
.
setInitialPremium
(
new
BigDecimal
(
policyExcelDTO
.
getInitialPremium
()));
}
policyFollow
.
setCustomerName
(
policyExcelDTO
.
getPolicyHolder
());
policyFollow
.
setCustomerBizId
(
customerNameToBizIdMap
.
get
(
policyExcelDTO
.
getPolicyHolder
()));
PolicyFollowStatusEnum
policyFollowStatusEnum
=
PolicyFollowStatusEnum
.
getEnumByItemLabel
(
policyExcelDTO
.
getStatus
());
...
...
@@ -311,22 +301,7 @@ public class ApiPolicyFollowController {
policy
.
setCoolingOffEndDate
(
policyFollow
.
getCoolingOffEndDate
());
// 转换为PolicyBroker对象
List
<
PolicyBroker
>
policyBrokerList
=
new
ArrayList
<>();
if
(
StringUtils
.
isNotBlank
(
policyExcelDTO
.
getBrokerName1
()))
{
policyBrokerList
.
add
(
getPolicyBroker
(
policyExcelDTO
.
getBrokerName1
(),
policyExcelDTO
.
getTeam1
(),
policyExcelDTO
.
getBrokerRatio1
(),
policyBizId
,
policyNo
));
}
if
(
StringUtils
.
isNotBlank
(
policyExcelDTO
.
getBrokerName2
()))
{
policyBrokerList
.
add
(
getPolicyBroker
(
policyExcelDTO
.
getBrokerName2
(),
policyExcelDTO
.
getTeam2
(),
policyExcelDTO
.
getBrokerRatio2
(),
policyBizId
,
policyNo
));
}
if
(
StringUtils
.
isNotBlank
(
policyExcelDTO
.
getBrokerName3
()))
{
policyBrokerList
.
add
(
getPolicyBroker
(
policyExcelDTO
.
getBrokerName3
(),
policyExcelDTO
.
getTeam3
(),
policyExcelDTO
.
getBrokerRatio3
(),
policyBizId
,
policyNo
));
}
if
(
StringUtils
.
isNotBlank
(
policyExcelDTO
.
getBrokerName4
()))
{
policyBrokerList
.
add
(
getPolicyBroker
(
policyExcelDTO
.
getBrokerName4
(),
policyExcelDTO
.
getTeam4
(),
policyExcelDTO
.
getBrokerRatio4
(),
policyBizId
,
policyNo
));
}
if
(
StringUtils
.
isNotBlank
(
policyExcelDTO
.
getBrokerName5
()))
{
policyBrokerList
.
add
(
getPolicyBroker
(
policyExcelDTO
.
getBrokerName5
(),
policyExcelDTO
.
getTeam5
(),
policyExcelDTO
.
getBrokerRatio5
(),
policyBizId
,
policyNo
));
}
List
<
PolicyBroker
>
policyBrokerList
=
buildPolicyBrokers
(
policyExcelDTO
,
policyBizId
,
policyNo
);
// 转换为PolicyFollowDTO对象
PolicyFollowDTO
policyFollowDTO
=
new
PolicyFollowDTO
();
...
...
@@ -348,6 +323,22 @@ public class ApiPolicyFollowController {
return
policyBroker
;
}
private
List
<
PolicyBroker
>
buildPolicyBrokers
(
PolicyExcelDTO
excelDTO
,
String
policyBizId
,
String
policyNo
)
{
List
<
PolicyBroker
>
brokers
=
new
ArrayList
<>();
addBrokerIfPresent
(
brokers
,
excelDTO
.
getBrokerName1
(),
excelDTO
.
getTeam1
(),
excelDTO
.
getBrokerRatio1
(),
policyBizId
,
policyNo
);
addBrokerIfPresent
(
brokers
,
excelDTO
.
getBrokerName2
(),
excelDTO
.
getTeam2
(),
excelDTO
.
getBrokerRatio2
(),
policyBizId
,
policyNo
);
addBrokerIfPresent
(
brokers
,
excelDTO
.
getBrokerName3
(),
excelDTO
.
getTeam3
(),
excelDTO
.
getBrokerRatio3
(),
policyBizId
,
policyNo
);
addBrokerIfPresent
(
brokers
,
excelDTO
.
getBrokerName4
(),
excelDTO
.
getTeam4
(),
excelDTO
.
getBrokerRatio4
(),
policyBizId
,
policyNo
);
addBrokerIfPresent
(
brokers
,
excelDTO
.
getBrokerName5
(),
excelDTO
.
getTeam5
(),
excelDTO
.
getBrokerRatio5
(),
policyBizId
,
policyNo
);
return
brokers
;
}
private
void
addBrokerIfPresent
(
List
<
PolicyBroker
>
brokers
,
String
name
,
String
team
,
String
ratio
,
String
policyBizId
,
String
policyNo
)
{
if
(
StringUtils
.
isNotBlank
(
name
))
{
brokers
.
add
(
getPolicyBroker
(
name
,
team
,
ratio
,
policyBizId
,
policyNo
));
}
}
/**
* 创建新单跟进
*
...
...
@@ -394,19 +385,12 @@ public class ApiPolicyFollowController {
}
String
policyBizId
=
deleteRequest
.
getPolicyBizId
();
// 获取当前登录用户
AuthUserDto
currentLoginUser
=
SecurityUtil
.
getCurrentLoginUser
();
String
loginUserId
=
currentLoginUser
.
getId
().
toString
();
// 判断是否存在
PolicyFollow
oldFna
=
policyFollowService
.
getByPolicyBizId
(
policyBizId
);
if
(
oldFna
==
null
)
{
return
Result
.
fail
(
ErrorCode
.
NOT_FOUND_ERROR
.
getCode
(),
ErrorCode
.
NOT_FOUND_ERROR
.
getMessage
());
}
// 仅本人或管理员可删除
// if (!oldFna.getUserId().equals(loginUserId) && !userService.isAdmin(request)) {
// throw new BusinessException(ErrorCode.NO_AUTH_ERROR);
// }
// 操作数据库
boolean
result
=
policyFollowService
.
removeById
(
oldFna
.
getId
());
if
(!
result
)
{
...
...
@@ -504,22 +488,6 @@ public class ApiPolicyFollowController {
}
/**
* 分页获取新单跟进列表(仅管理员可用)
*
* @param fnaQueryRequest
* @return
*/
// @PostMapping("/list/page")
// public Result<Page<Customer>> listFnaByPage(@RequestBody FnaQueryRequest fnaQueryRequest) {
// long current = fnaQueryRequest.getPageNo();
// long size = fnaQueryRequest.getPageSize();
// // 查询数据库
// Page<Customer> fnaPage = policyFollowService.page(new Page<>(current, size),
// policyFollowService.getQueryWrapper(fnaQueryRequest));
// return Result.success(fnaPage);
// }
/**
* 分页获取新单跟进列表
*
* @param policyFollowQueryRequest
...
...
@@ -593,22 +561,6 @@ public class ApiPolicyFollowController {
throw
new
BusinessException
(
ErrorCode
.
NOT_FOUND_ERROR
.
getCode
(),
ErrorCode
.
NOT_FOUND_ERROR
.
getMessage
());
}
// reportData.setStartTime("2025-10-30");
// reportData.setEndTime("2025-10-30");
// reportData.setLocation("香港");
// reportData.setServiceManager("Vickie");
// reportData.setPolicyHolder("policyHolder");
// reportData.setPolicyNumber("B635379588");
// reportData.setInsuranceCompany("友邦保险");
// reportData.setInsuredPerson("insuredPerson");
// reportData.setInsurancePlan("环宇盈活储蓄保险计划");
// reportData.setInsuredAge(1);
// reportData.setCurrency("HKD");
// reportData.setPaymentPeriod(5);
// reportData.setAnnualAmount(BigDecimal.valueOf(30000.08));
// reportData.setTotalPrepayment(BigDecimal.valueOf(150064.70));
// reportData.setPremiumFee(BigDecimal.valueOf(12.86));
try
{
log
.
info
(
"收到PDF生成请求: {}"
,
reportData
);
...
...
@@ -670,4 +622,39 @@ public class ApiPolicyFollowController {
return
Result
.
success
(
result
);
}
/**
* 通过 Feign Client 根据对账公司名称列表获取对账公司数据
*
* @param reconciliationCompanyNames 对账公司名称集合
* @return 对账公司列表
*/
@SuppressWarnings
(
"unchecked"
)
private
List
<
ReconciliationCompany
>
getReconciliationCompaniesByNames
(
Set
<
String
>
reconciliationCompanyNames
)
{
if
(
CollectionUtils
.
isEmpty
(
reconciliationCompanyNames
))
{
return
new
ArrayList
<>();
}
try
{
ApiInsuranceReconciliationCompanyPageRequest
request
=
new
ApiInsuranceReconciliationCompanyPageRequest
();
request
.
setPageNo
(
1
);
request
.
setPageSize
(
100
);
Result
<
Page
<
ReconciliationCompany
>>
result
=
(
Result
<
Page
<
ReconciliationCompany
>>)
(
Result
<?>)
apiInsuranceReconciliationCompanyFeignClient
.
page
(
request
);
if
(
result
!=
null
&&
result
.
getCode
()
==
200
&&
result
.
getData
()
!=
null
)
{
Page
<
ReconciliationCompany
>
page
=
result
.
getData
();
if
(
page
.
getRecords
()
!=
null
)
{
return
page
.
getRecords
().
stream
()
.
filter
(
company
->
reconciliationCompanyNames
.
contains
(
company
.
getCompanyName
()))
.
collect
(
Collectors
.
toList
());
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"通过 Feign Client 获取对账公司数据失败: {}"
,
e
.
getMessage
(),
e
);
}
return
new
ArrayList
<>();
}
}
\ No newline at end of file
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