no commit message

This commit is contained in:
annnj-company
2026-04-27 10:10:35 +08:00
parent 68a0b1ab22
commit 6fc3e6b64f
19 changed files with 1058 additions and 64 deletions

View File

@@ -1650,6 +1650,11 @@ function pushToAllClients($eventName, $data) {
'data' => json_encode($data)
];
error_log("=== 推送调试 ===");
error_log("目标地址: $socketUrl");
error_log("事件名称: $eventName");
error_log("推送数据: " . json_encode($data));
$options = [
'http' => [
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
@@ -1660,9 +1665,11 @@ function pushToAllClients($eventName, $data) {
];
$context = stream_context_create($options);
$result = file_get_contents($socketUrl, false, $context);
$result = @file_get_contents($socketUrl, false, $context);
writeLog("Push result - event: $eventName, data: " . json_encode($data) . ", result: '$result'", 'push_log');
error_log("推送结果: '" . ($result !== false ? $result : 'false') . "'");
writeLog("Push result - event: $eventName, data: " . json_encode($data) . ", result: '" . ($result !== false ? $result : 'false') . "'", 'push_log');
return $result === 'ok';
}
@@ -1694,5 +1701,187 @@ function fetchAndPushUnreturnedPriceCount() {
return pushUnreturnedPriceCount($count);
}
/**
* 推送预估数量更新
* @param array $counts 预估数量数组
* @return bool
*/
function pushEstimatePendingCount($counts) {
return pushToAllClients('updateEstimatePendingCount', $counts);
}
/**
* 获取预估数量
* @return array
*/
function getEstimatePendingCount() {
$Inquiry = new \app\model\Inquiry();
// 待制作status=9
$pendingCount = $Inquiry->where('status', 9)->count();
// 二审待制作status=10 且 estimate_status=2兼容字符串和数字类型
$secondReviewCount = $Inquiry->where('status', 10)
->where('estimate_status', '=', '2', false)
->count();
// 三审待制作status=10 且 estimate_status=3兼容字符串和数字类型
$thirdReviewCount = $Inquiry->where('status', 10)
->where('estimate_status', '=', '3', false)
->count();
// 待签章status=11
$signCount = $Inquiry->where('status', 11)->count();
// 总和
$total = $pendingCount + $secondReviewCount + $thirdReviewCount + $signCount;
return [
'pending' => $pendingCount,
'secondReview' => $secondReviewCount,
'thirdReview' => $thirdReviewCount,
'sign' => $signCount,
'total' => $total
];
}
/**
* 获取预估数量并推送给所有客户端
* @return bool
*/
function fetchAndPushEstimatePendingCount() {
$counts = getEstimatePendingCount();
return pushEstimatePendingCount($counts);
}
/**
* 推送查勘跟进中数量更新(推送刷新事件,让客户端主动获取自己的数量)
* @param int $count 查勘跟进中数量(当前用户的数量,用于发起者立即显示)
* @return bool
*/
function pushSurveyFollowCount($count) {
// 推送刷新事件,让所有客户端重新获取自己的查勘数量
return pushToAllClients('updateSurveyFollowCount', ['refresh' => true, 'count' => $count]);
}
/**
* 推送报告制作数量更新
* @param array $counts 报告制作数量数组
* @return bool
*/
function pushReportProduceCount($counts) {
// 推送刷新事件,让所有客户端重新获取自己的报告制作数量
return pushToAllClients('updateReportProduceCount', ['refresh' => true, 'counts' => $counts]);
}
/**
* 获取报告制作数量并推送给所有客户端
* @param int $userId 用户ID
* @param bool $isAdmin 是否管理员
* @return bool
*/
function fetchAndPushReportProduceCount($userId, $isAdmin = false) {
$pendingCount = Db::name('report')
->alias('r')
->join('inquiry i', 'r.quot_id = i.id', 'LEFT')
->where('r.report_source', 1)
->where('r.status', 1)
->where('r.create_time', 'gt', '2025-02-01 00:00:00');
$pending = $pendingCount->count();
// 二审待制作:以 pg_report 为主表review_status=1 且 status=2关联 pg_inquiry
$secondReviewCount = Db::name('report')
->alias('r')
->join('inquiry i', 'r.quot_id = i.id', 'LEFT')
->where('r.report_source', 1)
->where('r.review_status', 1)
->where('r.status', 2)
->where('r.create_time', 'gt', '2025-02-01 00:00:00')
->where('i.status', 7)
->group('r.quot_id');
$secondReview = $secondReviewCount->count();
// 三审待制作:以 pg_report 为主表review_status=2 且 review2_status=1 且 status=2关联 pg_inquiry
$thirdReviewCount = Db::name('report')
->alias('r')
->join('inquiry i', 'r.quot_id = i.id', 'LEFT')
->where('r.report_source', 1)
->where('r.review_status', 2)
->where('r.review2_status', 1)
->where('r.create_time', 'gt', '2025-02-01 00:00:00')
->where('r.status', 2);
$thirdReview = $thirdReviewCount->count();
// 计算总数
$total = $pending + $secondReview + $thirdReview;
return [
'pending' => $pending,
'secondReview' => $secondReview,
'thirdReview' => $thirdReview,
'total' => $total
];
error_log("查询到的报告制作数量: " . json_encode($counts));
$pushResult = pushReportProduceCount($counts);
error_log("推送结果: " . ($pushResult ? '成功' : '失败'));
return $pushResult;
}
/**
* 获取查勘跟进中数量(当前登录人)
* @param int $userId 用户ID
* @param bool $isAdmin 是否管理员
* @return int
*/
function getSurveyFollowCount($userId, $isAdmin = false) {
$Survey = new \app\model\Survey();
// 如果是管理员,不限制 user_id
if ($isAdmin) {
$count = $Survey->alias('s')
->join('pg_inquiry i', 's.order_no = i.order_no', 'INNER')
->where('i.status', 4)
->where('s.status', 2)
->where('s.assign_time', 'gt', '2025-02-01 00:00:00')
->count();
} else {
// 非管理员,只统计当前用户的查勘
$count = $Survey->alias('s')
->join('pg_inquiry i', 's.order_no = i.order_no', 'INNER')
->where('i.status', 4)
->where('s.status', 2)
->where('s.user_id', $userId)
->where('s.assign_time', 'gt', '2025-02-01 00:00:00')
->count();
}
return $count;
}
/**
* 获取查勘跟进中数量并推送给所有客户端
* @param int $userId 用户ID
* @param bool $isAdmin 是否管理员
* @return bool
*/
function fetchAndPushSurveyFollowCount($userId, $isAdmin = false) {
error_log("=== fetchAndPushSurveyFollowCount 调试 ===");
error_log("用户ID: $userId");
error_log("是否管理员: " . ($isAdmin ? 'true' : 'false'));
$count = getSurveyFollowCount($userId, $isAdmin);
error_log("查询到的查勘数量: $count");
$pushResult = pushSurveyFollowCount($count);
error_log("推送结果: " . ($pushResult ? '成功' : '失败'));
return $pushResult;
}
$GLOBALS['console'] = '';