邱宇豪
2023-11-03 bd74616204baf4e3f8bb124f142a07be8e5e9f13
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
<?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.thhy.mobile.modules.biz.mouldcheck.mapper.MouldCheckMapper">
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        t.mod_check_id as modCheckId,
        t.check_time as checkTime,
        t.check_user as checkUser,
        t.is_use as isUse,
        t.mod_id as modId,
        t.match_status as matchStatus,
        t.status as status
    </sql>
 
    <sql id="condition_query">
        <where>
            <trim suffixOverrides=" AND ">
                <if test="checkTime!=null">
                    t.check_time = #{checkTime} AND
                </if>
                <if test="checkUser!=null and checkUser!=''">
                    t.check_user = #{checkUser} AND
                </if>
                <if test="isUse!=null">
                    t.is_use = #{isUse} AND
                </if>
                <if test="modId!=null and modId!=''">
                    t.mod_id = #{modId} AND
                </if>
                <if test="status!=null">
                    t.status = #{status} AND
                </if>
            </trim>
        </where>
    </sql>
 
    <select id="queryById" resultType="com.thhy.mobile.modules.biz.mouldcheck.entity.MouldCheck">
        select <include refid="Base_Column_List" />
        from t_mould_check t
        where t.mod_check_id=#{modCheckId}
    </select>
 
    <select id="countByMouldNum" resultType="int">
        select  count(mod_check_id) from t_mould_check where mod_id = #{modId} and status = 1 and is_use = 1
    </select>
 
    <select id="queryVersionById" resultType="integer">
        select version from t_mould_check
        where mod_check_id=#{modCheckId}
    </select>
 
    <!--查询列表-->
    <select id="findList" resultType="com.thhy.mobile.modules.biz.mouldcheck.entity.MouldCheck">
        SELECT
        <include refid="Base_Column_List" />
        from t_mould_check t
        <include refid="condition_query" />
    </select>
 
    <!--查询列表-->
    <select id="findAll" resultType="com.thhy.mobile.modules.biz.mouldcheck.entity.MouldCheck">
        SELECT
        <include refid="Base_Column_List" />
        from t_mould_check t
    </select>
 
    <!--插入操作-->
    <insert id="insert" useGeneratedKeys="true" keyProperty="modCheckId">
        insert into t_mould_check
        <trim prefix="(" suffix=")" suffixOverrides="," >
            <if test="checkTime != null">
                check_time,
            </if>
            <if test="checkUser != null">
                check_user,
            </if>
            <if test="isUse != null">
                is_use,
            </if>
            <if test="modCheckId != null">
                mod_check_id,
            </if>
            <if test="modId != null">
                mod_id,
            </if>
            <if test="status != null">
                status,
            </if>
        </trim>
 
        <trim prefix="values (" suffix=")" suffixOverrides="," >
            <if test="checkTime != null">
                #{checkTime},
            </if>
            <if test="checkUser != null">
                #{checkUser},
            </if>
            <if test="isUse != null">
                #{isUse},
            </if>
            <if test="modCheckId != null">
                #{modCheckId},
            </if>
            <if test="modId != null">
                #{modId},
            </if>
            <if test="status != null">
                #{status},
            </if>
        </trim>
    </insert>
 
 
    <!--更新操作-->
    <update id="update">
        update t_mould_check
        <set>
            <if test="checkTime != null">
                check_time=#{checkTime},
            </if>
            <if test="checkUser != null">
                check_user=#{checkUser},
            </if>
            <if test="isUse != null">
                is_use=#{isUse},
            </if>
            <if test="modId != null">
                mod_id=#{modId},
            </if>
            <if test="status != null">
                status=#{status},
            </if>
        </set>
        where mod_check_id=#{modCheckId}
    </update>
 
    <update id="updateMatchStatus">
        update t_mould_check
        <set>
            <if test="matchStatus != null">
                match_status=#{matchStatus},
            </if>
        </set>
        where mod_check_id=#{modCheckId}
    </update>
 
    <!--逻辑删除-->
    <update id="deletelogic">
        update t_mould_check
        SET is_use = 0
        where mod_check_id=#{modCheckId}
    </update>
 
    <!--根据ID删除-->
    <delete id="deleteById">
        delete from t_mould_check
        where mod_check_id=#{modCheckId}
    </delete>
 
    <select id="ModCheckList" resultType="com.thhy.mobile.modules.biz.mouldcheck.entity.MouldCheckListVo">
        select mc.mod_check_id as modCheckId,mc.mod_id as modId,
               sm.mould_num as mouldNum,sm.mould_code as mouldCode,sd.dict_name as mouldSizeName,sd1.dict_name as mouldBlockName,sd2.dict_name as mouldTurnName,mc.match_status as matchStatus,
               mcr.steel_pro_num as produceNumber,spr.pro_name as proName,
               sd3.dict_name as steelSizeName,sd4.dict_name as steelReinforcementName,sd5.dict_name as steelBlockName
        from t_mould_check mc
                 left join sys_mould sm on sm.mould_id = mc.mod_id
                 left join sys_dict sd on sd.dict_id = sm.mould_size
                 left join sys_dict sd1 on sd1.dict_id = sm.mould_type
                 left join sys_dict sd2 on sd2.dict_id = sm.mould_turn
                 left join t_mould_check_record mcr on mcr.mod_check_id = mc.mod_check_id
                 left join t_steel_produce sp on sp.produce_number = mcr.steel_pro_num
                 left join sys_project spr on spr.pro_id = sm.pro_id
 
                 left join sys_dict sd3 on sd3.dict_id = sp.size_id
                 left join sys_dict sd4 on sd4.dict_id = sp.reinforcement_id
                 left join sys_dict sd5 on sd5.dict_id = sp.block_num
        <where>
            <trim suffixOverrides=" AND ">
                mc.is_use = 1 AND spr.company_id = #{companyId} AND
                <if test="mouldNum!=null and mouldNum!=''">
                    sm.mould_num LIKE CONCAT('%',#{mouldNum},'%') AND
                </if>
                <if test="matchStatus!=null">
                    mc.match_status = #{matchStatus} AND
                </if>
            </trim>
        </where>
        order by mc.check_time desc
    </select>
 
</mapper>