Commit a9e3726a authored by 廖旭伟's avatar 廖旭伟

页面信息流分析、页面使用习惯分析功能修改

parent b0f1c775
...@@ -5542,8 +5542,10 @@ dateTimeStart|String|是|结束时间 ...@@ -5542,8 +5542,10 @@ dateTimeStart|String|是|结束时间
``` ```
{ {
"productId":1, "productId":1,
"dateTimeStart":"2023-04-10", "dateTimeStart":"2023-04-15",
"dateTimeEnd":"2023-05-11" "dateTimeEnd":"2023-04-15",
"particleType":1,
"isRatio":1
} }
``` ```
...@@ -5555,6 +5557,7 @@ code|Integer|结果码(-1.失败,1.成功) ...@@ -5555,6 +5557,7 @@ code|Integer|结果码(-1.失败,1.成功)
msg|String|消息 msg|String|消息
data|array|数据对象 data|array|数据对象
 productId|long|产品id  productId|long|产品id
 dateStr|String|分组时间
 productName|String|产品名称  productName|String|产品名称
 firstCode|String|一级场景code  firstCode|String|一级场景code
 firstName|String|一级场景name  firstName|String|一级场景name
...@@ -5566,6 +5569,8 @@ data|array|数据对象 ...@@ -5566,6 +5569,8 @@ data|array|数据对象
 fourthName|String|四级场景name  fourthName|String|四级场景name
 accessCount|int|访问次数,打开次数  accessCount|int|访问次数,打开次数
 pageDepth|int|访问页面数  pageDepth|int|访问页面数
 accessRatio|int|访问次数增量
 depthRatio|int|访问页面数增量
**响应消息样例:** **响应消息样例:**
``` ```
...@@ -5574,6 +5579,10 @@ data|array|数据对象 ...@@ -5574,6 +5579,10 @@ data|array|数据对象
{ {
"deleted": 0, "deleted": 0,
"accessCount": 1, "accessCount": 1,
"dateStr": "2023-04-15 21:00:00",
"timeStr": "21:00:00",
"accessRatio": 0.0,
"depthRatio": 0.0,
"productId": 1, "productId": 1,
"productName": "导视机", "productName": "导视机",
"firstCode": "/", "firstCode": "/",
...@@ -5584,13 +5593,69 @@ data|array|数据对象 ...@@ -5584,13 +5593,69 @@ data|array|数据对象
"thirdName": "--", "thirdName": "--",
"fourthCode": "--", "fourthCode": "--",
"fourthName": "--", "fourthName": "--",
"pageDepth": 1 "pageDepth": 2
},
{
"deleted": 0,
"accessCount": 2,
"dateStr": "2023-04-15 21:10:00",
"timeStr": "21:10:00",
"accessRatio": -0.33,
"depthRatio": 0.0,
"productId": 1,
"productName": "导视机",
"firstCode": "/",
"firstName": "首页",
"secondCode": "/floor",
"secondName": "中心导航",
"thirdCode": "--",
"thirdName": "--",
"fourthCode": "--",
"fourthName": "--",
"pageDepth": 2
},
{
"deleted": 0,
"accessCount": 2,
"dateStr": "2023-04-15 21:20:00",
"timeStr": "21:20:00",
"accessRatio": -0.33,
"depthRatio": 0.0,
"productId": 1,
"productName": "导视机",
"firstCode": "/",
"firstName": "首页",
"secondCode": "/floor",
"secondName": "中心导航",
"thirdCode": "--",
"thirdName": "--",
"fourthCode": "--",
"fourthName": "--",
"pageDepth": 2
},
{
"deleted": 0,
"accessCount": 2,
"dateStr": "2023-04-15 21:30:00",
"timeStr": "21:30:00",
"accessRatio": -0.33,
"depthRatio": 0.0,
"productId": 1,
"productName": "导视机",
"firstCode": "/",
"firstName": "首页",
"secondCode": "/floor",
"secondName": "中心导航",
"thirdCode": "--",
"thirdName": "--",
"fourthCode": "--",
"fourthName": "--",
"pageDepth": 2
} }
], ],
"code": 1, "code": 1,
"msg": "查询信息流分析成功" "msg": "查询信息流分析成功"
} }
``` ```
......
...@@ -2,6 +2,8 @@ package com.mortals.xhx.module.page.model.pdu; ...@@ -2,6 +2,8 @@ package com.mortals.xhx.module.page.model.pdu;
import lombok.Data; import lombok.Data;
import java.util.List;
/** /**
* 页面统计查询 * 页面统计查询
*/ */
...@@ -15,4 +17,13 @@ public class PageCensusPdu { ...@@ -15,4 +17,13 @@ public class PageCensusPdu {
private String dateTimeEnd; private String dateTimeEnd;
/** 页面编码 **/ /** 页面编码 **/
private String pageCode; private String pageCode;
/** 颗粒度 **/
private Integer particleSize;
/** 颗粒度 **/
private Integer particleType;
/** 是否开启对比 **/
private Integer isRatio;
/** 业务编码 **/
private String businessCode;
private List<String> businessCodeList;
} }
package com.mortals.xhx.module.page.model.vo; package com.mortals.xhx.module.page.model.vo;
import com.mortals.framework.model.BaseEntityLong; import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.page.model.PageAccessEntity;
import lombok.Data; import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/** /**
* 产品页面配置视图对象 * 产品页面配置视图对象
* *
...@@ -15,4 +12,12 @@ import java.util.List; ...@@ -15,4 +12,12 @@ import java.util.List;
public class PageAccessVo extends BaseEntityLong { public class PageAccessVo extends BaseEntityLong {
/** 访问次数 */ /** 访问次数 */
private Integer accessCount; private Integer accessCount;
/** 统计显示日期 */
private String dateStr;
/** 统计显示时间 */
private String timeStr;
/** 访问人数增长度 */
private float accessRatio;
/** 页面数量增长度 */
private float depthRatio;
} }
\ No newline at end of file
package com.mortals.xhx.module.page.service.impl; package com.mortals.xhx.module.page.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.util.DateUtils;
import com.mortals.framework.util.StringUtils; import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.module.page.model.pdu.BuryPointPdu; import com.mortals.xhx.module.page.model.pdu.BuryPointPdu;
import com.mortals.xhx.module.page.model.pdu.PageCensusPdu; import com.mortals.xhx.module.page.model.pdu.PageCensusPdu;
...@@ -12,10 +13,10 @@ import com.mortals.xhx.module.page.dao.PageAccessDao; ...@@ -12,10 +13,10 @@ import com.mortals.xhx.module.page.dao.PageAccessDao;
import com.mortals.xhx.module.page.model.PageAccessEntity; import com.mortals.xhx.module.page.model.PageAccessEntity;
import com.mortals.xhx.module.page.service.PageAccessService; import com.mortals.xhx.module.page.service.PageAccessService;
import java.text.DecimalFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.*;
import java.util.List;
/** /**
* PageAccessService * PageAccessService
...@@ -85,13 +86,75 @@ public class PageAccessServiceImpl extends AbstractCRUDServiceImpl<PageAccessDao ...@@ -85,13 +86,75 @@ public class PageAccessServiceImpl extends AbstractCRUDServiceImpl<PageAccessDao
if(pdu.getProductId()==null){ if(pdu.getProductId()==null){
throw new AppException("产品id不能为空"); throw new AppException("产品id不能为空");
} }
if(pdu.getParticleType()==null){
pdu.setParticleSize(60*60);
}else if(pdu.getParticleType()==1){
pdu.setParticleSize(10*60); //时间间隔10分钟
}else if(pdu.getParticleType()==2){
pdu.setParticleSize(30*60); //时间间隔30分钟
}else {
pdu.setParticleSize(60*60); //时间间隔1小时
}
String lastDay ="";
try{ try{
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date1 = sdf.parse(pdu.getDateTimeStart()); Date date1 = sdf.parse(pdu.getDateTimeStart());
Date date2 = sdf.parse(pdu.getDateTimeEnd()); Date date2 = sdf.parse(pdu.getDateTimeEnd());
Calendar cd = Calendar.getInstance();
cd.setTime(date1);
cd.add(Calendar.DATE, -1);
lastDay = sdf.format(cd.getTime());
}catch (ParseException e){ }catch (ParseException e){
throw new AppException("日期格式错误,应为yyyy-MM-dd"); throw new AppException("日期格式错误,应为yyyy-MM-dd");
} }
return dao.getInformationFlow(pdu); if(pdu.getIsRatio()!=null && pdu.getIsRatio()==1){
List<PageAccessEntity> todayList = dao.getInformationFlow(pdu);
pdu.setDateTimeStart(lastDay);
pdu.setDateTimeEnd(lastDay);
List<PageAccessEntity> lastList = dao.getInformationFlow(pdu);
Map<String,PageAccessEntity> mp = new HashMap<>();
if(CollectionUtils.isNotEmpty(lastList)){
for (PageAccessEntity item:lastList){
String key = item.getTimeStr()+"_"+item.getFirstCode()+"_"+item.getSecondCode()+"_"+item.getThirdCode()+"_"+item.getFourthCode();
mp.put(key,item);
}
}
if(CollectionUtils.isNotEmpty(todayList)){
for (PageAccessEntity item:todayList){
if(item!=null) {
DecimalFormat decimalFormat=new DecimalFormat(".00");
String key = item.getTimeStr() + "_" + item.getFirstCode() + "_" + item.getSecondCode() + "_" + item.getThirdCode() + "_" + item.getFourthCode();
if (mp.containsKey(key)) {
PageAccessEntity last = mp.get(key);
if (last != null && last.getAccessCount() != null) {
float ac = (float)(item.getAccessCount() - last.getAccessCount());
float lc = (float)last.getAccessCount();
float p = ac/lc;
String s = decimalFormat.format(p);
item.setAccessRatio(Float.valueOf(s));
}else {
item.setAccessRatio(Float.valueOf("0.00"));
}
if (last != null && last.getAccessCount() != null) {
float ad = (float)(item.getPageDepth() - last.getPageDepth());
float ld = (float)last.getPageDepth();
float pd = ad/ld;
String sd = decimalFormat.format(pd);
item.setDepthRatio(Float.valueOf(sd));
}else {
item.setDepthRatio(Float.valueOf("0.00"));
}
}else {
item.setAccessRatio(Float.valueOf("0.00"));
item.setDepthRatio(Float.valueOf("0.00"));
}
}
}
}
return todayList;
}else {
//无需对比
return dao.getInformationFlow(pdu);
}
} }
} }
\ No newline at end of file
...@@ -23,10 +23,7 @@ import com.mortals.xhx.module.page.service.PageEventService; ...@@ -23,10 +23,7 @@ import com.mortals.xhx.module.page.service.PageEventService;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* PageEventService * PageEventService
...@@ -205,6 +202,13 @@ public class PageEventServiceImpl extends AbstractCRUDServiceImpl<PageEventDao, ...@@ -205,6 +202,13 @@ public class PageEventServiceImpl extends AbstractCRUDServiceImpl<PageEventDao,
if(pdu.getProductId()==null){ if(pdu.getProductId()==null){
throw new AppException("产品id不能为空"); throw new AppException("产品id不能为空");
} }
if(StringUtils.isNotEmpty(pdu.getBusinessCode())){
List<String> codeList = new ArrayList<>();
for(String s:pdu.getBusinessCode().split(",")){
codeList.add(s);
}
pdu.setBusinessCodeList(codeList);
}
try{ try{
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date1 = sdf.parse(pdu.getDateTimeStart()); Date date1 = sdf.parse(pdu.getDateTimeStart());
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
<!-- 信息流分析 --> <!-- 信息流分析 -->
<select id="getInformationFlow" parameterType="com.mortals.xhx.module.page.model.pdu.PageCensusPdu" resultType="com.mortals.xhx.module.page.model.PageAccessEntity"> <select id="getInformationFlow" parameterType="com.mortals.xhx.module.page.model.pdu.PageCensusPdu" resultType="com.mortals.xhx.module.page.model.PageAccessEntity">
SELECT SELECT
FROM_UNIXTIME(floor(unix_timestamp(t.createTime)/(#{particleSize}))*#{particleSize},'%Y-%m-%d %k:%i:%s') AS dateStr,
FROM_UNIXTIME(floor(unix_timestamp(t.createTime)/(#{particleSize}))*#{particleSize},'%k:%i:%s') AS timeStr,
t.productId, t.productId,
t.productName, t.productName,
t.firstCode, t.firstCode,
...@@ -32,6 +34,7 @@ ...@@ -32,6 +34,7 @@
IFNULL(t.thirdCode,'--'), IFNULL(t.thirdCode,'--'),
IFNULL(t.thirdName,'--'), IFNULL(t.thirdName,'--'),
IFNULL(t.fourthCode,'--'), IFNULL(t.fourthCode,'--'),
IFNULL(t.fourthName,'--') IFNULL(t.fourthName,'--'),
FLOOR(unix_timestamp(t.createTime)/#{particleSize})
</select> </select>
</mapper> </mapper>
\ No newline at end of file
...@@ -97,6 +97,12 @@ ...@@ -97,6 +97,12 @@
AND t.createTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{dateTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s') AND t.createTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{dateTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s')
AND t.businessCode IS NOT NULL AND t.businessCode IS NOT NULL
AND t.businessCode !='' AND t.businessCode !=''
<if test="businessCodeList != null and businessCodeList.size() > 0">
AND t.businessCode in
<foreach collection="businessCodeList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
GROUP BY GROUP BY
t.businessCode, t.businessCode,
t.businessName t.businessName
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment