zxz 3 tahun lalu
induk
melakukan
52dea03a24

+ 4 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/LeaveInfo.java

@@ -71,10 +71,14 @@ public class LeaveInfo extends BaseModel<LeaveInfo> {
     /**
      * 请假开始时间
      */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
     private Date startDate;
     /**
      * 请假结束时间
      */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
     private Date endDate;
     /**
      * 请假类型

+ 16 - 7
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/ClockInfoServiceImpl.java

@@ -4,11 +4,14 @@ import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.baomidou.mybatisplus.plugins.Page;
 import com.google.common.collect.Lists;
 import com.yh.saas.common.support.util.IdGenerator;
+import com.yh.saas.common.support.util.StringUtils;
 import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
 import com.yh.saas.plugin.yiliangyiyun.entity.ClockInfo;
+import com.yh.saas.plugin.yiliangyiyun.entity.LeaveInfo;
 import com.yh.saas.plugin.yiliangyiyun.mapper.ClockInfoMapper;
 import com.yh.saas.plugin.yiliangyiyun.service.IClockInfoService;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.yh.saas.plugin.yiliangyiyun.service.ILeaveInfoService;
 import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -28,6 +31,8 @@ import java.util.*;
 public class ClockInfoServiceImpl extends ServiceImpl<ClockInfoMapper, ClockInfo> implements IClockInfoService {
     @Autowired
     private IClockInfoService clockInfoService;
+    @Autowired
+    private ILeaveInfoService leaveInfoService;
 
     /**
      * 添加打卡信息
@@ -68,13 +73,17 @@ public class ClockInfoServiceImpl extends ServiceImpl<ClockInfoMapper, ClockInfo
                 .eq("common_id", clockInfo.getCommonId())
                 .eq("delete_flag", "0")
                 .gt("create_date", timeOfDay));
-        //信息不为空,下班打卡
+        //信息不为空
         if (clockInfo1 != null) {
-            if (timeOfFive.compareTo(currentTime) > 0) {
-                //早退
-                clockInfo1.setLeaveEarlyFlag("1");
+            if ("3".equals(clockInfo.getClockType())) {
+                if (timeOfFive.compareTo(currentTime) > 0 && clockInfo1.getLeaveId() == null) {
+                    //早退
+                    clockInfo1.setLeaveEarlyFlag("1");
+                }
+                clockInfo1.setOffClockDate(date);
+            } else {
+                clockInfo1.setToClockDate(date);
             }
-            clockInfo1.setOffClockDate(date);
             //更新主表数据
             this.updateById(clockInfo1);
         }
@@ -83,7 +92,7 @@ public class ClockInfoServiceImpl extends ServiceImpl<ClockInfoMapper, ClockInfo
             clockInfo.setId(IdGenerator.generateUUID());
             //下班打卡
             if ("3".equals(clockInfo.getClockType())) {
-                if (timeOfFive.compareTo(currentTime) > 0) {
+                if (timeOfFive.compareTo(currentTime) > 0 && clockInfo1.getLeaveId() == null) {
                     //早退
                     clockInfo.setLeaveEarlyFlag("1");
                 }
@@ -91,7 +100,7 @@ public class ClockInfoServiceImpl extends ServiceImpl<ClockInfoMapper, ClockInfo
             }
             //上班打卡
             else {
-                if (currentTime.compareTo(timeOfEight) > 0) {
+                if (currentTime.compareTo(timeOfEight) > 0 && clockInfo1.getLeaveId() == null) {
                     //迟到
                     clockInfo.setLateFlag("1");
                 }

+ 37 - 20
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/LeaveInfoServiceImpl.java

@@ -1,5 +1,6 @@
 package com.yh.saas.plugin.yiliangyiyun.service.impl;
 
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.baomidou.mybatisplus.plugins.Page;
 import com.google.common.collect.Lists;
 import com.yh.saas.common.support.util.IdGenerator;
@@ -13,9 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 /**
  * <p>
@@ -39,30 +39,47 @@ public class LeaveInfoServiceImpl extends ServiceImpl<LeaveInfoMapper, LeaveInfo
     @Override
     @Transactional(rollbackFor = Exception.class)
     public String addLeave(LeaveInfo leaveInfo) {
+        //当天零点
+        SimpleDateFormat now = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
+        Calendar a = Calendar.getInstance();
+        a.setTime(new Date());
+        a.add(Calendar.YEAR, 0);
+        Date x = a.getTime();
+        String timeOfDay = now.format(x);
         String ClockId = IdGenerator.generateUUID();
         //新增主键id
         leaveInfo.setId(IdGenerator.generateUUID());
         leaveInfo.setClockId(ClockId);
         leaveInfo.setStatus("待审核");
         leaveInfo.setStatusFlag("1");
-        boolean one = this.insert(leaveInfo);
-        //新增打卡信息
-        ClockInfo clockInfo = new ClockInfo();
-        clockInfo.setId(ClockId);
-        clockInfo.setLeaveId(leaveInfo.getId());
-        clockInfo.setCommonId(leaveInfo.getCommonId());
-        clockInfo.setCompId(leaveInfo.getCompId());
-        clockInfo.setDept(leaveInfo.getDept());
-        clockInfo.setEmpName(leaveInfo.getEmpName());
-        clockInfo.setPhone(leaveInfo.getPhone());
-        clockInfo.setLeaveId(leaveInfo.getId());
-        clockInfo.setLeaveType(leaveInfo.getLeaveType());
-        boolean two = clockInfoService.insert(clockInfo);
-        if (one && two) {
-            return "OK";
-        } else {
-            return "NG";
+        this.insert(leaveInfo);
+        //查询打卡信息
+        ClockInfo clockInfo1 = clockInfoService.selectOne(new EntityWrapper<ClockInfo>()
+                    .eq("comp_id",leaveInfo.getCompId())
+                    .eq("common_id",leaveInfo.getCommonId())
+                    .eq("delete_flag","0")
+                    .gt("create_date",timeOfDay));
+        if(clockInfo1 != null){
+            clockInfo1.setLeaveId(leaveInfo.getId());
+            clockInfo1.setLeaveType(leaveInfo.getLeaveType());
+            //修改数据
+            clockInfoService.updateById(clockInfo1);
         }
+        else {
+            //新增打卡信息
+            ClockInfo clockInfo = new ClockInfo();
+            clockInfo.setId(ClockId);
+            clockInfo.setLeaveId(leaveInfo.getId());
+            clockInfo.setCommonId(leaveInfo.getCommonId());
+            clockInfo.setCompId(leaveInfo.getCompId());
+            clockInfo.setDept(leaveInfo.getDept());
+            clockInfo.setEmpName(leaveInfo.getEmpName());
+            clockInfo.setPhone(leaveInfo.getPhone());
+            clockInfo.setLeaveType(leaveInfo.getLeaveType());
+            clockInfoService.insert(clockInfo);
+        }
+        return "OK";
+
     }
 
     /**

+ 2 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/ClockInfoMapper.xml

@@ -10,6 +10,7 @@
         comp_id = #{compId}
         and common_id = #{commonId}
         and delete_flag = '0'
+        and leave_id == null
     </select>
     <!-- 打卡记录查询 -->
     <select id="getListByCondition" parameterType="Map"
@@ -37,6 +38,7 @@
         comp_id = #{compId}
         and common_id = #{commonId}
         and delete_flag = '0'
+        and leave_id == null
         ORDER BY create_date
         <if test="currentPage != null and currentPage != ''">
             LIMIT ${startRecord}, ${pageSize}

+ 1 - 1
winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/LeaveInfoMapper.xml

@@ -37,7 +37,7 @@
         comp_id = #{compId}
         and common_id = #{commonId}
         and delete_flag = '0'
-        ORDER BY create_date
+        ORDER BY create_date DESC
         <if test="currentPage != null and currentPage != ''">
             LIMIT ${startRecord}, ${pageSize}
         </if>