<?php
/**
 *
 * @author：llbjj
 * @DateTime：2022/5/6 10:57
 * @Description：
 *
 */

namespace Application\Service\DB\Listset;

use Interop\Container\ContainerInterface;

class Annexcat extends \Application\Service\DB\AbstractDb
{
    public function __construct($dbAdapter, ContainerInterface $container)
    {
        $this->tableName = 'yikeen_listset_annexcat';
        parent::__construct($dbAdapter, $container);
    }

    /**
     * Notes:获取相关数组
     * @param
     * @return
     * @author haojinhua
     * @date 2024-07-02
     */
    public function fetchDataByItem($where,$val){
        $cond = [
            'where'=>$where,
            'columns'=>['id','item_id','list_type','annex_id','oa_category_id'],
            'order'=>['id']
        ];
        $arr = [];
        $datas = $this->fetchAll($cond);

        if(!empty($datas)){
            foreach($datas as $data){
                $arr[$data['item_id']][$data['list_type']][$data['annex_id']] = $data[$val];
            }
        }

        return $arr;
    }

    /**
     * Notes:获取文档分类关联数组
     * @param
     * @return
     * @author haojinhua
     * @date 2024-07-22
     */
    public function getOaDocumentInfo(){
        $category_datas = [];
        $oa_categoryData = $this->LocalService()->OAClient->documentCategoryList();
        if(!empty($oa_categoryData)){
            foreach($oa_categoryData as $oa_category){
                $category_datas[$oa_category['document_type']][$oa_category['item_id']][$oa_category['itemsig_id']][] = $oa_category;
            }
        }

        return $category_datas;
    }

    /**
     * Notes: 文档和名称对应数组
     * @param
     * @return
     * @author haojinhua
     * @date 2024-07-30
     */
    public function getOaDocNameInfo(){
        $category_datas = [];
        $oa_categoryData = $this->LocalService()->OAClient->documentCategoryList();
        if(!empty($oa_categoryData)){
            foreach($oa_categoryData as $oa_category){
                $category_datas[$oa_category['id']]= $oa_category['document_name'];
            }
        }

        return $category_datas;
    }
}