123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- <?php
- namespace app\inter\controller;
- use think\Controller;
- use think\Db;
- use app\common\library\UUIDs;
- use think\Session;
- use app\common\library\ResultTools;
- use think\Log;
- use think\Cache;
- class Operating extends Controller
- {
- public function index(){
- }
- /**
- * 医生运营统计
- *
- * @ApiTitle (医生运营统计)
- * @ApiSummary (医生运营统计)
- * @ApiSector (远程诊断)
- * @ApiMethod (POST)
- * @ApiRoute (/inter/operating/doctor)
- * @ApiHeaders (name="sign", type="string", required=true, description="请求头-校验key")
- * @ApiHeaders (name="nonce", type="string", required=true, description="请求头-随机数")
- * @ApiHeaders (name="timestamp", type=string, required=true, description="请求头-时间戳s")
- * @ApiParams (name="sessionid", type="string", required=true, description="参数json字符串")
- * @ApiReturnParams (name="status", type="integer", required=true, sample="0", description="返回码 fail 失败 ok成功"))
- * @ApiReturnParams (name="code", type="integer", required=true, sample="0", description="返回状态码")
- * @ApiReturnParams (name="info", type="string", required=true, sample="返回成功", description="返回信息")
- * @ApiReturnParams (name="msg", type="object", sample="{}", description="返回消息")
- * @ApiReturnParams (name="sessionid", type="object", sample="{}", description="缓存的数据key")
- * @ApiReturn (data="
- {
- 'status': ok,
- 'code': '0000',
- 'sessionid': 'a17z7a7a8f9g9rh9d89jio',
- 'msg': '请求成功',
- 'info' : ''
- }
- *")
- **/
- public function doctor(){
- try{
- $sessionid = $_REQUEST['sessionid'];
- log::record('-------运营------------');
- log::record($sessionid);
- $doctor = Cache::get($sessionid);
- log::record($doctor);
- log::record('-------------------');
- $operate = DB::table('operating')->where('type',1)->where('role_id',$doctor['id'])->field('nums,month,exam_num,remote_num,danger_num')->order('month asc')->limit(6)->select();
- if($operate){
- return json_encode(['code'=>'0000','status'=>'ok','msg'=>'请求成功','info'=>$operate,'sessionid'=>$sessionid]);
- }else{
- return json_encode(['code'=>'0000','status'=>'ok','msg'=>'请求成功','info'=>$operate,'sessionid'=>$sessionid]);
- }
- }catch(\Exception $e){
- return json_encode(['status'=>'fail','code'=>'2000','msg'=>$e->getMessage()]);
- }
- }
- public function getOperating(){
- $sessionid = $_REQUEST['sessionid'];
- $doctor = Cache::get($sessionid);
- $time = $_REQUEST['searchtime'];
- if($time){
- // where('id','between',[1,8]);
- }
- }
- public function saveYykExam()
- {
- $startTime = strtotime(date('Y-m-d H:00:00',strtotime('-150 day')));
- $finishTime = strtotime(date('Y-m-d H:59:59',strtotime('-1 day')));
- $key = 'YgpxjVeIx0yoK6Atz413IAj7hU9dygH4';
- $data = ['start_time'=>$startTime,'end_time'=>$finishTime];
- $sign = $this->getSign($key,$data);
- $url = 'https://pacs.yunyikang.cn/pacs/zskk/getPayList';
- $info = json_encode(['timestamp'=>time(),'signature'=>$sign,'data'=>json_encode($data,true)]);
- $return = $this->curlHttpsJsonPost($url,$info);
- $handleInfo = json_decode($return,true);
- $handleInfo['code'] = 0;
- if($handleInfo['code'] == 0)
- {
- $insert_handle = $handleInfo['data'];
- $history = DB::table('yyk')->column('exam_id');
- $insert = [];
- foreach ($insert_handle as $k=>$v)
- {
- if(in_array($v['exam_id'],$history))
- {
- continue;
- }
- $insert[$k] = $v;
- $insert[$k]['start_time'] = $startTime;
- $insert[$k]['end_time'] = $finishTime;
- }
- if(!empty($insert)){
- DB::table('yyk')->insertAll($insert);
- }
- return json_encode(['code'=>'0000','status'=>'ok','msg'=>'请求成功']);
- }else{
- return $return;
- }
- }
- public function curlHttpsJsonPost($url,$data)
- {
- $curl = curl_init(); // 启动一个CURL会话
- curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 对认证证书来源的检查
- curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
- curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器
- curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自动跳转
- curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自动设置Referer
- curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求
- curl_setopt($curl, CURLOPT_POSTFIELDS, $data); // Post提交的数据包
- curl_setopt($curl, CURLOPT_TIMEOUT, 30); // 设置超时限制防止死循环
- curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回
- curl_setopt($curl, CURLOPT_HTTPHEADER, array(
- 'Content-Type: application/json; charset=utf-8',
- )
- );
- $tmpInfo = curl_exec($curl); // 执行操作
- curl_close($curl); // 关闭CURL会话
- return $tmpInfo; // 返回数据
- }
- public function getSign($secret, $data) {
- // 对数组的值按key排序
- ksort($data);
- // 生成url的形式
- $params = http_build_query($data);
- // 生成sign
- $sign = md5($params . $secret);
- return $sign;
- }
- }
|