初始化
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/**
|
||||
* @deprecated 2026-06-18 已废弃,请使用 StationDefinition 替代。
|
||||
*/
|
||||
namespace app\models;
|
||||
|
||||
use core\base\Model;
|
||||
|
||||
/**
|
||||
* 入库模型
|
||||
* @deprecated
|
||||
*/
|
||||
class WarehouseIn extends Model
|
||||
{
|
||||
protected $table = 'warehouse_in';
|
||||
|
||||
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])->fetch();
|
||||
}
|
||||
|
||||
// 根据产品型号筛选记录(warehouse_in 表无 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(in_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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user