添加统计(汇总和各县统计)
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
package com.ruoyi.cms.controller.cms;
|
||||
|
||||
import com.ruoyi.cms.domain.BussinessDictType;
|
||||
import com.ruoyi.cms.domain.query.Staticsquery;
|
||||
import com.ruoyi.cms.service.StaticsqueryService;
|
||||
import com.ruoyi.cms.util.DateValidateUtil;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@@ -100,4 +100,24 @@ public class StaticsController extends BaseController {
|
||||
Map<String,Object> result = service.educationSalary(staticsquery);
|
||||
return success(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业岗位统计
|
||||
* @param staticsquery
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/qygwtjCount")
|
||||
public AjaxResult qygwtjCount(@RequestBody Staticsquery staticsquery)
|
||||
{
|
||||
if(staticsquery==null){
|
||||
return error("参数为空!");
|
||||
}
|
||||
//判断时间
|
||||
String timeError = DateValidateUtil.validateStartAndEndTime(staticsquery.getStartTime(),staticsquery.getEndTime());
|
||||
if (StringUtils.isNotBlank(timeError)) {
|
||||
return error(timeError);
|
||||
}
|
||||
Map<String,Object> result = service.qygwtjCount(staticsquery);
|
||||
return success(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.ruoyi.cms.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class StaticsJob {
|
||||
@ApiModelProperty("总数")
|
||||
private String zs;
|
||||
@ApiModelProperty("高效毕业生岗位")
|
||||
private String gxbysgw;
|
||||
@ApiModelProperty("实时在招岗位数")
|
||||
private String sszzgw;
|
||||
@ApiModelProperty("简历数量")
|
||||
private String jlsl;
|
||||
@ApiModelProperty("名称")
|
||||
private String label;
|
||||
|
||||
@ApiModelProperty("归集岗位合计")
|
||||
private String gjgwhj;
|
||||
@ApiModelProperty("注册企业数")
|
||||
private String zcqys;
|
||||
@ApiModelProperty("求职者实名数")
|
||||
private String qzzsms;
|
||||
}
|
||||
@@ -3,8 +3,15 @@ package com.ruoyi.cms.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.cms.domain.Statics;
|
||||
import com.ruoyi.cms.domain.StaticsJob;
|
||||
import com.ruoyi.cms.domain.query.Staticsquery;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface StaticsMapper extends BaseMapper<Statics>
|
||||
{
|
||||
|
||||
public StaticsJob qygwtjCount(Staticsquery staticsquery);
|
||||
|
||||
public List<StaticsJob> getGroutCityJobs(Staticsquery staticsquery);
|
||||
}
|
||||
|
||||
@@ -27,4 +27,6 @@ public interface StaticsqueryService {
|
||||
void educationSalaryGen();
|
||||
|
||||
Map<String, Object> educationSalary(Staticsquery staticsquery);
|
||||
|
||||
Map<String,Object> qygwtjCount(Staticsquery staticsquery);
|
||||
}
|
||||
|
||||
@@ -2,14 +2,12 @@ package com.ruoyi.cms.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.cms.domain.CommercialArea;
|
||||
import com.ruoyi.cms.domain.CompanyCardCollection;
|
||||
import com.ruoyi.cms.domain.Statics;
|
||||
import com.ruoyi.cms.domain.StaticsJob;
|
||||
import com.ruoyi.cms.domain.query.Staticsquery;
|
||||
import com.ruoyi.cms.mapper.CompanyCardCollectionMapper;
|
||||
import com.ruoyi.cms.mapper.StaticsMapper;
|
||||
import com.ruoyi.cms.service.ISubwayLineService;
|
||||
import com.ruoyi.cms.service.StaticsqueryService;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -551,4 +549,16 @@ public class StaticsqueryServiceImpl extends ServiceImpl<StaticsMapper, Statics>
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> qygwtjCount(Staticsquery staticsquery) {
|
||||
String eneTime= DateUtils.addOneDay(staticsquery.getEndTime(),DateUtils.YYYY_MM_DD,DateUtils.YYYY_MM_DD);
|
||||
staticsquery.setEndTime(eneTime);
|
||||
HashMap<String, Object> result = new HashMap<>();
|
||||
StaticsJob staticsJob=staticsMapper.qygwtjCount(staticsquery);
|
||||
List<StaticsJob> list=staticsMapper.getGroutCityJobs(staticsquery);
|
||||
result.put("hz",staticsJob);
|
||||
result.put("group",list);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.ruoyi.cms.util;
|
||||
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
@@ -12,6 +14,8 @@ public class DateValidateUtil {
|
||||
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
private static final String ERROR_MSG = "生日格式错误!不为空时必须填写 yyyy-MM-dd 完整格式(如 1991-09-01)";
|
||||
|
||||
private static final String DEFAULT_DATE_FORMAT_TIP = "请使用 yyyy-MM-dd 格式";
|
||||
|
||||
// 改为校验 String 类型
|
||||
public static String validateBirthDate(String birthDateStr) {
|
||||
if (birthDateStr == null || birthDateStr.trim().isEmpty()) {
|
||||
@@ -26,4 +30,73 @@ public class DateValidateUtil {
|
||||
return ERROR_MSG; // 格式错误返回提示
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验开始时间和结束时间的合法性
|
||||
* @param startTime 开始时间字符串
|
||||
* @param endTime 结束时间字符串
|
||||
* @return 校验不通过返回错误信息,校验通过返回null
|
||||
*/
|
||||
public static String validateStartAndEndTime(String startTime, String endTime) {
|
||||
StringBuilder errorMsg = new StringBuilder();
|
||||
|
||||
if (StringUtils.isBlank(startTime)) {
|
||||
errorMsg.append("开始时间不能为空!");
|
||||
} else {
|
||||
if (!isValidDate(startTime)) {
|
||||
errorMsg.append(StringUtils.isNotBlank(errorMsg.toString()) ? " " : "")
|
||||
.append("开始时间格式错误,").append(DEFAULT_DATE_FORMAT_TIP);
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(endTime)) {
|
||||
errorMsg.append(StringUtils.isNotBlank(errorMsg.toString()) ? " " : "")
|
||||
.append("结束时间不能为空!");
|
||||
} else {
|
||||
if (!isValidDate(endTime)) {
|
||||
errorMsg.append(StringUtils.isNotBlank(errorMsg.toString()) ? " " : "")
|
||||
.append("结束时间格式错误,").append(DEFAULT_DATE_FORMAT_TIP);
|
||||
} else if (StringUtils.isNotBlank(startTime) && isValidDate(startTime)) {
|
||||
if (!isEndTimeAfterStartTime(startTime, endTime)) {
|
||||
errorMsg.append(StringUtils.isNotBlank(errorMsg.toString()) ? " " : "")
|
||||
.append("结束时间不能早于开始时间!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return errorMsg.length() > 0 ? errorMsg.toString() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验单个日期字符串是否符合 yyyy-MM-dd 格式
|
||||
* @param dateStr 日期字符串
|
||||
* @return 合法返回true,否则false
|
||||
*/
|
||||
public static boolean isValidDate(String dateStr) {
|
||||
if (StringUtils.isBlank(dateStr)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
LocalDate.parse(dateStr); // 默认解析 yyyy-MM-dd 格式
|
||||
return true;
|
||||
} catch (DateTimeParseException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验结束时间是否晚于开始时间(前提:两个时间格式都合法)
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return 结束时间晚于开始时间返回true,否则false
|
||||
*/
|
||||
public static boolean isEndTimeAfterStartTime(String startTime, String endTime) {
|
||||
try {
|
||||
LocalDate startDate = LocalDate.parse(startTime);
|
||||
LocalDate endDate = LocalDate.parse(endTime);
|
||||
return !endDate.isBefore(startDate); // 结束时间 >= 开始时间 返回true
|
||||
} catch (DateTimeParseException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.ruoyi.cms.mapper.StaticsMapper">
|
||||
|
||||
<select id="qygwtjCount" parameterType="com.ruoyi.cms.domain.query.Staticsquery" resultType="com.ruoyi.cms.domain.StaticsJob">
|
||||
WITH time_params AS (
|
||||
SELECT
|
||||
CAST(#{startTime} AS timestamp) AS start_time,
|
||||
CAST(#{endTime} AS timestamp) AS end_time
|
||||
),
|
||||
job_stats AS (
|
||||
SELECT COUNT(*) AS 归集岗位合计 FROM job, time_params tp
|
||||
WHERE posting_date >= tp.start_time AND posting_date < tp.end_time
|
||||
),
|
||||
company_stats AS (
|
||||
SELECT COUNT(company_id) AS 注册企业数 FROM company, time_params tp
|
||||
WHERE del_flag='0' AND create_time >= tp.start_time AND create_time < tp.end_time
|
||||
),
|
||||
user_stats AS (
|
||||
SELECT COUNT(*) AS 求职者实名数 FROM app_user, time_params tp
|
||||
WHERE del_flag='0' AND is_company_user='1' AND id_card IS NOT NULL
|
||||
AND create_time >= tp.start_time AND create_time < tp.end_time
|
||||
),
|
||||
apply_stats AS (
|
||||
SELECT COUNT(id) AS 简历投递数量 FROM job_apply, time_params tp
|
||||
WHERE del_flag='0' AND create_time >= tp.start_time AND create_time < tp.end_time
|
||||
)
|
||||
SELECT
|
||||
js.归集岗位合计 gjgwhj, cs.注册企业数 zcqys,
|
||||
us.求职者实名数 qzzsms, as2.简历投递数量 jlsl
|
||||
FROM job_stats js, company_stats cs, user_stats us, apply_stats as2;
|
||||
</select>
|
||||
|
||||
<select id="getGroutCityJobs" parameterType="com.ruoyi.cms.domain.query.Staticsquery" resultType="com.ruoyi.cms.domain.StaticsJob">
|
||||
WITH job_stats AS (
|
||||
SELECT job_location_area_code, COUNT(job_id) AS zs,
|
||||
SUM(CASE WHEN education >= 3 THEN 1 ELSE 0 END) AS gxbysgw,
|
||||
SUM(CASE WHEN del_flag = '0' THEN 1 ELSE 0 END) AS sszzgw
|
||||
FROM job WHERE job_location_area_code IS NOT NULL
|
||||
<if test="startTime!=null and startTime!='' ">
|
||||
<![CDATA[ AND posting_date >= CAST(#{startTime} AS timestamp) ]]>
|
||||
</if>
|
||||
<if test="endTime!=null and endTime!='' ">
|
||||
<![CDATA[ AND posting_date <= CAST(#{endTime} AS timestamp) ]]>
|
||||
</if>
|
||||
GROUP BY job_location_area_code
|
||||
),apply_stats AS (
|
||||
SELECT j.job_location_area_code, COUNT(ja.id) AS jlsl
|
||||
FROM job j INNER JOIN job_apply ja ON j.job_id = ja.job_id
|
||||
WHERE j.job_location_area_code IS NOT NULL
|
||||
GROUP BY j.job_location_area_code )
|
||||
SELECT js.zs, js.gxbysgw, js.sszzgw, COALESCE(as2.jlsl, 0) AS jlsl,
|
||||
bdd.dict_label as label FROM job_stats js
|
||||
LEFT JOIN bussiness_dict_data bdd ON js.job_location_area_code = bdd.dict_value AND bdd.dict_type = 'area'
|
||||
LEFT JOIN apply_stats as2 ON js.job_location_area_code = as2.job_location_area_code
|
||||
ORDER BY bdd.dict_sort
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user