<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.countrygarden.bi.main.dao.common.CommCopyMapper">
  <resultMap id="SearchOneResultMap" type="cn.com.countrygarden.bi.main.service.project.impl.vo.OneProject">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="organName" jdbcType="VARCHAR" property="organName" />
    <result column="regionName" jdbcType="VARCHAR" property="regionName"/>
    <result column="contractorName" jdbcType="VARCHAR" property="contractorName" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="cooperationfName" jdbcType="VARCHAR" property="cooperationfName" />
    <result column="statusName" jdbcType="VARCHAR" property="statusName" />
    <result column="contractArea" jdbcType="VARCHAR" property="contractArea" />
    <result column="saturation" jdbcType="VARCHAR" property="saturation" />
    <result column="city" jdbcType="VARCHAR" property="city" />
    <result column="joint" jdbcType="VARCHAR" property="joint" />
    <result column="jointDuty" jdbcType="VARCHAR" property="jointDuty" />
    <result column="jointRightName" jdbcType="VARCHAR" property="jointRightName" />
    <result column="corpTypeName" jdbcType="VARCHAR" property="corpTypeName" />
    <result column="significanceName" jdbcType="VARCHAR" property="significanceName" />
    <result column="demandName" jdbcType="VARCHAR" property="demandName" />
    <result column="propertyFee" jdbcType="VARCHAR" property="propertyFee" />
    <result column="messageFee" jdbcType="VARCHAR" property="messageFee" />
     <result column="isSubmit" jdbcType="VARCHAR" property="isSubmit" />
       <result column="competitor" jdbcType="VARCHAR" property="competitor" />
        <result column="opinion" jdbcType="VARCHAR" property="opinion" />
         <result column="callFile" jdbcType="VARCHAR" property="callFile" />
           <result column="callOrganization" jdbcType="VARCHAR" property="callOrganization" />
            <result column="callEnvironmen" jdbcType="VARCHAR" property="callEnvironmen" />
              <result column="businessName" jdbcType="VARCHAR" property="businessName" />
              <result column="projectClass" jdbcType="VARCHAR" property="projectClass" />
                 <result column="projectPlan" jdbcType="VARCHAR" property="projectPlan" />
                   <result column="projectPlanCode" jdbcType="VARCHAR" property="projectPlanCode" />
                     <result column="remark" jdbcType="VARCHAR" property="remark" />
                       <result column="warningLight" jdbcType="VARCHAR" property="warningLight" />
                  <result column="isManage" jdbcType="INTEGER" property="isManage" /> 
                   <result column="ruserCode" jdbcType="VARCHAR" property="ruserCode" /> 
                        <result column="commCode" jdbcType="VARCHAR" property="commCode" /> 
                         <result column="projectClassCode" jdbcType="VARCHAR" property="projectClassCode" />
                           <result column="contractorCode" jdbcType="VARCHAR" property="contractorCode" />
                          
                        
  </resultMap>
  
  <select id = "selectByOneId" resultMap="SearchOneResultMap">
  	SELECT
  		c.id,
		o.`name` organName, 
		r.region_name regionName, 
		r.user_code ruserCode,
		c.contractor_name contractorName,
		c.contractor_code contractorCode,
		c.`name`, 
		c.cooperationf_name cooperationfName,
		sta.`name` statusName,
		c.contract_area contractArea,
		c.saturation saturation,
		c.comm_code commCode,
		c.city, 
		c.joint,
		c.joint_duty jointDuty, 
		jr.`name` jointRightName, 
		cy.`name` corpTypeName, 
		s.`name` significanceName,
		de.`name` demandName, 
		pf.`name` propertyFee, 
		mf.`name` messageFee,
		sub.`name` isSubmit,
		comp.`name` competitor, 
		opi.`name` opinion,
		cf.`name` callFile,
		co.`name` callOrganization,
		ce.`name` call_environmen,
		bus.`name` businessName,
		pclass.`name` projectClass,
		pclass.`code` projectClassCode, 
		pplan.`name` projectPlan, 
		pplan.`code` projectPlanCode,
		c.remark,
		c.warning_light warningLight
		
	FROM
		comm_copy c
	LEFT JOIN organ o ON o.organ_code = c.organ_id
	LEFT JOIN organ_region ore ON ore.organ_code = c.organ_id
	LEFT JOIN region r ON r.region_code = ore.region_code
	LEFT JOIN project_joint_plan bus ON c.business_type = bus.id
	LEFT JOIN project_joint_plan sta ON c.`status` =  sta.id
	LEFT JOIN project_joint_plan jr ON c.joint_right = jr.id
	LEFT JOIN project_joint_plan cy ON c.corp_type = cy.id
	LEFT JOIN project_joint_plan s ON s.id = c.significance
	LEFT JOIN project_joint_plan de ON de.id = c.demand
	LEFT JOIN project_joint_plan pf ON pf.id = c.property_fee
	LEFT JOIN project_joint_plan mf ON mf.id = c.message_fee
	LEFT JOIN project_joint_plan sub ON sub.id = c.is_submit
	LEFT JOIN project_joint_plan comp ON comp.id = c.competitor
	LEFT JOIN project_joint_plan opi ON opi.id = c.opinion
	LEFT JOIN project_joint_plan cf ON cf.id = c.call_file
	LEFT JOIN project_joint_plan co ON co.id = c.call_organization
	LEFT JOIN project_joint_plan ce ON ce.id = c.call_environmen
	LEFT JOIN project_class pclass ON pclass.`code` = c.project_class_code
	LEFT JOIN project_plan_one pplan ON pplan.`code` = c.project_plan_code

	WHERE c.id = #{id}
  </select>
</mapper>