<?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.ruoyi.system.mapper.visit.dr.VisitDrTaskExtMapper">
  <resultMap id="BaseResultMap" type="com.ruoyi.system.domain.visit.dr.ext.VisitDrTaskExt">
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="title" jdbcType="VARCHAR" property="title" />
    <result column="choose_type" jdbcType="VARCHAR" property="chooseType" />
    <result column="check_time" jdbcType="VARCHAR" property="chooseTime" />
    <result column="extfield_one" jdbcType="VARCHAR" property="result" />
    <result column="choose_form" jdbcType="VARCHAR" property="chooseForm" />
  </resultMap>
  <resultMap id="DiyMap" type="com.ruoyi.system.domain.visit.dr.ext.CompanyModelDengji">

    <result column="dengji" jdbcType="VARCHAR" property="dengJi" />
    <result column="count" jdbcType="VARCHAR" property="count" />

  </resultMap>
    <resultMap id="DiyVisitDrMap" type="com.ruoyi.system.domain.visit.dr.ext.VisitDrParams">

        <result column="rule_id" jdbcType="VARCHAR" property="ruleId" />
        <result column="task_id" jdbcType="VARCHAR" property="taskId" />
        <result column="company_name" jdbcType="VARCHAR" property="companyName" />
        <result column="is_ok" jdbcType="VARCHAR" property="isOk" />

    </resultMap>


  <select id="selectList" parameterType="java.lang.String" resultMap="BaseResultMap" >
    select a.id, b.title,b.choose_type,a.check_time,a.extfield_one,b.choose_form
    from visit_dr_task a left JOIN visit_dr_rule b on b.id=a.rule_id
    where a.is_valid='1'
    ORDER BY a.rule_id desc
  </select>
<select id="selectDetail"  parameterType="java.lang.String" resultMap="BaseResultMap" >
   select a.id, b.title,b.choose_type,a.check_time,a.extfield_one,b.choose_form
    from visit_dr_task a left JOIN visit_dr_rule b on b.id=a.rule_id
    where a.id=#{taskId,jdbcType=VARCHAR} and a.is_valid='1'
</select>


  <select id="getCompanySupervisionModel"  parameterType="java.lang.String" resultMap="DiyMap" >
 select zh_credit_level as dengji,COUNT(zh_credit_level) as count from grid_company GROUP BY zh_credit_level
</select>
    <select id="getCompanyCountByYear"  parameterType="java.lang.String" resultType="java.lang.Integer" >
SELECT count(*) from grid_company
where extfield_one like CONCAT(CONCAT('%',#{chooseFormType,jdbcType=VARCHAR}),'%')
</select>
<select id="getVisitDrCheckList"  parameterType="java.lang.String"   resultMap="DiyVisitDrMap">
    select d.id as rule_id,c.id as task_id,a.company_name, b.extfield_ten as is_ok
    from visit_dr_task_company a
    LEFT JOIN grid_company b on a.company_id=b.id
    LEFT JOIN visit_dr_task c on a.task_id=c.id
    LEFT JOIN visit_dr_rule d on c.rule_id=d.id
</select>
</mapper>