From eab874580586bb589d73f61df7a4ce10252a0110 Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Wed, 30 Dec 2020 15:23:58 +0800 Subject: [PATCH] modify --- zq-erp/src/main/java/com/matrix/system/hiveErp/action/DataAnalysisCustomer.java | 73 ++++-------------------------------- 1 files changed, 9 insertions(+), 64 deletions(-) diff --git a/zq-erp/src/main/java/com/matrix/system/hiveErp/action/DataAnalysisCustomer.java b/zq-erp/src/main/java/com/matrix/system/hiveErp/action/DataAnalysisCustomer.java index 69a4dc0..8c1a271 100644 --- a/zq-erp/src/main/java/com/matrix/system/hiveErp/action/DataAnalysisCustomer.java +++ b/zq-erp/src/main/java/com/matrix/system/hiveErp/action/DataAnalysisCustomer.java @@ -7,6 +7,7 @@ import com.matrix.system.common.tools.DataAuthUtil; import com.matrix.system.hive.bean.SysShopInfo; import com.matrix.system.hive.dao.SysShopInfoDao; +import com.matrix.system.hive.service.imp.DataAnalysisCustomerServiceImpl; import com.matrix.system.hiveErp.analysUtil.*; import com.matrix.system.hiveErp.dao.TjVipSumDao; import org.jetbrains.annotations.NotNull; @@ -31,6 +32,8 @@ @Autowired SysShopInfoDao shopInfoDao; + @Autowired + DataAnalysisCustomerServiceImpl dataAnalysisCustomerService; /** @@ -43,9 +46,9 @@ */ @RequestMapping(value = "/customerHeadCompare") public @ResponseBody AjaxResult customerHeadCompare(StatisticsParamVo statisticsParam) { - return getAnalysisResult(statisticsParam, new Caculate() { + return dataAnalysisCustomerService.getAnalysisResult(statisticsParam, new Caculate<Integer>() { @Override - public Map<String, Integer> exec(List<StatisticsTimeDaoParam> timeSpaceParam, Long shopId) { + public Map<String, Integer> exec(List<StatisticsTimeDaoParam> timeSpaceParam, Long shopId, Long companyId) { //从员工业绩统计表中,按时间段,门店的维度统计人头数 return tjVipSumDao.customerHeadCompare(timeSpaceParam,shopId); } @@ -61,9 +64,9 @@ */ @RequestMapping(value = "/customerEnterCountCompare") public @ResponseBody AjaxResult customerEnterCountCompare(StatisticsParamVo statisticsParam) { - return getAnalysisResult(statisticsParam, new Caculate() { + return dataAnalysisCustomerService.getAnalysisResult(statisticsParam, new Caculate<Integer>() { @Override - public Map<String, Integer> exec(List<StatisticsTimeDaoParam> timeSpaceParam, Long shopId) { + public Map<String, Integer> exec(List<StatisticsTimeDaoParam> timeSpaceParam, Long shopId, Long companyId) { //从员工业绩统计表中,按时间段,门店的维度统计人次 return tjVipSumDao.customerEnterCountCompare(timeSpaceParam,shopId); } @@ -80,9 +83,9 @@ */ @RequestMapping(value = "/customerEnterRateCompare") public @ResponseBody AjaxResult customerEnterRateCompare(StatisticsParamVo statisticsParam) { - return getAnalysisResult(statisticsParam, new Caculate() { + return dataAnalysisCustomerService.getAnalysisResult(statisticsParam, new Caculate<Integer>() { @Override - public Map<String, Integer> exec(List<StatisticsTimeDaoParam> timeSpaceParam, Long shopId) { + public Map<String, Integer> exec(List<StatisticsTimeDaoParam> timeSpaceParam, Long shopId, Long companyId) { //从员工业绩统计表中,按时间段,门店的维度统计人次 return tjVipSumDao.customerEnterRateCompare(timeSpaceParam,shopId); } @@ -93,64 +96,6 @@ - - - /** - * 按店铺查询数据通用格式执行方法,支持时、日、月、年维度 - * 如: A店铺 B店铺 - * 2020-01-01 12 13 - * 2020-02-02 10 11 - * @param statisticsParam 时间条件 - * @param caculate 循环调用caculate计算该店的数据 - * 查询的数据需满足 只有一个门店只有一行 列名称为 t0,t1,t2 - * @return - */ - private AjaxResult getAnalysisResult(StatisticsParamVo statisticsParam, Caculate caculate) { - AjaxResult result = new AjaxResult(); - - //根据计算横坐标 - List<Date> xAxis = StatisticsTimeUtil.getTimeSpace(statisticsParam.getBeginTime(), statisticsParam.getEndTime(), statisticsParam.getStatisticsUnit()); - - //获取所有门店 - SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); - List<SysShopInfo> shops=null; - if(DataAuthUtil.hasAllShopAuth()){ - shops= shopInfoDao.selectShopInfo(user.getCompanyId()); - }else{ - shops=Arrays.asList(shopInfoDao.selectById(user.getShopId())); - } - //定义数据项内容 - List<SeriesVo> series=new ArrayList<>(); - - //定义数据主体 - String[] legendData=new String[shops.size()]; - - int i=0; - - //按门店统计数据 - List<StatisticsTimeDaoParam> timeSpaceParam = StatisticsTimeUtil.buidParam(xAxis); - for(SysShopInfo shop: shops){ - - legendData[i++]=shop.getShopName(); - //数据项内容 - SeriesVo storeInfoSeries=new SeriesVo(); - storeInfoSeries.setName(shop.getShopName()); - //调用计算器获取数据库统计的结果 - Map<String, Integer> yAxisMap = caculate.exec(timeSpaceParam,shop.getId()); - //把统计结果转成数组格式 - storeInfoSeries.setData(StatisticsTimeUtil.getSeries(yAxisMap)); - series.add(storeInfoSeries); - - } - //构造返回对象 - Map<Object,Object> data=new HashMap<>(); - data.put("legendData",legendData); - data.put("series",series); - data.put("xAxis", StatisticsTimeUtil.getFormartDateList(xAxis,statisticsParam)); - result.setMapInfo(data); - result.setStatus(AjaxResult.STATUS_SUCCESS); - return result; - } -- Gitblit v1.9.1