刘小明
2024-07-26 9b63b9770cd02ca73c20196a3e02f971bc6e70e8
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
<?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.dy.pmsGlobal.daoPr.PrProductionProcessMapper">
 
    <resultMap id="BaseResultMap" type="com.dy.pmsGlobal.pojoPr.PrProductionProcess">
        <id property="id" column="id" jdbcType="BIGINT"/>
        <result property="proId" column="pro_id" jdbcType="BIGINT"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <result property="creator" column="creator" jdbcType="VARCHAR"/>
        <result property="dt" column="dt" jdbcType="TIMESTAMP"/>
        <result property="disabled" column="disabled" jdbcType="TINYINT"/>
        <result property="deleted" column="deleted" jdbcType="TINYINT"/>
        <result property="remark" column="remark" jdbcType="VARCHAR"/>
        <association property="proName" column="pro_id" javaType="java.lang.Long"
                     select="com.dy.pmsGlobal.daoPlt.PltProductMapper.selectProNameById" fetchType="eager" />
        <association property="creatorName" column="creator" javaType="java.lang.Long"
                     select="com.dy.pmsGlobal.daoBa.BaUserMapper.selectNameByUserId" fetchType="eager" />
        <association property="isQuote" column="id" javaType="java.lang.Boolean" fetchType="eager"
                     select="com.dy.pmsGlobal.daoPr.PrAssemblyPlanMapper.processIsQuote" />
        <association property="planNames" column="id" javaType="java.lang.String" fetchType="eager"
                     select="com.dy.pmsGlobal.daoPr.PrAssemblyPlanMapper.selectPlanNamesByProcessId"  />
        <collection property="nodes" ofType="com.dy.pmsGlobal.pojoPr.PrProductionNode"
                      select="selectByProcess" fetchType="eager" column="id" />
    </resultMap>
 
    <resultMap id="ProcessResultMap" type="com.dy.pmsGlobal.pojoPr.PrProductionProcess">
        <id property="id" column="id" jdbcType="BIGINT"/>
        <result property="proId" column="pro_id" jdbcType="BIGINT"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <result property="creator" column="creator" jdbcType="VARCHAR"/>
        <result property="dt" column="dt" jdbcType="TIMESTAMP"/>
        <result property="disabled" column="disabled" jdbcType="TINYINT"/>
        <result property="deleted" column="deleted" jdbcType="TINYINT"/>
        <result property="remark" column="remark" jdbcType="VARCHAR"/>
        <collection property="nodes" ofType="com.dy.pmsGlobal.pojoPr.PrProductionNode"
                    select="selectByProcess" fetchType="eager" column="id" />
    </resultMap>
 
    <sql id="Base_Column_List">
        id,pro_id,name,
        creator,dt,disabled,
        deleted,remark
    </sql>
 
    <select id="selectProcessNameById" resultType="java.lang.String">
        select  name
        from pr_production_process
        where  id = #{id,jdbcType=BIGINT}
    </select>
    <select id="selectByProcess" resultMap="com.dy.pmsGlobal.daoPr.PrProductionNodeMapper.BaseResultMap">
        select *
        from pr_production_node
        where process_id = #{processId,jdbcType=BIGINT}
    </select>
    <select id="selectByProcessId" parameterType="java.lang.Long" resultMap="ProcessResultMap">
        select
        <include refid="Base_Column_List" />
        from pr_production_process
        where  id = #{id,jdbcType=BIGINT} 
    </select>
 
    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from pr_production_process
        where  id = #{id,jdbcType=BIGINT}
    </select>
 
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete from pr_production_process
        where  id = #{id,jdbcType=BIGINT} 
    </delete>
 
    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoPr.PrProductionProcess" useGeneratedKeys="true">
        insert into pr_production_process
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="id != null">id,</if>
                <if test="proId != null">pro_id,</if>
                <if test="name != null">name,</if>
                <if test="creator != null">creator,</if>
                <if test="dt != null">dt,</if>
                <if test="disabled != null">disabled,</if>
                <if test="deleted != null">deleted,</if>
                <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="id != null">#{id,jdbcType=BIGINT},</if>
                <if test="proId != null">#{proId,jdbcType=BIGINT},</if>
                <if test="name != null">#{name,jdbcType=VARCHAR},</if>
                <if test="creator != null">#{creator,jdbcType=VARCHAR},</if>
                <if test="dt != null">#{dt,jdbcType=TIMESTAMP},</if>
                <if test="disabled != null">#{disabled,jdbcType=TINYINT},</if>
                <if test="deleted != null">#{deleted,jdbcType=TINYINT},</if>
                <if test="remark != null">#{remark,jdbcType=VARCHAR},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.dy.pmsGlobal.pojoPr.PrProductionProcess">
        update pr_production_process
        <set>
                <if test="proId != null">
                    pro_id = #{proId,jdbcType=BIGINT},
                </if>
                <if test="name != null">
                    name = #{name,jdbcType=VARCHAR},
                </if>
                <if test="creator != null">
                    creator = #{creator,jdbcType=VARCHAR},
                </if>
                <if test="dt != null">
                    dt = #{dt,jdbcType=TIMESTAMP},
                </if>
                <if test="disabled != null">
                    disabled = #{disabled,jdbcType=TINYINT},
                </if>
                <if test="deleted != null">
                    deleted = #{deleted,jdbcType=TINYINT},
                </if>
                <if test="remark != null">
                    remark = #{remark,jdbcType=VARCHAR},
                </if>
        </set>
        where   id = #{id,jdbcType=BIGINT} 
    </update>
 
    <select id="selectSome" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from pr_production_process t
        <trim prefix="where" suffixOverrides="and">
            <if test="proId != null">
                pro_id = #{proId,jdbcType=BIGINT} and
            </if>
<!--            <if test="name != null">-->
<!--                name = #{name,jdbcType=VARCHAR} and-->
<!--            </if>-->
        </trim>
        order by t.id desc
        <trim prefix="limit " >
            <if test="start != null and count != null">
                #{start}, #{count}
            </if>
        </trim>
    </select>
 
    <select id="selectSomeCount" resultType="java.lang.Long">
        select count(1)
        from pr_production_process t
        <trim prefix="where" suffixOverrides="and">
            <if test="proId != null">
                pro_id = #{proId,jdbcType=BIGINT} and
            </if>
            <!--            <if test="name != null">-->
            <!--                name = #{name,jdbcType=VARCHAR} and-->
            <!--            </if>-->
        </trim>
    </select>
    <select id="queryAll" resultType="java.util.List">
        select
            CAST(id AS CHAR) AS id,name
        from pr_production_process
        where deleted = 0
        <trim prefix="and" suffixOverrides=",">
            pro_id = #{proId,jdbcType=BIGINT}
        </trim>
    </select>
    <select id="exists" resultType="java.lang.Boolean">
        select count(1)
        from pr_production_process
        where name = #{name} and deleted = 0
        <if test="id != null">
            and id != #{id}
        </if>
    </select>
 
 
    <update id="deleteLogicById" parameterType="java.lang.Long">
        update pr_production_process set deleted = 1
        where id = #{id}
    </update>
</mapper>