Fixiaobai
2023-09-04 dd2554435b9ced61e2a6a06627145fca3bf2685b
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
<?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.QualificationRateStatisticsMapper">
    <select id="selectSupplierByCondition" resultType="java.util.Map">
        SELECT i.id,
        i.type,
        im.`name`,
        im.supplier,
        i.inspection_status inspectionStatus,
        i.start_time startTime,
        i.end_time endTime
        FROM inspection i
        INNER JOIN inspection_material im ON i.id = im.inspection_id
        where (i.state = 1  and im.state=1)
        <if test="dto.beginDate!=null and dto.endDate!=null">
            and DATE_FORMAT( i.end_time, '%Y-%m-%d' ) BETWEEN #{dto.beginDate}
            AND #{dto.endDate}
            AND DATE_FORMAT( i.start_time, '%Y-%m-%d' )>= #{dto.beginDate}
        </if>
        <if test="dto.type!=null">
            and i.type=#{dto.type}
        </if>
        <if test="dto.supplier!=null and dto.supplier!=''">
            and im.supplier=#{dto.supplier}
        </if>
        <if test="dto.sample!=null and dto.sample!=''">
            and im.name=#{dto.sample}
        </if>
        <if test="dto.code!=null and dto.code!=''">
            and im.code=#{dto.code}
        </if>
    </select>
    <select id="selectProjectionsByCondition" resultMap="ImInfoMap">
        SELECT
        im.id imId,
        im.`name` imName,
        i.inspection_status inspectionStatus,
        i.start_time startTime,
        i.end_time endTime,
        ipr.id iprId,
        ipr.`name` iprName,
        ipr.test_state testState,
        im.code imCode,
        i.type type
        FROM
        inspection i,
        inspection_material im,
        inspection_product ipr
        WHERE
        i.id = im.inspection_id
        AND im.id = ipr.inspection_material_id
        AND  i.state = 1
        AND im.state = 1
        AND ipr.state = 1
        AND i.inspection_status is NOT NULL
        AND ipr.test_state is not null
        AND ipr.test_state = 0
        <if test="dto.beginDate!=null and dto.endDate!=null">
            and DATE_FORMAT( i.end_time, '%Y-%m-%d' ) BETWEEN #{dto.beginDate}
            AND #{dto.endDate}
            AND DATE_FORMAT( i.start_time, '%Y-%m-%d' )>= #{dto.beginDate}
        </if>
        <if test="dto.type!=null">
            and i.type=#{dto.type}
        </if>
        <if test="dto.supplier!=null and dto.supplier!=''">
            and im.supplier=#{dto.supplier}
        </if>
        <if test="dto.sample!=null and dto.sample!=''">
            and im.name=#{dto.sample}
        </if>
        <if test="dto.code!=null and dto.code!=''">
            and im.code=#{dto.code}
        </if>
    </select>
    <select id="selectProjection" resultMap="ImInfoMap">
        SELECT
        im.id imId
        FROM
        inspection i,
        inspection_material im,
        inspection_product ipr
        WHERE
        i.id = im.inspection_id
        AND im.id = ipr.inspection_material_id
        AND  i.state = 1
        AND im.state = 1
        AND ipr.state = 1
        <if test="dto.beginDate!=null and dto.endDate!=null">
            and DATE_FORMAT( i.end_time, '%Y-%m-%d' ) BETWEEN #{dto.beginDate}
            AND #{dto.endDate}
            AND DATE_FORMAT( i.start_time, '%Y-%m-%d' )>= #{dto.beginDate}
        </if>
        <if test="dto.type!=null">
            and i.type=#{dto.type}
        </if>
        <if test="dto.supplier!=null and dto.supplier!=''">
            and im.supplier=#{dto.supplier}
        </if>
        <if test="dto.sample!=null and dto.sample!=''">
            and im.name=#{dto.sample}
        </if>
        <if test="dto.code!=null and dto.code!=''">
            and im.code=#{dto.code}
        </if>
        and im.code in
        <foreach collection="list" item="l" open="(" close=")" separator="," >
            #{l.code}
        </foreach>
        and im.name in
        <foreach collection="list" item="l" open="(" close=")" separator=",">
            #{l.name}
        </foreach>
    </select>
    <select id="selectTestSamp" resultType="java.util.Map">
        SELECT i.id,
        i.type,
        im.`name`,
        im.supplier,
        i.inspection_status inspectionStatus,
        i.start_time startTime,
        i.end_time endTime
        FROM inspection i
        INNER JOIN inspection_material im ON i.id = im.inspection_id
        where (i.state = 1 and im.state=1)
        <if test="dto.beginDate!=null and dto.endDate!=null">
           and  DATE_FORMAT( i.end_time, '%Y-%m-%d' ) BETWEEN #{dto.beginDate}
            AND #{dto.endDate}
            AND DATE_FORMAT( i.start_time, '%Y-%m-%d' )>= #{dto.beginDate}
        </if>
        <if test="dto.type!=null">
            and i.type=#{dto.type}
        </if>
        <if test="dto.supplier!=null and dto.supplier!=''">
            and im.supplier=#{dto.supplier}
        </if>
        <if test="dto.sample!=null and dto.sample!=''">
            and im.name=#{dto.sample}
        </if>
        <if test="dto.code!=null and dto.code!=''">
            and im.code=#{dto.code}
        </if>
    </select>
    <select id="getSampleOptions" resultType="java.util.Map">
        SELECT
            i.id,
            i.type,
            im.`name` name,
            im.supplier,
            i.inspection_status inspectionStatus,
            i.start_time startTime,
            i.end_time endTime,
            im.`code` code
        FROM
            inspection i
                INNER JOIN inspection_material im ON i.id = im.inspection_id
        WHERE
            ( i.state = 1  AND im.state = 1 )
    </select>
 
    <resultMap id="ImInfoMap" type="com.yuanchu.limslaboratory.pojo.ImInfo">
        <result property="imId" column="imId"/>
        <result property="imCode" column="imCode"/>
        <result property="imName" column="imName"/>
        <result property="startTime" column="startTime"/>
        <result property="endTime" column="endTime"/>
        <result property="inspectionStatus" column="inspectionStatus"/>
        <collection property="iprInfos" ofType="iprInfo">
            <result property="iprId" column="iprId"/>
            <result property="iprName" column="iprName"/>
            <result property="testState" column="testState"/>
        </collection>
    </resultMap>
</mapper>