Browse Source

文章总数 倒序取第一个

master
jianjun 5 years ago
parent
commit
96ee5f3a7a
  1. 88
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/DingTalkTextMsg.java
  2. 36
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java
  3. 2
      epmet-module/data-report/data-report-server/src/main/resources/mapper/publicity/PublicityDao.xml
  4. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/constant/ProjectConstant.java
  5. 454
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsPublicityServiceImpl.java
  6. 1
      epmet-module/data-statistical/data-statistical-server/src/main/resources/logback-spring.xml

88
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/DingTalkTextMsg.java

@ -0,0 +1,88 @@
package com.epmet.commons.tools.dto.form;
import com.alibaba.fastjson.JSON;
import lombok.Data;
import org.springframework.util.CollectionUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* desc: 钉钉文本消息参数 实体类
* date: 2019/2/20 11:00
* @author: jianjun liu
* email:liujianjun@yunzongnet.com
*/
public class DingTalkTextMsg {
/**
* 消息接收者
*/
private String receiver;
/**
* 发送内容
*/
private String content;
/**
* at的群成员手机号
*/
private List<String> atMobiles;
/**
* 是否at所有人
*/
private boolean isAtAll;
public String getReceiver() {
return receiver;
}
public void setReceiver(String receiver) {
this.receiver = receiver;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public List<String> getAtMobiles() {
return atMobiles;
}
public void setAtMobiles(List<String> atMobiles) {
this.atMobiles = atMobiles;
}
public boolean isAtAll() {
return isAtAll;
}
public void setAtAll(boolean atAll) {
isAtAll = atAll;
}
public String getMsgContent() {
Map<String, Object> items = new HashMap<>();
items.put("msgtype", "text");
Map<String, String> textContent = new HashMap<>();
textContent.put("content", getContent());
items.put("text", textContent);
Map<String, Object> atItems = new HashMap<>();
if (!CollectionUtils.isEmpty(atMobiles)) {
atItems.put("atMobiles", atMobiles);
}
if (isAtAll) {
atItems.put("isAtAll", isAtAll);
}
items.put("at", atItems);
return JSON.toJSONString(items);
}
}

36
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java

@ -1,10 +1,13 @@
package com.epmet.commons.tools.utils;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.dto.form.DingTalkTextMsg;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.scan.param.TextScanParamDTO;
import com.epmet.commons.tools.scan.param.TextTaskDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
@ -20,10 +23,12 @@ import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -115,6 +120,35 @@ public class HttpClientManager {
}
/**
* desc: 发送钉钉群消息 简版
* param: url,jsonStrParam
* return: Result<String>
*
* @author: jianjun liu
*/
public Result<String> sendAlarmMsg(String content) {
Long timestamp = System.currentTimeMillis();
String url = "https://oapi.dingtalk.com/robot/send?access_token=90782b119f82a5b6bb8e0f819b6a77bbc2102b53aa2d7d2e24fa10b66d580b1c";
String secret = "SEC080aac67ff78e79fdaba132aa51e3fb3f6060dec99492feaac82cabf9f8b6a19";
try {
String stringToSign = timestamp + "\n" + secret;
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(new SecretKeySpec(secret.getBytes("UTF-8"), "HmacSHA256"));
byte[] signData = mac.doFinal(stringToSign.getBytes("UTF-8"));
String sign = URLEncoder.encode(new String(Base64.encodeBase64(signData)),"UTF-8");
DingTalkTextMsg msg = new DingTalkTextMsg();
msg.setContent(content);
url = url.concat("&timestamp="+timestamp+"&sign="+sign);
String jsonStrParam = msg.getMsgContent();
return sendPostByJSON(url, jsonStrParam);
} catch (Exception e) {
e.printStackTrace();
}
return new Result<String>().error();
}
/**
* desc: 发送get请求
* param:url, params

2
epmet-module/data-report/data-report-server/src/main/resources/mapper/publicity/PublicityDao.xml

@ -10,7 +10,7 @@
article_published_count AS publishingTotal,
DATE_FORMAT( date_id, '%Y.%m.%d' ) AS dateName
FROM fact_article_published_agency_daily
where agency_id = #{agencyId}
where agency_id = #{agencyId} order by DATE_ID desc limit 1
</select>
<!-- 机关当月—每个标签阅读数量—前pageSize -->

5
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/constant/ProjectConstant.java

@ -43,4 +43,9 @@ public interface ProjectConstant {
*/
String PUBLISHER_TYPE_GRID = "grid";
/**
* 执行失败钉钉消息模版
*/
String EXE_FAILED_MSG = "定时任务【%s】执行失败,客户ID:%s,统计时间:%s,异常信息:%s";
}

454
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsPublicityServiceImpl.java

@ -5,6 +5,7 @@ import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.constant.DimAgencyConstant;
import com.epmet.constant.ProjectConstant;
import com.epmet.dto.voice.ArticleGridPublishedSummaryDTO;
@ -160,8 +161,8 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
for (String customerId : customerIdList) {
Date finalStatsDate = statsDate;
//executorService.submit(() -> {
//统计
statsTagUsedDaily(finalStatsDate, dimIdBean, customerId);
//统计
statsTagUsedDaily(finalStatsDate, dimIdBean, customerId);
//});
}
}
@ -218,10 +219,8 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
if (!CollectionUtils.isEmpty(customerIdList)) {
for (String customerId : customerIdList) {
Date finalStatsDate = statsDate;
//executorService.submit(() -> {
//统计
statsTagViewedDaily(finalStatsDate, dimIdBean, customerId);
//});
}
}
} while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize);
@ -245,13 +244,11 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize);
if (!CollectionUtils.isEmpty(customerIdList)) {
for (String customerId : customerIdList) {
executorService.submit(() -> {
try {
statsTagViewedMonthly(dimIdBean.getMonthId(), customerId);
} catch (Exception e) {
log.error("statsTagViewedMonthly exception", e);
}
});
try {
statsTagViewedMonthly(dimIdBean.getMonthId(), customerId);
} catch (Exception e) {
log.error("statsTagViewedMonthly exception", e);
}
}
}
} while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize);
@ -343,7 +340,8 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
log.warn("publicitySummary getDepartmentListByCustomerId return empty,customerId:{}", customerId);
return;
}
executorService.submit(() -> {
try {
//转换为 需要插入的Entity
Map<String, FactArticlePublishedDepartmentDailyEntity> departmentDailyEntityMap = convertDepartmentDailyEntity(departmentDTOList, dimIdBean);
//获取当天的业务数据
@ -364,7 +362,15 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
}
}
boolean b = factArticlePublishedDepartmentDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), departmentDailyEntityMap.values());
});
} catch (Exception e) {
try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按日统计部门纬度文章总数", customerId, statsDate, e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content);
} catch (Exception ex) {
log.error("sendAlarmMsg exception", e);
}
}
}
/**
@ -394,7 +400,7 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
}
/**
* desc:按日统计 网格纬度的 文章总数数据
* desc:按日统计 文章总数数据
*
* @param statsDate
* @param dimIdBean
@ -408,31 +414,37 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
log.warn("publicitySummary getGridListByCustomerId return empty,customerId:{}", customerId);
return;
}
executorService.submit(() -> {
try {
//转换为 需要插入的Entity
Map<String, FactArticlePublishedGridDailyEntity> gridDailyEntityMap = convertGridDailyEntity(gridDTOList, dimIdBean);
//获取当天的业务数据
List<ArticleGridPublishedSummaryDTO> publishedArticleCount = articleService.getAllGridPublishedCount(customerId, statsDate);
if (!CollectionUtils.isEmpty(publishedArticleCount)) {
for (ArticleGridPublishedSummaryDTO summaryDTO : publishedArticleCount) {
FactArticlePublishedGridDailyEntity gridDailyEntity = gridDailyEntityMap.get(summaryDTO.getPublisherId());
if (gridDailyEntity == null) {
log.error("publicitySummary getAllGridPublishedCount gridId:{} not exist in dimGrid", summaryDTO.getGridId());
continue;
}
gridDailyEntity.setArticleTotalCount(summaryDTO.getArticleTotalCount());
gridDailyEntity.setArticlePublishedCount(summaryDTO.getArticlePublishedCount());
gridDailyEntity.setPublishedCount(summaryDTO.getPublishedCount());
//同一个机关下数据累加
buildAgencySummaryData(agencySummaryMap, summaryDTO);
try {
//转换为 需要插入的Entity
Map<String, FactArticlePublishedGridDailyEntity> gridDailyEntityMap = convertGridDailyEntity(gridDTOList, dimIdBean);
//获取当天的业务数据
List<ArticleGridPublishedSummaryDTO> publishedArticleCount = articleService.getAllGridPublishedCount(customerId, statsDate);
if (!CollectionUtils.isEmpty(publishedArticleCount)) {
for (ArticleGridPublishedSummaryDTO summaryDTO : publishedArticleCount) {
FactArticlePublishedGridDailyEntity gridDailyEntity = gridDailyEntityMap.get(summaryDTO.getPublisherId());
if (gridDailyEntity == null) {
log.error("publicitySummary getAllGridPublishedCount gridId:{} not exist in dimGrid", summaryDTO.getGridId());
continue;
}
gridDailyEntity.setArticleTotalCount(summaryDTO.getArticleTotalCount());
gridDailyEntity.setArticlePublishedCount(summaryDTO.getArticlePublishedCount());
gridDailyEntity.setPublishedCount(summaryDTO.getPublishedCount());
//同一个机关下数据累加
buildAgencySummaryData(agencySummaryMap, summaryDTO);
}
boolean b = factArticlePublishedGridDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), gridDailyEntityMap.values());
} catch (Exception e) {
log.error("statsPublishedGridDaily exception customerId:{},statsDate:{}", customerId, statsDate);
}
});
boolean b = factArticlePublishedGridDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), gridDailyEntityMap.values());
} catch (Exception e) {
log.error("statsPublishedGridDaily exception customerId:{},statsDate:{}", customerId, statsDate);
try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按日统计网格纬度文章总数", customerId, statsDate, e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content);
} catch (Exception ex) {
log.error("sendAlarmMsg exception", e);
}
}
}
@ -443,7 +455,6 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
log.warn("publicitySummary getAgencyListByCustomerId return empty,customerId:{}", customerId);
return;
}
executorService.submit(() -> {
try {
//转换为 需要插入的Entity
Map<String, FactArticlePublishedAgencyDailyEntity> agencyDailyEntityMap = convertAgencyDailyEntity(agencyDTOList, dimIdBean);
@ -492,18 +503,22 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
if (!CollectionUtils.isEmpty(haveDataAgencyDailySelfMap)) {
agencyDailyEntityMap.putAll(haveDataAgencyDailySelfMap);
}
log.debug("statsPublishedAgencyDaily insert:{}",JSON.toJSONString(agencyDailyEntityMap.values()));
log.debug("statsPublishedAgencyDaily insert:{}", JSON.toJSONString(agencyDailyEntityMap.values()));
boolean b = factArticlePublishedAgencyDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), agencyDailyEntityMap.values());
} catch (Exception e) {
e.printStackTrace();
log.error("statsPublishedAgencyDaily exception,customer:{}",customerId);
log.error("statsPublishedAgencyDaily exception,customer:{}", customerId);
try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按日统计部门纬度文章总数", customerId, statsDate, e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content);
} catch (Exception ex) {
log.error("sendAlarmMsg exception", e);
}
}
});
}
/**
* desc:按日统计 网格纬度的 标签被使用的次数
* desc:按日统计 标签被使用的次数
*
* @param statsDate
* @param dimIdBean
@ -581,13 +596,17 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
}
setTagUsedData2ParentAgency(dimAgencyEntityMap, finalTagUsedAgencyDailyMap, currentEntity, dimIdBean);
}
if (!CollectionUtils.isEmpty(tagUsedAgencyDailySelfMap)){
if (!CollectionUtils.isEmpty(tagUsedAgencyDailySelfMap)) {
finalTagUsedAgencyDailyMap.putAll(tagUsedAgencyDailySelfMap);
}
factTagUsedAgencyDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), finalTagUsedAgencyDailyMap.values());
} catch (Exception e) {
e.printStackTrace();
//log.error();
try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按日统计标签被使用次数", customerId, statsDate, e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content);
} catch (Exception ex) {
log.error("sendAlarmMsg exception", e);
}
}
}
@ -599,88 +618,98 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
* @param customerId
*/
private void statsTagViewedDaily(Date statsDate, DimIdGenerator.DimIdBean dimIdBean, String customerId) {
//1.业务数据来源 发布时间为统计时间的
// 因为一个客户的发布文章数在同一天不会特别的多,所以以客户为单位查询今天发布的所有带有标签的文章 根据发布单位类型进行拆分
// 1.1查出今天所有的文章标签 根据网格Id
// 1.2
//获取所有机关 用于后面想上级添加数据
List<DimAgencyEntity> agencyDTOList = dimAgencyService.getAgencyListByCustomerId(customerId);
if (CollectionUtils.isEmpty(agencyDTOList)) {
log.debug("statsTagViewedDaily customerId:{} have any agency", customerId);
return;
}
List<DimGridEntity> dimGridList = dimGridService.getGridListByCustomerId(customerId);
if (CollectionUtils.isEmpty(dimGridList)) {
log.debug("statsTagViewedDaily customerId:{} have any grid", customerId);
return;
}
Map<String, DimGridEntity> dimGridEntityMap = dimGridList.stream().collect(Collectors.toMap(DimGridEntity::getId, o -> o));
//转换为 需要插入的Entity
Map<String, DimAgencyEntity> dimAgencyEntityMap = agencyDTOList.stream().collect(Collectors.toMap(DimAgencyEntity::getId, o -> o));
//转换为 需要插入的Entity key gridId_tagId
Map<String, FactTagViewedGridDailyEntity> tagViewedGridDailyMap = new HashMap<>();
Map<String, FactTagViewedAgencyDailyEntity> tagViewedAgencyDailyMap = new HashMap<>();
Map<String, FactTagViewedAgencyDailyEntity> tagViewedAgencyDailySelfMap = new HashMap<>();
//获取当天的业务数据
//1获取今天文章的阅读记录数
Date startTime = DateUtils.integrate(statsDate, DateUtils.DATE_PATTERN);
Date endTime = DateUtils.integrate(DateUtils.addDateDays(statsDate, 1), DateUtils.DATE_PATTERN);
List<ArticleViewedSummaryDTO> visitRecordList = articleVisitRecordService.getArticleVisitByCreateTime(customerId, startTime, endTime);
if (CollectionUtils.isEmpty(visitRecordList)) {
return;
}
for (ArticleViewedSummaryDTO viewedSummaryDTO : visitRecordList) {
List<ArticleTagsEntity> articleTagsList = articleTagsService.getArticleTagsByArticleId(customerId, viewedSummaryDTO.getArticleId());
if (CollectionUtils.isEmpty(articleTagsList)) {
continue;
try {
//1.业务数据来源 发布时间为统计时间的
// 因为一个客户的发布文章数在同一天不会特别的多,所以以客户为单位查询今天发布的所有带有标签的文章 根据发布单位类型进行拆分
// 1.1查出今天所有的文章标签 根据网格Id
// 1.2
//获取所有机关 用于后面想上级添加数据
List<DimAgencyEntity> agencyDTOList = dimAgencyService.getAgencyListByCustomerId(customerId);
if (CollectionUtils.isEmpty(agencyDTOList)) {
log.debug("statsTagViewedDaily customerId:{} have any agency", customerId);
return;
}
ArticleEntity articleEntity = articleService.selectArticleById(viewedSummaryDTO.getArticleId());
if (articleEntity == null) {
continue;
List<DimGridEntity> dimGridList = dimGridService.getGridListByCustomerId(customerId);
if (CollectionUtils.isEmpty(dimGridList)) {
log.debug("statsTagViewedDaily customerId:{} have any grid", customerId);
return;
}
boolean isAgencyPublished = false;
if (ProjectConstant.PUBLISHER_TYPE_AGENCY.equals(articleEntity.getPublisherType())) {
isAgencyPublished = true;
Map<String, DimGridEntity> dimGridEntityMap = dimGridList.stream().collect(Collectors.toMap(DimGridEntity::getId, o -> o));
//转换为 需要插入的Entity
Map<String, DimAgencyEntity> dimAgencyEntityMap = agencyDTOList.stream().collect(Collectors.toMap(DimAgencyEntity::getId, o -> o));
//转换为 需要插入的Entity key gridId_tagId
Map<String, FactTagViewedGridDailyEntity> tagViewedGridDailyMap = new HashMap<>();
Map<String, FactTagViewedAgencyDailyEntity> tagViewedAgencyDailyMap = new HashMap<>();
Map<String, FactTagViewedAgencyDailyEntity> tagViewedAgencyDailySelfMap = new HashMap<>();
//获取当天的业务数据
//1获取今天文章的阅读记录数
Date startTime = DateUtils.integrate(statsDate, DateUtils.DATE_PATTERN);
Date endTime = DateUtils.integrate(DateUtils.addDateDays(statsDate, 1), DateUtils.DATE_PATTERN);
List<ArticleViewedSummaryDTO> visitRecordList = articleVisitRecordService.getArticleVisitByCreateTime(customerId, startTime, endTime);
if (CollectionUtils.isEmpty(visitRecordList)) {
return;
}
String gridId = viewedSummaryDTO.getGridId();
DimGridEntity dimGridEntity = dimGridEntityMap.get(gridId);
if (dimGridEntity == null) {
log.error("statsTagViewedDaily viewedRecord gridId:{} not exist in dimGridMap", gridId);
continue;
}
DimAgencyEntity dimAgencyEntity = dimAgencyEntityMap.get(dimGridEntity.getAgencyId());
for (ArticleTagsEntity articleTag : articleTagsList) {
convertTagViewedGridDailyEntity(dimAgencyEntity, tagViewedGridDailyMap, articleTag, viewedSummaryDTO, dimIdBean);
convertTagViewedAgencyDailyEntity(dimAgencyEntity, tagViewedAgencyDailyMap, articleTag, viewedSummaryDTO, dimIdBean);
if (isAgencyPublished) {
convertTagViewedAgencyDailySelfEntity(dimAgencyEntity, tagViewedAgencyDailySelfMap, articleTag, viewedSummaryDTO, dimIdBean);
for (ArticleViewedSummaryDTO viewedSummaryDTO : visitRecordList) {
List<ArticleTagsEntity> articleTagsList = articleTagsService.getArticleTagsByArticleId(customerId, viewedSummaryDTO.getArticleId());
if (CollectionUtils.isEmpty(articleTagsList)) {
continue;
}
ArticleEntity articleEntity = articleService.selectArticleById(viewedSummaryDTO.getArticleId());
if (articleEntity == null) {
continue;
}
boolean isAgencyPublished = false;
if (ProjectConstant.PUBLISHER_TYPE_AGENCY.equals(articleEntity.getPublisherType())) {
isAgencyPublished = true;
}
String gridId = viewedSummaryDTO.getGridId();
DimGridEntity dimGridEntity = dimGridEntityMap.get(gridId);
if (dimGridEntity == null) {
log.error("statsTagViewedDaily viewedRecord gridId:{} not exist in dimGridMap", gridId);
continue;
}
DimAgencyEntity dimAgencyEntity = dimAgencyEntityMap.get(dimGridEntity.getAgencyId());
for (ArticleTagsEntity articleTag : articleTagsList) {
convertTagViewedGridDailyEntity(dimAgencyEntity, tagViewedGridDailyMap, articleTag, viewedSummaryDTO, dimIdBean);
convertTagViewedAgencyDailyEntity(dimAgencyEntity, tagViewedAgencyDailyMap, articleTag, viewedSummaryDTO, dimIdBean);
if (isAgencyPublished) {
convertTagViewedAgencyDailySelfEntity(dimAgencyEntity, tagViewedAgencyDailySelfMap, articleTag, viewedSummaryDTO, dimIdBean);
}
}
}
}
factTagViewedGridDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), tagViewedGridDailyMap.values());
factTagViewedGridDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), tagViewedGridDailyMap.values());
//向上级机关递归添加 数据
Map<String, FactTagViewedAgencyDailyEntity> finalTagUsedAgencyDailyMap = new HashMap<>();
finalTagUsedAgencyDailyMap.putAll(tagViewedAgencyDailyMap);
for (Map.Entry<String, FactTagViewedAgencyDailyEntity> entry : tagViewedAgencyDailyMap.entrySet()) {
String agencyId = entry.getKey();
FactTagViewedAgencyDailyEntity currentEntity = entry.getValue();
DimAgencyEntity dimAgencyEntity = dimAgencyEntityMap.get(currentEntity.getAgencyId());
if (dimAgencyEntity == null) {
//向上级机关递归添加 数据
Map<String, FactTagViewedAgencyDailyEntity> finalTagUsedAgencyDailyMap = new HashMap<>();
finalTagUsedAgencyDailyMap.putAll(tagViewedAgencyDailyMap);
for (Map.Entry<String, FactTagViewedAgencyDailyEntity> entry : tagViewedAgencyDailyMap.entrySet()) {
String agencyId = entry.getKey();
FactTagViewedAgencyDailyEntity currentEntity = entry.getValue();
DimAgencyEntity dimAgencyEntity = dimAgencyEntityMap.get(currentEntity.getAgencyId());
if (dimAgencyEntity == null) {
log.error("dimAgencyEntityMap bizData agencyId:{} not exist in dimAgency", agencyId);
continue;
log.error("dimAgencyEntityMap bizData agencyId:{} not exist in dimAgency", agencyId);
continue;
}
setTagViewedData2ParentAgency(dimAgencyEntityMap, finalTagUsedAgencyDailyMap, currentEntity, dimIdBean);
}
setTagViewedData2ParentAgency(dimAgencyEntityMap, finalTagUsedAgencyDailyMap, currentEntity, dimIdBean);
}
if (!CollectionUtils.isEmpty(tagViewedAgencyDailySelfMap)) {
finalTagUsedAgencyDailyMap.putAll(tagViewedAgencyDailySelfMap);
if (!CollectionUtils.isEmpty(tagViewedAgencyDailySelfMap)) {
finalTagUsedAgencyDailyMap.putAll(tagViewedAgencyDailySelfMap);
}
factTagViewedAgencyDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), finalTagUsedAgencyDailyMap.values());
} catch (Exception e) {
try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按日统计标签被查看次数", customerId, statsDate, e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content);
} catch (Exception ex) {
log.error("sendAlarmMsg exception", e);
}
}
factTagViewedAgencyDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), finalTagUsedAgencyDailyMap.values());
}
/**
@ -690,20 +719,29 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
* @param customerId
*/
private void statsTagUsedMonthly(String monthId, String customerId) {
List<FactTagUsedGridDailyEntity> gridDailyList = factTagUsedGridDailyService.getTagUsedCountByMonth(customerId, monthId);
if (!CollectionUtils.isEmpty(gridDailyList)) {
List<FactTagUsedGridMonthlyEntity> gridMonthlyList = ConvertUtils.sourceToTarget(gridDailyList, FactTagUsedGridMonthlyEntity.class);
factTagUsedGridMonthlyService.deleteAndInsertByMonthId(customerId, monthId, gridMonthlyList);
}
List<FactTagUsedDepartmentDailyEntity> deptDailyList = factTagUsedDepartmentDailyService.getTagUsedCountByMonth(customerId, monthId);
if (!CollectionUtils.isEmpty(deptDailyList)) {
List<FactTagUsedDepartmentMonthlyEntity> gridMonthlyList = ConvertUtils.sourceToTarget(deptDailyList, FactTagUsedDepartmentMonthlyEntity.class);
factTagUsedDepartmentMonthlyService.deleteAndInsertByMonthId(customerId, monthId, gridMonthlyList);
}
List<FactTagUsedAgencyDailyEntity> agencyDailyList = factTagUsedAgencyDailyService.getTagUsedCountByMonth(customerId, monthId);
if (!CollectionUtils.isEmpty(agencyDailyList)) {
List<FactTagUsedAgencyMonthlyEntity> agencyMonthlyList = ConvertUtils.sourceToTarget(agencyDailyList, FactTagUsedAgencyMonthlyEntity.class);
factTagUsedAgencyMonthlyService.deleteAndInsertByMonthId(customerId, monthId, (agencyMonthlyList));
try {
List<FactTagUsedGridDailyEntity> gridDailyList = factTagUsedGridDailyService.getTagUsedCountByMonth(customerId, monthId);
if (!CollectionUtils.isEmpty(gridDailyList)) {
List<FactTagUsedGridMonthlyEntity> gridMonthlyList = ConvertUtils.sourceToTarget(gridDailyList, FactTagUsedGridMonthlyEntity.class);
factTagUsedGridMonthlyService.deleteAndInsertByMonthId(customerId, monthId, gridMonthlyList);
}
List<FactTagUsedDepartmentDailyEntity> deptDailyList = factTagUsedDepartmentDailyService.getTagUsedCountByMonth(customerId, monthId);
if (!CollectionUtils.isEmpty(deptDailyList)) {
List<FactTagUsedDepartmentMonthlyEntity> gridMonthlyList = ConvertUtils.sourceToTarget(deptDailyList, FactTagUsedDepartmentMonthlyEntity.class);
factTagUsedDepartmentMonthlyService.deleteAndInsertByMonthId(customerId, monthId, gridMonthlyList);
}
List<FactTagUsedAgencyDailyEntity> agencyDailyList = factTagUsedAgencyDailyService.getTagUsedCountByMonth(customerId, monthId);
if (!CollectionUtils.isEmpty(agencyDailyList)) {
List<FactTagUsedAgencyMonthlyEntity> agencyMonthlyList = ConvertUtils.sourceToTarget(agencyDailyList, FactTagUsedAgencyMonthlyEntity.class);
factTagUsedAgencyMonthlyService.deleteAndInsertByMonthId(customerId, monthId, (agencyMonthlyList));
}
} catch (Exception e) {
try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按月统计标签被使用次数", customerId, monthId, e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content);
} catch (Exception ex) {
log.error("sendAlarmMsg exception", e);
}
}
}
@ -714,16 +752,25 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
* @param customerId
*/
private void statsTagViewedMonthly(String monthId, String customerId) {
List<FactTagViewedGridDailyEntity> gridDailyList = factTagViewedGridDailyService.getTagViewedCountByMonth(customerId, monthId);
if (!CollectionUtils.isEmpty(gridDailyList)) {
List<FactTagViewedGridMonthlyEntity> gridMonthlyList = ConvertUtils.sourceToTarget(gridDailyList, FactTagViewedGridMonthlyEntity.class);
factTagViewedGridMonthlyService.deleteAndInsertByMonthId(customerId, monthId, gridMonthlyList);
}
try {
List<FactTagViewedGridDailyEntity> gridDailyList = factTagViewedGridDailyService.getTagViewedCountByMonth(customerId, monthId);
if (!CollectionUtils.isEmpty(gridDailyList)) {
List<FactTagViewedGridMonthlyEntity> gridMonthlyList = ConvertUtils.sourceToTarget(gridDailyList, FactTagViewedGridMonthlyEntity.class);
factTagViewedGridMonthlyService.deleteAndInsertByMonthId(customerId, monthId, gridMonthlyList);
}
List<FactTagViewedAgencyDailyEntity> agencyDailyList = factTagViewedAgencyDailyService.getTagViewedCountByMonth(customerId, monthId);
if (!CollectionUtils.isEmpty(agencyDailyList)) {
List<FactTagViewedAgencyMonthlyEntity> agencyMonthlyList = ConvertUtils.sourceToTarget(agencyDailyList, FactTagViewedAgencyMonthlyEntity.class);
factTagViewedAgencyMonthlyService.deleteAndInsertByMonthId(customerId, monthId, (agencyMonthlyList));
List<FactTagViewedAgencyDailyEntity> agencyDailyList = factTagViewedAgencyDailyService.getTagViewedCountByMonth(customerId, monthId);
if (!CollectionUtils.isEmpty(agencyDailyList)) {
List<FactTagViewedAgencyMonthlyEntity> agencyMonthlyList = ConvertUtils.sourceToTarget(agencyDailyList, FactTagViewedAgencyMonthlyEntity.class);
factTagViewedAgencyMonthlyService.deleteAndInsertByMonthId(customerId, monthId, (agencyMonthlyList));
}
} catch (Exception e) {
try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按月统计标签被查看次数", customerId, monthId, e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content);
} catch (Exception ex) {
log.error("sendAlarmMsg exception", e);
}
}
}
@ -734,20 +781,29 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
* @param customerId
*/
private void statsTagUsedQuarterly(String quarterId, String customerId) {
List<FactTagUsedGridMonthlyEntity> gridMonthlyList = factTagUsedGridMonthlyService.getTagUsedCountByQuarterId(customerId, quarterId);
if (!CollectionUtils.isEmpty(gridMonthlyList)) {
List<FactTagUsedGridQuarterlyEntity> gridQuarterlyList = ConvertUtils.sourceToTarget(gridMonthlyList, FactTagUsedGridQuarterlyEntity.class);
factTagUsedGridQuarterlyService.deleteAndInsertByQuarterId(customerId, quarterId, gridQuarterlyList);
}
List<FactTagUsedDepartmentMonthlyEntity> deptMonthlyList = factTagUsedDepartmentMonthlyService.getTagUsedCountByQuarterId(customerId, quarterId);
if (!CollectionUtils.isEmpty(deptMonthlyList)) {
List<FactTagUsedDepartmentQuarterlyEntity> deptQuarterlyList = ConvertUtils.sourceToTarget(deptMonthlyList, FactTagUsedDepartmentQuarterlyEntity.class);
factTagUsedDepartmentQuarterlyService.deleteAndInsertByQuarterId(customerId, quarterId, deptQuarterlyList);
}
List<FactTagUsedAgencyMonthlyEntity> agencyMonthlyList = factTagUsedAgencyMonthlyService.getTagUsedCountByQuarterId(customerId, quarterId);
if (!CollectionUtils.isEmpty(agencyMonthlyList)) {
List<FactTagUsedAgencyQuarterlyEntity> agencyQuarterlyList = ConvertUtils.sourceToTarget(agencyMonthlyList, FactTagUsedAgencyQuarterlyEntity.class);
factTagUsedAgencyQuarterlyService.deleteAndInsertByQuarterId(customerId, quarterId, agencyQuarterlyList);
try {
List<FactTagUsedGridMonthlyEntity> gridMonthlyList = factTagUsedGridMonthlyService.getTagUsedCountByQuarterId(customerId, quarterId);
if (!CollectionUtils.isEmpty(gridMonthlyList)) {
List<FactTagUsedGridQuarterlyEntity> gridQuarterlyList = ConvertUtils.sourceToTarget(gridMonthlyList, FactTagUsedGridQuarterlyEntity.class);
factTagUsedGridQuarterlyService.deleteAndInsertByQuarterId(customerId, quarterId, gridQuarterlyList);
}
List<FactTagUsedDepartmentMonthlyEntity> deptMonthlyList = factTagUsedDepartmentMonthlyService.getTagUsedCountByQuarterId(customerId, quarterId);
if (!CollectionUtils.isEmpty(deptMonthlyList)) {
List<FactTagUsedDepartmentQuarterlyEntity> deptQuarterlyList = ConvertUtils.sourceToTarget(deptMonthlyList, FactTagUsedDepartmentQuarterlyEntity.class);
factTagUsedDepartmentQuarterlyService.deleteAndInsertByQuarterId(customerId, quarterId, deptQuarterlyList);
}
List<FactTagUsedAgencyMonthlyEntity> agencyMonthlyList = factTagUsedAgencyMonthlyService.getTagUsedCountByQuarterId(customerId, quarterId);
if (!CollectionUtils.isEmpty(agencyMonthlyList)) {
List<FactTagUsedAgencyQuarterlyEntity> agencyQuarterlyList = ConvertUtils.sourceToTarget(agencyMonthlyList, FactTagUsedAgencyQuarterlyEntity.class);
factTagUsedAgencyQuarterlyService.deleteAndInsertByQuarterId(customerId, quarterId, agencyQuarterlyList);
}
} catch (Exception e) {
try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按季统计标签被使用次数", customerId, quarterId, e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content);
} catch (Exception ex) {
log.error("sendAlarmMsg exception", e);
}
}
}
@ -758,16 +814,25 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
* @param customerId
*/
private void statsTagViewedQuarterly(String quarterId, String customerId) {
List<FactTagViewedGridMonthlyEntity> gridMonthlyList = factTagViewedGridMonthlyService.getTagViewedCountByQuarterId(customerId, quarterId);
if (!CollectionUtils.isEmpty(gridMonthlyList)) {
List<FactTagViewedGridQuarterlyEntity> gridQuarterlyList = ConvertUtils.sourceToTarget(gridMonthlyList, FactTagViewedGridQuarterlyEntity.class);
factTagViewedGridQuarterlyService.deleteAndInsertByQuarterId(customerId, quarterId, gridQuarterlyList);
}
try {
List<FactTagViewedGridMonthlyEntity> gridMonthlyList = factTagViewedGridMonthlyService.getTagViewedCountByQuarterId(customerId, quarterId);
if (!CollectionUtils.isEmpty(gridMonthlyList)) {
List<FactTagViewedGridQuarterlyEntity> gridQuarterlyList = ConvertUtils.sourceToTarget(gridMonthlyList, FactTagViewedGridQuarterlyEntity.class);
factTagViewedGridQuarterlyService.deleteAndInsertByQuarterId(customerId, quarterId, gridQuarterlyList);
}
List<FactTagViewedAgencyMonthlyEntity> agencyMonthlyList = factTagViewedAgencyMonthlyService.getTagViewedCountByQuarterId(customerId, quarterId);
if (!CollectionUtils.isEmpty(agencyMonthlyList)) {
List<FactTagViewedAgencyQuarterlyEntity> agencyQuarterlyList = ConvertUtils.sourceToTarget(agencyMonthlyList, FactTagViewedAgencyQuarterlyEntity.class);
factTagViewedAgencyQuarterlyService.deleteAndInsertByQuarterId(customerId, quarterId, agencyQuarterlyList);
List<FactTagViewedAgencyMonthlyEntity> agencyMonthlyList = factTagViewedAgencyMonthlyService.getTagViewedCountByQuarterId(customerId, quarterId);
if (!CollectionUtils.isEmpty(agencyMonthlyList)) {
List<FactTagViewedAgencyQuarterlyEntity> agencyQuarterlyList = ConvertUtils.sourceToTarget(agencyMonthlyList, FactTagViewedAgencyQuarterlyEntity.class);
factTagViewedAgencyQuarterlyService.deleteAndInsertByQuarterId(customerId, quarterId, agencyQuarterlyList);
}
} catch (Exception e) {
try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按季统计标签被查看次数", customerId, quarterId, e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content);
} catch (Exception ex) {
log.error("sendAlarmMsg exception", e);
}
}
}
@ -778,20 +843,29 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
* @param customerId
*/
private void statsTagUsedYearly(String yearId, String customerId) {
List<FactTagUsedGridMonthlyEntity> gridMonthlyList = factTagUsedGridMonthlyService.getTagUsedCountByYearId(customerId, yearId);
if (!CollectionUtils.isEmpty(gridMonthlyList)) {
List<FactTagUsedGridYearlyEntity> gridYearlyList = ConvertUtils.sourceToTarget(gridMonthlyList, FactTagUsedGridYearlyEntity.class);
factTagUsedGridYearlyService.deleteAndInsertByYearId(customerId, yearId, gridYearlyList);
}
List<FactTagUsedDepartmentMonthlyEntity> deptMonthlyList = factTagUsedDepartmentMonthlyService.getTagUsedCountByYearId(customerId, yearId);
if (!CollectionUtils.isEmpty(deptMonthlyList)) {
List<FactTagUsedDepartmentYearlyEntity> gridYearlyList = ConvertUtils.sourceToTarget(deptMonthlyList, FactTagUsedDepartmentYearlyEntity.class);
factTagUsedDepartmentYearlyService.deleteAndInsertByYearId(customerId, yearId, gridYearlyList);
}
List<FactTagUsedAgencyMonthlyEntity> agencyMonthlyList = factTagUsedAgencyMonthlyService.getTagUsedCountByYearId(customerId, yearId);
if (!CollectionUtils.isEmpty(agencyMonthlyList)) {
List<FactTagUsedAgencyYearlyEntity> agencyYearlyList = ConvertUtils.sourceToTarget(agencyMonthlyList, FactTagUsedAgencyYearlyEntity.class);
factTagUsedAgencyYearlyService.deleteAndInsertByYearId(customerId, yearId, agencyYearlyList);
try {
List<FactTagUsedGridMonthlyEntity> gridMonthlyList = factTagUsedGridMonthlyService.getTagUsedCountByYearId(customerId, yearId);
if (!CollectionUtils.isEmpty(gridMonthlyList)) {
List<FactTagUsedGridYearlyEntity> gridYearlyList = ConvertUtils.sourceToTarget(gridMonthlyList, FactTagUsedGridYearlyEntity.class);
factTagUsedGridYearlyService.deleteAndInsertByYearId(customerId, yearId, gridYearlyList);
}
List<FactTagUsedDepartmentMonthlyEntity> deptMonthlyList = factTagUsedDepartmentMonthlyService.getTagUsedCountByYearId(customerId, yearId);
if (!CollectionUtils.isEmpty(deptMonthlyList)) {
List<FactTagUsedDepartmentYearlyEntity> gridYearlyList = ConvertUtils.sourceToTarget(deptMonthlyList, FactTagUsedDepartmentYearlyEntity.class);
factTagUsedDepartmentYearlyService.deleteAndInsertByYearId(customerId, yearId, gridYearlyList);
}
List<FactTagUsedAgencyMonthlyEntity> agencyMonthlyList = factTagUsedAgencyMonthlyService.getTagUsedCountByYearId(customerId, yearId);
if (!CollectionUtils.isEmpty(agencyMonthlyList)) {
List<FactTagUsedAgencyYearlyEntity> agencyYearlyList = ConvertUtils.sourceToTarget(agencyMonthlyList, FactTagUsedAgencyYearlyEntity.class);
factTagUsedAgencyYearlyService.deleteAndInsertByYearId(customerId, yearId, agencyYearlyList);
}
} catch (Exception e) {
try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按年统计标签被使用次数", customerId, yearId, e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content);
} catch (Exception ex) {
log.error("sendAlarmMsg exception", e);
}
}
}
@ -802,15 +876,25 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
* @param customerId
*/
private void statsTagViewedYearly(String yearId, String customerId) {
List<FactTagViewedGridMonthlyEntity> gridMonthlyList = factTagViewedGridMonthlyService.getTagViewedCountByYearId(customerId, yearId);
if (!CollectionUtils.isEmpty(gridMonthlyList)) {
List<FactTagViewedGridYearlyEntity> gridYearlyList = ConvertUtils.sourceToTarget(gridMonthlyList, FactTagViewedGridYearlyEntity.class);
factTagViewedGridYearlyService.deleteAndInsertByYearId(customerId, yearId, gridYearlyList);
}
List<FactTagViewedAgencyMonthlyEntity> agencyMonthlyList = factTagViewedAgencyMonthlyService.getTagViewedCountByYearId(customerId, yearId);
if (!CollectionUtils.isEmpty(agencyMonthlyList)) {
List<FactTagViewedAgencyYearlyEntity> agencyYearlyList = ConvertUtils.sourceToTarget(agencyMonthlyList, FactTagViewedAgencyYearlyEntity.class);
factTagViewedAgencyYearlyService.deleteAndInsertByYearId(customerId, yearId, agencyYearlyList);
try {
List<FactTagViewedGridMonthlyEntity> gridMonthlyList = factTagViewedGridMonthlyService.getTagViewedCountByYearId(customerId, yearId);
if (!CollectionUtils.isEmpty(gridMonthlyList)) {
List<FactTagViewedGridYearlyEntity> gridYearlyList = ConvertUtils.sourceToTarget(gridMonthlyList, FactTagViewedGridYearlyEntity.class);
factTagViewedGridYearlyService.deleteAndInsertByYearId(customerId, yearId, gridYearlyList);
}
List<FactTagViewedAgencyMonthlyEntity> agencyMonthlyList = factTagViewedAgencyMonthlyService.getTagViewedCountByYearId(customerId, yearId);
if (!CollectionUtils.isEmpty(agencyMonthlyList)) {
List<FactTagViewedAgencyYearlyEntity> agencyYearlyList = ConvertUtils.sourceToTarget(agencyMonthlyList, FactTagViewedAgencyYearlyEntity.class);
factTagViewedAgencyYearlyService.deleteAndInsertByYearId(customerId, yearId, agencyYearlyList);
}
} catch (Exception e) {
try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按年统计标签被查看次数", customerId, yearId, e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content);
} catch (Exception ex) {
log.error("sendAlarmMsg exception", e);
}
}
}

1
epmet-module/data-statistical/data-statistical-server/src/main/resources/logback-spring.xml

@ -138,7 +138,6 @@
<logger name="org.springframework.web" level="INFO"/>
<logger name="org.springboot.sample" level="INFO"/>
<logger name="com.epmet.dao" level="INFO"/>
<logger name="com.epmet.dao" level="DEBUG"/>
<root level="INFO">
<appender-ref ref="DEBUG_FILE"/>
<appender-ref ref="INFO_FILE"/>

Loading…
Cancel
Save