|
|
@@ -8,6 +8,7 @@ import com.fs.common.exception.base.BaseException;
|
|
|
import com.fs.common.utils.PubFun;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.common.utils.date.DateUtil;
|
|
|
+import com.fs.course.config.CourseConfig;
|
|
|
import com.fs.course.domain.FsCourseWatchLog;
|
|
|
import com.fs.course.mapper.FsCourseWatchLogMapper;
|
|
|
import com.fs.course.param.FsCourseLinkCreateParam;
|
|
|
@@ -16,18 +17,17 @@ import com.fs.crm.domain.CrmMsg;
|
|
|
import com.fs.crm.mapper.CrmMsgMapper;
|
|
|
import com.fs.qw.domain.QwExternalContact;
|
|
|
import com.fs.qw.domain.QwGroupChat;
|
|
|
+import com.fs.qw.domain.QwGroupChatUser;
|
|
|
import com.fs.qw.domain.QwUser;
|
|
|
import com.fs.qw.mapper.QwExternalContactMapper;
|
|
|
+import com.fs.qw.mapper.QwGroupChatMapper;
|
|
|
+import com.fs.qw.mapper.QwGroupChatUserMapper;
|
|
|
import com.fs.qw.mapper.QwUserMapper;
|
|
|
import com.fs.qw.param.SopUserLogsVO;
|
|
|
import com.fs.qw.service.IQwGroupChatService;
|
|
|
import com.fs.qw.service.IQwUserService;
|
|
|
import com.fs.qw.vo.*;
|
|
|
-import com.fs.qwApi.service.QwApiService;
|
|
|
-import com.fs.sop.domain.QwSop;
|
|
|
-import com.fs.sop.domain.QwSopLogs;
|
|
|
-import com.fs.sop.domain.SopUserLogs;
|
|
|
-import com.fs.sop.domain.SopUserLogsInfo;
|
|
|
+import com.fs.sop.domain.*;
|
|
|
import com.fs.sop.mapper.QwSopMapper;
|
|
|
import com.fs.sop.mapper.SopUserLogsInfoMapper;
|
|
|
import com.fs.sop.mapper.SopUserLogsMapper;
|
|
|
@@ -35,9 +35,7 @@ import com.fs.sop.params.QwRatingConfig;
|
|
|
import com.fs.sop.params.SopUserLogsList;
|
|
|
import com.fs.sop.params.SopUserLogsParam;
|
|
|
import com.fs.sop.params.SopUserLogsParamByDate;
|
|
|
-import com.fs.sop.service.IQwSopLogsService;
|
|
|
-import com.fs.sop.service.IQwSopTempDayService;
|
|
|
-import com.fs.sop.service.ISopUserLogsService;
|
|
|
+import com.fs.sop.service.*;
|
|
|
import com.fs.sop.vo.QwRatingVO;
|
|
|
import com.fs.sop.vo.ReplaceUserDto;
|
|
|
import com.fs.sop.vo.SopUserLogsInfoVo;
|
|
|
@@ -69,7 +67,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
-public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
+public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(SopUserLogsServiceImpl.class);
|
|
|
|
|
|
@@ -85,7 +83,7 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
@Autowired
|
|
|
private QwSopMapper sopMapper;
|
|
|
@Autowired
|
|
|
- private QwApiService qwApiService;
|
|
|
+ private IFsCourseLinkService linkService;
|
|
|
|
|
|
@Autowired
|
|
|
private RedisCache redisCache;
|
|
|
@@ -99,6 +97,17 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
@Autowired
|
|
|
private IQwSopTempDayService qwSopTempDayService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SopUserLogsInfoServiceImpl sopUserLogsInfoService;
|
|
|
+ @Autowired
|
|
|
+ private IQwSopTempService sopTempService;
|
|
|
+ @Autowired
|
|
|
+ private IQwSopTempRulesService qwSopTempRulesService;
|
|
|
+ @Autowired
|
|
|
+ private QwGroupChatUserMapper qwGroupChatUserMapper;
|
|
|
+ @Autowired
|
|
|
+ private QwGroupChatMapper qwGroupChatMapper;
|
|
|
+
|
|
|
|
|
|
@Autowired
|
|
|
private ISysConfigService configService;
|
|
|
@@ -143,7 +152,7 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
// return sopUserLogsMapper.updateSopUserLogsDistinctByList(userLogsList);
|
|
|
// }
|
|
|
|
|
|
-// @Override
|
|
|
+ // @Override
|
|
|
// public int updateSopUserLogsDistinctByList(SopUserLogsArray userLogsArray) {
|
|
|
// return sopUserLogsMapper.updateSopUserLogsDistinctByList(userLogsArray);
|
|
|
// }
|
|
|
@@ -152,6 +161,57 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
sopUserLogsMapper.replaceUser(vo);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public R getShortLink(String id, String sopId, String appId) {
|
|
|
+ QwSop qwSop = sopMapper.selectQwSopById(sopId);
|
|
|
+ QwSopTemp qwSopTemp = sopTempService.selectQwSopTempById(qwSop.getTempId());
|
|
|
+ SopUserLogs sopUserLogs = sopUserLogsMapper.selectSopUserLogsById(id);
|
|
|
+ String[] userKey = sopUserLogs.getUserId().split("\\|");
|
|
|
+ String qwUserId = userKey[0].trim();
|
|
|
+ QwUser qwUser = qwUserMapper.selectById(qwUserId);
|
|
|
+ Optional<QwSopTempDay> dayOptional = qwSopTemp.getList().stream().filter(e -> Objects.equals(e.getDayNum(), sopUserLogs.getCountDays())).findFirst();
|
|
|
+ if (dayOptional.isPresent()) {
|
|
|
+ List<QwSopTempRules> rulesList = qwSopTempRulesService.selectListByDayId(dayOptional.get().getId());
|
|
|
+ Optional<QwSopTempRules> rulesOptional = rulesList.stream().filter(r -> r.getCourseId() != null).findFirst();
|
|
|
+ if (rulesOptional.isPresent()) {
|
|
|
+ QwSopTempRules rules = rulesOptional.get();
|
|
|
+ QwGroupChat groupChat = qwGroupChatMapper.selectQwGroupChatByChatId(sopUserLogs.getChatId());
|
|
|
+ List<QwGroupChatUser> groupUserList = qwGroupChatUserMapper.selectQwGroupChatUserByChatIds(new String[]{sopUserLogs.getChatId()});
|
|
|
+ List<String> groupChatUserIds = PubFun.listToNewList(groupUserList, QwGroupChatUser::getUserId);
|
|
|
+ if (!groupChatUserIds.isEmpty()) {
|
|
|
+ List<GroupUserExternalVo> userList = qwExternalContactMapper.selectByGroupUser(groupChatUserIds);
|
|
|
+ Map<String, List<GroupUserExternalVo>> userMap = PubFun.listToMapByGroupList(userList, GroupUserExternalVo::getExternalUserId);
|
|
|
+ groupUserList.forEach(e -> {
|
|
|
+ e.setUserList(userMap.getOrDefault(e.getUserId(), Collections.emptyList()));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ groupUserList.stream().filter(e -> e.getUserList() != null && !e.getUserList().isEmpty()).forEach(e -> {
|
|
|
+ Map<String, GroupUserExternalVo> userMap = PubFun.listToMapByGroupObject(e.getUserList(), GroupUserExternalVo::getUserId);
|
|
|
+ GroupUserExternalVo vo = userMap.get(groupChat.getOwner());
|
|
|
+ if (vo != null && vo.getId() != null) {
|
|
|
+ sopUserLogsInfoService.addWatchLogIfNeeded(sopId, rules.getVideoId().intValue(), rules.getCourseId().intValue(), vo.getFsUserId(), qwUser.getId().toString(), qwUser.getCompanyUserId().toString(), qwUser.getCompanyId().toString(), vo.getId(), sopUserLogs.getStartTime(), new Date());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("群聊创建看课记录失败!", e);
|
|
|
+ }
|
|
|
+ QwSopCourseFinishTempSetting.Setting st = new QwSopCourseFinishTempSetting.Setting();
|
|
|
+ st.setExpiresDays(1);
|
|
|
+ String json = configService.selectConfigByKey("course.config");
|
|
|
+ CourseConfig config = JSON.parseObject(json, CourseConfig.class);
|
|
|
+ String linkByMiniApp = sopUserLogsInfoService.createLinkByMiniApp(st, sopUserLogs.getCorpId(), new Date(), rules.getCourseId().intValue(), rules.getVideoId().intValue(),
|
|
|
+ qwUser.getId(), qwUser.getCompanyUserId().toString(), qwUser.getCompanyId().toString(), null, config, sopUserLogs.getChatId());
|
|
|
+ if(StringUtils.isNotEmpty(linkByMiniApp)){
|
|
|
+ linkByMiniApp = linkByMiniApp.replaceAll(".html", "");
|
|
|
+ }
|
|
|
+ String link = linkService.getGotoWxAppLink(linkByMiniApp, appId);
|
|
|
+ return R.ok().put("urlLink", link);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.error("系统错误❌");
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public int deleteSopUserLogsBySopId(String sopId) {
|
|
|
return sopUserLogsMapper.deleteSopUserLogsBySopId(sopId);
|
|
|
@@ -181,20 +241,20 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
//如果为空,则任务删除了 ,则全部营期删除
|
|
|
if (ruleTimeVO == null) {
|
|
|
sopUserLogsMapper.deleteSopUserLogsBySopId(key);
|
|
|
- }else if (ruleTimeVO.getStatus()==0){
|
|
|
+ } else if (ruleTimeVO.getStatus() == 0) {
|
|
|
SopUserLogs sopUserLogs = new SopUserLogs();
|
|
|
sopUserLogs.setSopId(key);
|
|
|
sopUserLogs.setStatus(2);
|
|
|
sopUserLogsMapper.updateSopUserLogsByStatus(sopUserLogs);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
|
|
|
//如果模板停用了,也改这个营期记录
|
|
|
- if (ruleTimeVO.getTempStatus().equals("0")){
|
|
|
+ if (ruleTimeVO.getTempStatus().equals("0")) {
|
|
|
SopUserLogs sopUserLogs = new SopUserLogs();
|
|
|
sopUserLogs.setSopId(key);
|
|
|
sopUserLogs.setStatus(2);
|
|
|
sopUserLogsMapper.updateSopUserLogsByStatus(sopUserLogs);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
|
|
|
// 分组的 key
|
|
|
List<SopUserLogsVo> userLogsVos = entry.getValue(); // 分组对应的日志列表
|
|
|
@@ -202,24 +262,24 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
// 处理日志数据
|
|
|
userLogsVos.forEach(log -> {
|
|
|
|
|
|
- // 获取开始时间和间隔天数
|
|
|
- Date startTime = null; // 假设 startTime 是 java.util.Date 类型
|
|
|
- try {
|
|
|
- startTime = formatter.parse(log.getStartTime());
|
|
|
- } catch (ParseException e) {
|
|
|
- logger.error("selectSopUserLogsListByTime解析开始时间失败: {}", e.getMessage());
|
|
|
- }
|
|
|
+ // 获取开始时间和间隔天数
|
|
|
+ Date startTime = null; // 假设 startTime 是 java.util.Date 类型
|
|
|
+ try {
|
|
|
+ startTime = formatter.parse(log.getStartTime());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ logger.error("selectSopUserLogsListByTime解析开始时间失败: {}", e.getMessage());
|
|
|
+ }
|
|
|
|
|
|
- Integer tempGap = ruleTimeVO.getTempGap();
|
|
|
+ Integer tempGap = ruleTimeVO.getTempGap();
|
|
|
|
|
|
- // 将 startTime 转换为 LocalDate
|
|
|
- LocalDate startLocalDate = startTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
+ // 将 startTime 转换为 LocalDate
|
|
|
+ LocalDate startLocalDate = startTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
|
|
|
- // 计算当前时间距离开始时间的天数差
|
|
|
- long daysBetween = ChronoUnit.DAYS.between(startLocalDate, currentDate);
|
|
|
+ // 计算当前时间距离开始时间的天数差
|
|
|
+ long daysBetween = ChronoUnit.DAYS.between(startLocalDate, currentDate);
|
|
|
|
|
|
- // TODO 修改
|
|
|
- // 获取 QwSopTempSetting 内容
|
|
|
+ // TODO 修改
|
|
|
+ // 获取 QwSopTempSetting 内容
|
|
|
// List<QwSopTempSetting> qwSopTempSettings = JSON.parseArray(ruleTimeVO.getTempSetting(), QwSopTempSetting.class);
|
|
|
//
|
|
|
// // 计算当前天数属于第几天,第一天就是 startLocalDate,后续递增
|
|
|
@@ -293,9 +353,6 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
// 遍历分组数据
|
|
|
@@ -454,7 +511,8 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
- private void insertSopUserLogs(List<SopUserLogsInfo> list,SopUserLogsVo log,Date sendTime,QwSopRuleTimeVO ruleTimeVO,QwSopTempSetting.Content element) {
|
|
|
+ private void insertSopUserLogs(List<SopUserLogsInfo> list, SopUserLogsVo log, Date sendTime, QwSopRuleTimeVO
|
|
|
+ ruleTimeVO, QwSopTempSetting.Content element) {
|
|
|
|
|
|
QwSopLogs sopLogs = new QwSopLogs();
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
@@ -574,7 +632,7 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
|
|
|
|
|
|
//如果要推短链-则必须要绑定了小程序-才会有观看记录
|
|
|
- if (sopLogs.getFsUserId() != null && sopLogs.getFsUserId()!= 0 ) {
|
|
|
+ if (sopLogs.getFsUserId() != null && sopLogs.getFsUserId() != 0) {
|
|
|
|
|
|
FsCourseWatchLog watchLog = new FsCourseWatchLog();
|
|
|
watchLog.setUserId(sopLogs.getFsUserId());
|
|
|
@@ -643,9 +701,9 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
return resultSopUserLogsList(list);
|
|
|
}
|
|
|
|
|
|
- private List<SopUserLogsVO> resultSopUserLogsList( List<SopUserLogsVO> list){
|
|
|
+ private List<SopUserLogsVO> resultSopUserLogsList(List<SopUserLogsVO> list) {
|
|
|
List<String> chatIdList = PubFun.listToNewList(list, SopUserLogsVO::getChatId);
|
|
|
- if(!chatIdList.isEmpty()){
|
|
|
+ if (!chatIdList.isEmpty()) {
|
|
|
List<QwGroupChat> qwGroupChatList = qwGroupChatService.selectQwGroupChatByChatIds(chatIdList.toArray(new String[0]));
|
|
|
Map<String, QwGroupChat> groupChatMap = PubFun.listToMapByGroupObject(qwGroupChatList, QwGroupChat::getChatId);
|
|
|
list.stream().filter(e -> groupChatMap.containsKey(e.getChatId())).forEach(e -> {
|
|
|
@@ -703,9 +761,9 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
// 获取名称
|
|
|
String names = voList.stream().peek(v -> {
|
|
|
// 标识那些是发送了,发送了到时候要更新状态不会查出数据进入此方法
|
|
|
- if(type == 0){
|
|
|
+ if (type == 0) {
|
|
|
v.setMinIsSend(true);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
v.setMaxIsSend(true);
|
|
|
}
|
|
|
}).map(SopUserLogsInfoVo::getExternalUserName).collect(Collectors.joining(","));
|
|
|
@@ -726,11 +784,11 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
// 打转换消息
|
|
|
List<CrmMsg> maxList = toFun.apply(list, 1);
|
|
|
// 不为空添加
|
|
|
- if(!minList.isEmpty()){
|
|
|
+ if (!minList.isEmpty()) {
|
|
|
msgList.addAll(minList);
|
|
|
}
|
|
|
// 不为空添加
|
|
|
- if(!maxList.isEmpty()){
|
|
|
+ if (!maxList.isEmpty()) {
|
|
|
msgList.addAll(maxList);
|
|
|
}
|
|
|
msgList.forEach(crmMsgMapper::insertCrmMsg);
|
|
|
@@ -756,8 +814,7 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
* @return sopUserLogs
|
|
|
*/
|
|
|
@Override
|
|
|
- public SopUserLogs selectSopUserLogsById(String id)
|
|
|
- {
|
|
|
+ public SopUserLogs selectSopUserLogsById(String id) {
|
|
|
return sopUserLogsMapper.selectSopUserLogsById(id);
|
|
|
}
|
|
|
|
|
|
@@ -768,14 +825,14 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
if (qwUser != null) {
|
|
|
Long companyUserId = qwUser.getCompanyUserId();
|
|
|
Long companyId = qwUser.getCompanyId();
|
|
|
- if (companyUserId==null) {
|
|
|
+ if (companyUserId == null) {
|
|
|
return R.error("用户未绑定销售,请先绑定");
|
|
|
}
|
|
|
- if (companyId==null) {
|
|
|
+ if (companyId == null) {
|
|
|
return R.error("用户未绑定销售公司,请先绑定");
|
|
|
}
|
|
|
|
|
|
- param.setUserId(qwUser.getId()+"|"+companyUserId+"|"+companyId);
|
|
|
+ param.setUserId(qwUser.getId() + "|" + companyUserId + "|" + companyId);
|
|
|
sopUserLogsMapper.updateSopUserLogsByCompanyInfo(param);
|
|
|
}
|
|
|
|
|
|
@@ -789,26 +846,26 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
|
|
|
Map<String, QwUser> qwUserMap = sopUserLogs.stream()
|
|
|
.collect(Collectors.toMap(
|
|
|
- item -> item.getCorpId() + "|" + item.getQwUserId()+"|"+item.getId(),
|
|
|
+ item -> item.getCorpId() + "|" + item.getQwUserId() + "|" + item.getId(),
|
|
|
item -> Optional.ofNullable(qwUserMapper.selectQwUserByCorpIdAndUserId(item.getCorpId(), item.getQwUserId()))
|
|
|
.orElse(new QwUser())
|
|
|
));
|
|
|
List<String> errorMessages = new ArrayList<>();
|
|
|
|
|
|
sopUserLogs.forEach(item -> {
|
|
|
- String key = item.getCorpId() + "|" + item.getQwUserId()+"|"+item.getId();
|
|
|
+ String key = item.getCorpId() + "|" + item.getQwUserId() + "|" + item.getId();
|
|
|
QwUser qwUser = qwUserMap.get(key);
|
|
|
|
|
|
- if (qwUser != null && qwUser.getId()!=null) {
|
|
|
+ if (qwUser != null && qwUser.getId() != null) {
|
|
|
Long companyUserId = qwUser.getCompanyUserId();
|
|
|
Long companyId = qwUser.getCompanyId();
|
|
|
|
|
|
if (companyUserId == null) {
|
|
|
- errorMessages.add("用户 " + item.getQwUserId() +"|"+item.getCorpId()+ " 未绑定销售,请先绑定");
|
|
|
+ errorMessages.add("用户 " + item.getQwUserId() + "|" + item.getCorpId() + " 未绑定销售,请先绑定");
|
|
|
return;
|
|
|
}
|
|
|
if (companyId == null) {
|
|
|
- errorMessages.add("用户 " + item.getQwUserId()+"|" +item.getCorpId()+ " 未绑定销售公司,请先绑定");
|
|
|
+ errorMessages.add("用户 " + item.getQwUserId() + "|" + item.getCorpId() + " 未绑定销售公司,请先绑定");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -826,10 +883,10 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
});
|
|
|
|
|
|
if (!errorMessages.isEmpty()) {
|
|
|
- logger.error("定时处理 营期异常的数据 出错:"+String.join(";", errorMessages));
|
|
|
+ logger.error("定时处理 营期异常的数据 出错:" + String.join(";", errorMessages));
|
|
|
}
|
|
|
- }catch (Exception e){
|
|
|
- logger.error("定时处理 营期异常的数据 出错2:"+e.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("定时处理 营期异常的数据 出错2:" + e.getMessage());
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -842,21 +899,21 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
QwRatingConfig config = JSON.parseObject(json, QwRatingConfig.class);
|
|
|
|
|
|
List<SopUserLogs> sopUserLogs = sopUserLogsMapper.meetsTheRatingByUserInfoBySopId(sopId);
|
|
|
- sopUserLogs.stream().forEach(item->{
|
|
|
+ sopUserLogs.stream().forEach(item -> {
|
|
|
|
|
|
Integer countDays = item.getCountDays();
|
|
|
|
|
|
- Integer sopTemIdNum=redisCache.getCacheObject("sop-tempId:"+item.getSopTempId());
|
|
|
+ Integer sopTemIdNum = redisCache.getCacheObject("sop-tempId:" + item.getSopTempId());
|
|
|
|
|
|
- if (sopTemIdNum==null){
|
|
|
- sopTemIdNum= qwSopTempDayService.getDayNumByIdLimitOne(item.getSopTempId());
|
|
|
- redisCache.setCacheObject("sop-tempId:"+item.getSopTempId(),sopTemIdNum,3, TimeUnit.HOURS);
|
|
|
- }
|
|
|
+ if (sopTemIdNum == null) {
|
|
|
+ sopTemIdNum = qwSopTempDayService.getDayNumByIdLimitOne(item.getSopTempId());
|
|
|
+ redisCache.setCacheObject("sop-tempId:" + item.getSopTempId(), sopTemIdNum, 3, TimeUnit.HOURS);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
//如果当前营期的伦次中,模板天数不足。则不评级
|
|
|
- if (sopTemIdNum< countDays){
|
|
|
- logger.info("当前营期的伦次中,模板天数不足。不评级:"+item.getSopTempId()+"|sopId:"+item.getSopId());
|
|
|
+ if (sopTemIdNum < countDays) {
|
|
|
+ logger.info("当前营期的伦次中,模板天数不足。不评级:" + item.getSopTempId() + "|sopId:" + item.getSopId());
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -864,7 +921,7 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
List<SopUserLogsInfo> sopUserLogsInfosList = sopUserLogsInfoMapper.selectSopUserLogsInfoListBySopId(item.getSopId(), item.getId());
|
|
|
if (sopUserLogsInfosList != null && !sopUserLogsInfosList.isEmpty()) {
|
|
|
|
|
|
- List<QwExternalContact> batchQwExternalContact=new ArrayList<>();
|
|
|
+ List<QwExternalContact> batchQwExternalContact = new ArrayList<>();
|
|
|
|
|
|
sopUserLogsInfosList.forEach(logsInfo -> {
|
|
|
try {
|
|
|
@@ -875,8 +932,8 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
.selectFsCourseWatchLogByExtIdRating(externalId, config.getLevelDay());
|
|
|
|
|
|
if (ratingVOS.isEmpty()) {
|
|
|
- log.error("没有看课记录不评级。则不评级:"+externalId);
|
|
|
- return ;
|
|
|
+ log.error("没有看课记录不评级。则不评级:" + externalId);
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
int scoreLevel = getScoreLevel(ratingVOS, config);
|
|
|
@@ -894,17 +951,15 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
batchQwExternalContact.add(externalContact);
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
logger.error("计算用户积分异常,用户id:{}", logsInfo, e);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
batchUpdateQwExternalContact(batchQwExternalContact);
|
|
|
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
logger.error("当前营期没有客户-sopId:{},营期id:{}", item.getSopId(), item.getId());
|
|
|
}
|
|
|
});
|
|
|
@@ -915,10 +970,10 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
|
|
|
@Override
|
|
|
public R updateLogDate(UpdateSopUserLogDateVo vo) {
|
|
|
- if(vo.getDate() == null){
|
|
|
+ if (vo.getDate() == null) {
|
|
|
throw new BaseException("修改时间不能为空");
|
|
|
}
|
|
|
- if(vo.getIds() == null || vo.getIds().isEmpty()){
|
|
|
+ if (vo.getIds() == null || vo.getIds().isEmpty()) {
|
|
|
throw new BaseException("营期ID不能为空");
|
|
|
}
|
|
|
// sopUserLogsMapper.updateSopuserLogsDateById(vo);
|
|
|
@@ -948,16 +1003,17 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
|
|
|
// 记录剔除的重复ID
|
|
|
if (!duplicateIds.isEmpty()) {
|
|
|
- log.error("根据sopId、qwUserId、corpId、startTime组合检查,剔除重复ID: {},时间:{}", duplicateIds,targetDateStr);
|
|
|
+ log.error("根据sopId、qwUserId、corpId、startTime组合检查,剔除重复ID: {},时间:{}", duplicateIds, targetDateStr);
|
|
|
}
|
|
|
|
|
|
- return R.ok().put("data",duplicateIds);
|
|
|
+ return R.ok().put("data", duplicateIds);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 检查是否存在相同组合的数据
|
|
|
*/
|
|
|
- private boolean checkDuplicateCombination(SopUserLogs currentLog, List<SopUserLogs> allLogs, String targetDate) {
|
|
|
+ private boolean checkDuplicateCombination(SopUserLogs currentLog, List<SopUserLogs> allLogs, String
|
|
|
+ targetDate) {
|
|
|
for (SopUserLogs log : allLogs) {
|
|
|
// 跳过自身比较
|
|
|
if (log.getId().equals(currentLog.getId())) {
|
|
|
@@ -1003,7 +1059,7 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
sopUserLogs.setStartTime(qwSop.getStartTime());
|
|
|
sopUserLogs.setStatus(1);
|
|
|
QwUserVO qwUserVO = qwUserMap.get(groupChat.getOwner());
|
|
|
- if(qwUserVO != null){
|
|
|
+ if (qwUserVO != null) {
|
|
|
sopUserLogs.setUserId(qwUserVO.getId() + "|" + qwUserVO.getCompanyUserId() + "|" + qwUserVO.getCompanyId());
|
|
|
}
|
|
|
return sopUserLogs;
|
|
|
@@ -1013,7 +1069,7 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
|
|
|
@Override
|
|
|
public List<SopUserLogs> meetsTherestoreByIsDaysNotStudy(int offset, int pageSize, Integer notStudyDays) {
|
|
|
- return sopUserLogsMapper.meetsTherestoreByIsDaysNotStudy(offset,pageSize,notStudyDays);
|
|
|
+ return sopUserLogsMapper.meetsTherestoreByIsDaysNotStudy(offset, pageSize, notStudyDays);
|
|
|
}
|
|
|
|
|
|
//批量更新
|
|
|
@@ -1030,7 +1086,7 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
// 直接使用批次数据进行批量更新,不需要额外的 List
|
|
|
try {
|
|
|
qwExternalContactMapper.batchUpdateQwExternalContact(batchList);
|
|
|
- logger.info("成功更新了评级批次数据,起始索引为:{},数量:{} ", i,batchList.size());
|
|
|
+ logger.info("成功更新了评级批次数据,起始索引为:{},数量:{} ", i, batchList.size());
|
|
|
} catch (Exception e) {
|
|
|
// 记录异常日志,方便后续排查问题
|
|
|
logger.error("批量更新数据时发生异常,处理的批次起始索引为: " + i, e);
|
|
|
@@ -1041,7 +1097,7 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
//评级
|
|
|
public int getScoreLevel(List<QwRatingVO> qwRatingVOS, QwRatingConfig config) {
|
|
|
|
|
|
- AtomicDouble watchCount= new AtomicDouble();
|
|
|
+ AtomicDouble watchCount = new AtomicDouble();
|
|
|
|
|
|
qwRatingVOS.forEach(vo -> {
|
|
|
// 计算 watchDuration 除以 allDuration,并保留2位小数,四舍五入
|
|
|
@@ -1080,20 +1136,21 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
throw new IllegalArgumentException("分数不在任何等级范围内: " + score);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
//升降等级
|
|
|
- public int getLevelUpFall(int scoreLevel,int levelUpFall){
|
|
|
+ public int getLevelUpFall(int scoreLevel, int levelUpFall) {
|
|
|
|
|
|
if (scoreLevel > levelUpFall) {
|
|
|
- return 1;//升级
|
|
|
- }else if (scoreLevel < levelUpFall) {
|
|
|
- return 2;//降级
|
|
|
- }else {
|
|
|
- return 3;//不变
|
|
|
+ return 1;//升级
|
|
|
+ } else if (scoreLevel < levelUpFall) {
|
|
|
+ return 2;//降级
|
|
|
+ } else {
|
|
|
+ return 3;//不变
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//计算最晚看课时间
|
|
|
- public int getLatestTime(List<QwRatingVO> qwRatingVOS){
|
|
|
+ public int getLatestTime(List<QwRatingVO> qwRatingVOS) {
|
|
|
|
|
|
// 定义日期时间格式
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
@@ -1102,21 +1159,21 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
// 用于存储提取出的时分
|
|
|
List<String> timeOnlyList = new ArrayList<>();
|
|
|
|
|
|
- qwRatingVOS.forEach(vos->{
|
|
|
+ qwRatingVOS.forEach(vos -> {
|
|
|
|
|
|
String finishTime = vos.getFinishTime();
|
|
|
|
|
|
- if (!StringUtil.strIsNullOrEmpty(finishTime)){
|
|
|
+ if (!StringUtil.strIsNullOrEmpty(finishTime)) {
|
|
|
LocalTime localTime = LocalTime.parse(finishTime, formatter);
|
|
|
String formattedTime = localTime.format(outputFormatter);
|
|
|
timeOnlyList.add(formattedTime);
|
|
|
}
|
|
|
|
|
|
});
|
|
|
- String latestTime=null;
|
|
|
- if (!timeOnlyList.isEmpty()){
|
|
|
- latestTime = Collections.max(timeOnlyList);
|
|
|
- }else {
|
|
|
+ String latestTime = null;
|
|
|
+ if (!timeOnlyList.isEmpty()) {
|
|
|
+ latestTime = Collections.max(timeOnlyList);
|
|
|
+ } else {
|
|
|
latestTime = "0";
|
|
|
}
|
|
|
|
|
|
@@ -1125,5 +1182,4 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
}
|