|  |  |  | 
|---|
|  |  |  | import com.matrix.core.constance.MatrixConstance; | 
|---|
|  |  |  | import com.matrix.core.pojo.AjaxResult; | 
|---|
|  |  |  | import com.matrix.core.tools.WebUtil; | 
|---|
|  |  |  | import com.matrix.system.app.dto.VipStatisticsParamDto; | 
|---|
|  |  |  | import com.matrix.system.common.bean.SysCompany; | 
|---|
|  |  |  | import com.matrix.system.common.bean.SysUsers; | 
|---|
|  |  |  | import com.matrix.system.common.dao.SysCompanyDao; | 
|---|
|  |  |  | import com.matrix.system.common.dao.SysUsersDao; | 
|---|
|  |  |  | import com.matrix.system.common.tools.DataAuthUtil; | 
|---|
|  |  |  | import com.matrix.system.hive.bean.SysShopInfo; | 
|---|
|  |  |  | import com.matrix.system.hive.dao.SysShopInfoDao; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SysCompanyDao sysCompanyDao; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SysUsersDao sysUsersDao; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 按店铺查询数据通用格式执行方法,支持时、日、月、年维度 | 
|---|
|  |  |  | 
|---|
|  |  |  | result.setStatus(AjaxResult.STATUS_SUCCESS); | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public AjaxResult getStaffAnalysisResult(VipStatisticsParamDto 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); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Long staffId = null; | 
|---|
|  |  |  | if (statisticsParam.getStaffId() == null) { | 
|---|
|  |  |  | staffId = user.getSuId(); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | staffId = statisticsParam.getStaffId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | SysUsers sysUsers = sysUsersDao.selectById(staffId); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //定义数据项内容 | 
|---|
|  |  |  | List<SeriesVo> series = new ArrayList<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //定义数据主体 | 
|---|
|  |  |  | String[] legendData = new String[1]; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int i = 0; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //按门店统计数据 | 
|---|
|  |  |  | List<StatisticsTimeDaoParam> timeSpaceParam = StatisticsTimeUtil.buidParam(xAxis); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | legendData[0] = sysUsers.getSuName(); | 
|---|
|  |  |  | //数据项内容 | 
|---|
|  |  |  | SeriesVo storeInfoSeries = new SeriesVo(); | 
|---|
|  |  |  | storeInfoSeries.setName(sysUsers.getSuName()); | 
|---|
|  |  |  | //调用计算器获取数据库统计的结果 | 
|---|
|  |  |  | Map<String, Integer> yAxisMap = caculate.exec(timeSpaceParam, null, sysUsers.getSuId()); | 
|---|
|  |  |  | //把统计结果转成数组格式 | 
|---|
|  |  |  | storeInfoSeries.setData(StatisticsTimeUtil.getSeries(yAxisMap)); | 
|---|
|  |  |  | series.add(storeInfoSeries); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //构造返回对象 | 
|---|
|  |  |  | Map<Object, Object> data = new HashMap<>(); | 
|---|
|  |  |  | data.put("legendData", legendData); | 
|---|
|  |  |  | data.put("series", series); | 
|---|
|  |  |  | StatisticsParamVo statisticsParam1 = new StatisticsParamVo(); | 
|---|
|  |  |  | statisticsParam1.setStatisticsUnit(statisticsParam.getStatisticsUnit()); | 
|---|
|  |  |  | String[] xData = StatisticsTimeUtil.getFormartDateList(xAxis, statisticsParam1); | 
|---|
|  |  |  | data.put("xAxis", Arrays.copyOf(xData, xData.length - 1)); | 
|---|
|  |  |  | result.setMapInfo(data); | 
|---|
|  |  |  | result.setStatus(AjaxResult.STATUS_SUCCESS); | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|