Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
promotion-service
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
promotion
promotion-service
Commits
96c00521
提交
96c00521
authored
12月 26, 2024
作者:
吕本才
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
上传活动计划,增加表头验证,优化勤策店铺code和名称校验
上级
66e88e12
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
35 行增加
和
10 行删除
+35
-10
ActivityPlanRecordCoreServiceImpl.java
...tivity/manage/impl/ActivityPlanRecordCoreServiceImpl.java
+35
-10
没有找到文件。
src/main/java/com/wangxiaolu/promotion/service/activity/manage/impl/ActivityPlanRecordCoreServiceImpl.java
浏览文件 @
96c00521
...
...
@@ -19,7 +19,6 @@ import com.wangxiaolu.promotion.pojo.user.dto.QinCeClienteleStoreDto;
import
com.wangxiaolu.promotion.result.basedata.RCode
;
import
com.wangxiaolu.promotion.service.activity.manage.ActivityPlanRecordCoreService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.groovy.util.Maps
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -82,8 +81,9 @@ public class ActivityPlanRecordCoreServiceImpl implements ActivityPlanRecordCore
private
void
saveActivityPlanInfo
(
ActivityPlanVo
activityPlanVo
,
EmployeeActivityPlanRecordDto
planDto
)
throws
Exception
{
// 下载
String
filePath
=
"/home/"
+
planDto
.
getExcelFiledId
();
downloadExcel
(
activityPlanVo
.
getExcelUrl
(),
filePath
);
// String filePath = "/home/" + planDto.getExcelFiledId();
// downloadExcel(activityPlanVo.getExcelUrl(), filePath);
String
filePath
=
"/Users/tumaxiao/学习资料和自媒体/王小卤/02项目/销售-小程序/"
+
planDto
.
getExcelFiledId
();
// 读取
List
<
EmployeeActivityPlanInfoDto
>
planInfoDtos
=
readSheet0
(
filePath
,
activityPlanVo
,
planDto
);
...
...
@@ -111,9 +111,12 @@ public class ActivityPlanRecordCoreServiceImpl implements ActivityPlanRecordCore
// 1、解析表格数据
ReadExcelUtils
readExcelUtils
=
new
ReadExcelUtils
(
filePath
);
Map
<
Integer
,
List
<
Object
>>
rows
=
readExcelUtils
.
readContent
();
String
[]
headers
=
readExcelUtils
.
readTitle
();
if
(
rows
.
size
()
<=
0
)
{
throw
new
DataException
(
RCode
.
API_DATA_ERROR
);
}
// 2、校验表头
validateHeader
(
headers
);
// 判断是否是城市经理已经的数据,5列数据是城市经理自己的,6列数据是战区顾问批量上传的
if
(
rows
.
get
(
1
).
size
()
==
6
)
{
...
...
@@ -125,12 +128,32 @@ public class ActivityPlanRecordCoreServiceImpl implements ActivityPlanRecordCore
}
}
public
void
validateHeader
(
String
[]
templateHeader
)
{
StringBuilder
msg
=
new
StringBuilder
();
if
(
templateHeader
.
length
<
6
)
{
msg
.
append
(
"模板列不正确"
);
}
String
[]
expectedHeader
=
{
"执行城市(二级行政单位市)\n例:成都市"
,
"门店负责人-工号\n例:000516"
,
"经销商编码(T100中的编码)\n例:001584"
,
"系统名称\n例:北京华联"
,
"门店编码(勤策-终端编码)\n例:POS00038920"
,
"门店全称(系统名称+分店地址)\n例:北京华联-经华南西店"
,
"活动模式(下拉选择)\n例:单点CP"
};
boolean
containsGh
=
templateHeader
[
1
].
contains
(
expectedHeader
[
1
]);
// 包含工号
for
(
int
i
=
0
;
i
<
templateHeader
.
length
;
i
++)
{
if
(
i
==
1
&&
containsGh
)
{
continue
;
}
if
(!
templateHeader
[
i
].
contains
(
expectedHeader
[
i
]))
{
msg
.
append
(
String
.
format
(
"第%d列表头是:%s"
,
i
+
1
,
expectedHeader
[
i
]));
}
}
if
(
msg
.
toString
().
length
()
>
0
)
{
throw
new
DataException
(
"模板不正确:"
+
msg
.
toString
());
}
}
/**
* 读取表格并进行数据校验
* 上传文件人员:城市经理自己
*/
private
List
<
EmployeeActivityPlanInfoDto
>
saveEmployeeOneselfPlan
(
Map
<
Integer
,
List
<
Object
>>
rows
,
ActivityPlanVo
activityPlanVo
,
EmployeeActivityPlanRecordDto
planDto
)
throws
Exception
{
// 查询当前用户下有效的门店名称列表,用于检查是否存在同名店铺
Set
<
String
>
storeNameDbList
=
employeeActivityPlanInfoDao
.
findStoreNameByEmployeeId
(
activityPlanVo
.
getEmployeeId
());
Map
<
Object
,
Object
>
dealers
=
redisCache
.
getAllHash
(
RedisKeys
.
UserKeys
.
DEALER_HAVE_LIST
.
getKey
());
...
...
@@ -187,7 +210,6 @@ public class ActivityPlanRecordCoreServiceImpl implements ActivityPlanRecordCore
List
<
ManageEmployeeInfoDto
>
employeeInfos
=
manageEmployeeInfoDao
.
selectList
(
new
ManageEmployeeWrapper
().
setEmployeeNos
(
employeeNos
));
Map
<
String
,
ManageEmployeeInfoDto
>
employeeInfoMap
=
employeeInfos
.
stream
().
collect
(
Collectors
.
toMap
(
ManageEmployeeInfoDto:
:
getEmployeeNo
,
o
->
o
));
Map
<
String
,
Integer
>
patternInfoMap
=
new
HashMap
<>();
for
(
Map
.
Entry
<
Object
,
Object
>
entry
:
patternMap
.
entrySet
())
{
patternInfoMap
.
put
(
entry
.
getValue
().
toString
(),
Integer
.
parseInt
((
String
)
entry
.
getKey
()));
...
...
@@ -271,11 +293,10 @@ public class ActivityPlanRecordCoreServiceImpl implements ActivityPlanRecordCore
QinCeClienteleStoreDto
oneStore
=
qinCeClienteleStoreDao
.
getOneStore
(
storeWrap
);
if
(
ObjectUtil
.
isEmpty
(
oneStore
))
{
sb
.
append
(
"勤策店铺编码不正确;"
);
}
}
else
{
if
(
StringUtils
.
isBlank
(
storeName
))
{
sb
.
append
(
"店铺名称不可为空;"
);
}
else
{
if
(
ObjectUtil
.
isNotEmpty
(
oneStore
.
getStoreName
())
&&
!
oneStore
.
getStoreName
().
equals
(
storeName
))
{
}
else
if
(!
storeName
.
equals
(
oneStore
.
getStoreName
())){
sb
.
append
(
"店铺名称不正确;"
);
}
}
...
...
@@ -355,12 +376,16 @@ public class ActivityPlanRecordCoreServiceImpl implements ActivityPlanRecordCore
QinCeClienteleStoreDto
oneStore
=
qinCeClienteleStoreDao
.
getOneStore
(
storeWrap
);
if
(
ObjectUtil
.
isEmpty
(
oneStore
))
{
sb
.
append
(
"勤策店铺编码不正确;"
);
}
if
(
ObjectUtil
.
isNotEmpty
(
oneStore
.
getStoreName
())
&&
!
oneStore
.
getStoreName
().
equals
(
storeName
))
{
}
else
{
if
(
StringUtils
.
isBlank
(
storeName
))
{
sb
.
append
(
"店铺名称不可为空;"
);
}
else
if
(!
storeName
.
equals
(
oneStore
.
getStoreName
())){
sb
.
append
(
"店铺名称不正确;"
);
}
}
}
String
pattern
=
(
String
)
value
.
get
(
6
);
if
(
StringUtils
.
isBlank
(
pattern
))
{
sb
.
append
(
"活动模式不可为空;"
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论