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

天府通办数据汇聚接口修改

parent d242eb2e
......@@ -3,6 +3,7 @@ package com.mortals.xhx.daemon.task;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.framework.util.DateUtils;
import com.mortals.xhx.feign.site.ISiteFeign;
import com.mortals.xhx.module.converge.service.ConvergeAppsService;
import com.mortals.xhx.module.converge.service.ConvergeDeviceService;
......@@ -41,7 +42,8 @@ public class ProvinceConvergeTaskImpl implements ITaskExcuteService {
log.error("汇聚设备数据出错",e);
}
try {
convergeAppsService.doConvergeApps();
String dateTime = DateUtils.getCurrStrDate();
convergeAppsService.doConvergeApps(dateTime);
}catch (Exception e){
log.error("汇聚应用数据出错",e);
......
......@@ -19,11 +19,11 @@ public interface ConvergeAppsAccessDao extends ICRUDDao<ConvergeAppsAccessEntit
* 应用浏览量PV统计
* @return
*/
List<AppsAccessVo> getAppsAccessPv();
List<AppsAccessVo> getAppsAccessPv(String startTime);
/**
* 应用浏览量UV统计
* @return
*/
List<AppsAccessVo> getAppsAccessUv();
List<AppsAccessVo> getAppsAccessUv(String startTime);
}
......@@ -19,12 +19,12 @@ public class ConvergeAppsAccessDaoImpl extends BaseCRUDDaoMybatis<ConvergeAppsAc
@Override
public List<AppsAccessVo> getAppsAccessPv() {
return this.getSqlSession().selectList(this.getSqlId("getAppsAccessPv"));
public List<AppsAccessVo> getAppsAccessPv(String startTime) {
return this.getSqlSession().selectList(this.getSqlId("getAppsAccessPv"),startTime);
}
@Override
public List<AppsAccessVo> getAppsAccessUv() {
return this.getSqlSession().selectList(this.getSqlId("getAppsAccessUv"));
public List<AppsAccessVo> getAppsAccessUv(String startTime) {
return this.getSqlSession().selectList(this.getSqlId("getAppsAccessUv"),startTime);
}
}
......@@ -10,12 +10,16 @@ import lombok.Data;
* 设备应用实体对象
*
* @author zxfei
* @date 2023-06-12
* @date 2023-07-06
*/
@Data
public class ConvergeAppsEntity extends ConvergeAppsVo {
private static final long serialVersionUID = 1L;
/**
* 站点id
*/
private Long siteId;
/**
* 设备ID
*/
......@@ -43,19 +47,19 @@ public class ConvergeAppsEntity extends ConvergeAppsVo {
/**
* 应用访问数
*/
private Integer pv;
private Integer totalPv;
/**
* 应用访客数
*/
private Integer uv;
private Integer totalUv;
/**
* 操作类型
*/
private String opr;
/**
* 站点id
* 统计月份,格式yyyy-MM-dd
*/
private Long siteId;
private String statYearMonth;
@Override
public int hashCode() {
return this.getId().hashCode();
......@@ -74,6 +78,8 @@ public class ConvergeAppsEntity extends ConvergeAppsVo {
public void initAttrValue(){
this.siteId = -1L;
this.equipmentId = -1L;
this.appEname = "";
......@@ -86,12 +92,12 @@ public class ConvergeAppsEntity extends ConvergeAppsVo {
this.origin = "";
this.pv = -1;
this.totalPv = -1;
this.uv = -1;
this.totalUv = -1;
this.opr = "";
this.siteId = -1L;
this.statYearMonth = "";
}
}
\ No newline at end of file
......@@ -27,11 +27,15 @@ public class AppVO {
/**
* 应用访问数
*/
private Integer pv;
private Integer totalPv;
/**
* 应用访客数
*/
private Integer uv;
private Integer totalUv;
/**
* 统计月份,格式yyyy-MM-dd
*/
private String statYearMonth;
/**
* 操作类型
*/
......
......@@ -35,10 +35,14 @@ public class AppsAccessVo {
/**
* 应用访问数
*/
private Integer pv;
private Integer totalPv;
/**
* 应用访客数
*/
private Integer uv;
private Integer totalUv;
/**
* 统计月份,格式yyyy-MM-dd
*/
private String statYearMonth;
}
......@@ -23,11 +23,11 @@ public interface ConvergeAppsAccessService extends ICRUDService<ConvergeAppsAcce
* 应用浏览量PV统计
* @return
*/
List<AppsAccessVo> getAppsAccessPv() throws AppException;
List<AppsAccessVo> getAppsAccessPv(String startTime) throws AppException;
/**
* 应用浏览量UV统计
* @return
*/
List<AppsAccessVo> getAppsAccessUv() throws AppException;
List<AppsAccessVo> getAppsAccessUv(String startTime) throws AppException;
}
\ No newline at end of file
......@@ -19,5 +19,5 @@ public interface ConvergeAppsService extends ICRUDService<ConvergeAppsEntity,Lon
* 天府通办数据汇聚
* @throws AppException
*/
void doConvergeApps() throws AppException;
void doConvergeApps(String startTime) throws AppException;
}
\ No newline at end of file
......@@ -23,12 +23,12 @@ import java.util.List;
public class ConvergeAppsAccessServiceImpl extends AbstractCRUDServiceImpl<ConvergeAppsAccessDao, ConvergeAppsAccessEntity, Long> implements ConvergeAppsAccessService {
@Override
public List<AppsAccessVo> getAppsAccessPv() throws AppException {
return dao.getAppsAccessPv();
public List<AppsAccessVo> getAppsAccessPv(String startTime) throws AppException {
return dao.getAppsAccessPv(startTime);
}
@Override
public List<AppsAccessVo> getAppsAccessUv() throws AppException {
return dao.getAppsAccessUv();
public List<AppsAccessVo> getAppsAccessUv(String startTime) throws AppException {
return dao.getAppsAccessUv(startTime);
}
}
\ No newline at end of file
......@@ -38,15 +38,15 @@ public class ConvergeAppsServiceImpl extends AbstractCRUDServiceImpl<ConvergeApp
private ConvergeDeviceService convergeDeviceService;
@Override
public void doConvergeApps() throws AppException {
List<AppsAccessVo> accessPvList = convergeAppsAccessService.getAppsAccessPv();
List<AppsAccessVo> accessUvList = convergeAppsAccessService.getAppsAccessUv();
public void doConvergeApps(String startTime) throws AppException {
List<AppsAccessVo> accessPvList = convergeAppsAccessService.getAppsAccessPv(startTime);
List<AppsAccessVo> accessUvList = convergeAppsAccessService.getAppsAccessUv(startTime);
if(CollectionUtils.isEmpty(accessPvList)||CollectionUtils.isEmpty(accessUvList)){
return;
}else {
Map<String,AppsAccessVo> uvMap = new HashMap<>();
for (AppsAccessVo vo:accessUvList){
String key = vo.getSiteId()+"_"+vo.getEquipmentId()+"_"+vo.getAppEname();
String key = vo.getSiteId()+"_"+vo.getEquipmentId()+"_"+vo.getAppEname()+"_"+vo.getStatYearMonth();
uvMap.put(key,vo);
}
List<ConvergeAppsEntity> appsList = new ArrayList<>();
......@@ -70,19 +70,20 @@ public class ConvergeAppsServiceImpl extends AbstractCRUDServiceImpl<ConvergeApp
entity.setProvider(item.getProvider());
entity.setOrigin(item.getOrigin());
entity.setSiteId(item.getSiteId());
entity.setPv(item.getPv());
String key = item.getSiteId()+"_"+item.getEquipmentId()+"_"+item.getAppEname();
entity.setTotalPv(item.getTotalPv());
entity.setStatYearMonth(item.getStatYearMonth());
String key = item.getSiteId()+"_"+item.getEquipmentId()+"_"+item.getAppEname()+"_"+item.getStatYearMonth();
if(uvMap.containsKey(key)) {
entity.setUv(uvMap.get(key).getUv());
entity.setTotalUv(uvMap.get(key).getTotalUv());
}
appsList.add(entity);
}
for(ConvergeAppsEntity item:appsList){
ConvergeAppsEntity temp = this.selectOne(new ConvergeAppsQuery().appEname(item.getAppEname()).equipmentId(item.getEquipmentId()).siteId(item.getSiteId()));
ConvergeAppsEntity temp = this.selectOne(new ConvergeAppsQuery().appEname(item.getAppEname()).equipmentId(item.getEquipmentId()).siteId(item.getSiteId()).statYearMonth(item.getStatYearMonth()));
if(temp!=null){
item.setId(temp.getId());
if(temp.getPv()==item.getPv()&&temp.getUv()==item.getUv()){
if(temp.getTotalPv()==item.getTotalPv()&&temp.getTotalUv()==item.getTotalUv()){
item.setOpr("P");
}else {
item.setOpr("U");
......
......@@ -62,6 +62,9 @@ public class ConvergeSiteServiceImpl extends AbstractCRUDServiceImpl<ConvergeSit
EquipmentVO equipmentVO = new EquipmentVO();
BeanUtils.copyProperties(deviceEntity,equipmentVO,BeanUtil.getNullPropertyNames(deviceEntity));
List<ConvergeAppsEntity> apps = convergeAppsService.find(new ConvergeAppsQuery().siteId(deviceEntity.getSiteId()).equipmentId(deviceEntity.getId()));
if(CollectionUtils.isEmpty(apps)){
continue;
}
equipmentVO.setAppStats(convertAppVO(apps));
equipments.add(equipmentVO);
}
......
package com.mortals.xhx.module.converge.web;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.framework.util.DateUtils;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.converge.model.vo.BranchVO;
import com.mortals.xhx.module.converge.service.ConvergeAppsService;
import com.mortals.xhx.module.converge.service.ConvergeDeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -38,6 +42,10 @@ public class ConvergeSiteController extends BaseCRUDJsonBodyMappingController<Co
@Autowired
private ParamService paramService;
@Autowired
private ConvergeDeviceService convergeDeviceService;
@Autowired
private ConvergeAppsService convergeAppsService;
public ConvergeSiteController(){
super.setModuleDesc( "网点信息");
......@@ -80,4 +88,29 @@ public class ConvergeSiteController extends BaseCRUDJsonBodyMappingController<Co
}
return JSONObject.toJSONString(model.get("data"));
}
// @Override
// protected void doListBefore(ConvergeSiteEntity query, Map<String, Object> model, Context context) throws AppException {
// log.info("开始执行省平台数据汇聚任务...");
// try {
// this.service.doConvergeSite();
//
// }catch (Exception e){
// log.error("汇聚网点数据执行出错",e);
// }
// try {
// convergeDeviceService.doConvergeDevice();
//
// }catch (Exception e){
// log.error("汇聚设备数据出错",e);
// }
// try {
// String dateTime = DateUtils.getCurrStrDate();
// convergeAppsService.doConvergeApps(dateTime);
//
// }catch (Exception e){
// log.error("汇聚应用数据出错",e);
// }
// log.info("省平台数据汇聚任务执行完成");
// }
}
\ No newline at end of file
......@@ -3,46 +3,60 @@
"mybatis-3-mapper.dtd">
<mapper namespace="com.mortals.xhx.module.converge.dao.ibatis.ConvergeAppsAccessDaoImpl">
<!-- 页面浏览量PV统计 -->
<select id="getAppsAccessPv" resultType="com.mortals.xhx.module.converge.model.vo.AppsAccessVo">
<select id="getAppsAccessPv" parameterType="String" resultType="com.mortals.xhx.module.converge.model.vo.AppsAccessVo">
SELECT
siteId,
ecode as equipmentId,
applicationId as appEname,
applicationName AS appName,
appSimpleName,
provider,
origin,
count(1) as pv
DATE_FORMAT(startTime,'%Y-%m-%d') as statYearMonth,
count(1) as totalPv
FROM
mortals_xhx_converge_apps_access
WHERE
startTime <![CDATA[ >= ]]> STR_TO_DATE(left(concat(#{startTime},' 00:00:00'),19),'%Y-%m-%d %k:%i:%s')
AND
startTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{startTime},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s')
GROUP BY
siteId,
applicationId,
ecode
ecode,
DATE_FORMAT(startTime,'%Y-%m-%d')
</select>
<!-- 页面浏览量UV统计 -->
<select id="getAppsAccessUv" resultType="com.mortals.xhx.module.converge.model.vo.AppsAccessVo">
<select id="getAppsAccessUv" parameterType="String" resultType="com.mortals.xhx.module.converge.model.vo.AppsAccessVo">
SELECT
siteId,
ecode AS equipmentId,
applicationId AS appEname,
applicationName AS appName,
appSimpleName,
provider,
origin,
count(1) AS uv
statYearMonth,
count(1) AS totalUv
FROM
(
SELECT
siteId,
ecode,
applicationId,
applicationName,
appSimpleName,
provider,
origin,
count(1),
DATE_FORMAT(startTime,'%Y-%m-%d') AS accessTime
DATE_FORMAT(startTime,'%Y-%m-%d') AS statYearMonth
FROM
mortals_xhx_converge_apps_access
WHERE
startTime <![CDATA[ >= ]]> STR_TO_DATE(left(concat(#{startTime},' 00:00:00'),19),'%Y-%m-%d %k:%i:%s')
AND
startTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{startTime},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s')
GROUP BY
siteId,
applicationId,
......
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