You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
3.1 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
1 month ago
2 months ago
  1. package com.example.demo.controller;
  2. import com.example.demo.domain.entity.Admin;
  3. import com.example.demo.domain.vo.WorkbenchCard;
  4. import com.example.demo.mapper.StatisticsMapper;
  5. import com.example.demo.service.GeneralService;
  6. import com.example.demo.service.StatisticsService;
  7. import com.example.demo.service.WorkbenchService;
  8. import lombok.RequiredArgsConstructor;
  9. import lombok.extern.slf4j.Slf4j;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.http.HttpStatus;
  12. import org.springframework.http.ResponseEntity;
  13. import org.springframework.security.core.annotation.AuthenticationPrincipal;
  14. import org.springframework.web.bind.annotation.*;
  15. import java.util.Date;
  16. import java.util.List;
  17. import java.util.Map;
  18. /**
  19. * @program: gold-java
  20. * @ClassName WorkbenchController
  21. * @description: 工作台相关
  22. * @author: Ethan
  23. * @create: 202506-17 17:13
  24. * @Version 1.0
  25. **/
  26. @RestController
  27. @RequestMapping("/workbench")
  28. @RequiredArgsConstructor
  29. @CrossOrigin
  30. @Slf4j
  31. public class WorkbenchController {
  32. @Autowired
  33. private WorkbenchService workbenchService;
  34. @Autowired
  35. private StatisticsService statisticsService;
  36. @Autowired
  37. private GeneralService generalService;
  38. @Autowired
  39. private StatisticsMapper statisticsMapper;
  40. /*
  41. 获取各地区工作台卡片的数据
  42. */
  43. @PostMapping("getCard")
  44. public ResponseEntity<WorkbenchCard> card1(@RequestBody WorkbenchCard workbench,
  45. @AuthenticationPrincipal Admin admin) {
  46. if (admin == null) {
  47. return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(null);
  48. }
  49. String account = admin.getAccount();
  50. //获取当前用户的市场列表
  51. List<String> markets = generalService.getRoleMarket(account);
  52. WorkbenchCard result;
  53. //判断是否是总部
  54. if (markets != null && markets.contains("总部")) {
  55. result = workbenchService.getCardCache(markets);//走缓存,拿全部市场的缓存数据
  56. } else {
  57. result = workbenchService.getCard(markets);//不走缓存,计算卡片属性
  58. }
  59. return ResponseEntity.ok(result);
  60. }
  61. /*
  62. 获取各地区工作台图表的数据
  63. */
  64. @PostMapping("getGraph")
  65. public ResponseEntity<WorkbenchCard> graph1(@RequestBody WorkbenchCard workbench, @AuthenticationPrincipal Admin admin) {
  66. String account = admin.getAccount();
  67. List<String> markets = generalService.getRoleMarket(account);
  68. workbench.setMarkets(markets);
  69. WorkbenchCard result =workbenchService.getGraph(workbench.getStartDate(),workbench.getEndDate(),workbench.getMarkets());
  70. return ResponseEntity.ok(result);
  71. }
  72. /*
  73. 更新统计表并获取卡片数据
  74. */
  75. /*@PostMapping("updateCard")
  76. public ResponseEntity<WorkbenchCard> updateCard(@RequestBody WorkbenchCard workbench){
  77. statisticsService.runHourlyTaskPart1(); //更新余量数据
  78. statisticsService.runHourlyTaskPart2(); //更新余量外数据
  79. WorkbenchCard result =workbenchService.getCard(workbench.getMarkets()); //获取卡片数据
  80. return ResponseEntity.ok(result);
  81. }*/
  82. }