Fixiaobai
2023-09-07 e29f147aab5b0b0b794d611b522b67b94423e3cf
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<?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.InspectionMapper">
    <select id="selectInspectsList" resultType="map">
        select i.id,
        i.code icode,
        i.type type,
        DATE_FORMAT(`form_time`,'%Y-%m-%d') form_time,
        supplier,
        im.code mcode,
        im.name,
        specifications,
        unit,
        num,
        DATE_FORMAT(i.`create_time`,'%Y-%m-%d') as create_time,
        u.name userName,
        inspection_status,
        DATE_FORMAT(i.`start_time`,'%Y-%m-%d') as start_time,
        DATE_FORMAT(i.`end_time`,'%Y-%m-%d') as end_time
        from lims_laboratory.inspection i
        join lims_laboratory.user u on i.user_id = u.id
        join lims_laboratory.inspection_material im on i.id = im.inspection_id
        where i.state=1
        <if test="message!=null">
            and (i.code like concat('%', #{message}, '%')
            or im.name like concat('%', #{message}, '%'))
        </if>
    </select>
 
    <!--计算检验的检验单数量-->
    <select id="seleCountIns" resultType="java.lang.Integer">
        select count(id)
        from lims_laboratory.inspection
        where state = 1
          and inspection_status in (0, 1)
    </select>
 
    <!--计算未检验的检验单数量-->
    <select id="seleCountUnIns" resultType="java.lang.Integer">
        select count(id)
        from lims_laboratory.inspection
        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>
    <select id="getInspectionMaterials" resultType="java.util.Map">
 
    </select>
    <select id="selectImAndUserName" resultType="java.util.Map">
        SELECT
            im.`code`,
            im.`name`,
            i.`code` iCode,
            i.create_time iCreateTime,
            im.specifications_id specificationsId,
            im.specifications specifications,
            u.`name` uName
        FROM
            inspection i,
            inspection_material im,
            `user` u
        WHERE
            i.id = im.inspection_id
          AND i.user_id=u.id
          AND i.id=#{id}
    </select>
</mapper>