From f88fad1e6c4453d724b4ffc4e8ac9ea6e4e9ef70 Mon Sep 17 00:00:00 2001 From: ICEC <414933307@qq.com> Date: Mon, 6 Jul 2020 20:41:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=86=E5=BA=A6=E4=BB=BB=E6=84=8F=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=8A=A5=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/api/dashboard/density.js | 8 + .../src/views/fx_density/fx_density_30d.vue | 5 +- .../src/views/fx_density/fx_density_72h.vue | 3 +- .../fx_density/fx_density_date_range.vue | 261 ++++++++++++++++++ .../src/views/fx_density/fx_density_group.vue | 3 +- .../DB_Ajax_DashBoard_Density_48102.java | 39 +++ .../controller/DensityController.java | 12 +- 7 files changed, 326 insertions(+), 5 deletions(-) create mode 100644 ruoyi-ui/src/views/fx_density/fx_density_date_range.vue diff --git a/ruoyi-ui/src/api/dashboard/density.js b/ruoyi-ui/src/api/dashboard/density.js index 6c3fe8898..88fb7d7fb 100644 --- a/ruoyi-ui/src/api/dashboard/density.js +++ b/ruoyi-ui/src/api/dashboard/density.js @@ -19,3 +19,11 @@ export function getDensityGroup() { method: 'get' }) } + + +export function getDensityDataRange(fDateStart,fDateEnd) { + return request({ + url: '/fx_density/getDensityDataRange/'+fDateStart+'/'+fDateEnd, + method: 'get' + }) +} diff --git a/ruoyi-ui/src/views/fx_density/fx_density_30d.vue b/ruoyi-ui/src/views/fx_density/fx_density_30d.vue index 7794bbd60..173f7afbd 100644 --- a/ruoyi-ui/src/views/fx_density/fx_density_30d.vue +++ b/ruoyi-ui/src/views/fx_density/fx_density_30d.vue @@ -138,11 +138,12 @@ }, itemStyle: { normal: { - color: '#fff', + color: '#a32323', borderWidth: 10, /*shadowColor: 'rgba(72,216,191, 0.3)', shadowBlur: 100,*/ - borderColor: '#A9F387' + borderColor: '#A9F387', + label : {show: true} } }, smooth: false, diff --git a/ruoyi-ui/src/views/fx_density/fx_density_72h.vue b/ruoyi-ui/src/views/fx_density/fx_density_72h.vue index 1cadc7360..0d6af13c2 100644 --- a/ruoyi-ui/src/views/fx_density/fx_density_72h.vue +++ b/ruoyi-ui/src/views/fx_density/fx_density_72h.vue @@ -140,10 +140,11 @@ }, itemStyle: { normal: { - color: '#fff', + color: '#a32323', borderWidth: 10, /*shadowColor: 'rgba(72,216,191, 0.3)', shadowBlur: 100,*/ + label : {show: true}, borderColor: '#A9F387' } }, diff --git a/ruoyi-ui/src/views/fx_density/fx_density_date_range.vue b/ruoyi-ui/src/views/fx_density/fx_density_date_range.vue new file mode 100644 index 000000000..b867cb76e --- /dev/null +++ b/ruoyi-ui/src/views/fx_density/fx_density_date_range.vue @@ -0,0 +1,261 @@ +<template> + <div > + <div class="ibox-title"> + <el-row :gutter="24"> + + <el-col :xs="24" :sm="24" :lg="24"> + + <b>选择时间范围</b> + + <el-date-picker + v-model="daterange_time1" + align="right" + value-format="yyyy-MM-dd" + type="date" + placeholder="选择日期" + :picker-options="pickerOptions"> + </el-date-picker> + + <b>--</b> + <el-date-picker + v-model="daterange_time2" + align="right" + value-format="yyyy-MM-dd" + type="date" + placeholder="选择日期" + :picker-options="pickerOptions"> + </el-date-picker> + + <el-button @click="getData" type="primary">查询</el-button> + + </el-col> + </el-row> + </div> + <el-container > + + + <div id="chart_density_avg" style="width: 90%;height: 600px;top:20px"></div> + </el-container> + </div> +</template> + +<script> + import echarts from 'echarts' + + require('echarts/theme/macarons') // echarts theme + import resize from '../dashboard/mixins/resize' + import { getDensityDataRange } from '@/api/dashboard/density' + + let lineChartData = { + xAxisData: [], + actualData: [] + } + + export default { + mixins: [resize], + name: 'density30day', + data() { + return { + tableData: [], + pickerOptions: { + disabledDate(time) { + return time.getTime() > Date.now(); + }, + shortcuts: [{ + text: '今天', + onClick(picker) { + picker.$emit('pick', new Date()); + } + }, { + text: '昨天', + onClick(picker) { + const date = new Date(); + date.setTime(date.getTime() - 3600 * 1000 * 24); + picker.$emit('pick', date); + } + }, { + text: '一周前', + onClick(picker) { + const date = new Date(); + date.setTime(date.getTime() - 3600 * 1000 * 24 * 7); + picker.$emit('pick', date); + } + }, { + text: '30天前', + onClick(picker) { + const date = new Date(); + date.setTime(date.getTime() - 3600 * 1000 * 24 * 30); + picker.$emit('pick', date); + } + }] + }, + daterange_time1: '', + daterange_time2: '', + } + }, + + created() { + // this.getData() + }, + mounted() { + + + }, + methods: { + getData() { + + lineChartData = { + xAxisData: [], + actualData: [] + } + + getDensityDataRange(this.daterange_time1,this.daterange_time2).then(response => { + for (var i = 0; i < response.data.length; i++) { + lineChartData.xAxisData.push((response.data[i].time + '').replace(' 00:00:00.0', '')) + lineChartData.actualData.push(parseFloat(response.data[i].density).toFixed(4)) + } + + const chart_energy_avg = echarts.init(document.getElementById('chart_density_avg')) + + option_energy_avg.xAxis[0].data = lineChartData.xAxisData + option_energy_avg.series[0].data = lineChartData.actualData + option_energy_avg.title.text = '平均密度' + option_energy_avg.yAxis[0].min = (Math.min.apply(null, lineChartData.actualData).toFixed(2)*1-0.01) + option_energy_avg.yAxis[0].max = (Math.max.apply(null, lineChartData.actualData).toFixed(2)*1+0.01) + + chart_energy_avg.setOption(option_energy_avg, true) + + }) + } + } + + } + + const option_energy_avg = { + title: { + text: '', + textStyle: { + color: '#000', + fontSize: 18 + }, + itemGap: 5, + + x: 'center' + }, + tooltip: { + trigger: 'axis' + }, + xAxis: [{ + type: 'category', + data: ['1#', '2#', '3#', '30#'], + axisLine: { + lineStyle: { + color: '#999' + } + } + }], + yAxis: [{ + type: 'value', + min: 0.36, + max: 0.42, + + // splitNumber: 12, + splitLine: { + lineStyle: { + type: 'dashed', + color: '#DDD' + } + }, + axisLine: { + show: false, + lineStyle: { + color: '#333' + } + }, + nameTextStyle: { + color: '#999' + }, + splitArea: { + show: false + } + }], + series: [{ + name: '密度', + type: 'line', + data: [80, 72], + lineStyle: { + normal: { + width: 8, + color: { + type: 'linear', + + colorStops: [{ + offset: 0, + color: '#A9F387' // 0% 处的颜色 + }, { + offset: 1, + color: '#48D8BF' // 100% 处的颜色 + }], + globalCoord: false // 缺省为 false + }, + shadowColor: 'rgba(72,216,191, 0.3)', + shadowBlur: 10, + shadowOffsetY: 20 + } + }, + itemStyle: { + normal: { + color: '#a32323', + borderWidth: 10, + /*shadowColor: 'rgba(72,216,191, 0.3)', + shadowBlur: 100,*/ + borderColor: '#A9F387', + label : {show: true} + } + }, + smooth: false, + markLine: { + label: { + formatter: '{b}: {c}' + }, + precision: 4, + lineStyle: { + width: 3, + color: 'red' + }, + data: [{ + name: '目标', + yAxis: '0.38' + }, { + type: 'average', + name: '平均' + }] + } + }] + + } + + +</script> + + +<style lang="scss" scoped> + .dashboard-editor-container { + padding: 32px; + background-color: rgb(240, 242, 245); + position: relative; + + .chart-wrapper { + background: #fff; + padding: 16px 16px 0; + margin-bottom: 32px; + } + } + + @media (max-width:1024px) { + .chart-wrapper { + padding: 8px; + } + } +</style> + diff --git a/ruoyi-ui/src/views/fx_density/fx_density_group.vue b/ruoyi-ui/src/views/fx_density/fx_density_group.vue index e2832cd8c..f8c99921f 100644 --- a/ruoyi-ui/src/views/fx_density/fx_density_group.vue +++ b/ruoyi-ui/src/views/fx_density/fx_density_group.vue @@ -133,10 +133,11 @@ }, itemStyle: { normal: { - color: '#fff', + color: '#a32323', borderWidth: 10, /*shadowColor: 'rgba(72,216,191, 0.3)', shadowBlur: 100,*/ + label : {show: true}, borderColor: '#A9F387' } }, diff --git a/ruoyi/src/main/java/com/ruoyi/db/mssql/DB_Ajax_DashBoard_Density_48102.java b/ruoyi/src/main/java/com/ruoyi/db/mssql/DB_Ajax_DashBoard_Density_48102.java index 8d0a42326..e8ecbe50b 100644 --- a/ruoyi/src/main/java/com/ruoyi/db/mssql/DB_Ajax_DashBoard_Density_48102.java +++ b/ruoyi/src/main/java/com/ruoyi/db/mssql/DB_Ajax_DashBoard_Density_48102.java @@ -242,4 +242,43 @@ public class DB_Ajax_DashBoard_Density_48102 { } return hashMapList; } + + public static List<HashMap<String,String>> getDensityDataRange(String fDateStart, String fDateEnd) { + List<HashMap<String,String>> hashMapList = new ArrayList<>(); + try { + Connection conn = getSQLConnection(); + String sql = "SELECT\n" + + "\tProductDate AS TIME,\n" + + "\tAVG ( Density ) AS density \n" + + "FROM\n" + + "\t[dbo].[MouldingRealTimeDensity] \n" + + "WHERE\n" + + "\tCreatedOn >= '"+fDateStart+"' and CreatedOn <= '"+fDateEnd+"'" + + "GROUP BY\n" + + "\tProductDate \n" + + "ORDER BY\n" + + "\tMAX ( CreatedOn );"; + Statement stmt = conn.createStatement();// + System.out.println(sql); + + ResultSet rs = stmt.executeQuery(sql); + while (rs.next()) { + // 截面积(mm2) + HashMap<String,String> map = new HashMap<>(); + map.put("density",rs.getString("density")); + map.put("time",rs.getString("time")); + hashMapList.add(map); + + } + rs.close(); + stmt.close(); + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + + } + return hashMapList; + } + + } diff --git a/ruoyi/src/main/java/com/ruoyi/project/fx_density/controller/DensityController.java b/ruoyi/src/main/java/com/ruoyi/project/fx_density/controller/DensityController.java index 6556fd69f..1d8cd5979 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/fx_density/controller/DensityController.java +++ b/ruoyi/src/main/java/com/ruoyi/project/fx_density/controller/DensityController.java @@ -1,15 +1,17 @@ package com.ruoyi.project.fx_density.controller; import com.ruoyi.db.mssql.DB_Ajax_DashBoard_Density_48102; +import com.ruoyi.db.mssql.DB_Ajax_DashBoard_Technologist_48102; import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.domain.AjaxResult; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * 服务器监控 - * + * * @author ruoyi */ @RestController @@ -36,4 +38,12 @@ public class DensityController extends BaseController { return AjaxResult.success(DB_Ajax_DashBoard_Density_48102.DoGetGroupDensityListMap()); } + + + @GetMapping("/getDensityDataRange/{fDateStart}/{fDateEnd}") + public AjaxResult getDateRange(@PathVariable String fDateStart, @PathVariable String fDateEnd) throws Exception + { + return AjaxResult.success(DB_Ajax_DashBoard_Density_48102.getDensityDataRange(fDateStart,fDateEnd)); + } + }