69 lines
1.9 KiB
PHP
69 lines
1.9 KiB
PHP
<?php
|
|
/**
|
|
* @deprecated 2026-06-18 已废弃,请使用 StationDefinition 替代。
|
|
*/
|
|
namespace app\models;
|
|
|
|
use core\base\Model;
|
|
|
|
/**
|
|
* 成品测试模型
|
|
* @deprecated
|
|
*/
|
|
class FinishedTest extends Model
|
|
{
|
|
protected $table = 'finished_test';
|
|
|
|
public function getAll()
|
|
{
|
|
return $this->order(['id DESC'])->fetchAll();
|
|
}
|
|
|
|
public function addRecord($data)
|
|
{
|
|
return $this->add($data);
|
|
}
|
|
|
|
public function findBySerial($finished_serial)
|
|
{
|
|
return $this->where(['finished_serial = :serial'], [':serial' => $finished_serial])->fetchAll();
|
|
}
|
|
|
|
// 根据产品型号筛选记录(finished_test 表无 product_type 列)
|
|
public function getByTypeAndModel($product_type, $product_model)
|
|
{
|
|
if (empty($product_model)) {
|
|
return [];
|
|
}
|
|
return $this->where(['product_model = :pm'], [':pm' => $product_model])->order(['id DESC'])->fetchAll();
|
|
}
|
|
|
|
// 统计当日某操作员的录入数量
|
|
public function countTodayByOperator($operator)
|
|
{
|
|
$sql = "SELECT COUNT(*) as cnt FROM " . $this->getTable() . " WHERE operator = :op AND DATE(test_time) = CURDATE()";
|
|
$result = $this->query($sql, [':op' => $operator]);
|
|
return $result[0]['cnt'] ?? 0;
|
|
}
|
|
|
|
// 统计总记录数(可按型号筛选)
|
|
public function countTotal($product_type = '', $product_model = '')
|
|
{
|
|
if (!empty($product_model)) {
|
|
$result = $this->where(['product_model = :pm'], [':pm' => $product_model])->field('COUNT(*) as cnt')->fetch();
|
|
} else {
|
|
$sql = "SELECT COUNT(*) as cnt FROM " . $this->getTable();
|
|
$result = $this->query($sql);
|
|
}
|
|
return $result[0]['cnt'] ?? 0;
|
|
}
|
|
|
|
public function batchImport($records)
|
|
{
|
|
foreach ($records as $record) {
|
|
$this->add($record);
|
|
}
|
|
return true;
|
|
}
|
|
}
|