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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,6 +91,62 @@
|
||||
ORDER BY f.job_fair_start_time DESC NULLS LAST, f.job_fair_id DESC
|
||||
</select>
|
||||
|
||||
<!-- 线上招聘会时间范围汇总:企业和岗位均跨招聘会去重。 -->
|
||||
<select id="selectOnlineFairStatisticsAggregate"
|
||||
resultType="com.ruoyi.cms.domain.vo.FairStatisticsAggregate">
|
||||
WITH selected_fairs AS (
|
||||
SELECT job_fair_id
|
||||
FROM public_job_fair
|
||||
WHERE del_flag = '0'
|
||||
AND job_fair_type = '1'
|
||||
AND job_fair_start_time <![CDATA[ >= ]]> #{startTime}
|
||||
AND job_fair_start_time <![CDATA[ < ]]> #{endTime}
|
||||
),
|
||||
approved_companies AS (
|
||||
SELECT DISTINCT company_relation.company_id
|
||||
FROM public_job_fair_company company_relation
|
||||
INNER JOIN selected_fairs selected_fair
|
||||
ON selected_fair.job_fair_id = company_relation.job_fair_id
|
||||
WHERE company_relation.del_flag = '0'
|
||||
AND coalesce(company_relation.review_status, '1') = '1'
|
||||
),
|
||||
unique_jobs AS (
|
||||
SELECT DISTINCT fair_job.job_id
|
||||
FROM public_job_fair_job fair_job
|
||||
INNER JOIN selected_fairs selected_fair
|
||||
ON selected_fair.job_fair_id = fair_job.job_fair_id
|
||||
INNER JOIN job job_info
|
||||
ON job_info.job_id = fair_job.job_id
|
||||
AND job_info.del_flag = '0'
|
||||
WHERE fair_job.del_flag = '0'
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM public_job_fair_company company_relation
|
||||
WHERE company_relation.job_fair_id = fair_job.job_fair_id
|
||||
AND company_relation.company_id = fair_job.company_id
|
||||
AND company_relation.del_flag = '0'
|
||||
AND coalesce(company_relation.review_status, '1') = '1'
|
||||
)
|
||||
)
|
||||
SELECT
|
||||
(SELECT COUNT(company_id) FROM approved_companies) AS "companyCount",
|
||||
(SELECT COUNT(1) FROM unique_jobs) AS "jobCount",
|
||||
coalesce((
|
||||
SELECT SUM(CASE
|
||||
WHEN job_info.vacancies IS NULL OR job_info.vacancies <![CDATA[ <= ]]> 0 THEN 1
|
||||
ELSE job_info.vacancies
|
||||
END)
|
||||
FROM unique_jobs
|
||||
INNER JOIN job job_info ON job_info.job_id = unique_jobs.job_id
|
||||
), 0) AS "demandCount",
|
||||
coalesce((
|
||||
SELECT COUNT(DISTINCT apply_record.job_id)
|
||||
FROM job_apply apply_record
|
||||
INNER JOIN unique_jobs ON unique_jobs.job_id = apply_record.job_id
|
||||
WHERE apply_record.del_flag = '0'
|
||||
), 0) AS "interactionCount"
|
||||
</select>
|
||||
|
||||
<!--
|
||||
户外招聘会没有投递入口,因此 interactionCount 只汇总签到人员记录。
|
||||
户外岗位也使用 job.vacancies;为空或非正数时按“若干=1 人”处理。
|
||||
@@ -144,4 +200,50 @@
|
||||
</choose>
|
||||
ORDER BY f.hold_time DESC NULLS LAST, f.id DESC
|
||||
</select>
|
||||
|
||||
<!-- 户外招聘会时间范围汇总:企业和岗位均跨招聘会去重。 -->
|
||||
<select id="selectOutdoorFairStatisticsAggregate"
|
||||
resultType="com.ruoyi.cms.domain.vo.FairStatisticsAggregate">
|
||||
WITH selected_fairs AS (
|
||||
SELECT id
|
||||
FROM cms_outdoor_fair
|
||||
WHERE coalesce(del_flag, '0') = '0'
|
||||
AND hold_time <![CDATA[ >= ]]> #{startTime}
|
||||
AND hold_time <![CDATA[ < ]]> #{endTime}
|
||||
),
|
||||
unique_jobs AS (
|
||||
SELECT DISTINCT fair_job.job_id
|
||||
FROM cms_outdoor_fair_job fair_job
|
||||
INNER JOIN selected_fairs selected_fair
|
||||
ON selected_fair.id = fair_job.fair_id
|
||||
INNER JOIN job job_info
|
||||
ON job_info.job_id = fair_job.job_id
|
||||
AND job_info.del_flag = '0'
|
||||
WHERE coalesce(fair_job.del_flag, '0') = '0'
|
||||
)
|
||||
SELECT
|
||||
coalesce((
|
||||
SELECT COUNT(DISTINCT company_relation.company_id)
|
||||
FROM fair_company company_relation
|
||||
INNER JOIN selected_fairs selected_fair
|
||||
ON selected_fair.id = company_relation.job_fair_id
|
||||
WHERE coalesce(company_relation.del_flag, '0') = '0'
|
||||
), 0) AS "companyCount",
|
||||
(SELECT COUNT(1) FROM unique_jobs) AS "jobCount",
|
||||
coalesce((
|
||||
SELECT SUM(CASE
|
||||
WHEN job_info.vacancies IS NULL OR job_info.vacancies <![CDATA[ <= ]]> 0 THEN 1
|
||||
ELSE job_info.vacancies
|
||||
END)
|
||||
FROM unique_jobs
|
||||
INNER JOIN job job_info ON job_info.job_id = unique_jobs.job_id
|
||||
), 0) AS "demandCount",
|
||||
coalesce((
|
||||
SELECT COUNT(1)
|
||||
FROM cms_outdoor_fair_attendee attendee
|
||||
INNER JOIN selected_fairs selected_fair
|
||||
ON selected_fair.id = attendee.fair_id
|
||||
WHERE coalesce(attendee.del_flag, '0') = '0'
|
||||
), 0) AS "interactionCount"
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
<where>
|
||||
del_flag = '0'
|
||||
<if test="query.jobFairTitle != null and query.jobFairTitle != ''">
|
||||
and job_fair_title like concat('%', cast(#{query.jobFairTitle, jdbcType=VARCHAR} as varchar), '%')
|
||||
and job_fair_title like concat('%', cast(#{query.jobFairTitle, jdbcType=VARCHAR} as varchar), '%') escape '\'
|
||||
</if>
|
||||
<if test="query.jobFairType != null and query.jobFairType != ''">
|
||||
and job_fair_type = #{query.jobFairType}
|
||||
@@ -181,7 +181,8 @@
|
||||
</select>
|
||||
|
||||
<select id="selectCrossDomainJobs" resultType="com.ruoyi.cms.domain.rc.CrossDomainJobVO">
|
||||
select j.job_id as jobId, j.job_title as jobTitle, j.min_salary as minSalary, j.max_salary as maxSalary,
|
||||
select j.job_id as jobId, j.job_title as jobTitle, j."view" as view,
|
||||
j.min_salary as minSalary, j.max_salary as maxSalary,
|
||||
j.education, j.experience, j.vacancies, j.posting_date as postingDate,
|
||||
j.company_id as companyId, j.company_name as companyName,
|
||||
c.industry, c.scale,
|
||||
@@ -190,13 +191,85 @@
|
||||
inner join public_job_fair_job pfj on pfj.job_fair_id = pf.job_fair_id and pfj.del_flag = '0'
|
||||
inner join job j on j.job_id = pfj.job_id and j.del_flag = '0'
|
||||
left join company c on c.company_id = pfj.company_id
|
||||
where pf.is_cross_domain = 'y' and pf.del_flag = '0'
|
||||
where upper(coalesce(pf.is_cross_domain, 'N')) = 'Y'
|
||||
and pf.job_fair_type = '1'
|
||||
and pf.del_flag = '0'
|
||||
and exists (
|
||||
select 1
|
||||
from public_job_fair_company company_relation
|
||||
where company_relation.job_fair_id = pfj.job_fair_id
|
||||
and company_relation.company_id = pfj.company_id
|
||||
and company_relation.del_flag = '0'
|
||||
and coalesce(company_relation.review_status, '1') = '1'
|
||||
)
|
||||
<if test="startDate != null">
|
||||
and pf.job_fair_start_time <![CDATA[ >= ]]> #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null">
|
||||
and pf.job_fair_start_time <![CDATA[ < ]]> #{endDate}
|
||||
</if>
|
||||
<if test="cityNames != null and cityNames != ''">
|
||||
and string_to_array(pf.cross_domain_cities, ',') && string_to_array(#{cityNames}, ',')
|
||||
</if>
|
||||
order by j.posting_date desc nulls last, j.job_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectCrossDomainStatistics"
|
||||
resultType="com.ruoyi.cms.domain.rc.CrossDomainStatisticsVO">
|
||||
WITH selected_fairs AS (
|
||||
SELECT job_fair_id
|
||||
FROM public_job_fair
|
||||
WHERE upper(coalesce(is_cross_domain, 'N')) = 'Y'
|
||||
AND job_fair_type = '1'
|
||||
AND del_flag = '0'
|
||||
AND job_fair_start_time <![CDATA[ >= ]]> #{startDate}
|
||||
AND job_fair_start_time <![CDATA[ < ]]> #{endDate}
|
||||
),
|
||||
approved_companies AS (
|
||||
SELECT DISTINCT company_relation.company_id
|
||||
FROM public_job_fair_company company_relation
|
||||
INNER JOIN selected_fairs selected_fair
|
||||
ON selected_fair.job_fair_id = company_relation.job_fair_id
|
||||
WHERE company_relation.del_flag = '0'
|
||||
AND coalesce(company_relation.review_status, '1') = '1'
|
||||
),
|
||||
unique_jobs AS (
|
||||
SELECT DISTINCT fair_job.job_id
|
||||
FROM public_job_fair_job fair_job
|
||||
INNER JOIN selected_fairs selected_fair
|
||||
ON selected_fair.job_fair_id = fair_job.job_fair_id
|
||||
INNER JOIN job job_info
|
||||
ON job_info.job_id = fair_job.job_id
|
||||
AND job_info.del_flag = '0'
|
||||
WHERE fair_job.del_flag = '0'
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM public_job_fair_company company_relation
|
||||
WHERE company_relation.job_fair_id = fair_job.job_fair_id
|
||||
AND company_relation.company_id = fair_job.company_id
|
||||
AND company_relation.del_flag = '0'
|
||||
AND coalesce(company_relation.review_status, '1') = '1'
|
||||
)
|
||||
)
|
||||
SELECT
|
||||
(SELECT COUNT(1) FROM selected_fairs) AS "fairCount",
|
||||
(SELECT COUNT(company_id) FROM approved_companies) AS "companyCount",
|
||||
(SELECT COUNT(1) FROM unique_jobs) AS "jobCount",
|
||||
coalesce((
|
||||
SELECT SUM(CASE
|
||||
WHEN job_info.vacancies IS NULL OR job_info.vacancies <![CDATA[ <= ]]> 0 THEN 1
|
||||
ELSE job_info.vacancies
|
||||
END)
|
||||
FROM unique_jobs
|
||||
INNER JOIN job job_info ON job_info.job_id = unique_jobs.job_id
|
||||
), 0) AS "demandCount",
|
||||
coalesce((
|
||||
SELECT SUM(coalesce(job_info."view", 0))
|
||||
FROM unique_jobs
|
||||
INNER JOIN job job_info ON job_info.job_id = unique_jobs.job_id
|
||||
), 0) AS "viewCount"
|
||||
</select>
|
||||
|
||||
<select id="checkUserSignUp" resultType="java.lang.Integer">
|
||||
select count(1) from rc_job_fair_sign_up
|
||||
where job_fair_id = #{jobFairId}::bigint and user_id = #{personId} and del_flag = '0' and status = '0'
|
||||
|
||||
@@ -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.domain.AjaxResult;
|
||||
@@ -76,6 +77,32 @@ class FairStatisticsControllerTest
|
||||
verify(mapper).selectOutdoorFairStatistics(isNull(), any(Date.class), any(Date.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void dateRangeUsesDeduplicatedOnlineAggregate() throws Exception
|
||||
{
|
||||
FairStatisticsMapper mapper = mock(FairStatisticsMapper.class);
|
||||
when(mapper.selectOnlineFairStatistics(any(), any(Date.class), any(Date.class)))
|
||||
.thenReturn(Collections.singletonList(item("online-100", 4L, 5L, 20L, 8L)));
|
||||
FairStatisticsAggregate aggregate = new FairStatisticsAggregate();
|
||||
aggregate.setCompanyCount(2L);
|
||||
aggregate.setJobCount(3L);
|
||||
aggregate.setDemandCount(7L);
|
||||
aggregate.setInteractionCount(4L);
|
||||
when(mapper.selectOnlineFairStatisticsAggregate(any(Date.class), any(Date.class)))
|
||||
.thenReturn(aggregate);
|
||||
FairStatisticsController controller = controllerWith(mapper);
|
||||
|
||||
AjaxResult result = controller.summary("online", null,
|
||||
new Date(1_700_000_000_000L), new Date(1_700_086_400_000L));
|
||||
|
||||
Map<String, Object> data = dataOf(result);
|
||||
assertEquals(2L, data.get("companyCount"));
|
||||
assertEquals(3L, data.get("jobCount"));
|
||||
assertEquals(7L, data.get("demandCount"));
|
||||
assertEquals(4L, data.get("interactionCount"));
|
||||
verify(mapper).selectOnlineFairStatisticsAggregate(any(Date.class), any(Date.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void incompleteScopeReturnsValidationError() throws Exception
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user