diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysLiveSchedulController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysLiveSchedulController.java index e4fe38404..1cc3ba664 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysLiveSchedulController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysLiveSchedulController.java @@ -1,9 +1,13 @@ package com.stdiet.web.controller.custom; +import java.math.BigDecimal; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; import com.stdiet.common.utils.DateUtils; +import com.stdiet.common.utils.NumberUtils; import com.stdiet.common.utils.StringUtils; import com.stdiet.custom.domain.SysLiveSchedulFanRecord; import org.springframework.security.access.prepost.PreAuthorize; @@ -36,11 +40,30 @@ public class SysLiveSchedulController extends BaseController */ @PreAuthorize("@ss.hasPermi('custom:liveSchedul:list')") @GetMapping("/list") - public TableDataInfo list(SysLiveSchedul sysLiveSchedul) + public AjaxResult list(SysLiveSchedul sysLiveSchedul) { startPage(); List list = sysLiveSchedulService.selectSysLiveSchedulList(sysLiveSchedul); - return getDataTable(list); + + int totalImportNum = 0; + int totalAddFanNum = 0; + double totalLiveTime = 0; + if(list != null && list.size() > 0){ + //查询总共导粉量 + totalImportNum = sysLiveSchedulService.getTotalImportFanNumByLiveSchedul(sysLiveSchedul); + //查询总共进粉量 + totalAddFanNum = sysLiveSchedulService.getTotalAddFanNumByLiveSchedul(sysLiveSchedul); + //查询总直播时长(小时) + totalLiveTime = NumberUtils.getNumberByRoundHalfUp(sysLiveSchedulService.getLiveTotalTimeByLiveSchedul(sysLiveSchedul)/60.0,2).doubleValue(); + } + + Map result = new HashMap<>(); + result.put("tableDataInfo", getDataTable(list)); + result.put("totalImportNum", totalImportNum); + result.put("totalAddFanNum", totalAddFanNum); + result.put("totalLiveTime", totalLiveTime); + + return AjaxResult.success(result); } /** @@ -52,6 +75,29 @@ public class SysLiveSchedulController extends BaseController public AjaxResult export(SysLiveSchedul sysLiveSchedul) { List list = sysLiveSchedulService.selectSysLiveSchedulList(sysLiveSchedul); + for (SysLiveSchedul live : list) { + live.setImportFanSize(0); + if(live.getWxAccountList() != null && live.getWxAccountList().size() > 0){ + for (Map map : live.getWxAccountList() + ) { + live.setImportFanSize(live.getImportFanSize() + (map.containsKey("fanNum") ? ((BigDecimal) map.get("fanNum")).intValue() : 0)); + } + } + live.setAddFanSize(live.getAddFanList() != null ? live.getAddFanList().size() : 0); + String liveTimeStr = ""; + if(live.getLiveStartTime() != null){ + liveTimeStr = DateUtils.getHourMinuteByDate(live.getLiveStartTime()); + } + if(live.getLiveEndTime() != null){ + liveTimeStr += "-" + DateUtils.getHourMinuteByDate(live.getLiveEndTime()); + } + live.setLiveStartTimeString(liveTimeStr); + //计算直播时长 + if(live.getLiveStartTime() != null && live.getLiveEndTime() != null){ + double t = (live.getLiveEndTime().getTime() - live.getLiveStartTime().getTime())/1000.0/60/60; + live.setLiveTotalHour(t > 0 ? NumberUtils.getNumberByRoundHalfUp(t,2) : new BigDecimal(0)); + } + } ExcelUtil util = new ExcelUtil(SysLiveSchedul.class); return util.exportExcel(list, "liveSchedul"); } diff --git a/stdiet-common/src/main/java/com/stdiet/common/utils/DateUtils.java b/stdiet-common/src/main/java/com/stdiet/common/utils/DateUtils.java index 2ae896768..4b04561a9 100644 --- a/stdiet-common/src/main/java/com/stdiet/common/utils/DateUtils.java +++ b/stdiet-common/src/main/java/com/stdiet/common/utils/DateUtils.java @@ -27,6 +27,8 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss"; public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"; + + public static String YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm"; private static String[] parsePatterns = { "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", @@ -231,4 +233,14 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils public static Date getLastMinuteDate(Date date){ return new Date(dateToDate(date).getTime()+(24 * 60 * 60 * 1000 - 1000)); } + + /** + * 获取日期的小时和分钟 + * @param date + * @return + */ + public static String getHourMinuteByDate(Date date){ + String dateStr = DateFormatUtils.format(date, YYYY_MM_DD_HH_MM); + return dateStr.substring(dateStr.length()-5); + } } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysLiveSchedul.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysLiveSchedul.java index f4b023aa7..ad27c03ed 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysLiveSchedul.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysLiveSchedul.java @@ -1,5 +1,6 @@ package com.stdiet.custom.domain; +import java.math.BigDecimal; import java.util.Date; import java.util.List; import java.util.Map; @@ -24,44 +25,38 @@ public class SysLiveSchedul extends BaseEntity private Long id; /** 直播间序号 */ - @Excel(name = "直播间序号") private Integer liveRoom; /** 排班日期 */ @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "排班日期", width = 30, dateFormat = "yyyy-MM-dd") + @Excel(name = "直播日期", width = 30, dateFormat = "yyyy-MM-dd", sort = 1) private Date liveSchedulDate; /** 直播开始时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm") - @Excel(name = "直播开始时间", width = 30, dateFormat = "yyyy-MM-dd") private Date liveStartTime; + @Excel(name = "直播时间", width = 30, sort = 3) private String liveStartTimeString; /** 直播结束时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm") - @Excel(name = "直播结束时间", width = 30, dateFormat = "yyyy-MM-dd") private Date liveEndTime; /** 直播营养师 */ - @Excel(name = "直播营养师") private Long liveNutritionistId; /** 直播运营 */ - @Excel(name = "直播运营") private Long liveOperatorId; /** 直播策划 */ - @Excel(name = "直播策划") private Long livePlannerId; /** 微信账号管理的进粉渠道 */ - @Excel(name = "微信账号管理的进粉渠道") private Integer fanChannel; /** 直播状态,0未开播 1已开播 2已下播 */ - @Excel(name = "直播状态,0未开播 1已开播 2已下播") + @Excel(name = "直播状态", readConverterExp="0=未开播,1=已开播,2=已下播",sort = 4) private Long liveStatus; /** 删除标识,默认0 */ @@ -71,19 +66,33 @@ public class SysLiveSchedul extends BaseEntity private Long wxAccountId; //直播间名称 + @Excel(name = "直播间", sort = 2) private String liveRoomName; + @Excel(name = "直播营养师", sort = 5) private String liveNutritionistName; private String livePlannerName; private String liveOperatorName; + @Excel(name = "所属账号",sort = 6) private String fanChannelName; //导粉情况 private List> wxAccountList; + //导粉数量 + @Excel(name = "导粉数量",sort = 7,isStatistics = true,cellType = Excel.ColumnType.NUMERIC) + private Integer importFanSize; + //进粉情况 private List> addFanList; + + //进粉数量 + @Excel(name = "进粉数量",sort = 8, isStatistics=true,cellType = Excel.ColumnType.NUMERIC) + private Integer addFanSize; + + @Excel(name = "直播时长",sort = 9, isStatistics=true,cellType = Excel.ColumnType.NUMERIC) + private BigDecimal liveTotalHour; } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysLiveSchedulMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysLiveSchedulMapper.java index 50e5494ad..e43ad910d 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysLiveSchedulMapper.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysLiveSchedulMapper.java @@ -96,4 +96,25 @@ public interface SysLiveSchedulMapper * @return */ public SysLiveSchedul getLiveSchedulByTime(SysLiveSchedul sysLiveSchedul); + + /** + * 查询导粉总量 + * @param sysLiveSchedul + * @return + */ + int getTotalImportFanNumByLiveSchedul(SysLiveSchedul sysLiveSchedul); + + /** + * 查询总进粉量 + * @param sysLiveSchedul + * @return + */ + int getTotalAddFanNumByLiveSchedul(SysLiveSchedul sysLiveSchedul); + + /** + * 查询总直播时长 + * @param sysLiveSchedul + * @return + */ + int getLiveTotalTimeByLiveSchedul(SysLiveSchedul sysLiveSchedul); } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysLiveSchedulService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysLiveSchedulService.java index 020b752fa..04dfcfb76 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysLiveSchedulService.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysLiveSchedulService.java @@ -113,4 +113,25 @@ public interface ISysLiveSchedulService * @return */ int delLiveSchedulFanRecord(Long id); + + /** + * 查询导粉总量 + * @param sysLiveSchedul + * @return + */ + int getTotalImportFanNumByLiveSchedul(SysLiveSchedul sysLiveSchedul); + + /** + * 查询总进粉量 + * @param sysLiveSchedul + * @return + */ + int getTotalAddFanNumByLiveSchedul(SysLiveSchedul sysLiveSchedul); + + /** + * 查询总直播时长 + * @param sysLiveSchedul + * @return + */ + int getLiveTotalTimeByLiveSchedul(SysLiveSchedul sysLiveSchedul); } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysLiveSchedulServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysLiveSchedulServiceImpl.java index 493068ece..c1e3aca64 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysLiveSchedulServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysLiveSchedulServiceImpl.java @@ -216,4 +216,31 @@ public class SysLiveSchedulServiceImpl implements ISysLiveSchedulService public int delLiveSchedulFanRecord(Long id){ return sysLiveSchedulFanRecordMapper.deleteSysLiveSchedulFanRecordById(id); } + + /** + * 查询导粉总量 + * @param sysLiveSchedul + * @return + */ + public int getTotalImportFanNumByLiveSchedul(SysLiveSchedul sysLiveSchedul){ + return sysLiveSchedulMapper.getTotalImportFanNumByLiveSchedul(sysLiveSchedul); + } + + /** + * 查询总进粉量 + * @param sysLiveSchedul + * @return + */ + public int getTotalAddFanNumByLiveSchedul(SysLiveSchedul sysLiveSchedul){ + return sysLiveSchedulMapper.getTotalAddFanNumByLiveSchedul(sysLiveSchedul); + } + + /** + * 查询总直播时长 + * @param sysLiveSchedul + * @return + */ + public int getLiveTotalTimeByLiveSchedul(SysLiveSchedul sysLiveSchedul){ + return sysLiveSchedulMapper.getLiveTotalTimeByLiveSchedul(sysLiveSchedul); + } } \ No newline at end of file diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysLiveSchedulMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysLiveSchedulMapper.xml index ce9bf25a8..690e68287 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysLiveSchedulMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysLiveSchedulMapper.xml @@ -67,8 +67,11 @@ left join sys_user su_plan on su_plan.user_id = slc.live_planner_id and su_plan.del_flag = 0 left join sys_user su_operator on su_operator.user_id = slc.live_operator_id and su_operator.del_flag = 0 where slc.del_flag = 0 - - and date_format(slc.live_schedul_date,'%y%m%d') = date_format(#{liveSchedulDate},'%y%m%d') + + and ( + date_format(slc.live_schedul_date,'%y%m%d') >= date_format(#{liveStartTime},'%y%m%d') + and date_format(#{liveEndTime},'%y%m%d') >= date_format(slc.live_schedul_date,'%y%m%d') + ) and slc.live_room = #{liveRoom} @@ -76,9 +79,10 @@ and slc.fan_channel = #{fanChannel} - + + and slc.live_nutritionist_id = #{liveNutritionistId} + + order by slc.live_schedul_date desc,slc.live_start_time desc ,slc.live_room asc @@ -175,6 +179,31 @@ group by w.wx_account,su.nick_name + + + + + + + + + \ No newline at end of file diff --git a/stdiet-ui/src/views/custom/liveSchedul/index.vue b/stdiet-ui/src/views/custom/liveSchedul/index.vue index 9445c72bc..7c0d01dc7 100644 --- a/stdiet-ui/src/views/custom/liveSchedul/index.vue +++ b/stdiet-ui/src/views/custom/liveSchedul/index.vue @@ -2,13 +2,27 @@
- - + --> + + + + - + + + + + + @@ -142,7 +172,7 @@