zss
2023-09-24 7930d685829d7cc1e743e9a4cd9bd3924ad953fb
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
<?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.mom.mapper.RawInspectMapper">
    <!--清空原材料检验结论-->
    <update id="updById">
        update mom_ocean.raw_inspect
        set ins_state=0,
            ins_time=null,
            judge_state=null
        where id = #{rawInspectId}
    </update>
    <select id="selCountRaw" resultType="java.lang.Integer">
        select count(id)
        from mom_ocean.raw_inspect
        where state=1
        and ins_state=1
        and judge_state=#{judgeState}
        <if test="begin != null and begin!=''">
            and raw_inspect.create_time &gt;= #{begin}
        </if>
        <if test="end != null and end!=''">
            and raw_inspect.create_time &lt;= #{end}
        </if>
    </select>
    <select id="seAllCount" resultType="java.lang.Long">
        select count(id)
        from mom_ocean.raw_inspect
        where state=1
        <if test="begin != null and begin!=''">
            and raw_inspect.create_time &gt;= #{begin}
        </if>
        <if test="end != null and end!=''">
            and raw_inspect.create_time &lt;= #{end}
        </if>
    </select>
 
    <!--分页查询原材料检验单列表-->
    <select id="selectRawInspectsList" resultType="java.util.Map">
        select id,
        DATE_FORMAT(form_time, '%Y-%m-%d') formTime,
        code,
        name,
        specifications,
        unit,
        number,
        DATE_FORMAT(create_time, '%Y-%m-%d') createTime,
        user_name,
        DATE_FORMAT(ins_time, '%Y-%m-%d') insTime,
        ins_state,
        judge_state
        from mom_ocean.raw_inspect
        where state=1
        <if test="formTime!=null and formTime!=''">
            and form_time=#{formTime}
        </if>
        <if test="code!=null and code!=''">
            and code like concat('%',#{code},'%')
        </if>
        <if test="insState!=null">
            and ins_state=#{insState}
        </if>
        <if test="name!=null and name!=''">
            and name like concat('%',#{name},'%')
        </if>
        ORDER BY id DESC
    </select>
 
    <!--根据原材料检验单id查看详情-->
    <resultMap id="oneMap" type="map">
        <id property="code" column="rcode"/>
        <result property="formTime" column="formTime"/>
        <result property="creatTime" column="creatTime"/>
        <result property="name" column="rname"/>
        <result property="specifications" column="specifications"/>
        <result property="runit" column="runit"/>
        <result property="number" column="number"/>
        <result property="supplier" column="supplier"/>
        <result property="judgeState" column="judge_state"/>
        <result property="userName" column="user_name"/>
        <collection property="children" resultMap="twoMap" javaType="List"/>
    </resultMap>
    <resultMap id="twoMap" type="Map">
        <id property="rpId" column="rpId"/>
        <result property="rpName" column="rpName"/>
        <result property="rpUnit" column="rpUnit"/>
        <result property="required" column="required"/>
        <result property="internal" column="internal"/>
        <result property="testValue" column="test_value"/>
        <result property="testState" column="test_state"/>
        <result property="deviceName" column="devName"/>
        <result property="deviceId" column="deviceId"/>
        <result property="uName" column="uName"/>
    </resultMap>
 
    <select id="selectRawInspectsListById" resultMap="oneMap">
        select DATE_FORMAT(form_time, '%Y-%m-%d')     formTime,
               r.code                                 rcode,
               r.name                                 rname,
               specifications,
               r.unit                                 runit,
               number,
               DATE_FORMAT(r.create_time, '%Y-%m-%d') creatTime,
               supplier,
               judge_state,
               user_name,
               rp.id                                  rpId,
               rp.name                                rpName,
               rp.unit                                rpUnit,
               required,
               internal,
               test_value,
               test_state,
               device.name                            devName,
               device.`id`                            deviceId,
               user.name                              uName
        from mom_ocean.raw_ins_product rp
                 left join mom_ocean.raw_inspect r on rp.raw_inspect_id = r.id
                 left join mom_ocean.device
                           on rp.device_id = device.id
                 left join mom_ocean.user on rp.user_id = user.id
        where r.state = 1
          and rp.state = 1
          and r.id = #{id}
    </select>
 
    <!--根据原材料编码查询最近一条数据-->
    <select id="selOneByCode" resultType="com.yuanchu.mom.pojo.RawInspect">
        select *
        from mom_ocean.raw_inspect
        where state = 1
          and code = #{code}
        order by id desc
        limit 1
    </select>
</mapper>