|
|
|
|
@ -10,6 +10,7 @@ import com.sztzjy.linkCommerce.config.exception.handler.ServiceException;
|
|
|
|
|
import com.sztzjy.linkCommerce.entity.*;
|
|
|
|
|
import com.sztzjy.linkCommerce.entity.dto.StuMachineLearningInfoDTO;
|
|
|
|
|
import com.sztzjy.linkCommerce.mapper.*;
|
|
|
|
|
import com.sztzjy.linkCommerce.service.ScoreService;
|
|
|
|
|
import com.sztzjy.linkCommerce.service.UserBehaviorProfilingAnaService;
|
|
|
|
|
import com.sztzjy.linkCommerce.util.BigDecimalUtils;
|
|
|
|
|
import com.sztzjy.linkCommerce.util.ResultEntity;
|
|
|
|
|
@ -33,26 +34,10 @@ public class UserBehaviorProfilingAnaServiceImpl implements UserBehaviorProfilin
|
|
|
|
|
@Autowired
|
|
|
|
|
private StuMachineLearningMapper machineLearningMapper;
|
|
|
|
|
|
|
|
|
|
// @Resource
|
|
|
|
|
// BigDecimalUtils bigDecimalUtils;
|
|
|
|
|
//
|
|
|
|
|
// @Resource
|
|
|
|
|
// StuUserMapper stuUserMapper;
|
|
|
|
|
//
|
|
|
|
|
// @Resource
|
|
|
|
|
// StuTrainingTaskSubmissionDetailsMapper stuTrainingTaskSubmissionDetailsMapper;
|
|
|
|
|
//
|
|
|
|
|
// @Resource
|
|
|
|
|
// StuModuleDetailsMapper stuModuleDetailsMapper;
|
|
|
|
|
// @Resource
|
|
|
|
|
// TchModuleWeithMapper tchModuleWeightMapper;
|
|
|
|
|
//
|
|
|
|
|
// @Resource
|
|
|
|
|
// ScoringUtil scoringUtil;
|
|
|
|
|
// @Resource
|
|
|
|
|
// StuScoreDetailsMapper stuScoreDetailsMapper;
|
|
|
|
|
// @Resource
|
|
|
|
|
// StuLearningAssessmentMapper learningAssessmentMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ScoreService scoreService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 用户行为画像分析自动保存
|
|
|
|
|
@ -64,9 +49,10 @@ public class UserBehaviorProfilingAnaServiceImpl implements UserBehaviorProfilin
|
|
|
|
|
@Override
|
|
|
|
|
public ResultEntity analysisByAutoSave(StuMachineLearning learning) {
|
|
|
|
|
|
|
|
|
|
//首次提交
|
|
|
|
|
Boolean flag = false;
|
|
|
|
|
|
|
|
|
|
if (learning.getStuMachineLearningInfoDTOList()!=null) {
|
|
|
|
|
if (learning.getStuMachineLearningInfoDTOList() != null) {
|
|
|
|
|
flag = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -76,90 +62,67 @@ public class UserBehaviorProfilingAnaServiceImpl implements UserBehaviorProfilin
|
|
|
|
|
|
|
|
|
|
if (!machineLearningList.isEmpty()) {
|
|
|
|
|
|
|
|
|
|
if (machineLearningList.get(0).getSubState() == null) {
|
|
|
|
|
machineLearningList.get(0).setSubState(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//只是自动保存了没有提交
|
|
|
|
|
if (machineLearningList.get(0).getSubState() == 1) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "保存成功!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//已经有数据
|
|
|
|
|
StuMachineLearning machineLearning = machineLearningList.get(0);
|
|
|
|
|
|
|
|
|
|
Integer id = machineLearning.getId();
|
|
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(learning, machineLearning);
|
|
|
|
|
machineLearning.setId(id);
|
|
|
|
|
if (flag)
|
|
|
|
|
{
|
|
|
|
|
//讲数据转为json
|
|
|
|
|
String json = JSONObject.toJSONString(learning.getStuMachineLearningInfoDTOList());
|
|
|
|
|
machineLearning.setActiveUserAnalysis(json);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StringUtils.hasText(learning.getStepechartlist1()))
|
|
|
|
|
{
|
|
|
|
|
String json = JSONObject.toJSONString(learning.getStepechartlist1());
|
|
|
|
|
machineLearning.setStepechartlist1(json);
|
|
|
|
|
return new ResultEntity<>(HttpStatus.ACCEPTED, "请勿重复提交!");
|
|
|
|
|
} else {
|
|
|
|
|
StuMachineLearning stuMachineLearning = machineLearningList.get(0);
|
|
|
|
|
Integer id = stuMachineLearning.getId();
|
|
|
|
|
BeanUtils.copyProperties(learning, stuMachineLearning);
|
|
|
|
|
stuMachineLearning.setId(id);
|
|
|
|
|
machineLearningMapper.updateByPrimaryKeyWithBLOBs(stuMachineLearning);
|
|
|
|
|
if (learning.getSubState() == 1) {
|
|
|
|
|
|
|
|
|
|
BigDecimal aDouble = BigDecimal.valueOf(100).subtract(Convert.toBigDecimal(learning.getErrorField()));
|
|
|
|
|
//算分
|
|
|
|
|
scoreService.insertScore(learning.getUserId(), learning.getProject(), learning.getModule(), aDouble, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StringUtils.hasText(learning.getStepechartlist2()))
|
|
|
|
|
{
|
|
|
|
|
String json = JSONObject.toJSONString(learning.getStepechartlist2());
|
|
|
|
|
machineLearning.setStepechartlist2(json);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StringUtils.hasText(learning.getStepechartlist3()))
|
|
|
|
|
{
|
|
|
|
|
String json = JSONObject.toJSONString(learning.getStepechartlist3());
|
|
|
|
|
machineLearning.setStepechartlist3(json);
|
|
|
|
|
}
|
|
|
|
|
//首次提交
|
|
|
|
|
int i = UUID.randomUUID().hashCode();
|
|
|
|
|
i = i < 0 ? -i : i;
|
|
|
|
|
|
|
|
|
|
//第一次保存
|
|
|
|
|
learning.setId(i);
|
|
|
|
|
if (flag) {
|
|
|
|
|
//讲数据转为json
|
|
|
|
|
String json = JSONObject.toJSONString(learning.getStuMachineLearningInfoDTOList());
|
|
|
|
|
learning.setActiveUserAnalysis(json);
|
|
|
|
|
|
|
|
|
|
machineLearningMapper.updateByPrimaryKeyWithBLOBs(machineLearning);
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.hasText(learning.getStepechartlist1())) {
|
|
|
|
|
String json = JSONObject.toJSONString(learning.getStepechartlist1());
|
|
|
|
|
learning.setStepechartlist1(json);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "保存成功!");
|
|
|
|
|
if (StringUtils.hasText(learning.getStepechartlist2())) {
|
|
|
|
|
String json = JSONObject.toJSONString(learning.getStepechartlist2());
|
|
|
|
|
learning.setStepechartlist2(json);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
if (StringUtils.hasText(learning.getStepechartlist3())) {
|
|
|
|
|
String json = JSONObject.toJSONString(learning.getStepechartlist3());
|
|
|
|
|
learning.setStepechartlist3(json);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int i = UUID.randomUUID().hashCode();
|
|
|
|
|
i = i < 0 ? -i : i;
|
|
|
|
|
machineLearningMapper.insertSelective(learning);
|
|
|
|
|
|
|
|
|
|
//第一次保存
|
|
|
|
|
learning.setId(i);
|
|
|
|
|
if (flag)
|
|
|
|
|
{
|
|
|
|
|
//讲数据转为json
|
|
|
|
|
String json = JSONObject.toJSONString(learning.getStuMachineLearningInfoDTOList());
|
|
|
|
|
learning.setActiveUserAnalysis(json);
|
|
|
|
|
if (learning.getSubState() == 1) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.hasText(learning.getStepechartlist1()))
|
|
|
|
|
{
|
|
|
|
|
String json = JSONObject.toJSONString(learning.getStepechartlist1());
|
|
|
|
|
learning.setStepechartlist1(json);
|
|
|
|
|
}
|
|
|
|
|
BigDecimal aDouble = BigDecimal.valueOf(100).subtract(Convert.toBigDecimal(learning.getErrorField()));
|
|
|
|
|
//算分
|
|
|
|
|
scoreService.insertScore(learning.getUserId(), learning.getProject(), learning.getModule(), aDouble, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StringUtils.hasText(learning.getStepechartlist2()))
|
|
|
|
|
{
|
|
|
|
|
String json = JSONObject.toJSONString(learning.getStepechartlist2());
|
|
|
|
|
learning.setStepechartlist2(json);
|
|
|
|
|
}
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "保存成功!");
|
|
|
|
|
|
|
|
|
|
if (StringUtils.hasText(learning.getStepechartlist3()))
|
|
|
|
|
{
|
|
|
|
|
String json = JSONObject.toJSONString(learning.getStepechartlist3());
|
|
|
|
|
learning.setStepechartlist3(json);
|
|
|
|
|
}
|
|
|
|
|
machineLearningMapper.insertSelective(learning);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "保存成功!");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查看接口
|
|
|
|
|
@ -213,12 +176,14 @@ public class UserBehaviorProfilingAnaServiceImpl implements UserBehaviorProfilin
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ResultEntity restartByTraining(String module, String userId) {
|
|
|
|
|
public ResultEntity restartByTraining(String module, String userId,String project) {
|
|
|
|
|
|
|
|
|
|
//删除做题记录 第二次成绩是否有效?
|
|
|
|
|
StuMachineLearningExample machineLearningExample = new StuMachineLearningExample();
|
|
|
|
|
machineLearningExample.createCriteria().andUserIdEqualTo(userId).andModuleEqualTo(module);
|
|
|
|
|
machineLearningMapper.deleteByExample(machineLearningExample);
|
|
|
|
|
int i = machineLearningMapper.deleteByExample(machineLearningExample);
|
|
|
|
|
|
|
|
|
|
scoreService.deleteScore(userId,project,userId);
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "重新实训成功!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|