XiaoRuby
2023-08-23 924d018e6e6f15effbd272cead5dff67cd3b93a5
inspection-server/src/main/resources/mapper/InspectionMapper.xml
@@ -42,4 +42,141 @@
        where state = 1
          and inspection_status is null
    </select>
    <!--获取检验单总数-->
    <select id="getcount" resultType="java.lang.Integer">
        select count(id)
        from lims_laboratory.inspection
        where state = 1
    </select>
    <!--检验结论,检验数量-->
    <select id="qualified" resultType="java.lang.Long">
        select count(id)
        from lims_laboratory.inspection
        where state = 1
        and type = 0
        <if test="b!=null ">
            and inspection_status = #{b}
        </if>
        <if test="b==null">
            and inspection_status is null
        </if>
    </select>
    <!--计算原材料与成品的合格率-->
    <select id="getResultNum" resultType="java.util.Map">
        select inspection_status result,
               count(id)         num
        from lims_laboratory.inspection
        where state = 1
        group by result
        order by num desc
    </select>
    <!--计算原材料检验单总数-->
    <select id="getallmater" resultType="java.lang.Integer">
        select count(id)
        from lims_laboratory.inspection
        where state = 1
          and type = 0
    </select>
    <!--计算成品检验单总数-->
    <select id="getallfin" resultType="java.lang.Integer">
        select count(id)
        from lims_laboratory.inspection
        where state = 1
          and type in (1, 2)
    </select>
    <!--计算原材料合格率-->
    <select id="qualifiedfin" resultType="java.lang.Long">
        select count(id)
        from lims_laboratory.inspection
        where state = 1
        and type in (1, 2)
        <if test="i!=null ">
            and inspection_status = #{i}
        </if>
        <if test="i==null">
            and inspection_status is null
        </if>
    </select>
    <!--查询该日期的原材料检验数量-->
    <select id="getMaterByDay" resultType="java.lang.Integer">
        select count(id)
        from lims_laboratory.inspection
        where state = 1
          and type = 0
          and create_time = #{time}
    </select>
    <!--查询该日期的成品检验数量-->
    <select id="getFinByDay" resultType="java.lang.Integer">
        select count(id)
        from lims_laboratory.inspection
        where state = 1
          and type in (1, 2)
          and create_time = #{time}
    </select>
    <!--查询该日期的原材料合格数量-->
    <select id="getOkMaterByDay" resultType="java.lang.Long">
        select count(id)
        from lims_laboratory.inspection
        where state = 1
          and type = 0
          and inspection_status = 1
          and end_time = #{time}
    </select>
    <!--查询该日期的成品合格数量-->
    <select id="getOkFinByDay" resultType="java.lang.Long">
        select count(id)
        from lims_laboratory.inspection
        where state = 1
          and type in (1, 2)
          and inspection_status = 1
          and end_time = #{time}
    </select>
    <!--查询该月的原材料检验数量-->
    <select id="getMaterByMonth" resultType="java.lang.Integer">
        select count(id)
        from lims_laboratory.inspection
        where state = 1
          and type = 0
          and DATE_FORMAT(create_time, '%Y-%m') = #{monthofYear}
    </select>
    <!--查询该月的成品检验数量-->
    <select id="getFinByMonth" resultType="java.lang.Integer">
        select count(id)
        from lims_laboratory.inspection
        where state = 1
          and type in (1, 2)
          and DATE_FORMAT(create_time, '%Y-%m') = #{monthofYear}
    </select>
    <!--查询该月的原材料合格率-->
    <select id="getOkMaterByMonth" resultType="java.lang.Long">
        select count(id)
        from lims_laboratory.inspection
        where state = 1
          and type = 0
          and inspection_status = 1
          and DATE_FORMAT(end_time, '%Y-%m') = #{monthofYear}
    </select>
    <!--查询该月的成品合格率-->
    <select id="getOkFinByMonth" resultType="java.lang.Long">
        select count(id)
        from lims_laboratory.inspection
        where state = 1
          and type in (1, 2)
          and inspection_status = 1
          and DATE_FORMAT(end_time, '%Y-%m') = #{monthofYear}
    </select>
</mapper>