| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- package com.jjt.biz.controller;
- import com.jjt.biz.domain.BizObjMetrics;
- import com.jjt.biz.service.IBizObjMetricsService;
- import com.jjt.common.annotation.Log;
- import com.jjt.common.core.controller.BaseController;
- import com.jjt.common.core.domain.AjaxResult;
- import com.jjt.common.core.page.TableDataInfo;
- import com.jjt.common.enums.BusinessType;
- import com.jjt.common.utils.poi.ExcelUtil;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import org.springframework.security.access.prepost.PreAuthorize;
- import org.springframework.web.bind.annotation.*;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletResponse;
- import java.text.DecimalFormat;
- import java.time.LocalDateTime;
- import java.time.ZoneOffset;
- import java.util.*;
- /**
- * 业务对象指标Controller
- *
- * @author jjt
- * @date 2024-08-09
- */
- @Api(tags = "业务对象指标")
- @RestController
- @RequestMapping("/obj/metrics")
- public class BizObjMetricsController extends BaseController {
- @Resource
- private IBizObjMetricsService bizObjMetricsService;
- /**
- * 查询业务对象指标列表
- */
- @ApiOperation("查询业务对象指标列表")
- @PreAuthorize("@ss.hasPermi('obj:metrics:list')")
- @GetMapping("/list")
- public TableDataInfo list(BizObjMetrics bizObjMetrics) {
- startPage();
- List<BizObjMetrics> list = bizObjMetricsService.selectBizObjMetricsList(bizObjMetrics);
- return getDataTable(list);
- }
- /**
- * 导出业务对象指标列表
- */
- @ApiOperation("导出业务对象指标列表")
- @PreAuthorize("@ss.hasPermi('obj:metrics:export')")
- @Log(title = "业务对象指标", businessType = BusinessType.EXPORT)
- @PostMapping("/export")
- public void export(HttpServletResponse response, BizObjMetrics bizObjMetrics) {
- List<BizObjMetrics> list = bizObjMetricsService.selectBizObjMetricsList(bizObjMetrics);
- ExcelUtil<BizObjMetrics> util = new ExcelUtil<BizObjMetrics>(BizObjMetrics.class);
- util.exportExcel(response, list, "业务对象指标数据");
- }
- /**
- * 获取业务对象指标详细信息
- */
- @ApiOperation("获取业务对象指标详细信息")
- @PreAuthorize("@ss.hasPermi('obj:metrics:query')")
- @GetMapping(value = "/{objMetricsId}")
- public AjaxResult getInfo(@PathVariable("objMetricsId") Long objMetricsId) {
- BizObjMetrics metrics = bizObjMetricsService.selectBizObjMetricsByObjMetricsId(objMetricsId);
- return success(bizObjMetricsService.selectBizObjMetricsByObjMetricsId(objMetricsId));
- }
- /**
- * 获取业务对象指标详细信息
- */
- @ApiOperation("获取业务对象历史趋势")
- @GetMapping(value = "/history/{objMetricsId}")
- public AjaxResult history(@PathVariable("objMetricsId") Long objMetricsId) {
- List<Long> times = new ArrayList<>();
- List<Float> values = new ArrayList<>();
- LocalDateTime ed = LocalDateTime.now();
- LocalDateTime st = ed.minusDays(7);
- Random r = new Random();
- DecimalFormat df = new DecimalFormat("#0.00");
- do {
- long time = st.toEpochSecond(ZoneOffset.ofHours(8)) * 1000;
- times.add(time);
- float f = r.nextFloat() * 100;
- // System.err.println(df.format(f));
- values.add(Float.parseFloat(df.format(f)));
- st = st.plusMinutes(15);
- } while (!st.isAfter(ed));
- Map<String, Object> map = new HashMap<>(16);
- map.put("times", times);
- map.put("values", values);
- return AjaxResult.success(map);
- }
- /**
- * 新增业务对象指标
- */
- @ApiOperation("新增业务对象指标")
- @PreAuthorize("@ss.hasPermi('obj:metrics:add')")
- @Log(title = "业务对象指标", businessType = BusinessType.INSERT)
- @PostMapping
- public AjaxResult add(@RequestBody BizObjMetrics bizObjMetrics) {
- return toAjax(bizObjMetricsService.insertBizObjMetrics(bizObjMetrics));
- }
- /**
- * 修改业务对象指标
- */
- @ApiOperation("修改业务对象指标")
- @PreAuthorize("@ss.hasPermi('obj:metrics:edit')")
- @Log(title = "业务对象指标", businessType = BusinessType.UPDATE)
- @PutMapping
- public AjaxResult edit(@RequestBody BizObjMetrics bizObjMetrics) {
- return toAjax(bizObjMetricsService.updateBizObjMetrics(bizObjMetrics));
- }
- /**
- * 删除业务对象指标
- */
- @ApiOperation("删除业务对象指标")
- @PreAuthorize("@ss.hasPermi('obj:metrics:remove')")
- @Log(title = "业务对象指标", businessType = BusinessType.DELETE)
- @DeleteMapping("/{objMetricsIds}")
- public AjaxResult remove(@PathVariable Long[] objMetricsIds) {
- return toAjax(bizObjMetricsService.deleteBizObjMetricsByObjMetricsIds(objMetricsIds));
- }
- }
|