Exemplo n.º 1
0
 /**
  * 得到 一二级热门科室、热门部位
  * @author gaoqing
  * @date 2016-04-13
  * @param int $columns 在页面中,显示的列数
  * @return array 热门科室、热门部位 数据集
  */
 public static function getCommonDepPart()
 {
     $commonDepPart = array();
     //获取科室
     $level1 = Department::find()->select('id,pinyin')->where('pid = 0')->asArray(true)->all();
     $level2 = Department::find()->select('id,name,pinyin,pid')->where('pid > 0')->asArray(true)->all();
     $dep = array();
     //科室部分
     foreach ($level1 as $k => $v) {
         $dep[$v['pinyin']] = array();
         foreach ($level2 as $kk => $vv) {
             if ($vv['pid'] == $v['id']) {
                 $dep[$v['pinyin']][] = $vv;
                 unset($level2[$k]);
             }
         }
     }
     //查询部位
     $part1 = Part::find()->select('id,pinyin')->where('pid = 0')->asArray(true)->all();
     $part2 = Part::find()->select('id,name,pinyin,pid')->where('pid > 0')->asArray(true)->all();
     $part = array();
     //部位部分
     foreach ($part1 as $k => $v) {
         $part[$v['pinyin']] = array();
         foreach ($part2 as $kk => $vv) {
             if ($vv['pid'] == $v['id']) {
                 $part[$v['pinyin']][] = $vv;
                 unset($part2[$k]);
             }
         }
     }
     $commonDepPart['department'] = $dep;
     $commonDepPart['part'] = $part;
     return $commonDepPart;
 }
Exemplo n.º 2
0
 /**
  * Lists all Product models.
  * @return mixed
  */
 public function actionIndex($category = null)
 {
     $query = Part::find();
     if ($category > 0) {
         $query->andWhere(['category_id' => $category]);
     }
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['kit_code' => SORT_ASC]]]);
     return $this->render('index', ['dataProvider' => $dataProvider, 'category_id' => $category]);
 }
Exemplo n.º 3
0
 public function actionPromo()
 {
     $this->layout = 'parts';
     $ids = [];
     foreach (Part::find()->where('file_foto != ""')->all() as $part) {
         $ids[$part->id] = null;
     }
     $parts = Part::find()->where(['in', 'id', array_rand($ids, 8)])->all();
     return $this->render('promo', ['parts' => $parts]);
 }
Exemplo n.º 4
0
 public function actionIndex()
 {
     Yii::$app->opengraph->title = Seo::Settings()->title;
     Yii::$app->opengraph->description = Seo::Settings()->description;
     Yii::$app->opengraph->image = 'http://xn--90agaunhfc3b5f.xn--p1ai/images/regularSprites/logoIQ174.png';
     Yii::$app->opengraph->twitter->card = 'summary';
     Yii::$app->opengraph->twitter->site = '@Webtest74';
     Yii::$app->opengraph->twitter->creator = '@Webtest74';
     $ids = [];
     foreach (Part::find()->where('file_foto != ""')->all() as $part) {
         $ids[$part->id] = null;
     }
     $parts = Part::find()->where(['in', 'id', array_rand($ids, 12)])->all();
     return $this->render('index', ['parts' => $parts]);
 }
 /**
  * 疾病 sitemap
  * @author gaoqing
  * @date 2016-04-25
  * @return array 响应信息
  */
 private function diseaseSitemap()
 {
     /**
      * <urlset>
      *  <url>
      *  <loc>http://jb.9939.com/article/2009/0327/1.shtml</loc>
      *  <lastmod>2009-03-27</lastmod>
      *  <changefreq>always</changefreq>
      *  <priority>0.6</priority>
      *  </url>
      * </urlset>
      */
     $where = $this->_ownership;
     $sitemap = '<?xml version="1.0" encoding="UTF-8"?>';
     $sitemap .= $this->_baidu ? '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:mobile="http://www.baidu.com/schemas/sitemap-mobile/1/">' : '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
     //判断jb还是wapjb
     $prefix = $where == 'pc' ? '' : 'wap_';
     //1、生成 疾病 部分的 sitemap
     $diseases = Disease::find()->asArray()->all();
     $sitemap .= $this->setSitemapURL($diseases, $prefix . 'disease');
     //2、生成 症状 部分的 sitemap
     $symptoms = Symptom::find()->asArray()->all();
     $sitemap .= $this->setSitemapURL($symptoms, $prefix . 'symptom');
     //3、生成 科室 部分的 sitemap
     $departments = Department::find()->asArray()->all();
     $sitemap .= $this->setSitemapURL($departments, $prefix . 'department');
     //4、生成 部位 部分的 sitemap
     $parts = Part::find()->asArray()->all();
     $sitemap .= $this->setSitemapURL($parts, $prefix . 'part');
     $sitemap .= '</urlset>';
     //5、生成 sitemap 文件
     if ($where == 'pc') {
         $frontend = \Yii::getAlias("@frontend");
         $frontDomain = \Yii::getAlias("@frontdomain");
     } elseif ($where == 'wap') {
         $frontend = \Yii::getAlias("@wapjb");
         $frontDomain = \Yii::getAlias("@mjb_domain");
     }
     //        $frontend = \Yii::getAlias("@frontend");
     $sitemapFolder = 'sitemap';
     $fileFolder = $frontend . '/web/' . $sitemapFolder;
     if (!file_exists($fileFolder) || !is_dir($fileFolder)) {
         mkdir($fileFolder, 0755);
     }
     $fileName = $this->_baidu ? 'diseasebaidusitemap.xml' : 'diseasesitemap.xml';
     if (file_put_contents($fileFolder . '/' . $fileName, $sitemap)) {
         //            $frontDomain = \Yii::getAlias("@frontdomain");
         return ['flag' => 1, 'url' => $frontDomain . '/' . $sitemapFolder . '/' . $fileName, 'name' => $fileName];
     }
     return [];
 }
Exemplo n.º 6
0
 /**
  * 一级部位下的子部位的数目
  * @param type $id
  * @return array 返回该一级部位下的子部位的数目
  */
 public function getLevel1ChildNum($id)
 {
     return Part::find()->select("count(id) as count")->where('pid=:pid', [':pid' => $id])->asArray()->one();
 }
Exemplo n.º 7
0
 /**
  * 根据疾病id, 获取所属的部位信息
  * @author gaoqing
  * @date 2016-03-23
  * @param int $diseaseid 疾病id
  * @return array 所属的部位信息
  */
 public static function getPartsByDisid($diseaseid)
 {
     $parts = [];
     //得到 9939_part_disease_rel 的 part id
     $partDiseases = [];
     $db = \Yii::$app->db_jbv2;
     $sql = "  SELECT DISTINCT partid FROM 9939_part_disease_rel WHERE diseaseid = '" . $diseaseid . "' ORDER BY partid DESC ";
     $partDiseases['list'] = $db->createCommand($sql)->queryAll(PDO::FETCH_ASSOC);
     //根据 part id 得到所有的部位信息
     $partids = self::getPartIDsFromPDR($partDiseases);
     if (!empty($partids)) {
         $parts = Part::find()->where(['id' => $partids])->orderBy('id DESC')->asArray()->all();
     }
     self::$_sftablename = "";
     return $parts;
 }