#
luxiaotao1123
2020-11-18 30dea6cb47cd52c8a9857ed5be71bac1c86e7225
#
2个文件已添加
4个文件已修改
199 ■■■■ 已修改文件
src/main/java/com/zy/asrs/controller/MonitorController.java 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/domain/dto/AxisBean.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/domain/dto/WorkChartAxis.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/mapper/ReportQueryMapper.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/js/common.js 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/monitor/monitor.html 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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);
    }
    /**
     * 库位使用情况统计
     */
src/main/java/com/zy/asrs/domain/dto/AxisBean.java
New file
@@ -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;
    }
}
src/main/java/com/zy/asrs/domain/dto/WorkChartAxis.java
New file
@@ -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;
    }
}
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();
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), //季度
        "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;
}
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);
                }
            }
        });