<?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.zt.plat.module.qms.business.bus.dal.mapper.BusinessAssayTaskDataMapper">

    <!--
        一般情况下，尽可能使用 Mapper 进行 CRUD 增删改查即可。
        无法满足的场景，例如说多表关联查询，才使用 XML 编写 SQL。
        代码生成器暂时只生成 Mapper XML 文件本身，更多推荐 MybatisX 快速开发插件来生成查询。
        文档可见：https://www.iocoder.cn/MyBatis/x-plugins/
     -->
     
     <select id="selectUnAssayTaskGroupList" resultType="com.zt.plat.module.qms.business.bus.controller.vo.BusinessAssayTaskDataGroupRespVO">
         SELECT
            tbatd.CFG_ASY_MTHD_ID AS configAssayMethodId,
            tcam.NAME AS configAssayMethodName,
            COUNT(tbatd.ID) AS sampleTaskCount
        FROM
            T_BSN_ASY_TSK_DAT tbatd
        LEFT JOIN T_CFG_ASY_MTHD tcam ON
            tbatd.CFG_ASY_MTHD_ID = tcam.ID
        WHERE
            tbatd.IS_ASN_TSKD = 0
            AND tbatd.IS_RPOD = 0
            AND tbatd.DELETED = 0
      <if test="reqVO.sampleFlowNodeKey != null and reqVO.sampleFlowNodeKey != ''">
            AND tbatd.SMP_FLW_NDE_KY = #{reqVO.sampleFlowNodeKey}
      </if>
      <if test="reqVO.sampleFlowNodeTime[0] != null and reqVO.sampleFlowNodeTime[0] != null">
            AND tbatd.SMP_FLW_NDE_TM #{reqVO.sampleFlowNodeTime[0]} and #{reqVO.sampleFlowNodeTime[1]}
      </if>
        GROUP BY
            tbatd.CFG_ASY_MTHD_ID,
            tcam.NAME
     </select>
     
     <select id="selectUnAuditTaskGroupList" resultType="com.zt.plat.module.qms.business.bus.controller.vo.BusinessAssayTaskDataGroupRespVO">
         SELECT
            tbatd.CFG_ASY_MTHD_ID AS configAssayMethodId,
            tbatd.ASY_TP AS  assayType,
            tcam.NAME AS configAssayMethodName,
            COUNT(tbatd.ID) AS sampleTaskCount
        FROM
            T_BSN_ASY_TSK_DAT tbatd
        LEFT JOIN T_CFG_ASY_MTHD tcam ON
            tbatd.CFG_ASY_MTHD_ID = tcam.ID
        WHERE
            tbatd.SMP_FLW_NDE_KY = 'flw_fx_receive'
            AND tbatd.DELETED = 0
        GROUP BY
            tbatd.CFG_ASY_MTHD_ID,
            tbatd.ASY_TP,
            tcam.NAME
     </select>

</mapper>