1 files added
7 files modified
| | |
| | | import com.matrix.system.hive.action.util.QueryUtil; |
| | | import com.matrix.system.hive.bean.SysBusinessData; |
| | | import com.matrix.system.hive.dao.SysBusinessDataDao; |
| | | import com.matrix.system.hive.service.imp.DataAnalysisCustomerServiceImpl; |
| | | import com.matrix.system.hiveErp.analysUtil.Caculate; |
| | | import com.matrix.system.hiveErp.analysUtil.StatisticsParamVo; |
| | | import com.matrix.system.hiveErp.analysUtil.StatisticsTimeDaoParam; |
| | | import com.matrix.system.hiveErp.dao.TjVipSumDao; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiResponse; |
| | | import io.swagger.annotations.ApiResponses; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author wzy |
| | |
| | | public class ApiStatisticsAction { |
| | | |
| | | @Autowired |
| | | TjVipSumDao tjVipSumDao; |
| | | |
| | | @Autowired |
| | | private SysBusinessDataDao sysBusinessDataDao; |
| | | |
| | | @Autowired |
| | | private DataAnalysisCustomerServiceImpl dataAnalysisCustomerService; |
| | | |
| | | @ApiOperation(value = "公司经营报表/门店经营报表") |
| | | @ApiResponses({ |
| | |
| | | |
| | | return AjaxResult.buildSuccessInstance(sysBusinessDataDao.selectApiBusinessDataInPage(sysBusinessData, pageVo), sysBusinessDataDao.selectApiBusinessDataTotal(sysBusinessData)); |
| | | } |
| | | |
| | | @ApiOperation(value = "专项 - 营业收入", notes = "专项 - 营业收入") |
| | | @PostMapping(value = "/findBusinessInCome") |
| | | public AjaxResult findBusinessInCome(@RequestBody StatisticsParamVo statisticsParam) { |
| | | return dataAnalysisCustomerService.getAnalysisResult(statisticsParam, new Caculate<BigDecimal>() { |
| | | @Override |
| | | public Map<String, BigDecimal> exec(List<StatisticsTimeDaoParam> timeSpaceParam, Long shopId, Long companyId) { |
| | | return tjVipSumDao.selectBusinessInCome(timeSpaceParam, shopId, null); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |
| | |
| | | @Override |
| | | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { |
| | | if ("dev".equals(evn)) { |
| | | SysUsers sysUsers = sysUsersDao.selectById(14L); |
| | | SysUsers sysUsers = sysUsersDao.selectById(1012L); |
| | | request.getSession().setAttribute(MatrixConstance.LOGIN_KEY, sysUsers); |
| | | return true; |
| | | } |
New file |
| | |
| | | package com.matrix.system.hive.service.imp; |
| | | |
| | | import com.matrix.core.constance.MatrixConstance; |
| | | import com.matrix.core.pojo.AjaxResult; |
| | | import com.matrix.core.tools.WebUtil; |
| | | 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.tools.DataAuthUtil; |
| | | import com.matrix.system.hive.bean.SysShopInfo; |
| | | import com.matrix.system.hive.dao.SysShopInfoDao; |
| | | import com.matrix.system.hiveErp.analysUtil.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author wzy |
| | | * @date 2020-12-30 |
| | | **/ |
| | | @Service |
| | | public class DataAnalysisCustomerServiceImpl { |
| | | |
| | | @Autowired |
| | | private SysShopInfoDao shopInfoDao; |
| | | |
| | | @Autowired |
| | | private SysCompanyDao sysCompanyDao; |
| | | |
| | | /** |
| | | * 按店铺查询数据通用格式执行方法,支持时、日、月、年维度 |
| | | * 如: A店铺 B店铺 |
| | | * 2020-01-01 12 13 |
| | | * 2020-02-02 10 11 |
| | | * |
| | | * @param statisticsParam 时间条件 |
| | | * @param caculate 循环调用caculate计算该店的数据 |
| | | * 查询的数据需满足 只有一个门店只有一行 列名称为 t0,t1,t2 |
| | | * @return |
| | | */ |
| | | public 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 (statisticsParam.getShopId() != null) { |
| | | shops = Arrays.asList(shopInfoDao.selectById(statisticsParam.getShopId())); |
| | | } else { |
| | | 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(), null); |
| | | //把统计结果转成数组格式 |
| | | 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; |
| | | } |
| | | |
| | | public AjaxResult getCompanyAnalysisResult(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); |
| | | |
| | | SysCompany company = sysCompanyDao.selectById(user.getCompanyId()); |
| | | |
| | | //定义数据项内容 |
| | | List<SeriesVo> series = new ArrayList<>(); |
| | | |
| | | //定义数据主体 |
| | | String[] legendData = new String[1]; |
| | | |
| | | //按门店统计数据 |
| | | List<StatisticsTimeDaoParam> timeSpaceParam = StatisticsTimeUtil.buidParam(xAxis); |
| | | |
| | | legendData[0] = company.getComName(); |
| | | //数据项内容 |
| | | SeriesVo storeInfoSeries = new SeriesVo(); |
| | | storeInfoSeries.setName(company.getComName()); |
| | | //调用计算器获取数据库统计的结果 |
| | | Map<String, Integer> yAxisMap = caculate.exec(timeSpaceParam, null, company.getComId()); |
| | | //把统计结果转成数组格式 |
| | | 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; |
| | | } |
| | | } |
| | |
| | | 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; |
| | |
| | | @Autowired |
| | | SysShopInfoDao shopInfoDao; |
| | | |
| | | @Autowired |
| | | DataAnalysisCustomerServiceImpl dataAnalysisCustomerService; |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | @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); |
| | | } |
| | |
| | | */ |
| | | @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); |
| | | } |
| | |
| | | */ |
| | | @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); |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 按店铺查询数据通用格式执行方法,支持时、日、月、年维度 |
| | | * 如: 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; |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | /** |
| | | * 明细数值计算器 |
| | | */ |
| | | public interface Caculate { |
| | | public Map<String, Integer> exec(List<StatisticsTimeDaoParam> timeSpaceParam , Long shopId); |
| | | public interface Caculate<T> { |
| | | public Map<String, T> exec(List<StatisticsTimeDaoParam> timeSpaceParam , Long shopId, Long companyId); |
| | | } |
| | |
| | | package com.matrix.system.hiveErp.analysUtil; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | |
| | | /** |
| | | * 统计查询条件 |
| | | * @author jyy |
| | | */ |
| | | @ApiModel(value = "StatisticsParamVo", description = "专项统计接收参数类") |
| | | public class StatisticsParamVo { |
| | | |
| | | public static final String COMPANY = "1"; |
| | | |
| | | public static final String SHOP = "2"; |
| | | |
| | | /** |
| | | * 开始时间 |
| | | */ |
| | | @ApiModelProperty(value = "开始时间", example = "2020-01") |
| | | private String beginTime; |
| | | |
| | | /** |
| | | *结束时间 |
| | | */ |
| | | @ApiModelProperty(value = "结束时间", example = "2020-12") |
| | | private String endTime; |
| | | /** |
| | | *统计单位 |
| | | */ |
| | | @ApiModelProperty(value = "统计单位", example = "月") |
| | | private String statisticsUnit; |
| | | |
| | | /** |
| | | *对比单位 |
| | | */ |
| | | @ApiModelProperty(hidden = true) |
| | | private String contrastUnit; |
| | | /** |
| | | * 门店id |
| | | */ |
| | | private String shopId; |
| | | @ApiModelProperty(value = "门店ID, 不传默认统计整个公司") |
| | | private Long shopId; |
| | | |
| | | public String getBeginTime() { |
| | | return beginTime; |
| | |
| | | this.contrastUnit = contrastUnit; |
| | | } |
| | | |
| | | public String getShopId() { |
| | | public Long getShopId() { |
| | | return shopId; |
| | | } |
| | | |
| | | public void setShopId(String shopId) { |
| | | public void setShopId(Long shopId) { |
| | | this.shopId = shopId; |
| | | } |
| | | } |
| | |
| | | import com.matrix.system.hiveErp.analysUtil.StatisticsTimeDaoParam; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | Map<String, Integer> customerEnterCountCompare(@Param("list") List<StatisticsTimeDaoParam> timeSpaceParam, @Param("shopId") Long shopId); |
| | | |
| | | Map<String, Integer> customerEnterRateCompare(@Param("list") List<StatisticsTimeDaoParam> timeSpaceParam, @Param("shopId") Long shopId); |
| | | |
| | | Map<String, BigDecimal> selectBusinessInCome(@Param("list") List<StatisticsTimeDaoParam> timeSpaceParam, @Param("shopId") Long shopId, @Param("companyId") Long companyId); |
| | | } |
| | |
| | | |
| | | </select> |
| | | |
| | | <select id="selectBusinessInCome" resultType="java.util.TreeMap"> |
| | | select |
| | | <foreach collection="list" index="index" item="item" separator="," > |
| | | ( |
| | | select IFNULL(sum(ZK_TOTAL), 0) |
| | | from sys_order |
| | | where STATU in ('已付款', '欠款') |
| | | and <![CDATA[order_time > #{item.beginTime} and order_time < #{item.endTime} ]]> |
| | | <if test="companyId != null and companyId != 0"> |
| | | and company_id=17 |
| | | </if> |
| | | <if test="shopId !=null and shopId !=0 " > |
| | | and SHOP_ID = #{shopId} |
| | | </if> |
| | | ) as t${index} |
| | | |
| | | </foreach> |
| | | from area where id=1 |
| | | </select> |
| | | |
| | | </mapper> |
| | | |