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
93 lines
3.1 KiB
package com.example.demo.controller;
|
|
|
|
import com.example.demo.domain.entity.Admin;
|
|
import com.example.demo.domain.vo.WorkbenchCard;
|
|
import com.example.demo.mapper.StatisticsMapper;
|
|
import com.example.demo.service.GeneralService;
|
|
import com.example.demo.service.StatisticsService;
|
|
import com.example.demo.service.WorkbenchService;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* @program: gold-java
|
|
* @ClassName WorkbenchController
|
|
* @description: 工作台相关
|
|
* @author: Ethan
|
|
* @create: 2025−06-17 17:13
|
|
* @Version 1.0
|
|
**/
|
|
|
|
@RestController
|
|
@RequestMapping("/workbench")
|
|
@RequiredArgsConstructor
|
|
@CrossOrigin
|
|
@Slf4j
|
|
public class WorkbenchController {
|
|
|
|
@Autowired
|
|
private WorkbenchService workbenchService;
|
|
@Autowired
|
|
private StatisticsService statisticsService;
|
|
@Autowired
|
|
private GeneralService generalService;
|
|
@Autowired
|
|
private StatisticsMapper statisticsMapper;
|
|
|
|
/*
|
|
获取各地区工作台卡片的数据
|
|
*/
|
|
@PostMapping("getCard")
|
|
public ResponseEntity<WorkbenchCard> card1(@RequestBody WorkbenchCard workbench,
|
|
@AuthenticationPrincipal Admin admin) {
|
|
if (admin == null) {
|
|
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(null);
|
|
}
|
|
|
|
String account = admin.getAccount();
|
|
//获取当前用户的市场列表
|
|
List<String> markets = generalService.getRoleMarket(account);
|
|
WorkbenchCard result;
|
|
//判断是否是总部
|
|
if (markets != null && markets.contains("总部")) {
|
|
result = workbenchService.getCardCache(markets);//走缓存,拿全部市场的缓存数据
|
|
} else {
|
|
result = workbenchService.getCard(markets);//不走缓存,计算卡片属性
|
|
}
|
|
|
|
return ResponseEntity.ok(result);
|
|
}
|
|
/*
|
|
获取各地区工作台图表的数据
|
|
*/
|
|
@PostMapping("getGraph")
|
|
public ResponseEntity<WorkbenchCard> graph1(@RequestBody WorkbenchCard workbench, @AuthenticationPrincipal Admin admin) {
|
|
String account = admin.getAccount();
|
|
List<String> markets = generalService.getRoleMarket(account);
|
|
|
|
|
|
workbench.setMarkets(markets);
|
|
WorkbenchCard result =workbenchService.getGraph(workbench.getStartDate(),workbench.getEndDate(),workbench.getMarkets());
|
|
return ResponseEntity.ok(result);
|
|
}
|
|
/*
|
|
更新统计表并获取卡片数据
|
|
*/
|
|
/*@PostMapping("updateCard")
|
|
public ResponseEntity<WorkbenchCard> updateCard(@RequestBody WorkbenchCard workbench){
|
|
statisticsService.runHourlyTaskPart1(); //更新余量数据
|
|
statisticsService.runHourlyTaskPart2(); //更新余量外数据
|
|
|
|
WorkbenchCard result =workbenchService.getCard(workbench.getMarkets()); //获取卡片数据
|
|
return ResponseEntity.ok(result);
|
|
}*/
|
|
}
|