FrontController.java 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. package com.slibra.web.controller.business;
  2. import com.alibaba.fastjson2.JSON;
  3. import com.alibaba.fastjson2.JSONWriter;
  4. import com.slibra.business.domain.TXinyiChatRecord;
  5. import com.slibra.business.domain.TXinyiWarningRecord;
  6. import com.slibra.business.mapper.*;
  7. import com.slibra.business.req.DecisionReq;
  8. import com.slibra.business.service.IFrontService;
  9. import com.slibra.common.core.controller.BaseController;
  10. import com.slibra.common.core.domain.AjaxResult;
  11. import com.slibra.common.core.page.TableDataInfo;
  12. import com.slibra.common.exception.ServiceException;
  13. import com.slibra.common.utils.SecurityUtils;
  14. import com.slibra.common.utils.StringUtils;
  15. import lombok.extern.slf4j.Slf4j;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.web.bind.annotation.GetMapping;
  18. import org.springframework.web.bind.annotation.PathVariable;
  19. import org.springframework.web.bind.annotation.RequestMapping;
  20. import org.springframework.web.bind.annotation.RestController;
  21. import java.util.List;
  22. /**
  23. * 前端用户相关接口
  24. */
  25. @RestController
  26. @RequestMapping("/front")
  27. @Slf4j
  28. public class FrontController extends BaseController {
  29. @Autowired
  30. private IFrontService frontService;
  31. @Autowired
  32. private TXinyiChatRecordMapper xinyiChatRecordMapper;
  33. @Autowired
  34. private TXinyiWarningRecordMapper xinyiWarningRecordMapper;
  35. @Autowired
  36. private TXinyiAgentAssistantMapper xinyiAgentAssistantMapper;
  37. @Autowired
  38. private TXinyiIndustryMapper xinyiIndustryMapper;
  39. /**
  40. * 获取大屏的实时数据 + 统计数据
  41. * @return
  42. */
  43. @GetMapping(value = "/realTimeData")
  44. public AjaxResult realTimeData()
  45. {
  46. log.info("进入了 获取大屏的实时数据 + 统计数据 接口");
  47. return AjaxResult.success(frontService.countInfo());
  48. }
  49. /**
  50. * 分页获取大模型的问答记录
  51. * @param tXinyiChatRecord
  52. * @return
  53. */
  54. @GetMapping("/bigModel/qa/pageList")
  55. public TableDataInfo qaPageList(TXinyiChatRecord tXinyiChatRecord)
  56. {
  57. log.info("进入了 分页获取大模型的问答记录 接口");
  58. //获取登录用户信息
  59. Long userId = SecurityUtils.getUserId();
  60. tXinyiChatRecord.setUserId(String.valueOf(userId));
  61. startPage();
  62. return getDataTable(xinyiChatRecordMapper.selectTXinyiChatRecordFirstList(tXinyiChatRecord));
  63. }
  64. /**
  65. * 通过sessionId获取某个用户的问答列表
  66. * @param tXinyiChatRecord
  67. * @return
  68. */
  69. @GetMapping("/bigModel/qa/qaListBySessionId")
  70. public AjaxResult qaListBySessionId(TXinyiChatRecord tXinyiChatRecord)
  71. {
  72. log.info("进入了 通过sessionId获取某个用户的问答列表 接口");
  73. String sessionId = tXinyiChatRecord.getSessionId();
  74. if(StringUtils.isBlank(sessionId))
  75. throw new ServiceException("必须传入sessionId");
  76. //获取登录用户信息
  77. Long userId = SecurityUtils.getUserId();
  78. tXinyiChatRecord.setUserId(String.valueOf(userId));
  79. return AjaxResult.success(xinyiChatRecordMapper.selectTXinyiChatRecordList(tXinyiChatRecord));
  80. }
  81. /**
  82. *
  83. * 获取报警统计信息接口
  84. * @return
  85. */
  86. @GetMapping("/bigModel/warningCount")
  87. public AjaxResult warningCount()
  88. {
  89. log.info("进入了获取报警统计信息接口");
  90. return AjaxResult.success(frontService.warningCount());
  91. }
  92. /**
  93. * 首页报警记录(按时间倒叙 取十条)
  94. * @return
  95. */
  96. @GetMapping("/bigModel/home/warningList")
  97. public AjaxResult homeWarningList()
  98. {
  99. log.info("进入了 首页报警记录(按时间倒叙 取十条) 接口");
  100. return AjaxResult.success(frontService.homeWarningList());
  101. }
  102. /**
  103. * 获取 信义推荐问答列表
  104. * type: 0专家问答 1水质报警 2生化报警 3预测预警
  105. * @return
  106. */
  107. @GetMapping("/bigModel/home/recommendQAList/{type}")
  108. public AjaxResult recommendQAList(@PathVariable Integer type)
  109. {
  110. log.info("进入了 获取 信义推荐问答列表 接口");
  111. return AjaxResult.success(frontService.recommendQAList(type));
  112. }
  113. //报警+预警记录列表 【水质报警 1生化报警 2预测报警】
  114. /**
  115. * 分页获取大模型的问答记录
  116. * @param tXinyiWarningRecord
  117. * @return
  118. */
  119. @GetMapping("/bigModel/warning/pageList")
  120. public TableDataInfo warningPageList(TXinyiWarningRecord tXinyiWarningRecord)
  121. {
  122. log.info("进入了 分页获取大模型的问答记录 接口");
  123. startPage();
  124. return getDataTable(xinyiWarningRecordMapper.selectTXinyiWarningRecordList(tXinyiWarningRecord));
  125. }
  126. /**
  127. * 获取 后台配置的智能助手列表
  128. * @return
  129. */
  130. @GetMapping("/bigModel/agentAssistant/list")
  131. public AjaxResult agentAssistantList()
  132. {
  133. log.info("进入了 获取 后台配置的智能助手列表 接口");
  134. return AjaxResult.success(xinyiAgentAssistantMapper.selectTXinyiAgentAssistantList(null));
  135. }
  136. @GetMapping("/test/data")
  137. public void testData(){
  138. List<DecisionReq> decisionReqs = this.xinyiIndustryMapper.selectLast10RecordsForDecisionOnlyIndustry();
  139. System.out.println(JSON.toJSONString(decisionReqs, JSONWriter.Feature.WriteNulls));
  140. }
  141. }