package cn.com.countrygarden.bi.main.dao.twerp.hm;

import cn.com.countrygarden.bi.main.dto.advise.ProjectListVO;
import cn.com.countrygarden.bi.main.dto.advise.RegionListVO;
import cn.com.countrygarden.bi.main.model.BigholderRightManager;
import cn.com.countrygarden.bi.main.model.twerp.ErpCommunity;
import cn.com.countrygarden.bi.main.model.twerp.hm.TbSysOrgan;
import com.github.pagehelper.PageRowBounds;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;
import java.util.List;
import java.util.Map;


@Repository
@Transactional
public interface TbSysOrganMapper {
	TbSysOrgan findByOrganCode(String organCode);

	TbSysOrgan findByUserCode(String userCode);

	TbSysOrgan findByOrganName(String organName);

	TbSysOrgan findByOrganNameNew(String organName);

	List<TbSysOrgan> findAllActive();
	List<TbSysOrgan> selectOrganAll();

	/**
	 * 查询所有的纯案场或者案场常规混合的区域
	 *
	 * @param organCode
	 * @return
	 */
	List<TbSysOrgan> findCaseFieldOrgans(@Param("organCode") String organCode);

	//有效的绩效区域
	List<TbSysOrgan> selectPerformanceArea();

	//所有的绩效区域
	List<TbSysOrgan> selectPerformanceAllArea();

	List<TbSysOrgan> selectPerformanceCompany();

	List<TbSysOrgan> selectPerformanceAll();

	List<TbSysOrgan> selectAll();

	List<ErpCommunity> findErpCommunityByOrgans(@Param("area") String area);

	/**
	 * 获取区域(不带条件)
	 * @param
	 * @return
	 */
	List<BigholderRightManager> getAreas();

	List<String> getAreasOnly();

	/**
	 * 获取区域(带条件)
	 * @param
	 * @return
	 */
	List<BigholderRightManager> getAreasWithCondition(@Param("area") String area,@Param("areaIds") List<String> areaIds,PageRowBounds pageRowBounds);

	/**
	 * 获取负责人
	 * @param pageRowBounds
	 * @param
	 * @return
	 */
	List<Map<String, String>> getUsers(@Param("user") String user, PageRowBounds pageRowBounds);

	/**
	 * 获取用户的区域
	 * @param pageRowBounds
	 * @param
	 * @return
	 */
	List<RegionListVO> findArea(@Param("organCode") String organCode,@Param("userCode") String userCode);
	/**
	 * 获取用户的项目
	 * @param pageRowBounds
	 * @param
	 * @param organCode
	 * @return
	 */
	List<ProjectListVO>  findProject(@Param("organCode")String organCode, @Param("userCode") String userCode,@Param("commID") String commID,@Param("commIds")List<String> commIds,@Param("organs")List<String> organs);

	List<ProjectListVO>  findProjectBasicInfo(@Param("organCode")String organCode, @Param("userCode") String userCode,@Param("commID") String commID,@Param("commIds")List<String> commIds,@Param("organs")List<String> organs);

	List<ProjectListVO> findProjectBasicInfoSelect(@Param("startTime")String startTime,@Param("endTime")String endTime,@Param("ckRegionRole") boolean ckRegionRole, @Param("regionList") List<RegionListVO> regionList,@Param("orgCode") String orgCode);

	int findProjectBasicInfoCount();


	List<ProjectListVO> allAreas(@Param("commIds")List<String> commIds);

	List<ProjectListVO>  findProjectOrder(@Param("organCode")String organCode,@Param("organName")String organName,
										  @Param("commId")String commId,@Param("commName")String commName,@Param("userCode") String userCode,@Param("commIds")List<String> commIds,@Param("organs")List<String> organs);

	List<ProjectListVO>  findOrgCoProject(@Param("organCode")String organCode, @Param("userCode") String userCode,@Param("commID") String commID,@Param("commIds")List<String> commIds,@Param("organs")List<String> organs);

	List<ProjectListVO>  findOrgCot(@Param("organCode")String organCode, @Param("userCode") String userCode,@Param("commID") String commID,@Param("organs")List<String> organs);

	List<ProjectListVO>  findCommPro(@Param("organCode")String organCode, @Param("userCode") String userCode,@Param("commID") String commID,@Param("commIds")List<String> commIds);

	List<RegionListVO> findAreaBasicInfo(@Param("organCode") String organCode,@Param("commID") String commID,@Param("userCode") String userCode);

    List<ProjectListVO> findProjectBasicInfoAdddsq(@Param("commID") String commID);

    Integer findProjectBasicInfoSelectCount(@Param("startTime")String startTime,@Param("endTime")String endTime,@Param("ckRegionRole") boolean ckRegionRole, @Param("regionList") List<RegionListVO> regionList,@Param("orgCode") String orgCode);

    List<RegionListVO> findAreaSatisfied();

	List<ProjectListVO> findProjectSatisfied(@Param("organCode")String organCode, @Param("userCode") String userCode,@Param("commID") String commID,@Param("commIds")List<String> commIds,@Param("organs")List<String> organs,@Param("organName")String organName,
											 @Param("commName")String commName);

	List<ProjectListVO> findProjectSatisfiedDaoqu(@Param("organCode")String organCode,@Param("organName")String organName);

	List<ProjectListVO> findProjectSatisfiedDaoxiangmu(@Param("commID")String commID,@Param("organName")String organName,@Param("commName")String commName);

    List<ProjectListVO> findProjectBasicInfoCommIdNum(@Param("startTime")String startTime,@Param("endTime")String endTime, @Param("ckRegionRole") boolean ckRegionRole,  @Param("regionList") List<RegionListVO> regionList, @Param("orgCode") String orgCode);

	List<ProjectListVO> findProjectBenefitsZation(@Param("organCode")String organCode,@Param("commID") String commID,@Param("comtr") List<String> comtr);

	List<ProjectListVO>  findProjectBenefits(@Param("organCode")String organCode, @Param("userCode") String userCode,@Param("commID") String commID,@Param("commIds")List<String> commIds,@Param("organs")List<String> organs);

	List<RegionListVO> findAreaBene(@Param("organCode") String organCode,@Param("userCode") String userCode);

}
