Browse Source

新增法定节假日,补班判定

anderx 1 year ago
parent
commit
6da4790954

+ 4 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java

@@ -90,6 +90,10 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     {
         return new SimpleDateFormat(YYYYnMMyDDrHH_MM_SS).format(date);
     }
+    public static final String parseStrYYYYnMMyDD(final Date date)
+    {
+        return new SimpleDateFormat(YYYY_MM_DD).format(date);
+    }
     public static final Date dateTime(final String format, final String ts)
     {
         try

+ 13 - 0
ruoyi-system/src/main/java/com/ruoyi/project/bo/MyMonthDays.java

@@ -8,6 +8,19 @@ public class MyMonthDays {
      *  0 =未到时限 1=满工时,2=未打卡,3=未满工时
      */
     private Integer status;
+    /**
+     * 0=正常,1=不属于打卡区间,2=未到时限,3=补班,4=法定节假日
+     */
+    private Integer dayStatus;
+
+
+    public Integer getDayStatus() {
+        return dayStatus;
+    }
+
+    public void setDayStatus(Integer dayStatus) {
+        this.dayStatus = dayStatus;
+    }
 
     public Integer getWeek() {
         return week;

+ 56 - 8
ruoyi-system/src/main/java/com/ruoyi/project/service/impl/ProjectStaffRecordServiceImpl.java

@@ -23,6 +23,8 @@ import com.ruoyi.project.mapper.ProjectStaffRecordLogMapper;
 import com.ruoyi.project.mapper.ProjectStaffRecordMapper;
 import com.ruoyi.project.mapper.ProjectTaskMapper;
 import com.ruoyi.project.service.ProjectStaffRecordService;
+import com.ruoyi.system.domain.LegalHolidays;
+import com.ruoyi.system.mapper.LegalHolidaysMapper;
 import com.ruoyi.system.mapper.SysUserMapper;
 import com.ruoyi.system.service.ISysDeptService;
 import com.ruoyi.system.service.impl.SysConfigServiceImpl;
@@ -69,6 +71,8 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
 
     @Autowired
     private SysConfigServiceImpl configService;
+    @Autowired
+    private LegalHolidaysMapper legalHolidaysMapper;
 
 
 
@@ -181,25 +185,69 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
      * @param maxDuration  最大工时
      */
     private void pushMyMonthDay(List<MyMonthDays> myMonthDays, ProjectTask projectTask, String date, BigDecimal maxDuration) {
+        List<LegalHolidays> legalHolidays = legalHolidaysMapper.selectAll();
+
         for (MyMonthDays myMonthDay : myMonthDays) {
             DateUtils.getWeeks(myMonthDay.getDates());
-//            0 =未到时限 1=满工时,2=未打卡,3=未满工时,4=不属于打卡区间
+//            status    0=未打卡,1=未满工时,2=满工时
+//             daystatus 0=正常,1=不属于打卡区间,2=未到时限,3=补班,4=法定节假日
+            pushLeaglHolidays(legalHolidays,myMonthDay);
             if (compareTo(projectTask.getStartTime(),myMonthDay.getDates(),0)||compareTo(projectTask.getEndTime(),myMonthDay.getDates(),1)){
-                myMonthDay.setStatus(4);
+                myMonthDay.setDayStatus(1);
                 myMonthDay.setDuration("0");
             }else if (compareTo(date,myMonthDay.getDates())){
-                myMonthDay.setStatus(0);
+                myMonthDay.setDayStatus(2);
             }else if (myMonthDay.getDuration().equals("0")) {
-                myMonthDay.setStatus(2);
+                myMonthDay.setStatus(0);
             }else if (new BigDecimal(myMonthDay.getDuration()).compareTo(maxDuration)<0){
-                myMonthDay.setStatus(3);
-            }else if (new BigDecimal(myMonthDay.getDuration()).compareTo(maxDuration)>=0){
                 myMonthDay.setStatus(1);
-            }else {
-                myMonthDay.setStatus(5);
+            }else if (new BigDecimal(myMonthDay.getDuration()).compareTo(maxDuration)>=0){
+                myMonthDay.setStatus(2);
+            }
+        }
+    }
+
+    private void pushLeaglHolidays(List<LegalHolidays> list, MyMonthDays myMonthDay) {
+        String dates = myMonthDay.getDates();
+        myMonthDay.setDayStatus(0);
+        List<HolidaysBo> boList=new ArrayList<>();
+        for (LegalHolidays e : list) {
+            String parseStr = DateUtils.parseStrYYYYnMMyDD(e.getHolidays());
+            HolidaysBo holidaysBo=new HolidaysBo();
+            holidaysBo.setDays(parseStr);
+            holidaysBo.setStatus(e.getStatus());
+            boList.add(holidaysBo);
+        }
+        for (HolidaysBo e : boList) {
+            if (dates.equals(e.getDays())){
+                if (e.getStatus()==1){
+                    myMonthDay.setDayStatus(4);
+                }else if (e.getStatus()==2) {
+                    myMonthDay.setDayStatus(3);
+                }
             }
         }
     }
+    class HolidaysBo{
+        private String days;
+        private Integer status;
+
+        public String getDays() {
+            return days;
+        }
+
+        public void setDays(String days) {
+            this.days = days;
+        }
+
+        public Integer getStatus() {
+            return status;
+        }
+
+        public void setStatus(Integer status) {
+            this.status = status;
+        }
+    }
 
 
     @Override

+ 110 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/LegalHolidays.java

@@ -0,0 +1,110 @@
+package com.ruoyi.system.domain;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 法定节假日
+ * @TableName legal_holidays
+ */
+public class LegalHolidays implements Serializable {
+    /**
+     * 编号
+     */
+    private Integer id;
+
+    /**
+     * 日期时间
+     */
+    private Date holidays;
+
+    /**
+     * 项目状态
+     */
+    private Integer status;
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 编号
+     */
+    public Integer getId() {
+        return id;
+    }
+
+    /**
+     * 编号
+     */
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    /**
+     * 日期时间
+     */
+    public Date getHolidays() {
+        return holidays;
+    }
+
+    /**
+     * 日期时间
+     */
+    public void setHolidays(Date holidays) {
+        this.holidays = holidays;
+    }
+
+    /**
+     * 项目状态
+     */
+    public Integer getStatus() {
+        return status;
+    }
+
+    /**
+     * 项目状态
+     */
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    @Override
+    public boolean equals(Object that) {
+        if (this == that) {
+            return true;
+        }
+        if (that == null) {
+            return false;
+        }
+        if (getClass() != that.getClass()) {
+            return false;
+        }
+        LegalHolidays other = (LegalHolidays) that;
+        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+            && (this.getHolidays() == null ? other.getHolidays() == null : this.getHolidays().equals(other.getHolidays()))
+            && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()));
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+        result = prime * result + ((getHolidays() == null) ? 0 : getHolidays().hashCode());
+        result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", holidays=").append(holidays);
+        sb.append(", status=").append(status);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 28 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/LegalHolidaysMapper.java

@@ -0,0 +1,28 @@
+package com.ruoyi.system.mapper;
+
+import com.ruoyi.system.domain.LegalHolidays;
+
+import java.util.List;
+
+/**
+* @author Administrator
+* @description 针对表【legal_holidays(法定节假日)】的数据库操作Mapper
+* @createDate 2024-02-22 10:58:56
+* @Entity com.ruoyi.system.domain.LegalHolidays
+*/
+public interface LegalHolidaysMapper {
+
+    int deleteByPrimaryKey(Long id);
+
+    int insert(LegalHolidays record);
+
+    int insertSelective(LegalHolidays record);
+
+    LegalHolidays selectByPrimaryKey(Long id);
+
+    int updateByPrimaryKeySelective(LegalHolidays record);
+
+    int updateByPrimaryKey(LegalHolidays record);
+
+    List<LegalHolidays> selectAll();
+}

+ 72 - 0
ruoyi-system/src/main/resources/mapper/LegalHolidaysMapper.xml

@@ -0,0 +1,72 @@
+<?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.ruoyi.system.mapper.LegalHolidaysMapper">
+
+    <resultMap id="BaseResultMap" type="com.ruoyi.system.domain.LegalHolidays">
+            <id property="id" column="id" jdbcType="INTEGER"/>
+            <result property="holidays" column="holidays" jdbcType="DATE"/>
+            <result property="status" column="status" jdbcType="INTEGER"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id,holidays,status
+    </sql>
+
+    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List" />
+        from legal_holidays
+        where  id = #{id,jdbcType=INTEGER} 
+    </select>
+    <select id="selectAll" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List" />
+        from legal_holidays
+    </select>
+
+    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+        delete from legal_holidays
+        where  id = #{id,jdbcType=INTEGER} 
+    </delete>
+    <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ruoyi.system.domain.LegalHolidays" useGeneratedKeys="true">
+        insert into legal_holidays
+        ( id,holidays,status
+        )
+        values (#{id,jdbcType=INTEGER},#{holidays,jdbcType=DATE},#{status,jdbcType=INTEGER}
+        )
+    </insert>
+    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ruoyi.system.domain.LegalHolidays" useGeneratedKeys="true">
+        insert into legal_holidays
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+                <if test="id != null">id,</if>
+                <if test="holidays != null">holidays,</if>
+                <if test="status != null">status,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+                <if test="id != null">#{id,jdbcType=INTEGER},</if>
+                <if test="holidays != null">#{holidays,jdbcType=DATE},</if>
+                <if test="status != null">#{status,jdbcType=INTEGER},</if>
+        </trim>
+    </insert>
+    <update id="updateByPrimaryKeySelective" parameterType="com.ruoyi.system.domain.LegalHolidays">
+        update legal_holidays
+        <set>
+                <if test="holidays != null">
+                    holidays = #{holidays,jdbcType=DATE},
+                </if>
+                <if test="status != null">
+                    status = #{status,jdbcType=INTEGER},
+                </if>
+        </set>
+        where   id = #{id,jdbcType=INTEGER} 
+    </update>
+    <update id="updateByPrimaryKey" parameterType="com.ruoyi.system.domain.LegalHolidays">
+        update legal_holidays
+        set 
+            holidays =  #{holidays,jdbcType=DATE},
+            status =  #{status,jdbcType=INTEGER}
+        where   id = #{id,jdbcType=INTEGER} 
+    </update>
+</mapper>