Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
jy_jfb
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
jy_jfb
Commits
e355fce1
提交
e355fce1
authored
9月 21, 2026
作者:
wml
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加招聘的状态
上级
f178e5d2
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
246 行增加
和
0 行删除
+246
-0
RecruitController.java
...in/java/com/jfb/recruit/controller/RecruitController.java
+212
-0
RecruitImportExcel.java
...a/com/jfb/recruit/util/Excelutils/RecruitImportExcel.java
+34
-0
没有找到文件。
jfb-recruit/src/main/java/com/jfb/recruit/controller/RecruitController.java
浏览文件 @
e355fce1
...
@@ -2,16 +2,30 @@ package com.jfb.recruit.controller;
...
@@ -2,16 +2,30 @@ package com.jfb.recruit.controller;
import
base.controller.BaseController
;
import
base.controller.BaseController
;
import
base.result.BaseResult
;
import
base.result.BaseResult
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.event.AnalysisEventListener
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.github.pagehelper.PageInfo
;
import
com.github.pagehelper.PageInfo
;
import
com.jfb.recruit.bean.auth.UserContext
;
import
com.jfb.recruit.bean.auth.UserContext
;
import
com.jfb.recruit.service.OrgService
;
import
com.jfb.recruit.service.RecruitService
;
import
com.jfb.recruit.service.RecruitService
;
import
com.jfb.recruit.util.Excelutils.RecruitImportExcel
;
import
com.jfb.recruit.util.auth.UserUtils
;
import
com.jfb.recruit.util.auth.UserUtils
;
import
com.jfb.recruit.xsnowflake.SnowFlakeFactory
;
import
data.recruit.Org
;
import
data.recruit.Recruit
;
import
data.recruit.Recruit
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -26,6 +40,15 @@ public class RecruitController extends BaseController {
...
@@ -26,6 +40,15 @@ public class RecruitController extends BaseController {
@Resource
@Resource
RecruitService
recruitService
;
RecruitService
recruitService
;
@Resource
OrgService
orgService
;
@Autowired
SnowFlakeFactory
snowFlakeFactory
;
@Autowired
private
ThreadPoolTaskExecutor
taskExecutor
;
/**
/**
* @description: 获取招聘列表
* @description: 获取招聘列表
* @author: wangmenglong
* @author: wangmenglong
...
@@ -108,4 +131,193 @@ public class RecruitController extends BaseController {
...
@@ -108,4 +131,193 @@ public class RecruitController extends BaseController {
return
recruitService
.
updateStatus
(
recruit
)?
BaseResult
.
success
(
"normal_002"
):
BaseResult
.
error
(
"error_002"
);
return
recruitService
.
updateStatus
(
recruit
)?
BaseResult
.
success
(
"normal_002"
):
BaseResult
.
error
(
"error_002"
);
}
}
/**
* 批量导入岗位(Excel):列顺序 企业名、企业信息、岗位名、岗位的信息、最低工资、最高工资
* @Author: wml
* @Date 2026/9/21
*/
@PostMapping
(
value
=
"/upload/excel"
)
public
BaseResult
uploadExcelFile
(
HttpServletRequest
req
,
@RequestParam
(
"file"
)
MultipartFile
file
)
{
UserContext
userContext
=
UserUtils
.
getUserContext
();
String
userId
=
userContext
.
getUserId
();
String
baseCode
=
userContext
.
getBaseCode
();
String
userName
=
userContext
.
getUsername
();
// 1. 提交异步任务到线程池(后台执行)
taskExecutor
.
execute
(()
->
{
String
recruitTypeId
=
req
.
getParameter
(
"recruitTypeId"
);
String
recruitType
=
req
.
getParameter
(
"recruitType"
);
String
experienceId
=
req
.
getParameter
(
"experienceId"
);
String
experience
=
req
.
getParameter
(
"experience"
);
String
qualificationId
=
req
.
getParameter
(
"qualificationId"
);
String
qualification
=
req
.
getParameter
(
"qualification"
);
String
payTimes
=
req
.
getParameter
(
"payTimes"
);
String
startDate
=
req
.
getParameter
(
"startDate"
);
String
expiredDate
=
req
.
getParameter
(
"expiredDate"
);
String
qualificationCode
=
req
.
getParameter
(
"qualificationCode"
);
String
experienceCode
=
req
.
getParameter
(
"experienceCode"
);
String
province
=
req
.
getParameter
(
"province"
);
String
city
=
req
.
getParameter
(
"city"
);
String
region
=
req
.
getParameter
(
"region"
);
String
oneIndustryName
=
req
.
getParameter
(
"oneIndustryName"
);
String
oneIndustryId
=
req
.
getParameter
(
"oneIndustryId"
);
String
towIndustryName
=
req
.
getParameter
(
"towIndustryName"
);
String
towIndustryId
=
req
.
getParameter
(
"towIndustryId"
);
String
industryCode
=
req
.
getParameter
(
"industryCode"
);
String
regionCode
=
req
.
getParameter
(
"regionCode"
);
String
industryName
=
req
.
getParameter
(
"industryName"
);
String
times
=
req
.
getParameter
(
"times"
);
// 2. 校验文件是否为空
if
(
file
.
isEmpty
())
{
System
.
out
.
println
(
"文件为空------------------------------------------------------"
);
return
;
}
// 3. 校验文件类型(支持 .xls / .xlsx)
String
originalFilename
=
file
.
getOriginalFilename
();
if
(
originalFilename
==
null
||
!(
originalFilename
.
trim
().
toLowerCase
().
endsWith
(
".xls"
)
||
originalFilename
.
trim
().
toLowerCase
().
endsWith
(
".xlsx"
)))
{
System
.
out
.
println
(
"文件类型错误------------------------------------------------------"
);
return
;
}
try
(
InputStream
inputStream
=
file
.
getInputStream
())
{
// 4. 读取 Excel 全部数据
class
DataReadListener
extends
AnalysisEventListener
<
RecruitImportExcel
>
{
private
List
<
RecruitImportExcel
>
dataList
=
new
ArrayList
<>();
@Override
public
void
invoke
(
RecruitImportExcel
data
,
AnalysisContext
context
)
{
dataList
.
add
(
data
);
}
@Override
public
void
doAfterAllAnalysed
(
AnalysisContext
context
)
{
}
public
List
<
RecruitImportExcel
>
getDataList
()
{
return
dataList
;
}
}
DataReadListener
listener
=
new
DataReadListener
();
EasyExcel
.
read
(
inputStream
,
RecruitImportExcel
.
class
,
listener
).
sheet
().
doRead
();
List
<
RecruitImportExcel
>
excelList
=
listener
.
getDataList
();
for
(
int
i
=
0
;
i
<
excelList
.
size
();
i
++)
{
RecruitImportExcel
row
=
excelList
.
get
(
i
);
String
fullCompanyName
=
row
.
getName
();
Org
orgDetails
=
orgService
.
getName
(
fullCompanyName
);
if
(
orgDetails
==
null
)
{
orgDetails
=
new
Org
();
orgDetails
.
setName
(
fullCompanyName
);
orgDetails
.
setDescr
(
row
.
getCompanyInfo
());
orgDetails
.
setRegionCode
(
regionCode
);
orgDetails
.
setRegion
(
region
);
orgDetails
.
setProvince
(
province
);
orgDetails
.
setCity
(
city
);
orgDetails
.
setId
(
snowFlakeFactory
.
nextId
());
orgDetails
.
setBaseCode
(
baseCode
);
orgDetails
.
setUserId
(
userId
);
orgDetails
.
setUserName
(
userName
);
orgService
.
create
(
orgDetails
);
}
if
(
orgDetails
!=
null
&&
StringUtils
.
isNotBlank
(
orgDetails
.
getId
()))
{
Recruit
recruit
=
new
Recruit
();
recruit
.
setId
(
snowFlakeFactory
.
nextId
());
recruit
.
setBaseCode
(
baseCode
);
recruit
.
setUserId
(
userId
);
recruit
.
setUserName
(
userName
);
recruit
.
setRecruitType
(
recruitType
);
recruit
.
setRecruitTypeId
(
recruitTypeId
);
recruit
.
setExperience
(
experience
);
recruit
.
setExperienceId
(
experienceId
);
recruit
.
setQualification
(
qualification
);
recruit
.
setQualificationId
(
qualificationId
);
recruit
.
setPayTimes
(
Integer
.
parseInt
(
payTimes
));
recruit
.
setStartDate
(
startDate
);
recruit
.
setExpiredDate
(
expiredDate
);
recruit
.
setQualificationCode
(
qualificationCode
);
recruit
.
setExperienceCode
(
experienceCode
);
recruit
.
setProvince
(
province
);
recruit
.
setCity
(
city
);
recruit
.
setRegion
(
region
);
recruit
.
setOneIndustryName
(
oneIndustryName
);
recruit
.
setOneIndustryId
(
oneIndustryId
);
recruit
.
setTowIndustryName
(
towIndustryName
);
recruit
.
setTowIndustryId
(
towIndustryId
);
recruit
.
setIndustryName
(
industryName
);
recruit
.
setIndustryCode
(
industryCode
);
recruit
.
setTimes
(
Integer
.
parseInt
(
times
));
recruit
.
setAddress
(
orgDetails
.
getProvince
()
+
orgDetails
.
getCity
()
+
orgDetails
.
getRegion
()
+
orgDetails
.
getAddress
());
recruit
.
setName
(
row
.
getJobName
());
recruit
.
setDetails
(
row
.
getJobInfo
());
recruit
.
setOrgId
(
orgDetails
.
getId
());
recruit
.
setOrgName
(
orgDetails
.
getName
());
recruit
.
setBatch
(
"0"
);
recruit
.
setBatchSend
(
"0"
);
recruit
.
setStatus
(
"up"
);
// 薪资:有值则解析(兼容小数,如 5000.0),缺失则给默认值 4000/5000
String
salaryMinStr
=
row
.
getSalaryMin
();
String
salaryMaxStr
=
row
.
getSalaryMax
();
if
(
StringUtils
.
isBlank
(
salaryMinStr
)
||
StringUtils
.
isBlank
(
salaryMaxStr
))
{
recruit
.
setSalaryMax
(
5000
);
recruit
.
setSalaryMin
(
4000
);
}
else
{
recruit
.
setSalaryMin
(
parseSalary
(
salaryMinStr
));
recruit
.
setSalaryMax
(
parseSalary
(
salaryMaxStr
));
}
recruitService
.
create
(
recruit
);
recruit
.
setOrg
(
orgDetails
);
try
{
Thread
.
sleep
(
500
);
System
.
out
.
println
(
"开始发送------------------------------------------------------第"
+
i
+
"条,总共"
+
excelList
.
size
()
+
"条"
);
recruitService
.
sendAli
(
recruit
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
// 5. 返回成功响应
System
.
out
.
println
(
"完成导入------------------------------------------------------"
);
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"io异常------------------------------------------------------"
);
}
});
return
BaseResult
.
success
();
}
/**
* 容错解析薪资:去除空格、千分位逗号,兼容小数(如 5000.0 → 5000),解析失败返回 0
**/
private
Integer
parseSalary
(
String
value
)
{
if
(
StringUtils
.
isBlank
(
value
))
{
return
0
;
}
try
{
String
cleaned
=
value
.
trim
().
replace
(
","
,
""
);
return
(
int
)
Math
.
floor
(
Double
.
parseDouble
(
cleaned
));
}
catch
(
NumberFormatException
e
)
{
return
0
;
}
}
}
}
jfb-recruit/src/main/java/com/jfb/recruit/util/Excelutils/RecruitImportExcel.java
0 → 100644
浏览文件 @
e355fce1
package
com
.
jfb
.
recruit
.
util
.
Excelutils
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
lombok.Data
;
/**
* @ClassName : RecruitImportExcel
* @Description : 批量导入岗位(Excel),列顺序:企业名、企业信息、岗位名、岗位的信息、最低工资、最高工资
* @Author : wml
* @Date: 2026-09-21
*/
@Data
public
class
RecruitImportExcel
{
// ExcelProperty:指定列名,index指定列索引(0开始)
@ExcelProperty
(
value
=
"企业名"
,
index
=
0
)
private
String
name
;
@ExcelProperty
(
value
=
"企业信息"
,
index
=
1
)
private
String
companyInfo
;
@ExcelProperty
(
value
=
"岗位名"
,
index
=
2
)
private
String
jobName
;
@ExcelProperty
(
value
=
"岗位的信息"
,
index
=
3
)
private
String
jobInfo
;
@ExcelProperty
(
value
=
"最低工资"
,
index
=
4
)
private
String
salaryMin
;
@ExcelProperty
(
value
=
"最高工资"
,
index
=
5
)
private
String
salaryMax
;
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论