报表增加作者和下载次数功能

Raod 3 years ago
parent add505e4a2
commit 236f6d2efa

@ -16,6 +16,7 @@ import com.anjiplus.template.gaea.business.modules.dashboard.service.ReportDashb
import com.anjiplus.template.gaea.business.modules.file.entity.GaeaFile; import com.anjiplus.template.gaea.business.modules.file.entity.GaeaFile;
import com.anjiplus.template.gaea.business.modules.file.service.GaeaFileService; import com.anjiplus.template.gaea.business.modules.file.service.GaeaFileService;
import com.anjiplus.template.gaea.business.modules.file.util.FileUtils; import com.anjiplus.template.gaea.business.modules.file.util.FileUtils;
import com.anjiplus.template.gaea.business.modules.report.service.ReportService;
import com.anjiplus.template.gaea.business.util.DateUtil; import com.anjiplus.template.gaea.business.util.DateUtil;
import com.anjiplus.template.gaea.business.modules.dashboardwidget.controller.dto.ReportDashboardWidgetDto; import com.anjiplus.template.gaea.business.modules.dashboardwidget.controller.dto.ReportDashboardWidgetDto;
import com.anjiplus.template.gaea.business.modules.dashboardwidget.controller.dto.ReportDashboardWidgetValueDto; import com.anjiplus.template.gaea.business.modules.dashboardwidget.controller.dto.ReportDashboardWidgetValueDto;
@ -26,6 +27,7 @@ import com.anjiplus.template.gaea.business.modules.dataset.controller.dto.DataSe
import com.anjiplus.template.gaea.business.modules.dataset.controller.dto.OriginalDataDto; import com.anjiplus.template.gaea.business.modules.dataset.controller.dto.OriginalDataDto;
import com.anjiplus.template.gaea.business.modules.dataset.service.DataSetService; import com.anjiplus.template.gaea.business.modules.dataset.service.DataSetService;
import com.anjiplus.template.gaea.business.util.FileUtil; import com.anjiplus.template.gaea.business.util.FileUtil;
import com.anjiplus.template.gaea.business.util.RequestUtil;
import com.anjiplus.template.gaea.business.util.UuidUtil; import com.anjiplus.template.gaea.business.util.UuidUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -51,6 +53,7 @@ import java.io.File;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture;
/** /**
* @author Raod * @author Raod
@ -74,6 +77,9 @@ public class ReportDashboardServiceImpl implements ReportDashboardService, Initi
@Autowired @Autowired
private GaeaFileService gaeaFileService; private GaeaFileService gaeaFileService;
@Autowired
private ReportService reportService;
@Value("${customer.file.downloadPath:''}") @Value("${customer.file.downloadPath:''}")
private String fileDownloadPath; private String fileDownloadPath;
@ -272,6 +278,13 @@ public class ReportDashboardServiceImpl implements ReportDashboardService, Initi
FileUtil.delete(path); FileUtil.delete(path);
log.info("删除临时文件:{}{}", zipPath, path); log.info("删除临时文件:{}{}", zipPath, path);
//异步统计下载次数
CompletableFuture.runAsync(() -> {
log.info("=======>ip:{} 下载模板:{}", RequestUtil.getIpAddr(request), reportCode);
reportService.downloadStatistics(reportCode);
});
return body; return body;
} }

@ -6,7 +6,6 @@ import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
/** /**
* TODO
* *
* @author chenkening * @author chenkening
* @date 2021/3/26 10:34 * @date 2021/3/26 10:34
@ -50,4 +49,11 @@ public class ReportDto extends GaeaBaseDTO implements Serializable {
/** 0--未删除 1--已删除 DIC_NAME=DELETE_FLAG */ /** 0--未删除 1--已删除 DIC_NAME=DELETE_FLAG */
private Integer deleteFlag; private Integer deleteFlag;
/** 报表作者 */
private String reportAuthor;
/** 下载次数 */
private Long downloadCount;
} }

@ -36,6 +36,12 @@ public class Report extends GaeaBaseEntity {
@ApiModelProperty(value = "报表缩略图") @ApiModelProperty(value = "报表缩略图")
private String reportImage; private String reportImage;
@ApiModelProperty(value = "报表作者")
private String reportAuthor;
@ApiModelProperty(value = "下载次数")
private Long downloadCount;
@ApiModelProperty(value = "0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG") @ApiModelProperty(value = "0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG")
private Integer enableFlag; private Integer enableFlag;

@ -6,7 +6,6 @@ import com.anjiplus.template.gaea.business.modules.report.controller.param.Repor
import com.anjiplus.template.gaea.business.modules.report.dao.entity.Report; import com.anjiplus.template.gaea.business.modules.report.dao.entity.Report;
/** /**
* TODO
* *
* @author chenkening * @author chenkening
* @date 2021/3/26 10:35 * @date 2021/3/26 10:35
@ -14,4 +13,10 @@ import com.anjiplus.template.gaea.business.modules.report.dao.entity.Report;
public interface ReportService extends GaeaBaseService<ReportParam, Report> { public interface ReportService extends GaeaBaseService<ReportParam, Report> {
void delReport(ReportDto reportDto); void delReport(ReportDto reportDto);
/**
* +1
* @param reportCode
*/
void downloadStatistics(String reportCode);
} }

@ -34,6 +34,27 @@ public class ReportServiceImpl implements ReportService {
//... //...
} }
/**
* +1
*
* @param reportCode
*/
@Override
public void downloadStatistics(String reportCode) {
Report report = selectOne("report_code", reportCode);
if (null != report) {
Long downloadCount = report.getDownloadCount();
if (null == downloadCount) {
downloadCount = 0L;
}else {
downloadCount++;
}
report.setDownloadCount(downloadCount);
update(report);
}
}
@Override @Override
public void processBeforeOperation(Report entity, BaseOperationEnum operationEnum) throws BusinessException { public void processBeforeOperation(Report entity, BaseOperationEnum operationEnum) throws BusinessException {

@ -0,0 +1,50 @@
package com.anjiplus.template.gaea.business.util;
import org.apache.commons.lang3.StringUtils;
import javax.servlet.http.HttpServletRequest;
/**
* @author: Raod
* @since: 2022-01-21
*/
public class RequestUtil {
/**ip
* @param request
* @return
*/
public static String getIpAddr(HttpServletRequest request) {
String Xip = request.getHeader("X-Real-IP");
String XFor = request.getHeader("X-Forwarded-For");
if(StringUtils.isNotEmpty(XFor) && !"unKnown".equalsIgnoreCase(XFor)){
//多次反向代理后会有多个ip值第一个ip才是真实ip
int index = XFor.indexOf(",");
if(index != -1){
return XFor.substring(0,index);
}else{
return XFor;
}
}
XFor = Xip;
if(StringUtils.isNotEmpty(XFor) && !"unKnown".equalsIgnoreCase(XFor)){
return XFor;
}
if (StringUtils.isBlank(XFor) || "unknown".equalsIgnoreCase(XFor)) {
XFor = request.getHeader("Proxy-Client-IP");
}
if (StringUtils.isBlank(XFor) || "unknown".equalsIgnoreCase(XFor)) {
XFor = request.getHeader("WL-Proxy-Client-IP");
}
if (StringUtils.isBlank(XFor) || "unknown".equalsIgnoreCase(XFor)) {
XFor = request.getHeader("HTTP_CLIENT_IP");
}
if (StringUtils.isBlank(XFor) || "unknown".equalsIgnoreCase(XFor)) {
XFor = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (StringUtils.isBlank(XFor) || "unknown".equalsIgnoreCase(XFor)) {
XFor = request.getRemoteAddr();
}
return XFor;
}
}
Loading…
Cancel
Save