You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
125 lines
3.3 KiB
PHP
125 lines
3.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\API\Admin\YeWu;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use App\Services\Admin\YeWu\CheckItemService;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class CheckItemController extends Controller
|
|
{
|
|
//获取检查项目类别列表
|
|
public function GetClassList()
|
|
{
|
|
$searchInfo = request('searchInfo');
|
|
$s = new CheckItemService;
|
|
return $s->GetClassList($searchInfo);
|
|
}
|
|
|
|
//获取检查项目列表
|
|
public function GetItemList()
|
|
{
|
|
$page = request('page');
|
|
$pageSize = request('pageSize');
|
|
$searchInfo = request('searchInfo');
|
|
$s = new CheckItemService;
|
|
return $s->GetItemList($searchInfo, $page, $pageSize);
|
|
}
|
|
|
|
//绑定设备
|
|
public function BindDevice()
|
|
{
|
|
$item_id = request('item_id');
|
|
$device_ids = request('device_ids');
|
|
$s = new CheckItemService;
|
|
return $s->BindDevice($item_id, $device_ids);
|
|
}
|
|
|
|
//保存检查项目信息
|
|
public function Save()
|
|
{
|
|
$Info = request('Info');
|
|
$s = new CheckItemService;
|
|
return $s->Save($Info);
|
|
}
|
|
|
|
//设置互斥
|
|
public function SetHuChi(Request $request)
|
|
{
|
|
$userid = $request->get('userid');//中间件产生的参数
|
|
$code1 = request('code1');
|
|
$code2 = request('code2');
|
|
$time = request('time');
|
|
if(!isset($time)) return \Yz::echoError1("时间不能为空");
|
|
|
|
$q = DB::table('s_huchi')
|
|
->where('is_del', 0)
|
|
->where(function ($query) use ($code1, $code2) {
|
|
$query->where('code1', $code1)->where('code2', $code2);
|
|
})
|
|
->orWhere(function ($query) use ($code1, $code2) {
|
|
$query->where('code1', $code2)->where('code2', $code1);
|
|
})
|
|
->get();
|
|
|
|
if (count($q) > 0) return \Yz::echoError1("此条互斥已存在,请删除后再添加!");
|
|
$i = DB::table('s_huchi')->insert([
|
|
'code1' => $code1,
|
|
'code2' => $code2,
|
|
'time' => $time,
|
|
'is_del' => 0,
|
|
'add_user' => $userid,
|
|
]);
|
|
if ($i) {
|
|
return \Yz::Return(true, '设置成功', []);
|
|
} else {
|
|
return \Yz::echoError1("添加失败");
|
|
}
|
|
|
|
}
|
|
|
|
public function DelHuChi()
|
|
{
|
|
$id = request('id');
|
|
$u = DB::table('s_huchi')
|
|
->where('id', $id)
|
|
->update([
|
|
'is_del' => 1
|
|
]);
|
|
|
|
if ($u) {
|
|
return \Yz::Return(true, '操作成功', []);
|
|
} else {
|
|
return \Yz::echoError1("操作失败");
|
|
}
|
|
}
|
|
|
|
//获取某个项目已经设置的互斥列表
|
|
public function GetHuChiList()
|
|
{
|
|
$code = request('code');
|
|
$q=DB::select("SELECT
|
|
s_huchi.code1,
|
|
COALESCE(ci1.item_name, '未找到') AS code1_item_name,
|
|
s_huchi.code2,
|
|
COALESCE(ci2.item_name, '未找到') AS code2_item_name,time,s_huchi.id
|
|
FROM
|
|
s_huchi
|
|
LEFT JOIN
|
|
s_check_item AS ci1
|
|
ON
|
|
s_huchi.code1 = ci1.item_code
|
|
LEFT JOIN
|
|
s_check_item AS ci2
|
|
ON
|
|
s_huchi.code2 = ci2.item_code
|
|
WHERE
|
|
s_huchi.is_del = 0 AND
|
|
(s_huchi.code1 = ? OR s_huchi.code2 = ?)",[$code,$code]);
|
|
|
|
return \Yz::Return(true, '操作成功', $q);
|
|
|
|
}
|
|
}
|