Fixiaobai
2023-09-05 c9da1b0da1178911e383ddcaebecd1e088fa6004
inspection-server/src/main/resources/mapper/InspectionProductMapper.xml
@@ -1,4 +1,51 @@
<?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.yuanchu.limslaboratory.mapper.InspectionProductMapper">
    <!--根据检验单id查询检验项目的检验结果-->
    <select id="getresult" resultType="java.lang.Integer">
        select test_state
        from lims_laboratory.inspection_product
        where state = 1
          and inspection_material_id = (select id from lims_laboratory.inspection_material where inspection_id = #{id})
    </select>
    <!--根据检验样品id作废检验项目-->
    <update id="updat">
        update lims_laboratory.inspection_product
        set state=0
        where inspection_material_id = #{id}
    </update>
    <!--计算已检验项目数量-->
    <select id="seleCountInspro" resultType="java.lang.Integer">
        select count(id)
        from lims_laboratory.inspection_product
        where state = 1
          and test_state in (0, 1)
    </select>
    <!--计算未检验项目数量-->
    <select id="seleCountUnInspro" resultType="java.lang.Integer">
        select count(id)
        from lims_laboratory.inspection_product
        where state = 1
          and test_state is null
    </select>
    <!--获取检验项目,设备,检验开始时间,执行人,检验结束时间-->
    <select id="getResultNum" resultType="java.util.Map">
        select ip.name,
               equipment_name                      instrumentname,
               DATE_FORMAT(start_time, '%Y-%m-%d') startTime,
               user.name                           checkname,
               DATE_FORMAT(end_time, '%Y-%m-%d')   endTime
        from lims_laboratory.inspection_product ip
                 left join lims_laboratory.inspection_material on ip.inspection_material_id = inspection_material.id
                 left join lims_laboratory.inspection i on inspection_material.inspection_id = i.id
                 left join lims_laboratory.instrument on ip.instrument_id = instrument.id
                 left join lims_laboratory.user on ip.user_id = user.id
        where ip.state = 1
          and test_state is null
        order by start_time
        limit 4
    </select>
</mapper>