Authored by tanling

Merge branch 'dev_0426_总成本报表需求' of http://git.yoho.cn/yoho30/yohobuy-union into dev_0426_总成本报表需求

... ... @@ -35,106 +35,106 @@ public class MktCostReportFormController {
logger.info("enter getMktReportForm. param mktReportFormReqVO={}", mktReportFormReqVO);
try {
// PageMktReportFormRspBO result = mktCostReportFormService.getMktReportForm(mktReportFormReqVO);
MktReportFormRspBO mktReportFormRspBO = new MktReportFormRspBO();
List<String> dateIdStrList = Lists.newArrayList();
List<BigDecimal> totalActuralCostList = Lists.newArrayList();
List<BigDecimal> iosActualCostList = Lists.newArrayList();
List<BigDecimal> androidActualCostList = Lists.newArrayList();
List<Integer> totalExpoureNumList = Lists.newArrayList();
List<Integer> iosExpoureNumList = Lists.newArrayList();
List<Integer> androidExpoureNumList = Lists.newArrayList();
List<Integer> totalActiveList = Lists.newArrayList();
List<Integer> iosActiveList = Lists.newArrayList();
List<Integer> androidActiveList = Lists.newArrayList();
List<Integer> totalNewUdidList = Lists.newArrayList();
List<Integer> iosNewUdidList = Lists.newArrayList();
List<Integer> androidNewUdidList = Lists.newArrayList();
List<BigDecimal> totalActiveRatio = Lists.newArrayList();
List<BigDecimal> iosActiveRatio = Lists.newArrayList();
List<BigDecimal> androidActiveRatio = Lists.newArrayList();
List<BigDecimal> totalExpoureRatio = Lists.newArrayList();
List<BigDecimal> iosExpoureRatio = Lists.newArrayList();
List<BigDecimal> androidExpoureRatio = Lists.newArrayList();
List<BigDecimal> totalNewUdidRatio = Lists.newArrayList();
List<BigDecimal> iosNewUdidRatio = Lists.newArrayList();
List<BigDecimal> androidNewUdidRatio = Lists.newArrayList();
for (Integer i = 0; i <=6; i++){
dateIdStrList.add("2017042" + i.toString());
totalActuralCostList.add(new BigDecimal(5000 - i * 100));
iosActualCostList.add(new BigDecimal(4000 - i * 80));
androidActualCostList.add(new BigDecimal(1000 - i * 20));
totalExpoureNumList.add(1000 - i * 100);
iosExpoureNumList.add(600 - i * 60);
androidExpoureNumList.add(400 - i * 40);
totalActiveList.add(2000 - i * 200);
iosActiveList.add(1500 - i * 150);
androidActiveList.add(500 - i * 50);
totalNewUdidList.add(100 - i * 10);
iosNewUdidList.add(70 - i * 7);
androidNewUdidList.add(30 - i * 3);
totalActiveRatio.add(getDivideData(totalActuralCostList.get(i), new BigDecimal(totalActiveList.get(i))));
iosActiveRatio.add(getDivideData(iosActualCostList.get(i), new BigDecimal(iosActiveList.get(i))));
androidActiveRatio.add(getDivideData(androidActualCostList.get(i), new BigDecimal(androidActiveList.get(i))));
totalExpoureRatio.add(getDivideData(totalActuralCostList.get(i), new BigDecimal(totalExpoureNumList.get(i))));
iosExpoureRatio.add(getDivideData(iosActualCostList.get(i), new BigDecimal(iosExpoureNumList.get(i))));
androidExpoureRatio.add(getDivideData(androidActualCostList.get(i), new BigDecimal(androidExpoureNumList.get(i))));
totalNewUdidRatio.add(getDivideData(totalActuralCostList.get(i), new BigDecimal(totalNewUdidList.get(i))));
iosNewUdidRatio.add(getDivideData(iosActualCostList.get(i), new BigDecimal(iosNewUdidList.get(i))));
androidNewUdidRatio.add(getDivideData(androidActualCostList.get(i), new BigDecimal(androidNewUdidList.get(i))));
}
mktReportFormRspBO.setDateIdStrList(dateIdStrList);
mktReportFormRspBO.setTotalActualCostList(totalActuralCostList);
mktReportFormRspBO.setIosActualCostList(iosActualCostList);
mktReportFormRspBO.setAndroidActualCost(androidActualCostList);
mktReportFormRspBO.setTotalExpoureNumList(totalExpoureNumList);
mktReportFormRspBO.setIosExpoureNumList(iosExpoureNumList);
mktReportFormRspBO.setAndroidExpoureNumList(androidExpoureNumList);
mktReportFormRspBO.setTotalAppActiveList(totalActiveList);
mktReportFormRspBO.setIosAppActiveList(iosActiveList);
mktReportFormRspBO.setAndroidAppActiveList(androidActiveList);
mktReportFormRspBO.setTotalNewUserList(totalNewUdidList);
mktReportFormRspBO.setIosNewUserList(iosNewUdidList);
mktReportFormRspBO.setAndroidNewUserList(androidNewUdidList);
mktReportFormRspBO.setTopActualCost(Collections.max(totalActuralCostList));
// mktReportFormRspBO.setTopAppActive(Collections.max(totalActiveList));
// mktReportFormRspBO.setTopExpoureNum(Collections.max(totalExpoureNumList));
// mktReportFormRspBO.setTopNewUdid(Collections.max(totalNewUdidList));
mktReportFormRspBO.setTotalActiveRatio(totalActiveRatio);
mktReportFormRspBO.setIosActiveRatio(iosActiveRatio);
mktReportFormRspBO.setAndroidActiveRatio(androidActiveRatio);
mktReportFormRspBO.setTotalExpoureRatio(totalExpoureRatio);
mktReportFormRspBO.setIosExpoureRatio(iosExpoureRatio);
mktReportFormRspBO.setAndroidExpoureRatio(androidExpoureRatio);
mktReportFormRspBO.setTotalNewUdidRatio(totalNewUdidRatio);
mktReportFormRspBO.setIosNewUdidRatio(iosNewUdidRatio);
mktReportFormRspBO.setAndroidNewUdidRatio(androidNewUdidRatio);
// mktReportFormRspBO.setTopActiveRatio(Collections.max(totalActiveRatio));
// mktReportFormRspBO.setTopNewUdidRatio(Collections.max(totalNewUdidRatio));
// mktReportFormRspBO.setTopExpoureRatio(Collections.max(totalExpoureRatio));
BigDecimal topRatio = Collections.max(totalActiveRatio);
if (topRatio.compareTo(Collections.max(totalNewUdidRatio)) < 0){
topRatio = Collections.max(totalNewUdidRatio);
} else if (topRatio.compareTo(Collections.max(totalExpoureRatio)) < 0){
topRatio = Collections.max(totalExpoureRatio);
}
mktReportFormRspBO.setTopRatio(topRatio);
Integer topExActNew = Collections.max(totalActiveList);
if (topExActNew < Collections.max(totalExpoureNumList)){
topExActNew = Collections.max(totalExpoureNumList);
} else if (topExActNew < Collections.max(totalNewUdidList)){
topExActNew = Collections.max(totalNewUdidList);
}
mktReportFormRspBO.setTopExposureActiveNewUdid(topExActNew);
MktReportFormRspBO mktReportFormRspBO = mktCostReportFormService.getMktReportForm(mktReportFormReqVO);
// MktReportFormRspBO mktReportFormRspBO = new MktReportFormRspBO();
// List<String> dateIdStrList = Lists.newArrayList();
// List<BigDecimal> totalActuralCostList = Lists.newArrayList();
// List<BigDecimal> iosActualCostList = Lists.newArrayList();
// List<BigDecimal> androidActualCostList = Lists.newArrayList();
// List<Integer> totalExpoureNumList = Lists.newArrayList();
// List<Integer> iosExpoureNumList = Lists.newArrayList();
// List<Integer> androidExpoureNumList = Lists.newArrayList();
// List<Integer> totalActiveList = Lists.newArrayList();
// List<Integer> iosActiveList = Lists.newArrayList();
// List<Integer> androidActiveList = Lists.newArrayList();
// List<Integer> totalNewUdidList = Lists.newArrayList();
// List<Integer> iosNewUdidList = Lists.newArrayList();
// List<Integer> androidNewUdidList = Lists.newArrayList();
// List<BigDecimal> totalActiveRatio = Lists.newArrayList();
// List<BigDecimal> iosActiveRatio = Lists.newArrayList();
// List<BigDecimal> androidActiveRatio = Lists.newArrayList();
// List<BigDecimal> totalExpoureRatio = Lists.newArrayList();
// List<BigDecimal> iosExpoureRatio = Lists.newArrayList();
// List<BigDecimal> androidExpoureRatio = Lists.newArrayList();
// List<BigDecimal> totalNewUdidRatio = Lists.newArrayList();
// List<BigDecimal> iosNewUdidRatio = Lists.newArrayList();
// List<BigDecimal> androidNewUdidRatio = Lists.newArrayList();
//
// for (Integer i = 0; i <=6; i++){
// dateIdStrList.add("2017042" + i.toString());
// totalActuralCostList.add(new BigDecimal(5000 - i * 100));
// iosActualCostList.add(new BigDecimal(4000 - i * 80));
// androidActualCostList.add(new BigDecimal(1000 - i * 20));
// totalExpoureNumList.add(1000 - i * 100);
// iosExpoureNumList.add(600 - i * 60);
// androidExpoureNumList.add(400 - i * 40);
// totalActiveList.add(2000 - i * 200);
// iosActiveList.add(1500 - i * 150);
// androidActiveList.add(500 - i * 50);
// totalNewUdidList.add(100 - i * 10);
// iosNewUdidList.add(70 - i * 7);
// androidNewUdidList.add(30 - i * 3);
//
// totalActiveRatio.add(getDivideData(totalActuralCostList.get(i), new BigDecimal(totalActiveList.get(i))));
// iosActiveRatio.add(getDivideData(iosActualCostList.get(i), new BigDecimal(iosActiveList.get(i))));
// androidActiveRatio.add(getDivideData(androidActualCostList.get(i), new BigDecimal(androidActiveList.get(i))));
// totalExpoureRatio.add(getDivideData(totalActuralCostList.get(i), new BigDecimal(totalExpoureNumList.get(i))));
// iosExpoureRatio.add(getDivideData(iosActualCostList.get(i), new BigDecimal(iosExpoureNumList.get(i))));
// androidExpoureRatio.add(getDivideData(androidActualCostList.get(i), new BigDecimal(androidExpoureNumList.get(i))));
// totalNewUdidRatio.add(getDivideData(totalActuralCostList.get(i), new BigDecimal(totalNewUdidList.get(i))));
// iosNewUdidRatio.add(getDivideData(iosActualCostList.get(i), new BigDecimal(iosNewUdidList.get(i))));
// androidNewUdidRatio.add(getDivideData(androidActualCostList.get(i), new BigDecimal(androidNewUdidList.get(i))));
// }
//
// mktReportFormRspBO.setDateIdStrList(dateIdStrList);
// mktReportFormRspBO.setTotalActualCostList(totalActuralCostList);
// mktReportFormRspBO.setIosActualCostList(iosActualCostList);
// mktReportFormRspBO.setAndroidActualCostList(androidActualCostList);
// mktReportFormRspBO.setTotalExposureNumList(totalExpoureNumList);
// mktReportFormRspBO.setIosExposureNumList(iosExpoureNumList);
// mktReportFormRspBO.setAndroidExposureNumList(androidExpoureNumList);
// mktReportFormRspBO.setTotalAppActiveList(totalActiveList);
// mktReportFormRspBO.setIosAppActiveList(iosActiveList);
// mktReportFormRspBO.setAndroidAppActiveList(androidActiveList);
// mktReportFormRspBO.setTotalNewUserList(totalNewUdidList);
// mktReportFormRspBO.setIosNewUserList(iosNewUdidList);
// mktReportFormRspBO.setAndroidNewUserList(androidNewUdidList);
//
// mktReportFormRspBO.setTopActualCost(Collections.max(totalActuralCostList));
//// mktReportFormRspBO.setTopAppActive(Collections.max(totalActiveList));
//// mktReportFormRspBO.setTopExpoureNum(Collections.max(totalExpoureNumList));
//// mktReportFormRspBO.setTopNewUdid(Collections.max(totalNewUdidList));
//
//
// mktReportFormRspBO.setTotalActiveRatioList(totalActiveRatio);
// mktReportFormRspBO.setIosActiveRatioList(iosActiveRatio);
// mktReportFormRspBO.setAndroidActiveRatioList(androidActiveRatio);
// mktReportFormRspBO.setTotalExposureRatioList(totalExpoureRatio);
// mktReportFormRspBO.setIosExposureRatioList(iosExpoureRatio);
// mktReportFormRspBO.setAndroidExposureRatioList(androidExpoureRatio);
// mktReportFormRspBO.setTotalNewUdidRatioList(totalNewUdidRatio);
// mktReportFormRspBO.setIosNewUdidRatioList(iosNewUdidRatio);
// mktReportFormRspBO.setAndroidNewUdidRatioList(androidNewUdidRatio);
//
//// mktReportFormRspBO.setTopActiveRatio(Collections.max(totalActiveRatio));
//// mktReportFormRspBO.setTopNewUdidRatio(Collections.max(totalNewUdidRatio));
//// mktReportFormRspBO.setTopExpoureRatio(Collections.max(totalExpoureRatio));
// BigDecimal topRatio = Collections.max(totalActiveRatio);
// if (topRatio.compareTo(Collections.max(totalNewUdidRatio)) < 0){
// topRatio = Collections.max(totalNewUdidRatio);
// } else if (topRatio.compareTo(Collections.max(totalExpoureRatio)) < 0){
// topRatio = Collections.max(totalExpoureRatio);
// }
// mktReportFormRspBO.setTopRatio(topRatio);
//
// Integer topExActNew = Collections.max(totalActiveList);
// if (topExActNew < Collections.max(totalExpoureNumList)){
// topExActNew = Collections.max(totalExpoureNumList);
// } else if (topExActNew < Collections.max(totalNewUdidList)){
// topExActNew = Collections.max(totalNewUdidList);
// }
// mktReportFormRspBO.setTopExposureActiveNewUdid(topExActNew);
return new ApiResponse.ApiResponseBuilder().code(200).data(mktReportFormRspBO).message("success").build();
... ... @@ -145,11 +145,11 @@ public class MktCostReportFormController {
}
private BigDecimal getDivideData(BigDecimal d1,BigDecimal d2){
if(d2.compareTo(new BigDecimal(0)) == 0){
return new BigDecimal(0);
}
return d1.divide(d2,2,BigDecimal.ROUND_HALF_UP);
}
// private BigDecimal getDivideData(BigDecimal d1,BigDecimal d2){
//
// if(d2.compareTo(new BigDecimal(0)) == 0){
// return new BigDecimal(0);
// }
// return d1.divide(d2,2,BigDecimal.ROUND_HALF_UP);
// }
}
... ...
... ... @@ -3,18 +3,18 @@ package com.yoho.unions.channel.service.impl;
import com.google.common.collect.Lists;
import com.yoho.service.model.union.request.MktReportFormReqVO;
import com.yoho.service.model.union.response.MktReportFormRspBO;
import com.yoho.service.model.union.response.PageMktReportFormRspBO;
import com.yoho.unions.channel.service.IMktCostReportFormService;
import com.yoho.unions.dal.IAppActiveDAO;
import com.yoho.unions.dal.IMktReportFormDAO;
import com.yoho.unions.dal.model.AppActive;
import com.yoho.unions.dal.model.MktReportForm;
import com.yoho.unions.dal.model.MktReportWithAppActive;
import com.yoho.unions.dal.model.MktReportBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
/**
... ... @@ -33,8 +33,6 @@ public class MktCostReportFormServiceImpl implements IMktCostReportFormService {
@Override
public MktReportFormRspBO getMktReportForm(MktReportFormReqVO reportFormReqVO) {
MktReportFormRspBO pageMktReportFormRspBO = new MktReportFormRspBO();
//从APP_ACTIVE中获取数据
Map<String, Integer> queryParam = new HashMap<>();
queryParam.put("beginTime", reportFormReqVO.getBeginTime());
... ... @@ -43,54 +41,223 @@ public class MktCostReportFormServiceImpl implements IMktCostReportFormService {
List<AppActive> appActiveList = appActiveDAO.selectActivationAndActualCostByDateId(queryParam);
List<MktReportForm> mktReportFormList = mktReportFormDAO.selectMktReportFormByDateId(queryParam);
List<String> dateIdStrList = Lists.newArrayList();
List<String> totalActualCostList = Lists.newArrayList();
List<String> iosActualCostList = Lists.newArrayList();
// List<String> dateIdStrList = Lists.newArrayList();
// List<String> dateIdStrList = Lists.newArrayList();
// List<String> dateIdStrList = Lists.newArrayList();
// List<String> dateIdStrList = Lists.newArrayList();
// List<String> dateIdStrList = Lists.newArrayList();
// List<String> dateIdStrList = Lists.newArrayList();
// List<String> dateIdStrList = Lists.newArrayList();
// List<String> dateIdStrList = Lists.newArrayList();
// List<String> dateIdStrList = Lists.newArrayList();
// List<String> dateIdStrList = Lists.newArrayList();
// int resultSize = appActiveList.size() > mktReportFormList.size() ? appActiveList.size() : mktReportFormList.size();
//
//
// if ((!appActiveList.isEmpty()) && (!mktReportFormList.isEmpty())){
// boolean flag = appActiveList.size() > mktReportFormList.size() ? true : false;
// if (flag){
//
// }
// }
return null;
Map<Integer, MktReportBean> resultMap = mergeData(appActiveList, mktReportFormList);
MktReportFormRspBO rspBO = composingResult(resultMap);
return rspBO;
}
private Map<Integer, MktReportBean> mergeData(List<AppActive> appActiveList, List<MktReportForm> mktReportFormList) {
Map<Integer, MktReportBean> resultMap = new TreeMap<>();
if ((!appActiveList.isEmpty()) && !mktReportFormList.isEmpty())
{
setValueToMapForAppActive(resultMap, appActiveList);
for (MktReportForm mktReportForm : mktReportFormList){
Integer dateId = mktReportForm.getDateId();
MktReportBean mktReportBean = null;
if (!resultMap.containsKey(dateId)){
mktReportBean = new MktReportBean();
setMktReportData(mktReportForm, mktReportBean);
} else {
mktReportBean = resultMap.get(mktReportForm.getDateId());
setMktReportData(mktReportForm, mktReportBean);
}
resultMap.put(dateId, mktReportBean);
}
} else if (!appActiveList.isEmpty()){
setValueToMapForAppActive(resultMap, appActiveList);
} else if (!mktReportFormList.isEmpty()){
setValueToMapForMktReportForm(resultMap, mktReportFormList);
} else {
resultMap = null;
}
return resultMap;
}
private void mergeData(List<AppActive> appActiveList, List<MktReportForm> mktReportFormList){
List<MktReportWithAppActive> mktReportWithAppActiveList = Lists.newArrayList();
Set<Integer> dateIdSet = new TreeSet<>();
private void setValueToMapForAppActive(Map<Integer, MktReportBean> resultMap, List<AppActive> appActiveList){
for (AppActive appActive : appActiveList) {
Integer dateId = appActive.getDateId();
MktReportBean mktReportBean = new MktReportBean();
setAppActiveData(appActive, mktReportBean);
resultMap.put(dateId, mktReportBean);
}
}
private void setValueToMapForMktReportForm(Map<Integer, MktReportBean> resultMap, List<MktReportForm> mktReportFormList){
for (MktReportForm mktReportForm : mktReportFormList) {
Integer dateId = mktReportForm.getDateId();
MktReportBean mktReportBean = new MktReportBean();
setMktReportData(mktReportForm, mktReportBean);
resultMap.put(dateId, mktReportBean);
}
}
for (AppActive active : appActiveList){
dateIdSet.add(active.getDateId());
private void setAppActiveData(AppActive appActive, MktReportBean mktReportBean){
if (null != appActive){
if ("yohobuy_ios".equals(appActive.getAppKey())){
mktReportBean.setIosAppActive(appActive.getAppActive());
mktReportBean.setIosNewUdid(appActive.getNewUdid());
} else if ("yohobuy_android".equals(appActive.getAppKey())){
mktReportBean.setAndroidAppActive(appActive.getAppActive());
mktReportBean.setAndroidNewUdid(appActive.getNewUdid());
}
}
}
for (MktReportForm mktReportForm : mktReportFormList){
dateIdSet.add(mktReportForm.getDateId());
private void setMktReportData(MktReportForm mktReportForm, MktReportBean mktReportBean){
if (null != mktReportForm){
if (1 == mktReportForm.getDeviceType()){
mktReportBean.setIosActualCost(mktReportForm.getActualCost());
mktReportBean.setIosExposureNum(mktReportForm.getExposureNum());
} else if (2 == mktReportForm.getDeviceType()){
mktReportBean.setAndroidActualCost(mktReportForm.getActualCost());
mktReportBean.setAndroidExposureNum(mktReportForm.getExposureNum());
}
}
}
private MktReportFormRspBO composingResult(Map<Integer, MktReportBean> resultMap){
List<String> dateIdStrList = Lists.newArrayList();
List<BigDecimal> totalActualCostList = Lists.newArrayList();
List<BigDecimal> iosActualCostList = Lists.newArrayList();
List<BigDecimal> androidActualCostList = Lists.newArrayList();
List<Integer> totalAppActiveList = Lists.newArrayList();
List<Integer> iosAppActiveList = Lists.newArrayList();
List<Integer> androidAppActiveList = Lists.newArrayList();
List<Integer> totalExposureNumList = Lists.newArrayList();
List<Integer> iosExposureNumList = Lists.newArrayList();
List<Integer> androidExposureNumList = Lists.newArrayList();
List<Integer> totalNewUserList = Lists.newArrayList();
List<Integer> iosNewUserList = Lists.newArrayList();
List<Integer> androidNewUserList = Lists.newArrayList();
List<BigDecimal> totalActiveRatioList = Lists.newArrayList();
List<BigDecimal> iosActiveRatioList = Lists.newArrayList();
List<BigDecimal> androidActiveRatioList = Lists.newArrayList();
List<BigDecimal> totalExposureRatioList = Lists.newArrayList();
List<BigDecimal> iosExposureRatioList = Lists.newArrayList();
List<BigDecimal> androidExposureRatioList = Lists.newArrayList();
List<BigDecimal> totalNewUdidRatioList = Lists.newArrayList();
List<BigDecimal> iosNewUdidRatioList = Lists.newArrayList();
List<BigDecimal> androidNewUdidRatioList = Lists.newArrayList();
Iterator it = resultMap.keySet().iterator();
while (it.hasNext()){
Integer dateId = (Integer) it.next();
MktReportBean mktReportBean = resultMap.get(dateId);
//日期
dateIdStrList.add(dateId.toString());
//实际费用
iosActualCostList.add(mktReportBean.getIosActualCost());
androidActualCostList.add(mktReportBean.getAndroidActualCost());
BigDecimal totalActualCost = mktReportBean.getIosActualCost().add(mktReportBean.getAndroidActualCost());
totalActualCostList.add(totalActualCost);
int minDateId = appActiveList.get(0).getDateId() < mktReportFormList.get(0).getDateId() ? appActiveList.get(0).getDateId() : mktReportFormList.get(0).getDateId();
int maxDateId = appActiveList.get(appActiveList.size() - 1).getDateId() > mktReportFormList.get(mktReportFormList.size() - 1).getDateId() ? appActiveList.get(appActiveList.size() - 1).getDateId() : mktReportFormList.get(mktReportFormList.size() - 1).getDateId();
//曝光数
iosExposureNumList.add(mktReportBean.getIosExposureNum());
androidExposureNumList.add(mktReportBean.getAndroidExposureNum());
Integer totalExposureNum = mktReportBean.getIosExposureNum() +mktReportBean.getAndroidExposureNum();
totalExposureNumList.add(totalExposureNum);
//激活数
iosAppActiveList.add(mktReportBean.getIosAppActive());
androidAppActiveList.add(mktReportBean.getAndroidAppActive());
Integer totalAppActive = mktReportBean.getIosAppActive() + mktReportBean.getAndroidAppActive();
totalAppActiveList.add(totalAppActive);
//新客数
iosNewUserList.add(mktReportBean.getIosNewUdid());
androidNewUserList.add(mktReportBean.getAndroidNewUdid());
Integer totalNewUser = mktReportBean.getIosNewUdid() + mktReportBean.getAndroidNewUdid();
totalNewUserList.add(totalNewUser);
//激活转化率
iosActiveRatioList.add(getDivideData(mktReportBean.getIosActualCost(), new BigDecimal(mktReportBean.getIosAppActive())));
androidActiveRatioList.add(getDivideData(mktReportBean.getAndroidActualCost(), new BigDecimal(mktReportBean.getAndroidAppActive())));
totalActiveRatioList.add(getDivideData(totalActualCost, new BigDecimal(totalAppActive)));
//曝光转化率
iosExposureRatioList.add(getDivideData(mktReportBean.getIosActualCost(), new BigDecimal(mktReportBean.getIosExposureNum())));
androidExposureRatioList.add(getDivideData(mktReportBean.getAndroidActualCost(), new BigDecimal(mktReportBean.getAndroidExposureNum())));
iosExposureRatioList.add(getDivideData(totalActualCost, new BigDecimal(totalExposureNum)));
//新客转化率
iosNewUdidRatioList.add(getDivideData(mktReportBean.getIosActualCost(), new BigDecimal(mktReportBean.getIosNewUdid())));
androidNewUdidRatioList.add(getDivideData(mktReportBean.getAndroidActualCost(), new BigDecimal(mktReportBean.getAndroidNewUdid())));
iosNewUdidRatioList.add(getDivideData(totalActualCost, new BigDecimal(totalNewUser)));
}
MktReportFormRspBO mktReportFormRspBO = new MktReportFormRspBO();
//日期
mktReportFormRspBO.setDateIdStrList(dateIdStrList);
//实际费用
mktReportFormRspBO.setIosActualCostList(iosActualCostList);
mktReportFormRspBO.setAndroidActualCostList(androidActualCostList);
mktReportFormRspBO.setTotalActualCostList(totalActualCostList);
//曝光量
mktReportFormRspBO.setIosExposureNumList(iosExposureNumList);
mktReportFormRspBO.setAndroidExposureNumList(androidExposureNumList);
mktReportFormRspBO.setTotalExposureNumList(totalExposureNumList);
//激活量
mktReportFormRspBO.setIosAppActiveList(iosAppActiveList);
mktReportFormRspBO.setAndroidAppActiveList(androidAppActiveList);
mktReportFormRspBO.setTotalAppActiveList(totalAppActiveList);
//新客量
mktReportFormRspBO.setIosNewUserList(iosNewUserList);
mktReportFormRspBO.setAndroidNewUserList(androidNewUserList);
mktReportFormRspBO.setTotalNewUserList(totalNewUserList);
//曝光转化率
mktReportFormRspBO.setIosExposureRatioList(iosExposureRatioList);
mktReportFormRspBO.setAndroidExposureRatioList(androidExposureRatioList);
mktReportFormRspBO.setTotalExposureRatioList(totalExposureRatioList);
//激活转化率
mktReportFormRspBO.setIosActiveRatioList(iosActiveRatioList);
mktReportFormRspBO.setAndroidActiveRatioList(androidActiveRatioList);
mktReportFormRspBO.setTotalActiveRatioList(totalActiveRatioList);
//新客转化率
mktReportFormRspBO.setIosNewUdidRatioList(iosNewUdidRatioList);
mktReportFormRspBO.setAndroidNewUdidRatioList(androidNewUdidRatioList);
mktReportFormRspBO.setTotalNewUdidRatioList(totalNewUdidRatioList);
BigDecimal topRatio = Collections.max(totalExposureRatioList);
if (topRatio.compareTo(Collections.max(totalActiveRatioList)) < 0)
{
topRatio = Collections.max(totalActiveRatioList);
} else if (topRatio.compareTo(Collections.max(totalNewUdidRatioList)) < 0){
topRatio = Collections.max(totalNewUdidRatioList);
}
mktReportFormRspBO.setTopRatio(topRatio);
Integer topExActNew = Collections.max(totalAppActiveList);
if (topExActNew < Collections.max(totalExposureNumList)){
topExActNew = Collections.max(totalExposureNumList);
} else if (topExActNew < Collections.max(totalNewUserList)){
topExActNew = Collections.max(totalNewUserList);
}
mktReportFormRspBO.setTopExposureActiveNewUdid(topExActNew);
return mktReportFormRspBO;
}
for (int dateId = minDateId; maxDateId <= maxDateId;){
private BigDecimal getDivideData(BigDecimal d1,BigDecimal d2){
if(d2.compareTo(new BigDecimal(0)) == 0){
return new BigDecimal(0);
}
return d1.divide(d2,4,BigDecimal.ROUND_HALF_UP);
}
}
... ...
... ... @@ -2,6 +2,7 @@ package com.yoho.unions.dal;
import com.yoho.unions.dal.model.AppActive;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
... ... @@ -19,5 +20,5 @@ public interface IAppActiveDAO {
int updateByPrimaryKey(AppActive record);
List<AppActive> selectActivationAndActualCostByDateId(Map<String, Integer> timeParam);
List<AppActive> selectActivationAndActualCostByDateId(@Param("params") Map<String, Integer> params);
}
\ No newline at end of file
... ...
... ... @@ -2,6 +2,7 @@ package com.yoho.unions.dal;
import com.yoho.unions.dal.model.MktReportForm;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
... ... @@ -19,5 +20,5 @@ public interface IMktReportFormDAO {
int updateByPrimaryKey(MktReportForm record);
List<MktReportForm> selectMktReportFormByDateId(Map<String, Integer> param);
List<MktReportForm> selectMktReportFormByDateId(@Param("params") Map<String, Integer> params);
}
\ No newline at end of file
... ...
... ... @@ -51,5 +51,13 @@ public class AppActive {
this.newUdid = newUdid;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof AppActive) {
AppActive appActive = (AppActive) obj;
return this.getDateId() == appActive.getDateId();
}
return super.equals(obj);
}
}
\ No newline at end of file
... ...
... ... @@ -5,23 +5,33 @@ import java.math.BigDecimal;
/**
* Created by yoho on 2017/4/26.
*/
public class MktReportWithAppActive {
public class MktReportBean {
private Integer dateId;
private Integer appActive;
private BigDecimal totalActualCost;
private String appKey;
private BigDecimal iosActualCost;
private Integer newUdid;
private BigDecimal androidActualCost;
private BigDecimal bookConsum;
private Integer totalAppActive;
private BigDecimal actualCost;
private Integer androidAppActive;
private Integer createTime;
private Integer iosAppActive;
private Integer deviceType;
private Integer totalNewUdid;
private Integer iosNewUdid;
private Integer androidNewUdid;
private Integer totalExposureNum;
private Integer iosExposureNum;
private Integer androidExposureNum;
private Integer divisionCode;
... ... @@ -31,8 +41,6 @@ public class MktReportWithAppActive {
private Integer channelCode;
private Integer exposureNum;
public Integer getDateId() {
return dateId;
}
... ... @@ -41,60 +49,100 @@ public class MktReportWithAppActive {
this.dateId = dateId;
}
public Integer getAppActive() {
return appActive;
public BigDecimal getTotalActualCost() {
return totalActualCost;
}
public void setTotalActualCost(BigDecimal totalActualCost) {
this.totalActualCost = totalActualCost;
}
public BigDecimal getIosActualCost() {
return iosActualCost;
}
public void setIosActualCost(BigDecimal iosActualCost) {
this.iosActualCost = iosActualCost;
}
public BigDecimal getAndroidActualCost() {
return androidActualCost;
}
public void setAndroidActualCost(BigDecimal androidActualCost) {
this.androidActualCost = androidActualCost;
}
public Integer getTotalAppActive() {
return totalAppActive;
}
public void setTotalAppActive(Integer totalAppActive) {
this.totalAppActive = totalAppActive;
}
public Integer getAndroidAppActive() {
return androidAppActive;
}
public void setAppActive(Integer appActive) {
this.appActive = appActive;
public void setAndroidAppActive(Integer androidAppActive) {
this.androidAppActive = androidAppActive;
}
public String getAppKey() {
return appKey;
public Integer getIosAppActive() {
return iosAppActive;
}
public void setAppKey(String appKey) {
this.appKey = appKey;
public void setIosAppActive(Integer iosAppActive) {
this.iosAppActive = iosAppActive;
}
public Integer getNewUdid() {
return newUdid;
public Integer getTotalNewUdid() {
return totalNewUdid;
}
public void setNewUdid(Integer newUdid) {
this.newUdid = newUdid;
public void setTotalNewUdid(Integer totalNewUdid) {
this.totalNewUdid = totalNewUdid;
}
public BigDecimal getBookConsum() {
return bookConsum;
public Integer getIosNewUdid() {
return iosNewUdid;
}
public void setBookConsum(BigDecimal bookConsum) {
this.bookConsum = bookConsum;
public void setIosNewUdid(Integer iosNewUdid) {
this.iosNewUdid = iosNewUdid;
}
public BigDecimal getActualCost() {
return actualCost;
public Integer getAndroidNewUdid() {
return androidNewUdid;
}
public void setActualCost(BigDecimal actualCost) {
this.actualCost = actualCost;
public void setAndroidNewUdid(Integer androidNewUdid) {
this.androidNewUdid = androidNewUdid;
}
public Integer getCreateTime() {
return createTime;
public Integer getTotalExposureNum() {
return totalExposureNum;
}
public void setCreateTime(Integer createTime) {
this.createTime = createTime;
public void setTotalExposureNum(Integer totalExposureNum) {
this.totalExposureNum = totalExposureNum;
}
public Integer getDeviceType() {
return deviceType;
public Integer getIosExposureNum() {
return iosExposureNum;
}
public void setDeviceType(Integer deviceType) {
this.deviceType = deviceType;
public void setIosExposureNum(Integer iosExposureNum) {
this.iosExposureNum = iosExposureNum;
}
public Integer getAndroidExposureNum() {
return androidExposureNum;
}
public void setAndroidExposureNum(Integer androidExposureNum) {
this.androidExposureNum = androidExposureNum;
}
public Integer getDivisionCode() {
... ... @@ -128,12 +176,4 @@ public class MktReportWithAppActive {
public void setChannelCode(Integer channelCode) {
this.channelCode = channelCode;
}
public Integer getExposureNum() {
return exposureNum;
}
public void setExposureNum(Integer exposureNum) {
this.exposureNum = exposureNum;
}
}
... ...
... ... @@ -161,4 +161,19 @@
exposure_num = #{exposureNum,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectMktReportFormByDateId" parameterType="java.util.Map" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from mkt_report_form
<include refid="WHERE_CONDITION"/>
</select>
<sql id="WHERE_CONDITION">
<trim prefix="where" prefixOverrides="and | or">
<if test="params.channelCode != null and params.channelCode != ''">and channel_code=#{params.channelCode}</if>
<if test="params.beginTime != null and params.beginTime != ''"><![CDATA[ and date_id>=#{params.beginTime}]]></if>
<if test="params.endTime != null and params.endTime != ''"><![CDATA[ and date_id<=#{params.endTime}]]></if>
</trim>
</sql>
</mapper>
\ No newline at end of file
... ...
... ... @@ -62,8 +62,8 @@
['费用','曝光量','曝光成本'],
data.data.dateIdStrList,
data.data.totalActualCostList,
data.data.totalExpoureNumList,
data.data.totalExpoureRatio,
data.data.totalExposureNumList,
data.data.totalExposureRatioList,
data.data.topActualCost,
data.data.topExposureActiveNewUdid,
data.data.topRatio);
... ... @@ -73,8 +73,8 @@
['费用','曝光量','曝光成本'],
data.data.dateIdStrList,
data.data.iosActualCostList,
data.data.iosExpoureNumList,
data.data.iosExpoureRatio,
data.data.iosExposureNumList,
data.data.iosExposureRatioList,
data.data.topActualCost,
data.data.topExposureActiveNewUdid,data.data.topRatio);
drawEchart('exposure_ios',exposureIosOption);
... ... @@ -82,9 +82,9 @@
var exposureAndroidOption = getEchartOption("android市场费用/曝光量",
['费用','曝光量','曝光成本'],
data.data.dateIdStrList,
data.data.androidActualCost,
data.data.androidExpoureNumList,
data.data.androidExpoureRatio,
data.data.androidActualCostList,
data.data.androidExposureNumList,
data.data.androidExposureRatioList,
data.data.topActualCost,
data.data.topExposureActiveNewUdid,data.data.topRatio);
drawEchart('exposure_android',exposureAndroidOption);
... ... @@ -95,7 +95,7 @@
data.data.dateIdStrList,
data.data.totalActualCostList,
data.data.totalAppActiveList,
data.data.totalActiveRatio,
data.data.totalActiveRatioList,
data.data.topActualCost,
data.data.topExposureActiveNewUdid,
data.data.topRatio);
... ... @@ -106,7 +106,7 @@
data.data.dateIdStrList,
data.data.iosActualCostList,
data.data.iosAppActiveList,
data.data.iosActiveRatio,
data.data.iosActiveRatioList,
data.data.topActualCost,
data.data.topExposureActiveNewUdid,data.data.topRatio);
drawEchart('active_ios',activeIosOption);
... ... @@ -114,9 +114,9 @@
var activeAndroidOption = getEchartOption("android端市场费用/激活量",
['费用','激活量','激活成本'],
data.data.dateIdStrList,
data.data.androidActualCost,
data.data.androidActualCostList,
data.data.androidAppActiveList,
data.data.androidActiveRatio,
data.data.androidActiveRatioList,
data.data.topActualCost,
data.data.topExposureActiveNewUdid,data.data.topRatio);
drawEchart('active_android',activeAndroidOption);
... ... @@ -127,7 +127,7 @@
data.data.dateIdStrList,
data.data.totalActualCostList,
data.data.totalNewUserList,
data.data.totalNewUdidRatio,
data.data.totalNewUdidRatioList,
data.data.topActualCost,
data.data.topExposureActiveNewUdid,data.data.topRatio);
drawEchart('newuser',newuserOption);
... ... @@ -137,7 +137,7 @@
data.data.dateIdStrList,
data.data.iosActualCostList,
data.data.iosNewUserList,
data.data.iosNewUdidRatio,
data.data.iosNewUdidRatioList,
data.data.topActualCost,
data.data.topExposureActiveNewUdid,data.data.topRatio);
drawEchart('newuser_ios',newuserIosOption);
... ... @@ -145,9 +145,9 @@
var newuserAndroidOption = getEchartOption("android市场费用/新客量",
['费用','新客量','新客成本'],
data.data.dateIdStrList,
data.data.androidActualCost,
data.data.androidActualCostList,
data.data.androidNewUserList,
data.data.androidNewUdidRatio,
data.data.androidNewUdidRatioList,
data.data.topActualCost,
data.data.topExposureActiveNewUdid,data.data.topRatio);
drawEchart('newuser_android',newuserAndroidOption);
... ...
... ... @@ -46,7 +46,7 @@
<th width="18%" data-options="field:'dateIdStr',align:'center'">日期</th>
<th width="15%" data-options="field:'totalActualCost',align:'center'">实际总成本</th>
<th width="15%" data-options="field:'iosActualCost',align:'center'">ios实际成本</th>
<th width="15%" data-options="field:'androidActualCost',align:'center'">android实际成本</th>
<th width="15%" data-options="field:'androidActualCostList',align:'center'">android实际成本</th>
<th width="15%" data-options="field:'totalClickNum',align:'center'">总点击量</th>
<th width="15%" data-options="field:'iosClickNum',align:'center'">ios点击量</th>
<th width="15%" data-options="field:'androidClickNum',align:'center'">android点击量</th>
... ...