Helius
2020-12-31 5cd7e4d630e265faac43e7544880430dfce4a9ee
finish baobiao
4 files modified
280 ■■■■■ changed files
zq-erp/src/main/java/com/matrix/system/app/action/ApiStatisticsAction.java 34 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/service/imp/DataAnalysisCustomerServiceImpl.java 56 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hiveErp/dao/TjVipSumDao.java 12 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/mybatis/mapper/hive/TjVipSumDao.xml 178 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/app/action/ApiStatisticsAction.java
@@ -184,7 +184,39 @@
    @ApiOperation(value = "员工专项", notes = "员工专项")
    @PostMapping(value = "/findVipBusinessData")
    public AjaxResult findVipBusinessData(@RequestBody @Validated VipStatisticsParamDto vipStatisticsParamDto) {
        return null;
        AjaxResult ajaxResult = dataAnalysisCustomerService.getStaffAnalysisResult(vipStatisticsParamDto, new Caculate<BigDecimal>() {
            @Override
            public Map<String, BigDecimal> exec(List<StatisticsTimeDaoParam> timeSpaceParam, Long shopId, Long staffId) {
                switch (vipStatisticsParamDto.getType()) {
                    case "1" :
                        return tjVipSumDao.selectStaffOrderAchieve(timeSpaceParam, staffId);
                    case "2" :
                        return tjVipSumDao.selectStaffCashAchieve(timeSpaceParam, staffId);
                    case "3" :
                        return tjVipSumDao.selectStaffCardAchieve(timeSpaceParam, staffId);
                    case "4" :
                        return tjVipSumDao.selectStaffGoodsAchieve(timeSpaceParam, staffId);
                    case "5" :
                        return tjVipSumDao.selectStaffCardUseAchieve(timeSpaceParam, staffId);
                    case "6" :
                        return tjVipSumDao.selectStaffHisConsumeAchieve(timeSpaceParam, staffId);
                    case "7" :
                        return tjVipSumDao.selectStaffFreeConsumeAchieve(timeSpaceParam, staffId);
                    case "8" :
                        return tjVipSumDao.selectStaffCommissionAchieve(timeSpaceParam, staffId);
                    case "9" :
                        return tjVipSumDao.selectStaffPeopleNum(timeSpaceParam, staffId);
                    case "10" :
                        return tjVipSumDao.selectStaffProjNum(timeSpaceParam, staffId);
                    case "11" :
                        return tjVipSumDao.selectStaffProjTime(timeSpaceParam, staffId);
                    default:
                        return tjVipSumDao.selectStaffOrderAchieve(timeSpaceParam, staffId);
                }
            }
        });
        return setDataList(ajaxResult);
    }
}
zq-erp/src/main/java/com/matrix/system/hive/service/imp/DataAnalysisCustomerServiceImpl.java
@@ -3,9 +3,11 @@
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;
@@ -27,6 +29,9 @@
    @Autowired
    private SysCompanyDao sysCompanyDao;
    @Autowired
    private SysUsersDao sysUsersDao;
    /**
     * 按店铺查询数据通用格式执行方法,支持时、日、月、年维度
@@ -133,4 +138,55 @@
        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;
    }
}
zq-erp/src/main/java/com/matrix/system/hiveErp/dao/TjVipSumDao.java
@@ -36,4 +36,16 @@
    Map<String, BigDecimal> selectCashRefund(@Param("list") List<StatisticsTimeDaoParam> timeSpaceParam, @Param("shopId") Long shopId, @Param("companyId") Long companyId);
    List<VipAchieveDataShowVo> selectVipAchieveInPage(@Param("record") AchieveNew achieveNew, @Param("pageVo") PaginationVO pageVo);
    Map<String, BigDecimal> selectStaffOrderAchieve(@Param("list") List<StatisticsTimeDaoParam> timeSpaceParam, @Param("staffId") Long staffId);
    Map<String, BigDecimal> selectStaffCashAchieve(@Param("list") List<StatisticsTimeDaoParam> timeSpaceParam, @Param("staffId") Long staffId);
    Map<String, BigDecimal> selectStaffCardAchieve(@Param("list") List<StatisticsTimeDaoParam> timeSpaceParam, @Param("staffId") Long staffId);
    Map<String, BigDecimal> selectStaffGoodsAchieve(@Param("list") List<StatisticsTimeDaoParam> timeSpaceParam, @Param("staffId") Long staffId);
    Map<String, BigDecimal> selectStaffCardUseAchieve(@Param("list") List<StatisticsTimeDaoParam> timeSpaceParam, @Param("staffId") Long staffId);
    Map<String, BigDecimal> selectStaffHisConsumeAchieve(@Param("list") List<StatisticsTimeDaoParam> timeSpaceParam, @Param("staffId") Long staffId);
    Map<String, BigDecimal> selectStaffFreeConsumeAchieve(@Param("list") List<StatisticsTimeDaoParam> timeSpaceParam, @Param("staffId") Long staffId);
    Map<String, BigDecimal> selectStaffCommissionAchieve(@Param("list") List<StatisticsTimeDaoParam> timeSpaceParam, @Param("staffId") Long staffId);
    Map<String, BigDecimal> selectStaffPeopleNum(@Param("list") List<StatisticsTimeDaoParam> timeSpaceParam, @Param("staffId") Long staffId);
    Map<String, BigDecimal> selectStaffProjNum(@Param("list") List<StatisticsTimeDaoParam> timeSpaceParam, @Param("staffId") Long staffId);
    Map<String, BigDecimal> selectStaffProjTime(@Param("list") List<StatisticsTimeDaoParam> timeSpaceParam, @Param("staffId") Long staffId);
}
zq-erp/src/main/resources/mybatis/mapper/hive/TjVipSumDao.xml
@@ -283,5 +283,183 @@
        </if>
    </select>
    <select id="selectStaffOrderAchieve" resultType="java.util.TreeMap">
        select
        <foreach collection="list" index="index" item="item"   separator=","  >
            (
            select
                IFNULL(SUM((IFNULL(a.card_cash,0) +IFNULL(a.proj_cash,0) + IFNULL(a.goods_cash,0))),0)
            from  achieve_new a
            where   <![CDATA[datatime > #{item.beginTime}   and  datatime < #{item.endTime} ]]>
            <if test="staffId != null and staffId != 0">
                and sale_id=#{staffId}
            </if>
            ) as t${index}
        </foreach>
        from area where id=1
    </select>
    <select id="selectStaffCashAchieve" resultType="java.util.TreeMap">
        select
        <foreach collection="list" index="index" item="item"   separator=","  >
            (
            select
            IFNULL(SUM((IFNULL(a.proj_cash,0))),0)
            from  achieve_new a
            where   <![CDATA[datatime > #{item.beginTime}   and  datatime < #{item.endTime} ]]>
            <if test="staffId != null and staffId != 0">
                and sale_id=#{staffId}
            </if>
            ) as t${index}
        </foreach>
        from area where id=1
    </select>
    <select id="selectStaffCardAchieve" resultType="java.util.TreeMap">
        select
        <foreach collection="list" index="index" item="item"   separator=","  >
            (
            select
            IFNULL(SUM((IFNULL(a.card_cash,0))),0)
            from  achieve_new a
            where   <![CDATA[datatime > #{item.beginTime}   and  datatime < #{item.endTime} ]]>
            <if test="staffId != null and staffId != 0">
                and sale_id=#{staffId}
            </if>
            ) as t${index}
        </foreach>
        from area where id=1
    </select>
    <select id="selectStaffGoodsAchieve" resultType="java.util.TreeMap">
        select
        <foreach collection="list" index="index" item="item"   separator=","  >
            (
            select
            IFNULL(SUM((IFNULL(a.goods_cash,0))),0)
            from  achieve_new a
            where   <![CDATA[datatime > #{item.beginTime}   and  datatime < #{item.endTime} ]]>
            <if test="staffId != null and staffId != 0">
                and sale_id=#{staffId}
            </if>
            ) as t${index}
        </foreach>
        from area where id=1
    </select>
    <select id="selectStaffCardUseAchieve" resultType="java.util.TreeMap">
        select
        <foreach collection="list" index="index" item="item"   separator=","  >
            (
            select
            IFNULL(SUM((IFNULL(a.consume,0))),0)
            from  achieve_new a
            where   <![CDATA[datatime > #{item.beginTime}   and  datatime < #{item.endTime} ]]>
            <if test="staffId != null and staffId != 0">
                and sale_id=#{staffId}
            </if>
            ) as t${index}
        </foreach>
        from area where id=1
    </select>
    <select id="selectStaffHisConsumeAchieve" resultType="java.util.TreeMap">
        select
        <foreach collection="list" index="index" item="item"   separator=","  >
            (
            select
            IFNULL(SUM((IFNULL(a.his_consume,0))),0)
            from  achieve_new a
            where   <![CDATA[datatime > #{item.beginTime}   and  datatime < #{item.endTime} ]]>
            <if test="staffId != null and staffId != 0">
                and beault_id=#{staffId}
            </if>
            ) as t${index}
        </foreach>
        from area where id=1
    </select>
    <select id="selectStaffFreeConsumeAchieve" resultType="java.util.TreeMap">
        select
        <foreach collection="list" index="index" item="item"   separator=","  >
            (
            select
            IFNULL(SUM((IFNULL(a.free_consume,0))),0)
            from  achieve_new a
            where   <![CDATA[datatime > #{item.beginTime}   and  datatime < #{item.endTime} ]]>
            <if test="staffId != null and staffId != 0">
                and beault_id=#{staffId}
            </if>
            ) as t${index}
        </foreach>
        from area where id=1
    </select>
    <select id="selectStaffCommissionAchieve" resultType="java.util.TreeMap">
        select
        <foreach collection="list" index="index" item="item"   separator=","  >
            (
            select
            IFNULL(SUM((IFNULL(a.proj_percentage,0))),0)
            from  achieve_new a
            where   <![CDATA[datatime > #{item.beginTime}   and  datatime < #{item.endTime} ]]>
            <if test="staffId != null and staffId != 0">
                and beault_id=#{staffId}
            </if>
            ) as t${index}
        </foreach>
        from area where id=1
    </select>
    <select id="selectStaffPeopleNum" resultType="java.util.TreeMap">
        select
        <foreach collection="list" index="index" item="item"   separator=","  >
            (
            select
            IFNULL(SUM((IFNULL(a.number_of_people,0))),0)
            from  achieve_new a
            where   <![CDATA[datatime > #{item.beginTime}   and  datatime < #{item.endTime} ]]>
            <if test="staffId != null and staffId != 0">
                and beault_id=#{staffId}
            </if>
            ) as t${index}
        </foreach>
        from area where id=1
    </select>
    <select id="selectStaffProjNum" resultType="java.util.TreeMap">
        select
        <foreach collection="list" index="index" item="item"   separator=","  >
            (
            select
            IFNULL(SUM((IFNULL(a.proj_num,0))),0)
            from  achieve_new a
            where   <![CDATA[datatime > #{item.beginTime}   and  datatime < #{item.endTime} ]]>
            <if test="staffId != null and staffId != 0">
                and beault_id=#{staffId}
            </if>
            ) as t${index}
        </foreach>
        from area where id=1
    </select>
    <select id="selectStaffProjTime" resultType="java.util.TreeMap">
        select
        <foreach collection="list" index="index" item="item"   separator=","  >
            (
            select
            IFNULL(SUM((IFNULL(a.proj_time,0))),0)
            from  achieve_new a
            where   <![CDATA[datatime > #{item.beginTime}   and  datatime < #{item.endTime} ]]>
            <if test="staffId != null and staffId != 0">
                and beault_id=#{staffId}
            </if>
            ) as t${index}
        </foreach>
        from area where id=1
    </select>
</mapper>