|
|
|
|
@ -83,11 +83,114 @@ public function GetItemList($searchInfo,$page,$pageSize){
|
|
|
|
|
->join('s_devices', 's_check_item_device.device_id', '=', 's_devices.id')
|
|
|
|
|
->select('s_devices.*')
|
|
|
|
|
->where('item_id',$v->id)->get();
|
|
|
|
|
// 解析原始科室
|
|
|
|
|
$deptNames = [];
|
|
|
|
|
if (!empty($v->hisExecDepts)) {
|
|
|
|
|
$deptCodes = json_decode($v->hisExecDepts, true);
|
|
|
|
|
if (!empty($deptCodes) && is_array($deptCodes)) {
|
|
|
|
|
$deptNames = DB::table('s_department')
|
|
|
|
|
->whereIn('department_number', $deptCodes)
|
|
|
|
|
->pluck('department_name')
|
|
|
|
|
->toArray();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$list[$k]->his_exec_dept_names = $deptNames;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return \Yz::Return(true, '查询成功', ['list'=>$list,'count'=>$count]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//导出检查项目列表
|
|
|
|
|
public function ExportItemList($searchInfo)
|
|
|
|
|
{
|
|
|
|
|
$small_id=[];
|
|
|
|
|
$list=DB::table('s_check_item')->where('s_check_item.is_del', 0)->whereNotNull('sheetType')->where('sheetType', '!=', '');
|
|
|
|
|
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'])){
|
|
|
|
|
$list->where(function($query) use ($searchInfo) {
|
|
|
|
|
$query->where('item_name', 'like', '%'.$searchInfo['name'].'%')
|
|
|
|
|
->orWhere('item_code', 'like', '%'.$searchInfo['name'].'%');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (isset($searchInfo['deviceBind']) && $searchInfo['deviceBind'] !== '') {
|
|
|
|
|
if ($searchInfo['deviceBind'] == 1) {
|
|
|
|
|
$list->whereIn('s_check_item.id', function($q) {
|
|
|
|
|
$q->select('item_id')->from('s_check_item_device');
|
|
|
|
|
});
|
|
|
|
|
} elseif ($searchInfo['deviceBind'] == 0) {
|
|
|
|
|
$list->whereNotIn('s_check_item.id', function($q) {
|
|
|
|
|
$q->select('item_id')->from('s_check_item_device');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (isset($searchInfo['hisExecDepts']) && $searchInfo['hisExecDepts'] !== '') {
|
|
|
|
|
if ($searchInfo['hisExecDepts'] == 1) {
|
|
|
|
|
$list->whereNotNull('hisExecDepts')->where('hisExecDepts', '!=', '');
|
|
|
|
|
} elseif ($searchInfo['hisExecDepts'] == 0) {
|
|
|
|
|
$list->where(function($q) {
|
|
|
|
|
$q->whereNull('hisExecDepts')->orWhere('hisExecDepts', '');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$list = $list->orderBy('s_check_item.id')->get();
|
|
|
|
|
|
|
|
|
|
// 构建 HTML 表格
|
|
|
|
|
$html = '<table border="1" cellpadding="6" cellspacing="0" style="border-collapse:collapse;width:100%;font-size:12px;font-family:微软雅黑;">';
|
|
|
|
|
$html .= '<thead><tr style="background:#4472C4;color:#fff;font-weight:bold;text-align:center;">';
|
|
|
|
|
$html .= '<th style="padding:8px;">检查项目代码</th><th style="padding:8px;">检查项目名称</th><th style="padding:8px;">HIS执行科室</th><th style="padding:8px;">关联排班</th></tr></thead><tbody>';
|
|
|
|
|
|
|
|
|
|
foreach ($list as $v) {
|
|
|
|
|
// 解析原始科室名称
|
|
|
|
|
$deptNames = [];
|
|
|
|
|
if (!empty($v->hisExecDepts)) {
|
|
|
|
|
$deptCodes = json_decode($v->hisExecDepts, true);
|
|
|
|
|
if (!empty($deptCodes) && is_array($deptCodes)) {
|
|
|
|
|
$deptNames = DB::table('s_department')
|
|
|
|
|
->whereIn('department_number', $deptCodes)
|
|
|
|
|
->pluck('department_name')
|
|
|
|
|
->toArray();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取关联排班名称
|
|
|
|
|
$deviceNames = DB::table('s_check_item_device')
|
|
|
|
|
->join('s_devices', 's_check_item_device.device_id', '=', 's_devices.id')
|
|
|
|
|
->where('item_id', $v->id)
|
|
|
|
|
->pluck('s_devices.device_name')
|
|
|
|
|
->toArray();
|
|
|
|
|
|
|
|
|
|
$deptCount = count($deptNames);
|
|
|
|
|
$deviceCount = count($deviceNames);
|
|
|
|
|
$maxRows = max($deptCount, $deviceCount, 1);
|
|
|
|
|
|
|
|
|
|
// 第一行,带合并单元格和背景色
|
|
|
|
|
$html .= '<tr style="background:#d9e2f3;">';
|
|
|
|
|
$html .= '<td rowspan="'.$maxRows.'" style="vertical-align:middle;text-align:center;padding:4px;">'.$v->item_code.'</td>';
|
|
|
|
|
$html .= '<td rowspan="'.$maxRows.'" style="vertical-align:middle;text-align:center;padding:4px;">'.$v->item_name.'</td>';
|
|
|
|
|
$html .= '<td style="padding:4px;">'.($deptNames[0] ?? '').'</td>';
|
|
|
|
|
$html .= '<td style="padding:4px;">'.($deviceNames[0] ?? '').'</td>';
|
|
|
|
|
$html .= '</tr>';
|
|
|
|
|
|
|
|
|
|
// 后续行
|
|
|
|
|
for ($i = 1; $i < $maxRows; $i++) {
|
|
|
|
|
$html .= '<tr>';
|
|
|
|
|
$html .= '<td style="padding:4px;">'.($deptNames[$i] ?? '').'</td>';
|
|
|
|
|
$html .= '<td style="padding:4px;">'.($deviceNames[$i] ?? '').'</td>';
|
|
|
|
|
$html .= '</tr>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$html .= '</tbody></table>';
|
|
|
|
|
return $html;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//绑定设备
|
|
|
|
|
public function BindDevice($item_id,$device_ids){
|
|
|
|
|
$data=[];
|
|
|
|
|
|