Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
training-project
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hqzhdj
training-project
Commits
9ab5510d
Commit
9ab5510d
authored
Sep 05, 2025
by
Lichen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
活动添加投票关联调整
parent
5d95d33c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
159 deletions
+65
-159
cloud-training-project-service/src/main/java/com/yizhi/training/application/service/impl/TpPlanServiceImpl.java
+65
-159
No files found.
cloud-training-project-service/src/main/java/com/yizhi/training/application/service/impl/TpPlanServiceImpl.java
View file @
9ab5510d
...
...
@@ -102,8 +102,6 @@ public class TpPlanServiceImpl extends ServiceImpl<TpPlanMapper, TpPlan> impleme
public
com
.
yizhi
.
training
.
application
.
vo
.
domain
.
TpPlanVo
save
(
BaseModel
<
TpPlanVo
>
model
)
{
RequestContext
context
=
model
.
getContext
();
Date
date
=
model
.
getDate
();
Map
<
String
,
Object
>
mapNode
=
new
HashMap
<>();
// 学习计划vo
TpPlanVo
tpPlanVo
=
model
.
getObj
();
com
.
yizhi
.
training
.
application
.
vo
.
domain
.
TpPlanVo
tp
=
new
com
.
yizhi
.
training
.
application
.
vo
.
domain
.
TpPlanVo
();
...
...
@@ -117,88 +115,53 @@ public class TpPlanServiceImpl extends ServiceImpl<TpPlanMapper, TpPlan> impleme
return
tp
;
}
// 组装学习计划
TpPlan
tpPlan
=
buildTpPlan
(
tpPlanVo
,
context
,
date
);
if
(
null
==
tpPlan
)
{
tp
.
setSubMsg
(
InternationalEnums
.
TP_PLAN_FAIL1
.
getCode
());
return
tp
;
}
// 组装学习计划条件前置条件(后置条件需要在活动组装完成后组装)
List
<
TpPlanConditionPre
>
planConditionPres
=
new
ArrayList
<>();
List
<
TpPlanConditionPost
>
planConditionPosts
=
new
ArrayList
<>();
try
{
buildTpPlanConditionPre
(
tpPlanVo
,
tpPlan
,
planConditionPres
);
}
catch
(
TrainingProjectException
e
)
{
log
.
error
(
"组装学习条件发生异常:{}"
,
e
);
tp
.
setSubMsg
(
InternationalEnums
.
TP_PLAN_FAIL2
.
getCode
());
return
tp
;
}
// // 组装计划提醒
// List<TpPlanRemindVo> planReminds = buildTpPlanRemind(tpPlanVo.getRemindVo(), tpPlan, context, date);
// TpPlan tpPlan = buildTpPlan(tpPlanVo, context, date);
// 学习活动vo
List
<
TpPlanActivityVo
>
activityVos
=
tpPlanVo
.
getActivities
();
// 组装学习活动 和 组装学习活动条件
List
<
TpPlanActivityConditionPre
>
activityConditionPres
=
new
ArrayList
<>();
List
<
TpPlanActivityConditionPost
>
activityConditionPosts
=
new
ArrayList
<>();
List
<
TpPlanActivity
>
planActivities
=
null
;
try
{
planActivities
=
buildTpPlanActivity
(
activityVos
,
context
,
date
,
tpPlan
,
tpPlanVo
.
getCondition
(),
planConditionPosts
,
activityConditionPres
,
activityConditionPosts
);
}
catch
(
TrainingProjectException
e
)
{
log
.
error
(
"组装学习活动 和 组装学习活动条件:{}"
,
e
);
tp
.
setSubMsg
(
InternationalEnums
.
TP_PLAN_FAIL3
.
getCode
());
return
tp
;
List
<
TpPlanActivity
>
planActivities
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
activityVos
.
size
();
i
++)
{
TpPlanActivityVo
item
=
activityVos
.
get
(
i
);
TpPlan
tpPlan
=
new
TpPlan
();
tpPlan
.
setId
(
idGenerator
.
generate
());
tpPlan
.
setSort
(
tpPlanVo
.
getSort
());
tpPlan
.
setTrainingProjectId
(
tpPlanVo
.
getTrainingProjectId
());
TpRemindVo
remindVo
=
tpPlanVo
.
getRemindVo
();
if
(
remindVo
!=
null
)
{
tpPlan
.
setAppRemindTemplateId
(
remindVo
.
getAppTemplateId
());
tpPlan
.
setMailRemindTemplateId
(
remindVo
.
getMailTemplateId
());
//此处不可删除
tpPlan
.
setEnableRemindApp
(
remindVo
.
getEnableApp
());
tpPlan
.
setEnableRemindMail
(
remindVo
.
getEnableMail
());
tpPlan
.
setRemindContent
(
remindVo
.
getContent
());
}
tpPlan
.
setDeleted
(
ProjectConstant
.
DELETED_NO
);
tpPlan
.
setName
(
item
.
getName
());
tpPlan
.
setStartTime
(
tpPlanVo
.
getStartTime
());
tpPlan
.
setEndTime
(
tpPlanVo
.
getEndTime
());
// 权限范围
tpPlan
.
setCompanyId
(
context
.
getCompanyId
());
tpPlan
.
setOrgId
(
context
.
getOrgId
()
==
null
?
new
Long
(
0
)
:
context
.
getOrgId
());
tpPlan
.
setSiteId
(
context
.
getSiteId
());
// 审计字段
tpPlan
.
setCreateById
(
context
.
getAccountId
());
tpPlan
.
setCreateByName
(
context
.
getAccountName
());
tpPlan
.
setCreateTime
(
date
);
LOGGER
.
info
(
"准备插入学习计划--{}"
,
tpPlan
.
getName
());
tpPlanMapper
.
insert
(
tpPlan
);
TpPlanActivity
planActivitie
=
buildTpPlanActivity
(
item
,
context
,
date
,
tpPlan
,
i
);
planActivities
.
add
(
planActivitie
);
}
// 插入学习计划
LOGGER
.
info
(
"准备插入学习计划--{}"
,
tpPlan
.
getName
());
tpPlanMapper
.
insert
(
tpPlan
);
// 插入学习计划条件
if
(!
CollectionUtils
.
isEmpty
(
planConditionPres
))
{
LOGGER
.
info
(
"准备插入学习计划前置条件"
);
tpPlanConditionPreMapper
.
batchInsert
(
planConditionPres
);
}
if
(!
CollectionUtils
.
isEmpty
(
planConditionPosts
))
{
LOGGER
.
info
(
"准备插入学习计划完成条件"
);
tpPlanConditionPostMapper
.
batchInsert
(
planConditionPosts
);
}
//发消息保存计划提醒
try
{
if
(
trainingProject
!=
null
&&
tpPlanVo
.
getMessageRemindVo
()
!=
null
)
{
taskExecutor
.
asynExecute
(
new
AbstractTaskHandler
()
{
@Override
public
void
handle
()
{
MessageRemindVo
mrv
=
tpPlanVo
.
getMessageRemindVo
();
MessageRemindVo
mrvs
=
new
MessageRemindVo
();
BeanUtils
.
copyProperties
(
mrv
,
mrvs
);
trainingEvenSendMessage
.
systemSendMessage
(
trainingProject
,
tpPlan
.
getId
(),
mrvs
,
context
);
}
});
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
// if (!CollectionUtils.isEmpty(planReminds)) {
// LOGGER.info("准备插入学习计划提醒完成条件");
// tpPlanRemindMapper.batchInsert(planReminds);
// }
// 插入学习活动
if
(!
CollectionUtils
.
isEmpty
(
planActivities
))
{
LOGGER
.
info
(
"准备插入学习活动"
);
tpPlanActivityMapper
.
batchInsert
(
planActivities
);
}
if
(!
CollectionUtils
.
isEmpty
(
activityConditionPres
))
{
LOGGER
.
info
(
"准备插入学习活动开启条件"
);
tpPlanActivityConditionPreMapper
.
batchInsert
(
activityConditionPres
);
}
if
(!
CollectionUtils
.
isEmpty
(
activityConditionPosts
))
{
LOGGER
.
info
(
"准备插入学习活动完成条件"
);
tpPlanActivityConditionPostMapper
.
batchInsert
(
activityConditionPosts
);
}
BeanUtils
.
copyProperties
(
tpPlan
,
tp
);
tp
.
setSubMsg
(
"success"
);
return
tp
;
}
...
...
@@ -787,97 +750,40 @@ public class TpPlanServiceImpl extends ServiceImpl<TpPlanMapper, TpPlan> impleme
/**
* 组装学习活动
*
* @param activityVo
s 学习活动vo集合
* @param activityVo
学习活动vo
* @param context 上下文
* @param date 操作时间
* @param tpPlan 组装好的学习计划
* @param planConditionVo 学习计划条件vo
* @param planConditionPosts 要入库的学习计划完成条件集合
* @param activityConditionPres 要入库的学习活动开启条件集合
* @param activityConditionPosts 要入库的学习活动完成条件集合
* @return
* @throws Exception
*/
private
List
<
TpPlanActivity
>
buildTpPlanActivity
(
List
<
TpPlanActivityVo
>
activityVos
,
RequestContext
context
,
Date
date
,
TpPlan
tpPlan
,
TpPlanConditionVo
planConditionVo
,
List
<
TpPlanConditionPost
>
planConditionPosts
,
List
<
TpPlanActivityConditionPre
>
activityConditionPres
,
List
<
TpPlanActivityConditionPost
>
activityConditionPosts
)
throws
TrainingProjectException
{
List
<
TpPlanActivity
>
list
=
null
;
if
(!
CollectionUtils
.
isEmpty
(
activityVos
))
{
list
=
new
ArrayList
<>();
// 活动关联id :活动 map
Map
<
Long
,
TpPlanActivity
>
relationActivityMap
=
new
HashMap
<>();
int
sort
=
0
;
for
(
TpPlanActivityVo
activityVo
:
activityVos
)
{
TpPlanActivity
activity
=
new
TpPlanActivity
();
activity
.
setCompanyId
(
context
.
getCompanyId
());
activity
.
setOrgId
(
context
.
getOrgId
()
==
null
?
new
Long
(
0
)
:
context
.
getOrgId
());
activity
.
setSiteId
(
context
.
getSiteId
());
activity
.
setCreateById
(
context
.
getAccountId
());
activity
.
setCreateByName
(
context
.
getAccountName
());
activity
.
setCreateTime
(
date
);
activity
.
setId
(
idGenerator
.
generate
());
activity
.
setDeleted
(
ProjectConstant
.
DELETED_NO
);
activity
.
setName
(
activityVo
.
getName
());
activity
.
setAddress
(
activityVo
.
getAddress
());
// 如果是外部链接,使用本身的id
if
(
activityVo
.
getType
().
equals
(
TpActivityType
.
TYPE_LINK
))
{
activity
.
setRelationId
(
activity
.
getId
());
}
else
{
activity
.
setRelationId
(
activityVo
.
getRelationId
());
}
activity
.
setTpPlanId
(
tpPlan
.
getId
());
activity
.
setTrainingProjectId
(
tpPlan
.
getTrainingProjectId
());
activity
.
setType
(
activityVo
.
getType
());
activity
.
setSort
(++
sort
);
list
.
add
(
activity
);
relationActivityMap
.
put
(
activity
.
getRelationId
(),
activity
);
}
// 组装活动条件
for
(
TpPlanActivityVo
activityVo
:
activityVos
)
{
TpPlanActivityConditionVo
activityConditionVo
=
activityVo
.
getCondition
();
buildTpPlanActivityCondition
(
relationActivityMap
,
relationActivityMap
.
get
(
activityVo
.
getRelationId
()),
activityConditionVo
,
activityConditionPres
,
activityConditionPosts
);
}
// 组装学习计划完成条件之一:指定的完成活动集合不为空
if
(
null
!=
planConditionVo
)
{
if
(!
CollectionUtils
.
isEmpty
(
planConditionVo
.
getPostActivityRelationIds
()))
{
for
(
Long
relationId
:
planConditionVo
.
getPostActivityRelationIds
())
{
TpPlanConditionPost
conditionPost
=
new
TpPlanConditionPost
();
conditionPost
.
setId
(
idGenerator
.
generate
());
conditionPost
.
setDeleted
(
ProjectConstant
.
DELETED_NO
);
conditionPost
.
setTpPlanId
(
tpPlan
.
getId
());
conditionPost
.
setType
(
ProjectConstant
.
TP_PLAN_CONDITION_POST_ACTIVITY_ID
);
conditionPost
.
setTpPlanActivityId
(
relationActivityMap
.
get
(
relationId
).
getId
());
conditionPost
.
setTpPlanActivityRelationId
(
relationId
);
conditionPost
.
setTrainingProjectId
(
tpPlan
.
getTrainingProjectId
());
planConditionPosts
.
add
(
conditionPost
);
}
}
// 组装学习计划完成条件之:设置的完成学习活动数不为空
if
(
null
!=
planConditionVo
.
getPostActivityNum
()
&&
planConditionVo
.
getPostActivityNum
()
>
0
)
{
TpPlanConditionPost
conditionPost
=
new
TpPlanConditionPost
();
conditionPost
.
setId
(
idGenerator
.
generate
());
conditionPost
.
setDeleted
(
ProjectConstant
.
DELETED_NO
);
conditionPost
.
setTpPlanId
(
tpPlan
.
getId
());
conditionPost
.
setType
(
ProjectConstant
.
TP_PLAN_CONDITION_POST_ACTIVITY_NUM
);
conditionPost
.
setNum
(
planConditionVo
.
getPostActivityNum
());
conditionPost
.
setTrainingProjectId
(
tpPlan
.
getTrainingProjectId
());
planConditionPosts
.
add
(
conditionPost
);
}
}
private
TpPlanActivity
buildTpPlanActivity
(
TpPlanActivityVo
activityVo
,
RequestContext
context
,
Date
date
,
TpPlan
tpPlan
,
int
sort
)
{
TpPlanActivity
activity
=
new
TpPlanActivity
();
activity
.
setCompanyId
(
context
.
getCompanyId
());
activity
.
setOrgId
(
context
.
getOrgId
()
==
null
?
new
Long
(
0
)
:
context
.
getOrgId
());
activity
.
setSiteId
(
context
.
getSiteId
());
activity
.
setCreateById
(
context
.
getAccountId
());
activity
.
setCreateByName
(
context
.
getAccountName
());
activity
.
setCreateTime
(
date
);
activity
.
setId
(
idGenerator
.
generate
());
activity
.
setDeleted
(
ProjectConstant
.
DELETED_NO
);
activity
.
setName
(
activityVo
.
getName
());
activity
.
setAddress
(
activityVo
.
getAddress
());
// 如果是外部链接,使用本身的id
if
(
activityVo
.
getType
().
equals
(
TpActivityType
.
TYPE_LINK
))
{
activity
.
setRelationId
(
activity
.
getId
());
}
else
{
activity
.
setRelationId
(
activityVo
.
getRelationId
());
}
return
list
;
activity
.
setTpPlanId
(
tpPlan
.
getId
());
activity
.
setTrainingProjectId
(
tpPlan
.
getTrainingProjectId
());
activity
.
setType
(
activityVo
.
getType
());
activity
.
setSort
(++
sort
);
return
activity
;
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment