diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppCommonController.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppCommonController.java index 4afc17e..ed9bfdd 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppCommonController.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppCommonController.java @@ -1,6 +1,5 @@ package com.ruoyi.cms.controller.app; -import com.ruoyi.cms.domain.AppUser; import com.ruoyi.cms.domain.BussinessDictData; import com.ruoyi.cms.domain.CommercialArea; import com.ruoyi.cms.domain.SubwayLine; @@ -8,22 +7,17 @@ import com.ruoyi.cms.service.*; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.TreeSelect; -import com.ruoyi.common.core.domain.entity.JobTitle; -import com.ruoyi.common.core.domain.entity.SysDictData; -import com.ruoyi.common.core.page.TableDataInfo; -import com.ruoyi.common.utils.StringUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; -import java.util.ArrayList; import java.util.List; import java.util.Map; -import static com.ruoyi.common.utils.PageUtils.startPage; - @RestController @RequestMapping("/app/common") @Api(tags = "移动端:常用参数查询") @@ -73,6 +67,7 @@ public class AppCommonController extends BaseController { List dictData = iBussinessDictTypeService.selectDictDataByType(dictType); return success(dictData); } + @ApiOperation("字段标准") @GetMapping("/standar/filed") public AjaxResult standarFiled() { diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppCompanyController.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppCompanyController.java index ec64e90..7c86c14 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppCompanyController.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppCompanyController.java @@ -1,7 +1,6 @@ package com.ruoyi.cms.controller.app; -import com.ruoyi.cms.domain.BussinessDictData; import com.ruoyi.cms.domain.Company; import com.ruoyi.cms.domain.CompanyCard; import com.ruoyi.cms.domain.query.LabelQuery; @@ -9,16 +8,14 @@ import com.ruoyi.cms.mapper.CompanyCardMapper; import com.ruoyi.cms.service.ICompanyCardService; import com.ruoyi.cms.service.ICompanyCollectionService; import com.ruoyi.cms.service.ICompanyService; -import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.annotation.BussinessLog; 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.core.page.TableSupport; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import java.util.List; @@ -46,7 +43,6 @@ public class AppCompanyController extends BaseController * 获取公司详细信息 */ @ApiOperation("获取公司详细信息") - @PreAuthorize("@ss.hasPermi('bussiness:company:query')") @GetMapping(value = "/{companyId}") public AjaxResult getInfo(@PathVariable("companyId") Long companyId) { @@ -55,7 +51,7 @@ public class AppCompanyController extends BaseController /** * 用户收藏公司 */ - @Log(title = "用户收藏公司") + @BussinessLog(title = "用户收藏公司") @PostMapping("/collection/{companyId}") @ApiOperation("用户收藏公司") public AjaxResult companyCollection(@PathVariable("companyId") Long companyId) @@ -66,7 +62,7 @@ public class AppCompanyController extends BaseController /** * 用户取消收藏公司 */ - @Log(title = "用户取消收藏公司") + @BussinessLog(title = "用户取消收藏公司") @DeleteMapping("/collection/{companyId}") @ApiOperation("用户取消收藏公司") public AjaxResult companyCancel(@PathVariable("companyId") Long companyId) @@ -76,7 +72,6 @@ public class AppCompanyController extends BaseController /** * 公司下的岗位 */ - @Log(title = "公司下的岗位") @GetMapping("/job/{companyId}") @ApiOperation("公司下的岗位") public TableDataInfo jobCompany(@ApiParam("公司id") @PathVariable Long companyId) @@ -84,7 +79,6 @@ public class AppCompanyController extends BaseController startPage(); return getDataTable(companyCollectionService.jobCompany(companyId)); } - @Log(title = "查看企业卡片") @GetMapping("/card") @ApiOperation("查看企业卡片") public TableDataInfo card() @@ -92,7 +86,7 @@ public class AppCompanyController extends BaseController startPage(); return getDataTable(companyCardService.cardApp()); } - @Log(title = "收藏企业卡片") + @BussinessLog(title = "收藏企业卡片") @PutMapping("/card/collection/{companyCardId}") @ApiOperation("收藏企业卡片") public AjaxResult cardCollection(@PathVariable Long companyCardId) @@ -100,7 +94,7 @@ public class AppCompanyController extends BaseController companyCardService.cardCollection(companyCardId); return success(); } - @Log(title = "取消收藏企业卡片") + @BussinessLog(title = "取消收藏企业卡片") @DeleteMapping("/card/collection/{companyCardId}") @ApiOperation("取消收藏公司卡片") public AjaxResult cardCancel(@PathVariable Long companyCardId) @@ -108,7 +102,6 @@ public class AppCompanyController extends BaseController companyCardService.cardCancel(companyCardId); return success(); } - @Log(title = "公司招聘的岗位数量") @GetMapping("/count/{companyId}") @ApiOperation("公司招聘的岗位数量") public AjaxResult count(@PathVariable Long companyId) @@ -116,7 +109,6 @@ public class AppCompanyController extends BaseController Integer count = companyService.count(companyId); return success(count); } - @Log(title = "公司标签下的公司") @GetMapping("/label") @ApiOperation("公司标签下的公司") public TableDataInfo label(LabelQuery labelQuery) @@ -126,14 +118,5 @@ public class AppCompanyController extends BaseController List companyList = companyService.label(companyCard,labelQuery); return getDataTable(companyList); } - @GetMapping("/importLabel500") - public void importLabel() - { - companyService.importLabel(); - } - @GetMapping("/importLabelBank") - public void importLabelBank() - { - companyService.importLabelBank(); - } + } diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppFairController.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppFairController.java index b7040bd..8bfad01 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppFairController.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppFairController.java @@ -4,7 +4,7 @@ package com.ruoyi.cms.controller.app; import com.ruoyi.cms.domain.JobFair; import com.ruoyi.cms.service.IFairCollectionService; import com.ruoyi.cms.service.IJobFairService; -import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.annotation.BussinessLog; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; @@ -33,7 +33,7 @@ public class AppFairController extends BaseController /** * 招聘会列表 */ - @Log(title = "招聘会列表") + @BussinessLog(title = "招聘会列表") @GetMapping public TableDataInfo list(JobFair jobFair) { @@ -45,7 +45,7 @@ public class AppFairController extends BaseController /** * 招聘会详情 */ - @Log(title = "招聘会详情") + @BussinessLog(title = "招聘会详情") @GetMapping("/{fairId}") public AjaxResult appDetail(@ApiParam("招聘会id") @PathVariable Long fairId) { @@ -55,7 +55,7 @@ public class AppFairController extends BaseController /** * 用户收藏招聘会 */ - @Log(title = "用户收藏招聘会") + @BussinessLog(title = "用户收藏招聘会") @PostMapping("/collection/{fairId}") public AjaxResult companyCollection(@ApiParam("招聘会id") @PathVariable Long fairId) { @@ -65,7 +65,7 @@ public class AppFairController extends BaseController /** * 用户取消收藏招聘会 */ - @Log(title = "用户取消收藏招聘会") + @BussinessLog(title = "用户取消收藏招聘会") @DeleteMapping("/collection/{fairId}") public AjaxResult companyCancel(@ApiParam("招聘会id") @PathVariable Long fairId) { diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppFileController.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppFileController.java index 44e0b35..f05317c 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppFileController.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppFileController.java @@ -1,6 +1,7 @@ package com.ruoyi.cms.controller.app; import com.ruoyi.cms.service.IFileService; +import com.ruoyi.common.annotation.BussinessLog; import com.ruoyi.common.core.domain.AjaxResult; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -14,6 +15,7 @@ import org.springframework.web.multipart.MultipartFile; public class AppFileController { @Autowired private IFileService fileService; + @BussinessLog(title = "上传文件") @PostMapping("/upload") public AjaxResult uploadFile(@RequestParam("file") MultipartFile file, @RequestParam(value = "bussinessId",required = false) Long bussinessId) { return fileService.uploadFile(file,bussinessId); diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppJobController.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppJobController.java index 26f9733..d7b46a0 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppJobController.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppJobController.java @@ -8,6 +8,7 @@ import com.ruoyi.cms.domain.vo.RadarChart; import com.ruoyi.cms.service.IESJobSearchService; import com.ruoyi.cms.service.IJobCollectionService; import com.ruoyi.cms.service.IJobService; +import com.ruoyi.common.annotation.BussinessLog; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; @@ -18,8 +19,9 @@ import io.swagger.annotations.ApiParam; import org.dromara.easyes.core.biz.EsPageInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import javax.servlet.http.HttpServletRequest; -import java.util.*; + +import java.util.List; +import java.util.Random; /** * 岗位Controller @@ -39,37 +41,28 @@ public class AppJobController extends BaseController @Autowired private IESJobSearchService esJobSearchService; - private Calendar calendar = Calendar.getInstance(); - private Date date = new Date(); - { - calendar.set(Calendar.YEAR, 2025); // 设置年份 - calendar.set(Calendar.MONTH, Calendar.JULY); // 设置月份(7月) - calendar.set(Calendar.DAY_OF_MONTH, 12); // 设置日期 - date = calendar.getTime(); // 转换为Date对象 -} - /** * 查询岗位列表 */ @ApiOperation("查询岗位列表") @GetMapping("/list") - public TableDataInfo list(ESJobSearch job, HttpServletRequest request) + public TableDataInfo list(ESJobSearch job) { - // 打印请求参数 - System.out.println("Request Parameters:"); - request.getParameterMap().forEach((key, value) -> { - System.out.println(key + " = " + String.join(", ", value)); - }); - // 打印请求头 - System.out.println("Request Headers:"); - Enumeration headerNames = request.getHeaderNames(); - Iterator iterator = Collections.list(headerNames).iterator(); - iterator.forEachRemaining(headerName -> { - System.out.println(headerName + " = " + request.getHeader(headerName)); - }); EsPageInfo list = jobService.appList(job); - return getTableDataInfo(list); + return getTableDataInfo2(list,job); } + + private TableDataInfo getTableDataInfo2(EsPageInfo list, ESJobSearch job) { + long total = list.getTotal(); + TableDataInfo rspData = new TableDataInfo(); + rspData.setCode(200); + rspData.setRows(list.getList()); + rspData.setTotal(total > 200 ? 200 : total); + job.setCompany(null); + rspData.setData(job); + return rspData; + } + /** * 获取5条推荐岗位 */ @@ -78,12 +71,9 @@ public class AppJobController extends BaseController public AjaxResult recommend(ESJobSearch esJobSearch) { List jobList = jobService.recommend(esJobSearch); - for (ESJobDocument esJobDocument:jobList){ - esJobDocument.setPostingDate(date); - } return success(jobList); } - @ApiOperation("获取littleVideo") + @ApiOperation("获取短视频") @GetMapping("/littleVideo") public AjaxResult littleVideo(ESJobSearch esJobSearch) { @@ -91,21 +81,13 @@ public class AppJobController extends BaseController return success(jobList); } - @ApiOperation("获取littleVideo") + @ApiOperation("随机获取短视频") @GetMapping("/littleVideo/random") public AjaxResult littleVideo(@RequestParam(required = true) String uuid,@RequestParam(required = false) Integer count,@RequestParam(required = false) String jobTitle) { List jobList = jobService.littleVideoRandom(uuid,count,jobTitle); return success(jobList); } - /** - * 获取5条推荐岗位 - */ - @GetMapping("/updateLon") - public void updateLon() - { - jobService.updateLon(); - } /** * 附件工作 */ @@ -115,9 +97,6 @@ public class AppJobController extends BaseController { EsPageInfo list = esJobSearchService.nearJob(jobQuery); List jobList = list.getList(); - for (ESJobDocument esJobDocument:jobList){ - esJobDocument.setPostingDate(date); - } list.setList(jobList); return getTableDataInfo(list); } @@ -130,9 +109,6 @@ public class AppJobController extends BaseController { EsPageInfo list = jobService.countyJobList(job); List jobList = list.getList(); - for (ESJobDocument esJobDocument:jobList){ - esJobDocument.setPostingDate(date); - } list.setList(jobList); return getTableDataInfo(list); } @@ -145,9 +121,6 @@ public class AppJobController extends BaseController { EsPageInfo list = jobService.subway(jobQuery); List jobList = list.getList(); - for (ESJobDocument esJobDocument:jobList){ - esJobDocument.setPostingDate(date); - } list.setList(jobList); return getTableDataInfo(list); } @@ -161,9 +134,6 @@ public class AppJobController extends BaseController { EsPageInfo list = jobService.commercialArea(jobQuery); List jobList = list.getList(); - for (ESJobDocument esJobDocument:jobList){ - esJobDocument.setPostingDate(date); - } list.setList(jobList); return getTableDataInfo(list); } @@ -175,14 +145,13 @@ public class AppJobController extends BaseController public AjaxResult getInfo(@PathVariable("jobId") Long jobId) { Job job = jobService.selectJobByJobIdApp(jobId); - job.setPostingDate(date); return success(job); } /** * 用户收藏岗位 */ - @Log(title = "用户收藏岗位") + @BussinessLog(title = "用户收藏岗位") @PostMapping("/collection/{jobId}") @ApiOperation("用户收藏") public AjaxResult jobCollection(@ApiParam("岗位id") @PathVariable Long jobId) @@ -193,7 +162,7 @@ public class AppJobController extends BaseController /** * 用户取消收藏岗位 */ - @Log(title = "用户取消收藏岗位") + @BussinessLog(title = "用户取消收藏岗位") @DeleteMapping("/collection/{jobId}") @ApiOperation("用户取消收藏岗位") public AjaxResult cancel(@ApiParam("岗位id") @PathVariable Long jobId) @@ -203,38 +172,17 @@ public class AppJobController extends BaseController /** * 用户申请岗位 */ - @Log(title = "用户申请岗位") + @BussinessLog(title = "用户申请岗位") @GetMapping("/apply/{jobId}") @ApiOperation("用户申请岗位") public AjaxResult apply(@ApiParam("岗位id") @PathVariable Long jobId) { return toAjax(jobCollectionService.apply(jobId)); } - @Log(title = "竞争力分析") @GetMapping("/competitiveness/{jobId}") @ApiOperation("竞争力分析") public AjaxResult competitiveness(@ApiParam("岗位id") @PathVariable Long jobId) { - // Generate random values for the response - Random random = new Random(); - - // Build radar chart with random values between 60-95 - RadarChart radarChart = new RadarChart(); - radarChart.setAge(60 + random.nextInt(36)); // 60-95 - radarChart.setExperience(60 + random.nextInt(36)); - radarChart.setEducation(60 + random.nextInt(36)); - radarChart.setSkill(60 + random.nextInt(36)); - radarChart.setSalary(60 + random.nextInt(36)); - radarChart.setLocation(60 + random.nextInt(36)); - - // Build response with random values - CompetitivenessResponse response = new CompetitivenessResponse(); - response.setTotalApplicants(0); // Always 0 as requested - response.setMatchScore(60 + random.nextInt(41)); // 60-100 - response.setRank(1 + random.nextInt(10)); // 1-10 - response.setPercentile(random.nextInt(101)); // 0-100 - response.setRadarChart(radarChart); - - return success(response); + return success(jobCollectionService.competitiveness(jobId)); } private TableDataInfo getTableDataInfo(EsPageInfo result){ long total = result.getTotal(); @@ -244,45 +192,5 @@ public class AppJobController extends BaseController rspData.setTotal(total > 200 ? 200 : total); return rspData; } - @GetMapping("/import") - public AjaxResult importData() - { - jobService.importData(); - return success(); - } - @GetMapping("/importRow") - public AjaxResult importRow() - { - jobService.importRow(); - return success(); - } - @GetMapping("/update") - public AjaxResult update() - { - jobService.updateEs(); - return success(); - } - @PostMapping("/getWechatUrl") - public AjaxResult getWechatUrl(@RequestBody HashMap url) - { - String s = url.get("imgUrl"); - return AjaxResult.success(jobService.getWechatUrl(s)); - } - @PostMapping("/insert") - public AjaxResult insertTemp(@RequestBody Job job) - { - return AjaxResult.success(jobService.insertTemp(job)); - } - @ApiOperation("生成分享的html") - @GetMapping("/htmlGen/{id}") - public AjaxResult htmlGen(@PathVariable(required = true) Long id) - { - String result = jobService.htmlGen(id); - return AjaxResult.success(result); - } - @GetMapping("/fix") - public void fix() - { - jobService.fix(); - } + } diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppNoticeInfoController.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppNoticeInfoController.java index 55ed43a..6a913a3 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppNoticeInfoController.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppNoticeInfoController.java @@ -1,15 +1,12 @@ package com.ruoyi.cms.controller.app; -import com.ruoyi.cms.domain.AppUser; import com.ruoyi.cms.domain.Job; import com.ruoyi.cms.domain.Notice; -import com.ruoyi.cms.domain.vo.AppNoticeVO; import com.ruoyi.cms.service.IAppNoticeService; +import com.ruoyi.common.annotation.BussinessLog; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.page.PageDomain; import com.ruoyi.common.core.page.TableDataInfo; -import com.ruoyi.common.utils.SecurityUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -17,8 +14,6 @@ import org.springframework.web.bind.annotation.*; import java.util.List; -import static com.ruoyi.common.utils.PageUtils.startPage; - @RestController @RequestMapping("/app/notice") @Api(tags = "移动端:消息") @@ -43,6 +38,7 @@ public class AppNoticeInfoController extends BaseController { } @ApiOperation("系统通知已读") @PostMapping("/read/sysNotice") + @BussinessLog(title = "系统通知标记已读") public AjaxResult sysNotice(@RequestParam String id) { appNoticeService.sysNotice(id); @@ -50,6 +46,7 @@ public class AppNoticeInfoController extends BaseController { } @ApiOperation("岗位推荐、招聘会已读") @PostMapping("/read") + @BussinessLog(title = "岗位推荐、招聘会已读标记已读") public AjaxResult read(@RequestParam String id) { appNoticeService.read(id); diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppScriptController.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppScriptController.java new file mode 100644 index 0000000..5aaf430 --- /dev/null +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppScriptController.java @@ -0,0 +1,73 @@ +package com.ruoyi.cms.controller.app; + +import com.ruoyi.cms.domain.ESJobDocument; +import com.ruoyi.cms.domain.Job; +import com.ruoyi.cms.domain.query.ESJobSearch; +import com.ruoyi.cms.domain.vo.CompetitivenessResponse; +import com.ruoyi.cms.domain.vo.RadarChart; +import com.ruoyi.cms.service.ICompanyService; +import com.ruoyi.cms.service.IESJobSearchService; +import com.ruoyi.cms.service.IJobCollectionService; +import com.ruoyi.cms.service.IJobService; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.dromara.easyes.core.biz.EsPageInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Random; + +/** + * 岗位Controller + * + * @author lishundong + * @date 2024-09-03 + */ +@RestController +@RequestMapping("/app/script") +@Api(tags = "移动端:脚本") +public class AppScriptController extends BaseController +{ + @Autowired + private IJobService jobService; + @Autowired + private ICompanyService companyService; + //更新经纬度 + @GetMapping("/updateLon") + public void updateLon() + { + jobService.updateLon(); + } + //导入数据 + @GetMapping("/import") + public AjaxResult importData() + { + jobService.importData(); + return success(); + } + //导入原始数据 + @GetMapping("/importRow") + public AjaxResult importRow(@RequestParam String path) + { + jobService.importRow(path); + return success(); + } + // 导入500强 + @GetMapping("/importLabel500") + public void importLabel() + { + companyService.importLabel(); + } + // 随机导入3个公司到银行标签 + @GetMapping("/importLabelBank") + public void importLabelBank() + { + companyService.importLabelBank(); + } +} diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppSpeechController.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppSpeechController.java new file mode 100644 index 0000000..d1f9776 --- /dev/null +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppSpeechController.java @@ -0,0 +1,37 @@ +package com.ruoyi.cms.controller.app; + +import com.alibaba.nls.client.AccessToken; +import com.ruoyi.cms.handler.SpeechRecognizerAI; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * app语音Controller + * + * @author lishundong + * @date 2024-09-03 + */ +@RestController +@RequestMapping("/app/speech") +@Api(tags = "移动端:用户相关") +public class AppSpeechController extends BaseController +{ + private String appKey = "4lFYn2yPsQymwGu8"; + private String id = "LTAI5t9hhSqdDHqwH3RjgyYj"; + private String secret = "ni5aW3vxrWouMwcGqJPfh9Uu56PBuv"; + private String url = System.getenv().getOrDefault("NLS_GATEWAY_URL", "wss://nls-gateway-cn-shanghai.aliyuncs.com/ws/v1"); + @ApiOperation("统计") + @GetMapping("/getToken") + public AjaxResult getToken() + { + SpeechRecognizerAI recognizerDemo = new SpeechRecognizerAI(appKey, id, secret, url); + AccessToken accessToken = recognizerDemo.getAccessToken(); + String token = "wss://nls-gateway.cn-shanghai.aliyuncs.com/ws/v1?appkey="+appKey+"&token="+accessToken.getToken(); + return AjaxResult.success(token); + } +} diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppUserController.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppUserController.java index 9a85baf..d8ed998 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppUserController.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/AppUserController.java @@ -6,6 +6,7 @@ import com.ruoyi.cms.domain.Job; import com.ruoyi.cms.domain.JobFair; import com.ruoyi.cms.domain.query.MineJobQuery; import com.ruoyi.cms.service.*; +import com.ruoyi.common.annotation.BussinessLog; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; @@ -46,6 +47,7 @@ public class AppUserController extends BaseController */ @ApiOperation("保存简历") @PostMapping("/resume") + @BussinessLog(title = "保存简历") public AjaxResult saveResume(@RequestBody AppUser appUser) { appUser.setUserId(SecurityUtils.getUserId()); diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/cms/BussinessOperlogController.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/cms/BussinessOperlogController.java index a74eb71..ec89663 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/cms/BussinessOperlogController.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/cms/BussinessOperlogController.java @@ -24,7 +24,7 @@ import java.util.List; */ @RestController @RequestMapping("/cms/operlog") -@Api(tags = "后台:App用户日志") +@Api(tags = "后台:App用户操作日志") public class BussinessOperlogController extends BaseController { @Autowired diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/cms/CmsJobController.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/cms/CmsJobController.java index c8c4b84..5ca9504 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/cms/CmsJobController.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/cms/CmsJobController.java @@ -121,9 +121,9 @@ public class CmsJobController extends BaseController return success(); } @GetMapping("/importRow") - public AjaxResult importRow() + public AjaxResult importRow(@RequestParam String path) { - jobService.importRow(); + jobService.importRow(path); return success(); } } diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/CommercialArea.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/CommercialArea.java index c4ae16d..2d1b07d 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/CommercialArea.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/CommercialArea.java @@ -42,7 +42,9 @@ public class CommercialArea extends BaseEntity @Excel(name = "经度") @ApiModelProperty("经度") private BigDecimal longitude; - + /** 地址 */ + @Excel(name = "地址") + @ApiModelProperty("地址") private String address; } diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/CompanyCard.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/CompanyCard.java index 29b0105..0d7869b 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/CompanyCard.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/CompanyCard.java @@ -46,5 +46,5 @@ public class CompanyCard extends BaseEntity private Integer status; private Integer cardOrder; private String description; - private String icon; + } \ No newline at end of file diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/ESJobDocument.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/ESJobDocument.java index 0c9d667..d80132d 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/ESJobDocument.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/ESJobDocument.java @@ -16,7 +16,7 @@ import java.util.Date; /** * 全文索引 ES数据模型 **/ -@IndexName("job_document_gt") +@IndexName("job_document") @Data public class ESJobDocument { diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/query/ESJobSearch.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/query/ESJobSearch.java index 73a28ee..034630c 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/query/ESJobSearch.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/query/ESJobSearch.java @@ -51,4 +51,6 @@ public class ESJobSearch extends Job private String salaryDictCode; private String scaleDictCode; + private String area; + } diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/handler/SpeechRecognitionWebSocketHandler.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/handler/SpeechRecognitionWebSocketHandler.java index 5b146bd..398afd6 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/handler/SpeechRecognitionWebSocketHandler.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/handler/SpeechRecognitionWebSocketHandler.java @@ -17,9 +17,9 @@ public class SpeechRecognitionWebSocketHandler { public SpeechRecognitionWebSocketHandler() { // 初始化语音识别器 - String appKey = "LuvNcrddU3PH8Tau"; - String id = "LTAI5tRBahK93vPNF1JDVEPA"; - String secret = "x95OWb4cV6ccQVtbEJ2Gxm2Uwl2thJ"; + String appKey = "4lFYn2yPsQymwGu8"; + String id = "LTAI5t9hhSqdDHqwH3RjgyYj"; + String secret = "ni5aW3vxrWouMwcGqJPfh9Uu56PBuv"; String url = System.getenv().getOrDefault("NLS_GATEWAY_URL", "wss://nls-gateway-cn-shanghai.aliyuncs.com/ws/v1"); recognizerDemo = new SpeechRecognizerAI(appKey, id, secret, url); } @@ -44,6 +44,7 @@ public class SpeechRecognitionWebSocketHandler { recognizerDemo.processStream(session, new ByteArrayInputStream(audioData), 16000); } + /** * 连接关闭调用的方法 */ diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/handler/SpeechRecognizerAI.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/handler/SpeechRecognizerAI.java index f0f33ab..17b1203 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/handler/SpeechRecognizerAI.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/handler/SpeechRecognizerAI.java @@ -7,23 +7,24 @@ import com.alibaba.nls.client.protocol.SampleRateEnum; import com.alibaba.nls.client.protocol.asr.SpeechRecognizer; import com.alibaba.nls.client.protocol.asr.SpeechRecognizerListener; import com.alibaba.nls.client.protocol.asr.SpeechRecognizerResponse; +import lombok.Data; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.websocket.Session; import java.io.IOException; import java.io.InputStream; - +@Data public class SpeechRecognizerAI { private static final Logger logger = LoggerFactory.getLogger(SpeechRecognizerAI.class); private String appKey; private NlsClient client; - + private AccessToken accessToken; public SpeechRecognizerAI(String appKey, String id, String secret, String url) { this.appKey = appKey; // 获取 AccessToken - AccessToken accessToken = new AccessToken(id, secret); + accessToken = new AccessToken(id, secret); try { accessToken.apply(); // 申请 Token logger.info("Token: {}, Expire Time: {}", accessToken.getToken(), accessToken.getExpireTime()); @@ -114,4 +115,28 @@ public class SpeechRecognizerAI { client.shutdown(); } } + /** + * 获取当前有效的 AccessToken + * + * @param id 阿里云 AccessKey ID + * @param secret 阿里云 AccessKey Secret + * @return 返回申请到的 AccessToken 字符串,失败时返回 null + */ + public static String getAccessToken(String id, String secret) { + try { + AccessToken accessToken = new AccessToken(id, secret); + accessToken.apply(); // 申请 token + + if (accessToken.getToken() != null) { + logger.info("成功获取 Token: {}, 过期时间: {}", accessToken.getToken(), accessToken.getExpireTime()); + return accessToken.getToken(); + } else { + logger.error("get token fail:"+accessToken.getToken()); + return null; + } + } catch (IOException e) { + logger.error("申请 Token 时发生网络错误: {}", e.getMessage()); + return null; + } + } } \ No newline at end of file diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/mapper/AppUserMapper.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/mapper/AppUserMapper.java index 5b0dba2..29fcbbf 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/mapper/AppUserMapper.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/mapper/AppUserMapper.java @@ -18,4 +18,6 @@ public interface AppUserMapper extends BaseMapper * @return APP用户集合 */ public List selectAppUserList(AppUser appUser); + + List selectByJobId(Long jobId); } diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/mapper/JobApplyMapper.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/mapper/JobApplyMapper.java index 6ead1dd..9c662f9 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/mapper/JobApplyMapper.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/mapper/JobApplyMapper.java @@ -22,7 +22,7 @@ public interface JobApplyMapper extends BaseMapper */ public List selectJobApplyList(JobApply jobApply); - //todo + List applyJob(Long userId); List candidates(Long jobId); diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/IJobCollectionService.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/IJobCollectionService.java index 3b5921d..4dfda81 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/IJobCollectionService.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/IJobCollectionService.java @@ -4,6 +4,7 @@ import java.util.List; import com.ruoyi.cms.domain.Job; import com.ruoyi.cms.domain.JobCollection; +import com.ruoyi.cms.domain.vo.CompetitivenessResponse; /** * 用户岗位收藏Service接口 @@ -70,5 +71,5 @@ public interface IJobCollectionService List collectionJob(); - String competitiveness(Long jobId); + CompetitivenessResponse competitiveness(Long jobId); } diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/IJobService.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/IJobService.java index 07a778a..3e7180f 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/IJobService.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/IJobService.java @@ -78,7 +78,7 @@ public interface IJobService Job selectJobByJobIdApp(Long jobId); - void importRow(); + void importRow(String path); List candidates(Long jobId); @@ -88,13 +88,4 @@ public interface IJobService List littleVideoRandom(String uuid, Integer count,String jobTitle); - void updateEs(); - - AppWechatEntity getWechatUrl(String wechatUrl); - - String insertTemp(Job job); - - String htmlGen(Long id); - - void fix(); } diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/AppReviewJobServiceImpl.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/AppReviewJobServiceImpl.java index 5ecd53e..56c5ff7 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/AppReviewJobServiceImpl.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/AppReviewJobServiceImpl.java @@ -1,25 +1,20 @@ package com.ruoyi.cms.service.impl; -import java.text.SimpleDateFormat; -import java.util.List; -import java.util.Arrays; -import java.util.stream.Collectors; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.cms.domain.AppReviewJob; -import com.ruoyi.cms.domain.Company; import com.ruoyi.cms.domain.Job; import com.ruoyi.cms.domain.query.MineJobQuery; import com.ruoyi.cms.mapper.AppReviewJobMapper; import com.ruoyi.cms.service.IAppReviewJobService; -import com.ruoyi.cms.service.IJobService; import com.ruoyi.common.utils.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + /** * 用户岗位浏览记录Service业务层处理 @@ -32,8 +27,7 @@ public class AppReviewJobServiceImpl extends ServiceImpl selectTextListExceptJobId(ESJobSearch esJobSearch, List jobIds) { + ESJobSearch newSearch = new ESJobSearch(); + BeanUtils.copyProperties(esJobSearch,newSearch); //查询 if(SecurityUtils.isLogin()){ AppUser appUser = appUserService.selectAppUserByUserId(SecurityUtils.getUserId()); - if(!ListUtil.isEmptyOrNull(appUser.getJobTitle())&&!StringUtil.isEmptyOrNull(esJobSearch.getJobTitle())){ - esJobSearch.setJobTitle(String.join(",", appUser.getJobTitle())); + if(!ListUtil.isEmptyOrNull(appUser.getJobTitle())){ + List jobTitle = appUser.getJobTitle(); + newSearch.setJobTitle(String.join(",", jobTitle)); } - if(!StringUtil.isEmptyOrNull(appUser.getEducation())&&!StringUtil.isEmptyOrNull(esJobSearch.getEducation())){ - esJobSearch.setEducation(appUser.getEducation()); + if(!StringUtil.isEmptyOrNull(esJobSearch.getJobTitle())){ + newSearch.setJobTitle(esJobSearch.getJobTitle()); } + if(!StringUtil.isEmptyOrNull(appUser.getEducation())){ + newSearch.setEducation(appUser.getEducation()); + } + if(!StringUtil.isEmptyOrNull(esJobSearch.getEducation())){ + newSearch.setEducation(esJobSearch.getEducation()); + } + if(!StringUtil.isEmptyOrNull(appUser.getArea())){ - esJobSearch.setJobLocationAreaCode(Integer.valueOf(appUser.getArea())); + newSearch.setArea(appUser.getArea()); } - if(!StringUtil.isEmptyOrNull(appUser.getExperience())&&!StringUtil.isEmptyOrNull(esJobSearch.getExperience())){ - esJobSearch.setExperience(appUser.getExperience()); + if(!StringUtil.isEmptyOrNull(esJobSearch.getArea())){ + newSearch.setArea(esJobSearch.getArea()); + } + if(!StringUtil.isEmptyOrNull(appUser.getExperience())){ + newSearch.setExperience(appUser.getExperience()); + } + if(!StringUtil.isEmptyOrNull(esJobSearch.getExperience())){ + newSearch.setExperience(esJobSearch.getExperience()); } if(!StringUtil.isEmptyOrNull(appUser.getSalaryMax())){ - esJobSearch.setMaxSalary(Long.valueOf(appUser.getSalaryMax())); + newSearch.setMaxSalary(Long.valueOf(appUser.getSalaryMax())); } if(!StringUtil.isEmptyOrNull(appUser.getSalaryMin())){ - esJobSearch.setMaxSalary(Long.valueOf(appUser.getSalaryMin())); + newSearch.setMinSalary(Long.valueOf(appUser.getSalaryMin())); } } - LambdaEsQueryWrapper wrapper = getWrapper(esJobSearch); - if(!ListUtil.isListEmptyOrNull(jobIds)){ - wrapper.in(ESJobDocument::getJobId, jobIds); - } + LambdaEsQueryWrapper wrapper = getWrapper(newSearch,jobIds); + //todo 暂时 wrapper.limit(esJobSearch.getPageSize()); - wrapper.orderByDesc(ESJobDocument::getCompanyId); - return esJobDocumentMapper.selectList(wrapper); + List esJobDocuments = esJobDocumentMapper.selectList(wrapper); + + if (esJobDocuments.size() < esJobSearch.getPageSize()) { + // 定义要逐步放宽的搜索条件字段 + List relaxConditions = new ArrayList<>(); + relaxConditions.add(() -> newSearch.setArea(null)); + relaxConditions.add(() -> newSearch.setExperience(null)); + relaxConditions.add(() -> newSearch.setMaxSalary(null)); + relaxConditions.add(() -> newSearch.setMinSalary(null)); + relaxConditions.add(() -> newSearch.setEducation(null)); + relaxConditions.add(()-> newSearch.setJobTitle(null)); + // 保存所有查询到的文档 + List allDocuments = new ArrayList<>(esJobDocuments); + + // 记录已经放宽的条件数量 + int relaxedConditions = 0; + + // 继续放宽条件直到满足分页或所有条件都已放宽 + while (allDocuments.size() < esJobSearch.getPageSize() + && relaxedConditions < relaxConditions.size()) { + // 放宽下一个条件 + relaxConditions.get(relaxedConditions).run(); + relaxedConditions++; + + // 查询新增的文档(不包含之前已经查询到的) + wrapper = getWrapper(newSearch, jobIds); + wrapper.limit(esJobSearch.getPageSize() - allDocuments.size()); + if (!allDocuments.isEmpty()) { + // 排除已经查询到的文档ID + Set existingIds = allDocuments.stream() + .map(ESJobDocument::getId) + .collect(Collectors.toSet()); + wrapper.not().in(ESJobDocument::getId, existingIds); + } + + List newDocuments = esJobDocumentMapper.selectList(wrapper); + allDocuments.addAll(newDocuments); + } + + // 如果总数超过分页大小,截取所需数量 + if (allDocuments.size() > esJobSearch.getPageSize()) { + esJobDocuments = allDocuments.subList(0, esJobSearch.getPageSize()); + } else { + esJobDocuments = allDocuments; + } + } + + return esJobDocuments; } @@ -221,7 +281,7 @@ public class ESJobSearchImpl implements IESJobSearchService public EsPageInfo nearJob(ESJobSearch jobQuery) { Integer pageNum = jobQuery.getCurrent(); Integer pageSize = jobQuery.getPageSize(); - LambdaEsQueryWrapper wrapper = getWrapper(jobQuery); + LambdaEsQueryWrapper wrapper = getWrapper(jobQuery,null); EsPageInfo esJobDocumentEsPageInfo = esJobDocumentMapper.pageQuery(wrapper, pageNum, pageSize); return esJobDocumentEsPageInfo; } @@ -230,7 +290,7 @@ public class ESJobSearchImpl implements IESJobSearchService public EsPageInfo countyJobList(ESJobSearch jobQuery) { Integer pageNum = jobQuery.getCurrent(); Integer pageSize = jobQuery.getPageSize(); - LambdaEsQueryWrapper wrapper = getWrapper(jobQuery); + LambdaEsQueryWrapper wrapper = getWrapper(jobQuery, null); if(jobQuery.getCountyIds()!=null){ wrapper.and(x->x.in(ESJobDocument::getJobLocationAreaCode,jobQuery.getCountyIds())); } @@ -242,7 +302,7 @@ public class ESJobSearchImpl implements IESJobSearchService public EsPageInfo subway(ESJobSearch jobQuery) { Integer pageNum = jobQuery.getCurrent(); Integer pageSize = jobQuery.getPageSize(); - LambdaEsQueryWrapper wrapper = getWrapper(jobQuery); + LambdaEsQueryWrapper wrapper = getWrapper(jobQuery,null); EsPageInfo esJobDocumentEsPageInfo = esJobDocumentMapper.pageQuery(wrapper, pageNum, pageSize); return esJobDocumentEsPageInfo; } @@ -251,7 +311,7 @@ public class ESJobSearchImpl implements IESJobSearchService public EsPageInfo commercialArea(ESJobSearch jobQuery) { Integer pageNum = jobQuery.getCurrent(); Integer pageSize = jobQuery.getPageSize(); - LambdaEsQueryWrapper wrapper = getWrapper(jobQuery); + LambdaEsQueryWrapper wrapper = getWrapper(jobQuery,null); if(jobQuery.getLongitude()!=null){ wrapper.geoDistance(ESJobDocument::getLatAndLon,Double.valueOf(jobQuery.getRadius()), DistanceUnit.KILOMETERS,new GeoPoint(Double.parseDouble(jobQuery.getLatitude().toString()), Double.parseDouble(jobQuery.getLongitude().toString()))); } @@ -263,7 +323,6 @@ public class ESJobSearchImpl implements IESJobSearchService public List littleVideo(ESJobSearch esJobSearch) { LambdaEsQueryWrapper wrapper = new LambdaEsQueryWrapper<>(); wrapper.eq(ESJobDocument::getIsExplain, 1); - wrapper.orderByDesc(ESJobDocument::getIsExplain); wrapper.limit(esJobSearch.getPageSize()); return esJobDocumentMapper.selectList(wrapper); } @@ -297,29 +356,17 @@ public class ESJobSearchImpl implements IESJobSearchService return esJobDocumentMapper.selectList(wrapper); } - private LambdaEsQueryWrapper getWrapper(ESJobSearch esJobSearch){ - List searchList = new ArrayList<>(); - if(!StringUtil.isEmptyOrNull(esJobSearch.getJobTitle())){ - searchList.add(esJobSearch.getJobTitle()); - }else { - if(SecurityUtils.isLogin()){ - AppUser appUser = appUserService.selectAppUserByUserId(SecurityUtils.getUserId()); - List jobTitleList = appUser.getJobTitle(); - if(!jobTitleList.isEmpty()){ - searchList.addAll(jobTitleList); - } - } - } + private LambdaEsQueryWrapper getWrapper(ESJobSearch esJobSearch,List jobIds){ + LambdaEsQueryWrapper wrapper = new LambdaEsQueryWrapper<>(); - if (!searchList.isEmpty()) - { - for (String keyWords:searchList){ - wrapper.or(a -> a.like(ESJobDocument::getJobTitle, keyWords, 5.0f) - .or() - .like(ESJobDocument::getDescription, keyWords, 1.0f) + if(!StringUtil.isEmptyOrNull(esJobSearch.getJobTitle())){ + for (String keyWord:esJobSearch.getJobTitle().split(",")) { + wrapper.and(a -> a.match(ESJobDocument::getJobTitle, keyWord, 5.0f) ); } + } + if(esJobSearch.getLongitude()!=null){ wrapper.geoDistance(ESJobDocument::getLatAndLon,Double.valueOf(esJobSearch.getRadius()), DistanceUnit.KILOMETERS,new GeoPoint(Double.parseDouble(esJobSearch.getLatitude().toString()), Double.parseDouble(esJobSearch.getLongitude().toString()))); } @@ -344,6 +391,10 @@ public class ESJobSearchImpl implements IESJobSearchService Integer maxValue = StringUtil.findMaxValue(esJobSearch.getScale()); wrapper.and(x->x.le(ESJobDocument::getScale,maxValue)); } + if(!StringUtil.isEmptyOrNull(esJobSearch.getArea())){ + List integers = StringUtil.convertStringToIntegerList(esJobSearch.getArea()); + wrapper.and(x->x.in(ESJobDocument::getJobLocationAreaCode,integers)); + } if(Objects.nonNull(esJobSearch.getOrder())){ if(esJobSearch.getOrder()==1){ wrapper.orderByDesc(ESJobDocument::getIsHot); @@ -352,7 +403,9 @@ public class ESJobSearchImpl implements IESJobSearchService wrapper.orderByDesc(ESJobDocument::getPostingDate); } } - //TODO LIST + if(!ListUtil.isListEmptyOrNull(jobIds)){ + wrapper.not().in(ESJobDocument::getJobId, jobIds); + } return wrapper; } @@ -362,6 +415,13 @@ public class ESJobSearchImpl implements IESJobSearchService Integer pageNum = jobQuery.getCurrent(); Integer pageSize = jobQuery.getPageSize(); LambdaEsQueryWrapper wrapper = new LambdaEsQueryWrapper<>(); +// if(SecurityUtils.isLogin()){ +// AppUser appUser = appUserService.selectAppUserByUserId(SecurityUtils.getUserId()); +// if(!ListUtil.isEmptyOrNull(appUser.getJobTitle())){ +// List jobTitle = appUser.getJobTitle(); +// jobQuery.setJobTitle(String.join(",", jobTitle)); +// } +// } if(!StringUtil.isEmptyOrNull(jobQuery.getJobTitle())){ wrapper.and(a->a.match(ESJobDocument::getJobTitle,jobQuery.getJobTitle(),5.0f) .or() @@ -370,7 +430,10 @@ public class ESJobSearchImpl implements IESJobSearchService if(!StringUtil.isEmptyOrNull(jobQuery.getEducation())){ wrapper.and(a->a.le(ESJobDocument::getEducation,jobQuery.getEducation())); } - + if(!StringUtil.isEmptyOrNull(jobQuery.getArea())){ + List integers = StringUtil.convertStringToIntegerList(jobQuery.getArea()); + wrapper.and(x->x.in(ESJobDocument::getJobLocationAreaCode,integers)); + } if(!StringUtil.isEmptyOrNull(jobQuery.getExperience())){ wrapper.and(a->a.le(ESJobDocument::getExperience,jobQuery.getExperience())); } @@ -430,6 +493,7 @@ public class ESJobSearchImpl implements IESJobSearchService for (ESJobDocument esJobDocument : esJobDocuments) { Job job = new Job(); BeanUtils.copyProperties(esJobDocument,job); + job.setJobId(null); jobMapper.insert(job); } } diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/JobCollectionServiceImpl.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/JobCollectionServiceImpl.java index 36043db..3f33709 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/JobCollectionServiceImpl.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/JobCollectionServiceImpl.java @@ -1,21 +1,24 @@ package com.ruoyi.cms.service.impl; -import java.util.List; -import java.util.Arrays; +import java.time.LocalDate; +import java.time.Period; +import java.time.ZoneId; +import java.util.*; import java.util.stream.Collectors; import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.ruoyi.cms.domain.AppUser; -import com.ruoyi.cms.domain.Job; -import com.ruoyi.cms.domain.JobApply; +import com.ruoyi.cms.domain.*; +import com.ruoyi.cms.domain.vo.CompetitivenessResponse; +import com.ruoyi.cms.domain.vo.RadarChart; import com.ruoyi.cms.mapper.AppUserMapper; import com.ruoyi.cms.mapper.JobApplyMapper; +import com.ruoyi.cms.mapper.JobMapper; +import com.ruoyi.cms.service.IBussinessDictTypeService; import com.ruoyi.common.utils.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; import com.ruoyi.cms.mapper.JobCollectionMapper; -import com.ruoyi.cms.domain.JobCollection; import com.ruoyi.cms.service.IJobCollectionService; import org.springframework.transaction.annotation.Transactional; @@ -34,6 +37,10 @@ public class JobCollectionServiceImpl extends ServiceImpl appUsers = appUserMapper.selectByJobId(jobId); + Long applyCount = (long) appUsers.size(); + + if (appUsers.isEmpty()) { + // 没有人申请,返回默认值或0 + CompetitivenessResponse emptyResponse = new CompetitivenessResponse(); + emptyResponse.setTotalApplicants(0); + emptyResponse.setMatchScore(0); + emptyResponse.setRank(0); + emptyResponse.setPercentile(0); + RadarChart radarChart = new RadarChart(); + emptyResponse.setRadarChart(radarChart); + return emptyResponse; + } + + // ================== 数据字典映射(用于排序比较)================== + // 假设你有字典工具类,如 DictUtils.getSort("education", value) 返回排序值 + // 这里我们用 Map 模拟字典排序(越小要求越低) + // 获取字典数据 + List educationDict = iBussinessDictTypeService.selectDictDataByType("education"); + List experienceDict = iBussinessDictTypeService.selectDictDataByType("experience"); + + // 构建学历排序映射:dictLabel -> dictSort(越小要求越低) + Map educationRank = educationDict.stream() + .collect(Collectors.toMap( + BussinessDictData::getDictLabel, + data -> Math.toIntExact(data.getDictSort()), + (a, b) -> a // 若有重复 key,保留第一个 + )); + + Map experienceRank = experienceDict.stream() + .collect(Collectors.toMap( + BussinessDictData::getDictLabel, + data -> Math.toIntExact(data.getDictSort()), + (a, b) -> a + )); + + // ================== 提取岗位要求 ================== + Integer jobEducationRank = educationRank.getOrDefault(job.getEducation(), 999); + Integer jobExperienceRank = experienceRank.getOrDefault(job.getExperience(), 999); + Integer jobMinSalary = job.getMinSalary() != null ? job.getMinSalary().intValue() : 0; + String jobLocation = job.getJobLocation(); + + // ================== 聚合用户数据用于分析 ================== + List userScores = new ArrayList<>(); + + for (AppUser user : appUsers) { + int matchScore = 0; + int totalFactors = 6; // 年龄、经验、学历、技能(暂用期望岗位匹配)、薪资、地点 + + // 1. 学历匹配(越接近越好) + Integer userEduRank = educationRank.getOrDefault(user.getEducation(), 999); + if (userEduRank <= jobEducationRank) { + matchScore += 1; // 达标 + } else if (userEduRank == jobEducationRank + 1) { + matchScore += 0.5; // 略高也算匹配 + } + + // 2. 经验匹配 + Integer userExpRank = experienceRank.getOrDefault(user.getExperience(), 999); + if (userExpRank >= jobExperienceRank) { + matchScore += 1; // 满足经验要求 + } + + // 3. 薪资匹配(用户期望 <= 岗位最大薪资,且不低于最小太多) + Integer userMinSalary = parseSalary(user.getSalaryMin()); + if (userMinSalary != null && userMinSalary <= job.getMaxSalary()) { + if (userMinSalary >= job.getMinSalary()) { + matchScore += 1; + } else if (userMinSalary >= job.getMinSalary() * 0.8) { + matchScore += 0.5; + } + } + + // 4. 地点匹配 + if (user.getArea() != null && user.getArea().contains(jobLocation) || jobLocation.contains(user.getArea())) { + matchScore += 1; + } + + // 5. 年龄估算(从生日计算) + int userAge = getUserAge(user.getBirthDate()); + // 假设最佳年龄区间为 22-35,越接近越匹配 + if (userAge >= 22 && userAge <= 35) { + matchScore += 1; + } else if (userAge >= 18 && userAge <= 45) { + matchScore += 0.5; + } + + // 6. 技能/岗位匹配(简化:期望岗位是否包含该岗位关键词) + boolean jobMatch = user.getJobTitle() != null && + user.getJobTitle().stream().anyMatch(title -> title.contains(job.getJobTitle()) || job.getJobTitle().contains(title)); + if (jobMatch) { + matchScore += 1; + } + + // 匹配度:0-6 → 映射为 0-100 分 + int finalScore = (int) Math.round((matchScore / (double) totalFactors) * 100); + userScores.add(new UserCompetitiveness(user, finalScore)); + } + + // 按匹配度降序 + userScores.sort((a, b) -> Integer.compare(b.getScore(), a.getScore())); + + // ================== 计算雷达图数据(取平均值)================== + RadarChart radarChart = new RadarChart(); + + double avgAgeScore = userScores.stream().mapToInt(u -> getAgeScore(u.getUser().getBirthDate())).average().orElse(0); + double avgExperienceScore = userScores.stream().mapToInt(u -> getExperienceScore(u.getUser().getExperience(), job.getExperience(), experienceRank)).average().orElse(0); + double avgEducationScore = userScores.stream().mapToInt(u -> getEducationScore(u.getUser().getEducation(), job.getEducation(), educationRank)).average().orElse(0); + double avgSkillScore = userScores.stream().mapToInt(u -> getSkillScore(u.getUser(), job)).average().orElse(0); + double avgSalaryScore = userScores.stream().mapToInt(u -> getSalaryScore(u.getUser(), job)).average().orElse(0); + double avgLocationScore = userScores.stream().mapToInt(u -> getLocationScore(u.getUser(), job)).average().orElse(0); + + radarChart.setAge((int) avgAgeScore); + radarChart.setExperience((int) avgExperienceScore); + radarChart.setEducation((int) avgEducationScore); + radarChart.setSkill((int) avgSkillScore); + radarChart.setSalary((int) avgSalaryScore); + radarChart.setLocation((int) avgLocationScore); + + // ================== 返回响应 ================== + CompetitivenessResponse response = new CompetitivenessResponse(); + response.setTotalApplicants(Math.toIntExact(applyCount)); + + // Top 用户的匹配分 + int topMatchScore = userScores.get(0).getScore(); + response.setMatchScore(topMatchScore); + + // 排名(Top1) + response.setRank(1); + + // 百分位:top用户超过多少人?(100%) + response.setPercentile(100); + + response.setRadarChart(radarChart); + + return response; + } + private int getUserAge(Date birthDate) { + if (birthDate == null) return 0; + try { + LocalDate birth = birthDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + return Period.between(birth, LocalDate.now()).getYears(); + } catch (Exception e) { + return 0; + } + } + private int getEducationScore(String userEdu, String jobEdu, Map rankMap) { + if (userEdu == null || jobEdu == null) return 60; + Integer u = rankMap.getOrDefault(userEdu, 999); + Integer j = rankMap.getOrDefault(jobEdu, 999); + if (u <= j) return 90; + if (u == j + 1) return 75; + return 60; + } + private int getExperienceScore(String userExp, String jobExp, Map rankMap) { + if (userExp == null || jobExp == null) return 60; + Integer u = rankMap.getOrDefault(userExp, 999); + Integer j = rankMap.getOrDefault(jobExp, 999); + if (u >= j) return 90; + if (u >= j - 1) return 75; // 容忍略低一年 + return 60; + } + private int getSalaryScore(AppUser user, Job job) { + Integer min = parseSalary(user.getSalaryMin()); + if (min == null) return 60; + if (job.getMinSalary() == null || job.getMaxSalary() == null) return 60; + + long jobMin = job.getMinSalary(); + long jobMax = job.getMaxSalary(); + + if (min >= jobMin && min <= jobMax) return 90; + if (min >= jobMin * 0.8 && min <= jobMax * 1.2) return 75; + return 60; + } + private int getLocationScore(AppUser user, Job job) { + String area = user.getArea(); + String loc = job.getJobLocation(); + if (area != null && (area.contains(loc) || loc.contains(area))) return 90; + return 60; + } + private int getSkillScore(AppUser user, Job job) { + String jobTitle = job.getJobTitle(); + List userTitles = user.getJobTitle(); + if (jobTitle == null || userTitles == null || userTitles.isEmpty()) return 60; + + boolean match = userTitles.stream() + .anyMatch(title -> title != null && + (title.contains(jobTitle) || jobTitle.contains(title))); + return match ? 90 : 60; + } + private Integer parseSalary(String salaryStr) { + if (salaryStr == null || salaryStr.trim().isEmpty()) return null; + try { + // 提取第一个连续数字 + String numberStr = salaryStr.replaceAll("[^0-9]", ""); + return numberStr.isEmpty() ? null : Integer.parseInt(numberStr); + } catch (Exception e) { + return null; + } + } + private int getAgeScore(Date birthDate) { + int age = getUserAge(birthDate); + if (age == 0) return 60; // 无法获取年龄,默认低分 + if (age >= 22 && age <= 35) return 90; + if (age >= 18 && age <= 45) return 75; + return 60; + } + private static class UserCompetitiveness { + private final AppUser user; + private final int score; + + public UserCompetitiveness(AppUser user, int score) { + this.user = user; + this.score = score; + } + + public AppUser getUser() { + return user; + } + + public int getScore() { + return score; + } } } diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/JobServiceImpl.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/JobServiceImpl.java index 2fe3279..feafddc 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/JobServiceImpl.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/JobServiceImpl.java @@ -295,7 +295,6 @@ public class JobServiceImpl extends ServiceImpl implements IJobSe }else { jobList = cacheObject.toList(Long.class); } - //从kafka中消费 bert模型跑出来的结果 //从es中查询 List jobListResult = iesJobSearchService.selectTextListExceptJobId(esJobSearch,jobList); //存入当前session中查看的岗位 避免重复 todo 定时删除 key上保存用户信息 @@ -331,41 +330,34 @@ public class JobServiceImpl extends ServiceImpl implements IJobSe @Override public Job selectJobByJobIdApp(Long jobId) { - try { - Job job = new Job(); - ESJobDocument esJobDocument = iesJobSearchService.selectById(jobId); - BeanUtils.copyProperties(esJobDocument,job); + Job job = jobMapper.selectById(jobId); //查询公司信息 if(Objects.nonNull(job.getCompanyId())){ Company company = companyMapper.selectById(job.getCompanyId()); job.setCompany(company); } -// if(SecurityUtils.isLogin()){ -// //查询申请信息 -// Long applyCount = jobApplyMapper.selectCount(Wrappers.lambdaQuery().eq(JobApply::getJobId, jobId).eq(JobApply::getUserId, SecurityUtils.getUserId())); -// job.setIsApply(applyCount>0?1:0); -// //查询收藏信息 -// Long collectionCount = jobCollectionMapper.selectCount(Wrappers.lambdaQuery().eq(JobCollection::getJobId, jobId).eq(JobCollection::getUserId, SecurityUtils.getUserId())); -// job.setIsCollection(collectionCount>0?1:0); -// //todo asyn -// //保存浏览记录 -// List appReviewJobs = appReviewJobMapper.selectList(Wrappers.lambdaQuery().eq(AppReviewJob::getUserId, SecurityUtils.getUserId()).eq(AppReviewJob::getJobId, jobId)); -// //之前相同岗位的记录删除 保存最新的浏览记录 -// if(!appReviewJobs.isEmpty()){ -// appReviewJobMapper.deleteBatchIds(appReviewJobs.stream().map(AppReviewJob::getId).collect(Collectors.toList())); -// } -// AppReviewJob appReviewJob = new AppReviewJob(); -// appReviewJob.setUserId(SecurityUtils.getUserId()); -// appReviewJob.setReviewDate(new Date()); -// appReviewJob.setJobId(jobId); -// appReviewJobMapper.insert(appReviewJob); -// } - //浏览量+1 -// this.view(jobId); + if(SecurityUtils.isLogin()){ + //查询申请信息 + Long applyCount = jobApplyMapper.selectCount(Wrappers.lambdaQuery().eq(JobApply::getJobId, jobId).eq(JobApply::getUserId, SecurityUtils.getUserId())); + job.setIsApply(applyCount>0?1:0); + //查询收藏信息 + Long collectionCount = jobCollectionMapper.selectCount(Wrappers.lambdaQuery().eq(JobCollection::getJobId, jobId).eq(JobCollection::getUserId, SecurityUtils.getUserId())); + job.setIsCollection(collectionCount>0?1:0); + //todo asyn + //保存浏览记录 + List appReviewJobs = appReviewJobMapper.selectList(Wrappers.lambdaQuery().eq(AppReviewJob::getUserId, SecurityUtils.getUserId()).eq(AppReviewJob::getJobId, jobId)); + //之前相同岗位的记录删除 保存最新的浏览记录 + if(!appReviewJobs.isEmpty()){ + appReviewJobMapper.deleteBatchIds(appReviewJobs.stream().map(AppReviewJob::getId).collect(Collectors.toList())); + } + AppReviewJob appReviewJob = new AppReviewJob(); + appReviewJob.setUserId(SecurityUtils.getUserId()); + appReviewJob.setReviewDate(new Date()); + appReviewJob.setJobId(jobId); + appReviewJobMapper.insert(appReviewJob); + } + this.view(jobId); return job; - }catch (Exception e){ - return this.selectJobByJobId(jobId); - } } @@ -398,12 +390,9 @@ public class JobServiceImpl extends ServiceImpl implements IJobSe @Override public List littleVideo(ESJobSearch esJobSearch) { - return iesJobSearchService.littleVideo(esJobSearch); - } - @Override - public void updateEs() { - iesJobSearchService.updateEs(); + return iesJobSearchService.littleVideo(esJobSearch); + } @Override @@ -450,77 +439,12 @@ public class JobServiceImpl extends ServiceImpl implements IJobSe return esJobDocuments; } - // @Override -// public void importRow() { -// -// -// try { -// logger.info("开始导入Excel数据..."); -// -// // 读取Excel文件中的数据 -// List rowWorks = ExcelToObject.readExcelToObjects("D:\\QD\\青岛市近一个月数据.xlsx", RowWork.class); -// logger.info("从Excel中读取到 {} 条数据", rowWorks.size()); -// -// // 从数据库中获取已有的数据 -// List rowWorksInMysql = jobMapper.selectAllRowWork(); -// logger.info("从数据库中查询到 {} 条已有数据", rowWorksInMysql.size()); -// -// // 创建一个Set来存储数据库中已有的记录的唯一标识 -// Set existingRecords = new HashSet<>(); -// for (RowWork rowWork : rowWorksInMysql) { -// String uniqueKey = rowWork.getJobCategory() + "_" + rowWork.getAca112() + "_" + rowWork.getAcb202(); -// existingRecords.add(uniqueKey); -// } -// logger.info("已加载 {} 条唯一标识到内存", existingRecords.size()); -// -// // 创建一个列表来收集待插入的数据 -// List batchList = new ArrayList<>(); -// int batchSize = 100; // 每批次插入的数量 -// int totalInserted = 0; // 记录总共插入的数据量 -// -// // 遍历Excel中的数据,进行去重并收集待插入的数据 -// for (RowWork rowWork : rowWorks) { -// String uniqueKey = rowWork.getStd_class() + "_" + rowWork.getAca112() + "_" + rowWork.getAcb202(); -// if (!existingRecords.contains(uniqueKey)) { -// batchList.add(rowWork); // 添加到待插入列表 -// existingRecords.add(uniqueKey); // 添加到已存在集合,避免重复 -// // 当待插入列表达到批次大小时,执行批量插入 -// if (batchList.size() >= batchSize) { -// try { -// jobMapper.insertBatchRowWork(batchList); // 批量插入 -// totalInserted += batchList.size(); -// logger.info("成功插入 {} 条数据,当前总共插入 {} 条数据", batchList.size(), totalInserted); -// batchList.clear(); // 清空列表,准备下一批次 -// } catch (Exception e) { -// logger.error("批量插入失败: " + e.getMessage(), e); -// } -// } -// } -// } -// -// // 插入剩余的数据(如果不足100条) -// if (!batchList.isEmpty()) { -// try { -// jobMapper.insertBatchRowWork(batchList); // 插入剩余数据 -// totalInserted += batchList.size(); -// logger.info("成功插入剩余的 {} 条数据,当前总共插入 {} 条数据", batchList.size(), totalInserted); -// } catch (Exception e) { -// logger.error("批量插入剩余数据失败: " + e.getMessage(), e); -// } -// } -// -// logger.info("数据导入完成,总共插入 {} 条数据", totalInserted); -// } catch (Exception e) { -// logger.error("导入数据过程中发生异常: " + e.getMessage(), e); -// throw new RuntimeException(e); -// } -// } @Override - public void importRow() { + public void importRow(String path) { try { logger.info("开始导入Excel数据..."); // 读取Excel文件中的数据 - List rowWorks = ExcelToObject.readExcelToObjects("/home/lapuda/Desktop/import.xlsx", RowWork.class); + List rowWorks = ExcelToObject.readExcelToObjects(path, RowWork.class); logger.info("从Excel中读取到 {} 条数据", rowWorks.size()); // 按ORG分类存储数据 @@ -651,11 +575,22 @@ public class JobServiceImpl extends ServiceImpl implements IJobSe for (RowWork rowWork : rowWorks) { try { Job job = new Job(); + if(StringUtil.isEmptyOrNull(rowWork.getAca112())){ + continue; + } job.setJobTitle(rowWork.getAca112()); job.setMinSalary(Long.valueOf(rowWork.getSalaryLow())); job.setMaxSalary(Long.valueOf(rowWork.getSalaryHight())); - job.setEducation(iBussinessDictDataService.findCode(dictData, rowWork.getAac011())); - job.setExperience(iBussinessDictDataService.findCode(expData, rowWork.getExperience())); + if(Objects.isNull(rowWork.getAac011())){ + job.setEducation("-1"); + }else { + job.setEducation(iBussinessDictDataService.findCode(dictData, rowWork.getAac011())); + } + if(Objects.isNull(rowWork.getExperience())){ + job.setExperience("0"); + }else { + job.setExperience(iBussinessDictDataService.findCode(expData, rowWork.getExperience())); + } job.setCompanyName(rowWork.getAAB004()); job.setJobLocation(rowWork.getAAE006()); job.setPostingDate(new Date()); @@ -673,7 +608,11 @@ public class JobServiceImpl extends ServiceImpl implements IJobSe job.setCompanyId(getCompanyId(allCompany, rowWork.getAAB004())); job.setIsHot(0); job.setApplyNum(0); - job.setJobLocationAreaCode(Integer.valueOf(Objects.requireNonNull(iBussinessDictDataService.findCode(areaData, rowWork.getCounty())))); + if(Objects.isNull(rowWork.getCounty())){ + job.setJobLocationAreaCode(null); + }else { + job.setJobLocationAreaCode(Integer.valueOf(Objects.requireNonNull(iBussinessDictDataService.findCode(areaData, rowWork.getCounty())))); + } job.setDescription(rowWork.getAcb22a()); job.setIsPublish(1); job.setDataSource(rowWork.getORG()); @@ -730,19 +669,28 @@ public class JobServiceImpl extends ServiceImpl implements IJobSe Company companyNew = new Company(); companyNew.setName(company.getName()); companyNew.setLocation(company.getLocation()); - companyNew.setScale(iBussinessDictDataService.findCode(scaleData,company.getScale())); + if(Objects.isNull(company.getScale())){ + companyNew.setScale("0"); + }else { + companyNew.setScale(iBussinessDictDataService.findCode(scaleData,company.getScale())); + } companyNew.setDelFlag("0"); companyNew.setCreateBy("system"); companyNew.setCreateTime(new Date()); companyNew.setRemark("add"); companyNew.setDescription(company.getDescription()); companyNew.setIndustry(findIndustry(treeSelects,company)); - companyNew.setNature(iBussinessDictDataService.findCode(natureData,company.getNature())); + if(Objects.isNull(company.getNature())){ + companyNew.setNature("8"); + }else { + companyNew.setNature(iBussinessDictDataService.findCode(natureData,company.getNature())); + } companyList.add(companyNew); } return companyList; } + private String findIndustry(List treeSelects, Company company) { if(company.getRemark()==null){return "";} if(Objects.equals(company.getRemark(), "")){return "";} @@ -776,108 +724,5 @@ public class JobServiceImpl extends ServiceImpl implements IJobSe } return jobs; } - @Autowired - private WechatUtil wechatUtil; - @Override - public AppWechatEntity getWechatUrl(String weChatUrl) { - return wechatUtil.sign(weChatUrl); - } - @Override - public String insertTemp(Job job) { - String companyName = job.getCompanyName(); - Company company = new Company(); - company.setName(companyName); - companyMapper.insert(company); - job.setCompanyId(company.getCompanyId()); - this.insertJob(job); - System.out.println(job.getJobId()); - String url = "https://qd.zhaopinzao8dian.com/app#/packageA/pages/post/post?jobId="+Base64.getEncoder().encodeToString(String.valueOf(job.getJobId()).getBytes()); - return url; - } - - @Override - public String htmlGen(Long id) { - ESJobDocument esJobDocument = iesJobSearchService.selectById(id); - String jobTitle = esJobDocument.getJobTitle(); - Long maxSalary = esJobDocument.getMaxSalary(); - Long minSalary = esJobDocument.getMinSalary(); - String companyName = esJobDocument.getCompanyName(); - Long vacancies = esJobDocument.getVacancies(); - - // 1. 从服务器获取模板文件内容 - String templateContent = fetchTemplateFromServer(); - if (templateContent == null || templateContent.isEmpty()) { - return ""; - } - - // 2. 替换模板中的动态变量 - String htmlContent = templateContent - .replace("${jobTitle}", jobTitle) - .replace("${companyName}", companyName) - .replace("${minSalary}", String.valueOf(minSalary)) - .replace("${maxSalary}", String.valueOf(maxSalary)) - .replace("${vacancies}", String.valueOf(vacancies)) - .replace("${jobId}", String.valueOf(id)); - - // 3. 检查并创建目录 - String directoryPath = "/data/file/share"; - String directoryPath_domain = "/file/share"; - File directory = new File(directoryPath); - if (!directory.exists()) { - directory.mkdirs(); - } - - // 4. 生成HTML文件 - String fileName = "share_" + id + ".html"; - String filePath = directoryPath + "/" + fileName; - File htmlFile = new File(filePath); - - try { - // 如果文件已存在,先删除 - if (htmlFile.exists()) { - return "https://qd.zhaopinzao8dian.com/file/share/"+fileName; - } - - // 写入新内容 - FileWriter writer = new FileWriter(htmlFile); - writer.write(htmlContent); - writer.close(); - - return "https://qd.zhaopinzao8dian.com/file/share/"+fileName; - } catch (IOException e) { - e.printStackTrace(); - return ""; - } - } - - private String fetchTemplateFromServer() { - String templateUrl = "https://qd.zhaopinzao8dian.com/file/share/template.html"; - try { - URL url = new URL(templateUrl); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.setRequestMethod("GET"); - - if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) { - BufferedReader reader = new BufferedReader( - new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)); - StringBuilder response = new StringBuilder(); - String line; - - while ((line = reader.readLine()) != null) { - response.append(line).append("\n"); - } - reader.close(); - return response.toString(); - } - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - @Override - public void fix() { - iesJobSearchService.fix(); - } } diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/util/StringUtil.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/util/StringUtil.java index 4ef1f52..2bf2d61 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/util/StringUtil.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/util/StringUtil.java @@ -1,5 +1,7 @@ package com.ruoyi.cms.util; +import com.ruoyi.cms.domain.query.ESJobSearch; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -47,4 +49,13 @@ public class StringUtil { } + public static List convertStringToStringList(String input) { + if (isEmptyOrNull(input)) { + return new ArrayList<>(); + } + + return Arrays.stream(input.split(",")) // 按逗号分割字符串 + .map(String::trim) // 去除每个部分的前后空格 + .collect(Collectors.toList()); // 收集为List + } } diff --git a/ruoyi-bussiness/src/main/resources/mapper/app/AppUserMapper.xml b/ruoyi-bussiness/src/main/resources/mapper/app/AppUserMapper.xml index 4b1f260..e4c47ed 100644 --- a/ruoyi-bussiness/src/main/resources/mapper/app/AppUserMapper.xml +++ b/ruoyi-bussiness/src/main/resources/mapper/app/AppUserMapper.xml @@ -54,4 +54,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and experience = #{experience} + \ No newline at end of file diff --git a/ruoyi-bussiness/src/main/resources/mapper/app/CompanyCardMapper.xml b/ruoyi-bussiness/src/main/resources/mapper/app/CompanyCardMapper.xml index f534307..404e13b 100644 --- a/ruoyi-bussiness/src/main/resources/mapper/app/CompanyCardMapper.xml +++ b/ruoyi-bussiness/src/main/resources/mapper/app/CompanyCardMapper.xml @@ -19,11 +19,10 @@ - - select company_card_id, name, targ, backgroud_color, del_flag, create_by, create_time, update_by, update_time, remark,status,company_nature,card_order,description,icon from company_card + select company_card_id, name, targ, backgroud_color, del_flag, create_by, create_time, update_by, update_time, remark,status,company_nature,card_order,description from company_card