From 30dea6cb47cd52c8a9857ed5be71bac1c86e7225 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期三, 18 十一月 2020 17:27:15 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/mapper/ReportQueryMapper.java | 6 + src/main/java/com/zy/asrs/domain/dto/WorkChartAxis.java | 31 +++++++ src/main/java/com/zy/asrs/domain/dto/AxisBean.java | 24 ++++++ src/main/java/com/zy/asrs/controller/MonitorController.java | 55 ++++++++++++- src/main/webapp/views/monitor/monitor.html | 59 +++++++++----- src/main/webapp/static/js/common.js | 24 ++++++ 6 files changed, 172 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/MonitorController.java b/src/main/java/com/zy/asrs/controller/MonitorController.java index 104dfce..f746714 100644 --- a/src/main/java/com/zy/asrs/controller/MonitorController.java +++ b/src/main/java/com/zy/asrs/controller/MonitorController.java @@ -3,6 +3,8 @@ import com.core.common.Arith; import com.core.common.Cools; import com.core.common.R; +import com.zy.asrs.domain.dto.AxisBean; +import com.zy.asrs.domain.dto.WorkChartAxis; import com.zy.asrs.domain.vo.LocChartPie; import com.zy.asrs.mapper.ReportQueryMapper; import com.zy.common.service.CommonService; @@ -11,11 +13,9 @@ import com.zy.core.enums.SlaveType; import com.zy.core.model.protocol.CrnProtocol; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import java.text.SimpleDateFormat; import java.util.*; /** @@ -111,6 +111,53 @@ return R.ok(pakinRep); } + @GetMapping("/line/charts") + public R locIoLineCharts(){ + Map<String,Object> map=new HashMap<String, Object>(); + List<AxisBean> list = new ArrayList<AxisBean>(); + + List<WorkChartAxis> listChart = reportQueryMapper.getChartAxis(); + + if(listChart!=null) { + ArrayList<Integer> data1 = new ArrayList<Integer>(); + ArrayList<Integer> data2 = new ArrayList<Integer>(); + + SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DATE, -12); + for(int i=0;i<12;i++) { + boolean flag = true; + calendar.add(Calendar.DATE, 1); + String str = sf.format(calendar.getTime()); + for(WorkChartAxis workChart : listChart) { + if(str.equals(workChart.getYmd())) { + data1.add(workChart.getInqty()); + data2.add(workChart.getOutqty()); + flag = false; + break; + } + } + if(flag) { + data1.add(0); + data2.add(0); + } + } + AxisBean inqty = new AxisBean(); + inqty.setName("鍏ュ簱鏁伴噺"); + Integer[] array1 = new Integer[data1.size()]; + inqty.setData(data1.toArray(array1)); + list.add(inqty); + AxisBean outqty = new AxisBean(); + outqty.setName("鍑哄簱鏁伴噺"); + Integer[] array2 = new Integer[data2.size()]; + outqty.setData(data2.toArray(array2)); + list.add(outqty); + } + map.put("rows",list); + return R.ok(map); + } + + /** * 搴撲綅浣跨敤鎯呭喌缁熻 */ diff --git a/src/main/java/com/zy/asrs/domain/dto/AxisBean.java b/src/main/java/com/zy/asrs/domain/dto/AxisBean.java new file mode 100644 index 0000000..4b86146 --- /dev/null +++ b/src/main/java/com/zy/asrs/domain/dto/AxisBean.java @@ -0,0 +1,24 @@ +package com.zy.asrs.domain.dto; + +/** + * 鏇茬嚎鍥捐〃json閿� + * @author admin + * + */ +public class AxisBean { + private String name; + private Integer[] data; + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public Integer[] getData() { + return data; + } + public void setData(Integer[] data) { + this.data = data; + } + +} diff --git a/src/main/java/com/zy/asrs/domain/dto/WorkChartAxis.java b/src/main/java/com/zy/asrs/domain/dto/WorkChartAxis.java new file mode 100644 index 0000000..cbb46b7 --- /dev/null +++ b/src/main/java/com/zy/asrs/domain/dto/WorkChartAxis.java @@ -0,0 +1,31 @@ +package com.zy.asrs.domain.dto; + +/** + * 鍏ュ嚭搴撶粺璁℃洸绾垮浘 + * @author admin + * @date 2018骞�12鏈�12鏃� + */ +public class WorkChartAxis { + private String ymd; + private int inqty; + private int outqty; + + public String getYmd() { + return ymd; + } + public void setYmd(String ymd) { + this.ymd = ymd; + } + public int getInqty() { + return inqty; + } + public void setInqty(int inqty) { + this.inqty = inqty; + } + public int getOutqty() { + return outqty; + } + public void setOutqty(int outqty) { + this.outqty = outqty; + } +} \ No newline at end of file diff --git a/src/main/java/com/zy/asrs/mapper/ReportQueryMapper.java b/src/main/java/com/zy/asrs/mapper/ReportQueryMapper.java index 1b84325..bd14d54 100644 --- a/src/main/java/com/zy/asrs/mapper/ReportQueryMapper.java +++ b/src/main/java/com/zy/asrs/mapper/ReportQueryMapper.java @@ -1,5 +1,6 @@ package com.zy.asrs.mapper; +import com.zy.asrs.domain.dto.WorkChartAxis; import com.zy.asrs.domain.vo.LocChartPie; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Select; @@ -35,6 +36,11 @@ "order by Min(wm.io_time) asc") List<Map<String, Object>> queryPakOutRep(); + //鏇茬嚎鍥� + @Select("select ymd,SUM(sto_qty) inqty,SUM(ret_qty) outqty from asr_sta_inout_view " + + "where ymd>CONVERT(char(10), DATEADD(DAY,-12,GETDATE()), 120) group by ymd order by ymd") + public List<WorkChartAxis> getChartAxis(); + @Select("select * from asr_loc_use_view") LocChartPie getLocUseRate(); diff --git a/src/main/webapp/static/js/common.js b/src/main/webapp/static/js/common.js index a2f6af8..5a0757e 100644 --- a/src/main/webapp/static/js/common.js +++ b/src/main/webapp/static/js/common.js @@ -168,4 +168,28 @@ return unescape(r[2]); } return null; +} + +function getDateFormat(value){ + var date = new Date();// 鑾峰彇褰撳墠鏃堕棿 + date.setDate(date.getDate() + value);// 璁剧疆澶╂暟 -1 澶� + return date.Format("MM-dd"); +} +/** + * 鏃ユ湡鏍煎紡鍖� + */ +Date.prototype.Format = function (fmt) { + var o = { + "M+": this.getMonth() + 1, //鏈堜唤 + "d+": this.getDate(), //鏃� + "h+": this.getHours(), //灏忔椂 + "m+": this.getMinutes(), //鍒� + "s+": this.getSeconds(), //绉� + "q+": Math.floor((this.getMonth() + 3) / 3), //瀛e害 + "S": this.getMilliseconds() //姣 + }; + if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); + for (var k in o) + if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); + return fmt; } \ No newline at end of file diff --git a/src/main/webapp/views/monitor/monitor.html b/src/main/webapp/views/monitor/monitor.html index 6c0748d..22a3fac 100644 --- a/src/main/webapp/views/monitor/monitor.html +++ b/src/main/webapp/views/monitor/monitor.html @@ -679,7 +679,7 @@ xAxis: { type: 'category', boundaryGap: false, - data: ['1', '2', '3', '4', '5', '6', '7'], + data: ['1', '2', '3', '4', '5', '6', '7'], axisLabel: { textStyle:{ color:'#aaa', //鍧愭爣鐨勫瓧浣撻鑹� @@ -713,45 +713,58 @@ } }, - series: [{ - data: [820, 932, 901, 934, 1290, 1330, 1320], - type: 'line', - areaStyle: { - color: '#7494ae' // 鎶樼嚎鍖哄煙棰滆壊 + series: [ + { + data: [820, 932, 901, 934, 1290, 1330, 1320], + type: 'line', + // areaStyle: { + // color: '#7494ae' // 鎶樼嚎鍖哄煙棰滆壊 + // }, + itemStyle:{ + normal:{ + color:'#3590ac', //鎶樼偣棰滆壊 + lineStyle:{ + color:'#3590ac' //鎶樼嚎棰滆壊 + } + } + } }, - itemStyle:{ - normal:{ - color:'#3590ac', //鎶樼偣棰滆壊 - lineStyle:{ - color:'#3590ac' //鎶樼嚎棰滆壊 + { + data: [820, 932, 901, 934, 1290, 1330, 1320], + type: 'line', + // areaStyle: { + // color: '#d55b35' // 鎶樼嚎鍖哄煙棰滆壊 + // }, + itemStyle:{ + normal:{ + color:'#0cbad9', //鎶樼偣棰滆壊 + lineStyle:{ + color:'#07a093' //鎶樼嚎棰滆壊 + } } } } - }] + ] }; // 璁块棶閲忔姤琛ㄥ姞杞� function initlinChart() { var reportView = lineChartOption; - var xAxisDate = []; - var seriesDate=[]; $.ajax({ - url: baseUrl+"/monitor/pakin/rep", + url: baseUrl+"/monitor/line/charts", method: 'GET', success: function (res) { if (res.code === 200){ - var json = res.data; - for (var i = 0; i < json.length; i++) { - xAxisDate[i]=json[i].node; - seriesDate[i]=json[i].val; - } - reportView.xAxis.data=xAxisDate; - reportView.series[0].data=seriesDate; + var json = res.data.rows; + reportView.xAxis.data=[getDateFormat(-11), getDateFormat(-10), getDateFormat(-9), getDateFormat(-8), getDateFormat(-7), getDateFormat(-6), + getDateFormat(-5), getDateFormat(-4), getDateFormat(-3), getDateFormat(-2), getDateFormat(-1), getDateFormat(-0)]; + reportView.series[0].data=res.data.rows[0].data; + reportView.series[1].data=res.data.rows[1].data; lineCharts.setOption(reportView) } else if (res.code === 403){ top.location.href = "/"; } else { - layer.msg(res.msg); + console.log(res.msg); } } }); -- Gitblit v1.9.1