|
@@ -230,6 +230,47 @@ class Exam extends Base {
|
|
|
public function deleteAll()
|
|
|
{
|
|
|
$string = is_string($_GET["ids"]) ? $_GET["ids"] : null;
|
|
|
+ $this->del($string);
|
|
|
+ return 'delete_ok';
|
|
|
+ }
|
|
|
+
|
|
|
+ public function curl_get($url){
|
|
|
+
|
|
|
+// $header = array(
|
|
|
+// 'Accept: text/html',
|
|
|
+// );
|
|
|
+ $curl = curl_init();
|
|
|
+ //设置抓取的url
|
|
|
+ curl_setopt($curl, CURLOPT_URL, $url);
|
|
|
+ //设置头文件的信息作为数据流输出
|
|
|
+ curl_setopt($curl, CURLOPT_HEADER, 0);
|
|
|
+ // 超时设置,以秒为单位
|
|
|
+ curl_setopt($curl, CURLOPT_TIMEOUT, 1);
|
|
|
+
|
|
|
+ // 超时设置,以毫秒为单位
|
|
|
+ // curl_setopt($curl, CURLOPT_TIMEOUT_MS, 500);
|
|
|
+
|
|
|
+ // 设置请求头
|
|
|
+// curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
|
|
|
+ //设置获取的信息以文件流的形式返回,而不是直接输出。
|
|
|
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
|
|
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
|
|
+ curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
|
|
+ //执行命令
|
|
|
+ $data = curl_exec($curl);
|
|
|
+ curl_close($curl);
|
|
|
+
|
|
|
+// // 显示错误信息
|
|
|
+// if (curl_error($curl)) {
|
|
|
+// print "Error: " . curl_error($curl);
|
|
|
+// } else {
|
|
|
+// // 打印返回的内容
|
|
|
+// var_dump($data);
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function del($string)
|
|
|
+ {
|
|
|
$ids = explode(',',$string);
|
|
|
if(empty($ids)){
|
|
|
return '';
|
|
@@ -237,16 +278,10 @@ class Exam extends Base {
|
|
|
$study_ids = DB::table('exams')->where('id','in',$ids)->where("study_id is not null or study_id != ''")->column('study_id');
|
|
|
$studies = DB::table('series')->where('study_id','in',$study_ids)->column('id');
|
|
|
$images = DB::table('images')->where('series_id','in',$studies)->column('metadata');
|
|
|
- $return = $this->delAli($images);
|
|
|
- return 'delete_ok';
|
|
|
- }
|
|
|
-
|
|
|
- public function delAli($data)
|
|
|
- {
|
|
|
- if(empty($data)){
|
|
|
+ if(empty($images)){
|
|
|
return;
|
|
|
}
|
|
|
- $count = count($data);
|
|
|
+ $count = count($images);
|
|
|
|
|
|
|
|
|
$accessKeyId = "LTAI4GDTQ15b4F85sAaAKTEE";
|
|
@@ -254,39 +289,41 @@ class Exam extends Base {
|
|
|
// Endpoint以杭州为例,其它Region请按实际情况填写。
|
|
|
$endpoint = "http://oss-cn-beijing.aliyuncs.com";
|
|
|
$bucket= "zskk-dcm";
|
|
|
-
|
|
|
- $objects = array();
|
|
|
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint);
|
|
|
- if($count > 1000){
|
|
|
- $c = floor($count/1000);
|
|
|
+
|
|
|
+ if($count > 499){
|
|
|
+ $c = floor($count/500);
|
|
|
for ($i=0;$i<=$c;$i++)
|
|
|
{
|
|
|
- $num1 = $i*1000;
|
|
|
- $num2 = $i*1000+999;
|
|
|
- // 截取1000个image数据
|
|
|
- $data = array_slice($data,$num1,$num2);
|
|
|
+ $data = [];
|
|
|
+ $objects = array();
|
|
|
+ $num1 = $i*500;
|
|
|
+ $num2 = 500;
|
|
|
+ // 截取500个image数据
|
|
|
+ $data = array_slice($images,$num1,$num2);
|
|
|
foreach ($data as $k=>$v){
|
|
|
$objects[] = $v;
|
|
|
}
|
|
|
// 调用阿里删除数据
|
|
|
- $info = $ossClient->deleteObjects($bucket, $objects);
|
|
|
- if($info){
|
|
|
- // 删除成功则删除对应数据
|
|
|
- DB::table('images')->where('metadata','in',$objects)->delete();
|
|
|
- DB::table('oss_callbacks')->where('md5','in',$objects)->delete();
|
|
|
- }
|
|
|
+ $this->delAli($ossClient,$bucket,$objects);
|
|
|
}
|
|
|
}else{
|
|
|
- foreach ($data as $k=>$v){
|
|
|
+ foreach ($images as $k=>$v){
|
|
|
$objects[] = $v;
|
|
|
}
|
|
|
- $info = $ossClient->deleteObjects($bucket, $objects);
|
|
|
- if($info){
|
|
|
- DB::table('images')->where('metadata','in',$objects)->delete();
|
|
|
- DB::table('oss_callbacks')->where('md5','in',$objects)->delete();
|
|
|
- }
|
|
|
+ $this->delAli($ossClient,$bucket,$objects);
|
|
|
}
|
|
|
|
|
|
- return $info;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function delAli($ossClient,$bucket,$objects)
|
|
|
+ {
|
|
|
+ $info = $ossClient->deleteObjects($bucket, $objects);
|
|
|
+ if($info){
|
|
|
+ // 删除成功则删除对应数据
|
|
|
+ DB::table('images')->where('metadata','in',$objects)->delete();
|
|
|
+ DB::table('oss_callbacks')->where('md5','in',$objects)->delete();
|
|
|
+ }
|
|
|
}
|
|
|
}
|