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.
81 lines
3.1 KiB
PHP
81 lines
3.1 KiB
PHP
<?php
|
|
namespace App\Services\Admin\YeWu;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use mysql_xdevapi\Table;
|
|
|
|
class CheckItemService
|
|
{
|
|
|
|
//获取检查项目类别列表
|
|
public function GetClassList($searchInfo){
|
|
$bigClass=DB::table('s_check_item_class')->where(['pid'=>0,'is_del'=>0])->get();
|
|
$smallClass=[];
|
|
if(!empty($searchInfo['bigClass'])) {
|
|
$smallClass = DB::table('s_check_item_class')->where(['pid'=>$searchInfo['bigClass'],'is_del'=>0])->get();
|
|
}
|
|
return \Yz::Return(true, '查询成功', ['bigClass'=>$bigClass,'smallClass'=>$smallClass]);
|
|
}
|
|
//获取检查项目列表
|
|
public function GetItemList($searchInfo,$page,$pageSize){
|
|
$where=['s_check_item.is_del'=>0];
|
|
$small_id=[];
|
|
$list=DB::table('s_check_item');
|
|
if(empty($searchInfo['bigClass'])!==true and empty($searchInfo['smallClass'])===true){
|
|
$small_id= DB::table('s_check_item_class')->where(['pid'=>$searchInfo['bigClass'],'is_del'=>0])->pluck('id')->toArray();
|
|
$list= $list->whereIn('item_class_id',$small_id);
|
|
}
|
|
if(!empty($searchInfo['smallClass'])){
|
|
$small_id[0]=$searchInfo['smallClass'];
|
|
$list= $list->whereIn('item_class_id',$small_id);
|
|
}
|
|
if(!empty($searchInfo['name'])){
|
|
$where[]=['item_name','like','%'.$searchInfo['name'].'%'];
|
|
}
|
|
$count= $list->where($where)->count();
|
|
$list= $list ->leftJoin('s_appointment_type', 's_check_item.reservation_method', '=', 's_appointment_type.id')
|
|
->select('s_check_item.*','s_appointment_type.name as reservation_method_name')
|
|
->where($where)->skip(($page-1)*$pageSize) // 跳过前9999条记录
|
|
->take($pageSize)->get();
|
|
foreach ($list as $k=>$v){
|
|
$list[$k]->devicesInfo=DB::table('s_check_item_device')
|
|
->join('s_devices', 's_check_item_device.device_id', '=', 's_devices.id')
|
|
->select('s_devices.*')
|
|
->where('item_id',$v->id)->get();
|
|
}
|
|
|
|
return \Yz::Return(true, '查询成功', ['list'=>$list,'count'=>$count]);
|
|
}
|
|
|
|
//绑定设备
|
|
public function BindDevice($item_id,$device_ids){
|
|
$data=[];
|
|
foreach ($device_ids as $k=>$v){
|
|
$data[$k]['item_id']=$item_id;
|
|
$data[$k]['device_id']=$v;
|
|
}
|
|
DB::beginTransaction();
|
|
DB::table('s_check_item_device')->where('item_id',$item_id)->delete();
|
|
$i= DB::table('s_check_item_device')->insert($data);
|
|
if($i>0){
|
|
DB::commit();
|
|
return \Yz::Return(true, '绑定成功', []);
|
|
}else{
|
|
DB::rollBack();
|
|
return \Yz::Return(false, '绑定失败');
|
|
}
|
|
}
|
|
public function Save($Info){
|
|
if(!empty($Info['id'])){
|
|
$res=DB::table('s_check_item')->where('id',$Info['id'])->update($Info);
|
|
if($res){
|
|
return \Yz::Return(true, '修改成功');
|
|
}else{
|
|
return \Yz::Return(false, '修改失败');
|
|
}
|
|
}else{
|
|
return \Yz::Return(false, 'id不能为空');
|
|
}
|
|
}
|
|
}
|