feat: 完善跨域招聘会统计与时间范围查询
This commit is contained in:
@@ -14,6 +14,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -46,12 +50,49 @@ public class CmsPublicJobFairController extends BaseController {
|
||||
@ApiOperation("跨域招聘会岗位列表")
|
||||
@PreAuthorize("@ss.hasPermi('cms:crossCityFair:list')")
|
||||
@GetMapping("/cross-domain-jobs")
|
||||
public TableDataInfo crossDomainJobs(@RequestParam(required = false) String cityNames) {
|
||||
public TableDataInfo crossDomainJobs(@RequestParam(required = false) String cityNames,
|
||||
@RequestParam(required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
|
||||
@RequestParam(required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate) {
|
||||
startPage();
|
||||
List<CrossDomainJobVO> list = publicJobFairService.selectCrossDomainJobs(cityNames);
|
||||
List<CrossDomainJobVO> list = publicJobFairService.selectCrossDomainJobs(
|
||||
cityNames, toStartOfDay(startDate), toExclusiveEndOfDay(endDate));
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询指定时间范围内跨域线上招聘会的去重统计。
|
||||
*/
|
||||
@ApiOperation("跨域线上招聘会统计")
|
||||
@PreAuthorize("@ss.hasPermi('cms:crossCityFair:list')")
|
||||
@GetMapping("/cross-domain-statistics")
|
||||
public AjaxResult crossDomainStatistics(
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate) {
|
||||
if (endDate.before(startDate)) {
|
||||
return error("结束日期不能早于起始日期");
|
||||
}
|
||||
return success(publicJobFairService.selectCrossDomainStatistics(
|
||||
toStartOfDay(startDate), toExclusiveEndOfDay(endDate)));
|
||||
}
|
||||
|
||||
private Date toStartOfDay(Date value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
LocalDate date = value.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
return Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant());
|
||||
}
|
||||
|
||||
private Date toExclusiveEndOfDay(Date value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
LocalDate date = value.toInstant().atZone(ZoneId.systemDefault()).toLocalDate().plusDays(1);
|
||||
return Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取招聘会详情
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.cms.controller.cms;
|
||||
|
||||
import com.ruoyi.cms.domain.vo.FairStatisticsAggregate;
|
||||
import com.ruoyi.cms.domain.vo.FairStatisticsFairItem;
|
||||
import com.ruoyi.cms.mapper.FairStatisticsMapper;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
@@ -108,18 +109,21 @@ public class FairStatisticsController extends BaseController
|
||||
fairs = fairStatisticsMapper.selectOutdoorFairStatistics(outdoorFairId, rangeStart, rangeEnd);
|
||||
}
|
||||
|
||||
long companyCount = 0L;
|
||||
long jobCount = 0L;
|
||||
long demandCount = 0L;
|
||||
long interactionCount = 0L;
|
||||
for (FairStatisticsFairItem fair : fairs)
|
||||
FairStatisticsAggregate aggregate = null;
|
||||
if (!hasFairId)
|
||||
{
|
||||
companyCount += numberOrZero(fair.getCompanyCount());
|
||||
jobCount += numberOrZero(fair.getJobCount());
|
||||
demandCount += numberOrZero(fair.getDemandCount());
|
||||
interactionCount += numberOrZero(fair.getInteractionCount());
|
||||
aggregate = ONLINE.equals(normalizedType)
|
||||
? fairStatisticsMapper.selectOnlineFairStatisticsAggregate(rangeStart, rangeEnd)
|
||||
: fairStatisticsMapper.selectOutdoorFairStatisticsAggregate(rangeStart, rangeEnd);
|
||||
}
|
||||
|
||||
long companyCount = aggregate == null ? sumCompanyCount(fairs) : numberOrZero(aggregate.getCompanyCount());
|
||||
long jobCount = aggregate == null ? sumJobCount(fairs) : numberOrZero(aggregate.getJobCount());
|
||||
long demandCount = aggregate == null ? sumDemandCount(fairs) : numberOrZero(aggregate.getDemandCount());
|
||||
long interactionCount = aggregate == null
|
||||
? sumInteractionCount(fairs)
|
||||
: numberOrZero(aggregate.getInteractionCount());
|
||||
|
||||
Map<String, Object> result = new LinkedHashMap<>();
|
||||
result.put("fairType", normalizedType);
|
||||
result.put("fairCount", fairs.size());
|
||||
@@ -145,4 +149,44 @@ public class FairStatisticsController extends BaseController
|
||||
{
|
||||
return value == null ? 0L : value;
|
||||
}
|
||||
|
||||
private long sumCompanyCount(List<FairStatisticsFairItem> fairs)
|
||||
{
|
||||
long total = 0L;
|
||||
for (FairStatisticsFairItem fair : fairs)
|
||||
{
|
||||
total += numberOrZero(fair.getCompanyCount());
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
private long sumJobCount(List<FairStatisticsFairItem> fairs)
|
||||
{
|
||||
long total = 0L;
|
||||
for (FairStatisticsFairItem fair : fairs)
|
||||
{
|
||||
total += numberOrZero(fair.getJobCount());
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
private long sumDemandCount(List<FairStatisticsFairItem> fairs)
|
||||
{
|
||||
long total = 0L;
|
||||
for (FairStatisticsFairItem fair : fairs)
|
||||
{
|
||||
total += numberOrZero(fair.getDemandCount());
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
private long sumInteractionCount(List<FairStatisticsFairItem> fairs)
|
||||
{
|
||||
long total = 0L;
|
||||
for (FairStatisticsFairItem fair : fairs)
|
||||
{
|
||||
total += numberOrZero(fair.getInteractionCount());
|
||||
}
|
||||
return total;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,9 @@ public class CrossDomainJobVO implements Serializable {
|
||||
@ApiModelProperty("岗位名称")
|
||||
private String jobTitle;
|
||||
|
||||
@ApiModelProperty("岗位浏览量")
|
||||
private Long view;
|
||||
|
||||
@ApiModelProperty("最低薪资")
|
||||
private Integer minSalary;
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.ruoyi.cms.domain.rc;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 跨域线上招聘会统计汇总。
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("跨域线上招聘会统计")
|
||||
public class CrossDomainStatisticsVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("跨域线上招聘会数量")
|
||||
private Long fairCount;
|
||||
|
||||
@ApiModelProperty("参会企业数量")
|
||||
private Long companyCount;
|
||||
|
||||
@ApiModelProperty("去重后的岗位数量")
|
||||
private Long jobCount;
|
||||
|
||||
@ApiModelProperty("招聘需求人数")
|
||||
private Long demandCount;
|
||||
|
||||
@ApiModelProperty("岗位浏览量")
|
||||
private Long viewCount;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.ruoyi.cms.domain.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 招聘会统计时间范围内的去重汇总数据。
|
||||
*/
|
||||
public class FairStatisticsAggregate implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long companyCount;
|
||||
|
||||
private Long jobCount;
|
||||
|
||||
private Long demandCount;
|
||||
|
||||
private Long interactionCount;
|
||||
|
||||
public Long getCompanyCount()
|
||||
{
|
||||
return companyCount;
|
||||
}
|
||||
|
||||
public void setCompanyCount(Long companyCount)
|
||||
{
|
||||
this.companyCount = companyCount;
|
||||
}
|
||||
|
||||
public Long getJobCount()
|
||||
{
|
||||
return jobCount;
|
||||
}
|
||||
|
||||
public void setJobCount(Long jobCount)
|
||||
{
|
||||
this.jobCount = jobCount;
|
||||
}
|
||||
|
||||
public Long getDemandCount()
|
||||
{
|
||||
return demandCount;
|
||||
}
|
||||
|
||||
public void setDemandCount(Long demandCount)
|
||||
{
|
||||
this.demandCount = demandCount;
|
||||
}
|
||||
|
||||
public Long getInteractionCount()
|
||||
{
|
||||
return interactionCount;
|
||||
}
|
||||
|
||||
public void setInteractionCount(Long interactionCount)
|
||||
{
|
||||
this.interactionCount = interactionCount;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ruoyi.cms.mapper;
|
||||
|
||||
import com.ruoyi.cms.domain.vo.FairStatisticsFairItem;
|
||||
import com.ruoyi.cms.domain.vo.FairStatisticsAggregate;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
@@ -16,8 +17,16 @@ public interface FairStatisticsMapper
|
||||
@Param("startTime") Date startTime,
|
||||
@Param("endTime") Date endTime);
|
||||
|
||||
/** 查询线上招聘会时间范围内的去重汇总。 */
|
||||
FairStatisticsAggregate selectOnlineFairStatisticsAggregate(@Param("startTime") Date startTime,
|
||||
@Param("endTime") Date endTime);
|
||||
|
||||
/** 查询户外招聘会的逐场统计。 */
|
||||
List<FairStatisticsFairItem> selectOutdoorFairStatistics(@Param("fairId") Long fairId,
|
||||
@Param("startTime") Date startTime,
|
||||
@Param("endTime") Date endTime);
|
||||
|
||||
/** 查询户外招聘会时间范围内的去重汇总。 */
|
||||
FairStatisticsAggregate selectOutdoorFairStatisticsAggregate(@Param("startTime") Date startTime,
|
||||
@Param("endTime") Date endTime);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.ruoyi.cms.domain.Job;
|
||||
import com.ruoyi.cms.domain.rc.*;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -57,7 +58,15 @@ public interface PublicJobFairMapper extends BaseMapper<PublicJobFair> {
|
||||
/**
|
||||
* 查询跨域招聘会下的岗位(可按联盟城市过滤,cityNames 为逗号分隔的城市名称)
|
||||
*/
|
||||
List<CrossDomainJobVO> selectCrossDomainJobs(@Param("cityNames") String cityNames);
|
||||
List<CrossDomainJobVO> selectCrossDomainJobs(@Param("cityNames") String cityNames,
|
||||
@Param("startDate") Date startDate,
|
||||
@Param("endDate") Date endDate);
|
||||
|
||||
/**
|
||||
* 查询指定时间范围内跨域线上招聘会的去重统计。
|
||||
*/
|
||||
CrossDomainStatisticsVO selectCrossDomainStatistics(@Param("startDate") Date startDate,
|
||||
@Param("endDate") Date endDate);
|
||||
|
||||
/**
|
||||
* 检查用户是否已报名
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.ruoyi.cms.domain.Job;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 公共招聘会Service接口
|
||||
@@ -136,5 +137,10 @@ public interface IPublicJobFairService {
|
||||
/**
|
||||
* 查询跨域招聘会下的岗位(可按联盟城市过滤,cityNames 为逗号分隔的城市名称)
|
||||
*/
|
||||
List<CrossDomainJobVO> selectCrossDomainJobs(String cityNames);
|
||||
List<CrossDomainJobVO> selectCrossDomainJobs(String cityNames, Date startDate, Date endDate);
|
||||
|
||||
/**
|
||||
* 查询指定时间范围内跨域线上招聘会的去重统计。
|
||||
*/
|
||||
CrossDomainStatisticsVO selectCrossDomainStatistics(Date startDate, Date endDate);
|
||||
}
|
||||
|
||||
@@ -681,7 +681,12 @@ public class PublicJobFairServiceImpl implements IPublicJobFairService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrossDomainJobVO> selectCrossDomainJobs(String cityNames) {
|
||||
return publicJobFairMapper.selectCrossDomainJobs(cityNames);
|
||||
public List<CrossDomainJobVO> selectCrossDomainJobs(String cityNames, Date startDate, Date endDate) {
|
||||
return publicJobFairMapper.selectCrossDomainJobs(cityNames, startDate, endDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CrossDomainStatisticsVO selectCrossDomainStatistics(Date startDate, Date endDate) {
|
||||
return publicJobFairMapper.selectCrossDomainStatistics(startDate, endDate);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user