瀏覽代碼

打卡功能

zxz 3 年之前
父節點
當前提交
87b314d67c

+ 36 - 3
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/ClockInfoController.java

@@ -1,9 +1,12 @@
 package com.yh.saas.plugin.yiliangyiyun.controller;
 
 
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
+import com.baomidou.mybatisplus.plugins.Page;
+import com.yh.saas.plugin.yiliangyiyun.entity.AcquisitionInfo;
+import com.yh.saas.plugin.yiliangyiyun.entity.ClockInfo;
+import com.yh.saas.plugin.yiliangyiyun.service.IClockInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
 
 /**
  * <p>
@@ -16,6 +19,36 @@ import org.springframework.web.bind.annotation.RestController;
 @RestController
 @RequestMapping("/clockInfo")
 public class ClockInfoController {
+    @Autowired
+    private IClockInfoService clockInfoService;
 
+    /**
+     * 添加h上班打卡信息
+     * @param clockInfo
+     * @return
+     */
+    @PostMapping("/api/addClock")
+    public String addClock(@RequestBody ClockInfo clockInfo){
+        return clockInfoService.addClock(clockInfo);
+    }
+    /**
+     * 打卡记录查询
+     *
+     * @param clockInfo
+     * @return
+     */
+    @GetMapping("/selectClockInfo")
+    public Page<ClockInfo> selectClockInfo(ClockInfo clockInfo) {
+        return clockInfoService.selectClockInfo(clockInfo);
+    }
+    /**
+     * 添加补卡信息
+     * @param clockInfo
+     * @return
+     */
+    @PostMapping("/api/suppClock")
+    public String suppClock(@RequestBody ClockInfo clockInfo){
+        return clockInfoService.suppClock(clockInfo);
+    }
 }
 

+ 29 - 6
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/ClockInfo.java

@@ -4,13 +4,16 @@ import java.util.Date;
 import java.io.Serializable;
 
 
+import com.baomidou.mybatisplus.annotations.TableField;
 import com.baomidou.mybatisplus.annotations.TableId;
 import com.baomidou.mybatisplus.annotations.TableName;
 import com.baomidou.mybatisplus.enums.IdType;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.yh.saas.common.support.entity.BaseModel;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
+import org.springframework.format.annotation.DateTimeFormat;
 
 /**
  * <p>
@@ -58,7 +61,7 @@ public class ClockInfo extends BaseModel<ClockInfo> {
      */
     private String empName;
     /**
-     * 打卡原因(1上班/下班3其他)
+     * 打卡原因(1上班3下班)
      */
     private String clockType;
     /**
@@ -66,27 +69,35 @@ public class ClockInfo extends BaseModel<ClockInfo> {
      */
     private Double clockDistance;
     /**
-     * 目标位置
+     * 早退标识(1是)
      */
-    private String targetLocation;
+    private String leaveEarlyFlag;
     /**
-     * 其他原因
+     * 迟到标识(1是)
+     */
+    private String lateFlag;
+    /**
+     * 目标位置
      */
-    private String otherReasons;
+    private String targetLocation;
     /**
      * 上班打卡时间
      */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date toClockDate;
     /**
      * 下班打卡时间
      */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date offClockDate;
     /**
      * 请假类型
      */
     private String leaveType;
     /**
-     * 补卡原因(1上班/下班3其他)
+     * 补卡原因(1上班3下班)
      */
     private String supplementClockType;
     /**
@@ -109,6 +120,18 @@ public class ClockInfo extends BaseModel<ClockInfo> {
      * 工作流ID
      */
     private String workflowId;
+    /**
+     * APP端(传0)
+     */
+    @TableField(exist = false)
+    private String pcFlag;
+    /**
+     * 打卡日期
+     */
+    @TableField(exist = false)
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    private Date theClockDate;
 
 
     @Override

+ 17 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/mapper/ClockInfoMapper.java

@@ -3,6 +3,9 @@ package com.yh.saas.plugin.yiliangyiyun.mapper;
 import com.yh.saas.plugin.yiliangyiyun.entity.ClockInfo;
 import com.baomidou.mybatisplus.mapper.BaseMapper;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  * 记录打卡信息 Mapper 接口
@@ -12,5 +15,19 @@ import com.baomidou.mybatisplus.mapper.BaseMapper;
  * @since 2022-06-11
  */
 public interface ClockInfoMapper extends BaseMapper<ClockInfo> {
+    /**
+     * 根据条件查询总数
+     *
+     * @param pageView
+     * @return
+     */
+    Integer getCountByCondition(Map<String, Object> pageView);
 
+    /**
+     * 根据条件查询打卡记录
+     *
+     * @param pageView
+     * @return
+     */
+    List<ClockInfo> getListByCondition(Map<String, Object> pageView);
 }

+ 18 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/IClockInfoService.java

@@ -1,5 +1,6 @@
 package com.yh.saas.plugin.yiliangyiyun.service;
 
+import com.baomidou.mybatisplus.plugins.Page;
 import com.yh.saas.plugin.yiliangyiyun.entity.ClockInfo;
 import com.baomidou.mybatisplus.service.IService;
 
@@ -13,4 +14,21 @@ import com.baomidou.mybatisplus.service.IService;
  */
 public interface IClockInfoService extends IService<ClockInfo> {
 
+    /**
+     * 添加上班打卡信息
+     * @param  clockInfo
+     */
+    String addClock(ClockInfo clockInfo);
+    /**
+     * 打卡记录
+     *
+     * @param clockInfo
+     * @return
+     */
+    Page<ClockInfo> selectClockInfo(ClockInfo clockInfo);
+    /**
+     * 添加补卡信息
+     * @param  clockInfo
+     */
+    String suppClock(ClockInfo clockInfo);
 }

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

@@ -1,11 +1,22 @@
 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.winsea.svc.base.security.util.AuthSecurityUtils;
+import com.yh.saas.common.support.util.IdGenerator;
+import com.yh.saas.common.support.util.StringUtils;
 import com.yh.saas.plugin.yiliangyiyun.entity.ClockInfo;
 import com.yh.saas.plugin.yiliangyiyun.mapper.ClockInfoMapper;
 import com.yh.saas.plugin.yiliangyiyun.service.IClockInfoService;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.util.*;
+
 /**
  * <p>
  * 记录打卡信息 服务实现类
@@ -17,4 +28,130 @@ import org.springframework.stereotype.Service;
 @Service
 public class ClockInfoServiceImpl extends ServiceImpl<ClockInfoMapper, ClockInfo> implements IClockInfoService {
 
-}
+    /**
+     * 添加打卡信息
+     *
+     * @param clockInfo
+     * @return
+     */
+    @Override
+    public String addClock(ClockInfo clockInfo) {
+        //当天零点
+        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);
+        //早八
+        SimpleDateFormat eight = new SimpleDateFormat("yyyy-MM-dd 08:00:00");
+        Calendar b = Calendar.getInstance();
+        b.setTime(new Date());
+        b.add(Calendar.YEAR, 0);
+        Date y = b.getTime();
+        String timeOfEight = eight.format(y);
+        //晚五
+        SimpleDateFormat five = new SimpleDateFormat("yyyy-MM-dd 17:00:00");
+        Calendar c = Calendar.getInstance();
+        c.setTime(new Date());
+        c.add(Calendar.YEAR, 0);
+        Date z = c.getTime();
+        String timeOfFive = five.format(z);
+        //获取当前系统时间
+        Date date = new Date();
+        SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String currentTime = s.format(date);
+        //查询打卡信息
+        ClockInfo clockInfo1 = this.selectOne(new EntityWrapper<ClockInfo>()
+                .eq("comp_id", clockInfo.getCompId())
+                .eq("common_id", clockInfo.getCommonId())
+                .gt("create_date", timeOfDay));
+        //信息不为空,下班打卡
+        if (clockInfo1 != null) {
+            if (timeOfFive.compareTo(currentTime) > 0) {
+                //早退
+                clockInfo1.setLeaveEarlyFlag("1");
+            }
+            clockInfo1.setOffClockDate(date);
+            //更新主表数据
+            this.updateById(clockInfo1);
+        }
+        //信息为空
+        else {
+            clockInfo.setId(IdGenerator.generateUUID());
+            //下班打卡
+            if ("3".equals(clockInfo.getClockType())) {
+                if (timeOfFive.compareTo(currentTime) > 0) {
+                    //早退
+                    clockInfo.setLeaveEarlyFlag("1");
+                }
+                clockInfo.setOffClockDate(date);
+            }
+            //上班打卡
+            else {
+                if (currentTime.compareTo(timeOfEight) > 0) {
+                    //迟到
+                    clockInfo.setLateFlag("1");
+                }
+                clockInfo.setToClockDate(date);
+            }
+            //操作主表数据
+            this.insert(clockInfo);
+        }
+        return "OK";
+    }
+
+    /**
+     * 打卡记录
+     *
+     * @param clockInfo
+     * @return
+     */
+    @Override
+    public Page<ClockInfo> selectClockInfo(ClockInfo clockInfo) {
+        Map<String, Object> pageView = new HashMap<>();
+        pageView.put("startRecord", (clockInfo.getCurrentPage() - 1)
+                * clockInfo.getPageSize());
+        //  公司ID
+        pageView.put("compId", clockInfo.getCompId());
+        pageView.put("commonId", clockInfo.getCommonId());
+        pageView.put("pageSize", clockInfo.getPageSize());
+        pageView.put("currentPage", clockInfo.getCurrentPage());
+        // 查询总数
+        Integer dataCount = baseMapper.getCountByCondition(pageView);
+        List<ClockInfo> dataList = baseMapper.getListByCondition(pageView);
+        Page<ClockInfo> page = new Page<>();
+        page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
+        page.setTotal(dataCount == null ? 0 : dataCount);
+        page.setCurrent(clockInfo.getCurrentPage());
+        page.setSize(clockInfo.getPageSize());
+        return page;
+    }
+
+    /**
+     * 添加补卡信息
+     *
+     * @param clockInfo
+     * @return
+     */
+    @Override
+    public String suppClock(ClockInfo clockInfo) {
+        //当天零点
+        SimpleDateFormat zero = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
+        Calendar d = Calendar.getInstance();
+        d.setTime(new Date());
+        d.add(Calendar.YEAR, 0);
+        Date n = d.getTime();
+        String zeroOfDay = zero.format(n);
+        //查询打卡信息
+        ClockInfo clockInfo1 = this.selectOne(new EntityWrapper<ClockInfo>()
+                .eq("common_id", clockInfo.getCommonId())
+                .gt("create_date",zeroOfDay));
+        if (clockInfo1 != null) {
+            clockInfo1.setSupplementClockType(clockInfo.getSupplementClockType());
+            clockInfo1.setReasonForApplication(clockInfo.getReasonForApplication());
+            this.updateById(clockInfo1);
+        }
+        return "OK";
+    }
+}

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

@@ -1,5 +1,46 @@
 <?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.yh.saas.plugin.yiliangyiyun.mapper.ClockInfoMapper">
-
+    <!-- 获得打卡记录总数 -->
+    <select id="getCountByCondition" parameterType="Map" resultType="java.lang.Integer">
+        SELECT
+        COUNT(id)
+        FROM clock_info
+        WHERE
+        comp_id = #{compId}
+        and common_id = #{commonId}
+        and delete_flag = '0'
+--         and pc_flag = '0'
+    </select>
+    <!-- 打卡记录查询 -->
+    <select id="getListByCondition" parameterType="Map"
+            resultType="com.yh.saas.plugin.yiliangyiyun.entity.ClockInfo">
+        SELECT
+        id,
+        comp_id as compId,
+        common_id as commonId,
+        dept,
+        phone,
+        emp_name as empName,
+        clock_type as clockType,
+        to_clock_date as toClockDate,
+        off_clock_date as offClockDate,
+        leave_type as leaveType,
+        leave_early_flag as leaveEarlyFlag,
+        late_flag as lateFlag,
+        status,
+        status_flag as statusFlag,
+        approve_status as approveStatus,
+        create_date as createDate
+        FROM clock_info
+        WHERE
+        comp_id = #{compId}
+        and common_id = #{commonId}
+        and delete_flag = '0'
+--         and pc_flag = '0'
+        ORDER BY create_date
+        <if test="currentPage != null and currentPage != ''">
+            LIMIT ${startRecord}, ${pageSize}
+        </if>
+    </select>
 </mapper>