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.

84 lines
2.9 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.entity.Statistics;
  4. import com.example.demo.domain.vo.TestRequest;
  5. import com.example.demo.domain.vo.WorkbenchCard;
  6. import com.example.demo.mapper.StatisticsMapper;
  7. import com.example.demo.service.GeneralService;
  8. import com.example.demo.service.StatisticsService;
  9. import com.example.demo.service.WorkbenchService;
  10. import lombok.RequiredArgsConstructor;
  11. import lombok.extern.slf4j.Slf4j;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.http.HttpStatus;
  14. import org.springframework.http.ResponseEntity;
  15. import org.springframework.security.core.Authentication;
  16. import org.springframework.security.core.annotation.AuthenticationPrincipal;
  17. import org.springframework.security.core.context.SecurityContextHolder;
  18. import org.springframework.web.bind.annotation.*;
  19. import java.util.Date;
  20. import java.util.List;
  21. import java.util.Map;
  22. /**
  23. * @program: gold-java
  24. * @ClassName WorkbenchController
  25. * @description: 工作台相关
  26. * @author: Ethan
  27. * @create: 202506-17 17:13
  28. * @Version 1.0
  29. **/
  30. @RestController
  31. @RequestMapping("/workbench")
  32. @RequiredArgsConstructor
  33. @CrossOrigin
  34. @Slf4j
  35. public class WorkbenchController {
  36. @Autowired
  37. private WorkbenchService workbenchService;
  38. @Autowired
  39. private StatisticsService statisticsService;
  40. @Autowired
  41. private GeneralService generalService;
  42. @Autowired
  43. private StatisticsMapper statisticsMapper;
  44. /*
  45. 获取各地区工作台卡片的数据
  46. */
  47. @PostMapping("getCard")
  48. public ResponseEntity<WorkbenchCard> card1(@RequestBody WorkbenchCard workbench,
  49. @AuthenticationPrincipal Admin admin) throws Exception{
  50. if (admin != null) {
  51. String account = admin.getAccount();
  52. List<String> markets = generalService.getRoleMarket(account);
  53. WorkbenchCard result = workbenchService.getCard(markets);
  54. return ResponseEntity.ok(result);
  55. } else {
  56. return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(null);
  57. }
  58. }
  59. /*
  60. 获取各地区工作台图表的数据
  61. */
  62. @PostMapping("getGraph")
  63. public ResponseEntity<WorkbenchCard> graph1(@RequestBody WorkbenchCard workbench){
  64. WorkbenchCard result =workbenchService.getGraph(workbench.getStartDate(),workbench.getEndDate(),workbench.getMarkets());
  65. return ResponseEntity.ok(result);
  66. }
  67. /*
  68. 更新统计表并获取卡片数据
  69. */
  70. /*@PostMapping("updateCard")
  71. public ResponseEntity<WorkbenchCard> updateCard(@RequestBody WorkbenchCard workbench){
  72. statisticsService.runHourlyTaskPart1(); //更新余量数据
  73. statisticsService.runHourlyTaskPart2(); //更新余量外数据
  74. WorkbenchCard result =workbenchService.getCard(workbench.getMarkets()); //获取卡片数据
  75. return ResponseEntity.ok(result);
  76. }*/
  77. }