|
@@ -24,8 +24,7 @@ import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
|
|
|
-import static org.dromara.common.core.constant.Constants.READ_TRAIN;
|
|
|
-import static org.dromara.common.core.constant.Constants.READ_TRAIN_TIME;
|
|
|
+import static org.dromara.common.core.constant.Constants.*;
|
|
|
import static org.dromara.common.satoken.utils.LoginHelper.getLoginUser;
|
|
|
import static org.dromara.common.satoken.utils.LoginHelper.getUserId;
|
|
|
|
|
@@ -48,7 +47,7 @@ public class StaffTrainManualServiceImpl implements IStaffTrainManualService {
|
|
|
* @return 员工培训手册
|
|
|
*/
|
|
|
@Override
|
|
|
- public StaffTrainManualVo queryById(Long manualId){
|
|
|
+ public StaffTrainManualVo queryById(Long manualId) {
|
|
|
//获取该培训手册对象阅读人员的value值
|
|
|
List<String> valueList = RedisUtils.getCacheList(READ_TRAIN + manualId);
|
|
|
//获取当前登录人的员工信息
|
|
@@ -71,12 +70,12 @@ public class StaffTrainManualServiceImpl implements IStaffTrainManualService {
|
|
|
//新增阅读时间
|
|
|
//key = read_train_time:manualId:userId
|
|
|
RedisUtils.setCacheObject(READ_TRAIN_TIME + manualId + ":" + userId, DateUtils.getTime());
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
//更新阅读时间
|
|
|
//key = read_train_time:manualId:userId
|
|
|
RedisUtils.setCacheObject(READ_TRAIN_TIME + manualId + ":" + userId, DateUtils.getTime());
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
//新增第一个阅读人员
|
|
|
List<String> stringList = new ArrayList<>();
|
|
|
stringList.add(value);
|
|
@@ -86,7 +85,7 @@ public class StaffTrainManualServiceImpl implements IStaffTrainManualService {
|
|
|
}
|
|
|
StaffTrainManual staffTrainManual = baseMapper.selectById(manualId);
|
|
|
Long viewCount = staffTrainManual.getViewCount();
|
|
|
- staffTrainManual.setViewCount(viewCount+1);
|
|
|
+ staffTrainManual.setViewCount(viewCount + 1);
|
|
|
baseMapper.updateById(staffTrainManual);
|
|
|
return MapstructUtils.convert(staffTrainManual, StaffTrainManualVo.class);
|
|
|
}
|
|
@@ -102,6 +101,19 @@ public class StaffTrainManualServiceImpl implements IStaffTrainManualService {
|
|
|
public TableDataInfo<StaffTrainManualVo> queryPageList(StaffTrainManualBo bo, PageQuery pageQuery) {
|
|
|
LambdaQueryWrapper<StaffTrainManual> lqw = buildQueryWrapper(bo);
|
|
|
Page<StaffTrainManualVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
+ List<StaffTrainManualVo> records = result.getRecords();
|
|
|
+ Long userId = getUserId();
|
|
|
+ if (records != null) {
|
|
|
+ for (StaffTrainManualVo record : records) {
|
|
|
+ record.setProgress("0");
|
|
|
+ Long manualId = record.getManualId();
|
|
|
+ String key = MANUAL_PROGRESS_USER + manualId + "#" + userId;
|
|
|
+ Object progress= RedisUtils.getCacheObject(key);
|
|
|
+ if (progress != null) {
|
|
|
+ record.setProgress(progress.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return TableDataInfo.build(result);
|
|
|
}
|
|
|
|
|
@@ -166,10 +178,23 @@ public class StaffTrainManualServiceImpl implements IStaffTrainManualService {
|
|
|
return baseMapper.updateById(update) > 0;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 修改员工培训手册个人进度
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean putProgress(StaffTrainManualBo bo) {
|
|
|
+ Long manualId = bo.getManualId();
|
|
|
+ String progress = bo.getProgress();
|
|
|
+ Long userId = getUserId();
|
|
|
+ String key = MANUAL_PROGRESS_USER + manualId + "#" + userId;
|
|
|
+ RedisUtils.setCacheObject(key, progress);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 保存前的数据校验
|
|
|
*/
|
|
|
- private void validEntityBeforeSave(StaffTrainManual entity){
|
|
|
+ private void validEntityBeforeSave(StaffTrainManual entity) {
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
}
|
|
|
|
|
@@ -182,7 +207,7 @@ public class StaffTrainManualServiceImpl implements IStaffTrainManualService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
- if(isValid){
|
|
|
+ if (isValid) {
|
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
|
}
|
|
|
return baseMapper.deleteByIds(ids) > 0;
|
|
@@ -205,7 +230,7 @@ public class StaffTrainManualServiceImpl implements IStaffTrainManualService {
|
|
|
for (String value : valueList) {
|
|
|
String[] split = value.split(":");
|
|
|
//key = read_train:manualId:userId
|
|
|
- String readTime = RedisUtils.getCacheObject(READ_TRAIN_TIME + manualId + ":" + split[0]);
|
|
|
+ String readTime = RedisUtils.getCacheObject(READ_TRAIN_TIME + manualId + ":" + split[0]);
|
|
|
Map<String, String> map = new HashMap<>(2);
|
|
|
if (StringUtils.isBlank(author) && searchTime == null) {
|
|
|
map.put("name", split[1]);
|
|
@@ -259,7 +284,7 @@ public class StaffTrainManualServiceImpl implements IStaffTrainManualService {
|
|
|
resultList.add(map);
|
|
|
}
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
map.put("name", split[1]);
|
|
|
map.put("time", readTime);
|
|
|
resultList.add(map);
|