testDao;
// }
public function __construct(TestDao $testDao, CommonService $commonService,ReportDao $reportDao) {
parent::__construct();
$this->testDao = $testDao;
$this->reportDao = $reportDao;
$this->commonService = $commonService;
}
private function injectDao($testDao, $commonService) {
}
// public function test($study,$email) {
// set_time_limit(0);
// ini_set('memory_limit','1280M');
// $study = str_replace('&node_type=1','',$study);
// $this->reportDao->insertDcmCompress(['status'=>1,'study_id'=>$study]);
// $path = $this->runRack($study,1);
// $type = 1;
// if(strrpos($path,'zip') !== false && file_exists($path))
// {
// $type = $this->uploadZip($path,$study);
// }
// if(!empty($email))
// {
// $this->reportDao->insertDcmCompress(['status'=>9,'study_id'=>$study,'msg'=>$path]);
// if(strrpos($path,'zip') !== false)
// {
// $name = $this->reportDao->getPatientName($study);
// $this->reportDao->insertDcmCompress(['status'=>10,'study_id'=>$study]);
// // 存在zip压缩文件
// $this->sendEmail($email,$path,$name,$type);
// $this->reportDao->insertDcmCompress(['status'=>11,'study_id'=>$study]);
// Log::record('邮件发送完毕');
// $this->reportDao->updateEmailStatus($email,$study);
// }
// }
// }
//
// public function runRack($study,$come='')
// {
// ini_set('max_execution_time', 6000);
// $time = date('Y-m-d H:i:s',time());
// //过期时间 大于当前 则 还没过期
// $where = "effective_date > '$time'";
// $dcm = $this->reportDao->getDcmPath($where,$study);
// if(!empty($dcm))
// {
// log::record('存在历史dcm地址'.$dcm);
// return $dcm;
// }
// $this->setCache($study.'_zip',$study,600);
// log::record('不存在历史地址则继续'.$study);
// //外网地址 需要network 走带宽
//// $url = "https://query.pacsonline.cn/query/url?network=1&study_id=$study&version=V1.2.0.0";
// //内网地址
// $url = 'https://query.pacsonline.cn/query/url?&study_id='.$study.'&version=V1.2.0.0';
// $data = $this->curl_get($url);
// $data = json_decode($data);
// if(empty($data))
// {
// log::record('没有找到dcm信息');
// return '';
// }
// $this->reportDao->insertDcmCompress(['status'=>2,'study_id'=>$study]);
// $date = time();
// $create = ROOT_PATH . 'public' . DS . 'download'.DS.$date;
// log::record('压缩中');
// $path = $this->zip($data,$create,$date,$study);
// log::record('压缩成功');
// return $path;
// }
//
// public function uploadZip($path_url,$study)
// {
// $this->reportDao->insertDcmCompress(['status'=>7,'study_id'=>$study]);
// $upload = new uploadToCloud();
// $s = $upload->upload($path_url,$path_url, 'zskktemp');
// var_dump($s);
// if(($s['@metadata']['statusCode'] ?? '') == '200')
// {
// $this->reportDao->insertDcmCompress(['status'=>8,'study_id'=>$study]);
// gc_collect_cycles();
// $this->reportDao->updateDcmPath(['study_id'=>$study],['dcm_type'=>2]);
// unlink($path_url);
// return 2;
// }
// return '1';
//
// }
//
// public function zip($data,$create,$date,$study)
// {
// ini_set('max_execution_time', 6000);
// $fileList = [];
// $exam = $this->reportDao->getExamByStudy($study);
// $this->reportDao->insertDcmCompress(['status'=>3,'study_id'=>$study]);
// if($exam['institution_id'] == '06300009')
// {
// $patient_num = $exam['patient_num'];
// $name = $exam['name'];
// //工人医院需要解密
// if (!file_exists($create)) {
// mkdir($create, 0777,true);
// @chmod($create, 0777);
// }
// $ts = system("python3.8 /data/code/ris_server/utils/down/main.py '$patient_num' '$study' '$name' $date");
// if($ts)
// {
// $files = scandir($create);
// foreach ($files as $v)
// {
// if($v == '.' || $v == '..')
// {
// continue;
// }
// $fileList[] = $create.DS.$v;
// }
// }
// }else{
// foreach ($data as $k=>$v)
// {
// $path = $this->downLoad($v,$create.DS.$k,$create);
// $fileList[] = $path;
// }
// $zipPath = ROOT_PATH . 'public' . DS .'zip';
// $filename = $zipPath.DS."$date.zip";
// if (!file_exists($zipPath)) {
// mkdir($zipPath, 0777,true);
// @chmod($zipPath, 0777);
// }
// $this->reportDao->insertDcmCompress(['status'=>4,'study_id'=>$study]);
// $zip = new \ZipArchive();
// $zip->open($filename,\ZipArchive::CREATE); //打开压缩包
// foreach($fileList as $file){
// $zip->addFile($file,basename($file)); //向压缩包中添加文件
// }
// $zip->close(); //关闭压缩包
// }
// $this->reportDao->insertDcmCompress(['status'=>5,'study_id'=>$study]);
// $path_url = 'zip/'.$date.".zip";
// $insert = [
// 'dcm_path'=>$path_url,
// 'study_id'=>$study,
// 'effective_date'=>date('Y-m-d H:i:s',time()+864000), //10天有效期
// ];
// $this->reportDao->insertDcmPath($insert);
// $this->delCache($study.'_zip');
// $this->reportDao->insertDcmCompress(['status'=>6,'study_id'=>$study]);
// return $path_url;
// }
//
// public function sendEmail($email,$dcmPath,$name,$type=1)
// {
// $dcmPath = $this->makeFileUrl($dcmPath,$type,'attachment','+3 days','zskktemp');
// $mail = new PHPMailer(true); // Passing `true` enables exceptions
// try {
// //服务器配置
// $mail->CharSet ="UTF-8"; //设定邮件编码
// $mail->SMTPDebug = 0; // 调试模式输出
// $mail->isSMTP(); // 使用SMTP
// $mail->Host = 'smtp.exmail.qq.com'; // SMTP服务器
// $mail->SMTPAuth = true; // 允许 SMTP 认证
// $mail->Username = 'company@pacsonline.cn'; // SMTP 用户名 即邮箱的用户名
// $mail->Password = 'Zskk1234'; // SMTP 密码 部分邮箱是授权码(例如163邮箱)
// $mail->SMTPSecure = 'ssl'; // 允许 TLS 或者ssl协议
// $mail->Port = 465; // 服务器端口 25 或者465 具体要看邮箱服务器支持
//
// $mail->setFrom('company@pacsonline.cn', '冠医云'); //发件人
// $mail->addAddress($email, ''); // 收件人
// //$mail->addAddress('ellen@example.com'); // 可添加多个收件人
// $mail->addReplyTo('company@pacsonline.cn', '冠医云'); //回复的时候回复给哪个邮箱 建议和发件人一致
// //$mail->addCC('cc@example.com'); //抄送
// //$mail->addBCC('bcc@example.com'); //密送
// $zipPath = ROOT_PATH . 'public';
//// $maxsize = 45 * 1024 * 1024;
// $mail->Subject = $name.'影像';
//// if(filesize($zipPath.'/'.$dcmPath) < $maxsize)
//// {
//// //发送附件
////// $mail->addAttachment($zipPath.'a.zip'); // 添加附件
//// $mail->addAttachment($zipPath.'/'.$dcmPath, $name.'.zip'); // 发送附件并且重命名
//// $mail->Body = "链接将于".date('Y-m-d',time()+10*24*3600)."失效,请即时下载";
//// $mail->AltBody = "链接将于".date('Y-m-d',time()+10*24*3600)."失效,请即时下载";
//// }else{
// //发送链接地址
//
// //Content
// $mail->isHTML(true); // 是否以HTML文档格式发送 发送后客户端可直接显示对应HTML内容
// if($type == 2)
// {
// $dcmPath = ltrim($dcmPath,'/');
// $mail->Body = "下载".$name."影像"."
链接将于".date('Y-m-d',time()+3*24*3600)."失效,请及时下载";
// }else
// {
// $mail->Body = "下载".$name."影像"."
链接将于".date('Y-m-d',time()+3*24*3600)."失效,请及时下载";
// }
//// $mail->AltBody = '如果邮件客户端不支持HTML则显示此内容';
//// }
//
// $mail->send();
// return '邮件发送成功';
// } catch (Exception $e) {
// return '邮件发送失败: '.$mail->ErrorInfo;
// }
// }
}