Authored by tanling

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

... ... @@ -70,6 +70,10 @@
<artifactId>yoho-message-sdk</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yoho.service.model</groupId>
<artifactId>union-service-model</artifactId>
</dependency>
</dependencies>
... ...
package com.yoho.unions.channel.restapi;
import com.alibaba.fastjson.JSONArray;
import com.google.common.collect.Lists;
import com.google.gson.Gson;
import com.yoho.service.model.union.request.ChannelBlackListRequestBO;
import com.yoho.service.model.union.request.ChannelGroupRequestBO;
import com.yoho.service.model.union.request.MktReportFormReqVO;
import com.yoho.service.model.union.response.MktReportFormRspBO;
import com.yoho.service.model.union.response.PageBlackListRspBO;
import com.yoho.service.model.union.response.PageChannelGroupRspBO;
import com.yoho.service.model.union.response.PageMktReportFormRspBO;
import com.yoho.unions.channel.service.IChannelBlackListService;
import com.yoho.unions.channel.service.IMktCostReportFormService;
import com.yoho.unions.common.ApiResponse;
import com.yoho.unions.common.utils.PhoneUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
... ... @@ -61,6 +50,15 @@ public class MktCostReportFormController {
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 = 6; i >=0; i--){
dateIdStrList.add("2017042" + i.toString());
... ... @@ -76,6 +74,16 @@ public class MktCostReportFormController {
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))));
androidActiveRatio.add(getDivideData(androidActualCostList.get(i), new BigDecimal(androidNewUdidList.get(i))));
}
mktReportFormRspBO.setDateIdStrList(dateIdStrList);
... ... @@ -91,12 +99,10 @@ public class MktCostReportFormController {
mktReportFormRspBO.setTotalNewUserList(totalNewUdidList);
mktReportFormRspBO.setIosNewUserList(iosNewUdidList);
mktReportFormRspBO.setAndroidNewUserList(androidNewUdidList);
mktReportFormRspBO.setMaxActualCost(500);
mktReportFormRspBO.setMaxAppActive(400);
mktReportFormRspBO.setMaxExpoureNum(300);
mktReportFormRspBO.setMaxNewUdid(200);
mktReportFormRspBO.setTopActualCost(5000);
mktReportFormRspBO.setTopAppActive(1000);
mktReportFormRspBO.setTopExpoureNum(2000);
mktReportFormRspBO.setTopNewUdid(100);
return new ApiResponse.ApiResponseBuilder().code(200).data(mktReportFormRspBO).message("success").build();
} catch (Exception e){
... ... @@ -105,4 +111,12 @@ 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);
}
}
... ...
package com.yoho.unions.channel.service;
import com.yoho.service.model.union.request.MktReportFormReqVO;
import com.yoho.service.model.union.response.MktReportFormRspBO;
/**
* Created by yoho on 2017/4/26.
*/
public interface IMktCostReportFormService {
MktReportFormRspBO getMktReportForm(MktReportFormReqVO reportFormReqVO);
}
... ...
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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* Created by yoho on 2017/4/26.
*/
@Service
public class MktCostReportFormServiceImpl implements IMktCostReportFormService {
static Logger logger = LoggerFactory.getLogger(MktCostReportFormServiceImpl.class);
@Autowired
private IMktReportFormDAO mktReportFormDAO;
@Autowired
private IAppActiveDAO appActiveDAO;
@Override
public MktReportFormRspBO getMktReportForm(MktReportFormReqVO reportFormReqVO) {
MktReportFormRspBO pageMktReportFormRspBO = new MktReportFormRspBO();
//从APP_ACTIVE中获取数据
Map<String, Integer> queryParam = new HashMap<>();
queryParam.put("beginTime", reportFormReqVO.getBeginTime());
queryParam.put("endTime", reportFormReqVO.getEndTime());
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;
}
private void mergeData(List<AppActive> appActiveList, List<MktReportForm> mktReportFormList){
List<MktReportWithAppActive> mktReportWithAppActiveList = Lists.newArrayList();
Set<Integer> dateIdSet = new TreeSet<>();
for (AppActive active : appActiveList){
dateIdSet.add(active.getDateId());
}
for (MktReportForm mktReportForm : mktReportFormList){
dateIdSet.add(mktReportForm.getDateId());
}
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();
for (int dateId = minDateId; maxDateId <= maxDateId){
}
}
}
... ...
... ... @@ -3,6 +3,9 @@ package com.yoho.unions.dal;
import com.yoho.unions.dal.model.AppActive;
import java.util.List;
import java.util.Map;
public interface IAppActiveDAO {
int deleteByPrimaryKey(Integer id);
... ... @@ -15,4 +18,6 @@ public interface IAppActiveDAO {
int updateByPrimaryKeySelective(AppActive record);
int updateByPrimaryKey(AppActive record);
List<AppActive> selectActivationAndActualCostByDateId(Map<String, Integer> timeParam);
}
\ No newline at end of file
... ...
... ... @@ -3,6 +3,9 @@ package com.yoho.unions.dal;
import com.yoho.unions.dal.model.MktReportForm;
import java.util.List;
import java.util.Map;
public interface IMktReportFormDAO {
int deleteByPrimaryKey(Integer id);
... ... @@ -15,4 +18,6 @@ public interface IMktReportFormDAO {
int updateByPrimaryKeySelective(MktReportForm record);
int updateByPrimaryKey(MktReportForm record);
List<MktReportForm> selectMktReportFormByDateId(Map<String, Integer> param);
}
\ No newline at end of file
... ...
... ... @@ -50,4 +50,6 @@ public class AppActive {
public void setNewUdid(Integer newUdid) {
this.newUdid = newUdid;
}
}
\ No newline at end of file
... ...
package com.yoho.unions.dal.model;
import java.math.BigDecimal;
/**
* Created by yoho on 2017/4/26.
*/
public class MktReportWithAppActive {
private Integer dateId;
private Integer appActive;
private String appKey;
private Integer newUdid;
private BigDecimal bookConsum;
private BigDecimal actualCost;
private Integer createTime;
private Integer deviceType;
private Integer divisionCode;
private Integer businessCode;
private Integer classCode;
private Integer channelCode;
private Integer exposureNum;
public Integer getDateId() {
return dateId;
}
public void setDateId(Integer dateId) {
this.dateId = dateId;
}
public Integer getAppActive() {
return appActive;
}
public void setAppActive(Integer appActive) {
this.appActive = appActive;
}
public String getAppKey() {
return appKey;
}
public void setAppKey(String appKey) {
this.appKey = appKey;
}
public Integer getNewUdid() {
return newUdid;
}
public void setNewUdid(Integer newUdid) {
this.newUdid = newUdid;
}
public BigDecimal getBookConsum() {
return bookConsum;
}
public void setBookConsum(BigDecimal bookConsum) {
this.bookConsum = bookConsum;
}
public BigDecimal getActualCost() {
return actualCost;
}
public void setActualCost(BigDecimal actualCost) {
this.actualCost = actualCost;
}
public Integer getCreateTime() {
return createTime;
}
public void setCreateTime(Integer createTime) {
this.createTime = createTime;
}
public Integer getDeviceType() {
return deviceType;
}
public void setDeviceType(Integer deviceType) {
this.deviceType = deviceType;
}
public Integer getDivisionCode() {
return divisionCode;
}
public void setDivisionCode(Integer divisionCode) {
this.divisionCode = divisionCode;
}
public Integer getBusinessCode() {
return businessCode;
}
public void setBusinessCode(Integer businessCode) {
this.businessCode = businessCode;
}
public Integer getClassCode() {
return classCode;
}
public void setClassCode(Integer classCode) {
this.classCode = classCode;
}
public Integer getChannelCode() {
return channelCode;
}
public void setChannelCode(Integer channelCode) {
this.channelCode = channelCode;
}
public Integer getExposureNum() {
return exposureNum;
}
public void setExposureNum(Integer exposureNum) {
this.exposureNum = exposureNum;
}
}
... ...
... ... @@ -90,4 +90,18 @@
NEW_UDID = #{newUdid,jdbcType=INTEGER}
where ID = #{id,jdbcType=INTEGER}
</update>
<select id="selectActivationAndActualCostByDateId" parameterType="java.util.Map" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from APP_ACTIVE
<include refid="WHERE_CONDITION"/>
</select>
<sql id="WHERE_CONDITION">
<trim prefix="where" prefixOverrides="and | or">
<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
... ...
... ... @@ -61,4 +61,14 @@
</table>
</div>
</div>
</body>
\ No newline at end of file
</body>
<script>
$(function(){
var date = new Date();
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
$('#beginTime').datebox('setValue', year + '-' + month + '-' + (day-1));
})
</script>
\ No newline at end of file
... ...