package com.connor.sso.sso.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@org.apache.ibatis.annotations.Mapper
public interface MyMapper {

//    @Select("Select puid from PPom_USER where puser_id = #{puser_id,jdbcType=VARCHAR}")
//    public String selectUserUid(@Param("puser_id")String puser_id);
//
//    @Select("SELECT  count(*) FROM PWORKSPACEOBJECT t_01 , PEPMTASK t_02 WHERE ( ( ( ( ( t_02.pstate_value = 4 OR ( t_02.pstate_value >= 128 ) ) AND t_02.rresponsible_partyu = #{rresponsible_partyu,jdbcType=VARCHAR} ) AND t_01.pobject_type NOT IN  ('EPMNotifyTask', 'EPMPerformSignoffTask' ) ) AND ( t_01.pobject_type = 'EPMRouteTask' OR  NOT EXISTS ( SELECT  DISTINCT t_03.puid FROM PEPMTASK t_03 WHERE ( ( t_03.pstate_value = 4 OR ( t_03.pstate_value >= 128 ) ) AND ( t_03.rparent_tasku = t_02.puid ) ) ) ) ) AND ( t_01.puid = t_02.puid ) )")
//    public int selectCount(@Param("rresponsible_partyu")String rresponsible_partyu);

//    @Select("select VLA_847_3 from PFOLDER where puid =(SELECT PVAlu_0 FROM PCONTENTS WHERE PUID = (SELECT PUID from PWORKSPACEOBJECT where POBJECT_NAME like '%#{id}%' and Pobject_type = 'TaskInbox') and rownum=1)")
//    public int selectCount(@Param("id")String id);


    @Select("select t1.puid,t1.pcid,t1.pname,t1.pklassi,t2.pval_0 as parent from PSMLB0 t1 left join PPARENT t2 on t1.puid = t2.puid")
    public List<FieldBean> selectTree();

    @Select({"select b.punct,c.pname from PSMLB0 a inner join PSMLB1 b on a.puid = b.rtag_to_headeru inner join PUNCT_DICT c on b.punct = c.punct where a.pcid = #{pcid}"})
    public List<ClassFieldBean> selectClassField(String pcid);

    @Select("${_parameter}")
    List<Map<String, String>> selectClassData(String sql);

    @Select({"select t1.punct ,t2.pname,t2.pref_options,t1.pdbindex from PSMLB1 t1" +
            " inner join (SELECT pref_options,punct,pname  FROM PPOM_OBJECT a1, PUNCT_DICT a2  WHERE a1.puid=a2.puid AND  a2.puid IN (SELECT t_02.puid FROM PSMLB1 t_01 , PUNCT_DICT t_02 WHERE ( t_01.rtag_to_headeru IN  ( SELECT t_03.puid FROM PSMLB0 t_03 WHERE ( t_03.pcid = #{pcid} ) ) AND ( t_01.punct = t_02.punct ) ))) t2" +
            " on t1.punct = t2.punct" +
            " where t1.rtag_to_headeru= (select puid from PSMLB0 where pcid = #{pcid}) order by punct ASC"})
    public List<SqlFieldBean> selectFields(String pcid);

}
