AnalysisCommonController.java 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. package com.redxun.knowledge.analysis.controller;
  2. import com.baomidou.mybatisplus.core.metadata.IPage;
  3. import com.redxun.common.annotation.ClassDefine;
  4. import com.redxun.common.base.entity.JsonPageResult;
  5. import com.redxun.common.base.entity.JsonResult;
  6. import com.redxun.common.base.entity.QueryData;
  7. import com.redxun.knowledge.analysis.entity.dto.DownloadDto;
  8. import com.redxun.knowledge.analysis.entity.dto.PersonVisitDto;
  9. import com.redxun.knowledge.analysis.entity.page.MyJsonResult;
  10. import com.redxun.knowledge.analysis.entity.vo.*;
  11. import com.redxun.knowledge.analysis.service.*;
  12. import com.redxun.knowledge.utils.DateUtils;
  13. import io.swagger.annotations.Api;
  14. import io.swagger.annotations.ApiOperation;
  15. import lombok.extern.slf4j.Slf4j;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.validation.BindingResult;
  18. import org.springframework.web.bind.annotation.*;
  19. import javax.servlet.http.HttpServletResponse;
  20. import javax.validation.Valid;
  21. import java.util.*;
  22. /**
  23. * 文件名: CommonController
  24. * 作者: zizg
  25. * 时间: 2023/3/17
  26. * 描述:
  27. * 修改人:
  28. * 修改时间:
  29. * 修改内容:
  30. */
  31. @Slf4j
  32. @RestController
  33. @RequestMapping("/api-knowledge/analysis")
  34. @Api(tags = "业务--系统页面访问量统计")
  35. @ClassDefine(title = "业务--系统页面访问量统计", alias = "CommonController", path = "/api-knowledge/analysis", packages = "analysis", packageName = "子系统名称")
  36. public class AnalysisCommonController {
  37. @Autowired
  38. private AnalysisCommonServiceImpl analysisCommonService;
  39. @Autowired
  40. private AnalysisAlbumServiceImpl analysisAlbumService;
  41. @Autowired
  42. private AnalysisMapServiceImpl analysisMapService;
  43. @Autowired
  44. private AnalysisSearchServiceImpl analysisSearchService;
  45. @Autowired
  46. private AnalysisSynthesizeServiceImpl analysisSynthesizeService;
  47. @Autowired
  48. private AnalysisDownloadService analysisDownloadService;
  49. @ApiOperation("PC 各模块整体数量统计")
  50. @GetMapping("totalAmount")
  51. public JsonResult totalAmount() {
  52. Map<String, Object> result = analysisCommonService.totalAmount();
  53. return JsonResult.getSuccessResult(result);
  54. }
  55. @ApiOperation("PC 获取搜索服务访问量分布柱状图数据")
  56. @GetMapping("searchVisitHistogram")
  57. public JsonResult searchVisitHistogram() {
  58. SearchVisitHistogramVo searchVisitHistogramVo = analysisCommonService.searchVisitHistogram();
  59. return JsonResult.getSuccessResult(searchVisitHistogramVo);
  60. }
  61. @ApiOperation("PC 获取搜索服务分词的词云数据")
  62. @GetMapping("searchParticipleWordCloud")
  63. public JsonResult searchParticipleWordCloud(@RequestParam(value = "tops", required = false, defaultValue = "100") Integer tops) {
  64. List<SearchParticipleWordCloudVo> result = analysisCommonService.searchParticipleWordCloud(tops);
  65. return JsonResult.getSuccessResult(result);
  66. }
  67. @ApiOperation("PC 查询各类型(维基、文档)知识数量")
  68. @GetMapping("knowledgeTypeAmount")
  69. public JsonResult knowledgeTypeAmount() {
  70. Map<String, Object> result = analysisCommonService.knowledgeTypeAmount();
  71. return JsonResult.getSuccessResult(result);
  72. }
  73. @ApiOperation("知识类型访问量分布")
  74. @GetMapping("knowledgeTypeVisitProportion")
  75. public JsonResult knowledgeTypeVisitProportion(@RequestParam("type") String type) {
  76. Map<String, Object> result = analysisCommonService.knowledgeTypeVisitProportion(type);
  77. return JsonResult.getSuccessResult(result);
  78. }
  79. @ApiOperation("各一级分类知识创建数量")
  80. @GetMapping("level1KnowledgeHistogram")
  81. public JsonResult level1KnowledgeHistogram(@RequestParam("type") String type,
  82. @RequestParam(value = "sort", required = false) String sort) {
  83. List<KnowledgeCategoryVo> knowledgeCategoryVoList = analysisCommonService.level1KnowledgeHistogram(type, sort);
  84. return JsonResult.getSuccessResult(knowledgeCategoryVoList);
  85. }
  86. @ApiOperation("组织创建知识数量")
  87. @PostMapping("organizationKnowledges")
  88. public JsonPageResult organizationKnowledges(@RequestBody QueryData queryData) {
  89. JsonPageResult jsonResult = JsonPageResult.getSuccess("");
  90. IPage knowledgeCompanyVoList = analysisCommonService.organizationKnowledges(queryData);
  91. jsonResult.setPageData(knowledgeCompanyVoList);
  92. return jsonResult;
  93. }
  94. @ApiOperation("组织创建知识数量(新)")
  95. @GetMapping("organizationKnowledge")
  96. public JsonResult organizationKnowledge(@RequestParam(value = "type",required = false) String type,
  97. @RequestParam("organizationId") String organizationId,
  98. @RequestParam(value = "createTime",required = false) String createTime,
  99. @RequestParam(value = "endTime",required = false) String endTime) {
  100. KnowledgeCompanyVo result = analysisCommonService.organizationKnowledge(type, organizationId,createTime,endTime);
  101. return JsonResult.getSuccessResult(result);
  102. }
  103. @ApiOperation("人员创建知识数量")
  104. @PostMapping("personKnowledge")
  105. public JsonResult personKnowledge(@RequestBody @Valid PersonVisitDto personVisitDto,BindingResult validResult) {
  106. JsonResult jsonResult = JsonResult.getSuccessResult("");
  107. if (validResult.hasErrors()) {
  108. return jsonResult.setMessage("组织Id不能为空");
  109. }
  110. List<KnowledgeCompanyVo> result = analysisCommonService.personKnowledge(personVisitDto);
  111. return JsonResult.getSuccessResult(result);
  112. }
  113. @ApiOperation("专辑创建总量")
  114. @GetMapping("albumAmount")
  115. public JsonResult albumAmount(@RequestParam("type") String type) {
  116. CreateCountTotal result = analysisAlbumService.albumAmount(type);
  117. return JsonResult.getSuccessResult(result);
  118. }
  119. @ApiOperation("专辑详情Top访问量(pv)统计")
  120. @GetMapping("albumDetailVisits")
  121. public JsonResult albumDetailVisits(@RequestParam("type") String type,
  122. @RequestParam(value = "tops", required = false, defaultValue = "10") Integer tops) {
  123. List<AlbumDetailVisitsVo> result = analysisAlbumService.albumDetailVisits(type, tops);
  124. return JsonResult.getSuccessResult(result);
  125. }
  126. @ApiOperation("各一级分类专辑创建数量")
  127. @GetMapping("level1AlbumHistogram")
  128. public JsonResult level1AlbumHistogram(@RequestParam("type") String type,
  129. @RequestParam(value = "sort", required = false) String sort) {
  130. List<AlbumCategoryVo> result = analysisAlbumService.level1AlbumHistogram(type, sort);
  131. return JsonResult.getSuccessResult(result);
  132. }
  133. @ApiOperation("组织创建和访问专辑数量")
  134. @PostMapping("organizationAlbums")
  135. public JsonPageResult organizationAlbums(@RequestBody QueryData queryData) {
  136. JsonPageResult jsonResult = JsonPageResult.getSuccess("");
  137. IPage result = analysisAlbumService.organizationAlbums(queryData);
  138. jsonResult.setPageData(result);
  139. return jsonResult;
  140. }
  141. @ApiOperation("组织创建和访问专辑数量(新)")
  142. @GetMapping("organizationAlbum")
  143. public JsonResult organizationAlbum(@RequestParam(value = "type",required = false) String type,
  144. @RequestParam("organizationId") String organizationId,
  145. @RequestParam(value = "createTime",required = false) String createTime,
  146. @RequestParam(value = "endTime",required = false) String endTime) {
  147. AlbumCompanyVo result = analysisAlbumService.organizationAlbum(type, organizationId,createTime,endTime);
  148. return JsonResult.getSuccessResult(result);
  149. }
  150. @ApiOperation("人员创建和访问专辑数量")
  151. @PostMapping("personAlbum")
  152. public JsonResult personAlbum(@RequestBody @Valid PersonVisitDto personVisitDto,BindingResult validResult) {
  153. JsonResult jsonResult = JsonResult.getSuccessResult("");
  154. if (validResult.hasErrors()) {
  155. return jsonResult.setMessage("组织Id不能为空");
  156. }
  157. List<AlbumCompanyVo> result = analysisAlbumService.personAlbum(personVisitDto);
  158. return JsonResult.getSuccessResult(result);
  159. }
  160. @ApiOperation("地图创建总量")
  161. @GetMapping("mapAmount")
  162. public JsonResult mapAmount(@RequestParam("type") String type) {
  163. CreateCountTotal result = analysisMapService.mapAmount(type);
  164. return JsonResult.getSuccessResult(result);
  165. }
  166. @ApiOperation("各类型地图创建数量")
  167. @GetMapping("typeMapPie")
  168. public JsonResult typeMapPie(@RequestParam("type") String type) {
  169. List<MapTypeCountVo> result = analysisMapService.typeMapPie(type);
  170. return JsonResult.getSuccessResult(result);
  171. }
  172. @ApiOperation("地图页面访问量")
  173. @GetMapping("mapPageHistogram")
  174. public JsonResult mapPageHistogram(@RequestParam("type") String type) {
  175. List<MapPagePvVo> result = analysisMapService.mapPageHistogram(type);
  176. return JsonResult.getSuccessResult(result);
  177. }
  178. @ApiOperation("组织创建和访问地图数量")
  179. @PostMapping("organizationMaps")
  180. public JsonPageResult organizationMaps(@RequestBody QueryData queryData) {
  181. JsonPageResult jsonResult = JsonPageResult.getSuccess("");
  182. IPage result = analysisMapService.organizationMaps(queryData);
  183. jsonResult.setPageData(result);
  184. return jsonResult;
  185. }
  186. @ApiOperation("组织创建和访问地图数量(新)")
  187. @GetMapping("organizationMap")
  188. public JsonResult organizationMap(@RequestParam(value = "type",required = false) String type,
  189. @RequestParam("organizationId") String organizationId,
  190. @RequestParam(value = "createTime",required = false) String createTime,
  191. @RequestParam(value = "endTime",required = false) String endTime) {
  192. MapCompanyVo result = analysisMapService.organizationMap(type, organizationId,createTime,endTime);
  193. return JsonResult.getSuccessResult(result);
  194. }
  195. @ApiOperation("人员创建和访问地图数量")
  196. @PostMapping("personMap")
  197. public JsonResult personMap(@RequestBody @Valid PersonVisitDto personVisitDto,BindingResult validResult) {
  198. JsonResult jsonResult = JsonResult.getSuccessResult("");
  199. if (validResult.hasErrors()) {
  200. return jsonResult.setMessage("组织Id不能为空");
  201. }
  202. List<MapCompanyVo> result = analysisMapService.personMap(personVisitDto);
  203. return JsonResult.getSuccessResult(result);
  204. }
  205. @ApiOperation("各业务系统分布")
  206. @GetMapping("searchSystemDetailVisits")
  207. public JsonResult searchSystemDetailVisits(@RequestParam("type") String type) {
  208. List<SystemDetailVisitsVo> result = analysisSearchService.searchSystemDetailVisits(type);
  209. return JsonResult.getSuccessResult(result);
  210. }
  211. @ApiOperation("组织访问量")
  212. @PostMapping("organizationSearchs")
  213. public JsonPageResult organizationSearchs(@RequestBody QueryData queryData) {
  214. JsonPageResult jsonResult = JsonPageResult.getSuccess("");
  215. Map<String, List> result = analysisSearchService.organizationSearchs(queryData);
  216. MyJsonResult myJsonResult = new MyJsonResult(result.get("rows"), result.get("columns"));
  217. jsonResult.setResult(myJsonResult);
  218. return jsonResult;
  219. }
  220. @ApiOperation("组织访问量(新)")
  221. @GetMapping("organizationSearch")
  222. public JsonResult organizationSearch(@RequestParam(value = "type",required = false) String type,
  223. @RequestParam("organizationId") String organizationId,
  224. @RequestParam(value = "createTime",required = false) String createTime,
  225. @RequestParam(value = "endTime",required = false) String endTime) {
  226. OrganizationSearchVo result = analysisSearchService.organizationSearch(type, organizationId,createTime,endTime);
  227. return JsonResult.getSuccessResult(result);
  228. }
  229. @ApiOperation("人员访问量")
  230. @PostMapping("personSearch")
  231. public JsonResult personSearch(@RequestBody @Valid PersonVisitDto personVisitDto,BindingResult validResult) {
  232. JsonResult jsonResult = JsonResult.getSuccessResult("");
  233. if (validResult.hasErrors()) {
  234. return jsonResult.setMessage("组织Id不能为空");
  235. }
  236. List<OrganizationSearchVo> result = analysisSearchService.personSearch(personVisitDto);
  237. return JsonResult.getSuccessResult(result);
  238. }
  239. @ApiOperation("用户访问总量")
  240. @GetMapping("totalUserVisits")
  241. public JsonResult totalUserVisits(@RequestParam("module") String module,
  242. @RequestParam("type") String type) {
  243. CreateUserView createUserView = analysisSynthesizeService.totalUserVisits(module, type);
  244. return JsonResult.getSuccessResult(createUserView);
  245. }
  246. @ApiOperation("各板块访问量分布")
  247. @GetMapping("moduleUserVisits")
  248. public JsonResult moduleUserVisits(@RequestParam("type") String type) {
  249. Map<String, Object> map = analysisSynthesizeService.moduleUserVisits(type);
  250. return JsonResult.getSuccessResult(map);
  251. }
  252. @ApiOperation("各板块访问量分布(UV)")
  253. @GetMapping("moduleUserUniqueVisits")
  254. public JsonResult moduleUserUniqueVisits(@RequestParam("type") String type) {
  255. Map<String, Object> map = analysisSynthesizeService.moduleUserUniqueVisits(type);
  256. return JsonResult.getSuccessResult(map);
  257. }
  258. @ApiOperation("组织访问量")
  259. @PostMapping("organizationVisits")
  260. public JsonPageResult organizationVisits(@RequestBody QueryData queryData) {
  261. JsonPageResult jsonResult = JsonPageResult.getSuccess("");
  262. IPage result = analysisSynthesizeService.organizationVisits(queryData);
  263. jsonResult.setPageData(result);
  264. return jsonResult;
  265. }
  266. @ApiOperation("组织访问量(新)")
  267. @GetMapping("organizationVisit")
  268. public JsonResult organizationVisit(@RequestParam(value = "type",required = false) String type,
  269. @RequestParam("organizationId") String organizationId,
  270. @RequestParam(value = "createTime",required = false) String createTime,
  271. @RequestParam(value = "endTime",required = false) String endTime) {
  272. SynthesizeCompanyVo result = analysisSynthesizeService.organizationVisit(type, organizationId,createTime,endTime);
  273. return JsonResult.getSuccessResult(result);
  274. }
  275. @ApiOperation("人员访问量")
  276. @PostMapping("personVisit")
  277. public JsonResult personVisit(@RequestBody @Valid PersonVisitDto personVisitDto, BindingResult validResult) {
  278. JsonResult jsonResult = JsonResult.getSuccessResult("");
  279. if (validResult.hasErrors()) {
  280. return jsonResult.setMessage("组织Id不能为空");
  281. }
  282. List<SynthesizeCompanyVo> result = analysisSynthesizeService.personVisit(personVisitDto);
  283. return jsonResult.setData(result);
  284. }
  285. @ApiOperation("人员模版导出")
  286. @PostMapping("download")
  287. public void download(@RequestBody @Valid DownloadDto downloadDto, BindingResult bindingResult, HttpServletResponse httpServletResponse){
  288. if (bindingResult.hasErrors()){
  289. throw new RuntimeException(bindingResult.toString());
  290. }
  291. analysisDownloadService.download(downloadDto,httpServletResponse);
  292. }
  293. @ApiOperation("展示员工的知识上传数和专辑评论数")
  294. @GetMapping("knowledgeSumAndYelpSumByUserId")
  295. public JsonResult knowledgeSumAndYelpSumByUserId(@RequestParam(value = "beginTime",required = false) String beginTime,
  296. @RequestParam(value = "endTime",required = false) String endTime,
  297. @RequestParam(value = "userId",required = false) String userId){
  298. JsonResult jsonResult = JsonResult.getSuccessResult("");
  299. Map<String,Object> result = analysisCommonService.knowledgeSumAndYelpSumByLogin(beginTime,endTime,userId);
  300. return jsonResult.setData(result);
  301. }
  302. @ApiOperation("展示员工知识上传数和专辑评论数列表")
  303. @GetMapping("knowledgeSumAndYelpSumList")
  304. public JsonResult knowledgeSumAndYelpSumList(@RequestParam(value = "beginTime",required = false) String beginTime,
  305. @RequestParam(value = "endTime",required = false) String endTime,
  306. @RequestParam(value = "type") Integer type){
  307. JsonResult jsonResult = JsonResult.getSuccessResult("");
  308. List<KnowledgeSumAndYelpSumListVo> result = analysisCommonService.knowledgeSumAndYelpSumList(type,beginTime,endTime);
  309. return jsonResult.setData(result);
  310. }
  311. @ApiOperation("员工行为页面返回左上角时间")
  312. @GetMapping("getRoundTime")
  313. public JsonResult getRoundTime(){
  314. JsonResult jsonResult = JsonResult.getSuccessResult("");
  315. Map<String,Object> result = new HashMap<>();
  316. //获取当前年
  317. Calendar calendar = Calendar.getInstance();
  318. int year = calendar.get(Calendar.YEAR);
  319. result.put("beginTime",DateUtils.format(DateUtils.getFirstOfYearByUser(year)));
  320. result.put("endTime",DateUtils.format(new Date()));
  321. return jsonResult.setData(result);
  322. }
  323. }