修复竞争比

This commit is contained in:
杨志
2026-01-21 14:50:39 +08:00
parent 6f429ffce2
commit afa0706f04
4 changed files with 31 additions and 11 deletions

View File

@@ -292,7 +292,7 @@ class CrawlerService
}
/**
* 计算竞争比格式1:比例,保留2位小数)
* 计算竞争比格式1:比例,四舍五入取整,无小数)
* @param int $zprs 招聘人数
* @param int $bkrs 审核通过人数
* @return string
@@ -309,16 +309,14 @@ class CrawlerService
// 将招聘人数简化为1计算审核通过人数与招聘人数的比例
$ratio = $bkrs / $zprs;
$ratioRounded = (int) round($ratio, 0, PHP_ROUND_HALF_UP);
// 保留2位小数
$ratioFormatted = number_format($ratio, 2, '.', '');
// 如果小数部分是.00,则显示为整数
if (floatval($ratioFormatted) == intval($ratioFormatted)) {
return '1:' . intval($ratioFormatted);
// 防止四舍五入后为0的极端情况
if ($ratioRounded < 0) {
$ratioRounded = 0;
}
return '1:' . $ratioFormatted;
return '1:' . $ratioRounded;
}
/**

View File

@@ -1,2 +0,0 @@
*
!.gitignore

24
public/static/js/xlsx.full.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>职位信息爬虫工具-2</title>
<!-- SheetJS库用于导出XLSX -->
<script src="/static/js/xlsx.full.min.js"></script>
<script src="<?php echo request()->root(); ?>/static/js/xlsx.full.min.js?v=1"></script>
<style>
* {
margin: 0;