jyy
2020-12-02 7efbe93bdb75762f50a1d2d104e05a9e4db49ea2
修改人头统计计算
1 files added
3 files modified
204 ■■■■ changed files
zq-erp/src/main/java/com/matrix/system/hiveErp/Vo/SeriesVo.java 49 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hiveErp/action/CustomerAnalysis.java 48 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/mybatis/mapper/hive/TjVipSumDao.xml 22 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/templates/views/admin/hive-erp/analysis/customerFlow.html 85 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hiveErp/Vo/SeriesVo.java
New file
@@ -0,0 +1,49 @@
package com.matrix.system.hiveErp.Vo;
/**
 * echart 图表参数
 */
public class SeriesVo {
    private String TYPE_LINE="line";
    private  String name;
    private Integer[] data;
    private String type="line";
    public SeriesVo() {
    }
    public SeriesVo(String name, Integer[] data, String type) {
        this.name = name;
        this.data = data;
        this.type = type;
    }
    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;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
}
zq-erp/src/main/java/com/matrix/system/hiveErp/action/CustomerAnalysis.java
@@ -1,7 +1,14 @@
package com.matrix.system.hiveErp.action;
import com.matrix.core.constance.MatrixConstance;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.tools.DateUtil;
import com.matrix.core.tools.WebUtil;
import com.matrix.system.common.bean.SysUsers;
import com.matrix.system.hive.bean.SysShopInfo;
import com.matrix.system.hive.dao.SysShopInfoDao;
import com.matrix.system.hive.service.SysShopInfoService;
import com.matrix.system.hiveErp.Vo.SeriesVo;
import com.matrix.system.hiveErp.Vo.StatisticsParamVo;
import com.matrix.system.hiveErp.Vo.StatisticsTimeDaoParam;
import com.matrix.system.hiveErp.dao.TjVipSumDao;
@@ -20,12 +27,17 @@
    @Autowired
    TjVipSumDao tjVipSumDao;
    @Autowired
    SysShopInfoDao shopInfoDao;
    /**
     * 到店次数趋势统计
     *
     * @return
     */
    @RequestMapping(value = "/vipVisitTendency ")
    @RequestMapping(value = "/vipVisitTendency")
    public @ResponseBody
    AjaxResult vipVisit(StatisticsParamVo statisticsParam) {
        AjaxResult result = new AjaxResult();
@@ -42,6 +54,38 @@
        result.setStatus(AjaxResult.STATUS_SUCCESS);
        return result;
    }
 */
    @RequestMapping(value = "vipVisitCompare")
    public @ResponseBody  AjaxResult vipVisitCompare(StatisticsParamVo statisticsParam) {
        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
        AjaxResult result = new AjaxResult();
        //计算横坐标
        List<Date> xAxis = StatisticsTimeUtil.getTimeSpace(statisticsParam.getBeginTime(), statisticsParam.getEndTime(), statisticsParam.getStatisticsUnit());
        //获取所有门店
        List<SysShopInfo> shops= shopInfoDao.selectShopInfo(user.getCompanyId());
        List<SeriesVo> series=new ArrayList<>();
        String[]  legendData=new String[shops.size()];
        int i=0;
        for(SysShopInfo shop: shops){
            legendData[i++]=shop.getShopName();
            SeriesVo storeInfoSeries=new SeriesVo();
            storeInfoSeries.setName(shop.getShopName());
            Map<String, Integer> yAxisMap = tjVipSumDao.countVisitByTime(buidParam(xAxis),shop.getId());
            storeInfoSeries.setData(getSeries(yAxisMap));
            series.add(storeInfoSeries);
        }
        //构造返回对象
        Map<Object,Object> data=new HashMap<>();
        data.put("legendData",legendData);
        data.put("series",series);
        data.put("xAxis", getFormartDateList(xAxis,statisticsParam));
        result.setMapInfo(data);
        result.setStatus(AjaxResult.STATUS_SUCCESS);
        return result;
    }
    /**
     * 获取map中的值为数组
zq-erp/src/main/resources/mybatis/mapper/hive/TjVipSumDao.xml
@@ -8,25 +8,21 @@
    <!-- 人头数统计 -->
    <select id="countVisitByTime" resultType="java.util.TreeMap">
        select
        <foreach collection="list" index="index" item="item"   separator=","  >
            (
                SELECT count(*)  from (
                    SELECT DISTINCT vip_id  from  achieve_new where <![CDATA[datatime > #{item.beginTime}   and  datatime < #{item.endTime} ]]>
                    <if test="shopId !=null and shopId !=0 " >
                        and SHOP_ID = #{shopId}
                    </if>
            SELECT count(*)  from (SELECT DISTINCT vip_id  from  achieve_new
                where
                <![CDATA[datatime > #{item.beginTime}   and  datatime < #{item.endTime} ]]>
                <if test="shopId !=null and shopId !=0 " >
                    and SHOP_ID = #{shopId}
                </if>
            ) t
                ) t
            ) as t${index}
        </foreach>
        from area where id=1
    </select>
    </mapper>
</mapper>
    
zq-erp/src/main/resources/templates/views/admin/hive-erp/analysis/customerFlow.html
@@ -31,7 +31,8 @@
                </button>
            </div>
        </div>
        <div class="form-group mr-20" id="timeBox">
        <div class="form-group mr-20 mt-20" id="timeBox">
            <label>统计范围</label>
            <input name="beginTime" type="text" autocomplete="off"
@@ -39,7 +40,7 @@
                name="endTime" type="text" class="form-control datetimepicker" autocomplete="off"
                id="endTime">
        </div>
        <div class="form-group mr-20">
        <div class="form-group mr-20  ">
            <label>统计单位</label>
            <select name="statisticsUnit" class=" form-control " id="unitSelect"
                    style="width: 80px">
@@ -52,11 +53,32 @@
    </form>
    <!-- 搜索框部分en -->
    <div class="row chartsBox">
    <div class="row chartsBox "  style="margin-top: 40px">
        <div class=" col-md-12">
            <div class="echarts" id="echarts-line-chart2"></div>
        </div>
    </div>
   <!-- <div class="row chartsBox "  style="margin-top: 40px">
        <div class=" col-md-12" id="table">
            <table class="table table-striped" >
                <thead>
                <tr>
                    <th>时间</th>
                    <th v-for="name in legend" >{{name}}</th>
                </tr>
                </thead>
                <tbody>
                <tr v-for="(item,index) in xAxis">
                    <td>{{item}}</td>
                    <td v-for="data in series[index].data" >{{data}}</td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
-->
</div>
<script type="text/javascript" th:src="@{/js/systools/MJsBase.js}"></script>
@@ -66,6 +88,7 @@
<script type="text/javascript" th:src="@{/plugin/StringUtil.js}"></script>
<script type="text/javascript" th:src="@{/plugin/moment.min.js}"></script>
<script type="text/javascript" th:src="@{/js/systools/ChartsUtils.js}"></script>
<script type="text/javascript" th:src="@{/js/plugin/vue.js}"></script>
<script>
@@ -76,7 +99,9 @@
    // 基于准备好的dom,初始化echarts实例
    var myChart2 = echarts.init(document.getElementById('echarts-line-chart2'), 'macarons');
    myChart2.on('click', function (params) {
        console.log(params);
    });
    // 指定图表的配置项和数据
    function getption(title) {
@@ -113,6 +138,12 @@
            yAxis: {
                type: 'value'
            },
            series: [{
                name: '人头数',
                type: 'line',
                smooth: true,
                data: [1,2]
            }],
            dataZoom: [
                {
                    id: 'dataZoomX',
@@ -121,23 +152,6 @@
                    filterMode: 'filter'
                }
            ],
            series: [{
                name: '客流量',
                type: 'line',
                smooth: true,
                data: [],
                markLine: {
                    data: [
                        {type: 'average', name: '平均值'}
                    ]
                },
                markPoint: {
                    data: [
                        {type: 'max', name: '最大值'},
                        {type: 'min', name: '最小值'}
                    ]
                },
            }],
            animation: true,
            animationDuration: 1000,
            animationDurationUpdate: 1000,
@@ -151,19 +165,18 @@
    //加载数据
    function loadData() {
        //加载门店客流对比
        myChart2.showLoading();
        $.AjaxProxy({
            p: MForm.toJson("#serchform"),
            c: false,
        }).invoke(basePath+"/admin/analysis/vipVisitTendency",
        }).invoke(basePath+"/admin/analysis/vipVisitCompare",
            function (loj) {
                var map = loj.getValue("mapInfo");
                var option = getption("门店客流趋势对比");
                console.log(map);
                var option = getption("门店人头数对比");
                option.series = map.series;
                console.log("option.series",option.series);
                option.legend.data = map.legendData;
                option.xAxis.data = map.xAxis;
                console.log(option);
@@ -171,18 +184,28 @@
                myChart2.setOption(option);
                myChart2.hideLoading();
            });
    }
    var ChartsUtils = new ChartsUtils(loadData);
    ChartsUtils.setDataPackTimeValue();
    ChartsUtils.loadChartData();
    function  buildTable(map){
        console.log(buildTable,map);
        var app = new Vue({
            el: '#table',
            data: {
                series : map.series,
                legend : map.legendData,
                xAxis : map.xAxis
            }
        } );
    }
</script>
</body>