| | |
| | | import cc.mrbird.febs.ai.mapper.AiProductQuestionJobMapper; |
| | | import cc.mrbird.febs.ai.mapper.AiProductQuestionMapper; |
| | | import cc.mrbird.febs.ai.req.AiProductQuestionAiDto; |
| | | import cc.mrbird.febs.ai.res.AdminQuestionInfoVo; |
| | | import cc.mrbird.febs.ai.service.AiProductCategoryService; |
| | | import cc.mrbird.febs.ai.service.AiProductQuestionItemService; |
| | | import cc.mrbird.febs.ai.service.AiProductQuestionService; |
| | |
| | | import cc.mrbird.febs.mall.entity.MallMember; |
| | | import cc.mrbird.febs.mall.entity.MallOrderInfo; |
| | | import cc.mrbird.febs.mall.entity.MallOrderItem; |
| | | import cc.mrbird.febs.mall.vo.AdminAgentMemberVo; |
| | | import cc.mrbird.febs.rabbit.producter.AgentProducer; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateUtil; |
| | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.math.BigDecimal; |
| | | import java.net.URLEncoder; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse jobStateUpdate(String ids) { |
| | | if (StrUtil.isEmpty(ids)) { |
| | | throw new FebsException("参数错误"); |
| | | } |
| | | List<String> idList = StrUtil.split(ids, ','); |
| | | aiProductQuestionJobMapper.update(null, |
| | | Wrappers.lambdaUpdate(AiProductQuestionJob.class) |
| | | .set(AiProductQuestionJob::getState, 2) |
| | | .set(AiProductQuestionJob::getUpdatedTime, new Date()) |
| | | .in(AiProductQuestionJob::getId, idList)); |
| | | return new FebsResponse().success().message("操作成功"); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse delete(String id) { |
| | | AiProductQuestion entity = this.getById(id); |
| | | if(ObjectUtil.isNotNull( entity)){ |
| | |
| | | Integer questionCnt = aiProductQuestionJob.getQuestionCnt(); |
| | | Integer questionDoneCnt = aiProductQuestionJob.getQuestionDoneCnt(); |
| | | if (questionCnt <= questionDoneCnt){ |
| | | aiProductQuestionJob.setState(2); |
| | | aiProductQuestionJobMapper.update(null, |
| | | Wrappers.lambdaUpdate(AiProductQuestionJob.class) |
| | | .set(AiProductQuestionJob::getState, 2) |
| | |
| | | .eq(AiProductQuestionJob::getId, id)); |
| | | return; |
| | | } |
| | | // int i = questionCnt - questionDoneCnt; |
| | | // if (i >= 5){ |
| | | // i = 5; |
| | | // } |
| | | int i = questionCnt - questionDoneCnt; |
| | | if (i >= 5){ |
| | | i = 5; |
| | | } |
| | | AiProductQuestionAiDto dto = new AiProductQuestionAiDto(); |
| | | String jsonFormat = "{\"question_list\":[{\"title\": \"消费者对透明质酸的主要担忧是什么?\",\"answer_list\":[{\"answer\": \"消费者担心透明质酸维持时间短,效果不明显。\",\"type\": 1,\"analysis\": \"\"},{\"answer\": \"消费者担心透明质酸注射后可能出现移位、凹陷、馒化、僵硬以及炎症反应。\",\"type\": 1,\"analysis\": \"\"},{\"answer\": \"消费者的主要担忧包括效果不明显、维持时间短、注射后出现移位、凹陷、馒化、僵硬以及炎症反应。他们希望既达到理想效果,又避免这些副作用。\",\"type\": 2,\"analysis\": \"标准答案涵盖了消费者对透明质酸的所有主要担忧,既包括效果问题,也涵盖副作用风险,全面反映消费者心理需求。\"}]}]} "; |
| | | dto.setJsonFormat(jsonFormat); |
| | |
| | | aiProductQuestion.setProductCategoryId(productCategoryId); |
| | | aiProductQuestion.setTitle(title); |
| | | aiProductQuestion.setDifficulty(difficulty); |
| | | aiProductQuestion.setJobId(id); |
| | | aiProductQuestion.setCreatedTime(createdTime); |
| | | this.save(aiProductQuestion); |
| | | JSONArray answerList = questionObj.getJSONArray("answer_list"); |
| | |
| | | aiProductQuestionItem.setAnswer(answer.getStr("answer")); |
| | | aiProductQuestionItem.setCorrectAnswer(answer.getInt("type") == 2 ? 1 : 0); |
| | | aiProductQuestionItem.setAnswerAnalysis(answer.getStr("analysis")); |
| | | aiProductQuestionItem.setJobId( id); |
| | | aiProductQuestionItem.setCreatedTime(createdTime); |
| | | aiProductQuestionItemService.getBaseMapper().insert(aiProductQuestionItem); |
| | | } |
| | |
| | | Wrappers.lambdaUpdate(AiProductQuestionJob.class) |
| | | .set(AiProductQuestionJob::getQuestionDoneCnt, questionDoneCnt + questionList.size()) |
| | | .set(AiProductQuestionJob::getUpdatedTime, new Date()) |
| | | .set(AiProductQuestionJob::getState, 1) |
| | | .eq(AiProductQuestionJob::getId, id)); |
| | | } |
| | | AiProductQuestionJob aiProductQuestionJobDone = aiProductQuestionJobMapper.selectById(id); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse importNewProductQuestion(MultipartFile file, String categoryId, String companyId) { |
| | | public FebsResponse importNewProductQuestion(MultipartFile file, String categoryId, String companyId, Integer difficulty) { |
| | | try { |
| | | if (file.isEmpty()) { |
| | | return new FebsResponse().fail().message("文件不能为空"); |
| | |
| | | question.setCompanyId(companyId); |
| | | question.setProductCategoryId(categoryId); |
| | | question.setTitle(title); |
| | | question.setDifficulty(2); // 默认中等难度 |
| | | question.setDifficulty(difficulty); // 默认中等难度 |
| | | question.setState(0); // 默认启用 |
| | | question.setCreatedTime(new Date()); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public IPage<AdminQuestionInfoVo> jobChild(QueryRequest request, AiProductQuestionJob dto) { |
| | | |
| | | Page<AdminQuestionInfoVo> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | return aiProductQuestionMapper.selectJobChildPage(page, dto); |
| | | } |
| | | |
| | | private void saveQuestionWithItems(AiProductQuestion question, List<AiProductQuestionItem> items) { |
| | | // 保存题目(新增一次) |
| | | this.save(question); |