<?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="com.dayou.mapper.BusinessProductionPerformanceMapper">

   <select id="getMajorDetail" parameterType="com.dayou.vo.BusinessProductionPerformanceVO" resultType="com.dayou.entity.BusinessProductionPerformance">
       select bpp.*,
       ( CASE mp.production WHEN 'STATEMENT' THEN '价值意见书' WHEN 'REPORT' THEN '报告' ELSE '复评函' END ) AS productionType,
       u.NAME AS principal ,
       mp.id as pId,
       mp.name as productionName from major_production mp  left join
       (select * from business_production_performance where  deleted = 0
       <if test="performance!=null and performance.checkLoop!=null and performance.checkLoop!='' ">
           and check_loop = #{performance.checkLoop}
       </if>
      ) bpp
            on mp.id  = bpp.production_id
        left join major m on m.id = mp.major_id
           left join user u on u.id = m.principal_id
        where mp.deleted = 0 and m.deleted = 0 and m.id = #{performance.majorId} and mp.report_no = #{performance.productionNo}

   </select>

    <!--根据业务类型,产品id及checkLoop获取质检信息-->
    <select id="getProductionPerformance" resultType="com.dayou.entity.BusinessProductionPerformance">
        SELECT id, fatal_mistake, hard_mistake, normal_mistake, reason
        FROM business_production_performance
        WHERE production_id = #{productionId}
        AND check_loop = #{CheckLoop}
        AND business_type = #{BusinessType}
    </select>
</mapper>
