Commit 805ccd64 by 杨卫

Merge remote-tracking branch 'origin/v5.6.0' into v5.6.0

2 parents 127b07c5 34d82346
package cn.com.glsx.dj.strategy.dto;
import cn.com.glsx.dj.strategy.model.StrategyCourseRel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 策略-人员-课程 DTO
*/
@Data
public class StrategyStaffCourseRelDTO extends StrategyCourseRel {
@ApiModelProperty(notes = "学习记录")
private Object learningRecord;
@ApiModelProperty(notes = "课程详情")
private Object courseDetail;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.strategy.dto;
import cn.com.glsx.dj.strategy.model.LearningRecord;
import cn.com.glsx.dj.strategy.model.StrategyRecordingRel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 策略-人员-录音 DTO
*/
@Data
public class StrategyStaffRecordingRelDTO extends StrategyRecordingRel {
@ApiModelProperty(notes = "学习记录")
private LearningRecord learningRecord;
@ApiModelProperty(notes = "录音详情")
private Object recordingDetail;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.strategy.model;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import lombok.Data;
@Data
public class StrategyCourseLearnProcessDTO implements Serializable {
/**
* 课程id,dj_beisen_course.id
*/
@ApiModelProperty(notes = "课程ID")
private String courseId;
@ApiModelProperty(notes = "用户ID")
private String userId;
@ApiModelProperty(notes = "学习状态 10:未学习 20:未完成 30:待考核 40:未通过 50:已完成 60:待签署")
private Integer learnStatus;
@ApiModelProperty(notes = "学习成绩")
private BigDecimal totalScore;
}
\ No newline at end of file \ No newline at end of file
...@@ -111,4 +111,5 @@ public class StrategyStaffRel implements Serializable { ...@@ -111,4 +111,5 @@ public class StrategyStaffRel implements Serializable {
@Transient @Transient
@ApiModelProperty(notes = "完成时间(任务/课程完成的具体时间)") @ApiModelProperty(notes = "完成时间(任务/课程完成的具体时间)")
private Date completionTime; private Date completionTime;
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.strategy.mapper; package cn.com.glsx.dj.strategy.mapper;
import cn.com.glsx.dj.strategy.model.LearningRecord; import cn.com.glsx.dj.strategy.model.LearningRecord;
import cn.com.glsx.dj.strategy.model.StrategyCourseLearnProcessDTO;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -12,4 +13,6 @@ public interface LearningRecordMapper extends OreMapper<LearningRecord> { ...@@ -12,4 +13,6 @@ public interface LearningRecordMapper extends OreMapper<LearningRecord> {
LearningRecord selectByRecordIdAndUUid(@Param("recordingId") String recordingId, @Param("userUuid") String userUuid); LearningRecord selectByRecordIdAndUUid(@Param("recordingId") String recordingId, @Param("userUuid") String userUuid);
List<LearningRecord> queryLearningRecordList(@Param("recordingIds") List<Integer> recordingIds,@Param("userUuids") List<String> userUuids); List<LearningRecord> queryLearningRecordList(@Param("recordingIds") List<Integer> recordingIds,@Param("userUuids") List<String> userUuids);
List<StrategyCourseLearnProcessDTO> findCourseProcess(@Param("courseList") List<String> courseList, @Param("beisenUserList") List<Integer> beisenUserList);
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.strategy.mapper; package cn.com.glsx.dj.strategy.mapper;
import cn.com.glsx.dj.riskmanage.model.course.BeiSenCourse;
import cn.com.glsx.dj.riskmanage.model.course.BeiSenCourseStaff;
import cn.com.glsx.dj.strategy.model.StrategyCourseRel; import cn.com.glsx.dj.strategy.model.StrategyCourseRel;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.oreframework.datasource.mybatis.mapper.OreMapper; import org.oreframework.datasource.mybatis.mapper.OreMapper;
import java.util.List;
@Mapper @Mapper
public interface StrategyCourseRelMapper extends OreMapper<StrategyCourseRel> { public interface StrategyCourseRelMapper extends OreMapper<StrategyCourseRel> {
List<BeiSenCourseStaff> queryCourseLearnSituation(@Param("beisenUserId") Integer beisenUserId, @Param("courseIdList") List<String> courseIdList);
List<BeiSenCourse> queryCourseDetail(@Param("courseIdList") List<String> courseIdList);
} }
\ No newline at end of file \ No newline at end of file
...@@ -2,7 +2,9 @@ package cn.com.glsx.dj.strategy.mapper; ...@@ -2,7 +2,9 @@ package cn.com.glsx.dj.strategy.mapper;
import cn.com.glsx.dj.strategy.model.StrategyStaffRel; import cn.com.glsx.dj.strategy.model.StrategyStaffRel;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.oreframework.datasource.mybatis.mapper.OreMapper; import org.oreframework.datasource.mybatis.mapper.OreMapper;
@Mapper @Mapper
public interface StrategyStaffRelMapper extends OreMapper<StrategyStaffRel> { public interface StrategyStaffRelMapper extends OreMapper<StrategyStaffRel> {
StrategyStaffRel selectByStrategyIdAndStaffId(@Param("strategyId") Integer strategyId, @Param("userUuid") String userUuid);
} }
\ No newline at end of file \ No newline at end of file
...@@ -2,6 +2,7 @@ package cn.com.glsx.dj.strategy.service; ...@@ -2,6 +2,7 @@ package cn.com.glsx.dj.strategy.service;
import cn.com.glsx.dj.strategy.mapper.LearningRecordMapper; import cn.com.glsx.dj.strategy.mapper.LearningRecordMapper;
import cn.com.glsx.dj.strategy.model.LearningRecord; import cn.com.glsx.dj.strategy.model.LearningRecord;
import cn.com.glsx.dj.strategy.model.StrategyCourseLearnProcessDTO;
import cn.com.glsx.framework.core.exception.RpcServiceException; import cn.com.glsx.framework.core.exception.RpcServiceException;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -29,7 +30,7 @@ public class LearningRecordService { ...@@ -29,7 +30,7 @@ public class LearningRecordService {
* 插入或更新 * 插入或更新
* @param learningRecord * @param learningRecord
*/ */
@GlsxDistributeLockable(name = "'LearningRecordService_insertOrUpdate_' + #learningRecord.recordingId" + "'_' + #learningRecord.userUuid", @GlsxDistributeLockable(name = "'LearningRecordService_insertOrUpdate_' +#learningRecord.userUuid",
time = 5, timeUnit = TimeUnit.MINUTES, timeoutException = RpcServiceException.class) time = 5, timeUnit = TimeUnit.MINUTES, timeoutException = RpcServiceException.class)
public void insertOrUpdateLearningRecord(LearningRecord learningRecord) { public void insertOrUpdateLearningRecord(LearningRecord learningRecord) {
String recordingId = learningRecord.getRecordingId(); String recordingId = learningRecord.getRecordingId();
...@@ -56,4 +57,8 @@ public class LearningRecordService { ...@@ -56,4 +57,8 @@ public class LearningRecordService {
public List<LearningRecord> queryLearningRecordList(List<Integer> recordingIds, List<String> userUuids) { public List<LearningRecord> queryLearningRecordList(List<Integer> recordingIds, List<String> userUuids) {
return learningRecordMapper.queryLearningRecordList(recordingIds, userUuids); return learningRecordMapper.queryLearningRecordList(recordingIds, userUuids);
} }
public List<StrategyCourseLearnProcessDTO> findCourseProcess(List<String> courseList, List<Integer> beisenUserList) {
return learningRecordMapper.findCourseProcess(courseList, beisenUserList);
}
} }
package cn.com.glsx.dj.strategy.service; package cn.com.glsx.dj.strategy.service;
import cn.com.glsx.dj.riskmanage.model.course.BeiSenCourse;
import cn.com.glsx.dj.riskmanage.model.course.BeiSenCourseStaff;
import cn.com.glsx.dj.strategy.mapper.StrategyCourseRelMapper; import cn.com.glsx.dj.strategy.mapper.StrategyCourseRelMapper;
import cn.com.glsx.dj.strategy.model.StrategyCourseRel; import cn.com.glsx.dj.strategy.model.StrategyCourseRel;
import cn.com.glsx.dj.strategy.model.StrategyInfo; import cn.com.glsx.dj.strategy.model.StrategyInfo;
...@@ -64,4 +66,12 @@ public class StrategyCourseRelService { ...@@ -64,4 +66,12 @@ public class StrategyCourseRelService {
.andEqualTo("deletedFlag", DeleteFlagEnum.N.getValue()); .andEqualTo("deletedFlag", DeleteFlagEnum.N.getValue());
return strategyCourseRelMapper.selectByExample(example); return strategyCourseRelMapper.selectByExample(example);
} }
public List<BeiSenCourseStaff> queryCourseLearnSituation(Integer beisenUserId, List<String> courseIdList) {
return strategyCourseRelMapper.queryCourseLearnSituation(beisenUserId, courseIdList);
}
public List<BeiSenCourse> queryCourseDetail(List<String> courseIdList) {
return strategyCourseRelMapper.queryCourseDetail(courseIdList);
}
} }
...@@ -12,6 +12,13 @@ import cn.com.glsx.dj.strategy.enums.StrategyPushFlagEnum; ...@@ -12,6 +12,13 @@ import cn.com.glsx.dj.strategy.enums.StrategyPushFlagEnum;
import cn.com.glsx.dj.strategy.enums.StrategyPushType; import cn.com.glsx.dj.strategy.enums.StrategyPushType;
import cn.com.glsx.dj.strategy.enums.StrategyTypeEnum; import cn.com.glsx.dj.strategy.enums.StrategyTypeEnum;
import cn.com.glsx.dj.strategy.mapper.StrategyInfoMapper; import cn.com.glsx.dj.strategy.mapper.StrategyInfoMapper;
import cn.com.glsx.dj.strategy.model.LearningRecord;
import cn.com.glsx.dj.strategy.model.StrategyCourseLearnProcessDTO;
import cn.com.glsx.dj.strategy.model.StrategyCourseRel;
import cn.com.glsx.dj.strategy.model.StrategyInfo;
import cn.com.glsx.dj.strategy.model.StrategyRecordingRel;
import cn.com.glsx.dj.strategy.model.StrategyStaffRel;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.dj.strategy.mapper.StrategyStaffMessageMapper; import cn.com.glsx.dj.strategy.mapper.StrategyStaffMessageMapper;
import cn.com.glsx.dj.strategy.model.*; import cn.com.glsx.dj.strategy.model.*;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination; import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
...@@ -55,16 +62,16 @@ public class StrategyInfoService { ...@@ -55,16 +62,16 @@ public class StrategyInfoService {
@Autowired @Autowired
private LearningRecordService learningRecordService; private LearningRecordService learningRecordService;
@Autowired @Autowired
private KafkaProducer kafkaProducer; private KafkaProducer kafkaProducer;
@Autowired @Autowired
private KafkaTopicConfig kafkaTopicConfig; private KafkaTopicConfig kafkaTopicConfig;
@Autowired @Autowired
private PadMessageBoxRemote padMessageBoxRemote; private PadMessageBoxRemote padMessageBoxRemote;
@Autowired @Autowired
private StrategyStaffMessageMapper strategyStaffMessageMapper; private StrategyStaffMessageMapper strategyStaffMessageMapper;
...@@ -100,6 +107,7 @@ public class StrategyInfoService { ...@@ -100,6 +107,7 @@ public class StrategyInfoService {
strategyInfo.setCreatedDate(date); strategyInfo.setCreatedDate(date);
strategyInfo.setCreatedBy(batchStrategyInfo.getCreatedBy()); strategyInfo.setCreatedBy(batchStrategyInfo.getCreatedBy());
strategyInfo.setPushFlag(StrategyPushFlagEnum.NOT_PUSHED.getValue()); strategyInfo.setPushFlag(StrategyPushFlagEnum.NOT_PUSHED.getValue());
strategyInfo.setCreatedUUid(batchStrategyInfo.getCreatedUUid());
return strategyInfo; return strategyInfo;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
//批量插入策略基础信息 //批量插入策略基础信息
...@@ -166,8 +174,25 @@ public class StrategyInfoService { ...@@ -166,8 +174,25 @@ public class StrategyInfoService {
if (StrategyTypeEnum.LEARNING.getValue().intValue()==strategyInfo.getStrategyType()){ if (StrategyTypeEnum.LEARNING.getValue().intValue()==strategyInfo.getStrategyType()){
List<StrategyCourseRel> strategyCourseRels = strategyCourseRelService.queryStrategyCourseRelList( List<StrategyCourseRel> strategyCourseRels = strategyCourseRelService.queryStrategyCourseRelList(
strategyId); strategyId);
List<String> collect = strategyCourseRels.stream()
.map(StrategyCourseRel::getCourseId).collect(Collectors.toList());
List<Integer> stringList = strategyInfo.getStaffList().stream()
.map(StrategyStaffRel::getBeisenUserId).collect(
Collectors.toList());
List<StrategyCourseLearnProcessDTO> learningRecords=learningRecordService.findCourseProcess(collect, stringList);
for (StrategyCourseRel strategyCourseRel : strategyCourseRels){ for (StrategyCourseRel strategyCourseRel : strategyCourseRels){
// TODO 处理课程的学习进度 // 处理学习进度
for (StrategyStaffRel strategyStaffRel : strategyInfo.getStaffList()) {
StrategyCourseLearnProcessDTO learningRecord = learningRecords.stream()
.filter(learningRecord1 -> learningRecord1.getUserId().equals(strategyStaffRel.getBeisenUserId()+"") && learningRecord1.getCourseId().equals(strategyCourseRel.getCourseId()))
.findFirst().orElse(null);
if (learningRecord != null){
// TODO 处理课程完成时间
strategyStaffRel.setProgressStatus(3);
}else{
strategyStaffRel.setProgressStatus(1);
}
}
strategyCourseRel.setStaffList(strategyInfo.getStaffList()); strategyCourseRel.setStaffList(strategyInfo.getStaffList());
} }
strategyInfo.setCourseList(strategyCourseRels); strategyInfo.setCourseList(strategyCourseRels);
...@@ -223,7 +248,7 @@ public class StrategyInfoService { ...@@ -223,7 +248,7 @@ public class StrategyInfoService {
* 查询需要推送的策略ID列表 * 查询需要推送的策略ID列表
* 条件:执行策略类型(0-学习类,1-优秀录音分享类,3-任务型)并且下发标识是未推送并且时间等于start_date(精确到分钟) * 条件:执行策略类型(0-学习类,1-优秀录音分享类,3-任务型)并且下发标识是未推送并且时间等于start_date(精确到分钟)
* 注意:“3-任务型”策略只查询定时推送类 * 注意:“3-任务型”策略只查询定时推送类
* *
* @return 策略ID列表 * @return 策略ID列表
*/ */
public List<Integer> queryStrategyIdsForPush() { public List<Integer> queryStrategyIdsForPush() {
...@@ -232,7 +257,7 @@ public class StrategyInfoService { ...@@ -232,7 +257,7 @@ public class StrategyInfoService {
/** /**
* 更新策略推送标识为已推送 * 更新策略推送标识为已推送
* *
* @param strategyId 策略ID * @param strategyId 策略ID
*/ */
public void updateStrategyPushFlag(Integer strategyId) { public void updateStrategyPushFlag(Integer strategyId) {
...@@ -242,7 +267,7 @@ public class StrategyInfoService { ...@@ -242,7 +267,7 @@ public class StrategyInfoService {
strategyInfo.setUpdatedDate(new Date()); strategyInfo.setUpdatedDate(new Date());
strategyInfoMapper.updateByPrimaryKeySelective(strategyInfo); strategyInfoMapper.updateByPrimaryKeySelective(strategyInfo);
} }
/** /**
* 使用分布式锁处理策略推送 * 使用分布式锁处理策略推送
* @param strategyStaffRel 策略人员关联信息 * @param strategyStaffRel 策略人员关联信息
...@@ -274,14 +299,14 @@ public class StrategyInfoService { ...@@ -274,14 +299,14 @@ public class StrategyInfoService {
// TODO // TODO
} }
} }
/** /**
* 处理任务型策略的特殊逻辑 * 处理任务型策略的特殊逻辑
* @param strategyInfo 策略信息 * @param strategyInfo 策略信息
*/ */
private void handleTaskStrategyProcessing(StrategyInfo strategyInfo, StrategyStaffRel staffRel, Byte reminderType) { private void handleTaskStrategyProcessing(StrategyInfo strategyInfo, StrategyStaffRel staffRel, Byte reminderType) {
log.info("开始处理任务型策略特殊逻辑,策略ID: {}", strategyInfo.getId()); log.info("开始处理任务型策略特殊逻辑,策略ID: {}", strategyInfo.getId());
try { try {
Integer staffMessageId = saveStrategyStaffMessage(strategyInfo, staffRel); Integer staffMessageId = saveStrategyStaffMessage(strategyInfo, staffRel);
Integer messageId = pushMessageToPadBox(strategyInfo, staffRel, reminderType); Integer messageId = pushMessageToPadBox(strategyInfo, staffRel, reminderType);
...@@ -327,24 +352,24 @@ public class StrategyInfoService { ...@@ -327,24 +352,24 @@ public class StrategyInfoService {
padMessageBox.setMsgTitle(strategyInfo.getTitle()); // 使用策略标题作为消息标题 padMessageBox.setMsgTitle(strategyInfo.getTitle()); // 使用策略标题作为消息标题
padMessageBox.setTaskStartTime(strategyInfo.getStartDate()); // 设置任务开始时间 padMessageBox.setTaskStartTime(strategyInfo.getStartDate()); // 设置任务开始时间
padMessageBox.setTaskEndTime(strategyInfo.getEndDate()); // 设置任务结束时间 padMessageBox.setTaskEndTime(strategyInfo.getEndDate()); // 设置任务结束时间
log.info("准备向pad_message_box推送消息,策略ID: {}, 人员UUID: {}", log.info("准备向pad_message_box推送消息,策略ID: {}, 人员UUID: {}",
strategyInfo.getId(), staffRel.getUserUuid()); strategyInfo.getId(), staffRel.getUserUuid());
// 调用远程接口保存消息 // 调用远程接口保存消息
RpcResponse<PadMessageBox> response = padMessageBoxRemote.messageBoxSaveRemote(padMessageBox); RpcResponse<PadMessageBox> response = padMessageBoxRemote.messageBoxSaveRemote(padMessageBox);
if (response != null && response.getResult() != null) { if (response != null && response.getResult() != null) {
log.info("成功向pad_message_box推送消息,策略ID: {}, 消息ID: {}", log.info("成功向pad_message_box推送消息,策略ID: {}, 消息ID: {}",
strategyInfo.getId(), response.getResult().getId()); strategyInfo.getId(), response.getResult().getId());
return response.getResult().getId(); return response.getResult().getId();
} else { } else {
log.error("向pad_message_box推送消息失败,策略ID: {}, 错误: {}", log.error("向pad_message_box推送消息失败,策略ID: {}, 错误: {}",
strategyInfo.getId(), response != null ? response.getMessage() : "未知错误"); strategyInfo.getId(), response != null ? response.getMessage() : "未知错误");
return null; return null;
} }
} catch (Exception e) { } catch (Exception e) {
log.error("向pad_message_box推送消息时发生异常,策略ID: {}, 人员UUID: {}", log.error("向pad_message_box推送消息时发生异常,策略ID: {}, 人员UUID: {}",
strategyInfo.getId(), staffRel.getUserUuid(), e); strategyInfo.getId(), staffRel.getUserUuid(), e);
return null; return null;
} }
...@@ -369,7 +394,7 @@ public class StrategyInfoService { ...@@ -369,7 +394,7 @@ public class StrategyInfoService {
throw new RpcServiceException(StrategyErrorEnum.BUSINESS_EXCEPTION, "不支持的业务类型"); throw new RpcServiceException(StrategyErrorEnum.BUSINESS_EXCEPTION, "不支持的业务类型");
} }
} }
/** /**
* 保存策略-人员-消息关联记录 * 保存策略-人员-消息关联记录
* @param strategyInfo 策略信息 * @param strategyInfo 策略信息
...@@ -386,19 +411,19 @@ public class StrategyInfoService { ...@@ -386,19 +411,19 @@ public class StrategyInfoService {
strategyStaffMessage.setCreatedDate(new Date()); strategyStaffMessage.setCreatedDate(new Date());
strategyStaffMessage.setUpdatedDate(new Date()); strategyStaffMessage.setUpdatedDate(new Date());
strategyStaffMessage.setDeletedFlag("N"); strategyStaffMessage.setDeletedFlag("N");
int result = strategyStaffMessageMapper.insertSelective(strategyStaffMessage); int result = strategyStaffMessageMapper.insertSelective(strategyStaffMessage);
return strategyStaffMessage.getId(); return strategyStaffMessage.getId();
} catch (Exception e) { } catch (Exception e) {
log.error("保存策略-人员-消息关联记录时发生异常,策略ID: {}, 人员UUID: {}", log.error("保存策略-人员-消息关联记录时发生异常,策略ID: {}, 人员UUID: {}",
strategyInfo.getId(), staffRel.getUserUuid(), e); strategyInfo.getId(), staffRel.getUserUuid(), e);
throw new RpcServiceException(StrategyErrorEnum.BUSINESS_EXCEPTION, "保存策略人员消息关联记录失败"); throw new RpcServiceException(StrategyErrorEnum.BUSINESS_EXCEPTION, "保存策略人员消息关联记录失败");
} }
} }
/** /**
* 查询未完成策略任务的策略-人员ID集合 * 查询未完成策略任务的策略-人员ID集合
* *
* @return 未完成策略任务的策略-人员信息列表 * @return 未完成策略任务的策略-人员信息列表
*/ */
public List<Integer> queryUnfinishedStrategyStaffList() { public List<Integer> queryUnfinishedStrategyStaffList() {
......
...@@ -3,20 +3,29 @@ package cn.com.glsx.dj.strategy.service; ...@@ -3,20 +3,29 @@ package cn.com.glsx.dj.strategy.service;
import cn.com.glsx.dj.mindworkplate.dto.ConversationBatchDTO; import cn.com.glsx.dj.mindworkplate.dto.ConversationBatchDTO;
import cn.com.glsx.dj.mindworkplate.model.warning.LearningEffectAnalysisRequest; import cn.com.glsx.dj.mindworkplate.model.warning.LearningEffectAnalysisRequest;
import cn.com.glsx.dj.mindworkplate.remote.MonitoringRemote; import cn.com.glsx.dj.mindworkplate.remote.MonitoringRemote;
import cn.com.glsx.dj.riskmanage.model.course.BeiSenCourse;
import cn.com.glsx.dj.riskmanage.model.course.BeiSenCourseStaff;
import cn.com.glsx.dj.strategy.dto.StrategyStaffCourseRelDTO;
import cn.com.glsx.dj.strategy.dto.StrategyStaffRecordingRelDTO;
import cn.com.glsx.dj.strategy.enums.StrategyTypeEnum; import cn.com.glsx.dj.strategy.enums.StrategyTypeEnum;
import cn.com.glsx.dj.strategy.mapper.LearningRecordMapper;
import cn.com.glsx.dj.strategy.mapper.StrategyInfoMapper; import cn.com.glsx.dj.strategy.mapper.StrategyInfoMapper;
import cn.com.glsx.dj.strategy.mapper.StrategyStaffMessageMapper; import cn.com.glsx.dj.strategy.mapper.StrategyStaffMessageMapper;
import cn.com.glsx.dj.strategy.model.StrategyInfo; import cn.com.glsx.dj.strategy.mapper.StrategyStaffRelMapper;
import cn.com.glsx.dj.strategy.model.StrategyRecordingRel; import cn.com.glsx.dj.strategy.model.*;
import cn.com.glsx.dj.strategy.model.StrategyStaffMessage;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination; import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse; import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.hutool.core.bean.BeanUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
...@@ -35,6 +44,15 @@ public class StrategyStaffMessageService { ...@@ -35,6 +44,15 @@ public class StrategyStaffMessageService {
@Autowired @Autowired
private StrategyRecordingRelService strategyRecordingRelService; private StrategyRecordingRelService strategyRecordingRelService;
@Autowired
private LearningRecordMapper learningRecordMapper;
@Autowired
private StrategyCourseRelService strategyCourseRelService;
@Autowired
private StrategyStaffRelMapper strategyStaffRelMapper;
/** /**
* 根据消息盒子ID和手机号更新业务消息记录的已读状态 * 根据消息盒子ID和手机号更新业务消息记录的已读状态
* @param messageId 消息盒子ID * @param messageId 消息盒子ID
...@@ -74,10 +92,17 @@ public class StrategyStaffMessageService { ...@@ -74,10 +92,17 @@ public class StrategyStaffMessageService {
} else if (StrategyTypeEnum.EXCELLENT_RECORDING_SHARE.equals(strategyInfo.getStrategyType())) { } else if (StrategyTypeEnum.EXCELLENT_RECORDING_SHARE.equals(strategyInfo.getStrategyType())) {
// 查询策略关联的全部录音 // 查询策略关联的全部录音
List<StrategyRecordingRel> strategyRecordingRels = strategyRecordingRelService.queryStrategyRecordingRelList(strategyId); List<StrategyRecordingRel> strategyRecordingRels = strategyRecordingRelService.queryStrategyRecordingRelList(strategyId);
List<StrategyStaffRecordingRelDTO> strategyStaffRecordingRelDTOS = BeanUtil.copyToList(strategyRecordingRels, StrategyStaffRecordingRelDTO.class);
List<Integer> recordIdList = strategyRecordingRels.stream().map(StrategyRecordingRel::getRecordingId).collect(Collectors.toList());
Map<Integer, LearningRecord> learningRecordMap = new HashMap<>();
List<LearningRecord> learningRecords = learningRecordMapper.queryLearningRecordList(recordIdList, Collections.singletonList(staffMessage.getUuid()));
if (CollectionUtils.isNotEmpty(learningRecords)) {
learningRecords.stream().map(learningRecord -> learningRecordMap.put(Integer.valueOf(learningRecord.getRecordingId()), learningRecord));
}
LearningEffectAnalysisRequest condition = new LearningEffectAnalysisRequest(); LearningEffectAnalysisRequest condition = new LearningEffectAnalysisRequest();
condition.setStaffPhone(staffMessage.getPhone()); condition.setRecordIdList(recordIdList);
condition.setRecordIdList(strategyRecordingRels.stream().map(StrategyRecordingRel::getRecordingId).collect(Collectors.toList()));
RpcPagination<LearningEffectAnalysisRequest> request = new RpcPagination<>(); RpcPagination<LearningEffectAnalysisRequest> request = new RpcPagination<>();
request.setPageNum(1); request.setPageNum(1);
...@@ -85,17 +110,54 @@ public class StrategyStaffMessageService { ...@@ -85,17 +110,54 @@ public class StrategyStaffMessageService {
request.setCondition(condition); request.setCondition(condition);
RpcResponse<RpcPagination<ConversationBatchDTO>> recordPageListByCondition = monitoringRemote.getRecordPageListByCondition(request); RpcResponse<RpcPagination<ConversationBatchDTO>> recordPageListByCondition = monitoringRemote.getRecordPageListByCondition(request);
if (recordPageListByCondition.isSuccess()) { if (!recordPageListByCondition.isSuccess()) {
return recordPageListByCondition.getResult().getList();
} else {
log.warn("查询录音详情失败,messageId:{}", messageId); log.warn("查询录音详情失败,messageId:{}", messageId);
return null; return null;
} }
Map<Integer, ConversationBatchDTO> conversationBatchDTOMap = new HashMap<>();
List<ConversationBatchDTO> conversationBatchDTOS = recordPageListByCondition.getResult().getList();
conversationBatchDTOS.forEach(conversationBatchDTO -> conversationBatchDTOMap.put(conversationBatchDTO.getId(), conversationBatchDTO));
for (StrategyStaffRecordingRelDTO dto : strategyStaffRecordingRelDTOS) {
dto.setRecordingDetail(conversationBatchDTOMap.get(dto.getRecordingId()));
dto.setLearningRecord(learningRecordMap.get(dto.getRecordingId()));
}
return strategyStaffRecordingRelDTOS;
} else if (StrategyTypeEnum.LEARNING.equals(strategyInfo.getStrategyType())) { } else if (StrategyTypeEnum.LEARNING.equals(strategyInfo.getStrategyType())) {
// 查询策略关联的全部课程
List<StrategyCourseRel> strategyCourseRels = strategyCourseRelService.queryStrategyCourseRelList(strategyId);
List<StrategyStaffCourseRelDTO> strategyStaffCourseRelDTOS = BeanUtil.copyToList(strategyCourseRels, StrategyStaffCourseRelDTO.class);
return null; // 查询单个策略-人员关联关系
StrategyStaffRel strategyStaffRel = strategyStaffRelMapper.selectByStrategyIdAndStaffId(strategyId, staffMessage.getUuid());
// 查询课程学习情况
List<String> courseIdList = strategyCourseRels.stream().map(StrategyCourseRel::getCourseId).collect(Collectors.toList());
Map<String, BeiSenCourseStaff> beisenCourseStaffMap = new HashMap<>();
List<BeiSenCourseStaff> beisenCourseStaffs = strategyCourseRelService.queryCourseLearnSituation(strategyStaffRel.getBeisenUserId(), courseIdList);
if (CollectionUtils.isNotEmpty(beisenCourseStaffs)) {
beisenCourseStaffs.stream().map(beisenCourseStaff -> beisenCourseStaffMap.put(beisenCourseStaff.getCourseId(), beisenCourseStaff));
}
// 查询课程详情
Map<String, BeiSenCourse> courseMap = new HashMap<>();
List<BeiSenCourse> courseDetails = strategyCourseRelService.queryCourseDetail(courseIdList);
if (CollectionUtils.isNotEmpty(courseDetails)) {
courseDetails.stream().map(courseDetail -> courseMap.put(courseDetail.getId(), courseDetail));
}
// 封装数据返回
strategyStaffCourseRelDTOS.forEach(dto -> {
dto.setLearningRecord(beisenCourseStaffMap.get(dto.getCourseId()));
dto.setCourseDetail(courseMap.get(dto.getCourseId()));
});
return strategyStaffCourseRelDTOS;
} else { } else {
// 其他类型,返回null TODO 待实现 0-学习类,1-优秀录音分享类,剩余类型暂时无推送消息 // 其他类型,返回null
return null; return null;
} }
} }
......
...@@ -47,4 +47,17 @@ ...@@ -47,4 +47,17 @@
</foreach> </foreach>
</if> </if>
</select> </select>
<select id="findCourseProcess"
resultType="cn.com.glsx.dj.strategy.model.StrategyCourseLearnProcessDTO">
select t1.user_id as userId,t1.course_id as courseId, t1.learn_status as learnStatus,t1.total_score as totalScore from dj_beisen_course_staff t1
where
t1.user_id in
<foreach item="item" index="index" collection="beisenUserList" separator="," open="(" close=")">
#{item}
</foreach>
and t1.course_id in
<foreach item="item" index="index" collection="courseList" separator="," open="(" close=")">
#{item}
</foreach>
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -38,4 +38,25 @@ ...@@ -38,4 +38,25 @@
WHERE cr.strategy_id = #{strategyId,jdbcType=INTEGER} WHERE cr.strategy_id = #{strategyId,jdbcType=INTEGER}
AND cr.deleted_flag = 'N' AND cr.deleted_flag = 'N'
</select> </select>
<select id="queryCourseLearnSituation" resultType="cn.com.glsx.dj.riskmanage.model.course.BeiSenCourseStaff">
SELECT
*
FROM dj_beisen_course_staff
WHERE deleted_flag = 'N'
and user_id = #{beisenUserId,jdbcType=INTEGER}
and course_id IN
<foreach collection="courseIdList" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<select id="queryCourseDetail" resultType="cn.com.glsx.dj.riskmanage.model.course.BeiSenCourse">
SELECT
*
FROM dj_beisen_course
WHERE id IN
<foreach collection="courseIdList" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
--> -->
<id column="id" property="id" jdbcType="INTEGER" /> <id column="id" property="id" jdbcType="INTEGER" />
<result column="strategy_id" property="strategyId" jdbcType="INTEGER" /> <result column="strategy_id" property="strategyId" jdbcType="INTEGER" />
<result column="recording_id" property="recordingId" jdbcType="VARCHAR" /> <result column="recording_id" property="recordingId" />
<result column="reception_staff_name" property="receptionStaffName" jdbcType="VARCHAR" /> <result column="reception_staff_name" property="receptionStaffName" jdbcType="VARCHAR" />
<result column="reception_date" property="receptionDate" /> <result column="reception_date" property="receptionDate" />
<result column="created_by" property="createdBy" jdbcType="VARCHAR" /> <result column="created_by" property="createdBy" jdbcType="VARCHAR" />
......
...@@ -30,4 +30,12 @@ ...@@ -30,4 +30,12 @@
WHERE strategy_id = #{strategyId,jdbcType=INTEGER} WHERE strategy_id = #{strategyId,jdbcType=INTEGER}
AND deleted_flag = 'N' AND deleted_flag = 'N'
</select> </select>
<select id="selectByStrategyIdAndStaffId" resultType="cn.com.glsx.dj.strategy.model.StrategyStaffRel">
SELECT
<include refid="Base_Column_List" />
FROM dj_car_life_strategy_staff_rel
WHERE strategy_id = #{strategyId,jdbcType=INTEGER}
AND user_uuid = #{userUuid,jdbcType=VARCHAR}
AND deleted_flag = 'N'
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -10,6 +10,7 @@ import cn.com.glsx.dj.strategy.enums.StrategyPushType; ...@@ -10,6 +10,7 @@ import cn.com.glsx.dj.strategy.enums.StrategyPushType;
import cn.com.glsx.dj.strategy.enums.StrategyTypeEnum; import cn.com.glsx.dj.strategy.enums.StrategyTypeEnum;
import cn.com.glsx.dj.strategy.model.*; import cn.com.glsx.dj.strategy.model.*;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -47,16 +48,16 @@ public class StrategyInfoServiceTest extends BaseServiceTest { ...@@ -47,16 +48,16 @@ public class StrategyInfoServiceTest extends BaseServiceTest {
merchantList.add(merchantInfo2); merchantList.add(merchantInfo2);
batchInsertStrategyInfo.setMerchantList(merchantList); batchInsertStrategyInfo.setMerchantList(merchantList);
StrategyInfo strategyInfo = new StrategyInfo(); StrategyInfo strategyInfo = new StrategyInfo();
strategyInfo.setStrategyType(StrategyTypeEnum.TASK.getValue()); strategyInfo.setStrategyType(StrategyTypeEnum.EXCELLENT_RECORDING_SHARE.getValue());
strategyInfo.setBiz(1); strategyInfo.setBiz(1);
strategyInfo.setTitle("测试任务型策略"); strategyInfo.setTitle("测试优秀录音分享策略");
strategyInfo.setSubTitle("副标题"); //strategyInfo.setSubTitle("副标题");
strategyInfo.setStartDate(new Date()); strategyInfo.setStartDate(new Date());
//strategyInfo.setEndDate(DateUtil.offsetDay(new Date(), 10)); //strategyInfo.setEndDate(DateUtil.offsetDay(new Date(), 10));
strategyInfo.setDescription("这是一个任务型策略"); strategyInfo.setDescription("测试优秀录音分享策略");
strategyInfo.setPushType(StrategyPushType.TIMED_PUSH.getValue()); strategyInfo.setPushType(StrategyPushType.TIMED_PUSH.getValue());
strategyInfo.setHandlerType("0"); strategyInfo.setHandlerType("0");
strategyInfo.setContent("这是一个任务型策略的内容"); strategyInfo.setContent("这是一个测试优秀录音分享策略");
batchInsertStrategyInfo.setStrategyInfo(strategyInfo); batchInsertStrategyInfo.setStrategyInfo(strategyInfo);
List<StrategyStaffRel> staffList = new ArrayList<>(); List<StrategyStaffRel> staffList = new ArrayList<>();
StrategyStaffRel strategyStaffRel = new StrategyStaffRel(); StrategyStaffRel strategyStaffRel = new StrategyStaffRel();
...@@ -71,13 +72,13 @@ public class StrategyInfoServiceTest extends BaseServiceTest { ...@@ -71,13 +72,13 @@ public class StrategyInfoServiceTest extends BaseServiceTest {
// strategyCourseRel.setCourseId("077527d0-8d20-400a-bd2b-b3020d3fee74"); // strategyCourseRel.setCourseId("077527d0-8d20-400a-bd2b-b3020d3fee74");
// courseList.add(strategyCourseRel); // courseList.add(strategyCourseRel);
// batchInsertStrategyInfo.setCourseList(courseList); // batchInsertStrategyInfo.setCourseList(courseList);
// List<StrategyRecordingRel> recordingList = new ArrayList<>(); List<StrategyRecordingRel> recordingList = new ArrayList<>();
// StrategyRecordingRel strategyRecordingRel = new StrategyRecordingRel(); StrategyRecordingRel strategyRecordingRel = new StrategyRecordingRel();
// strategyRecordingRel.setRecordingId("077527d0-8d20-400a-bd2b-b3020d3fee74"); strategyRecordingRel.setRecordingId(834);
// strategyRecordingRel.setReceptionDate(new Date()); strategyRecordingRel.setReceptionDate("2025-12-31");
// strategyRecordingRel.setReceptionStaffName("测试一下哦"); strategyRecordingRel.setReceptionStaffName("测试一下哦");
// recordingList.add(strategyRecordingRel); recordingList.add(strategyRecordingRel);
// batchInsertStrategyInfo.setRecordingList(recordingList); batchInsertStrategyInfo.setRecordingList(recordingList);
batchInsertStrategyInfo.setCreatedBy("fanfr"); batchInsertStrategyInfo.setCreatedBy("fanfr");
Boolean b = strategyInfoService.batchCreate(batchInsertStrategyInfo); Boolean b = strategyInfoService.batchCreate(batchInsertStrategyInfo);
log.info("b: {}", b); log.info("b: {}", b);
...@@ -113,6 +114,12 @@ public class StrategyInfoServiceTest extends BaseServiceTest { ...@@ -113,6 +114,12 @@ public class StrategyInfoServiceTest extends BaseServiceTest {
log.info("b: {}", b); log.info("b: {}", b);
} }
@Test
public void testQueryStrategyInfoById() {
StrategyInfo strategyInfo = strategyInfoService.queryStrategyInfoById(5);
log.info("strategyInfo: {}", JSONObject.toJSONString(strategyInfo));
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!