liuxiaolong
2019-05-06 a7bed6b4cfecd61ec153818945f982c5bb796b98
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
<?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.cloud.attendance.dao.AttDayDao">
 
 
  <!-- 查询 人员 信息 暂不适用 19-03-12 -->
   <select id="queryPersonByContent" resultType="String" >
    SELECT id
    from <include refid="sysuser_database"/>.<include refid="bbperson_database"/>
        WHERE delFlag != '1'
    <if test="contentValue != null" >
     and (  no like concat('%', #{contentValue}, '%') or cardId like concat('%', #{contentValue}, '%')  or `name` like concat('%', #{contentValue}, '%') )
    </if>
    <if test="identity != null " >
      and type = #{identity,jdbcType=VARCHAR}
    </if>
    <if test="orgId != null" >
      and orgId = #{orgId,jdbcType =VARCHAR}
    </if>
    <if test="gradeValue !=null  or classValue != null " >
      and officeId
      in (SELECT id
      FROM <include refid="sysuser_database" />.sys_organization WHERE  parentIds like
      <if test="classValue != null " >
       concat('%', #{classValue}, '%'))
      </if>
      <if test="gradeValue != null  and classValue == null" >
        concat('%', #{gradeValue}, '%'))
      </if>
    </if>
  </select>
 
 
  <resultMap id="BaseResultMap" type="com.cloud.attendance.model.AttDay">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="orgId" jdbcType="INTEGER" property="orgId" />
    <result column="employeeId" jdbcType="VARCHAR" property="employeeId" />
    <result column="employeeName" jdbcType="VARCHAR" property="employeeName" />
    <result column="signDate" jdbcType="DATE" property="signDate" />
    <result column="inTime" jdbcType="TIMESTAMP" property="inTime" />
    <result column="outTime" jdbcType="TIMESTAMP" property="outTime" />
    <result column="inDeviceId" jdbcType="VARCHAR" property="inDeviceId" />
    <result column="inDeviceName" jdbcType="VARCHAR" property="inDeviceName" />
    <result column="outDeviceId" jdbcType="VARCHAR" property="outDeviceId" />
    <result column="outDeviceName" jdbcType="VARCHAR" property="outDeviceName" />
    <result column="isNotSign" jdbcType="INTEGER" property="isNotSign" />
    <result column="isLate" jdbcType="INTEGER" property="isLate" />
    <result column="isLeaveEarly" jdbcType="INTEGER" property="isLeaveEarly" />
    <result column="isLeave" jdbcType="INTEGER" property="isLeave" />
    <result column="isRepair" jdbcType="INTEGER" property="isRepair" />
    <result column="revJson" jdbcType="CHAR" property="revJson" />
    <result column="createBy" jdbcType="VARCHAR" property="createBy" />
    <result column="createDate" jdbcType="TIMESTAMP" property="createDate" />
    <result column="updateBy" jdbcType="VARCHAR" property="updateBy" />
    <result column="updateDate" jdbcType="TIMESTAMP" property="updateDate" />
    <result column="remarks" jdbcType="VARCHAR" property="remarks" />
    <result column="delFlag" jdbcType="VARCHAR" property="delFlag" />
    <result column="dayStatus" jdbcType="VARCHAR" property="dayStatus" />
  </resultMap>
  <sql id="Base_Column_List">
    id, orgId, employeeId, employeeName, signDate, inTime, outTime, inDeviceId, inDeviceName, 
    outDeviceId, outDeviceName, isNotSign, isLate, isLeaveEarly, isLeave, isRepair, revJson, 
    createBy, createDate, updateBy, updateDate, remarks, delFlag
  </sql>
 
 
  <select id="selectById" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from att_day
    where id = #{id,jdbcType=INTEGER}
  </select>
 
  <delete id="deleteById" parameterType="java.lang.Integer">
    delete from att_day
    where id = #{id,jdbcType=INTEGER}
  </delete>
 
  <insert id="save" parameterType="com.cloud.attendance.model.AttDay">>
    insert into att_day (orgId, employeeId, employeeName, 
      signDate, inTime, outTime, 
      inDeviceId, inDeviceName, outDeviceId, 
      outDeviceName, isNotSign, isLate, 
      isLeaveEarly, isLeave, isRepair, 
      revJson, createBy, createDate, 
      updateBy, updateDate, remarks, 
      delFlag)
    values (#{orgId,jdbcType=INTEGER}, #{employeeId,jdbcType=VARCHAR}, #{employeeName,jdbcType=VARCHAR},
      #{signDate,jdbcType=DATE}, #{inTime,jdbcType=TIMESTAMP}, #{outTime,jdbcType=TIMESTAMP}, 
      #{inDeviceId,jdbcType=VARCHAR}, #{inDeviceName,jdbcType=VARCHAR}, #{outDeviceId,jdbcType=VARCHAR}, 
      #{outDeviceName,jdbcType=VARCHAR}, #{isNotSign,jdbcType=INTEGER}, #{isLate,jdbcType=INTEGER}, 
      #{isLeaveEarly,jdbcType=INTEGER}, #{isLeave,jdbcType=INTEGER}, #{isRepair,jdbcType=INTEGER}, 
      #{revJson,jdbcType=CHAR}, #{createBy,jdbcType=VARCHAR}, #{createDate,jdbcType=TIMESTAMP}, 
      #{updateBy,jdbcType=VARCHAR}, #{updateDate,jdbcType=TIMESTAMP}, #{remarks,jdbcType=VARCHAR}, 
      #{delFlag,jdbcType=VARCHAR})
  </insert>
  <insert id="saveSelective" parameterType="com.cloud.attendance.model.AttDay">
    insert into att_day
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="orgId != null">
        orgId,
      </if>
      <if test="employeeId != null">
        employeeId,
      </if>
      <if test="employeeName != null">
        employeeName,
      </if>
      <if test="signDate != null">
        signDate,
      </if>
      <if test="inTime != null">
        inTime,
      </if>
      <if test="outTime != null">
        outTime,
      </if>
      <if test="inDeviceId != null">
        inDeviceId,
      </if>
      <if test="inDeviceName != null">
        inDeviceName,
      </if>
      <if test="outDeviceId != null">
        outDeviceId,
      </if>
      <if test="outDeviceName != null">
        outDeviceName,
      </if>
      <if test="isNotSign != null">
        isNotSign,
      </if>
      <if test="isLate != null">
        isLate,
      </if>
      <if test="isLeaveEarly != null">
        isLeaveEarly,
      </if>
      <if test="isLeave != null">
        isLeave,
      </if>
      <if test="isRepair != null">
        isRepair,
      </if>
      <if test="revJson != null">
        revJson,
      </if>
      <if test="createBy != null">
        createBy,
      </if>
      <if test="createDate != null">
        createDate,
      </if>
      <if test="updateBy != null">
        updateBy,
      </if>
      <if test="updateDate != null">
        updateDate,
      </if>
      <if test="remarks != null">
        remarks,
      </if>
      <if test="delFlag != null">
        delFlag,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="orgId != null">
        #{orgId,jdbcType=INTEGER},
      </if>
      <if test="employeeId != null">
        #{employeeId,jdbcType=VARCHAR},
      </if>
      <if test="employeeName != null">
        #{employeeName,jdbcType=VARCHAR},
      </if>
      <if test="signDate != null">
        #{signDate,jdbcType=DATE},
      </if>
      <if test="inTime != null">
        #{inTime,jdbcType=TIMESTAMP},
      </if>
      <if test="outTime != null">
        #{outTime,jdbcType=TIMESTAMP},
      </if>
      <if test="inDeviceId != null">
        #{inDeviceId,jdbcType=VARCHAR},
      </if>
      <if test="inDeviceName != null">
        #{inDeviceName,jdbcType=VARCHAR},
      </if>
      <if test="outDeviceId != null">
        #{outDeviceId,jdbcType=VARCHAR},
      </if>
      <if test="outDeviceName != null">
        #{outDeviceName,jdbcType=VARCHAR},
      </if>
      <if test="isNotSign != null">
        #{isNotSign,jdbcType=INTEGER},
      </if>
      <if test="isLate != null">
        #{isLate,jdbcType=INTEGER},
      </if>
      <if test="isLeaveEarly != null">
        #{isLeaveEarly,jdbcType=INTEGER},
      </if>
      <if test="isLeave != null">
        #{isLeave,jdbcType=INTEGER},
      </if>
      <if test="isRepair != null">
        #{isRepair,jdbcType=INTEGER},
      </if>
      <if test="revJson != null">
        #{revJson,jdbcType=CHAR},
      </if>
      <if test="createBy != null">
        #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null">
        #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null">
        #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateDate != null">
        #{updateDate,jdbcType=TIMESTAMP},
      </if>
      <if test="remarks != null">
        #{remarks,jdbcType=VARCHAR},
      </if>
      <if test="delFlag != null">
        #{delFlag,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByIdSelective" parameterType="com.cloud.attendance.model.AttDay">
    update att_day
    <set>
      <if test="orgId != null">
        orgId = #{orgId,jdbcType=INTEGER},
      </if>
      <if test="employeeId != null">
        employeeId = #{employeeId,jdbcType=VARCHAR},
      </if>
      <if test="employeeName != null">
        employeeName = #{employeeName,jdbcType=VARCHAR},
      </if>
      <if test="signDate != null">
        signDate = #{signDate,jdbcType=DATE},
      </if>
      <if test="inTime != null">
        inTime = #{inTime,jdbcType=TIMESTAMP},
      </if>
      <if test="outTime != null">
        outTime = #{outTime,jdbcType=TIMESTAMP},
      </if>
      <if test="inDeviceId != null">
        inDeviceId = #{inDeviceId,jdbcType=VARCHAR},
      </if>
      <if test="inDeviceName != null">
        inDeviceName = #{inDeviceName,jdbcType=VARCHAR},
      </if>
      <if test="outDeviceId != null">
        outDeviceId = #{outDeviceId,jdbcType=VARCHAR},
      </if>
      <if test="outDeviceName != null">
        outDeviceName = #{outDeviceName,jdbcType=VARCHAR},
      </if>
      <if test="isNotSign != null">
        isNotSign = #{isNotSign,jdbcType=INTEGER},
      </if>
      <if test="isLate != null">
        isLate = #{isLate,jdbcType=INTEGER},
      </if>
      <if test="isLeaveEarly != null">
        isLeaveEarly = #{isLeaveEarly,jdbcType=INTEGER},
      </if>
      <if test="isLeave != null">
        isLeave = #{isLeave,jdbcType=INTEGER},
      </if>
      <if test="isRepair != null">
        isRepair = #{isRepair,jdbcType=INTEGER},
      </if>
      <if test="revJson != null">
        revJson = #{revJson,jdbcType=CHAR},
      </if>
      <if test="createBy != null">
        createBy = #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null">
        createDate = #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null">
        updateBy = #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateDate != null">
        updateDate = #{updateDate,jdbcType=TIMESTAMP},
      </if>
      <if test="remarks != null">
        remarks = #{remarks,jdbcType=VARCHAR},
      </if>
      <if test="delFlag != null">
        delFlag = #{delFlag,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
 
  <update id="updateById" parameterType="com.cloud.attendance.model.AttDay">
    update att_day
    set orgId = #{orgId,jdbcType=INTEGER},
      employeeId = #{employeeId,jdbcType=VARCHAR},
      employeeName = #{employeeName,jdbcType=VARCHAR},
      signDate = #{signDate,jdbcType=DATE},
      inTime = #{inTime,jdbcType=TIMESTAMP},
      outTime = #{outTime,jdbcType=TIMESTAMP},
      inDeviceId = #{inDeviceId,jdbcType=VARCHAR},
      inDeviceName = #{inDeviceName,jdbcType=VARCHAR},
      outDeviceId = #{outDeviceId,jdbcType=VARCHAR},
      outDeviceName = #{outDeviceName,jdbcType=VARCHAR},
      isNotSign = #{isNotSign,jdbcType=INTEGER},
      isLate = #{isLate,jdbcType=INTEGER},
      isLeaveEarly = #{isLeaveEarly,jdbcType=INTEGER},
      isLeave = #{isLeave,jdbcType=INTEGER},
      isRepair = #{isRepair,jdbcType=INTEGER},
      revJson = #{revJson,jdbcType=CHAR},
      createBy = #{createBy,jdbcType=VARCHAR},
      createDate = #{createDate,jdbcType=TIMESTAMP},
      updateBy = #{updateBy,jdbcType=VARCHAR},
      updateDate = #{updateDate,jdbcType=TIMESTAMP},
      remarks = #{remarks,jdbcType=VARCHAR},
      delFlag = #{delFlag,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <!--  单人每月考情情况-->
  <resultMap id="BigResultMap" type="com.cloud.attendance.model.AttMouthData" >
    <result column="perId" property="perId" jdbcType="VARCHAR" />
    <result column="perName" property="perName" jdbcType="VARCHAR" />
    <result column="attendValue" property="attendValue" jdbcType="VARCHAR" />  <!--出勤汇总 -->
    <result column="lateValue" property="lateValue" jdbcType="INTEGER" />     <!-- 迟到汇总-->
    <result column="leaveEarlyValue" property="leaveEarlyValue" jdbcType="INTEGER"/>  <!-- 早退汇总-->
    <result column="isLeave" property="isLeave" jdbcType="INTEGER"/>  <!-- 请假汇总-->
    <collection property="totalList"  ofType="com.cloud.attendance.model.DayStatus" javaType="ArrayList">
      <result column="dayDate" property="dayDate" jdbcType="DATE" />
      <result column="detail" property="detail" jdbcType="VARCHAR" />
    </collection>
  </resultMap>
<sql id="sysuser_database" >
    sys_user2
</sql>
  <sql id="bbperson_database" >
    bb_person_base
</sql>
  <!-- 查询单人当月的考勤信息 -->
  <select id="selectAttDayByUserAndMouth" resultMap="BaseResultMap"  >
   SELECT id,employeeId,employeeName,signDate,inDeviceName,inTime,outDeviceName,outTime,
isNotSign,isLate,isLeaveEarly,isLeave,isRepair,
(case when(isLate = '1'  and isLeaveEarly = '1' )   then '迟到/早退'
            when(isLate = '1')    then '迟到'
      when(isLeaveEarly = '1'  )   then '早退'
            when(isLeave = '1' )   then '请假'
            when(isRepair = '1')   then '补签'
            when(isNotSign = '0')   then '正常'
            else   '缺勤'  end ) dayStatus
 FROM att_day
WHERE date_format(signDate,'%Y-%m')=#{mouthDate,jdbcType=VARCHAR} and employeeId = #{id,jdbcType=INTEGER} and signDate &lt; NOW()
ORDER BY signDate ASC
  </select>
 
  <!-- 查询 流水记录页面符合要求的人员以便查询es 数据-->
  <select id="queryPersonById" resultMap="BaseResultMap" >
    SELECT a.id,a.orgId,a.employeeId,a.employeeName,a.inTime,a.outTime,a.inDeviceName,a.outDeviceName
    FROM att_day a
    WHERE date_format(a.inTime,'%Y-%m-%d %H:%i:%s') BETWEEN #{beginTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
    and a.employeeId=#{id,jdbcType=INTEGER}
  </select>
  <!-- 老师或学生 考情情况  se.`name` name,se.gender gender,se.orgId orgId -->
  <select id="selectAttDayByMouth" resultMap="BigResultMap"  >
    select e.employeeId perId,e.isLeave isLeave,e.isLeaveEarly leaveEarlyValue,e.isLate lateValue,
    e.isNotSign attendValue,ad.signDate dayDate,
    (case when(ad.isLate = '1'  and ad.isLeaveEarly = '1' )   then '迟到早退'
    when(ad.isLate = '1')    then '迟到'
    when(ad.isLeaveEarly = '1'  )   then '早退'
    when(ad.isLeave = '1' )   then '请假'
    when(ad.isRepair = '1')   then '补签'
    when(ad.isNotSign = '0')   then '√'
    else   '缺勤'  end )  detail
    from(
    SELECT ad0.employeeId employeeId,sum(ad0.isLeave) isLeave,sum(ad0.isLeaveEarly) isLeaveEarly,sum(ad0.isLate) isLate ,
    SUM(case ad0.isNotSign when 0 then 1 else 0 end ) isNotSign
    FROM att_day ad0
    WHERE date_format(ad0.signDate,'%Y-%m')=#{mouthDate,jdbcType=VARCHAR}  and ad0.delFlag = 0
     and ad0.employeeId in
     <foreach collection="personIds" separator="," open="(" close=")" item="userId" index="index" >
       #{userId,jdbcType=VARCHAR}
     </foreach>
    GROUP BY ad0.employeeId
    )e INNER JOIN att_day ad
    on e.employeeId = ad.employeeId and date_format(ad.signDate,'%Y-%m')=#{mouthDate,jdbcType=VARCHAR}   and ad.delFlag = 0
    and ad.signDate &lt; NOW()
    ORDER BY e.employeeId asc,ad.signDate asc
  </select>
 
  <!-- 查询 人员 信息 暂不适用 19-03-12 -->
  <select id="getPersonInfoById" resultType="Map">
    select  id ,name,type,photos,cardId
    from
    <include refid="sysuser_database"/>.<include refid="bbperson_database"/>  where id = #{perId,jdbcType=VARCHAR}
  </select>
 
<!-- 暂停用-->
  <insert id="insertEmployData"  parameterType="String"  >
    insert into att_day (orgId, employeeId,
    employeeName,signDate, createBy,
    createDate)
    select  orgId,id,name,DATE_ADD(date_format(NOW(),'%y-%m-%d'),INTERVAL 1 DAY),#{createBy,jdbcType=VARCHAR},NOW()
     from <include refid="sysuser_database"/>.<include refid="bbperson_database"/>  where delFlag = 0
  and   not exists (select   ad.employeeId,
    ad.employeeName , ad.signDate from att_day ad
    where ad.signDate = date_format(NOW(),'%y-%m-%d') and ad.employeeId = e2.id )
  </insert>
 
  <!-- 启动 添加今日 人员 空数据  暂停用 wp 19-03-12  -->
  <insert id="startInsertEmployData"  parameterType="String"  >
    insert into att_day ( orgId, employeeId,
    employeeName,signDate, createBy,
    createDate)
    select  e2.orgId,e2.id,e2.name,
    <if test="signDate == null" >
      date_format(NOW(),'%y-%m-%d')
    </if>
    <if test="signDate != null" >
       date_format(#{signDate},'%y-%m-%d')
    </if>
    ,#{createBy,jdbcType=VARCHAR},NOW()
     from <include refid="sysuser_database"/>.<include refid="bbperson_database"/> e2 where e2.delFlag = 0
     and   not exists (select  ad.employeeId,
    ad.employeeName , ad.signDate
     from att_day ad
    where
    <if test="signDate == null" >
        ad.signDate = date_format(NOW(),'%y-%m-%d')
    </if>
    <if test="signDate != null" >
      ad.signDate = date_format(#{signDate},'%y-%m-%d')
    </if> )
  </insert>
 
  <!-- 查询人员考勤当天人员id集合 wp 19-03-12  -->
  <select id="selectPersonByDate"   resultType="String" >
    select  employeeId
    from att_day
    where
    <if test="signDate == null" >
      signDate = date_format(NOW(),'%y-%m-%d')
    </if>
    <if test="signDate != null" >
      signDate = date_format(#{signDate},'%y-%m-%d')
    </if>
  </select>
 
  <!-- 定时 每天 添加 es 人员 的空数据  只用作考勤测试 废弃 -->
  <insert id="insertEsPerson" parameterType="com.cloud.attendance.model.PersonForEs" >
    insert into <include refid="sysuser_database"/>.<include refid="bbperson_database"/>  ( id,orgId, officeId,
    name, gender, type,photos,createBy,
    createTime, updateBy, updateTime)
    values
  ( #{pid,jdbcType=INTEGER},#{orgId,jdbcType=INTEGER}, #{officeId,jdbcType=INTEGER},
      #{name,jdbcType=VARCHAR},  #{gender,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR},
      #{photos,jdbcType=VARCHAR},#{createBy,jdbcType=VARCHAR},
      <if test="createTime==null" >
        NOW()
      </if>
      <if test="createTime!=null" >
       #{createTime,jdbcType=TIMESTAMP}
      </if>
      , #{createBy,jdbcType=VARCHAR}, NOW()
   ) /*where
    not exists (select   ad.employeeId,
    ad.employeeName,ad.signDate
    from att_day ad
    where ad.signDate = date_format(NOW(),'%y-%m-%d')  )*/
  </insert>
 
 
  <!-- 定时 每天 添加参数传递 的空数据  启动也可以动-->
  <!-- BbEmployee 字段 orgId  userId userName -->
  <insert id="insertMoreData" parameterType="java.util.List" >
    insert into att_day ( orgId, employeeId,
    employeeName, signDate,  createBy,
    createDate, updateBy, updateDate)
    values
    <foreach collection="attDays" index="index" item="item" open="(" separator="),(" close=")">
      #{item.orgId,jdbcType=INTEGER}, #{item.id,jdbcType=INTEGER},
      #{item.userName,jdbcType=VARCHAR},
      <if test=" signDate == null" >
        date_format(NOW(),'%y-%m-%d'),
      </if>
      <if test=" signDate != null" >
       date_format(#{signDate},'%y-%m-%d'),
      </if>
      #{item.createBy,jdbcType=VARCHAR},
      <if test="createTime==null" >
       NOW(),
      </if>
      <if test="createTime!=null" >
       #{createTime,jdbcType=TIMESTAMP},
      </if>
      #{item.updateBy,jdbcType=VARCHAR},
      <if test="updateTime==null" >
        NOW()
      </if>
      <if test="updateTime!=null" >
        #{updateTime,jdbcType=TIMESTAMP}
      </if>
    </foreach>
  </insert>
  <!-- 定时 每天每5分钟 更新所有人 的考勤数据-->
  <update id="updateByMorePerId" parameterType="java.util.List">
    <foreach collection="list" item="attDay" separator=";">
      update att_day
      set
      inTime = #{attDay.inTime,jdbcType=TIMESTAMP},
      outTime = #{attDay.outTime,jdbcType=TIMESTAMP},
      inDeviceId = #{attDay.inDeviceId,jdbcType=VARCHAR},
      inDeviceName = #{attDay.inDeviceName,jdbcType=VARCHAR},
      outDeviceId = #{attDay.outDeviceId,jdbcType=VARCHAR},
      outDeviceName = #{attDay.outDeviceName,jdbcType=VARCHAR},
      <if test="attDay.isNotSign != null" >
      isNotSign = #{attDay.isNotSign,jdbcType=INTEGER},
      </if>
      <if test="attDay.isLate != null" >
      isLate = #{attDay.isLate,jdbcType=INTEGER},
      </if>
      <if test="attDay.isLeaveEarly != null" >
      isLeaveEarly = #{attDay.isLeaveEarly,jdbcType=INTEGER},
      </if>
      <if test="attDay.isLeave != null" >
        isLeave = #{attDay.isLeave,jdbcType=INTEGER},
      </if>
      <if test="attDay.isRepair != null" >
      isRepair = #{attDay.isRepair,jdbcType=INTEGER},
      </if>
      <if test="attDay.revJson != null" >
        revJson = #{attDay.revJson,jdbcType=VARCHAR},
      </if>
      <if test="attDay.updateBy!=null" >
      updateBy = #{attDay.updateBy,jdbcType=VARCHAR},
      </if>
      <if test="attDay.updateTime==null" >
        updateDate = NOW(),
      </if>
      <if test="attDay.updateTime!=null" >
        updateDate = #{attDay.updateTime,jdbcType=TIMESTAMP},
      </if>
      remarks = #{attDay.remarks,jdbcType=VARCHAR},
      <if test="attDay.delFlag==null" >
        delFlag = 0
      </if>
      <if test="attDay.delFlag!=null" >
        delFlag = #{attDay.delFlag,jdbcType=INTEGER}
      </if>
      where employeeId = #{attDay.employeeId ,jdbcType=VARCHAR} and signDate = date_format( #{attDay.signDate,jdbcType=VARCHAR},'%y-%m-%d')
    </foreach>
  </update>
 
  <!-- 启动 更新所有人 之前所有的考勤数据-->
  <update id="updateByMoreSourcePerId" parameterType="java.util.List">
    <foreach collection="list" item="attDay" separator=";">
      update att_day
      set inTime =
      CASE WHEN inTime is NULL THEN #{attDay.inTime,jdbcType=TIMESTAMP}
      WHEN inTime &gt; #{attDay.inTime,jdbcType=TIMESTAMP} THEN #{attDay.inTime,jdbcType=TIMESTAMP}
      ELSE inTime END ,
      outTime = CASE WHEN outTime is NULL THEN #{attDay.outTime,jdbcType=TIMESTAMP}
      WHEN outTime &lt; #{attDay.outTime,jdbcType=TIMESTAMP} THEN #{attDay.outTime,jdbcType=TIMESTAMP}
      ELSE outTime END ,
      inDeviceId =
      CASE WHEN inTime is NULL THEN  #{attDay.inDeviceId,jdbcType=VARCHAR}
      WHEN inTime &gt; #{attDay.inTime,jdbcType=TIMESTAMP} THEN #{attDay.inDeviceId,jdbcType=VARCHAR}
      ELSE inDeviceId END,
      inDeviceName =
      CASE WHEN inTime is NULL THEN   #{attDay.inDeviceName,jdbcType=VARCHAR}
      WHEN inTime &gt; #{attDay.inTime,jdbcType=TIMESTAMP} THEN  #{attDay.inDeviceName,jdbcType=VARCHAR}
      ELSE inDeviceName END,
      outDeviceId =
      CASE WHEN outTime is NULL THEN #{attDay.outDeviceId,jdbcType=VARCHAR}
      WHEN outTime &lt; #{attDay.outTime,jdbcType=TIMESTAMP} THEN #{attDay.outDeviceId,jdbcType=VARCHAR}
      ELSE outDeviceId END,
      outDeviceName =
      CASE WHEN outTime is NULL THEN  #{attDay.outDeviceName,jdbcType=VARCHAR}
      WHEN outTime &lt; #{attDay.outTime,jdbcType=TIMESTAMP} THEN  #{attDay.outDeviceName,jdbcType=VARCHAR}
      ELSE outDeviceName END,
      <if test="attDay.isNotSign != null" >
        isNotSign =
        CASE WHEN isNotSign is NULL THEN  #{attDay.isNotSign,jdbcType=INTEGER}
        WHEN isNotSign = 0 THEN  0
        ELSE #{attDay.isNotSign,jdbcType=INTEGER} END,
      </if>
      <if test="attDay.isLate != null" >
        isLate =
        CASE WHEN isLate is NULL THEN  #{attDay.isLate,jdbcType=INTEGER}
        WHEN isLate = 0 THEN  0
        ELSE #{attDay.isLate,jdbcType=INTEGER} END,
      </if>
      <if test="attDay.isLeaveEarly != null" >
        isLeaveEarly =
        CASE WHEN isLeaveEarly is NULL THEN  #{attDay.isLeaveEarly,jdbcType=INTEGER}
        WHEN isLeaveEarly = 0 THEN  0
        ELSE #{attDay.isLeaveEarly,jdbcType=INTEGER} END,
      </if>
      <if test="attDay.isLeave != null" >
        isLeave = #{attDay.isLeave,jdbcType=INTEGER},
      </if>
      <if test="attDay.isRepair != null" >
        isRepair = #{attDay.isRepair,jdbcType=INTEGER},
      </if>
      <if test="attDay.revJson != null" >
        revJson = #{attDay.revJson,jdbcType=VARCHAR},
      </if>
      <if test="attDay.updateBy!=null" >
        updateBy = #{attDay.updateBy,jdbcType=VARCHAR},
      </if>
      <if test="attDay.updateTime==null" >
        updateDate = NOW(),
      </if>
      <if test="attDay.updateTime!=null" >
        updateDate = #{attDay.updateTime,jdbcType=TIMESTAMP},
      </if>
      remarks = #{attDay.remarks,jdbcType=VARCHAR},
      <if test="attDay.delFlag==null" >
        delFlag = 0
      </if>
      <if test="attDay.delFlag!=null" >
        delFlag = #{attDay.delFlag,jdbcType=INTEGER}
      </if>
      where employeeId = #{attDay.employeeId ,jdbcType=VARCHAR} and signDate = date_format( #{attDay.signDate,jdbcType=VARCHAR},'%y-%m-%d')
    </foreach>
  </update>
 
</mapper>