zouyu
2024-03-15 81f615750dec3e3aba4b607033609a1f3c7fc7fd
inspect-server/src/main/resources/mapper/InsSampleMapper.xml
@@ -40,4 +40,61 @@
        appointed,create_user,update_user,
        create_time,update_time
    </sql>
    <select id="findInsSampleAndOrder" resultType="com.yuanchu.mom.vo.InsOrderPlanVO">
        SELECT DISTINCT
            io.entrust_code,
            io.type,
            tempA.id,
            tempA.sample,
            tempA.sample_code,
            tempA.send_time,
            tempA.appointed,
            tempA.ins_state,
            tempA.ins_result,
            tempA.user_id,
            tempA.ins_order_id,
            tempA.sample_user_id,
            ipr.son_laboratory
        FROM
            (
                SELECT
                    temp.*
                FROM
                    (
                        SELECT
                            isa.id,
                            isa.sample,
                            isa.sample_code,
                            isa.send_time,
                            isa.appointed,
                            isa.ins_state,
                            isa.ins_result,
                            isu.user_id,
                            isa.ins_order_id,
                            isu.id as sample_user_id
                        FROM
                            ins_sample isa
                                LEFT JOIN ins_sample_user isu ON isa.id = isu.ins_sample_id
                    ) AS temp
                WHERE
                    temp.user_id = #{ew.userId}
                   OR ( SELECT COUNT(*) FROM ins_sample_user WHERE ins_sample_id = temp.id ) = 0
            ) AS tempA
                LEFT JOIN ins_order io ON tempA.ins_order_id = io.id
                LEFT JOIN ins_product ipr ON tempA.id = ipr.ins_sample_id
        WHERE
          io.state = #{ew.state}
          AND ipr.state = 1
          AND ipr.son_laboratory = #{ew.childrenLaboratory}
          <if test="ew.insState!=null and ew.insState!=''">
              AND tempA.ins_state = #{ew.insState}
          </if>
          <if test="ew.sampleName!=null and ew.sampleName!=''">
              AND tempA.sample like concat('%',#{ew.sampleName},'%')
          </if>
          <if test="ew.viewSelf==true">
              AND tempA.sample_user_id is not null
          </if>
          ORDER BY io.type DESC
    </select>
</mapper>