package com.slibra.web.controller.business; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONWriter; import com.slibra.business.domain.TXinyiChatRecord; import com.slibra.business.domain.TXinyiWarningRecord; import com.slibra.business.mapper.*; import com.slibra.business.req.DecisionReq; import com.slibra.business.service.IFrontService; import com.slibra.common.core.controller.BaseController; import com.slibra.common.core.domain.AjaxResult; import com.slibra.common.core.page.TableDataInfo; import com.slibra.common.exception.ServiceException; import com.slibra.common.utils.SecurityUtils; import com.slibra.common.utils.StringUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; /** * 前端用户相关接口 */ @RestController @RequestMapping("/front") @Slf4j public class FrontController extends BaseController { @Autowired private IFrontService frontService; @Autowired private TXinyiChatRecordMapper xinyiChatRecordMapper; @Autowired private TXinyiWarningRecordMapper xinyiWarningRecordMapper; @Autowired private TXinyiAgentAssistantMapper xinyiAgentAssistantMapper; @Autowired private TXinyiIndustryMapper xinyiIndustryMapper; /** * 获取大屏的实时数据 + 统计数据 * @return */ @GetMapping(value = "/realTimeData") public AjaxResult realTimeData() { log.info("进入了 获取大屏的实时数据 + 统计数据 接口"); return AjaxResult.success(frontService.countInfo()); } /** * 分页获取大模型的问答记录 * @param tXinyiChatRecord * @return */ @GetMapping("/bigModel/qa/pageList") public TableDataInfo qaPageList(TXinyiChatRecord tXinyiChatRecord) { log.info("进入了 分页获取大模型的问答记录 接口"); //获取登录用户信息 Long userId = SecurityUtils.getUserId(); tXinyiChatRecord.setUserId(String.valueOf(userId)); startPage(); return getDataTable(xinyiChatRecordMapper.selectTXinyiChatRecordFirstList(tXinyiChatRecord)); } /** * 通过sessionId获取某个用户的问答列表 * @param tXinyiChatRecord * @return */ @GetMapping("/bigModel/qa/qaListBySessionId") public AjaxResult qaListBySessionId(TXinyiChatRecord tXinyiChatRecord) { log.info("进入了 通过sessionId获取某个用户的问答列表 接口"); String sessionId = tXinyiChatRecord.getSessionId(); if(StringUtils.isBlank(sessionId)) throw new ServiceException("必须传入sessionId"); //获取登录用户信息 Long userId = SecurityUtils.getUserId(); tXinyiChatRecord.setUserId(String.valueOf(userId)); return AjaxResult.success(xinyiChatRecordMapper.selectTXinyiChatRecordList(tXinyiChatRecord)); } /** * * 获取报警统计信息接口 * @return */ @GetMapping("/bigModel/warningCount") public AjaxResult warningCount() { log.info("进入了获取报警统计信息接口"); return AjaxResult.success(frontService.warningCount()); } /** * 首页报警记录(按时间倒叙 取十条) * @return */ @GetMapping("/bigModel/home/warningList") public AjaxResult homeWarningList() { log.info("进入了 首页报警记录(按时间倒叙 取十条) 接口"); return AjaxResult.success(frontService.homeWarningList()); } /** * 获取 信义推荐问答列表 * type: 0专家问答 1水质报警 2生化报警 3预测预警 * @return */ @GetMapping("/bigModel/home/recommendQAList/{type}") public AjaxResult recommendQAList(@PathVariable Integer type) { log.info("进入了 获取 信义推荐问答列表 接口"); return AjaxResult.success(frontService.recommendQAList(type)); } //报警+预警记录列表 【水质报警 1生化报警 2预测报警】 /** * 分页获取大模型的问答记录 * @param tXinyiWarningRecord * @return */ @GetMapping("/bigModel/warning/pageList") public TableDataInfo warningPageList(TXinyiWarningRecord tXinyiWarningRecord) { log.info("进入了 分页获取大模型的问答记录 接口"); startPage(); return getDataTable(xinyiWarningRecordMapper.selectTXinyiWarningRecordList(tXinyiWarningRecord)); } /** * 获取 后台配置的智能助手列表 * @return */ @GetMapping("/bigModel/agentAssistant/list") public AjaxResult agentAssistantList() { log.info("进入了 获取 后台配置的智能助手列表 接口"); return AjaxResult.success(xinyiAgentAssistantMapper.selectTXinyiAgentAssistantList(null)); } @GetMapping("/test/data") public void testData(){ List decisionReqs = this.xinyiIndustryMapper.selectLast10RecordsForDecisionOnlyIndustry(); System.out.println(JSON.toJSONString(decisionReqs, JSONWriter.Feature.WriteNulls)); } }