|
@@ -10,6 +10,8 @@ use think\Cookie;
|
|
|
use think\Request;
|
|
|
use app\common\library\SysLogs;
|
|
|
use app\common\library\UUIDs;
|
|
|
+use OSS\OssClient;
|
|
|
+use OSS\Core\OssException;
|
|
|
|
|
|
class Exam extends Base {
|
|
|
|
|
@@ -26,6 +28,7 @@ class Exam extends Base {
|
|
|
$deptid = isset($params["deptid"]) ? $params["deptid"] : null;
|
|
|
$patient_num = isset($params["patient_num"]) ? $params["patient_num"] : null;
|
|
|
$accession_num = isset($params["accession_num"]) ? $params["accession_num"] : null;
|
|
|
+ $exam_class = isset($params["exam_class"]) ? $params["exam_class"] : null;
|
|
|
|
|
|
$insMap = array();
|
|
|
$insArr = Db::table("institution")->field("id, name")->select();
|
|
@@ -62,6 +65,9 @@ class Exam extends Base {
|
|
|
if (!empty($accession_num)) {
|
|
|
$wheres["accession_num"] = $accession_num;
|
|
|
}
|
|
|
+ if (!empty($exam_class)) {
|
|
|
+ $wheres["exam_class"] = $exam_class;
|
|
|
+ }
|
|
|
|
|
|
// 处理分页
|
|
|
$page = empty($_GET["page"]) ? 1 : $_GET["page"];
|
|
@@ -203,4 +209,84 @@ class Exam extends Base {
|
|
|
$id = is_string($_GET["id"]) ? $_GET["id"] : "";
|
|
|
}
|
|
|
|
|
|
+ public function deleteOne()
|
|
|
+ {
|
|
|
+ $id = is_string($_GET["id"]) ? $_GET["id"] : null;
|
|
|
+ if(empty($id)){
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ $exam = DB::table('exams')->where('id',$id)->field('study_id')->find();
|
|
|
+ if(empty($exam['study_id']))
|
|
|
+ {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ $studies = DB::table('series')->where('study_id',$exam['study_id'])->column('id');
|
|
|
+ $images = DB::table('images')->where('series_id','in',$studies)->column('metadata');
|
|
|
+ $return = $this->delAli($images);
|
|
|
+ return 'delete_ok';
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public function deleteAll()
|
|
|
+ {
|
|
|
+ $string = is_string($_GET["ids"]) ? $_GET["ids"] : null;
|
|
|
+ $ids = explode(',',$string);
|
|
|
+ if(empty($ids)){
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ $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)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $count = count($data);
|
|
|
+
|
|
|
+
|
|
|
+ $accessKeyId = "LTAI4GDTQ15b4F85sAaAKTEE";
|
|
|
+ $accessKeySecret = "6NrhII6uYQj0mEvU7jnPNhr9InSq57";
|
|
|
+ // 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);
|
|
|
+ for ($i=0;$i<=$c;$i++)
|
|
|
+ {
|
|
|
+ $num1 = $i*1000;
|
|
|
+ $num2 = $i*1000+999;
|
|
|
+ // 截取1000个image数据
|
|
|
+ $data = array_slice($data,$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();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $info;
|
|
|
+ }
|
|
|
}
|