zxz 3 lat temu
rodzic
commit
552d58be5c

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

@@ -1,9 +1,11 @@
 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.LeaveInfo;
+import com.yh.saas.plugin.yiliangyiyun.service.ILeaveInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
 
 /**
  * <p>
@@ -16,6 +18,38 @@ import org.springframework.web.bind.annotation.RestController;
 @RestController
 @RequestMapping("/leaveInfo")
 public class LeaveInfoController {
+    @Autowired
+    private ILeaveInfoService leaveInfoService;
 
+    /**
+     * 添加请假信息
+     *
+     * @param leaveInfo
+     * @return
+     */
+    @PostMapping("/api/addLeave")
+    public String addLeave(@RequestBody LeaveInfo leaveInfo) {
+        return leaveInfoService.addLeave(leaveInfo);
+    }
+    /**
+     * 请假记录查询
+     *
+     * @param leaveInfo
+     * @return
+     */
+    @GetMapping("/selectLeaveInfo")
+    public Page<LeaveInfo> selectLeaveInfo(LeaveInfo leaveInfo) {
+        return leaveInfoService.selectLeaveInfo(leaveInfo);
+    }
+    /**
+     * 请假记录查询(PC)
+     *
+     * @param leaveInfo
+     * @return
+     */
+    @GetMapping("/selectLeaveInfoPc")
+    public Page<LeaveInfo> selectLeaveInfoPc(LeaveInfo leaveInfo) {
+        return leaveInfoService.selectLeaveInfoPc(leaveInfo);
+    }
 }
 

+ 30 - 1
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/LeaveInfo.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>
@@ -45,6 +48,14 @@ public class LeaveInfo extends BaseModel<LeaveInfo> {
      * 用户id
      */
     private String commonId;
+    /**
+     * 部门
+     */
+    private String dept;
+    /**
+     * 手机号
+     */
+    private String phone;
     /**
      * 请假编号
      */
@@ -93,7 +104,25 @@ public class LeaveInfo extends BaseModel<LeaveInfo> {
      * 工作流ID
      */
     private String workflowId;
-
+    /**
+     * 模糊查询
+     */
+    @TableField(exist = false)
+    private String searchKeyWord;
+    /**
+     * 开始时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @TableField(exist = false)
+    private Date theStartDate;
+    /**
+     * 结束时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @TableField(exist = false)
+    private Date theEndDate;
 
     @Override
     protected Serializable pkVal() {

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

@@ -1,8 +1,12 @@
 package com.yh.saas.plugin.yiliangyiyun.mapper;
 
+import com.yh.saas.plugin.yiliangyiyun.entity.ClockInfo;
 import com.yh.saas.plugin.yiliangyiyun.entity.LeaveInfo;
 import com.baomidou.mybatisplus.mapper.BaseMapper;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  * 记录请假信息 Mapper 接口
@@ -12,5 +16,34 @@ import com.baomidou.mybatisplus.mapper.BaseMapper;
  * @since 2022-06-22
  */
 public interface LeaveInfoMapper extends BaseMapper<LeaveInfo> {
+    /**
+     * 根据条件查询总数
+     *
+     * @param pageView
+     * @return
+     */
+    Integer getCountByCondition(Map<String, Object> pageView);
+
+    /**
+     * 根据条件查询请假记录
+     *
+     * @param pageView
+     * @return
+     */
+    List<LeaveInfo> getListByCondition(Map<String, Object> pageView);
+    /**
+     * 根据条件查询总数(PC)
+     *
+     * @param pageView
+     * @return
+     */
+    Integer getCountByConditionPc(Map<String, Object> pageView);
 
+    /**
+     * 根据条件查询请假记录(PC)
+     *
+     * @param pageView
+     * @return
+     */
+    List<LeaveInfo> getListByConditionPc(Map<String, Object> pageView);
 }

+ 21 - 1
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/ILeaveInfoService.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.LeaveInfo;
 import com.baomidou.mybatisplus.service.IService;
 
@@ -12,5 +13,24 @@ import com.baomidou.mybatisplus.service.IService;
  * @since 2022-06-22
  */
 public interface ILeaveInfoService extends IService<LeaveInfo> {
-
+    /**
+     * 添加请假信息
+     *
+     * @param leaveInfo
+     */
+    String addLeave(LeaveInfo leaveInfo);
+    /**
+     * 请假记录查询
+     *
+     * @param leaveInfo
+     * @return
+     */
+    Page<LeaveInfo> selectLeaveInfo(LeaveInfo leaveInfo);
+    /**
+     * 请假记录查询(PC)
+     *
+     * @param leaveInfo
+     * @return
+     */
+    Page<LeaveInfo> selectLeaveInfoPc(LeaveInfo leaveInfo);
 }

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

@@ -1,10 +1,21 @@
 package com.yh.saas.plugin.yiliangyiyun.service.impl;
 
+import com.baomidou.mybatisplus.plugins.Page;
+import com.google.common.collect.Lists;
+import com.yh.saas.common.support.util.IdGenerator;
+import com.yh.saas.plugin.yiliangyiyun.entity.ClockInfo;
 import com.yh.saas.plugin.yiliangyiyun.entity.LeaveInfo;
 import com.yh.saas.plugin.yiliangyiyun.mapper.LeaveInfoMapper;
+import com.yh.saas.plugin.yiliangyiyun.service.IClockInfoService;
 import com.yh.saas.plugin.yiliangyiyun.service.ILeaveInfoService;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+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;
 
 /**
  * <p>
@@ -16,5 +27,96 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class LeaveInfoServiceImpl extends ServiceImpl<LeaveInfoMapper, LeaveInfo> implements ILeaveInfoService {
+    @Autowired
+    private IClockInfoService clockInfoService;
+
+    /**
+     * 添加请假信息
+     *
+     * @param leaveInfo
+     * @return
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public String addLeave(LeaveInfo leaveInfo) {
+        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";
+        }
+    }
+
+    /**
+     * 请假记录查询
+     *
+     * @param leaveInfo
+     * @return
+     */
+    @Override
+    public Page<LeaveInfo> selectLeaveInfo(LeaveInfo leaveInfo) {
+        Map<String, Object> pageView = new HashMap<>();
+        pageView.put("startRecord", (leaveInfo.getCurrentPage() - 1)
+                * leaveInfo.getPageSize());
+        //  公司ID
+        pageView.put("compId", leaveInfo.getCompId());
+        pageView.put("commonId", leaveInfo.getCommonId());
+        pageView.put("pageSize", leaveInfo.getPageSize());
+        pageView.put("currentPage", leaveInfo.getCurrentPage());
+        // 查询总数
+        Integer dataCount = baseMapper.getCountByCondition(pageView);
+        List<LeaveInfo> dataList = baseMapper.getListByCondition(pageView);
+        Page<LeaveInfo> page = new Page<>();
+        page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
+        page.setTotal(dataCount == null ? 0 : dataCount);
+        page.setCurrent(leaveInfo.getCurrentPage());
+        page.setSize(leaveInfo.getPageSize());
+        return page;
+    }
 
+    /**
+     * 请假记录查询(PC)
+     * @param leaveInfo
+     * @return
+     */
+    @Override
+    public Page<LeaveInfo> selectLeaveInfoPc(LeaveInfo leaveInfo) {
+        Map<String, Object> pageView = new HashMap<>();
+        pageView.put("startRecord", (leaveInfo.getCurrentPage() - 1)
+                * leaveInfo.getPageSize());
+        //  公司ID
+        pageView.put("compId", leaveInfo.getCompId());
+        pageView.put("pageSize", leaveInfo.getPageSize());
+        pageView.put("currentPage", leaveInfo.getCurrentPage());
+        pageView.put("searchKeyWord", leaveInfo.getSearchKeyWord());
+        pageView.put("theStartDate", leaveInfo.getTheStartDate());
+        pageView.put("theEndDate", leaveInfo.getTheEndDate());
+        // 查询总数
+        Integer dataCount = baseMapper.getCountByConditionPc(pageView);
+        List<LeaveInfo> dataList = baseMapper.getListByConditionPc(pageView);
+        Page<LeaveInfo> page = new Page<>();
+        page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
+        page.setTotal(dataCount == null ? 0 : dataCount);
+        page.setCurrent(leaveInfo.getCurrentPage());
+        page.setSize(leaveInfo.getPageSize());
+        return page;
+    }
 }

+ 19 - 3
winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/ClockInfoMapper.xml

@@ -51,8 +51,16 @@
         WHERE
         cl.comp_id = #{compId}
         and cl.delete_flag = '0'
+        <if test="startDate != null">
+            AND (DATE_FORMAT(cl.create_date,"%Y%m%d") &gt;=
+            DATE_FORMAT(#{startDate},"%Y%m%d"))
+        </if>
+        <if test="endDate != null">
+            AND (DATE_FORMAT(cl.create_date,"%Y%m%d") &lt;=
+            DATE_FORMAT(#{endDate},"%Y%m%d"))
+        </if>
         <if test="searchKeyWord != null and searchKeyWord != ''">
-            AND (lower(emp_name) like lower(CONCAT('%',#{searchKeyWord},'%'))
+            AND (lower(cl.emp_name) like lower(CONCAT('%',#{searchKeyWord},'%')))
         </if>
     </select>
     <!-- 考勤记录查询 -->
@@ -84,10 +92,18 @@
         WHERE
         cl.comp_id = #{compId}
         and cl.delete_flag = '0'
-        GROUP BY cl.emp_name
+        <if test="startDate != null">
+            AND (DATE_FORMAT(cl.create_date,"%Y%m%d") &gt;=
+            DATE_FORMAT(#{startDate},"%Y%m%d"))
+        </if>
+        <if test="endDate != null">
+            AND (DATE_FORMAT(cl.create_date,"%Y%m%d") &lt;=
+            DATE_FORMAT(#{endDate},"%Y%m%d"))
+        </if>
         <if test="searchKeyWord != null and searchKeyWord != ''">
-            AND (lower(emp_name) like lower(CONCAT('%',#{searchKeyWord},'%'))
+            AND (lower(cl.emp_name) like lower(CONCAT('%',#{searchKeyWord},'%')))
         </if>
+        GROUP BY cl.emp_name
         <if test="currentPage != null and currentPage != ''">
             LIMIT ${startRecord}, ${pageSize}
         </if>

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

@@ -1,5 +1,108 @@
 <?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.LeaveInfoMapper">
+    <!-- 获得请假记录总数 -->
+    <select id="getCountByCondition" parameterType="Map" resultType="java.lang.Integer">
+        SELECT
+        COUNT(id)
+        FROM leave_info
+        WHERE
+        comp_id = #{compId}
+        and common_id = #{commonId}
+        and delete_flag = '0'
+    </select>
+    <!-- 请假记录查询 -->
+    <select id="getListByCondition" parameterType="Map"
+            resultType="com.yh.saas.plugin.yiliangyiyun.entity.LeaveInfo">
+        SELECT
+        id,
+        comp_id as compId,
+        common_id as commonId,
+        dept,
+        phone,
+        emp_name as empName,
+        clock_id as clockId,
+        reason_for_leave as reasonForLeave,
+        start_date as startDate,
+        end_date as endDate,
+        leave_type as leaveType,
+        leave_type_key as leaveTypeKey,
+        leave_duration as leaveDuration,
+        status,
+        status_flag as statusFlag,
+        approve_status as approveStatus,
+        create_date as createDate
+        FROM leave_info
+        WHERE
+        comp_id = #{compId}
+        and common_id = #{commonId}
+        and delete_flag = '0'
+        ORDER BY create_date
+        <if test="currentPage != null and currentPage != ''">
+            LIMIT ${startRecord}, ${pageSize}
+        </if>
+    </select>
+    <!-- 获得请假记录总数(PC) -->
+    <select id="getCountByConditionPc" parameterType="Map" resultType="java.lang.Integer">
+        SELECT
+        COUNT(id)
+        FROM leave_info
+        WHERE
+        comp_id = #{compId}
+        and delete_flag = '0'
+        <if test="theStartDate != null">
+            AND (DATE_FORMAT(create_date,"%Y%m%d") &gt;=
+            DATE_FORMAT(#{theStartDate},"%Y%m%d"))
+        </if>
+        <if test="theEndDate != null">
+            AND (DATE_FORMAT(create_date,"%Y%m%d") &lt;=
+            DATE_FORMAT(#{theEndDate},"%Y%m%d"))
+        </if>
+        <if test="searchKeyWord != null and searchKeyWord != ''">
+            AND (lower(emp_name) like lower(CONCAT('%',#{searchKeyWord},'%')))
+        </if>
+    </select>
+    <!-- 请假记录查询(PC) -->
+    <select id="getListByConditionPc" parameterType="Map"
+            resultType="com.yh.saas.plugin.yiliangyiyun.entity.LeaveInfo">
+        SELECT
+        id,
+        comp_id as compId,
+        common_id as commonId,
+        dept,
+        phone,
+        leave_no as leaveNo,
+        emp_name as empName,
+        clock_id as clockId,
+        reason_for_leave as reasonForLeave,
+        start_date as startDate,
+        end_date as endDate,
+        leave_type as leaveType,
+        leave_type_key as leaveTypeKey,
+        leave_duration as leaveDuration,
+        status,
+        status_flag as statusFlag,
+        approve_status as approveStatus,
+        create_date as createDate
+        FROM leave_info
+        WHERE
+        comp_id = #{compId}
+        and delete_flag = '0'
 
+        <if test="theStartDate != null">
+            AND (DATE_FORMAT(create_date,"%Y%m%d") &gt;=
+            DATE_FORMAT(#{theStartDate},"%Y%m%d"))
+        </if>
+        <if test="theEndDate != null">
+            AND (DATE_FORMAT(create_date,"%Y%m%d") &lt;=
+            DATE_FORMAT(#{theEndDate},"%Y%m%d"))
+        </if>
+        <if test="searchKeyWord != null and searchKeyWord != ''">
+            AND (lower(emp_name) like lower(CONCAT('%',#{searchKeyWord},'%')))
+        </if>
+        ORDER BY leave_no
+        <if test="currentPage != null and currentPage != ''">
+            LIMIT ${startRecord}, ${pageSize}
+        </if>
+    </select>
 </mapper>