修复机器学习bug

master
whb 7 months ago
parent 64a8a05022
commit df9309ff8b

@ -175,4 +175,15 @@ public class QianFanBigModuleController {
}
@ApiOperation("获取文件上传信息")
@GetMapping("/getUploadFileInfo")
@AnonymousAccess
public ResultEntity getUploadFileInfo(
String userId,String module,String schoolId) {
return qianFanBigModuleService.getUploadFileInfo(userId,module,schoolId);
}
}

@ -21,12 +21,18 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
import java.util.stream.Collectors;
@ -48,6 +54,10 @@ public class StuExperimentalTrainingController {
private StuLearningAssessmentMapper stuLearningAssessmentMapper;
@Autowired
private ConvertUtil convertUtil;
@Value("${file.path}")
private String filePath;
@Autowired
private StuFiveGTrainingService stuFiveGTrainingService;
@ -357,6 +367,25 @@ public class StuExperimentalTrainingController {
return vector;
}
@PostMapping("/creatAbstract")
@ApiOperation("自然语言处理:生成摘要")
@AnonymousAccess
public ResultEntity<String> creatAbstract(String userId) {
String info = "生成式人工智能深刻影响人们生活的方方面面,当我们使用生成式人工智能高效搜索、生成文本、提高工作效率时,生成式人工智能的潜在风险也在不知不觉中逐渐渗透。生成式人工智能可处理海量数据,但也给知识产权保护、个人隐私保护、打击虚假信息等方面带来新挑战。积极推进人工智能治理,法治与社会教育是促进守正创新的两大抓手。一方面,营造安全有序的法治环境,规范生成式人工智能服务。同时,健全生成式人工智能系统出现问题时的法律责任和赔偿机制,另一方面,加强对公众的教育与培训也至关重要,强调伦理和法律约束,以提高对这些潜在风险的认识。";
return new ResultEntity<>(HttpStatus.OK, info);
}
@GetMapping("/creatImg")
@ApiOperation("自然语言处理:生成云图")
@AnonymousAccess
public ResponseEntity<byte[]> creatImg(String userId) throws IOException {
// 模拟加载公章图片的数据(假设在硬盘上的某个路径下)
String imagePath = filePath + "/doc/word.png"; // 替换为你的实际路径
byte[] sealBytes = Files.readAllBytes(Paths.get(imagePath));
// 构建HTTP响应设置Content-Type为image/png
return ResponseEntity.ok().contentType(MediaType.IMAGE_PNG).body(sealBytes);
}
}

@ -37,4 +37,14 @@ public interface QianFanBigModuleService {
*/
Flux<String> createArticleByMessage(List<Message> messageList);
/**
*
* @param userId
* @param module
* @param schoolId
* @return
*/
ResultEntity getUploadFileInfo(String userId, String module, String schoolId);
}

@ -7,10 +7,13 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.sztzjy.marketing.entity.StuAiLimit;
import com.sztzjy.marketing.entity.StuAiLimitExample;
import com.sztzjy.marketing.entity.StuUploadImgAi;
import com.sztzjy.marketing.entity.StuUploadImgAiExample;
import com.sztzjy.marketing.entity.dto.ReqChatMessage;
import com.sztzjy.marketing.entity.dto.StuCreateArticleDTO;
import com.sztzjy.marketing.entity.dto.StuCreateImgDTO;
import com.sztzjy.marketing.mapper.StuAiLimitMapper;
import com.sztzjy.marketing.mapper.StuUploadImgAiMapper;
import com.sztzjy.marketing.qianfan.Qianfan;
import com.sztzjy.marketing.qianfan.model.chat.ChatResponse;
import com.sztzjy.marketing.qianfan.model.chat.Message;
@ -28,7 +31,9 @@ import org.apache.http.client.methods.HttpPost;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import reactor.core.publisher.Flux;
@ -191,6 +196,31 @@ public class QianFanBigModuleServiceImpl implements QianFanBigModuleService {
return (chat(accesstoken,messageList));
}
/**
*
* @param userId
* @param module
* @param schoolId
* @return
*/
@Autowired
private StuUploadImgAiMapper stuUploadImgAiMapper;
@Override
public ResultEntity getUploadFileInfo(String userId, String module, String schoolId) {
StuUploadImgAiExample limitExample = new StuUploadImgAiExample();
limitExample.createCriteria().andUserIdEqualTo(userId).andModuleEqualTo(module);
List<StuUploadImgAi> stuAiLimits = stuUploadImgAiMapper.selectByExample(limitExample);
if (CollectionUtils.isEmpty(stuAiLimits))
{
return new ResultEntity<>(HttpStatus.OK);
}else {
return new ResultEntity<>(HttpStatus.OK,stuAiLimits);
}
}
//获取accessToken
public String getAccesstoken() throws IOException {

@ -15,6 +15,7 @@ import com.sztzjy.marketing.mapper.StuDigServiceTradeMapper;
import com.sztzjy.marketing.mapper.StuDigitalConfirmationMapper;
import com.sztzjy.marketing.mapper.StuHadoopTrainMapper;
import com.sztzjy.marketing.service.StuFiveGTrainingService;
import com.sztzjy.marketing.service.UserBehaviorProfilingAnaService;
import com.sztzjy.marketing.util.file.IFileUtil;
import com.sztzjy.marketing.mapper.StuImageRecognitionTrainingMapper;
import org.apache.logging.log4j.util.Strings;
@ -49,6 +50,9 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService {
@Autowired
private StuImageRecognitionTrainingMapper stuImageRecognitionTrainingMapper;
@Autowired
UserBehaviorProfilingAnaService userBehaviorProfilingAnaService;
@Resource
private IFileUtil iFileUtil;
@ -143,7 +147,7 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService {
stuHadoopTrainMapper.updateByPrimaryKeySelective(stuHadoopTrains.get(0));
//提交答题错误
Integer anInt = Convert.toInt(stuHadoopTrains.get(0).getWrongDetail());
// stuDigitalIndustrializationService.practicalTrainingSubmission(userId,"大数据","Hadoop",anInt);
userBehaviorProfilingAnaService.practicalTrainingSubmission(userId,"Hadoop",anInt);
}
return info;
}

@ -149,7 +149,7 @@ public class StuSubSerivceImpl implements StuSubSerivce {
public ResultEntity machineLearningSavaAuto(StuMachineLearningDto stuMachineLearningDto) {
StuMachineLearningExample example = new StuMachineLearningExample();
example.createCriteria().andUserIdEqualTo(stuMachineLearningDto.getUserId());
example.createCriteria().andUserIdEqualTo(stuMachineLearningDto.getUserId()).andModuleEqualTo("机器学习");
List<StuMachineLearning> stuMachineLearningList = stuMachineLearningMapper.selectByExample(example);
if (!stuMachineLearningList.isEmpty())
{
@ -173,6 +173,7 @@ public class StuSubSerivceImpl implements StuSubSerivce {
learning.setUserId(stuMachineLearningDto.getUserId());
learning.setSubState(stuMachineLearningDto.getSubState());
learning.setId((int) IdUtil.getSnowflakeNextId());
learning.setModule("机器学习");
stuMachineLearningMapper.insertSelective(learning);
@ -188,7 +189,7 @@ public class StuSubSerivceImpl implements StuSubSerivce {
StuMachineLearningExample example = new StuMachineLearningExample();
example.createCriteria().andUserIdEqualTo(userId);
example.createCriteria().andUserIdEqualTo(userId).andModuleEqualTo("机器学习");
List<StuMachineLearning> stuMachineLearningList = stuMachineLearningMapper.selectByExample(example);
if (!stuMachineLearningList.isEmpty())
{

Loading…
Cancel
Save