Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
dj
/
rop-dj-script
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 8f99cabc
authored
Dec 17, 2025
by
杨卫
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:1047852:d+后台毛利额、区域运营管理、bi事项管理管理接口代码提交
1 parent
583fd9b8
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
1173 additions
and
44 deletions
pom.xml
src/main/java/cn/com/glsx/dj/script/config/PeAnalysisDubboConfig.java
src/main/java/cn/com/glsx/dj/script/constant/ConfigCenterConstants.java
src/main/java/cn/com/glsx/dj/script/constant/RedisKeyConstants.java
src/main/java/cn/com/glsx/dj/script/controller/BiAnalyseBackgroundController.java
src/main/java/cn/com/glsx/dj/script/converter/MerchantBiMatterConvert.java
src/main/java/cn/com/glsx/dj/script/converter/MerchantProfitRecordConvert.java
src/main/java/cn/com/glsx/dj/script/converter/ProvinceOrganizationConvert.java
src/main/java/cn/com/glsx/dj/script/converter/excel/BusinessTypeConverter.java
src/main/java/cn/com/glsx/dj/script/converter/excel/YearMonthConverter.java
src/main/java/cn/com/glsx/dj/script/dto/excel/BiMatterExcelDTO.java
src/main/java/cn/com/glsx/dj/script/dto/excel/MerchantProfitRecordExcelDTO.java
src/main/java/cn/com/glsx/dj/script/dto/excel/MerchantProfitRecordExcelImportDTO.java
src/main/java/cn/com/glsx/dj/script/enums/RopErrorEnum.java
src/main/java/cn/com/glsx/dj/script/enums/TemplateCodeEnum.java
src/main/java/cn/com/glsx/dj/script/listener/excel/MerchantProfitRecordListener.java
src/main/java/cn/com/glsx/dj/script/request/analysis/MerchantProfitRecordQryReq.java
src/main/java/cn/com/glsx/dj/script/request/analysis/ProvinceOrganizationQryPageReq.java
src/main/java/cn/com/glsx/dj/script/response/analysis/MerchantBiMatterResp.java
src/main/java/cn/com/glsx/dj/script/response/analysis/MerchantProfitRecordResp.java
src/main/java/cn/com/glsx/dj/script/service/BiAnalyseBackgroundService.java
src/main/java/cn/com/glsx/dj/script/service/ExcelAsyncImportService.java
src/main/java/cn/com/glsx/dj/script/utils/excel/RopExcelFileValidator.java
src/main/resources/template/merchant_profit_record_temp.xlsx
src/main/resources/template/merchant_profit_record_temp_error.xlsx
pom.xml
View file @
8f99cab
...
@@ -47,5 +47,10 @@
...
@@ -47,5 +47,10 @@
<artifactId>
rpc-dj-smartcarlife-api
</artifactId>
<artifactId>
rpc-dj-smartcarlife-api
</artifactId>
<version>
${api-version}
</version>
<version>
${api-version}
</version>
</dependency>
</dependency>
<dependency>
<groupId>
cn.com.glsx.dj.peanalysis
</groupId>
<artifactId>
rpc-dj-pe-analysis-api
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/dj/script/config/PeAnalysisDubboConfig.java
0 → 100644
View file @
8f99cab
package
cn
.
com
.
glsx
.
dj
.
script
.
config
;
import
cn.com.glsx.dj.peanalysis.remote.BiAnalyseBackgroundRemote
;
import
lombok.RequiredArgsConstructor
;
import
org.oreframework.boot.autoconfigure.dubbo.reference.ReferenceBuilderFactory
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
/**
* rpc pe analysis dubbo 配置
* @author yangwei
* @version 1.0
* @since 2025/12/15 17:17
*/
@Configuration
@RequiredArgsConstructor
public
class
PeAnalysisDubboConfig
{
private
final
ReferenceBuilderFactory
factory
;
@Bean
public
BiAnalyseBackgroundRemote
biAnalyseBackgroundRemote
(){
return
factory
.
builder
(
BiAnalyseBackgroundRemote
.
class
)
.
check
(
false
)
.
timeout
(
30000
)
.
build
();
}
}
src/main/java/cn/com/glsx/dj/script/constant/ConfigCenterConstants.java
View file @
8f99cab
...
@@ -13,4 +13,7 @@ public interface ConfigCenterConstants {
...
@@ -13,4 +13,7 @@ public interface ConfigCenterConstants {
/** excel 临时文件静态资源路径 */
/** excel 临时文件静态资源路径 */
String
GOP_EXCEL_TEM_URL
=
"gop.excel.tem.url"
;
String
GOP_EXCEL_TEM_URL
=
"gop.excel.tem.url"
;
/** 异步导入进度条过期时间,不配置默认为5分钟 */
String
IMPORT_PROGRESS_KEY_EXPIRED_MINUTES
=
"import.progress.keyExpiredMinutes"
;
}
}
src/main/java/cn/com/glsx/dj/script/constant/RedisKeyConstants.java
0 → 100644
View file @
8f99cab
package
cn
.
com
.
glsx
.
dj
.
script
.
constant
;
/**
* redis key 常量接口
* @author yangwei
* @since 2025/12/16 10:18
*/
public
interface
RedisKeyConstants
{
/**
* 导入进度缓存
*/
String
DJ_SCRIPT_IMPORT_PROGRESS_MAP
=
"DJ_SCRIPT_IMPORT_PROGRESS_MAP_%s"
;
}
src/main/java/cn/com/glsx/dj/script/controller/BiAnalyseBackgroundController.java
View file @
8f99cab
package
cn
.
com
.
glsx
.
dj
.
script
.
controller
;
package
cn
.
com
.
glsx
.
dj
.
script
.
controller
;
import
cn.com.glsx.dj.peanalysis.dto.analysis.*
;
import
cn.com.glsx.dj.peanalysis.enums.BiErrorEnum
;
import
cn.com.glsx.dj.peanalysis.remote.BiAnalyseBackgroundRemote
;
import
cn.com.glsx.dj.script.converter.MerchantBiMatterConvert
;
import
cn.com.glsx.dj.script.converter.MerchantProfitRecordConvert
;
import
cn.com.glsx.dj.script.converter.ProvinceOrganizationConvert
;
import
cn.com.glsx.dj.script.request.analysis.*
;
import
cn.com.glsx.dj.script.request.analysis.*
;
import
cn.com.glsx.dj.script.request.common.CommonTemplateReq
;
import
cn.com.glsx.dj.script.request.common.CommonTemplateReq
;
import
cn.com.glsx.dj.script.request.common.SingleUploadRequest
;
import
cn.com.glsx.dj.script.request.common.SingleUploadRequest
;
...
@@ -8,11 +14,16 @@ import cn.com.glsx.dj.script.response.analysis.MerchantBiMatterResp;
...
@@ -8,11 +14,16 @@ import cn.com.glsx.dj.script.response.analysis.MerchantBiMatterResp;
import
cn.com.glsx.dj.script.response.analysis.MerchantProfitRecordDetailResp
;
import
cn.com.glsx.dj.script.response.analysis.MerchantProfitRecordDetailResp
;
import
cn.com.glsx.dj.script.response.analysis.MerchantProfitRecordResp
;
import
cn.com.glsx.dj.script.response.analysis.MerchantProfitRecordResp
;
import
cn.com.glsx.dj.script.response.analysis.ProvinceOrganizationResp
;
import
cn.com.glsx.dj.script.response.analysis.ProvinceOrganizationResp
;
import
cn.com.glsx.dj.script.service.BiAnalyseBackgroundService
;
import
cn.com.glsx.dj.script.service.ExcelAsyncImportService
;
import
cn.com.glsx.dj.script.utils.CommonUtil
;
import
cn.com.glsx.dj.smartcarlife.dto.LoginUserDTO
;
import
cn.com.glsx.framework.core.beans.rpc.RpcPagination
;
import
cn.com.glsx.framework.core.beans.rpc.RpcPagination
;
import
cn.com.glsx.framework.core.beans.rpc.RpcResponse
;
import
cn.com.glsx.framework.core.enums.DefaultErrorEnum
;
import
cn.com.glsx.framework.core.enums.DefaultErrorEnum
;
import
cn.com.glsx.framework.core.exception.RpcServiceException
;
import
cn.com.glsx.framework.core.exception.RpcServiceException
;
import
cn.com.glsx.framework.rop.response.RopResponse
;
import
cn.com.glsx.framework.rop.response.RopResponse
;
import
c
om.rop.AbstractRopRequest
;
import
c
n.hutool.core.bean.BeanUtil
;
import
com.rop.annotation.NeedInSessionType
;
import
com.rop.annotation.NeedInSessionType
;
import
com.rop.annotation.ServiceMethod
;
import
com.rop.annotation.ServiceMethod
;
import
com.rop.annotation.ServiceMethodBean
;
import
com.rop.annotation.ServiceMethodBean
;
...
@@ -21,7 +32,7 @@ import io.swagger.annotations.ApiOperation;
...
@@ -21,7 +32,7 @@ import io.swagger.annotations.ApiOperation;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.
List
;
import
java.util.
Optional
;
/**
/**
* bi 指标分析后台服务控制器
* bi 指标分析后台服务控制器
...
@@ -35,13 +46,27 @@ import java.util.List;
...
@@ -35,13 +46,27 @@ import java.util.List;
@ServiceMethodBean
(
version
=
"1.0.0"
,
needInSession
=
NeedInSessionType
.
YES
)
@ServiceMethodBean
(
version
=
"1.0.0"
,
needInSession
=
NeedInSessionType
.
YES
)
public
class
BiAnalyseBackgroundController
{
public
class
BiAnalyseBackgroundController
{
private
final
ExcelAsyncImportService
excelAsyncImportService
;
private
final
MerchantBiMatterConvert
merchantBiMatterConvert
;
private
final
BiAnalyseBackgroundRemote
biAnalyseBackgroundRemote
;
private
final
BiAnalyseBackgroundService
biAnalyseBackgroundService
;
private
final
MerchantProfitRecordConvert
merchantProfitRecordConvert
;
private
final
ProvinceOrganizationConvert
provinceOrganizationConvert
;
@ApiOperation
(
"BI-门店毛利额分页记录"
)
@ApiOperation
(
"BI-门店毛利额分页记录"
)
@ServiceMethod
(
method
=
"dj.api.script.merchant.profit.record.page"
,
needInSession
=
NeedInSessionType
.
YES
)
@ServiceMethod
(
method
=
"dj.api.script.merchant.profit.record.page"
,
needInSession
=
NeedInSessionType
.
YES
)
public
RopResponse
<
RpcPagination
<
MerchantProfitRecordResp
>>
merchantProfitRecordPage
(
MerchantProfitRecordQryPageReq
request
)
{
public
RopResponse
<
RpcPagination
<
MerchantProfitRecordResp
>>
merchantProfitRecordPage
(
MerchantProfitRecordQryPageReq
request
)
{
try
{
try
{
RpcPagination
<
MerchantProfitRecordQryDTO
>
rpcPagination
=
CommonUtil
.
getRpcPagination
(
MerchantProfitRecordQryDTO
.
class
);
MerchantProfitRecordQryDTO
condition
=
BeanUtil
.
copyProperties
(
request
,
MerchantProfitRecordQryDTO
.
class
);
return
null
;
rpcPagination
.
setCondition
(
condition
);
RpcResponse
<
RpcPagination
<
MerchantProfitRecordDTO
>>
response
=
biAnalyseBackgroundRemote
.
merchantProfitRecordPage
(
rpcPagination
);
RpcPagination
<
MerchantProfitRecordDTO
>
result
=
response
.
getResult
();
if
(
response
.
isFailed
())
{
throw
new
RpcServiceException
(
response
.
getError
(),
response
.
getMessage
());
}
return
RopResponse
.
success
(
merchantProfitRecordConvert
.
merchantProfitRecordDto2ResponsePage
(
result
));
}
catch
(
RpcServiceException
e
)
{
}
catch
(
RpcServiceException
e
)
{
log
.
info
(
"dj.api.script.merchant.profit.record.page occur error!"
,
e
);
log
.
info
(
"dj.api.script.merchant.profit.record.page occur error!"
,
e
);
return
RopResponse
.
error
(
e
);
return
RopResponse
.
error
(
e
);
...
@@ -56,8 +81,14 @@ public class BiAnalyseBackgroundController {
...
@@ -56,8 +81,14 @@ public class BiAnalyseBackgroundController {
public
RopResponse
<
MerchantProfitRecordDetailResp
>
merchantProfitRecordDetail
(
MerchantProfitRecordSingleIdReq
request
)
{
public
RopResponse
<
MerchantProfitRecordDetailResp
>
merchantProfitRecordDetail
(
MerchantProfitRecordSingleIdReq
request
)
{
try
{
try
{
MerchantProfitRecordSingleIdDTO
rpcDTO
=
MerchantProfitRecordSingleIdDTO
.
builder
().
recordId
(
request
.
getRecordId
()).
build
();
RpcResponse
<
MerchantProfitRecordDetailDTO
>
rpcResponse
=
biAnalyseBackgroundRemote
.
merchantProfitRecordDetail
(
rpcDTO
);
if
(
rpcResponse
.
isFailed
())
{
throw
new
RpcServiceException
(
rpcResponse
.
getError
(),
rpcResponse
.
getMessage
());
}
return
null
;
MerchantProfitRecordDetailResp
merchantProfitRecordDetailResp
=
merchantProfitRecordConvert
.
merchantProfitRecordDetailDto2Response
(
rpcResponse
.
getResult
());
return
RopResponse
.
success
(
merchantProfitRecordDetailResp
);
}
catch
(
RpcServiceException
e
)
{
}
catch
(
RpcServiceException
e
)
{
log
.
info
(
"dj.api.script.merchant.profit.record.detail occur error!"
,
e
);
log
.
info
(
"dj.api.script.merchant.profit.record.detail occur error!"
,
e
);
return
RopResponse
.
error
(
e
);
return
RopResponse
.
error
(
e
);
...
@@ -71,9 +102,18 @@ public class BiAnalyseBackgroundController {
...
@@ -71,9 +102,18 @@ public class BiAnalyseBackgroundController {
@ServiceMethod
(
method
=
"dj.api.script.merchant.profit.record.add"
,
needInSession
=
NeedInSessionType
.
YES
)
@ServiceMethod
(
method
=
"dj.api.script.merchant.profit.record.add"
,
needInSession
=
NeedInSessionType
.
YES
)
public
RopResponse
<
Boolean
>
merchantProfitRecordAdd
(
MerchantProfitRecordAddReq
request
)
{
public
RopResponse
<
Boolean
>
merchantProfitRecordAdd
(
MerchantProfitRecordAddReq
request
)
{
try
{
try
{
String
userName
=
Optional
.
ofNullable
(
CommonUtil
.
getLoginUser
())
.
orElseThrow
(()
->
new
RpcServiceException
(
BiErrorEnum
.
LOGIN_USER_NOT_EXIST
))
return
null
;
.
getUserName
();
MerchantProfitRecordOperationDTO
rpcDto
=
BeanUtil
.
copyProperties
(
request
,
MerchantProfitRecordOperationDTO
.
class
);
rpcDto
.
setOperator
(
userName
);
RpcResponse
<
Boolean
>
rpcResponse
=
biAnalyseBackgroundRemote
.
merchantProfitRecordAdd
(
rpcDto
);
if
(
rpcResponse
.
isFailed
())
{
throw
new
RpcServiceException
(
rpcResponse
.
getError
(),
rpcResponse
.
getMessage
());
}
return
RopResponse
.
success
(
rpcResponse
.
getResult
());
}
catch
(
RpcServiceException
e
)
{
}
catch
(
RpcServiceException
e
)
{
log
.
info
(
"dj.api.script.merchant.profit.record.add occur error!"
,
e
);
log
.
info
(
"dj.api.script.merchant.profit.record.add occur error!"
,
e
);
return
RopResponse
.
error
(
e
);
return
RopResponse
.
error
(
e
);
...
@@ -87,9 +127,18 @@ public class BiAnalyseBackgroundController {
...
@@ -87,9 +127,18 @@ public class BiAnalyseBackgroundController {
@ServiceMethod
(
method
=
"dj.api.script.merchant.profit.record.upd"
,
needInSession
=
NeedInSessionType
.
YES
)
@ServiceMethod
(
method
=
"dj.api.script.merchant.profit.record.upd"
,
needInSession
=
NeedInSessionType
.
YES
)
public
RopResponse
<
Boolean
>
merchantProfitRecordUpd
(
MerchantProfitRecordUpdReq
request
)
{
public
RopResponse
<
Boolean
>
merchantProfitRecordUpd
(
MerchantProfitRecordUpdReq
request
)
{
try
{
try
{
String
userName
=
Optional
.
ofNullable
(
CommonUtil
.
getLoginUser
())
.
orElseThrow
(()
->
new
RpcServiceException
(
BiErrorEnum
.
LOGIN_USER_NOT_EXIST
))
return
null
;
.
getUserName
();
MerchantProfitRecordOperationDTO
rpcDto
=
BeanUtil
.
copyProperties
(
request
,
MerchantProfitRecordOperationDTO
.
class
);
rpcDto
.
setOperator
(
userName
);
RpcResponse
<
Boolean
>
rpcResponse
=
biAnalyseBackgroundRemote
.
merchantProfitRecordUpd
(
rpcDto
);
if
(
rpcResponse
.
isFailed
())
{
throw
new
RpcServiceException
(
rpcResponse
.
getError
(),
rpcResponse
.
getMessage
());
}
return
RopResponse
.
success
(
rpcResponse
.
getResult
());
}
catch
(
RpcServiceException
e
)
{
}
catch
(
RpcServiceException
e
)
{
log
.
info
(
"dj.api.script.merchant.profit.record.upd occur error!"
,
e
);
log
.
info
(
"dj.api.script.merchant.profit.record.upd occur error!"
,
e
);
return
RopResponse
.
error
(
e
);
return
RopResponse
.
error
(
e
);
...
@@ -103,9 +152,13 @@ public class BiAnalyseBackgroundController {
...
@@ -103,9 +152,13 @@ public class BiAnalyseBackgroundController {
@ServiceMethod
(
method
=
"dj.api.script.merchant.profit.record.delete"
,
needInSession
=
NeedInSessionType
.
YES
)
@ServiceMethod
(
method
=
"dj.api.script.merchant.profit.record.delete"
,
needInSession
=
NeedInSessionType
.
YES
)
public
RopResponse
<
Boolean
>
merchantProfitRecordDelete
(
MerchantProfitRecordSingleIdReq
request
)
{
public
RopResponse
<
Boolean
>
merchantProfitRecordDelete
(
MerchantProfitRecordSingleIdReq
request
)
{
try
{
try
{
MerchantProfitRecordOperationDTO
rpcDto
=
MerchantProfitRecordOperationDTO
.
builder
().
recordId
(
request
.
getRecordId
()).
build
();
RpcResponse
<
Boolean
>
rpcResponse
=
biAnalyseBackgroundRemote
.
merchantProfitRecordDelete
(
rpcDto
);
if
(
rpcResponse
.
isFailed
())
{
throw
new
RpcServiceException
(
rpcResponse
.
getError
(),
rpcResponse
.
getMessage
());
}
return
RopResponse
.
success
(
rpcResponse
.
getResult
());
return
null
;
}
catch
(
RpcServiceException
e
)
{
}
catch
(
RpcServiceException
e
)
{
log
.
info
(
"dj.api.script.merchant.profit.record.delete occur error!"
,
e
);
log
.
info
(
"dj.api.script.merchant.profit.record.delete occur error!"
,
e
);
return
RopResponse
.
error
(
e
);
return
RopResponse
.
error
(
e
);
...
@@ -123,9 +176,7 @@ public class BiAnalyseBackgroundController {
...
@@ -123,9 +176,7 @@ public class BiAnalyseBackgroundController {
@ServiceMethod
(
method
=
"dj.api.script.merchant.profit.record.async.export"
,
needInSession
=
NeedInSessionType
.
YES
)
@ServiceMethod
(
method
=
"dj.api.script.merchant.profit.record.async.export"
,
needInSession
=
NeedInSessionType
.
YES
)
public
RopResponse
<
String
>
merchantProfitRecordAsyncExport
(
MerchantProfitRecordQryReq
request
)
{
public
RopResponse
<
String
>
merchantProfitRecordAsyncExport
(
MerchantProfitRecordQryReq
request
)
{
try
{
try
{
return
excelAsyncImportService
.
exportAsync
(
request
,
biAnalyseBackgroundService:
:
exportMerchantProfitRecord
);
return
null
;
}
catch
(
RpcServiceException
e
)
{
}
catch
(
RpcServiceException
e
)
{
log
.
info
(
"dj.api.script.merchant.profit.record.async.export occur error!"
,
e
);
log
.
info
(
"dj.api.script.merchant.profit.record.async.export occur error!"
,
e
);
return
RopResponse
.
error
(
e
);
return
RopResponse
.
error
(
e
);
...
@@ -139,9 +190,7 @@ public class BiAnalyseBackgroundController {
...
@@ -139,9 +190,7 @@ public class BiAnalyseBackgroundController {
@ServiceMethod
(
method
=
"dj.api.script.common.template.async.export.async.export"
,
needInSession
=
NeedInSessionType
.
YES
)
@ServiceMethod
(
method
=
"dj.api.script.common.template.async.export.async.export"
,
needInSession
=
NeedInSessionType
.
YES
)
public
RopResponse
<
String
>
commonTemplateAsyncExport
(
CommonTemplateReq
request
)
{
public
RopResponse
<
String
>
commonTemplateAsyncExport
(
CommonTemplateReq
request
)
{
try
{
try
{
return
excelAsyncImportService
.
exportAsync
(
request
,
biAnalyseBackgroundService:
:
commonTemplateAsyncExport
);
return
null
;
}
catch
(
RpcServiceException
e
)
{
}
catch
(
RpcServiceException
e
)
{
log
.
info
(
"dj.api.script.common.template.async.export.async.export occur error!"
,
e
);
log
.
info
(
"dj.api.script.common.template.async.export.async.export occur error!"
,
e
);
return
RopResponse
.
error
(
e
);
return
RopResponse
.
error
(
e
);
...
@@ -158,9 +207,8 @@ public class BiAnalyseBackgroundController {
...
@@ -158,9 +207,8 @@ public class BiAnalyseBackgroundController {
@ServiceMethod
(
method
=
"dj.api.script.merchant.profit.record.async.import"
,
needInSession
=
NeedInSessionType
.
YES
)
@ServiceMethod
(
method
=
"dj.api.script.merchant.profit.record.async.import"
,
needInSession
=
NeedInSessionType
.
YES
)
public
RopResponse
<
String
>
merchantProfitRecordAsyncImport
(
SingleUploadRequest
request
)
{
public
RopResponse
<
String
>
merchantProfitRecordAsyncImport
(
SingleUploadRequest
request
)
{
try
{
try
{
String
processId
=
biAnalyseBackgroundService
.
merchantProfitRecordAsyncImport
(
request
);
return
RopResponse
.
success
(
processId
);
return
null
;
}
catch
(
RpcServiceException
e
)
{
}
catch
(
RpcServiceException
e
)
{
log
.
info
(
"dj.api.script.common.template.async.export.async.import occur error!"
,
e
);
log
.
info
(
"dj.api.script.common.template.async.export.async.import occur error!"
,
e
);
return
RopResponse
.
error
(
e
);
return
RopResponse
.
error
(
e
);
...
@@ -172,11 +220,18 @@ public class BiAnalyseBackgroundController {
...
@@ -172,11 +220,18 @@ public class BiAnalyseBackgroundController {
@ApiOperation
(
"BI-区域运营管理列表"
)
@ApiOperation
(
"BI-区域运营管理列表"
)
@ServiceMethod
(
method
=
"dj.api.script.province.organization.list"
,
needInSession
=
NeedInSessionType
.
YES
)
@ServiceMethod
(
method
=
"dj.api.script.province.organization.list"
,
needInSession
=
NeedInSessionType
.
YES
)
public
RopResponse
<
List
<
ProvinceOrganizationResp
>>
provinceOrganizationList
(
AbstractRopRequest
request
)
{
public
RopResponse
<
RpcPagination
<
ProvinceOrganizationResp
>>
provinceOrganizationList
(
ProvinceOrganizationQryPageReq
request
)
{
try
{
try
{
RpcPagination
<?>
rpcPagination
=
new
RpcPagination
<>();
rpcPagination
.
setPageNum
(
request
.
getPageNum
());
rpcPagination
.
setPageSize
(
request
.
getPageSize
());
RpcResponse
<
RpcPagination
<
ProvinceOrganizationDTO
>>
response
=
biAnalyseBackgroundRemote
.
provinceOrganizationList
(
rpcPagination
);
if
(
response
.
isFailed
())
{
throw
new
RpcServiceException
(
response
.
getError
(),
response
.
getMessage
());
}
return
null
;
return
RopResponse
.
success
(
provinceOrganizationConvert
.
provinceOrganization2ResponsePage
(
response
.
getResult
()))
;
}
catch
(
RpcServiceException
e
)
{
}
catch
(
RpcServiceException
e
)
{
log
.
info
(
"dj.api.script.province.organization.list occur error!"
,
e
);
log
.
info
(
"dj.api.script.province.organization.list occur error!"
,
e
);
return
RopResponse
.
error
(
e
);
return
RopResponse
.
error
(
e
);
...
@@ -190,8 +245,18 @@ public class BiAnalyseBackgroundController {
...
@@ -190,8 +245,18 @@ public class BiAnalyseBackgroundController {
@ServiceMethod
(
method
=
"dj.api.script.province.organization.upd"
,
needInSession
=
NeedInSessionType
.
YES
)
@ServiceMethod
(
method
=
"dj.api.script.province.organization.upd"
,
needInSession
=
NeedInSessionType
.
YES
)
public
RopResponse
<
Boolean
>
provinceOrganizationUpd
(
ProvinceOrganizationBaseReq
request
)
{
public
RopResponse
<
Boolean
>
provinceOrganizationUpd
(
ProvinceOrganizationBaseReq
request
)
{
try
{
try
{
String
userName
=
Optional
.
ofNullable
(
CommonUtil
.
getLoginUser
())
return
null
;
.
orElseThrow
(()
->
new
RpcServiceException
(
BiErrorEnum
.
LOGIN_USER_NOT_EXIST
))
.
getUserName
();
ProvinceOrganizationBaseDTO
rpcDto
=
BeanUtil
.
copyProperties
(
request
,
ProvinceOrganizationBaseDTO
.
class
);
rpcDto
.
setOperator
(
userName
);
RpcResponse
<
Boolean
>
rpcResponse
=
biAnalyseBackgroundRemote
.
provinceOrganizationUpd
(
rpcDto
);
if
(
rpcResponse
.
isFailed
())
{
throw
new
RpcServiceException
(
rpcResponse
.
getError
(),
rpcResponse
.
getMessage
());
}
return
RopResponse
.
success
(
rpcResponse
.
getResult
());
}
catch
(
RpcServiceException
e
)
{
}
catch
(
RpcServiceException
e
)
{
log
.
info
(
"dj.api.script.province.organization.upd occur error!"
,
e
);
log
.
info
(
"dj.api.script.province.organization.upd occur error!"
,
e
);
return
RopResponse
.
error
(
e
);
return
RopResponse
.
error
(
e
);
...
@@ -205,9 +270,15 @@ public class BiAnalyseBackgroundController {
...
@@ -205,9 +270,15 @@ public class BiAnalyseBackgroundController {
@ServiceMethod
(
method
=
"dj.api.script.merchant.bi.matter.page"
,
needInSession
=
NeedInSessionType
.
YES
)
@ServiceMethod
(
method
=
"dj.api.script.merchant.bi.matter.page"
,
needInSession
=
NeedInSessionType
.
YES
)
public
RopResponse
<
RpcPagination
<
MerchantBiMatterResp
>>
merchantBiMatterPage
(
MerchantBiMatterQryPageReq
request
)
{
public
RopResponse
<
RpcPagination
<
MerchantBiMatterResp
>>
merchantBiMatterPage
(
MerchantBiMatterQryPageReq
request
)
{
try
{
try
{
RpcPagination
<
MerchantBiMatterBaseQryDTO
>
rpcPagination
=
CommonUtil
.
getRpcPagination
(
MerchantBiMatterBaseQryDTO
.
class
);
MerchantBiMatterBaseQryDTO
condition
=
BeanUtil
.
copyProperties
(
request
,
MerchantBiMatterBaseQryDTO
.
class
);
return
null
;
rpcPagination
.
setCondition
(
condition
);
RpcResponse
<
RpcPagination
<
MerchantBiMatterDTO
>>
response
=
biAnalyseBackgroundRemote
.
merchantBiMatterPage
(
rpcPagination
);
if
(
response
.
isFailed
())
{
throw
new
RpcServiceException
(
response
.
getError
(),
response
.
getMessage
());
}
return
RopResponse
.
success
(
merchantBiMatterConvert
.
merchantBiMatterDto2ResponsePage
(
response
.
getResult
()));
}
catch
(
RpcServiceException
e
)
{
}
catch
(
RpcServiceException
e
)
{
log
.
info
(
"dj.api.script.merchant.bi.matter.page occur error!"
,
e
);
log
.
info
(
"dj.api.script.merchant.bi.matter.page occur error!"
,
e
);
return
RopResponse
.
error
(
e
);
return
RopResponse
.
error
(
e
);
...
@@ -221,9 +292,21 @@ public class BiAnalyseBackgroundController {
...
@@ -221,9 +292,21 @@ public class BiAnalyseBackgroundController {
@ServiceMethod
(
method
=
"dj.api.script.merchant.bi.matter.handle"
,
needInSession
=
NeedInSessionType
.
YES
)
@ServiceMethod
(
method
=
"dj.api.script.merchant.bi.matter.handle"
,
needInSession
=
NeedInSessionType
.
YES
)
public
RopResponse
<
Boolean
>
merchantBiMatterHandle
(
MerchantBiMatterHandleReq
request
)
{
public
RopResponse
<
Boolean
>
merchantBiMatterHandle
(
MerchantBiMatterHandleReq
request
)
{
try
{
try
{
LoginUserDTO
loginUserDTO
=
Optional
.
ofNullable
(
CommonUtil
.
getLoginUser
())
.
orElseThrow
(()
->
new
RpcServiceException
(
BiErrorEnum
.
LOGIN_USER_NOT_EXIST
));
String
userName
=
loginUserDTO
.
getUserName
();
String
loginAccount
=
loginUserDTO
.
getLoginAccout
();
MerchantBiMatterHandleDTO
merchantBiMatterHandleDTO
=
BeanUtil
.
copyProperties
(
request
,
MerchantBiMatterHandleDTO
.
class
);
merchantBiMatterHandleDTO
.
setOperator
(
userName
);
merchantBiMatterHandleDTO
.
setOperatorUniqueKey
(
loginAccount
);
RpcResponse
<
Boolean
>
rpcResponse
=
biAnalyseBackgroundRemote
.
merchantBiMatterHandle
(
merchantBiMatterHandleDTO
);
if
(
rpcResponse
.
isFailed
())
{
throw
new
RpcServiceException
(
rpcResponse
.
getError
(),
rpcResponse
.
getMessage
());
}
return
null
;
return
RopResponse
.
success
(
rpcResponse
.
getResult
())
;
}
catch
(
RpcServiceException
e
)
{
}
catch
(
RpcServiceException
e
)
{
log
.
info
(
"dj.api.script.merchant.bi.matter.handle occur error!"
,
e
);
log
.
info
(
"dj.api.script.merchant.bi.matter.handle occur error!"
,
e
);
return
RopResponse
.
error
(
e
);
return
RopResponse
.
error
(
e
);
...
@@ -237,9 +320,13 @@ public class BiAnalyseBackgroundController {
...
@@ -237,9 +320,13 @@ public class BiAnalyseBackgroundController {
@ServiceMethod
(
method
=
"dj.api.script.merchant.bi.matter.delete"
,
needInSession
=
NeedInSessionType
.
YES
)
@ServiceMethod
(
method
=
"dj.api.script.merchant.bi.matter.delete"
,
needInSession
=
NeedInSessionType
.
YES
)
public
RopResponse
<
Boolean
>
merchantBiMatterDelete
(
MerchantBiMatterSingleIdReq
request
)
{
public
RopResponse
<
Boolean
>
merchantBiMatterDelete
(
MerchantBiMatterSingleIdReq
request
)
{
try
{
try
{
MerchantBiMatterSingleIdDTO
merchantBiMatterSingleIdDTO
=
BeanUtil
.
copyProperties
(
request
,
MerchantBiMatterSingleIdDTO
.
class
);
RpcResponse
<
Boolean
>
rpcResponse
=
biAnalyseBackgroundRemote
.
merchantBiMatterDelete
(
merchantBiMatterSingleIdDTO
);
if
(
rpcResponse
.
isFailed
())
{
throw
new
RpcServiceException
(
rpcResponse
.
getError
(),
rpcResponse
.
getMessage
());
}
return
RopResponse
.
success
(
rpcResponse
.
getResult
());
return
null
;
}
catch
(
RpcServiceException
e
)
{
}
catch
(
RpcServiceException
e
)
{
log
.
info
(
"dj.api.script.merchant.bi.matter.delete occur error!"
,
e
);
log
.
info
(
"dj.api.script.merchant.bi.matter.delete occur error!"
,
e
);
return
RopResponse
.
error
(
e
);
return
RopResponse
.
error
(
e
);
...
@@ -256,9 +343,7 @@ public class BiAnalyseBackgroundController {
...
@@ -256,9 +343,7 @@ public class BiAnalyseBackgroundController {
@ServiceMethod
(
method
=
"dj.api.script.merchant.bi.matter.async.export"
,
needInSession
=
NeedInSessionType
.
YES
)
@ServiceMethod
(
method
=
"dj.api.script.merchant.bi.matter.async.export"
,
needInSession
=
NeedInSessionType
.
YES
)
public
RopResponse
<
String
>
merchantBiMatterAsyncExport
(
MerchantBiMatterBaseQryReq
request
)
{
public
RopResponse
<
String
>
merchantBiMatterAsyncExport
(
MerchantBiMatterBaseQryReq
request
)
{
try
{
try
{
return
excelAsyncImportService
.
exportAsync
(
request
,
biAnalyseBackgroundService:
:
merchantBiMatterAsyncExport
);
return
null
;
}
catch
(
RpcServiceException
e
)
{
}
catch
(
RpcServiceException
e
)
{
log
.
info
(
"dj.api.script.merchant.bi.matter.async.export occur error!"
,
e
);
log
.
info
(
"dj.api.script.merchant.bi.matter.async.export occur error!"
,
e
);
return
RopResponse
.
error
(
e
);
return
RopResponse
.
error
(
e
);
...
...
src/main/java/cn/com/glsx/dj/script/converter/MerchantBiMatterConvert.java
0 → 100644
View file @
8f99cab
package
cn
.
com
.
glsx
.
dj
.
script
.
converter
;
import
cn.com.glsx.dj.peanalysis.dto.analysis.MerchantBiMatterDTO
;
import
cn.com.glsx.dj.script.dto.excel.BiMatterExcelDTO
;
import
cn.com.glsx.dj.script.response.analysis.MerchantBiMatterResp
;
import
cn.com.glsx.framework.core.beans.rpc.RpcPagination
;
import
org.mapstruct.Mapper
;
import
java.util.List
;
/**
* bi 事项管理对象转换器
* @author yangwei
* @version 1.0
* @since 2025/12/17 15:04
*/
@Mapper
(
componentModel
=
"spring"
)
public
interface
MerchantBiMatterConvert
{
RpcPagination
<
MerchantBiMatterResp
>
merchantBiMatterDto2ResponsePage
(
RpcPagination
<
MerchantBiMatterDTO
>
pagination
);
List
<
BiMatterExcelDTO
>
biMatterDtoList2ExcelDtoList
(
List
<
MerchantBiMatterDTO
>
list
);
BiMatterExcelDTO
biMatterDto2ExcelDto
(
MerchantBiMatterDTO
merchantBiMatterDTO
);
}
src/main/java/cn/com/glsx/dj/script/converter/MerchantProfitRecordConvert.java
0 → 100644
View file @
8f99cab
package
cn
.
com
.
glsx
.
dj
.
script
.
converter
;
import
cn.com.glsx.dj.peanalysis.dto.analysis.MerchantProfitRecordDTO
;
import
cn.com.glsx.dj.peanalysis.dto.analysis.MerchantProfitRecordDetailDTO
;
import
cn.com.glsx.dj.script.dto.excel.MerchantProfitRecordExcelDTO
;
import
cn.com.glsx.dj.script.response.analysis.MerchantProfitRecordDetailResp
;
import
cn.com.glsx.dj.script.response.analysis.MerchantProfitRecordResp
;
import
cn.com.glsx.framework.core.beans.rpc.RpcPagination
;
import
org.mapstruct.Mapper
;
import
java.util.List
;
/**
* 门店毛利配置 对象转换
* @author yangwei
* @version 1.0
* @since 2025/12/15 09:57
*/
@Mapper
(
componentModel
=
"spring"
)
public
interface
MerchantProfitRecordConvert
{
RpcPagination
<
MerchantProfitRecordResp
>
merchantProfitRecordDto2ResponsePage
(
RpcPagination
<
MerchantProfitRecordDTO
>
page
);
MerchantProfitRecordDetailResp
merchantProfitRecordDetailDto2Response
(
MerchantProfitRecordDetailDTO
result
);
MerchantProfitRecordDetailResp
.
MerchantProfitOpeLogResp
merchantProfitOpeLogDto2Response
(
MerchantProfitRecordDetailDTO
.
MerchantProfitOpeLogDTO
result
);
MerchantProfitRecordExcelDTO
merchantProfitRecordDto2ExcelDto
(
MerchantProfitRecordDTO
merchantProfitRecordDTO
);
List
<
MerchantProfitRecordExcelDTO
>
merchantProfitRecordDtoList2ExcelDtoList
(
List
<
MerchantProfitRecordDTO
>
merchantProfitRecordDTO
);
}
src/main/java/cn/com/glsx/dj/script/converter/ProvinceOrganizationConvert.java
0 → 100644
View file @
8f99cab
package
cn
.
com
.
glsx
.
dj
.
script
.
converter
;
import
cn.com.glsx.dj.peanalysis.dto.analysis.ProvinceOrganizationDTO
;
import
cn.com.glsx.dj.script.response.analysis.ProvinceOrganizationResp
;
import
cn.com.glsx.framework.core.beans.rpc.RpcPagination
;
import
org.mapstruct.Mapper
;
/**
* 区域运营 对象转换器
* @author yangwei
* @version 1.0
* @since 2025/12/16 18:03
*/
@Mapper
(
componentModel
=
"spring"
)
public
interface
ProvinceOrganizationConvert
{
RpcPagination
<
ProvinceOrganizationResp
>
provinceOrganization2ResponsePage
(
RpcPagination
<
ProvinceOrganizationDTO
>
page
);
}
src/main/java/cn/com/glsx/dj/script/converter/excel/BusinessTypeConverter.java
0 → 100644
View file @
8f99cab
package
cn
.
com
.
glsx
.
dj
.
script
.
converter
.
excel
;
import
cn.com.glsx.dj.peanalysis.enums.BusinessTypeEnum
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.excel.converters.Converter
;
import
com.alibaba.excel.enums.CellDataTypeEnum
;
import
com.alibaba.excel.metadata.CellData
;
import
com.alibaba.excel.metadata.GlobalConfiguration
;
import
com.alibaba.excel.metadata.property.ExcelContentProperty
;
import
java.util.Objects
;
/**
* BI 分析业务类型转换器
* @see BusinessTypeEnum
* @author yangwei
* @version 1.0
* @since 2025/12/15 16:49
*/
public
class
BusinessTypeConverter
implements
Converter
<
String
>
{
@Override
public
Class
<?>
supportJavaTypeKey
()
{
return
String
.
class
;
}
@Override
public
CellDataTypeEnum
supportExcelTypeKey
()
{
return
CellDataTypeEnum
.
STRING
;
}
@Override
public
String
convertToJavaData
(
CellData
cellData
,
ExcelContentProperty
contentProperty
,
GlobalConfiguration
globalConfiguration
)
throws
Exception
{
String
stringValue
=
cellData
.
getStringValue
();
if
(
StrUtil
.
isNotBlank
(
stringValue
))
{
return
BusinessTypeEnum
.
getCodeByDesc
(
stringValue
);
}
return
stringValue
;
}
@Override
public
CellData
<?>
convertToExcelData
(
String
value
,
ExcelContentProperty
contentProperty
,
GlobalConfiguration
globalConfiguration
)
throws
Exception
{
String
desc
=
BusinessTypeEnum
.
getDescByCode
(
value
);
return
new
CellData
<>(
StrUtil
.
isNotBlank
(
desc
)
?
Objects
.
requireNonNull
(
desc
)
:
StrUtil
.
EMPTY
);
}
}
src/main/java/cn/com/glsx/dj/script/converter/excel/YearMonthConverter.java
0 → 100644
View file @
8f99cab
package
cn
.
com
.
glsx
.
dj
.
script
.
converter
.
excel
;
import
cn.com.glsx.dj.peanalysis.constants.SymbolConstants
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.excel.converters.Converter
;
import
com.alibaba.excel.enums.CellDataTypeEnum
;
import
com.alibaba.excel.metadata.CellData
;
import
com.alibaba.excel.metadata.GlobalConfiguration
;
import
com.alibaba.excel.metadata.property.ExcelContentProperty
;
/**
* <pre>
* 月份转换器
* 读取:2025-07 -> 202507
* 写出:202507 -> 2025-07
* </pre>
* @author yangwei
* @version 1.0
* @since 2025/12/16 09:46
*/
public
class
YearMonthConverter
implements
Converter
<
String
>
{
@Override
public
Class
<?>
supportJavaTypeKey
()
{
return
String
.
class
;
}
@Override
public
CellDataTypeEnum
supportExcelTypeKey
()
{
return
CellDataTypeEnum
.
STRING
;
}
@Override
public
String
convertToJavaData
(
CellData
cellData
,
ExcelContentProperty
contentProperty
,
GlobalConfiguration
globalConfiguration
)
throws
Exception
{
String
stringValue
=
cellData
.
getStringValue
();
if
(
StrUtil
.
isNotBlank
(
stringValue
))
{
return
stringValue
.
replace
(
SymbolConstants
.
DASH
,
StrUtil
.
EMPTY
);
}
return
stringValue
;
}
@Override
public
CellData
<?>
convertToExcelData
(
String
value
,
ExcelContentProperty
contentProperty
,
GlobalConfiguration
globalConfiguration
)
throws
Exception
{
if
(
StrUtil
.
isNotBlank
(
value
)
&&
value
.
length
()
==
6
)
{
// 202507 -> 2025-07
value
=
value
.
substring
(
0
,
4
)
+
SymbolConstants
.
DASH
+
value
.
substring
(
4
);
return
new
CellData
<>(
value
);
}
return
new
CellData
<>(
value
);
}
}
src/main/java/cn/com/glsx/dj/script/dto/excel/BiMatterExcelDTO.java
0 → 100644
View file @
8f99cab
package
cn
.
com
.
glsx
.
dj
.
script
.
dto
.
excel
;
import
cn.com.glsx.dj.script.converter.excel.BusinessTypeConverter
;
import
cn.com.glsx.dj.script.converter.excel.YearMonthConverter
;
import
com.alibaba.excel.annotation.ExcelIgnoreUnannotated
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.alibaba.excel.annotation.format.DateTimeFormat
;
import
com.alibaba.excel.annotation.format.NumberFormat
;
import
com.alibaba.excel.annotation.write.style.*
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.apache.poi.ss.usermodel.BorderStyle
;
import
org.apache.poi.ss.usermodel.FillPatternType
;
import
org.apache.poi.ss.usermodel.HorizontalAlignment
;
import
org.apache.poi.ss.usermodel.VerticalAlignment
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.util.Date
;
/**
* BI-事项
* @author yangwei
* @version 1.0
* @since 2025/12/11 17:27
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ExcelIgnoreUnannotated
@ContentRowHeight
(
20
)
@HeadRowHeight
(
20
)
@ColumnWidth
(
38
)
@HeadStyle
(
horizontalAlignment
=
HorizontalAlignment
.
CENTER
,
verticalAlignment
=
VerticalAlignment
.
CENTER
,
borderLeft
=
BorderStyle
.
THIN
,
borderRight
=
BorderStyle
.
THIN
,
borderTop
=
BorderStyle
.
THIN
,
borderBottom
=
BorderStyle
.
THIN
,
fillForegroundColor
=
9
,
fillPatternType
=
FillPatternType
.
SOLID_FOREGROUND
)
@HeadFontStyle
(
fontHeightInPoints
=
12
)
@ContentStyle
(
horizontalAlignment
=
HorizontalAlignment
.
CENTER
,
verticalAlignment
=
VerticalAlignment
.
CENTER
,
borderLeft
=
BorderStyle
.
THIN
,
borderRight
=
BorderStyle
.
THIN
,
borderTop
=
BorderStyle
.
THIN
,
borderBottom
=
BorderStyle
.
THIN
,
fillForegroundColor
=
9
,
wrapped
=
true
,
fillPatternType
=
FillPatternType
.
SOLID_FOREGROUND
)
@ContentFontStyle
(
fontName
=
"宋体"
,
fontHeightInPoints
=
12
)
public
class
BiMatterExcelDTO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
6241795238964931077L
;
@ExcelProperty
(
value
=
"4S门店"
,
index
=
0
)
@ColumnWidth
(
41
)
private
String
storeName
;
@ExcelProperty
(
value
=
"业务类型"
,
index
=
1
,
converter
=
BusinessTypeConverter
.
class
)
private
String
businessType
;
@ExcelProperty
(
value
=
"所属月份"
,
index
=
2
,
converter
=
YearMonthConverter
.
class
)
private
String
monthYear
;
@ExcelProperty
(
value
=
"毛利额"
,
index
=
3
)
@NumberFormat
(
value
=
"0.00"
,
roundingMode
=
RoundingMode
.
HALF_UP
)
private
BigDecimal
profitAmount
;
@ExcelProperty
(
value
=
"导入时间"
,
index
=
4
)
@DateTimeFormat
(
"yyyy-MM-dd HH:mm:ss"
)
private
Date
createdAt
;
}
src/main/java/cn/com/glsx/dj/script/dto/excel/MerchantProfitRecordExcelDTO.java
0 → 100644
View file @
8f99cab
package
cn
.
com
.
glsx
.
dj
.
script
.
dto
.
excel
;
import
cn.com.glsx.dj.script.converter.excel.BusinessTypeConverter
;
import
cn.com.glsx.dj.script.converter.excel.YearMonthConverter
;
import
com.alibaba.excel.annotation.ExcelIgnoreUnannotated
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.alibaba.excel.annotation.format.DateTimeFormat
;
import
com.alibaba.excel.annotation.format.NumberFormat
;
import
com.alibaba.excel.annotation.write.style.*
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.apache.poi.ss.usermodel.BorderStyle
;
import
org.apache.poi.ss.usermodel.FillPatternType
;
import
org.apache.poi.ss.usermodel.HorizontalAlignment
;
import
org.apache.poi.ss.usermodel.VerticalAlignment
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.util.Date
;
/**
* BI-门店毛利额导出实体
* @author yangwei
* @version 1.0
* @since 2025/12/11 17:27
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ExcelIgnoreUnannotated
@ContentRowHeight
(
20
)
@HeadRowHeight
(
20
)
@ColumnWidth
(
38
)
@HeadStyle
(
horizontalAlignment
=
HorizontalAlignment
.
CENTER
,
verticalAlignment
=
VerticalAlignment
.
CENTER
,
borderLeft
=
BorderStyle
.
THIN
,
borderRight
=
BorderStyle
.
THIN
,
borderTop
=
BorderStyle
.
THIN
,
borderBottom
=
BorderStyle
.
THIN
,
fillForegroundColor
=
9
,
fillPatternType
=
FillPatternType
.
SOLID_FOREGROUND
)
@HeadFontStyle
(
fontHeightInPoints
=
12
)
@ContentStyle
(
horizontalAlignment
=
HorizontalAlignment
.
CENTER
,
verticalAlignment
=
VerticalAlignment
.
CENTER
,
borderLeft
=
BorderStyle
.
THIN
,
borderRight
=
BorderStyle
.
THIN
,
borderTop
=
BorderStyle
.
THIN
,
borderBottom
=
BorderStyle
.
THIN
,
fillForegroundColor
=
9
,
wrapped
=
true
,
fillPatternType
=
FillPatternType
.
SOLID_FOREGROUND
)
@ContentFontStyle
(
fontName
=
"宋体"
,
fontHeightInPoints
=
12
)
public
class
MerchantProfitRecordExcelDTO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
6241795238964931077L
;
@ExcelProperty
(
value
=
"4S门店"
,
index
=
0
)
@ColumnWidth
(
41
)
private
String
storeName
;
@ExcelProperty
(
value
=
"业务类型"
,
index
=
1
,
converter
=
BusinessTypeConverter
.
class
)
private
String
businessType
;
@ExcelProperty
(
value
=
"所属月份"
,
index
=
2
,
converter
=
YearMonthConverter
.
class
)
private
String
monthYear
;
@ExcelProperty
(
value
=
"毛利额"
,
index
=
3
)
@NumberFormat
(
value
=
"0.00"
,
roundingMode
=
RoundingMode
.
HALF_UP
)
private
BigDecimal
profitAmount
;
@ExcelProperty
(
value
=
"导入时间"
,
index
=
4
)
@DateTimeFormat
(
"yyyy-MM-dd HH:mm:ss"
)
private
Date
createdAt
;
}
src/main/java/cn/com/glsx/dj/script/dto/excel/MerchantProfitRecordExcelImportDTO.java
0 → 100644
View file @
8f99cab
package
cn
.
com
.
glsx
.
dj
.
script
.
dto
.
excel
;
import
cn.com.glsx.dj.peanalysis.constants.DatePatternConstants
;
import
cn.com.glsx.dj.peanalysis.validator.DateCheck
;
import
cn.com.glsx.dj.peanalysis.validator.InList
;
import
cn.com.glsx.dj.script.converter.excel.BusinessTypeConverter
;
import
cn.com.glsx.dj.script.converter.excel.YearMonthConverter
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.excel.annotation.ExcelIgnore
;
import
com.alibaba.excel.annotation.ExcelIgnoreUnannotated
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
javax.validation.constraints.DecimalMax
;
import
javax.validation.constraints.DecimalMin
;
import
javax.validation.constraints.Digits
;
import
javax.validation.constraints.NotNull
;
import
java.math.BigDecimal
;
import
java.util.HashSet
;
import
java.util.Set
;
/**
* 门店毛利率导入 excel 导入实体
* @author yangwei
* @version 1.0
* @since 2025/12/15 18:08
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ExcelIgnoreUnannotated
public
class
MerchantProfitRecordExcelImportDTO
{
@ExcelProperty
(
value
=
"*商户号"
,
index
=
0
)
@NotNull
(
message
=
"*商户号不能为空"
)
private
Long
storeId
;
@ExcelProperty
(
value
=
"*门店"
,
index
=
1
)
@NotNull
(
message
=
"*门店不能为空"
)
private
String
storeName
;
@ExcelProperty
(
value
=
"*业务类型"
,
index
=
2
,
converter
=
BusinessTypeConverter
.
class
)
@NotNull
(
message
=
"*业务类型不能为空"
)
@InList
(
values
=
{
"1"
,
"2"
,
"3"
,
"4"
},
message
=
"业务识别失败"
)
private
String
businessType
;
@ExcelProperty
(
value
=
"*所属月份"
,
index
=
3
,
converter
=
YearMonthConverter
.
class
)
@NotNull
(
message
=
"*所属月份不能为空"
)
@DateCheck
(
pattern
=
DatePatternConstants
.
DATE_PATTERN_YYYYMM
,
message
=
"无效月份"
)
private
String
monthYear
;
@ExcelProperty
(
value
=
"*毛利额"
,
index
=
4
)
@NotNull
(
message
=
"*毛利额不能为空"
)
@Digits
(
integer
=
8
,
fraction
=
2
,
message
=
"数值的整数部分最多8位,小数部分最多2位"
)
@DecimalMin
(
value
=
"-99999999.99"
,
message
=
"数值不能小于 -99999999.99"
)
@DecimalMax
(
value
=
"99999999.99"
,
message
=
"数值不能大于 99999999.99"
)
private
BigDecimal
profitAmount
;
@ExcelIgnore
private
Set
<
String
>
errors
=
new
HashSet
<>();
@ExcelIgnore
private
String
errorStr
=
StrUtil
.
EMPTY
;
}
src/main/java/cn/com/glsx/dj/script/enums/RopErrorEnum.java
View file @
8f99cab
...
@@ -177,8 +177,14 @@ public enum RopErrorEnum implements ErrorEnum{
...
@@ -177,8 +177,14 @@ public enum RopErrorEnum implements ErrorEnum{
VALIDATION_ERROR
(
"30180104"
,
"验证失败!"
),
VALIDATION_ERROR
(
"30180104"
,
"验证失败!"
),
;
TEMPLATE_CODE_NOT_EXIST
(
"30180105"
,
"模版代码不存在!"
),
TEMPLATE_ERROR
(
"30180106"
,
"模版错误"
),
EMPTY_INPUT_ERROR
(
"30180107"
,
"内容为空,导入失败"
),
PARSE_EXCEL_EXCEPTION
(
"30180107"
,
"解析excel异常,请检查导入的excel文件"
),
;
private
String
value
;
private
String
value
;
...
...
src/main/java/cn/com/glsx/dj/script/enums/TemplateCodeEnum.java
0 → 100644
View file @
8f99cab
package
cn
.
com
.
glsx
.
dj
.
script
.
enums
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
/**
* 模版路径枚举
* @author yangwei
* @version 1.0
* @since 2025/12/15 17:20
*/
@Getter
@AllArgsConstructor
public
enum
TemplateCodeEnum
{
MERCHANT_PROFIT_RECORD_TEMP
(
"毛利额导入模版"
,
"merchant_profit_record_temp"
,
"template/merchant_profit_record_temp.xlsx"
),
MERCHANT_PROFIT_RECORD_TEMP_ERROR
(
"毛利额导入失败记录"
,
"merchant_profit_record_temp_error"
,
"template/merchant_profit_record_temp_error.xlsx"
),
;
/**
* 导出文件名称
*/
private
final
String
name
;
/**
* 模版代码
*/
private
final
String
code
;
/**
* 模版路径
*/
private
final
String
path
;
public
static
TemplateCodeEnum
getByCode
(
String
code
)
{
for
(
TemplateCodeEnum
value
:
values
())
{
if
(
value
.
getCode
().
equals
(
code
))
{
return
value
;
}
}
return
MERCHANT_PROFIT_RECORD_TEMP
;
}
}
src/main/java/cn/com/glsx/dj/script/listener/excel/MerchantProfitRecordListener.java
0 → 100644
View file @
8f99cab
package
cn
.
com
.
glsx
.
dj
.
script
.
listener
.
excel
;
import
cn.com.glsx.dj.script.dto.excel.ActivityAwardWinnerExcelDTO
;
import
cn.com.glsx.dj.script.dto.excel.MerchantProfitRecordExcelImportDTO
;
import
cn.com.glsx.dj.script.enums.RopErrorEnum
;
import
cn.com.glsx.dj.script.utils.CommonUtil
;
import
cn.com.glsx.dj.script.utils.validation.BeanValidationUtils
;
import
cn.com.glsx.dj.script.utils.validation.ValidationResult
;
import
cn.com.glsx.framework.core.exception.RpcServiceException
;
import
cn.hutool.core.map.MapUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.event.AnalysisEventListener
;
import
com.alibaba.excel.metadata.CellData
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
javax.validation.groups.Default
;
import
java.lang.reflect.Field
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
/**
* 门店毛利率导入监听器
* @author yangwei
* @version 1.0
* @since 2025/12/15 18:07
*/
@Slf4j
@RequiredArgsConstructor
public
class
MerchantProfitRecordListener
extends
AnalysisEventListener
<
MerchantProfitRecordExcelImportDTO
>
{
private
final
Map
<
Integer
,
MerchantProfitRecordExcelImportDTO
>
exportDataMap
;
@Override
public
void
invokeHead
(
Map
<
Integer
,
CellData
>
headMap
,
AnalysisContext
context
)
{
Map
<
Integer
,
String
>
entityHeadMap
=
MapUtil
.<
Integer
,
String
>
builder
().
build
();
List
<
Field
>
fields
=
CommonUtil
.
getAllFields
(
ActivityAwardWinnerExcelDTO
.
class
);
for
(
Field
field
:
fields
)
{
ExcelProperty
annotation
=
field
.
getAnnotation
(
ExcelProperty
.
class
);
if
(
ObjectUtil
.
isNotNull
(
annotation
))
{
entityHeadMap
.
put
(
annotation
.
index
(),
annotation
.
value
()[
0
]);
}
}
headMap
.
forEach
((
columnIndex
,
headContent
)
->
{
if
(!
ObjectUtil
.
equal
(
entityHeadMap
.
get
(
columnIndex
),
headContent
))
{
throw
new
RpcServiceException
(
RopErrorEnum
.
TEMPLATE_ERROR
);
}
});
}
@Override
public
void
invoke
(
MerchantProfitRecordExcelImportDTO
data
,
AnalysisContext
context
)
{
// jsr303 校验
ValidationResult
validate
=
BeanValidationUtils
.
validate
(
data
,
Default
.
class
);
if
(
validate
.
hasErrors
())
{
Set
<
String
>
errors
=
new
HashSet
<>(
validate
.
getErrorMessages
());
data
.
getErrors
().
addAll
(
errors
);
}
exportDataMap
.
put
(
context
.
readRowHolder
().
getRowIndex
(),
data
);
}
@Override
public
void
doAfterAllAnalysed
(
AnalysisContext
context
)
{
// 异步导入,数据校验异步逻辑执行
}
}
src/main/java/cn/com/glsx/dj/script/request/analysis/MerchantProfitRecordQryReq.java
View file @
8f99cab
...
@@ -29,7 +29,6 @@ public class MerchantProfitRecordQryReq extends AbstractRopRequest implements Se
...
@@ -29,7 +29,6 @@ public class MerchantProfitRecordQryReq extends AbstractRopRequest implements Se
)
)
private
Long
storeId
;
private
Long
storeId
;
@ApiModelProperty
(
@ApiModelProperty
(
name
=
"businessType"
,
name
=
"businessType"
,
notes
=
"业务类型:1.延保 2.轻改 3.权益 4.二手车"
,
notes
=
"业务类型:1.延保 2.轻改 3.权益 4.二手车"
,
...
@@ -37,7 +36,6 @@ public class MerchantProfitRecordQryReq extends AbstractRopRequest implements Se
...
@@ -37,7 +36,6 @@ public class MerchantProfitRecordQryReq extends AbstractRopRequest implements Se
)
)
private
String
businessType
;
private
String
businessType
;
@ApiModelProperty
(
@ApiModelProperty
(
name
=
"monthYear"
,
name
=
"monthYear"
,
notes
=
"所属月份,格式 YYYYMM"
,
notes
=
"所属月份,格式 YYYYMM"
,
...
@@ -45,7 +43,6 @@ public class MerchantProfitRecordQryReq extends AbstractRopRequest implements Se
...
@@ -45,7 +43,6 @@ public class MerchantProfitRecordQryReq extends AbstractRopRequest implements Se
)
)
private
String
monthYear
;
private
String
monthYear
;
@ApiModelProperty
(
@ApiModelProperty
(
name
=
"startDate"
,
name
=
"startDate"
,
notes
=
"开始日期"
,
notes
=
"开始日期"
,
...
@@ -54,7 +51,6 @@ public class MerchantProfitRecordQryReq extends AbstractRopRequest implements Se
...
@@ -54,7 +51,6 @@ public class MerchantProfitRecordQryReq extends AbstractRopRequest implements Se
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
startDate
;
private
Date
startDate
;
@ApiModelProperty
(
@ApiModelProperty
(
name
=
"endDate"
,
name
=
"endDate"
,
notes
=
"结束时间"
,
notes
=
"结束时间"
,
...
...
src/main/java/cn/com/glsx/dj/script/request/analysis/ProvinceOrganizationQryPageReq.java
0 → 100644
View file @
8f99cab
package
cn
.
com
.
glsx
.
dj
.
script
.
request
.
analysis
;
import
com.rop.AbstractRopRequest
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
java.io.Serializable
;
/**
* BI-事项管理分页查询请求对象
* @author yangwei
* @version 1.0
* @since 2025/12/12 14:51
*/
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
@ApiModel
(
"BI-事项管理分页查询请求对象"
)
public
class
ProvinceOrganizationQryPageReq
extends
AbstractRopRequest
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
5529292550079622536L
;
@ApiModelProperty
(
name
=
"pageNum"
,
notes
=
"当前页(默认1)"
,
dataType
=
"int"
,
example
=
"1"
)
private
Integer
pageNum
=
1
;
@ApiModelProperty
(
name
=
"pageSize"
,
notes
=
"每页数据大小(默认10)"
,
dataType
=
"int"
,
example
=
"10"
)
private
Integer
pageSize
=
10
;
}
src/main/java/cn/com/glsx/dj/script/response/analysis/MerchantBiMatterResp.java
View file @
8f99cab
...
@@ -102,14 +102,14 @@ public class MerchantBiMatterResp implements Serializable {
...
@@ -102,14 +102,14 @@ public class MerchantBiMatterResp implements Serializable {
notes
=
"线上运营"
,
notes
=
"线上运营"
,
example
=
"1"
example
=
"1"
)
)
private
List
<
OperatorResp
>
onlineOperator
Resp
;
private
List
<
OperatorResp
>
onlineOperator
;
@ApiModelProperty
(
@ApiModelProperty
(
name
=
"areaOperatorResp"
,
name
=
"areaOperatorResp"
,
notes
=
"区域运营"
,
notes
=
"区域运营"
,
example
=
"1"
example
=
"1"
)
)
private
List
<
OperatorResp
>
areaOperator
Resp
;
private
List
<
OperatorResp
>
areaOperator
;
/**
/**
...
...
src/main/java/cn/com/glsx/dj/script/response/analysis/MerchantProfitRecordResp.java
View file @
8f99cab
...
@@ -20,7 +20,6 @@ public class MerchantProfitRecordResp implements Serializable {
...
@@ -20,7 +20,6 @@ public class MerchantProfitRecordResp implements Serializable {
private
static
final
long
serialVersionUID
=
6241795238964931077L
;
private
static
final
long
serialVersionUID
=
6241795238964931077L
;
@ApiModelProperty
(
@ApiModelProperty
(
name
=
"storeId"
,
name
=
"storeId"
,
notes
=
"关联门店ID"
,
notes
=
"关联门店ID"
,
...
...
src/main/java/cn/com/glsx/dj/script/service/BiAnalyseBackgroundService.java
0 → 100644
View file @
8f99cab
package
cn
.
com
.
glsx
.
dj
.
script
.
service
;
import
cn.com.glsx.dj.peanalysis.constants.SymbolConstants
;
import
cn.com.glsx.dj.peanalysis.dto.analysis.*
;
import
cn.com.glsx.dj.peanalysis.enums.BiErrorEnum
;
import
cn.com.glsx.dj.peanalysis.remote.BiAnalyseBackgroundRemote
;
import
cn.com.glsx.dj.script.constant.ConfigCenterConstants
;
import
cn.com.glsx.dj.script.converter.MerchantBiMatterConvert
;
import
cn.com.glsx.dj.script.converter.MerchantProfitRecordConvert
;
import
cn.com.glsx.dj.script.dto.excel.ActivityAwardWinnerExcelDTO
;
import
cn.com.glsx.dj.script.dto.excel.BiMatterExcelDTO
;
import
cn.com.glsx.dj.script.dto.excel.MerchantProfitRecordExcelDTO
;
import
cn.com.glsx.dj.script.dto.excel.MerchantProfitRecordExcelImportDTO
;
import
cn.com.glsx.dj.script.enums.RopErrorEnum
;
import
cn.com.glsx.dj.script.enums.TemplateCodeEnum
;
import
cn.com.glsx.dj.script.listener.excel.MerchantProfitRecordListener
;
import
cn.com.glsx.dj.script.request.analysis.MerchantBiMatterBaseQryReq
;
import
cn.com.glsx.dj.script.request.analysis.MerchantProfitRecordQryReq
;
import
cn.com.glsx.dj.script.request.common.CommonTemplateReq
;
import
cn.com.glsx.dj.script.request.common.SingleUploadRequest
;
import
cn.com.glsx.dj.script.utils.CommonUtil
;
import
cn.com.glsx.dj.script.utils.FileUtils
;
import
cn.com.glsx.dj.script.utils.excel.RopExcelFileValidator
;
import
cn.com.glsx.dj.smartcarlife.constant.CommonConstants
;
import
cn.com.glsx.dj.smartcarlife.vo.excel.ExcelImportProgressVo
;
import
cn.com.glsx.framework.core.beans.rpc.RpcPagination
;
import
cn.com.glsx.framework.core.beans.rpc.RpcResponse
;
import
cn.com.glsx.framework.core.enums.DefaultErrorEnum
;
import
cn.com.glsx.framework.core.exception.RpcServiceException
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.ListUtil
;
import
cn.hutool.core.lang.UUID
;
import
cn.hutool.core.map.MapUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.ExcelWriter
;
import
com.alibaba.excel.support.ExcelTypeEnum
;
import
com.alibaba.excel.util.DateUtils
;
import
com.alibaba.excel.write.metadata.WriteSheet
;
import
com.google.common.collect.Lists
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.core.task.TaskExecutor
;
import
org.springframework.stereotype.Service
;
import
java.io.*
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
* bi 分析后台
*
* @author yangwei
* @version 1.0
* @since 2025/12/15 16:36
*/
@Slf4j
@Service
@RequiredArgsConstructor
public
class
BiAnalyseBackgroundService
{
private
final
Environment
env
;
private
final
TaskExecutor
taskExecutor
;
private
final
ExcelAsyncImportService
excelAsyncImportService
;
private
final
BiAnalyseBackgroundRemote
biAnalyseBackgroundRemote
;
private
final
MerchantProfitRecordConvert
merchantProfitRecordConvert
;
private
final
MerchantBiMatterConvert
merchantBiMatterConvert
;
/**
* 导出门店毛利额
*
* @param merchantProfitRecordQryReq 查询参数
* @return java.lang.String 临时文件url
* @author yangwei
* @since 2025/12/15 17:14
*/
public
String
exportMerchantProfitRecord
(
MerchantProfitRecordQryReq
merchantProfitRecordQryReq
)
{
StringBuilder
fileNameSb
=
new
StringBuilder
();
fileNameSb
.
append
(
"门店毛利额"
).
append
(
DateUtils
.
format
(
new
Date
(),
DateUtils
.
DATE_FORMAT_14
)).
append
(
ExcelTypeEnum
.
XLSX
.
getValue
());
String
gopExcelTempPath
=
Optional
.
ofNullable
(
env
.
getProperty
(
ConfigCenterConstants
.
GOP_EXCEL_TEMP_PATH
))
.
orElseThrow
(()
->
new
RpcServiceException
(
DefaultErrorEnum
.
SERVICE_ERROR
,
"excel临时存放目录未配置"
));
File
file
=
FileUtils
.
getFile
(
gopExcelTempPath
);
File
outfile
=
new
File
(
file
,
fileNameSb
.
toString
());
// 导出 excel
ExcelWriter
excelWriter
=
null
;
try
{
excelWriter
=
EasyExcel
.
write
(
outfile
,
MerchantProfitRecordExcelDTO
.
class
).
build
();
WriteSheet
writeSheet
=
EasyExcel
.
writerSheet
(
"sheet1"
).
build
();
RpcPagination
<
MerchantProfitRecordQryDTO
>
rpcPagination
=
CommonUtil
.
getRpcPagination
(
MerchantProfitRecordQryDTO
.
class
);
rpcPagination
.
setPageNum
(-
1
);
MerchantProfitRecordQryDTO
condition
=
BeanUtil
.
copyProperties
(
merchantProfitRecordQryReq
,
MerchantProfitRecordQryDTO
.
class
);
rpcPagination
.
setCondition
(
condition
);
RpcResponse
<
RpcPagination
<
MerchantProfitRecordDTO
>>
response
=
biAnalyseBackgroundRemote
.
merchantProfitRecordPage
(
rpcPagination
);
RpcPagination
<
MerchantProfitRecordDTO
>
result
=
response
.
getResult
();
if
(
response
.
isFailed
())
{
throw
new
RpcServiceException
(
response
.
getError
(),
response
.
getMessage
());
}
List
<
MerchantProfitRecordDTO
>
list
=
Optional
.
ofNullable
(
result
.
getList
()).
filter
(
CollUtil:
:
isNotEmpty
).
orElseGet
(
ArrayList:
:
new
);
List
<
MerchantProfitRecordExcelDTO
>
excelDtoList
=
merchantProfitRecordConvert
.
merchantProfitRecordDtoList2ExcelDtoList
(
list
);
excelWriter
.
write
(
excelDtoList
,
writeSheet
);
}
catch
(
Exception
e
)
{
log
.
error
(
"写出excel异常"
,
e
);
throw
new
RpcServiceException
(
RopErrorEnum
.
AYSNC_EXPORT_ERROR
,
"导出excel失败"
);
}
finally
{
if
(
excelWriter
!=
null
)
{
excelWriter
.
finish
();
}
}
return
Optional
.
ofNullable
(
env
.
getProperty
(
ConfigCenterConstants
.
GOP_EXCEL_TEM_URL
))
.
orElseThrow
(()
->
new
RpcServiceException
(
DefaultErrorEnum
.
SERVICE_ERROR
,
"excel临时存放目录未配置"
))
+
fileNameSb
;
}
/**
* 通用模板异步导出
*
* @param commonTemplateReq 通用模板参数
* @return java.lang.String 临时文件url
* @author yangwei
* @since 2025/12/15 17:39
*/
public
String
commonTemplateAsyncExport
(
CommonTemplateReq
commonTemplateReq
)
{
TemplateCodeEnum
templateCodeEnum
=
Optional
.
ofNullable
(
commonTemplateReq
.
getTemplateCode
()).
map
(
TemplateCodeEnum:
:
getByCode
)
.
orElseThrow
(()
->
new
RpcServiceException
(
RopErrorEnum
.
TEMPLATE_CODE_NOT_EXIST
));
ClassPathResource
classPathResource
=
new
ClassPathResource
(
templateCodeEnum
.
getPath
());
String
fileNameSb
=
templateCodeEnum
.
getName
()
+
ExcelTypeEnum
.
XLSX
.
getValue
();
String
gopExcelTempPath
=
Optional
.
ofNullable
(
env
.
getProperty
(
ConfigCenterConstants
.
GOP_EXCEL_TEMP_PATH
))
.
orElseThrow
(()
->
new
RpcServiceException
(
DefaultErrorEnum
.
SERVICE_ERROR
,
"excel临时存放目录未配置"
));
File
file
=
FileUtils
.
getFile
(
gopExcelTempPath
);
File
outfile
=
new
File
(
file
,
fileNameSb
);
try
(
InputStream
inputStream
=
classPathResource
.
getInputStream
())
{
org
.
apache
.
commons
.
io
.
FileUtils
.
copyInputStreamToFile
(
inputStream
,
outfile
);
}
catch
(
IOException
e
)
{
log
.
error
(
"复制文件失败"
,
e
);
throw
new
RpcServiceException
(
RopErrorEnum
.
AYSNC_EXPORT_ERROR
,
"导出excel失败"
);
}
return
Optional
.
ofNullable
(
env
.
getProperty
(
ConfigCenterConstants
.
GOP_EXCEL_TEM_URL
))
.
orElseThrow
(()
->
new
RpcServiceException
(
DefaultErrorEnum
.
SERVICE_ERROR
,
"excel临时存放目录未配置"
))
+
fileNameSb
;
}
/**
* 门店毛利额异步导入
*
* @param request 上传参数
* @return java.lang.String 导入进度条UUID
* @author yangwei
* @since 2025/12/15 17:47
*/
public
String
merchantProfitRecordAsyncImport
(
SingleUploadRequest
request
)
{
String
errorMsg
=
RopExcelFileValidator
.
validateExcelFile
(
request
.
getFile
());
if
(
StrUtil
.
isNotBlank
(
errorMsg
))
{
throw
new
RpcServiceException
(
RopErrorEnum
.
ACTIVITY_AWARD_WINNER_EXCEL_FORMAT_ERROR
,
errorMsg
);
}
Map
<
Integer
,
MerchantProfitRecordExcelImportDTO
>
readDataMap
=
readExcelHandler
(
request
);
if
(
MapUtil
.
isEmpty
(
readDataMap
))
{
throw
new
RpcServiceException
(
RopErrorEnum
.
EMPTY_INPUT_ERROR
);
}
String
uuid
=
UUID
.
fastUUID
().
toString
(
true
);
log
.
info
(
"门店毛利额导入进度条uuid:{}"
,
uuid
);
excelAsyncImportService
.
incrementImportProcess
(
uuid
,
BigDecimal
.
ZERO
);
String
userName
=
Optional
.
ofNullable
(
CommonUtil
.
getLoginUser
())
.
orElseThrow
(()
->
new
RpcServiceException
(
BiErrorEnum
.
LOGIN_USER_NOT_EXIST
))
.
getUserName
();
taskExecutor
.
execute
(()
->
importMerchantProfitRecord
(
readDataMap
,
uuid
,
userName
));
return
uuid
;
}
/**
* 导入门店毛利额
*
* @param readDataMap 读取的excel数据
* @param uuid 进度条uuid
* @param operator 操作人
* @author yangwei
* @since 2025/12/16 15:03
*/
private
void
importMerchantProfitRecord
(
Map
<
Integer
,
MerchantProfitRecordExcelImportDTO
>
readDataMap
,
String
uuid
,
String
operator
)
{
if
(
MapUtil
.
isEmpty
(
readDataMap
))
{
excelAsyncImportService
.
incrementImportProcess
(
uuid
,
CommonConstants
.
ONEHUNDRED_BIGDECIMAL
);
return
;
}
// 步长
BigDecimal
step
=
CommonConstants
.
ONEHUNDRED_BIGDECIMAL
.
divide
(
BigDecimal
.
valueOf
(
readDataMap
.
hashCode
()),
2
,
RoundingMode
.
HALF_UP
);
// 计算进度条,批量远程调用
List
<
MerchantProfitRecordExcelImportDTO
>
importDtoList
=
Lists
.
newArrayList
(
readDataMap
.
values
());
List
<
List
<
MerchantProfitRecordExcelImportDTO
>>
partition
=
ListUtil
.
partition
(
importDtoList
,
200
);
for
(
List
<
MerchantProfitRecordExcelImportDTO
>
batch
:
partition
)
{
// 远程调用校验以及导入
List
<
MerchantProfitRecordImportDataDTO
>
data
=
BeanUtil
.
copyToList
(
batch
,
MerchantProfitRecordImportDataDTO
.
class
);
MerchantProfitRecordImportDTO
rpcDto
=
MerchantProfitRecordImportDTO
.
builder
().
operator
(
operator
).
data
(
data
).
build
();
RpcResponse
<
List
<
MerchantProfitRecordImportDataDTO
>>
listRpcResponse
=
biAnalyseBackgroundRemote
.
merchantProfitRecordImport
(
rpcDto
);
if
(
listRpcResponse
.
isFailed
())
{
if
(
listRpcResponse
.
hasException
())
{
log
.
info
(
"门店毛利额批量导入失败远程调用失败"
,
listRpcResponse
.
getException
());
}
else
if
(
listRpcResponse
.
hasError
())
{
log
.
info
(
"门店毛利额批量导入失败远程调用失败{}"
,
listRpcResponse
.
getError
().
toString
());
}
data
.
forEach
(
dto
->
dto
.
getErrors
().
add
(
listRpcResponse
.
getMessage
()));
}
// 有失败记录
List
<
MerchantProfitRecordImportDataDTO
>
result
=
listRpcResponse
.
getResult
();
if
(
CollUtil
.
isNotEmpty
(
result
))
{
Map
<
String
,
Set
<
String
>>
uniqueKeyMapError
=
result
.
stream
().
collect
(
Collectors
.
toMap
(
ele
->
StrUtil
.
join
(
SymbolConstants
.
UNDERLINE
,
ele
.
getStoreId
(),
ele
.
getBusinessType
(),
ele
.
getMonthYear
()),
MerchantProfitRecordImportDataDTO:
:
getErrors
));
batch
.
forEach
(
ele
->
{
// 添加错误信息
Set
<
String
>
error
=
uniqueKeyMapError
.
getOrDefault
(
StrUtil
.
join
(
SymbolConstants
.
UNDERLINE
,
ele
.
getStoreId
(),
ele
.
getBusinessType
(),
ele
.
getMonthYear
()),
new
HashSet
<>());
ele
.
getErrors
().
addAll
(
error
);
});
}
// 维护导入进度条
excelAsyncImportService
.
incrementImportProcess
(
uuid
,
step
.
multiply
(
new
BigDecimal
(
batch
.
size
())));
}
// 导入完毕
List
<
MerchantProfitRecordExcelImportDTO
>
allData
=
partition
.
stream
().
flatMap
(
Collection:
:
stream
).
collect
(
Collectors
.
toList
());
Map
<
Boolean
,
List
<
MerchantProfitRecordExcelImportDTO
>>
partitionBy
=
allData
.
stream
().
collect
(
Collectors
.
partitioningBy
(
ele
->
CollUtil
.
isEmpty
(
ele
.
getErrors
())));
List
<
MerchantProfitRecordExcelImportDTO
>
successData
=
partitionBy
.
get
(
true
);
List
<
MerchantProfitRecordExcelImportDTO
>
failData
=
partitionBy
.
get
(
false
);
String
exportExcelUrl
=
null
;
if
(
CollectionUtils
.
isNotEmpty
(
failData
)){
// 失败数据导出
exportExcelUrl
=
errorRecordExport
(
failData
);
}
// 维护异步导入进度条
int
successNum
=
successData
.
size
();
int
failNum
=
failData
.
size
();
int
totalNum
=
successNum
+
failNum
;
ExcelImportProgressVo
importProgressVo
=
new
ExcelImportProgressVo
(
CommonConstants
.
ONEHUNDRED_BIGDECIMAL
,
successNum
,
failNum
,
totalNum
==
0
||
successNum
>
0
?
"导入成功"
:
"导入失败"
,
exportExcelUrl
);
excelAsyncImportService
.
updateImportProcess
(
uuid
,
importProgressVo
);
}
/**
* 导出错误数据
* @param failData 错误数据
* @return excel url
* @author yangwei
* @since 2025/12/16 15:58
*/
public
String
errorRecordExport
(
List
<
MerchantProfitRecordExcelImportDTO
>
failData
)
{
TemplateCodeEnum
templateCodeEnum
=
TemplateCodeEnum
.
MERCHANT_PROFIT_RECORD_TEMP_ERROR
;
String
fileNameSb
=
templateCodeEnum
.
getName
()
+
DateUtils
.
format
(
new
Date
(),
DateUtils
.
DATE_FORMAT_14
)
+
ExcelTypeEnum
.
XLSX
.
getValue
();
String
gopExcelTempPath
=
Optional
.
ofNullable
(
env
.
getProperty
(
ConfigCenterConstants
.
GOP_EXCEL_TEMP_PATH
))
.
orElseThrow
(()
->
new
RpcServiceException
(
DefaultErrorEnum
.
SERVICE_ERROR
,
"excel临时存放目录未配置"
));
File
file
=
FileUtils
.
getFile
(
gopExcelTempPath
);
File
outfile
=
new
File
(
file
,
fileNameSb
);
ExcelWriter
excelWriter
=
null
;
try
{
excelWriter
=
EasyExcel
.
write
(
outfile
).
withTemplate
(
new
ClassPathResource
(
templateCodeEnum
.
getPath
()).
getInputStream
()).
build
();
WriteSheet
writeSheet
=
EasyExcel
.
writerSheet
().
build
();
excelWriter
.
fill
(
failData
,
writeSheet
);
}
catch
(
IOException
e
)
{
log
.
error
(
"门店毛利额批量导入失败"
,
e
);
}
finally
{
if
(
excelWriter
!=
null
)
{
excelWriter
.
finish
();
}
}
return
Optional
.
ofNullable
(
env
.
getProperty
(
ConfigCenterConstants
.
GOP_EXCEL_TEM_URL
))
.
orElseThrow
(()
->
new
RpcServiceException
(
DefaultErrorEnum
.
SERVICE_ERROR
,
"excel临时存放目录未配置"
))
+
fileNameSb
;
}
/**
* 读取excel数据
*
* @param request 上传参数
* @return java.util.Map<java.lang.Integer, cn.com.glsx.dj.script.dto.excel.ActivityAwardWinnerExcelDTO>
* @author yangwei
* @since 2025/12/16 10:02
*/
public
Map
<
Integer
,
MerchantProfitRecordExcelImportDTO
>
readExcelHandler
(
SingleUploadRequest
request
)
{
Map
<
Integer
,
MerchantProfitRecordExcelImportDTO
>
exportDataMap
=
MapUtil
.
newHashMap
(
true
);
try
(
InputStream
inputstream
=
new
BufferedInputStream
(
new
ByteArrayInputStream
(
request
.
getFile
().
getContent
())))
{
EasyExcel
.
read
(
inputstream
,
ActivityAwardWinnerExcelDTO
.
class
,
new
MerchantProfitRecordListener
(
exportDataMap
))
.
sheet
()
.
headRowNumber
(
8
)
.
doRead
();
}
catch
(
Exception
e
)
{
log
.
error
(
"导入文件异常"
,
e
);
Throwable
cause
=
e
.
getCause
();
if
(
ObjectUtil
.
isNotNull
(
cause
)
&&
cause
instanceof
RpcServiceException
)
{
String
msg
=
cause
.
getMessage
();
throw
new
RpcServiceException
(
RopErrorEnum
.
TEMPLATE_ERROR
,
msg
);
}
throw
new
RpcServiceException
(
RopErrorEnum
.
PARSE_EXCEL_EXCEPTION
);
}
return
exportDataMap
;
}
/**
* 事项管理异步导出
* @author yangwei
* @since 2025/12/17 17:54
* @param merchantBiMatterBaseQryReq 导出请求参数
* @return java.lang.String uuid
*/
public
String
merchantBiMatterAsyncExport
(
MerchantBiMatterBaseQryReq
merchantBiMatterBaseQryReq
)
{
StringBuilder
fileNameSb
=
new
StringBuilder
();
fileNameSb
.
append
(
"BI事项"
).
append
(
DateUtils
.
format
(
new
Date
(),
DateUtils
.
DATE_FORMAT_14
)).
append
(
ExcelTypeEnum
.
XLSX
.
getValue
());
String
gopExcelTempPath
=
Optional
.
ofNullable
(
env
.
getProperty
(
ConfigCenterConstants
.
GOP_EXCEL_TEMP_PATH
))
.
orElseThrow
(()
->
new
RpcServiceException
(
DefaultErrorEnum
.
SERVICE_ERROR
,
"excel临时存放目录未配置"
));
File
file
=
FileUtils
.
getFile
(
gopExcelTempPath
);
File
outfile
=
new
File
(
file
,
fileNameSb
.
toString
());
// 导出 excel
ExcelWriter
excelWriter
=
null
;
try
{
excelWriter
=
EasyExcel
.
write
(
outfile
,
BiMatterExcelDTO
.
class
).
build
();
WriteSheet
writeSheet
=
EasyExcel
.
writerSheet
(
"sheet1"
).
build
();
RpcPagination
<
MerchantBiMatterBaseQryDTO
>
rpcPagination
=
CommonUtil
.
getRpcPagination
(
MerchantBiMatterBaseQryDTO
.
class
);
rpcPagination
.
setPageNum
(-
1
);
MerchantBiMatterBaseQryDTO
condition
=
BeanUtil
.
copyProperties
(
merchantBiMatterBaseQryReq
,
MerchantBiMatterBaseQryDTO
.
class
);
rpcPagination
.
setCondition
(
condition
);
RpcResponse
<
RpcPagination
<
MerchantBiMatterDTO
>>
response
=
biAnalyseBackgroundRemote
.
merchantBiMatterPage
(
rpcPagination
);
RpcPagination
<
MerchantBiMatterDTO
>
result
=
response
.
getResult
();
if
(
response
.
isFailed
())
{
throw
new
RpcServiceException
(
response
.
getError
(),
response
.
getMessage
());
}
List
<
MerchantBiMatterDTO
>
list
=
Optional
.
ofNullable
(
result
.
getList
()).
filter
(
CollUtil:
:
isNotEmpty
).
orElseGet
(
ArrayList:
:
new
);
List
<
BiMatterExcelDTO
>
excelDtoList
=
merchantBiMatterConvert
.
biMatterDtoList2ExcelDtoList
(
list
);
excelWriter
.
write
(
excelDtoList
,
writeSheet
);
}
catch
(
Exception
e
)
{
log
.
error
(
"写出excel异常"
,
e
);
throw
new
RpcServiceException
(
RopErrorEnum
.
AYSNC_EXPORT_ERROR
,
"导出excel失败"
);
}
finally
{
if
(
excelWriter
!=
null
)
{
excelWriter
.
finish
();
}
}
return
Optional
.
ofNullable
(
env
.
getProperty
(
ConfigCenterConstants
.
GOP_EXCEL_TEM_URL
))
.
orElseThrow
(()
->
new
RpcServiceException
(
DefaultErrorEnum
.
SERVICE_ERROR
,
"excel临时存放目录未配置"
))
+
fileNameSb
;
}
}
src/main/java/cn/com/glsx/dj/script/service/ExcelAsyncImportService.java
View file @
8f99cab
package
cn
.
com
.
glsx
.
dj
.
script
.
service
;
package
cn
.
com
.
glsx
.
dj
.
script
.
service
;
import
cn.com.glsx.dj.script.constant.ConfigCenterConstants
;
import
cn.com.glsx.dj.script.constant.RedisKeyConstants
;
import
cn.com.glsx.dj.script.interceptor.ThreadLocalCache
;
import
cn.com.glsx.dj.script.interceptor.ThreadLocalCache
;
import
cn.com.glsx.dj.script.utils.CommonUtil
;
import
cn.com.glsx.dj.script.utils.CommonUtil
;
import
cn.com.glsx.dj.smartcarlife.constant.CommonConstants
;
import
cn.com.glsx.dj.smartcarlife.dto.ExportLogDTO
;
import
cn.com.glsx.dj.smartcarlife.dto.ExportLogDTO
;
import
cn.com.glsx.dj.smartcarlife.dto.LoginUserDTO
;
import
cn.com.glsx.dj.smartcarlife.dto.LoginUserDTO
;
import
cn.com.glsx.dj.smartcarlife.enums.CarLifeEnum
;
import
cn.com.glsx.dj.smartcarlife.enums.CarLifeEnum
;
import
cn.com.glsx.dj.smartcarlife.remote.ExcelAsyncExportRemote
;
import
cn.com.glsx.dj.smartcarlife.remote.ExcelAsyncExportRemote
;
import
cn.com.glsx.dj.smartcarlife.vo.excel.ExcelImportProgressVo
;
import
cn.com.glsx.framework.core.beans.rpc.RpcResponse
;
import
cn.com.glsx.framework.core.beans.rpc.RpcResponse
;
import
cn.com.glsx.framework.core.exception.RpcServiceException
;
import
cn.com.glsx.framework.core.exception.RpcServiceException
;
import
cn.com.glsx.framework.rop.response.RopResponse
;
import
cn.com.glsx.framework.rop.response.RopResponse
;
...
@@ -16,12 +20,17 @@ import org.apache.commons.lang.StringUtils;
...
@@ -16,12 +20,17 @@ import org.apache.commons.lang.StringUtils;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.task.TaskExecutor
;
import
org.springframework.core.task.TaskExecutor
;
import
org.springframework.data.redis.core.BoundValueOperations
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.Objects
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.util.concurrent.TimeUnit
;
@Slf4j
@Slf4j
@Service
@Service
...
@@ -34,6 +43,9 @@ public class ExcelAsyncImportService {
...
@@ -34,6 +43,9 @@ public class ExcelAsyncImportService {
@Autowired
@Autowired
private
TaskExecutor
taskExecutor
;
private
TaskExecutor
taskExecutor
;
@Autowired
private
RedisTemplate
<
String
,
ExcelImportProgressVo
>
redisTemplate
;
public
RpcResponse
<
ExportLogDTO
>
insertExportLog
(
String
methodName
)
{
public
RpcResponse
<
ExportLogDTO
>
insertExportLog
(
String
methodName
)
{
LoginUserDTO
loginUser
=
CommonUtil
.
getLoginUser
();
LoginUserDTO
loginUser
=
CommonUtil
.
getLoginUser
();
ExportLogDTO
exportLogDTO
=
new
ExportLogDTO
();
ExportLogDTO
exportLogDTO
=
new
ExportLogDTO
();
...
@@ -81,4 +93,47 @@ public class ExcelAsyncImportService {
...
@@ -81,4 +93,47 @@ public class ExcelAsyncImportService {
String
export
(
T
request
)
throws
Exception
;
String
export
(
T
request
)
throws
Exception
;
}
}
/**
* 增加导入进度
* @author yangwei
* @since 2025/12/16 10:22
* @param uuid 导入进度条唯一标识
* @param pace 步长
*/
public
void
incrementImportProcess
(
String
uuid
,
BigDecimal
pace
)
{
final
String
redisKey
=
String
.
format
(
RedisKeyConstants
.
DJ_SCRIPT_IMPORT_PROGRESS_MAP
,
uuid
);
BoundValueOperations
<
String
,
ExcelImportProgressVo
>
cacheOps
=
redisTemplate
.
boundValueOps
(
redisKey
);
ExcelImportProgressVo
progressVo
=
cacheOps
.
get
();
if
(
progressVo
==
null
)
{
progressVo
=
ExcelImportProgressVo
.
builder
().
uuid
(
uuid
).
progress
(
BigDecimal
.
ZERO
).
build
();
}
BigDecimal
progress
=
progressVo
.
getProgress
().
add
(
pace
);
if
(
CommonConstants
.
ONEHUNDRED_BIGDECIMAL
.
compareTo
(
progress
)
<
0
)
{
progress
=
CommonConstants
.
ONEHUNDRED_BIGDECIMAL
;
}
if
(
BigDecimal
.
ZERO
.
compareTo
(
progress
)
>
0
)
{
progress
=
BigDecimal
.
ZERO
;
}
progressVo
.
setProgress
(
progress
);
Long
expireMinutes
=
Optional
.
ofNullable
(
env
.
getProperty
(
ConfigCenterConstants
.
IMPORT_PROGRESS_KEY_EXPIRED_MINUTES
,
Long
.
class
)).
orElse
(
5L
);
cacheOps
.
set
(
progressVo
,
expireMinutes
,
TimeUnit
.
MINUTES
);
}
/**
* 更新导入进度
* @author yangwei
* @since 2025/12/16 10:22
* @param uuid 导入进度条唯一标识
* @param progressVo 进度条对象
*/
public
void
updateImportProcess
(
String
uuid
,
ExcelImportProgressVo
progressVo
)
{
if
(
progressVo
!=
null
)
{
String
redisKey
=
String
.
format
(
RedisKeyConstants
.
DJ_SCRIPT_IMPORT_PROGRESS_MAP
,
uuid
);
Long
expireMinutes
=
Optional
.
ofNullable
(
env
.
getProperty
(
ConfigCenterConstants
.
IMPORT_PROGRESS_KEY_EXPIRED_MINUTES
,
Long
.
class
)).
orElse
(
5L
);
redisTemplate
.
opsForValue
().
set
(
redisKey
,
progressVo
,
expireMinutes
,
TimeUnit
.
MINUTES
);
}
}
}
}
src/main/java/cn/com/glsx/dj/script/utils/excel/RopExcelFileValidator.java
View file @
8f99cab
...
@@ -46,4 +46,28 @@ public final class RopExcelFileValidator {
...
@@ -46,4 +46,28 @@ public final class RopExcelFileValidator {
return
null
;
return
null
;
}
}
/**
* <pre>
* 校验Excel文件
* 1. 校验文件不能为null
* 2. 校验文件扩展名只能是 .xlsx 或 .xls
* </pre>
* @author yangwei
* @since 2025/12/15 14:53
* @param uploadFile ROP上传文件对象
* @return java.lang.String 校验结果消息,null表示通过
*/
public
static
String
validateExcelFile
(
UploadFile
uploadFile
)
{
if
(
uploadFile
==
null
)
{
return
"文件不能为空"
;
}
String
fileExtension
=
uploadFile
.
getFileType
().
toLowerCase
();
if
(!
ALLOWED_EXTENSIONS
.
contains
(
fileExtension
))
{
return
"只支持 .xlsx 或 .xls 格式的Excel文件"
;
}
return
null
;
}
}
}
\ No newline at end of file
\ No newline at end of file
src/main/resources/template/merchant_profit_record_temp.xlsx
0 → 100644
View file @
8f99cab
No preview for this file type
src/main/resources/template/merchant_profit_record_temp_error.xlsx
0 → 100644
View file @
8f99cab
No preview for this file type
Write
Preview
Markdown
is supported
Attach a file
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 post a comment