Просмотр исходного кода

添加 检查列表删除阿里云影像

刘桂岩 4 лет назад
Родитель
Сommit
14809df765
4 измененных файлов с 196 добавлено и 5 удалено
  1. 86 0
      application/manage/controller/Exam.php
  2. 66 3
      application/manage/view/exam/index.html
  3. 2 1
      composer.json
  4. 42 1
      composer.lock

+ 86 - 0
application/manage/controller/Exam.php

@@ -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;
+    }
 }

+ 66 - 3
application/manage/view/exam/index.html

@@ -93,8 +93,18 @@
                     return source;
                 }
             }
-            
-            
+
+            function deleteOneFormatter(id,row){
+                var cmdEdit="<a href='#' onclick=\"javascript:deleteOne('"+row.id+"');\" >删除云影像</a>&nbsp;";
+                return cmdEdit;
+            }
+
+            function deleteAllFormatter(id,row){
+                var cmdEdit="<input type='checkbox' name='allDelete' class='allDelete' value="+row.id+">";
+                return cmdEdit;
+            }
+
+
             $(function(){
                 
                 var height=$(document).height();
@@ -137,7 +147,8 @@
                             {field:'createdAt',title:'创建时间',width:115 , formatter:dateFormatter },
                             {field:'pay_status',title:'支付状态',width:115  },
                             {field:'status',title:'数据状态',width:115 , formatter:statusFormatter },
-                            {field:'grid_commands',title:'操作',align: 'center',width:100 },
+                            {field:'grid_command',title:'操作',align: 'center',width:100, formatter:deleteOneFormatter },
+                            {field:'grid_commands',title:'批量删除',align: 'center',width:100, formatter:deleteAllFormatter },
                     ]],
                     onDblClickRow :function(rowIndex,rowData){
                         showEditWin(rowData.id);
@@ -152,12 +163,14 @@
                 var deptid=$("#dept_id").combobox("getValue");
                 var patient_num=$("#patient_num").textbox("getValue");
                 var accession_num=$("#accession_num").textbox("getValue");
+                var exam_class=$("#exam_class").textbox("getValue");
                 
                 var queryParams = $('#dg').datagrid('options').queryParams;
                 queryParams.insid=institution_id;
                 queryParams.deptid=deptid;
                 queryParams.patient_num=patient_num;
                 queryParams.accession_num=accession_num;
+                queryParams.exam_class=exam_class;
                 
                 $('#dg').datagrid('options').queryParams=queryParams;
                 $('#dg').datagrid("reload");
@@ -191,6 +204,53 @@
                     }
                 });
             }
+
+            function deleteOne(id){
+                $.messager.confirm('Confirm','确定要删除这条检查的云影像吗?',function(r){
+                    if(r){
+                        $.ajax({
+                            url:"/manage/exam/deleteOne",
+                            data:"id="+id,
+                            success:function(rs){
+                                if(rs=="delete_ok"){
+                                    alert("操作已成功!");
+                                }else{
+                                    alert("操作失败!");
+                                }
+                            }
+                        });
+                    }
+                });
+            }
+
+            function deleteAll(){
+                $.messager.confirm('Confirm','确定要删除这些检查的云影像吗?',function(r){
+                    ids = $("input:checkbox[name='allDelete']:checked").map(function(index,elem) {
+                        return $(elem).val();
+                    }).get();
+                    if(r){
+                        $.ajax({
+                            url:"/manage/exam/deleteAll",
+                            data:"ids="+ids,
+                            success:function(rs){
+                                if(rs=="delete_ok"){
+                                    alert("操作已成功!");
+                                }else{
+                                    alert("操作失败!");
+                                }
+                            }
+                        });
+                    }
+                });
+            }
+
+            function  chooseAll()
+            {
+                $('.allDelete').each(function(){
+                    //将checkbox状态改为选中
+                    $(this).prop("checked",true);
+                });
+            }
             
             // 关闭编辑窗口
             function closeEditWin(isReload){
@@ -226,11 +286,14 @@
         <div id="tb" class="editform" style="display: none; padding-top: 1px;">&nbsp;
             所在机构:<input type="text" name="institution_id" id="institution_id" style="width:150px;" />&nbsp;
             所在科室:<input type="text" name="dept_id" id="dept_id" style="width:100px;"  />&nbsp;
+            检查类型:<input type="text" id="exam_class" name="exam_class" class="easyui-textbox" style="width: 120px;" />&nbsp;
             病例号:<input type="text" id="patient_num" name="patient_num" class="easyui-textbox" style="width: 120px;" />&nbsp;
             科室检查号:<input type="text" id="accession_num" name="accession_num" class="easyui-textbox" style="width: 120px;" />&nbsp;
             <a id="submit" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" style="width: 80px" onclick="reload()" >查询</a>
             &nbsp;&nbsp;&nbsp;&nbsp;
             <a id="add" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add'" onclick="javascript:showEditWin()" style="width: 80px">添加</a>
+            <a id="deleteAll" href="#" class="easyui-linkbutton"  onclick="javascript:deleteAll()" style="width: 100px">批量删除</a>
+            <a id="chooseAll" href="#" class="easyui-linkbutton"  onclick="javascript:chooseAll()" style="width: 100px">全部选中</a>
         </div>
         <div id="edit-window" class="easyui-window" style="overflow: hidden" ><iframe src="about:blank" id="editFrame" style="width:100%;height:100%" frameborder="0" scrolling="yes" ></iframe></div>
         

+ 2 - 1
composer.json

@@ -20,7 +20,8 @@
         "topthink/framework": "5.0.*",
         "topthink/think-captcha": "1.0.7",
         "phpoffice/phpexcel": "^1.8",
-        "opqnext/reflection-api-doc": "v1.0"
+        "opqnext/reflection-api-doc": "v1.0",
+        "aliyuncs/oss-sdk-php": "^2.3"
     },
     "autoload": {
         "psr-4": {

+ 42 - 1
composer.lock

@@ -4,8 +4,49 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "423b1945150535b893066045c34cb122",
+    "content-hash": "7577eb49d960f0bbe778b6b9cc6a9073",
     "packages": [
+        {
+            "name": "aliyuncs/oss-sdk-php",
+            "version": "v2.3.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/aliyun/aliyun-oss-php-sdk.git",
+                "reference": "053d7ba9e798e4c09b9c5c1edab153d25ea9643a"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/aliyun/aliyun-oss-php-sdk/zipball/053d7ba9e798e4c09b9c5c1edab153d25ea9643a",
+                "reference": "053d7ba9e798e4c09b9c5c1edab153d25ea9643a",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "~4.0",
+                "satooshi/php-coveralls": "~1.0"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "OSS\\": "src/OSS"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Aliyuncs",
+                    "homepage": "http://www.aliyun.com"
+                }
+            ],
+            "description": "Aliyun OSS SDK for PHP",
+            "homepage": "http://www.aliyun.com/product/oss/",
+            "time": "2019-11-15T11:05:42+00:00"
+        },
         {
             "name": "opqnext/reflection-api-doc",
             "version": "v1.0",