刘小明
2024-08-26 591e3b8a10ed15023f3ad9e5a72a887ef89b0bb2
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
<?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.PrProductionNodeMapper">
 
    <resultMap id="BaseResultMap" type="com.dy.pmsGlobal.pojoPr.PrProductionNode">
        <id property="id" column="id" jdbcType="BIGINT"/>
        <result property="processId" column="process_id" jdbcType="BIGINT"/>
        <result property="sort" column="sort" jdbcType="INTEGER"/>
        <result property="content" column="content" jdbcType="VARCHAR"/>
        <result property="nodeType" column="node_type" jdbcType="INTEGER"/>
        <result property="isStart" column="is_start" jdbcType="TINYINT"/>
        <result property="isEnd" column="is_end" jdbcType="TINYINT"/>
        <result property="isRecord" column="is_record" jdbcType="TINYINT"/>
        <result property="deviceCycleContent" column="device_cycle_content" jdbcType="VARCHAR"/>
        <result property="deleted" column="deleted" jdbcType="TINYINT"/>
        <result property="remark" column="remark" jdbcType="VARCHAR"/>
        <association property="instruction"
            column="id" javaType="java.lang.Long" select="com.dy.pmsGlobal.daoPr.PrWorkingInstructionMapper.selectByNodeId" fetchType="eager" />
    </resultMap>
 
    <sql id="Base_Column_List">
        id,process_id,sort,
        content,node_type,is_start,is_end,
        is_record,device_cycle_content,deleted,
        remark
    </sql>
 
<!--    <select id="selectProNameById" resultMap="com.dy.pmsGlobal.daoPr.PrWorkingInstructionMapper.BaseResultMap">-->
<!--        select *-->
<!--        from pr_working_instruction-->
<!--        where node_id = #{id,jdbcType=BIGINT}-->
<!--    </select>-->
    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from pr_production_node
        where  id = #{id,jdbcType=BIGINT} 
    </select>
    <select id="selectNameByNodeId" parameterType="java.lang.Long" resultType="String">
        select content from pr_production_node where id = #{id}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete from pr_production_node
        where  id = #{id,jdbcType=BIGINT} 
    </delete>
    <delete id="deleteByProcessId">
        delete from pr_production_node
        where  process_id = #{processId,jdbcType=BIGINT}
    </delete>
    <delete id="deleteByNodeId" parameterType="arraylist">
        delete from pr_production_node
        where  id in
        <foreach collection="list" item="item" index="index" open="(" separator="," close=")">
            #{item}
        </foreach>
    </delete>
    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoPr.PrProductionNode" useGeneratedKeys="true">
        insert into pr_production_node
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="id != null and id !=''">id,</if>
                <if test="isEnd!= null and isEnd !=''">process_id,</if>
                <if test="sort != null and sort !=''">sort,</if>
                <if test="content != null and content !=''">content,</if>
                <if test="nodeType!= null and nodeType !=''">node_type,</if>
                <if test="isStart!= null and isStart !=''">is_start,</if>
                <if test="isEnd!= null and isEnd !=''">is_end,</if>
                <if test="isRecord!= null and isRecord !=''">is_record,</if>
                <if test="deviceCycleContent != null and deviceCycleContent !=''">device_cycle_content,</if>
                <if test="deleted != null and deleted !=''">deleted,</if>
                <if test="remark != null and remark !=''">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="id != null and id !=''">#{id,jdbcType=BIGINT},</if>
                <if test="isEnd!= null and isEnd !=''">#{processId,jdbcType=BIGINT},</if>
                <if test="sort != null and sort !=''">#{sort,jdbcType=INTEGER},</if>
                <if test="content != null and content !=''">#{content,jdbcType=VARCHAR},</if>
                <if test="nodeType!= null and nodeType !=''">#{nodeType,jdbcType=INTEGER},</if>
                <if test="isStart!= null and isStart !=''">#{isStart,jdbcType=TINYINT},</if>
                <if test="isEnd!= null and isEnd !=''">#{isEnd,jdbcType=TINYINT},</if>
                <if test="isRecord!= null and isRecord !=''">#{isRecord,jdbcType=TINYINT},</if>
                <if test="deviceCycleContent != null and deviceCycleContent !=''">#{deviceCycleContent,jdbcType=VARCHAR},</if>
                <if test="deleted != null and deleted !=''">#{deleted,jdbcType=TINYINT},</if>
                <if test="remark != null and remark !=''">#{remark,jdbcType=VARCHAR},</if>
        </trim>
    </insert>
 
    <insert id="insertMany" parameterType="java.util.List">
       INSERT INTO pr_production_node (id,process_id,sort,
        content,node_type,is_start,is_end,
        is_record,device_cycle_content,deleted,
        remark) VALUES
       <foreach item="item" index="index" collection="list" open="(" separator="),(" close=")">
           #{item.id},
           #{item.processId},
           #{item.sort},
           #{item.content},
           #{item.nodeType},
           #{item.isStart},
           #{item.isEnd},
           #{item.isRecord},
           #{item.deviceCycleContent},
           #{item.deleted},
           #{item.remark}
       </foreach>
    </insert>
 
 
    <update id="updateByPrimaryKeySelective" parameterType="com.dy.pmsGlobal.pojoPr.PrProductionNode">
        update pr_production_node
        <set>
                <if test="isEnd!= null and isEnd !=''">
                    process_id = #{processId,jdbcType=BIGINT},
                </if>
                <if test="sort != null and sort !=''">
                    sort = #{sort,jdbcType=INTEGER},
                </if>
                <if test="content != null and content !=''">
                    content = #{content,jdbcType=VARCHAR},
                </if>
                <if test="nodeType!= null and nodeType !=''">
                    node_type = #{nodeType,jdbcType=INTEGER},
                </if>
                <if test="isStart!= null and isStart !=''">
                    is_start = #{isStart,jdbcType=TINYINT},
                </if>
                <if test="isEnd!= null and isEnd !=''">
                    is_end = #{isEnd,jdbcType=TINYINT},
                </if>
                <if test="isRecord!= null and isRecord !=''">
                    is_record = #{isRecord,jdbcType=TINYINT},
                </if>
                <if test="deviceCycleContent != null and deviceCycleContent !=''">
                    device_cycle_content = #{deviceCycleContent,jdbcType=VARCHAR},
                </if>
                <if test="deleted != null and deleted !=''">
                    deleted = #{deleted,jdbcType=TINYINT},
                </if>
                <if test="remark != null and remark !=''">
                    remark = #{remark,jdbcType=VARCHAR},
                </if>
        </set>
        where   id = #{id,jdbcType=BIGINT} 
    </update>
 
    <select id="selectByProcess" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from pr_production_node
        <trim prefix="where" suffixOverrides="and">
            <if test="processId!= null and processId !=''">
                process_id = #{processId,jdbcType=BIGINT} and
            </if>
        </trim>
        order by sort asc
<!--        <trim prefix="limit " >-->
<!--            <if test="start != null and count != null">-->
<!--                #{start}, #{count}-->
<!--            </if>-->
<!--        </trim>-->
    </select>
    <select id="isEndNode" resultType="java.lang.Boolean">
        select
            n.sort >=n1.sort
        from pr_production_node n
                 left join pr_production_node n1 on n.process_id = n1.process_id
        where n1.id = #{id} and n.is_end=1
    </select>
 
    <update id="deleteLogicById" parameterType="java.lang.Long">
        update pr_production_node set deleted = 1
        where id = #{id}
    </update>
</mapper>