Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
promotion-service
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
promotion
promotion-service
Commits
781fed7f
提交
781fed7f
authored
1月 01, 2026
作者:
吕本才
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
style(promotion): 格式化代码样式并优化日期处理逻辑
上级
c78295a5
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
48 行增加
和
37 行删除
+48
-37
PromPlanCoreServiceImpl.java
.../service/activityplanv2/impl/PromPlanCoreServiceImpl.java
+48
-37
没有找到文件。
src/main/java/com/wangxiaolu/promotion/service/activityplanv2/impl/PromPlanCoreServiceImpl.java
浏览文件 @
781fed7f
...
...
@@ -63,7 +63,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
public
Map
<
String
,
Object
>
selfPlanUp
(
ActivityPlanVo
planVo
,
String
filePath
)
throws
DataException
{
// 1、解析活动计划文件是否符合规范
Map
<
String
,
Object
>
map
=
readSheetByCSJLUp
(
planVo
,
filePath
);
if
(!
map
.
containsKey
(
"uuid"
)){
if
(!
map
.
containsKey
(
"uuid"
))
{
return
map
;
}
...
...
@@ -77,7 +77,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
map
.
put
(
"record"
,
record
);
map
.
put
(
"type"
,
OperationType
.
UP
.
getCode
());
// 保存到缓存(uuid)
redisCache
.
addToJsonToMinute
(
RedisKeys
.
Manage
.
ACTIVITY_PLAN_UP
.
getKey
()
+
map
.
get
(
"uuid"
).
toString
(),
map
,
30
);
redisCache
.
addToJsonToMinute
(
RedisKeys
.
Manage
.
ACTIVITY_PLAN_UP
.
getKey
()
+
map
.
get
(
"uuid"
).
toString
(),
map
,
30
);
// 返回结果
return
map
;
}
...
...
@@ -117,7 +117,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
List
<
ActivityPlanInfoDto
>
rDtos
=
new
ArrayList
<>(
rows
.
size
()
*
4
);
// 循环每行
for
(
Map
.
Entry
<
Integer
,
List
<
Object
>>
row
:
rows
.
entrySet
())
{
List
<
ActivityPlanInfoDto
>
infoDtos
=
getRowByCSJLUp
(
planVo
,
row
.
getValue
(),
rMap
);
List
<
ActivityPlanInfoDto
>
infoDtos
=
getRowByCSJLUp
(
planVo
,
row
.
getValue
(),
rMap
);
rDtos
.
addAll
(
infoDtos
);
}
rMap
.
put
(
"table"
,
rDtos
);
...
...
@@ -125,12 +125,11 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
}
/**
* 城市经理 - 上传计划
* 循环每天
*/
private
List
<
ActivityPlanInfoDto
>
getRowByCSJLUp
(
ActivityPlanVo
planVo
,
List
<
Object
>
row
,
Map
<
String
,
Object
>
rMap
)
{
private
List
<
ActivityPlanInfoDto
>
getRowByCSJLUp
(
ActivityPlanVo
planVo
,
List
<
Object
>
row
,
Map
<
String
,
Object
>
rMap
)
{
List
<
ActivityPlanInfoDto
>
dtos
=
new
ArrayList
<>();
LocalDate
now
=
LocalDate
.
now
();
int
monthValue
=
now
.
getMonthValue
();
...
...
@@ -205,7 +204,11 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
int
year
=
DateUtil
.
thisYear
();
Month
month
=
Month
.
of
(
monthInt
);
if
(
month
.
equals
(
Month
.
JANUARY
))
{
year
+=
1
;
Month
currentMonth
=
now
.
getMonth
();
Integer
currentMonthValue
=
currentMonth
.
getValue
();
if
(!
currentMonthValue
.
equals
(
monthInt
))
{
year
+=
1
;
}
}
LocalDate
planDate
=
LocalDate
.
of
(
year
,
month
,
day
);
if
(
monthInt
!=
nextMonthValue
&&
monthInt
!=
monthValue
)
{
...
...
@@ -279,7 +282,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
}
catch
(
DateTimeException
e
)
{
dto
.
setErrorMsg
(
"月份、日期、时间需要调整;"
);
}
if
(
StringUtils
.
isNotBlank
(
dto
.
getErrorMsg
())){
if
(
StringUtils
.
isNotBlank
(
dto
.
getErrorMsg
()))
{
rMap
.
remove
(
"uuid"
);
}
dtos
.
add
(
dto
);
...
...
@@ -295,7 +298,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
public
Map
<
String
,
Object
>
authPlanUp
(
ActivityPlanVo
planVo
,
String
filePath
)
throws
DataException
{
// 1、解析活动计划文件是否符合规范
Map
<
String
,
Object
>
map
=
readSheetByZNJSUp
(
planVo
,
filePath
);
if
(!
map
.
containsKey
(
"uuid"
)){
if
(!
map
.
containsKey
(
"uuid"
))
{
return
map
;
}
...
...
@@ -309,7 +312,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
map
.
put
(
"record"
,
record
);
map
.
put
(
"type"
,
OperationType
.
UP
.
getCode
());
// 保存到缓存(uuid)
redisCache
.
addToJsonToMinute
(
RedisKeys
.
Manage
.
ACTIVITY_PLAN_UP
.
getKey
()
+
map
.
get
(
"uuid"
).
toString
(),
map
,
30
);
redisCache
.
addToJsonToMinute
(
RedisKeys
.
Manage
.
ACTIVITY_PLAN_UP
.
getKey
()
+
map
.
get
(
"uuid"
).
toString
(),
map
,
30
);
// 返回结果
return
map
;
}
...
...
@@ -347,7 +350,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
List
<
ActivityPlanInfoDto
>
rDtos
=
new
ArrayList
<>(
rows
.
size
()
*
4
);
for
(
Map
.
Entry
<
Integer
,
List
<
Object
>>
row
:
rows
.
entrySet
())
{
List
<
ActivityPlanInfoDto
>
infoDtos
=
getRowByZNJSUp
(
planVo
,
row
.
getValue
(),
rMap
);
List
<
ActivityPlanInfoDto
>
infoDtos
=
getRowByZNJSUp
(
planVo
,
row
.
getValue
(),
rMap
);
rDtos
.
addAll
(
infoDtos
);
}
rMap
.
put
(
"table"
,
rDtos
);
...
...
@@ -358,7 +361,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
/**
* 职能角色 - 上传计划
*/
private
List
<
ActivityPlanInfoDto
>
getRowByZNJSUp
(
ActivityPlanVo
planVo
,
List
<
Object
>
row
,
Map
<
String
,
Object
>
rMap
)
{
private
List
<
ActivityPlanInfoDto
>
getRowByZNJSUp
(
ActivityPlanVo
planVo
,
List
<
Object
>
row
,
Map
<
String
,
Object
>
rMap
)
{
List
<
ActivityPlanInfoDto
>
dtos
=
new
ArrayList
<>();
LocalDate
now
=
LocalDate
.
now
();
int
monthValue
=
now
.
getMonthValue
();
...
...
@@ -439,7 +442,11 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
int
monthInt
=
Integer
.
parseInt
(
row
.
get
(
4
).
toString
());
Month
month
=
Month
.
of
(
monthInt
);
if
(
month
.
equals
(
Month
.
JANUARY
))
{
year
+=
1
;
Month
currentMonth
=
now
.
getMonth
();
Integer
currentMonthValue
=
currentMonth
.
getValue
();
if
(!
currentMonthValue
.
equals
(
monthInt
))
{
year
+=
1
;
}
}
LocalDate
planDate
=
LocalDate
.
of
(
year
,
month
,
day
);
if
(
monthInt
!=
nextMonthValue
&&
monthInt
!=
monthValue
)
{
...
...
@@ -508,7 +515,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
}
catch
(
DateTimeException
e
)
{
dto
.
setErrorMsg
(
"月份、日期、时间需要调整;"
);
}
if
(
StringUtils
.
isNotBlank
(
dto
.
getErrorMsg
())){
if
(
StringUtils
.
isNotBlank
(
dto
.
getErrorMsg
()))
{
rMap
.
remove
(
"uuid"
);
}
dtos
.
add
(
dto
);
...
...
@@ -523,8 +530,8 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
@Override
public
Map
<
String
,
Object
>
selfPlanPut
(
ActivityPlanVo
planVo
,
String
filePath
)
throws
DataException
{
// 1、解析活动计划文件是否符合规范
Map
<
String
,
Object
>
map
=
readSheetByCSJLPut
(
planVo
,
filePath
);
if
(!
map
.
containsKey
(
"uuid"
)){
Map
<
String
,
Object
>
map
=
readSheetByCSJLPut
(
planVo
,
filePath
);
if
(!
map
.
containsKey
(
"uuid"
))
{
return
map
;
}
...
...
@@ -538,7 +545,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
map
.
put
(
"record"
,
record
);
map
.
put
(
"type"
,
OperationType
.
PUT
.
getCode
());
// 保存到缓存(uuid)
redisCache
.
addToJsonToMinute
(
RedisKeys
.
Manage
.
ACTIVITY_PLAN_UP
.
getKey
()
+
map
.
get
(
"uuid"
).
toString
(),
map
,
30
);
redisCache
.
addToJsonToMinute
(
RedisKeys
.
Manage
.
ACTIVITY_PLAN_UP
.
getKey
()
+
map
.
get
(
"uuid"
).
toString
(),
map
,
30
);
// 返回结果
return
map
;
}
...
...
@@ -547,11 +554,11 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
public
void
putActivityPlan
(
ActivityPlanOperVo
operVo
)
{
ActivityPlanInfoDto
dto
=
activityPlanInfoDao
.
selectById
(
operVo
.
getId
());
// 已执行的计划不可修改
if
(
PlanStatus
.
EXECUTION
.
getCode
().
equals
(
dto
.
getPlanStatus
())){
if
(
PlanStatus
.
EXECUTION
.
getCode
().
equals
(
dto
.
getPlanStatus
()))
{
throw
new
FlowException
(
RCode
.
ACTIVITY_IS_START
);
}
// 不可修改活动日期 <= 今日 的计划
if
(
DateUtils
.
parseDateBylocalDate
(
dto
.
getDate
()).
isBefore
(
LocalDate
.
now
())){
if
(
DateUtils
.
parseDateBylocalDate
(
dto
.
getDate
()).
isBefore
(
LocalDate
.
now
()))
{
throw
new
FlowException
(
RCode
.
ACTIVITY_PLAN_NOT_DELETE
);
}
...
...
@@ -560,13 +567,13 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
Date
planDate
=
operVo
.
getDate
();
LocalDate
localDatePlan
=
DateUtils
.
parseDateBylocalDate
(
planDate
);
LocalDate
lastDayOfMonth
=
today
.
with
(
TemporalAdjusters
.
lastDayOfMonth
());
if
(!
localDatePlan
.
isAfter
(
today
)
||
localDatePlan
.
isAfter
(
lastDayOfMonth
)){
if
(!
localDatePlan
.
isAfter
(
today
)
||
localDatePlan
.
isAfter
(
lastDayOfMonth
))
{
throw
new
FlowException
(
RCode
.
ACTIVITY_PLAN_DATA_ERROR
);
}
ActivityPlanInfoDto
planDto
=
new
ActivityPlanInfoDto
();
// 归属人改变
if
(!
operVo
.
getEmployeeId
().
equals
(
dto
.
getEmployeeId
())){
if
(!
operVo
.
getEmployeeId
().
equals
(
dto
.
getEmployeeId
()))
{
ManageEmployeeInfoDto
employeeInfoDto
=
manageEmployeeInfoDao
.
selectById
(
operVo
.
getEmployeeId
());
planDto
.
setEmployeeId
(
employeeInfoDto
.
getId
())
.
setEmployeeNo
(
employeeInfoDto
.
getEmployeeNo
())
...
...
@@ -578,7 +585,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
StoreWrapper
storeWrap
=
new
StoreWrapper
().
setStoreCode
(
operVo
.
getStoreCode
());
QinCeClienteleStoreDto
storeDto
=
qinCeClienteleStoreDao
.
getOneStore
(
storeWrap
);
if
(!
storeDto
.
getDealerId
().
equals
(
dto
.
getDealerId
())){
if
(!
storeDto
.
getDealerId
().
equals
(
dto
.
getDealerId
()))
{
throw
new
FlowException
(
RCode
.
QINCE_STORE_DEALER_ERROR
);
}
...
...
@@ -650,18 +657,18 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
ManageEmployeeInfoDto
employeeInfoDto
=
manageEmployeeInfoDao
.
selectById
(
operVo
.
getEmployeeId
());
ActivityPlanInfoDto
planDto
=
new
ActivityPlanInfoDto
();
planDto
.
setEmployeeId
(
employeeInfoDto
.
getId
())
.
setEmployeeName
(
employeeInfoDto
.
getName
())
.
setEmployeeNo
(
employeeInfoDto
.
getEmployeeNo
())
.
setOrgName
(
employeeInfoDto
.
getDeptQcName
())
.
setOrgQcId
(
employeeInfoDto
.
getDeptQcId
())
.
setEmployeeName
(
employeeInfoDto
.
getName
())
.
setEmployeeNo
(
employeeInfoDto
.
getEmployeeNo
())
.
setOrgName
(
employeeInfoDto
.
getDeptQcName
())
.
setOrgQcId
(
employeeInfoDto
.
getDeptQcId
())
.
setModifyBy
(
operVo
.
getOperName
());
activityPlanInfoDao
.
updateByIds
(
operVo
.
getPlanIds
(),
planDto
);
activityPlanInfoDao
.
updateByIds
(
operVo
.
getPlanIds
(),
planDto
);
}
/**
* 城市经理 - 修改计划
*/
private
Map
<
String
,
Object
>
readSheetByCSJLPut
(
ActivityPlanVo
planVo
,
String
filePath
)
throws
DataException
{
private
Map
<
String
,
Object
>
readSheetByCSJLPut
(
ActivityPlanVo
planVo
,
String
filePath
)
throws
DataException
{
ReadExcelUtils
readExcelUtils
=
new
ReadExcelUtils
(
filePath
);
String
[]
headers
=
readExcelUtils
.
readTitle
();
Map
<
Integer
,
List
<
Object
>>
rows
=
readExcelUtils
.
readContent
();
...
...
@@ -691,7 +698,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
List
<
ActivityPlanInfoDto
>
rDtos
=
new
ArrayList
<>(
rows
.
size
()
*
4
);
for
(
Map
.
Entry
<
Integer
,
List
<
Object
>>
row
:
rows
.
entrySet
())
{
List
<
ActivityPlanInfoDto
>
infoDtos
=
getRowByCSJLPut
(
planVo
,
row
.
getValue
(),
rMap
);
List
<
ActivityPlanInfoDto
>
infoDtos
=
getRowByCSJLPut
(
planVo
,
row
.
getValue
(),
rMap
);
rDtos
.
addAll
(
infoDtos
);
}
rMap
.
put
(
"table"
,
rDtos
);
...
...
@@ -701,7 +708,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
/**
* 城市经理 - 修改计划
*/
private
List
<
ActivityPlanInfoDto
>
getRowByCSJLPut
(
ActivityPlanVo
planVo
,
List
<
Object
>
row
,
Map
<
String
,
Object
>
rMap
)
{
private
List
<
ActivityPlanInfoDto
>
getRowByCSJLPut
(
ActivityPlanVo
planVo
,
List
<
Object
>
row
,
Map
<
String
,
Object
>
rMap
)
{
List
<
ActivityPlanInfoDto
>
dtos
=
new
ArrayList
<>();
/**
...
...
@@ -718,7 +725,12 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
int
year
=
DateUtil
.
thisYear
();
Month
month
=
Month
.
of
(
monthInt
);
if
(
month
.
equals
(
Month
.
JANUARY
))
{
year
+=
1
;
LocalDate
now
=
LocalDate
.
now
();
Month
currentMonth
=
now
.
getMonth
();
Integer
currentMonthValue
=
currentMonth
.
getValue
();
if
(!
currentMonthValue
.
equals
(
monthInt
))
{
year
+=
1
;
}
}
LocalDate
planDate
=
LocalDate
.
of
(
year
,
month
,
day
);
dto
.
setYear
(
year
).
setMonth
(
planDate
.
getMonthValue
()).
setDate
(
DateUtils
.
parseDateBylocalDate
(
planDate
));
...
...
@@ -761,7 +773,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
}
else
if
(
PlanStatus
.
EXECUTION
.
getCode
().
equals
(
hasDto
.
getPlanStatus
()))
{
dto
.
setErrorMsg
(
"计划已执行,不可修改;"
);
}
else
if
(!
hasDto
.
getEmployeeNo
().
equals
(
row
.
get
(
0
).
toString
()))
{
dto
.
setErrorMsg
(
"计划不属于"
+
row
.
get
(
0
)+
",归属人:"
+
hasDto
.
getEmployeeName
()
+
";"
);
dto
.
setErrorMsg
(
"计划不属于"
+
row
.
get
(
0
)
+
",归属人:"
+
hasDto
.
getEmployeeName
()
+
";"
);
}
dto
.
setEmployeeName
(
hasDto
.
getEmployeeName
())
.
setOrgQcId
(
hasDto
.
getOrgQcId
())
...
...
@@ -793,7 +805,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
}
// 促销员上班时间顺延1小时内,可修改
if
(
LocalDateTime
.
now
().
isAfter
(
hasDto
.
getClockInTime
().
plusHours
(
1
))){
if
(
LocalDateTime
.
now
().
isAfter
(
hasDto
.
getClockInTime
().
plusHours
(
1
)))
{
dto
.
setErrorMsg
(
"已超促销员上班时间1小时,不可修改;"
);
}
...
...
@@ -844,7 +856,6 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
synchronized
void
selfPlanAf
(
String
planUuid
)
{
...
...
@@ -860,16 +871,16 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
String
type
=
mapJson
.
getString
(
"type"
);
if
(
OperationType
.
UP
.
getCode
().
equals
(
type
))
{
// 保存上传记录
Long
recordId
=
activityPlanRecordDao
.
save
(
record
,
OperationType
.
UP
);
Long
recordId
=
activityPlanRecordDao
.
save
(
record
,
OperationType
.
UP
);
activityPlanInfoDao
.
saveList
(
table
,
recordId
);
}
else
if
(
OperationType
.
PUT
.
getCode
().
equals
(
type
))
{
Long
recordId
=
activityPlanRecordDao
.
save
(
record
,
OperationType
.
PUT
);
Long
recordId
=
activityPlanRecordDao
.
save
(
record
,
OperationType
.
PUT
);
activityPlanInfoDao
.
updateList
(
table
,
recordId
);
}
}
@Override
public
void
deletePlan
(
List
<
Long
>
planIds
,
String
employeeNo
,
String
operNo
)
{
activityPlanInfoDao
.
deleteByPlanIds
(
planIds
,
employeeNo
,
operNo
);
public
void
deletePlan
(
List
<
Long
>
planIds
,
String
employeeNo
,
String
operNo
)
{
activityPlanInfoDao
.
deleteByPlanIds
(
planIds
,
employeeNo
,
operNo
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论