Zsk.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835
  1. <?php
  2. namespace app\controller;
  3. use app\model\CdssDisease;
  4. use app\model\ClinicalPathway;
  5. use app\model\DocumentImages;
  6. use app\model\MindMapzh;
  7. use app\model\Omics;
  8. use app\model\Operation;
  9. use app\model\XySickNess;
  10. use app\model\XyZskInspection;
  11. use app\model\XyZskMedicine;
  12. use app\model\ZySickness;
  13. use think\response\Json;
  14. use think\facade\Request;
  15. use app\model\DiseaseProperties;
  16. use app\model\DiseaseCategoryProperties;
  17. use app\model\GetGuide;
  18. use app\model\XyZskDisease;
  19. use app\model\GuideKeyword;
  20. use app\model\DocumentCaseReport;
  21. use app\model\TitleContent;
  22. require_once app()->getRootPath().'vendor/autoload.php';
  23. class Zsk extends CommonTwoController
  24. {
  25. /**
  26. * 科室以及科室下疾病
  27. */
  28. public function index():Json
  29. {
  30. $tag = Request::param('tag') ?? 'xy';
  31. $page = Request::param('page') ?? 1;
  32. $pagesize = 10;
  33. $limit = ($page - 1) * $pagesize;
  34. $type = Request::param('type') ?? 'zsk';
  35. if('department' === $type) {
  36. $pagesize = 30;
  37. }
  38. /**
  39. * 西医科室以及科室下疾病
  40. */
  41. if('xy' === $tag) {
  42. $departments = XyZskDisease::distinct(true)
  43. ->field('departmentLevel1 as department')
  44. ->where('departmentLevel1' , '<>' , null)
  45. ->limit($limit , $pagesize)
  46. ->select()
  47. ->toArray();
  48. if('department' === $type) {
  49. $departmentPageSize = 500;
  50. }
  51. if('zsk' === $type) {
  52. $departmentPageSize = 6;
  53. }
  54. foreach ($departments as $key => $value)
  55. {
  56. $departments[$key]['diseases'] = $this->getDiseaseByDepartment($value['department'] , $tag , $departmentPageSize);
  57. $departments[$key]['first_letter'] = $this->getFirstCharters($value['department']);
  58. $departments[$key]['tag'] = 'Disease';
  59. }
  60. }
  61. /**
  62. * 中医科室以及科室下疾病
  63. */
  64. if('zy' === $tag) {
  65. //$query = "match(n:SickNess) where n.department is not null return distinct n.department as department skip $limit limit $pagesize";
  66. //$departments = $this->getAboutInfo($query , $tag);
  67. $departments = ZySickness::distinct(true)->field('department')->where('department' , '<>' , null)->limit($limit , $pagesize)->select()->toArray();
  68. foreach ($departments as $key => $value) {
  69. $departments[$key]['diseases'] = $this->getDiseaseByDepartment($value['department'] , $tag);
  70. $departments[$key]['first_letter'] = $this->getFirstCharters($value['department']);
  71. $departments[$key]['tag'] = 'zySickNess';
  72. }
  73. }
  74. $firstLetters = array_column($departments, 'first_letter');
  75. array_multisort($firstLetters , SORT_ASC , SORT_NATURAL , $departments);
  76. return $this->_json_succ(
  77. $departments
  78. );
  79. }
  80. /**
  81. * 科室下疾病
  82. */
  83. private function getDiseaseByDepartment($department , $tag , $pagesize = 6):array
  84. {
  85. $diseases = XyZskDisease::field('name')->where('departmentLevel1' , $department)->limit($pagesize)->select()->toArray();
  86. $sickness = ZySickness::field('name')->where('department' , $department)->limit($pagesize)->select()->toArray();
  87. return 'zy' === $tag ? $sickness : $diseases;
  88. }
  89. /**
  90. * 详情
  91. */
  92. public function detail()
  93. {
  94. $type = Request::param('type') ?? '';
  95. $tag = 'zh' === $type ? 2 : 1;
  96. $label = Request::param('label');
  97. $name = Request::param('name') ?? '';
  98. /**
  99. * 中医疾病下存在多种证型情况 需要单独处理
  100. */
  101. if(2 === $tag && 'zySickNess' === $label) {
  102. $diseaseCategoryProperties = ZySickness::where('name' , $name)->field('dialecticalName as name')->select()->toArray();
  103. foreach ($diseaseCategoryProperties as $key => $value)
  104. {
  105. $diseaseCategoryProperties[$key]['DiseaseCategoryProperties'] = DiseaseProperties::where('label' , 'zySickNess')
  106. ->order('order' , 'desc')
  107. ->select()
  108. ->toArray();
  109. }
  110. } else {
  111. $diseaseCategoryProperties = DiseaseCategoryProperties::where('tag' , $tag)
  112. ->where('label' , $label)
  113. ->select()
  114. ->toArray();
  115. foreach($diseaseCategoryProperties as $key => $value)
  116. {
  117. $diseaseCategoryProperties[$key]['DiseaseCategoryProperties'] = DiseaseProperties::where('category_id' , $value['id'])->order('order' , 'desc')->select()->toArray();
  118. }
  119. }
  120. return $this->_json_succ($diseaseCategoryProperties);
  121. }
  122. /**
  123. * 属性详情
  124. *
  125. * @param string $name
  126. * @param string $propertyChName
  127. * @param string $propertyZhName
  128. * @param string $type
  129. * @param string $label
  130. */
  131. public function propertyDetail()
  132. {
  133. $name = Request::param('name');
  134. $propertyZhName = Request::param('property_zh_name');
  135. $propertyChName = Request::param('property_ch_name');
  136. $type = Request::param('type') ?? '';
  137. $label = Request::param('label');
  138. if(! $name || ! $propertyZhName || ! $propertyChName || ! $label) {
  139. return $this->_json_error('请求参数有误!');
  140. }
  141. $model = '';
  142. $where = [];
  143. switch ($label) {
  144. case "Disease":
  145. $model = '\app\model\CdssDisease';
  146. break;
  147. case "Inspection":
  148. $model = '\app\model\CdssInspection';
  149. break;
  150. case "MedicineProduction":
  151. $model = '\app\model\CdssMedicine';
  152. break;
  153. case "Operation":
  154. $model = '\app\model\Operation';
  155. break;
  156. case "zySickNess":
  157. $model = '\app\model\ZySickness';
  158. $where = ['dialecticalName' => $name];
  159. break;
  160. case "CnMedicinalCrop":
  161. $model = '\app\model\ZyMedicinalCrop';
  162. $where = ['id' => $name];
  163. break;
  164. case "CnPatentMedicine":
  165. $model = '\app\model\ZyPatentMedicine';
  166. break;
  167. case "Prescription":
  168. $model = '\app\model\ZyPrescription';
  169. break;
  170. case "TonicDiet":
  171. $model = '\app\model\ZyTonicDiet';
  172. break;
  173. case "Constitution":
  174. $model = '\app\model\ZyConstitution';
  175. break;
  176. case "ChannelCollateral":
  177. $model = '\app\model\ZyChannelCollateral';
  178. $where = ['id' => $name];
  179. break;
  180. case "Acupoint":
  181. $model = '\app\model\ZyAcupoint';
  182. break;
  183. case "SickNess":
  184. $model = '\app\model\ZySickness';
  185. break;
  186. default:
  187. if($propertyChName === 'DiagnosisTreatment')
  188. {
  189. $diagnosisTreatment = GetGuide ::field('title , title_trans , abstract , abstract_trans , author , publish_time , full_text_url , pdf')
  190. ->where("keyword_cn" , "like" , "%$name%" )
  191. ->order('publish_time' , 'DESC')
  192. ->select()
  193. ->toArray();
  194. foreach ($diagnosisTreatment as $k => $v)
  195. {
  196. if(stripos($v['pdf'] , 'file') !== false) {
  197. $diagnosisTreatment[$k]['pdf'] = 'https://jm.admin.jiankangche.cn/uploads/'.$v['pdf'];
  198. } elseif($v['pdf']) {
  199. $diagnosisTreatment[$k]['pdf'] = 'http://124.70.62.102:8212/'.$v['pdf'].'.pdf';
  200. }
  201. }
  202. return $this->_json_succ(
  203. [
  204. 'text' => $propertyZhName ,
  205. 'value' => $diagnosisTreatment ?? '',
  206. 'data_type' => 'many'
  207. ]
  208. );
  209. }
  210. break;
  211. }
  212. if($model) {
  213. $where = empty($where) ? ['name' => $name] : $where;
  214. $fieldValue = $model::where($where)->value($propertyChName);
  215. return $this->_json_succ(
  216. [
  217. 'text' => $propertyZhName ,
  218. 'value' => $fieldValue ,
  219. 'data_type' => 'single'
  220. ]
  221. );
  222. }
  223. }
  224. /**
  225. * 某个科室下所有疾病的首字母
  226. */
  227. public function getDepartmentExistDiseasesLetter()
  228. {
  229. $department = Request::param('department');
  230. $type = Request::param('type') ?? '';
  231. if(! $type) {
  232. //$query = "match(n:Disease) where n.departmentLevel1="."'".$department."'"."return n.name as name";
  233. //$diseases = $this->getAboutInfo($query) ?? [];
  234. $diseases = XyZskDisease::field('name')->where('departmentLevel1' , $department)->select()->toArray();
  235. } else {
  236. $query = "match(n:SickNess) where n.department="."'".$department."'"."return n.dialecticalName as name";
  237. $diseases = $this->getAboutInfo($query , 'zy') ?? [];
  238. }
  239. if(empty($diseases)) {
  240. return $this->_json_error('暂无数据!');
  241. }
  242. foreach ($diseases as $key => $value)
  243. {
  244. $diseases[$key]['first_letter'] = $this->getFirstCharters($value['name']);
  245. }
  246. $letters = array_unique(array_column($diseases , 'first_letter'));
  247. sort($letters);
  248. return $this->_json_succ(array_values(array_filter($letters)));
  249. }
  250. /**
  251. * 首字母检索疾病
  252. */
  253. public function getDiseaseNameByFirstLetter()
  254. {
  255. $department = Request::param('department');
  256. $firstLetter = Request::param('first_letter');
  257. $type = Request::param('type') ?? '';
  258. if(!$type) {
  259. $diseases = XyZskDisease::field('name')->where('departmentLevel1' , $department)->select()->toArray();
  260. } else {
  261. $query = "match(n:SickNess) where n.department="."'".$department."'"."return n.dialecticalName as name";
  262. $diseases = $this->getAboutInfo($query , 'zy') ?? [];
  263. }
  264. if(empty($diseases)) {
  265. return $this->_json_error('暂无数据!');
  266. }
  267. foreach ($diseases as $key => $value)
  268. {
  269. $diseases[$key]['first_letter'] = $this->getFirstCharters($value['name']);
  270. }
  271. $searchs = [];
  272. foreach ($diseases as $disease)
  273. {
  274. if($disease['first_letter'] === $firstLetter) {
  275. $searchs[] = $disease['name'];
  276. }
  277. }
  278. return $this->_json_succ(
  279. [
  280. 'department' => $department ,
  281. 'searchs' => $searchs
  282. ]
  283. );
  284. }
  285. /**
  286. * 检测neo4j 有的搜索标签 【未用】
  287. */
  288. public function getHaveDataLabelByNeo4j():Json
  289. {
  290. $keyword = Request::param('keyword');
  291. $type = Request::param('type') ?? '';
  292. if('zh' === $type) {
  293. $tags = ['SickNess' , 'CnMedicinalCrop' , 'CnPatentMedicine' , 'Prescription' , 'TonicDiet' , 'Constitution' , 'ChannelCollateral' , 'Acupoint' , 'Symptom'];
  294. } else {
  295. $tags = ['Disease' , 'Inspection' , 'MedicineProduction' , 'Identity' , 'SickNess' , 'ClinicalPathway'];
  296. }
  297. $existDataTags = [];
  298. foreach($tags as $tag)
  299. {
  300. $query = "match(n:".$tag.") where n.name =~'.*".$keyword.".*' return n.name as name , n.kgid as kgid limit 1";
  301. $data = 'zh' === $type ? $this->getAboutInfo($query , $type) : $this->getAboutInfo($query);
  302. if(isset($data[0]['name'])) {
  303. $existDataTags[] = $tag;
  304. }
  305. if('ClinicalPathway' === $tag) {
  306. $count = ClinicalPathway::where("clinical_pathway" , "like" , "%$keyword%" )->count();
  307. if($count > 0) {
  308. $existDataTags[] = $tag;
  309. }
  310. }
  311. }
  312. $result = [];
  313. if(!empty($existDataTags)) {
  314. foreach($existDataTags as $existDataTag) {
  315. $result[] = [
  316. 'key' => $existDataTag ,
  317. 'value' => DiseaseCategoryProperties::getValueByTag($existDataTag , $type)
  318. ];
  319. }
  320. }
  321. return $this->_json_succ($result);
  322. }
  323. /**
  324. * 搜索下展示标签
  325. */
  326. public function getLabels()
  327. {
  328. $lables = DiseaseCategoryProperties::getValueByTag('' , Request::param('type') ?? '',Request::param('gh') ?? '');
  329. $result = [];
  330. foreach($lables as $key => $value)
  331. {
  332. $result[] = [
  333. 'key' => $key ,
  334. 'value' => $value ,
  335. 'department' => $this->getDepartment($key)
  336. ];
  337. }
  338. return $this->_json_succ($result);
  339. }
  340. /**
  341. * 医疗疾病 | 科普疾病 获取科室
  342. */
  343. public function getDepartment($label)
  344. {
  345. if('Disease' === $label) {
  346. $department = CdssDisease::field('department_1 as department')
  347. ->distinct(true)
  348. ->limit(30)
  349. ->select()
  350. ->toArray();
  351. return array_values(array_filter(array_column($department , 'department')));
  352. }
  353. //9.26 修改
  354. //if('SickNess' === $label) {
  355. // $department = XySickNess::field('departmentLevel1 as department')
  356. // ->distinct(true)
  357. // ->limit(30)
  358. // ->select()
  359. // ->toArray();
  360. // return array_values(array_filter(array_column($department , 'department')));
  361. //}
  362. return [];
  363. }
  364. /**
  365. * 图像库
  366. */
  367. public function imgs()
  368. {
  369. $page = Request::param('page') ?? 1;
  370. $pasgesize = 10;
  371. $limit = ($page - 1) * $pasgesize;
  372. $imgs = XyZskDisease::field('ct')->where('ct' , '<>' , '' )->limit($limit , $pasgesize)->select()->toArray();
  373. foreach($imgs as $key => $img) {
  374. $imgs[$key]['ct'] = 'http://124.70.62.102:8212/'.$img['ct'].'.jpg';
  375. }
  376. return $this->_json_succ(
  377. [
  378. 'images' => $imgs ,
  379. 'total' => 500
  380. ]
  381. );
  382. }
  383. /**
  384. * 获取疾病诊疗指南关键词(调用外部接口)[弃用]
  385. */
  386. public function getKeywordByDiseaseName()
  387. {
  388. $name = Request::param('name');
  389. $url = "http://124.70.62.102/keyword/query?keyword_cn=".urlencode($name);
  390. $response = json_decode(file_get_contents($url) , true);
  391. if(200 == $response['code']) {
  392. $keyword = $response['data'][0]['keyword'];
  393. $keywords = explode(' ' , $keyword);
  394. return $keywords[0];
  395. }
  396. return false;
  397. }
  398. // ------------------------------------------- 外部接口数据录入 ---------------------------------------
  399. /**
  400. * 诊疗指南录入
  401. */
  402. public function addGuide()
  403. {
  404. //$date = "2022-07-14"; // 0510
  405. $date = '';
  406. if(!$date) {
  407. return $this->_json_error('日期未输入!');
  408. }
  409. if(!$type = Request::param('type') ?? 'guides') {
  410. return $this->_json_error('日期未输入!');
  411. }
  412. $url = "http://124.70.62.102/data/query?date=".urlencode($date).'&type='.urlencode($type);
  413. $data = json_decode(file_get_contents($url) , true);
  414. if(empty($data)) {
  415. return;
  416. }
  417. $guides = $data['data'];
  418. foreach($guides as $guide)
  419. {
  420. if($guide['references']) {
  421. $guide['references'] = json_encode($guide['references']);
  422. }
  423. if($guide['references_trans']) {
  424. $guide['references_trans'] = json_encode($guide['references_trans']);
  425. }
  426. if($guide['full_text_url']) {
  427. $guide['full_text_url'] = json_encode($guide['full_text_url']);
  428. }
  429. $result = GetGuide::create($guide);
  430. }
  431. $result = [];
  432. return $this->_json_succ($result);
  433. }
  434. /**
  435. * 指南关键词录入
  436. */
  437. public function addGuideKeyword()
  438. {
  439. $url = "http://124.70.62.102/keyword/query";
  440. $data = json_decode(file_get_contents($url) , true);
  441. if(empty($data)) {
  442. return;
  443. }
  444. $data = $data['data'];
  445. foreach($data as $value)
  446. {
  447. $result = GuideKeyword::create($value);
  448. }
  449. $result = [];
  450. return $this->_json_succ($result);
  451. }
  452. /**
  453. * 疾病录入
  454. */
  455. public function addDise()
  456. {
  457. $date = "2022-05-13"; // 0510
  458. //$date = '';
  459. if(!$date) {
  460. return $this->_json_error('日期未输入!');
  461. }
  462. if(!$type = Request::param('type') ?? 'pet') {
  463. return $this->_json_error('日期未输入!');
  464. }
  465. $url = "http://124.70.62.102/data/query?date=".urlencode($date).'&type='.urlencode($type);
  466. $data = json_decode(file_get_contents($url) , true);
  467. if(empty($data)) {
  468. return;
  469. }
  470. //return $this->_json_succ($data);
  471. $guides = $data['data'];
  472. foreach($guides as $guide)
  473. {
  474. if($guide['references']) {
  475. $guide['references'] = json_encode($guide['references']);
  476. }
  477. if($guide['references_trans']) {
  478. $guide['references_trans'] = json_encode($guide['references_trans']);
  479. }
  480. if($guide['full_text_url']) {
  481. $guide['full_text_url'] = json_encode($guide['full_text_url']);
  482. }
  483. $result = DocumentImages::create($guide);
  484. }
  485. $result = [];
  486. return $this->_json_succ($result);
  487. }
  488. // -------------------------------- 图像库 | 病例库 ---------------------------------
  489. /**
  490. * 图像类型
  491. */
  492. public function imageType()
  493. {
  494. $imageType = [
  495. ['key' => 'x' , 'value' => 'X线片'],
  496. ['key' => 'ct' , 'value' => 'CT'],
  497. ['key' => 'mri' , 'value' => 'MRI'],
  498. ['key' => 'pet' , 'value' => 'PET'],
  499. ['key' => 'ultrasound' , 'value' => '超声图像'],
  500. ['key' => 'microscopy' , 'value' => '显微镜图'],
  501. ['key' => 'graphics' , 'value' => '绘图图表']
  502. ];
  503. return $this->_json_succ($imageType);
  504. }
  505. /**
  506. * 图像库首页
  507. */
  508. public function documentImages()
  509. {
  510. $search = Request::param('search') ?? '';
  511. $type = Request::param('type') ?? '';
  512. $page = Request::param('pn') ?? 1;
  513. $pasgesize = 12;
  514. $limit = ($page - 1) * $pasgesize;
  515. $where = [];
  516. if($type) {
  517. $where[] = ['type' , '=' , $type];
  518. }
  519. if($search) {
  520. $where[] = ["keyword_cn" , "like" , "%$search%"];
  521. }
  522. $total = DocumentImages::count();
  523. $documentImages = DocumentImages::field('img_name , type , title_trans as title , abstract_trans , keyword_cn , publish_time')->where($where)->limit($limit , $pasgesize)->select()->toArray();
  524. if(empty($documentImages)) {
  525. return $this->_json_error();
  526. }
  527. foreach($documentImages as $key => $img) {
  528. $documentImages[$key]['image'] = 'https://jm.jiankangche.cn/disease-img/images/'.$img['img_name'].'.jpg';
  529. $documentImages[$key]['type_zh'] = DocumentImages::imageType($img['type']);
  530. }
  531. /**
  532. * 总页数
  533. */
  534. $total_page = ceil($total/$pasgesize);
  535. return $this->_json_succ(['images' => $documentImages , 'total' => $total , 'total_page' => $total_page]);
  536. }
  537. /**
  538. * 图像库文献详情
  539. */
  540. public function documentImagesDetail()
  541. {
  542. if(!$imgName = Request::param('img_name') ?? '') {
  543. return $this->_json_error('请求参数有误!');
  544. }
  545. $document = DocumentImages::getByImgName($imgName);
  546. $newDocument = [
  547. 'title' => $document['title_trans'],
  548. 'enTitle' => $document['title'],
  549. 'source' => $document['source'],
  550. 'abstract' => $document['abstract'],
  551. 'abstract_trans'=> $document['abstract_trans'],
  552. 'constitutor' => $document['author'],
  553. 'year' => $document['publish_time'],
  554. 'full_text_url' => $document['full_text_url'],
  555. 'onlineRead' => 'https://jm.jiankangche.cn/disease-img/images/'.$document['pdf_file'].'.pdf'
  556. ];
  557. return $this->_json_succ($newDocument);
  558. }
  559. /**
  560. * 病例库文献
  561. */
  562. public function documentCaseReports()
  563. {
  564. $page = Request::param('pn') ?? 1;
  565. $pasgesize = 10;
  566. $limit = ($page - 1) * $pasgesize;
  567. $search = Request::param('search') ?? '';
  568. if(!$search) {
  569. $total = DocumentCaseReport::count();
  570. $documentCaseReports = DocumentImages::limit($limit , $pasgesize)->select()->toArray();
  571. } else {
  572. $total = DocumentCaseReport::where("keyword_cn" , "like" , "%$search%")->whereOr("title_trans" , "like" , "%$search%")->count();
  573. $documentCaseReports = DocumentImages::where("keyword_cn" , "like" , "%$search%")
  574. ->whereOr("title_trans" , "like" , "%$search%")
  575. ->limit($limit , $pasgesize)
  576. ->select()
  577. ->toArray();
  578. }
  579. if(empty($documentCaseReports)) {
  580. return $this->_json_error('未查到数据!');
  581. }
  582. $newCaeReports = [];
  583. foreach($documentCaseReports as $key => $value) {
  584. $newCaeReports[$key]['title'] = $value['title_trans'];
  585. $newCaeReports[$key]['enTitle'] = $value['title'];
  586. $newCaeReports[$key]['source'] = $value['source'] ?? '';
  587. $newCaeReports[$key]['abstract'] = $value['abstract'];
  588. $newCaeReports[$key]['abstract_trans'] = $value['abstract_trans'];
  589. $newCaeReports[$key]['constitutor'] = $value['author'];
  590. $newCaeReports[$key]['year'] = $value['publish_time'];
  591. $newCaeReports[$key]['full_text_url'] = $value['full_text_url'];
  592. $newCaeReports[$key]['onlineRead'] = 'https://file.jiankangche.cn/'.$value['pdf_file'].'.pdf';
  593. }
  594. /**
  595. * 总页数
  596. */
  597. $total_page = ceil($total/$pasgesize);
  598. return $this->_json_succ(
  599. [
  600. 'caeReports' => $newCaeReports ,
  601. 'total' => $total ,
  602. 'total_page' => $total_page
  603. ]
  604. );
  605. }
  606. /**
  607. * 指南脑图(中文)
  608. */
  609. public function getMindMapZhList():Json
  610. {
  611. $search = Request::param('search') ?? '';
  612. $type = Request::param('type') ?? 1;
  613. return $this->_json_succ(
  614. $this->getTrees(MindMapzh::where(['type' => $type])->select() , 0 , $search)
  615. );
  616. }
  617. /**
  618. * 递归生成树形结构
  619. * @param array $data 所有分类数据
  620. * @param int $pid 父级id
  621. * @return array
  622. */
  623. protected function getTrees($data , $pid = 0 , $search = ''):array
  624. {
  625. $tree = [];
  626. foreach ($data as $value)
  627. {
  628. /**
  629. * 关键字搜索
  630. */
  631. if(stripos($value['category_name'] , $search) !== false) {
  632. $value['is_search'] = 1;
  633. } else {
  634. $value['is_search'] = 2;
  635. }
  636. /**
  637. * 字符长度超多8个汉字需要截取处理
  638. */
  639. $strLen = 24;
  640. if($strLen < strlen($value['category_name'])) {
  641. $value['category_name_substr'] = mb_substr($value['category_name'] , 0 , 8) . '...';
  642. } else {
  643. $value['category_name_substr'] = $value['category_name'];
  644. }
  645. if ($value['parent_id'] == $pid) {
  646. /*
  647. * 销毁节点 , 减少后续递归消耗
  648. */
  649. // unset($data[$key]);
  650. $children = $this->getTrees($data , $value['id'] , $search);
  651. if (!empty($children)) {
  652. $value['children'] = $children;
  653. }
  654. $tree[] = $value;
  655. }
  656. }
  657. return $tree;
  658. }
  659. /**
  660. * 指南结构化
  661. */
  662. public function getGuideStructureList():Json
  663. {
  664. $search = Request::param('search') ?? '';
  665. $page = Request::param('page') ?? 1;
  666. $pasgesize = 10;
  667. $limit = ($page - 1) * $pasgesize;
  668. if($search) {
  669. $list = TitleContent::field('title , content , page')->where("title" , "like" , "%$search%")->where('title' , '<>' , '')->limit($limit , $pasgesize)->select()->toArray();
  670. $total = TitleContent::where("title" , "like" , "%$search%")->where('title' , '<>' , '')->count();
  671. } else {
  672. $list = TitleContent::field('title , content , page')->where('title' , '<>' , '')->limit($limit , $pasgesize)->select()->toArray();
  673. $total = TitleContent::where("title" , "like" , "%$search%")->where('title' , '<>' , '')->count();
  674. }
  675. foreach($list as $key => $value) {
  676. $list[$key]['pdf_link'] = "https://jm.jiankangche.cn/sga2022.v2.pdf";
  677. }
  678. /**
  679. * 总页数
  680. */
  681. $total_page = ceil($total/$pasgesize);
  682. return $this->_json_succ(
  683. [
  684. 'list' => $list ,
  685. 'total' => $total ,
  686. 'total_page' => $total_page
  687. ]
  688. );
  689. }
  690. /**
  691. * 药物靶点
  692. */
  693. public function getOmicsList():Json
  694. {
  695. $page = Request::param('page') ?? 1;
  696. $pasgesize = 10;
  697. $limit = ($page - 1) * $pasgesize;
  698. $searchField = Request::param('search_field') ?? '';
  699. $search = Request::param('search') ?? '';
  700. if($searchField && $search) {
  701. $list = Omics::where($searchField , "like" , "%$search%")->limit($limit , $pasgesize)->select()->toArray();
  702. $total = Omics::where($searchField , "like" , "%$search%")->count();
  703. } else {
  704. $list = Omics::limit($limit , $pasgesize)->select()->toArray();
  705. $total = Omics::count();
  706. }
  707. /**
  708. * 总页数
  709. */
  710. $total_page = ceil($total/$pasgesize);
  711. return $this->_json_succ(
  712. [
  713. 'list' => $list ,
  714. 'total' => $total ,
  715. 'total_page' => $total_page
  716. ]
  717. );
  718. }
  719. }