diff --git a/zc-business/src/main/java/com/zc/business/controller/DcPublishManageController.java b/zc-business/src/main/java/com/zc/business/controller/DcPublishManageController.java index ac81413f..eab0b511 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcPublishManageController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcPublishManageController.java @@ -7,8 +7,15 @@ import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.poi.ExcelUtil; import com.zc.business.domain.DcPublishManage; +import com.zc.business.domain.export.AllEventNum; +import com.zc.business.domain.export.EventTypePublishManageMonth; +import com.zc.business.domain.export.StatisticsPublishManage; +import com.zc.business.domain.export.TrendsPublishManage; +import com.zc.business.enums.EventTypeEnum; import com.zc.business.enums.UniversalEnum; +import com.zc.business.enums.ValueConverter; import com.zc.business.service.IDcPublishManageService; +import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -17,7 +24,8 @@ import javax.servlet.http.HttpServletResponse; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; /** * 信息发布管理记录Controller @@ -105,18 +113,109 @@ public class DcPublishManageController extends BaseController { return AjaxResult.success(dcPublishManageService.statisticsPublishManage()); } + @ApiOperation(value = "导出今日发布渠道分析",tags = {"ECharts导出"}) + @GetMapping("/exportStatisticsPublishManage") + public void exportStatisticsPublishManage(HttpServletResponse response){ + + List> data = dcPublishManageService.statisticsPublishManage(); + List list = new ArrayList<>(); + if (data != null && data.size() > 0) { + Long total = data.stream().mapToLong(item -> Long.parseLong(item.get("number").toString())).sum(); + for (HashMap datum : data) { + StatisticsPublishManage statisticsPublishManage = new StatisticsPublishManage(); + if ("4".equals(datum.get("publishChannels").toString())){ + statisticsPublishManage.setChannelName("情报板"); + } else if ("7".equals(datum.get("publishChannels").toString())){ + statisticsPublishManage.setChannelName("语音广播"); + } else if ("8".equals(datum.get("publishChannels").toString())){ + statisticsPublishManage.setChannelName("企业微信"); + } + statisticsPublishManage.setNum(datum.get("number").toString()); + + //计算百分比 + double ratio = (double) Long.parseLong(datum.get("number").toString()) / total * 100; + ratio = Math.round(ratio * 100.0) / 100.0; + statisticsPublishManage.setRatio(ratio + "%"); + list.add(statisticsPublishManage); + } + } + ExcelUtil util = new ExcelUtil<>(StatisticsPublishManage.class); + util.exportExcel(response, list, "今日发布渠道分析"); + } + //统计服务,今日发布事件类型分析 @PostMapping("/eventTypePublishManage") public AjaxResult eventTypePublishManage() { return AjaxResult.success(dcPublishManageService.eventTypePublishManage()); } + + @ApiOperation(value = "导出今日发布事件类型分析",tags = {"ECharts导出"}) + @GetMapping("/exportEventTypePublishManage") + public void exportEventTypePublishManage(HttpServletResponse response){ + + List> data = dcPublishManageService.eventTypePublishManage(); + List list = new ArrayList<>(); + if (data != null && data.size() > 0) { + Long total = data.stream().mapToLong(item -> Long.parseLong(item.get("number").toString())).sum(); + for (HashMap datum : data) { + AllEventNum allEventNum = new AllEventNum(); + allEventNum.setEventName(ValueConverter.eventTypeName(datum.get("eventType").toString())); + allEventNum.setNum(datum.get("number").toString()); + + //计算百分比 + double ratio = (double) Long.parseLong(datum.get("number").toString()) / total * 100; + ratio = Math.round(ratio * 100.0) / 100.0; + allEventNum.setRatio(ratio + "%"); + list.add(allEventNum); + } + } + ExcelUtil util = new ExcelUtil<>(AllEventNum.class); + util.exportExcel(response, list, "今日发布事件类型分析"); + } + //统计服务,今日发布趋势分析 @PostMapping("/trendsPublishManage") public AjaxResult releaseTrendsPublishManage() { return AjaxResult.success(dcPublishManageService.releaseTrendsPublishManage()); } + + @ApiOperation(value = "导出今日发布趋势分析",tags = {"ECharts导出"}) + @GetMapping("/exportTrendsPublishManage") + public void exportTrendsPublishManage(HttpServletResponse response){ + + List> data = dcPublishManageService.releaseTrendsPublishManage(); + List list = new ArrayList<>(); + if (data != null && data.size() > 0) { + Map>> group = data.stream().collect(Collectors.groupingBy(item -> item.get("hour").toString())); + for (String publishTime : group.keySet()) { + TrendsPublishManage trendsPublishManage = new TrendsPublishManage(); + trendsPublishManage.setPublishTime(publishTime + "时"); + List> groupData = group.get(publishTime); + for (HashMap groupDatum : groupData) { + if ("4".equals(groupDatum.get("publishChannels").toString())){ + trendsPublishManage.setBoard(groupDatum.get("number").toString()); + } else if ("7".equals(groupDatum.get("publishChannels").toString())){ + trendsPublishManage.setBroadcast(groupDatum.get("number").toString()); + } else if ("8".equals(groupDatum.get("publishChannels").toString())){ + trendsPublishManage.setWeChat(groupDatum.get("number").toString()); + } + } + + list.add(trendsPublishManage); + } + + list = list.stream().sorted(Comparator.comparing(item ->{ + String publicTime = item.getPublishTime().substring(0,item.getPublishTime().length() -1); + return Integer.parseInt(publicTime); + })).collect(Collectors.toList()); + } + + ExcelUtil util = new ExcelUtil<>(TrendsPublishManage.class); + util.exportExcel(response, list, "今日发布趋势分析"); + } + //统计服务,月发布渠道趋势分析 @PostMapping("/monthTrendsPublishManage") public AjaxResult monthTrendsPublishManage(@RequestBody DcPublishManage dcPublishManage) @@ -126,6 +225,39 @@ public class DcPublishManageController extends BaseController } return AjaxResult.success(dcPublishManageService.monthTrendsPublishManage(dcPublishManage)); } + + @ApiOperation(value = "导出月发布渠道趋势分析",tags = {"ECharts导出"}) + @GetMapping("/exportMonthTrendsPublishManage") + public void exportMonthTrendsPublishManage(HttpServletResponse response,DcPublishManage dcPublishManage){ + + List> data = dcPublishManageService.monthTrendsPublishManage(dcPublishManage); + List list = new ArrayList<>(); + if (data != null && data.size() > 0) { + Map>> group = data.stream().collect(Collectors.groupingBy(item -> item.get("publishTime").toString())); + for (String publishTime : group.keySet()) { + TrendsPublishManage trendsPublishManage = new TrendsPublishManage(); + trendsPublishManage.setPublishTime(publishTime); + List> groupData = group.get(publishTime); + for (HashMap groupDatum : groupData) { + if ("4".equals(groupDatum.get("publishChannels").toString())){ + trendsPublishManage.setBoard(groupDatum.get("number").toString()); + } else if ("7".equals(groupDatum.get("publishChannels").toString())){ + trendsPublishManage.setBroadcast(groupDatum.get("number").toString()); + } else if ("8".equals(groupDatum.get("publishChannels").toString())){ + trendsPublishManage.setWeChat(groupDatum.get("number").toString()); + } + } + + list.add(trendsPublishManage); + } + + list = list.stream().sorted(Comparator.comparing(TrendsPublishManage::getPublishTime)).collect(Collectors.toList()); + } + + ExcelUtil util = new ExcelUtil<>(TrendsPublishManage.class); + util.exportExcel(response, list, "月发布渠道趋势分析"); + } + //统计服务,事件类型对应的发布渠道发布的数量 @PostMapping("/eventTypePublishManageSum") public AjaxResult eventTypePublishManageSum() @@ -141,6 +273,38 @@ public class DcPublishManageController extends BaseController } return AjaxResult.success(dcPublishManageService.eventTypePublishManageMonth(dcPublishManage)); } + @ApiOperation(value = "导出各事件发布渠道分析",tags = {"ECharts导出"}) + @GetMapping("/exportEventTypePublishManageMonth") + public void exportEventTypePublishManageMonth(HttpServletResponse response,DcPublishManage dcPublishManage){ + + List> data = dcPublishManageService.eventTypePublishManageMonth(dcPublishManage); + List list = new ArrayList<>(); + if (data != null && data.size() > 0) { + Map>> group = data.stream().collect(Collectors.groupingBy(item -> item.get("eventType").toString())); + for (EventTypeEnum value : EventTypeEnum.values()) { + EventTypePublishManageMonth eventTypePublishManageMonth = new EventTypePublishManageMonth(); + eventTypePublishManageMonth.setTypeName(value.getInfo()); + if (group.containsKey(String.valueOf(value.getCode()))){ + List> groupData = group.get(String.valueOf(value.getCode())); + for (HashMap groupDatum : groupData) { + if ("4".equals(groupDatum.get("publishChannels").toString())){ + eventTypePublishManageMonth.setBoard(groupDatum.get("number").toString()); + } else if ("7".equals(groupDatum.get("publishChannels").toString())){ + eventTypePublishManageMonth.setBroadcast(groupDatum.get("number").toString()); + } else if ("8".equals(groupDatum.get("publishChannels").toString())){ + eventTypePublishManageMonth.setWeChat(groupDatum.get("number").toString()); + } + } + } + list.add(eventTypePublishManageMonth); + } + + } + + ExcelUtil util = new ExcelUtil<>(EventTypePublishManageMonth.class); + util.exportExcel(response, list, "各事件发布渠道分析"); + } + /** * 公众服务统计查询 */ diff --git a/zc-business/src/main/java/com/zc/business/domain/export/EventTypePublishManageMonth.java b/zc-business/src/main/java/com/zc/business/domain/export/EventTypePublishManageMonth.java new file mode 100644 index 00000000..0456bf53 --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/domain/export/EventTypePublishManageMonth.java @@ -0,0 +1,73 @@ +package com.zc.business.domain.export; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; + +/** + * 导出月发布渠道趋势分析 + * + * @author ruoyi + * @date 2024-01-13 + */ +public class EventTypePublishManageMonth extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + /** 事件类型 */ + @Excel(name = "事件类型") + private String typeName; + + /** 情报板 */ + @Excel(name = "情报板") + private String board; + /** 语音广播 */ + @Excel(name = "语音广播") + private String broadcast; + /** 企业微信 */ + @Excel(name = "企业微信") + private String weChat; + + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + public String getBoard() { + return board; + } + + public void setBoard(String board) { + this.board = board; + } + + public String getBroadcast() { + return broadcast; + } + + public void setBroadcast(String broadcast) { + this.broadcast = broadcast; + } + + public String getWeChat() { + return weChat; + } + + public void setWeChat(String weChat) { + this.weChat = weChat; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("typeName", typeName) + .append("board", board) + .append("broadcast", broadcast) + .append("weChat", weChat) + .toString(); + } +} diff --git a/zc-business/src/main/java/com/zc/business/domain/export/StatisticsPublishManage.java b/zc-business/src/main/java/com/zc/business/domain/export/StatisticsPublishManage.java new file mode 100644 index 00000000..561ce53c --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/domain/export/StatisticsPublishManage.java @@ -0,0 +1,61 @@ +package com.zc.business.domain.export; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; + +/** + * 导出今日发布渠道分析对象 + * + * @author ruoyi + * @date 2024-01-13 + */ +public class StatisticsPublishManage extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + /** 渠道 */ + @Excel(name = "渠道") + private String channelName; + + /** 数量 */ + @Excel(name = "数量") + private String num; + /** 占比 */ + @Excel(name = "占比") + private String ratio; + + public String getChannelName() { + return channelName; + } + + public void setChannelName(String channelName) { + this.channelName = channelName; + } + + public String getNum() { + return num; + } + + public void setNum(String num) { + this.num = num; + } + + public String getRatio() { + return ratio; + } + + public void setRatio(String ratio) { + this.ratio = ratio; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("channelName", channelName) + .append("num", num) + .append("ratio", ratio) + .toString(); + } +} diff --git a/zc-business/src/main/java/com/zc/business/domain/export/TrendsPublishManage.java b/zc-business/src/main/java/com/zc/business/domain/export/TrendsPublishManage.java new file mode 100644 index 00000000..2c68c5f5 --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/domain/export/TrendsPublishManage.java @@ -0,0 +1,73 @@ +package com.zc.business.domain.export; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; + +/** + * 导出月发布渠道趋势分析 + * + * @author ruoyi + * @date 2024-01-13 + */ +public class TrendsPublishManage extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + /** 时间 */ + @Excel(name = "时间") + private String publishTime; + + /** 情报板 */ + @Excel(name = "情报板") + private String board; + /** 语音广播 */ + @Excel(name = "语音广播") + private String broadcast; + /** 企业微信 */ + @Excel(name = "企业微信") + private String weChat; + + public String getPublishTime() { + return publishTime; + } + + public void setPublishTime(String publishTime) { + this.publishTime = publishTime; + } + + public String getBoard() { + return board; + } + + public void setBoard(String board) { + this.board = board; + } + + public String getBroadcast() { + return broadcast; + } + + public void setBroadcast(String broadcast) { + this.broadcast = broadcast; + } + + public String getWeChat() { + return weChat; + } + + public void setWeChat(String weChat) { + this.weChat = weChat; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("publishTime", publishTime) + .append("board", board) + .append("broadcast", broadcast) + .append("weChat", weChat) + .toString(); + } +}