提交 | 用户 | 时间
|
139c6a
|
1 |
package com.iailab.module.data.api.controller.admin; |
9100b0
|
2 |
|
潘 |
3 |
import com.iailab.framework.common.pojo.CommonResult; |
|
4 |
import com.iailab.framework.common.util.object.ConvertUtils; |
2056b4
|
5 |
import com.iailab.framework.tenant.core.context.TenantContextHolder; |
9100b0
|
6 |
import com.iailab.module.data.api.ind.dto.ApiIndItemQueryDTO; |
潘 |
7 |
import com.iailab.module.data.api.ind.dto.ApiIndItemValueDTO; |
|
8 |
import com.iailab.module.data.ind.collection.IndItemCollector; |
|
9 |
import com.iailab.module.data.ind.item.vo.IndItemValueVO; |
|
10 |
import io.swagger.v3.oas.annotations.Operation; |
|
11 |
import io.swagger.v3.oas.annotations.tags.Tag; |
|
12 |
import lombok.extern.slf4j.Slf4j; |
|
13 |
import org.springframework.beans.factory.annotation.Autowired; |
|
14 |
import org.springframework.web.bind.annotation.GetMapping; |
|
15 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
16 |
import org.springframework.web.bind.annotation.RequestParam; |
|
17 |
import org.springframework.web.bind.annotation.RestController; |
|
18 |
|
|
19 |
import javax.annotation.security.PermitAll; |
2056b4
|
20 |
import java.util.ArrayList; |
9100b0
|
21 |
import java.util.List; |
潘 |
22 |
|
|
23 |
import static com.iailab.framework.common.pojo.CommonResult.success; |
|
24 |
|
|
25 |
/** |
|
26 |
* @author PanZhibao |
|
27 |
* @Description |
|
28 |
* @createTime 2024年10月10日 |
|
29 |
*/ |
|
30 |
@Slf4j |
|
31 |
@RestController |
|
32 |
@RequestMapping("/api/data/ind-item") |
|
33 |
@Tag(name = "指标") |
9961c7
|
34 |
public class ApiIndItemController { |
9100b0
|
35 |
|
潘 |
36 |
@Autowired |
|
37 |
private IndItemCollector indItemCollector; |
|
38 |
|
|
39 |
@PermitAll |
|
40 |
@GetMapping("/query-ind/default-value") |
|
41 |
@Operation(summary = "查询指标默认值") |
|
42 |
public CommonResult<List<ApiIndItemValueDTO>> queryIndItemDefaultValue(@RequestParam String itemNo) { |
2056b4
|
43 |
TenantContextHolder.setTenantId(161L); |
9100b0
|
44 |
List<IndItemValueVO> list = indItemCollector.queryValue(itemNo); |
2056b4
|
45 |
List<ApiIndItemValueDTO> dtoList = new ArrayList<>(); |
J |
46 |
list.forEach(item -> { |
|
47 |
ApiIndItemValueDTO dto = new ApiIndItemValueDTO(); |
|
48 |
dto.setDataTime(item.getDataTime()); |
|
49 |
dto.setDataValue(item.getDataValue().doubleValue()); |
|
50 |
dtoList.add(dto); |
|
51 |
}); |
|
52 |
return success(dtoList); |
9100b0
|
53 |
|
潘 |
54 |
} |
|
55 |
|
|
56 |
@PermitAll |
|
57 |
@GetMapping("/query-ind/history-value") |
|
58 |
@Operation(summary = "查询指标历史值") |
|
59 |
public CommonResult<List<ApiIndItemValueDTO>> queryIndItemHistoryValue(@RequestParam ApiIndItemQueryDTO dto) { |
|
60 |
List<IndItemValueVO> list = indItemCollector.queryValue(dto.getItemNo(), dto.getStart(), dto.getEnd()); |
|
61 |
return success(ConvertUtils.sourceToTarget(list, ApiIndItemValueDTO.class)); |
|
62 |
} |
|
63 |
} |