liulingling.177216
2024-08-26 349f1cfc5fa77fbc636d542df0d8050fddec48c2
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.dingzhuo.energy.basic.data.workforce.mapper.RosteringMapper">
    
    <resultMap type="Rostering" id="RosteringResult">
        <result property="id"    column="id"    />
        <result property="code"    column="code"    />
        <result property="name"    column="name"    />
        <result property="schemeId"    column="scheme_id"    />
        <result property="shiftId"    column="shift_id"    />
        <result property="dutyId"    column="duty_id"    />
        <result property="description"    column="description"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="departMemberId"    column="depart_member_id"  />
        <result property="beginTimes"    column="begin_times"    />
        <result property="endTimes"    column="end_times"  />
    </resultMap>
    <resultMap type="RosteringScheme" id="RosteringSchemeResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
    </resultMap>
    <resultMap type="RosteringCopy" id="RosteringCopyResult">
        <result property="code"    column="code"    />
        <result property="name"    column="name"    />
        <result property="schemeId"    column="scheme_id"    />
        <result property="shiftName"    column="name"    />
        <result property="startTime"    column="start_time"    />
        <result property="enddTime"    column="endd_time"    />
        <result property="isCrossDay"    column="is_cross_day"    />
        <result property="dutyName"    column="name"    />
        <result property="shiftId"    column="shift_id"    />
        <result property="dutyId"    column="duty_id"    />
    </resultMap>
    <sql id="selectRosteringVo">
        SELECT r.ID,
            r.code,
            r.NAME,
            r.begin_times,
            r.end_times,
            r.scheme_id,
            (SELECT name from rostering_scheme a where a.id=r.scheme_id) schemeName,
            r.shift_id,
           (SELECT name from rostering_shift d where d.id=r.shift_id) shiftName,
            r.duty_id,
            (SELECT name from rostering_duty d where d.id=r.duty_id) dutyName,
            r.depart_member_id,
            (SELECT s.dept_name FROM sys_dept s WHERE s.dept_id=r.depart_member_id) deptName,
            r.description
        FROM
            rostering r
 
    </sql>
 
    <select id="selectRosteringList" parameterType="Rostering" resultMap="RosteringResult">
        <include refid="selectRosteringVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="schemeId != null  and schemeId != ''"> and scheme_id like concat('%', #{schemeId}, '%')</if>
            <if test="shiftId != null  and shiftId != ''"> and shift_id like concat('%', #{shiftId}, '%')</if>
            <if test="dutyId != null  and dutyId != ''"> and duty_id like concat('%', #{dutyId}, '%')</if>
            <if test="description != null  and description != ''"> and description like concat('%', #{description}, '%')</if>
            <if test="departMemberId != null  and departMemberId != ''"> and depart_member_id like concat('%', #{departMemberId}, '%')</if>
        </where>
    </select>
    <select id="selectSchemeNameList" parameterType="RosteringScheme" resultMap="RosteringSchemeResult">
         select id,name from rostering_scheme
    </select>
 
    <select id="selectRosteringById" parameterType="String" resultMap="RosteringResult">
        <include refid="selectRosteringVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertRostering" parameterType="Rostering">
        insert into rostering
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null  and id != ''">id,</if>
            <if test="code != null  and code != ''">code,</if>
            <if test="name != null  and name != ''">name,</if>
            <if test="schemeId != null  and schemeId != ''">scheme_id,</if>
            <if test="shiftId != null  and shiftId != ''">shift_id,</if>
            <if test="dutyId != null  and dutyId != ''">duty_id,</if>
            <if test="description != null  and description != ''">description,</if>
            <if test="createBy != null  and createBy != ''">create_by,</if>
            <if test="createTime != null ">create_time,</if>
            <if test="departMemberId != null  and departMemberId != ''">depart_member_id,</if>
            <if test="beginTimes != null">begin_times,</if>
            <if test="endTimes != null">end_times,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null  and id != ''">#{id},</if>
            <if test="code != null  and code != ''">#{code},</if>
            <if test="name != null  and name != ''">#{name},</if>
            <if test="schemeId != null  and schemeId != ''">#{schemeId},</if>
            <if test="shiftId != null  and shiftId != ''">#{shiftId},</if>
            <if test="dutyId != null  and dutyId != ''">#{dutyId},</if>
            <if test="description != null  and description != ''">#{description},</if>
            <if test="createBy != null  and createBy != ''">#{createBy},</if>
            <if test="createTime != null ">#{createTime},</if>
            <if test="departMemberId != null  and departMemberId != ''">#{departMemberId},</if>
            <if test="beginTimes != null">#{beginTimes},</if>
            <if test="endTimes != null">#{endTimes},</if>
         </trim>
    </insert>
    <insert id="saveRostering1" parameterType="java.util.List">
        <foreach item="dataItems" collection="dataItemVlues">
            <if test="dataItems != null">
                insert into rostering (id,code,name,scheme_id,shift_id,duty_id,description,create_by,create_time,depart_member_id,begin_times,end_times)
                values (#{dataItems.id},#{dataItems.code},#{dataItems.name},#{dataItems.schemeId},#{dataItems.shiftId},#{dataItems.dutyId},#{dataItems.description},#{dataItems.createBy},#{dataItems.createTime},#{dataItems.departMemberId},#{dataItems.beginTimes},#{dataItems.endTimes});
            </if>
        </foreach>
    </insert>
    <insert id="saveRostering">
        insert into rostering (id,code,name,scheme_id,shift_id,duty_id,description,create_by,create_time,depart_member_id,begin_times,end_times)
        values
        <foreach collection="list" item="dataItems" index="index" separator=",">
            (#{dataItems.id},#{dataItems.code},#{dataItems.name},#{dataItems.schemeId},#{dataItems.shiftId},#{dataItems.dutyId},#{dataItems.description},#{dataItems.createBy},#{dataItems.createTime},#{dataItems.departMemberId},#{dataItems.beginTimes},#{dataItems.endTimes})
        </foreach>
    </insert>
    <update id="updateRostering" parameterType="Rostering">
        update rostering
        <trim prefix="SET" suffixOverrides=",">
            <if test="code != null  and code != ''">code = #{code},</if>
            <if test="name != null  and name != ''">name = #{name},</if>
            <if test="schemeId != null  and schemeId != ''">scheme_id = #{schemeId},</if>
            <if test="shiftId != null  and shiftId != ''">shift_id = #{shiftId},</if>
            <if test="dutyId != null  and dutyId != ''">duty_id = #{dutyId},</if>
            <if test="description != null  and description != ''">description = #{description},</if>
            <if test="departMemberId != null  and departMemberId != ''">depart_member_id = #{departMemberId},</if>
            <if test="updateBy != null  and updateBy != ''">update_by = #{updateBy},</if>
            <if test="updateTime != null ">update_time = #{updateTime},</if>
            <if test="beginTimes != null">begin_times = #{beginTimes},</if>
            <if test="endTimes != null">end_times = #{endTimes},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteRosteringById" parameterType="String">
        delete from rostering where id = #{id}
    </delete>
 
    <delete id="deleteRosteringByIds" parameterType="String">
        delete from rostering where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
    <select id="selectList" parameterType="RosteringCopy" resultMap="RosteringCopyResult">
        SELECT
            s.code,
            s.name,
            s.scheme_id,
            s.shift_id,
            s.duty_id,
            (rs.name) shiftName,
            rs.start_time,
            rs.endd_time,
            rs.is_cross_day,
            (d.name) dutyName
        FROM
            rostering_scheme_item s
            LEFT JOIN rostering_shift rs ON rs.id = s.shift_id
            LEFT JOIN rostering_duty d ON d.id = s.duty_id
        WHERE
            scheme_id = #{schemeId}
            AND rs.dept_id = #{departMemberId}
 
    </select>
</mapper>