Fixiaobai
2023-09-06 8abe275e36823f1065300af45e1f7a9a68f549a7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?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.ProductMapper">
    <insert id="addProduct">
        insert
        product (name,father,unit,state,create_time,update_time,version,specifications_id)
        value (#{name},#{father},#{unit},1,#{createTime},#{updateTime},#{version},#{specifications_id})
    </insert>
    <select id="selectProductByMaterialId" resultType="Map">
        select p.name, unit, required, internal
        from lims_laboratory.product p,
             lims_laboratory.specifications sp,
             lims_laboratory.standard st
        where specifications_id = sp.id
          and standard_id = st.id
          and material_id = #{materialId}
    </select>
 
 
    <!--展示该型号下的检验项目要求-->
    <resultMap id="pageProductInformationMap" type="map">
        <id property="name" column="father"/>
        <collection property="children" resultMap="pageProductInformationTowMap" javaType="List"/>
    </resultMap>
    <resultMap id="pageProductInformationTowMap" type="map">
        <id property="id" column="id"/>
        <result property="name" column="name"/>
        <result property="unit" column="unit"/>
        <result property="required" column="required"/>
        <result property="internal" column="internal"/>
        <result property="version" column="version"/>
    </resultMap>
 
    <select id="pageProductInformation" resultMap="pageProductInformationMap">
        select id,
               name,
               father,
               unit,
               required,
               internal,
               version
        from lims_laboratory.product
        where state = 1
          and specifications_id = #{specificationsId}
          and version = #{version}
        ORDER BY product.`create_time` DESC
    </select>
 
    <select id="deleteList">
        update lims_laboratory.product
        set state=0
        where id in (${ids})
    </select>
 
    <!--展示该型号下的检验项目要求-选择版本-->
    <select id="chooseVersion" resultType="java.lang.Integer">
        select distinct version
        from lims_laboratory.product
        where state = 1
          and specifications_id = #{specificationsId}
        order by version desc
    </select>
 
    <!--查询该型号下的所有试验项目(父类)-->
    <resultMap id="chooseProjects" type="map">
        <id property="name" column="father"/>
        <collection property="children" resultMap="chooseProjectTowMap" javaType="List"/>
    </resultMap>
    <resultMap id="chooseProjectTowMap" type="map">
        <id property="id" column="id"/>
        <result property="name" column="name"/>
    </resultMap>
    <select id="chooseProject" resultMap="chooseProjects">
        select id, father, name
        from lims_laboratory.product
        where state = 1
          and specifications_id = #{modelId}
    </select>
 
    <!--根据项目父类,型号id,版本查询二级详情-->
    <select id="selFath" resultMap="pageProductInformationMap">
        select id,
               name,
               father,
               unit,
               required,
               internal,
               version
        from lims_laboratory.product
        where state = 1
          and specifications_id = #{specificationId}
          and version = #{version}
          and father = #{exper}
    </select>
 
    <!--根据项目父类为空,项目名,型号id,版本查询-->
    <select id="selNam" resultType="java.util.Map">
        select id,
               name,
               unit,
               required,
               internal,
               version
        from lims_laboratory.product
        where state = 1
          and specifications_id = #{specificationId}
          and version = #{version}
          and name = #{exper}
          and father is null
    </select>
</mapper>