1
0

2 کامیت‌ها 5446c60abe ... 7e9c6846e5

نویسنده SHA1 پیام تاریخ
  fuxubing 7e9c6846e5 Merge remote-tracking branch 'origin/dev' into dev 3 سال پیش
  fuxubing d0c4c75635 bug fix 3 سال پیش

+ 4 - 0
jz-crm-db/src/main/java/org/linlinjava/jz/db/dao/HmEmployTaskMapper.java

@@ -139,4 +139,8 @@ public interface HmEmployTaskMapper {
     int batchInsert(@Param("hmEmployTask") HmEmployTask hmEmployTask, @Param("itemIds") String[] itemIds);
 
     int batchInsertWeekTask(@Param("orderNo") String orderNo, @Param("employClockId") Long employClockId, @Param("employRelationId") Long employRelationId, @Param("mapList") List<Map<String, Object>> mapList);
+
+    long queryWeekCount(@Param("employRelationId") Long employRelationId, @Param("stateList") List<Integer> stateList);
+
+    long queryMonthCount(@Param("employRelationId") Long employRelationId, @Param("stateList") List<Integer> stateList);
 }

+ 44 - 5
jz-crm-db/src/main/java/org/linlinjava/jz/db/service/hm/HmEmployTaskService.java

@@ -7,10 +7,12 @@ import org.linlinjava.jz.db.dao.HmTaskQuestionLogMapper;
 import org.linlinjava.jz.db.domain.HmEmployTask;
 import org.linlinjava.jz.db.domain.HmEmployTaskExample;
 import org.linlinjava.jz.db.domain.HmTaskQuestionLog;
+import org.linlinjava.jz.db.util.hm.CalendarUtil;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.List;
 import java.util.Map;
@@ -57,6 +59,30 @@ public class HmEmployTaskService {
     }
 
     /**
+     * 查询打卡关联日任务总数
+     *
+     * @param employClockId
+     * @return
+     */
+    public long queryDayCount(Long employClockId) {
+        HmEmployTaskExample example = new HmEmployTaskExample();
+        example.or().andEmployClockIdEqualTo(employClockId).andTaskTypeEqualTo(1);
+        return hmEmployTaskMapper.countByExample(example);
+    }
+
+    /**
+     * 查询打卡关联日任务完成数
+     *
+     * @param employClockId
+     * @return
+     */
+    public long queryDayCompleteCount(Long employClockId) {
+        HmEmployTaskExample example = new HmEmployTaskExample();
+        example.or().andEmployClockIdEqualTo(employClockId).andStateIn(Lists.newArrayList(1, 2)).andTaskTypeEqualTo(1);
+        return hmEmployTaskMapper.countByExample(example);
+    }
+
+    /**
      * 查询打卡关联任务总完成数
      *
      * @param employClockId
@@ -68,6 +94,7 @@ public class HmEmployTaskService {
         return hmEmployTaskMapper.countByExample(example);
     }
 
+
     /**
      * 查询打卡关联任务无法完成数
      *
@@ -165,20 +192,32 @@ public class HmEmployTaskService {
      *
      * @param employClockId
      * @param isNeedClock
+     * @param date
      * @return
      */
-    public boolean isAllCompleted(Long employClockId, Integer isNeedClock) {
+    public boolean isAllCompleted(Long employRelationId, Long employClockId, Integer isNeedClock, LocalDate date) {
         boolean isCompleted = false;
         long count = queryCount(employClockId);
-
-        long completeCount = queryCompleteCount(employClockId);
+        long dayCount = queryDayCount(employClockId);
+        long completeCount = queryDayCompleteCount(employClockId);
+        //月最后一天
+        String lastDayOfMonth = CalendarUtil.getLastDayOfMonth(date.getYear(), date.getMonth().getValue());
 
         if (count >= 0 && isNeedClock == 1) {
-            if (completeCount == count) {
+            //周天
+            if (7 == date.getDayOfWeek().getValue()) {
+                dayCount += hmEmployTaskMapper.queryWeekCount(employRelationId, null);
+                completeCount += hmEmployTaskMapper.queryWeekCount(employRelationId, Lists.newArrayList(1, 2));
+            }
+            //月底
+            if (lastDayOfMonth.equals(CalendarUtil.localDateFormat(date, "yyyy-MM-dd"))) {
+                dayCount += hmEmployTaskMapper.queryMonthCount(employRelationId, null);
+                completeCount += hmEmployTaskMapper.queryMonthCount(employRelationId, Lists.newArrayList(1, 2));
+            }
+            if (completeCount == dayCount) {
                 isCompleted = true;
             }
         }
-
         return isCompleted;
     }
 

+ 199 - 199
jz-crm-db/src/main/java/org/linlinjava/jz/db/util/hm/CalendarUtil.java

@@ -2,209 +2,209 @@ package org.linlinjava.jz.db.util.hm;
 
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.Locale;
+import java.util.*;
 
 public class CalendarUtil {
-	public static String DATE_FORMAT = "yyyy-MM-dd";
-	public static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-	public static SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM");
-	public static DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
-
-	/**
-	 * 获取上一月
-	 *
-	 * @return
-	 */
-	public static String getLastMonth(Date date) {
-		Calendar cal = Calendar.getInstance(Locale.CHINA);
-		if (null != date) {
-			cal.setTime(date);
-		}
-		cal.add(cal.MONTH, -1);
-		String lastMonth = dft.format(cal.getTime());
-		return lastMonth;
-	}
-
-	/**
-	 * 下一月
-	 *
-	 * @return
-	 */
-	public static String getPreMonth(Date date) {
-		Calendar cal = Calendar.getInstance(Locale.CHINA);
-		if (null != date) {
-			cal.setTime(date);
-		}
-		cal.add(cal.MONTH, 1);
-		String preMonth = dft.format(cal.getTime());
-		return preMonth;
-	}
-
-	/**
-	 * 当月
-	 *
-	 * @return
-	 */
-	public static String getCurrMonth(Date date) {
-		Calendar cal = Calendar.getInstance(Locale.CHINA);
-		if (null != date) {
-			cal.setTime(date);
-		}
-		String preMonth = dft.format(cal.getTime());
-		return preMonth;
-	}
-
-	/**
-	 * 当天
-	 *
-	 * @return
-	 */
-	public static String getCurrDay() {
-		Calendar cal = Calendar.getInstance(Locale.CHINA);
-		String preMonth = sdf.format(cal.getTime());
-		return preMonth;
-	}
-
-	/**
-	 * 获取某年某月的所有天 strDate 2020-02
-	 *
-	 * @return
-	 */
-	public static List<String> getDayListOfMonth(String strDate) {
-		List<String> list = new ArrayList<String>();
-		Calendar calendar = new GregorianCalendar();
-		try {
-			Date date1 = dft.parse(strDate);
-			calendar.setTime(date1); // 放入你的日期
-		} catch (ParseException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-
-		int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
-
-		for (int i = 1; i <= maxDay; i++) {
-			String r = i + "";
-			if (i < 10) {
-				r = "0" + r;
-			}
-			String aDate = strDate + "-" + r;
-			list.add(aDate);
-		}
-
-		return list;
-	}
-
-	/**
-	 * 判断日期属于周几
-	 *
-	 * @param data
-	 * @return
-	 */
-	public static int ofWeek(String data) {
-		Calendar c = Calendar.getInstance();
-		try {
-			Date date = sdf.parse(data);
-			c.setTime(date);
-		} catch (ParseException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-
-		int dayForWeek = 0;
-		if (c.get(Calendar.DAY_OF_WEEK) == 1) {
-			dayForWeek = 7;
-		} else {
-			dayForWeek = c.get(Calendar.DAY_OF_WEEK) - 1;
-		}
+    public static String DATE_FORMAT = "yyyy-MM-dd";
+    public static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+    public static SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM");
+    public static DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+    /**
+     * 获取上一月
+     *
+     * @return
+     */
+    public static String getLastMonth(Date date) {
+        Calendar cal = Calendar.getInstance(Locale.CHINA);
+        if (null != date) {
+            cal.setTime(date);
+        }
+        cal.add(cal.MONTH, -1);
+        String lastMonth = dft.format(cal.getTime());
+        return lastMonth;
+    }
+
+    /**
+     * 下一月
+     *
+     * @return
+     */
+    public static String getPreMonth(Date date) {
+        Calendar cal = Calendar.getInstance(Locale.CHINA);
+        if (null != date) {
+            cal.setTime(date);
+        }
+        cal.add(cal.MONTH, 1);
+        String preMonth = dft.format(cal.getTime());
+        return preMonth;
+    }
+
+    /**
+     * 当月
+     *
+     * @return
+     */
+    public static String getCurrMonth(Date date) {
+        Calendar cal = Calendar.getInstance(Locale.CHINA);
+        if (null != date) {
+            cal.setTime(date);
+        }
+        String preMonth = dft.format(cal.getTime());
+        return preMonth;
+    }
+
+    /**
+     * 当天
+     *
+     * @return
+     */
+    public static String getCurrDay() {
+        Calendar cal = Calendar.getInstance(Locale.CHINA);
+        String preMonth = sdf.format(cal.getTime());
+        return preMonth;
+    }
+
+    /**
+     * 获取某年某月的所有天 strDate 2020-02
+     *
+     * @return
+     */
+    public static List<String> getDayListOfMonth(String strDate) {
+        List<String> list = new ArrayList<String>();
+        Calendar calendar = new GregorianCalendar();
+        try {
+            Date date1 = dft.parse(strDate);
+            calendar.setTime(date1); // 放入你的日期
+        } catch (ParseException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+
+        int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
+
+        for (int i = 1; i <= maxDay; i++) {
+            String r = i + "";
+            if (i < 10) {
+                r = "0" + r;
+            }
+            String aDate = strDate + "-" + r;
+            list.add(aDate);
+        }
+
+        return list;
+    }
+
+    /**
+     * 判断日期属于周几
+     *
+     * @param data
+     * @return
+     */
+    public static int ofWeek(String data) {
+        Calendar c = Calendar.getInstance();
+        try {
+            Date date = sdf.parse(data);
+            c.setTime(date);
+        } catch (ParseException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+
+        int dayForWeek = 0;
+        if (c.get(Calendar.DAY_OF_WEEK) == 1) {
+            dayForWeek = 7;
+        } else {
+            dayForWeek = c.get(Calendar.DAY_OF_WEEK) - 1;
+        }
 //		System.out.println(dayForWeek);
-		return dayForWeek;
-	}
-
-	/**
-	 * 获取指定年月的第一天
-	 *
-	 * @param year
-	 * @param month
-	 * @return
-	 */
-	public static String getFirstDayOfMonth(int year, int month) {
-		Calendar cal = Calendar.getInstance();
-		// 设置年份
-		cal.set(Calendar.YEAR, year);
-		// 设置月份
-		cal.set(Calendar.MONTH, month - 1);
-		// 获取某月最小天数
-		int firstDay = cal.getMinimum(Calendar.DATE);
-		// 设置日历中月份的最小天数
-		cal.set(Calendar.DAY_OF_MONTH, firstDay);
-		// 格式化日期
-		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-		return sdf.format(cal.getTime());
-	}
-
-	/**
-	 * 获取指定年月的第一天
-	 * 
-	 * @param str 2020-10
-	 * @return
-	 */
-	public static String getFirstDayOfMonth(String str) {
-		String[] split = str.split("-");
-		if(split.length!=2) {
-			return "";
-		}
-		String firstDayOfMonth = getFirstDayOfMonth(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
-		return firstDayOfMonth;
-	}
-
-	/**
-	 * 获取指定年月的最后一天
-	 *
-	 * @param year
-	 * @param month
-	 * @return
-	 */
-	public static String getLastDayOfMonth(int year, int month) {
-		Calendar cal = Calendar.getInstance();
-		// 设置年份
-		cal.set(Calendar.YEAR, year);
-		// 设置月份
-		cal.set(Calendar.MONTH, month - 1);
-		// 获取某月最大天数
-		int lastDay = cal.getActualMaximum(Calendar.DATE);
-		// 设置日历中月份的最大天数
-		cal.set(Calendar.DAY_OF_MONTH, lastDay);
-		// 格式化日期
-		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-		return sdf.format(cal.getTime());
-	}
-
-	/**
-	 * 获取指定年月的最后一天
-	 * 
-	 * @param str 2020-10
-	 * @return
-	 */
-	public static String getLastDayOfMonth(String str) {
-		String[] split = str.split("-");
-		if(split.length!=2) {
-			return "";
-		}
-		String lastDayOfMonth = getLastDayOfMonth(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
-		return lastDayOfMonth;
-	}
-
-	public static void main(String[] args) throws ParseException {
+        return dayForWeek;
+    }
+
+    /**
+     * 获取指定年月的第一天
+     *
+     * @param year
+     * @param month
+     * @return
+     */
+    public static String getFirstDayOfMonth(int year, int month) {
+        Calendar cal = Calendar.getInstance();
+        // 设置年份
+        cal.set(Calendar.YEAR, year);
+        // 设置月份
+        cal.set(Calendar.MONTH, month - 1);
+        // 获取某月最小天数
+        int firstDay = cal.getMinimum(Calendar.DATE);
+        // 设置日历中月份的最小天数
+        cal.set(Calendar.DAY_OF_MONTH, firstDay);
+        // 格式化日期
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        return sdf.format(cal.getTime());
+    }
+
+    /**
+     * 获取指定年月的第一天
+     *
+     * @param str 2020-10
+     * @return
+     */
+    public static String getFirstDayOfMonth(String str) {
+        String[] split = str.split("-");
+        if (split.length != 2) {
+            return "";
+        }
+        String firstDayOfMonth = getFirstDayOfMonth(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
+        return firstDayOfMonth;
+    }
+
+    /**
+     * 获取指定年月的最后一天
+     *
+     * @param year
+     * @param month
+     * @return
+     */
+    public static String getLastDayOfMonth(int year, int month) {
+        Calendar cal = Calendar.getInstance();
+        // 设置年份
+        cal.set(Calendar.YEAR, year);
+        // 设置月份
+        cal.set(Calendar.MONTH, month - 1);
+        // 获取某月最大天数
+        int lastDay = cal.getActualMaximum(Calendar.DATE);
+        // 设置日历中月份的最大天数
+        cal.set(Calendar.DAY_OF_MONTH, lastDay);
+        // 格式化日期
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        return sdf.format(cal.getTime());
+    }
+
+    /**
+     * 获取指定年月的最后一天
+     *
+     * @param str 2020-10
+     * @return
+     */
+    public static String getLastDayOfMonth(String str) {
+        String[] split = str.split("-");
+        if (split.length != 2) {
+            return "";
+        }
+        String lastDayOfMonth = getLastDayOfMonth(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
+        return lastDayOfMonth;
+    }
+
+    public static String localDateFormat(LocalDate date, String format) {
+        DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern(format);
+        return dateFormat.format(date);
+    }
+
+    public static void main(String[] args) throws ParseException {
 //        List<String> dayListOfMonth = getDayListOfMonth("2020-02");
 //        System.out.println(dayListOfMonth);
-		System.out.println(getFirstDayOfMonth(2021, 3));
-
-	}
+        //System.out.println(localDateFormat(LocalDate.now(), "yyyy-MM-dd"));
+    }
 }

+ 26 - 0
jz-crm-db/src/main/resources/org/linlinjava/jz/db/dao/HmEmployTaskMapper.xml

@@ -618,4 +618,30 @@
                   and t.state in (1, 2)
                   AND MONTH (t.`task_start_time`) = MONTH (#{date})
     </select>
+    <select id="queryWeekCount" resultType="java.lang.Long">
+        SELECT count(*)
+        FROM `hm_employ_task` t
+        WHERE t.employ_relation_id = #{employRelationId}
+        and t.`task_type` = #{taskType}
+        AND WEEK(t.`task_start_time`) = WEEK(now())
+        <if test="stateList != null">
+            and t.state IN
+            <foreach collection="stateList" item="item" separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+    </select>
+    <select id="queryMonthCount" resultType="java.lang.Long">
+        SELECT count(*)
+        FROM `hm_employ_task` t
+        WHERE t.employ_relation_id = #{employRelationId}
+        and t.`task_type` = #{taskType}
+        AND MONTH(t.`task_start_time`) = MONTH(now())
+        <if test="stateList != null">
+            and t.state IN
+            <foreach collection="stateList" item="item" separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+    </select>
 </mapper>

+ 1 - 1
jz-crm-hm-api/src/main/java/org/linlinjava/jz/hm/util/DateUtil.java

@@ -644,7 +644,7 @@ public class DateUtil {
     public static void main(String[] args) throws ParseException {
 //        Date nextMonthLastDay = nextMonthFirstDate();
 //        System.out.println(nextMonthLastDay);
-        System.out.println(DateFormatToyyyyMMdd(LocalDateTime.now()));
+        System.out.println(LocalDate.now().getDayOfWeek().getValue());
     }
 
     // public static void main(String[] args) {

+ 1 - 1
jz-crm-hm-api/src/main/java/org/linlinjava/jz/hm/web/servant/HmServantInfoController.java

@@ -116,7 +116,7 @@ public class HmServantInfoController {
 
         HmEmployRelation relation = hmEmployRelationService.queryById(hmEmployClock.getEmployRelationId());
 
-        boolean allCompleted = hmEmployTaskService.isAllCompleted(employClockId, relation.getIsNeedClock());
+        boolean allCompleted = hmEmployTaskService.isAllCompleted(hmEmployClock.getEmployRelationId(), employClockId, relation.getIsNeedClock(), hmEmployClock.getWorkData().toLocalDate());
 
         if (!allCompleted) {
             return HmResponseUtil.fail("请确认任务是否全部完成,全部完成后再重试");

+ 2 - 2
jz-crm-hm-api/src/main/java/org/linlinjava/jz/hm/web/servant/HmServantTaskController.java

@@ -74,7 +74,7 @@ public class HmServantTaskController {
             isRestDay = hmEmployClock.getIsRestday() == 1;
             inCompleteCount = hmEmployTaskService.queryInCompleteCount(hmEmployClock.getId());
 
-            isCompleted = hmEmployTaskService.isAllCompleted(hmEmployClock.getId(), relation.getIsNeedClock());
+            isCompleted = hmEmployTaskService.isAllCompleted(hmEmployClock.getEmployRelationId(), hmEmployClock.getId(), relation.getIsNeedClock(), DateUtil.strToLocalDate(date));
 
         } else {
             //判断是否是休息日
@@ -89,7 +89,7 @@ public class HmServantTaskController {
         //当前输入日期与合同开始日期比较
         boolean before = contractSubTemplateService.isBefore(relation.getOrderNo(), DateUtil.strToLocalDate(date));
 
-        if (!before && relation.getIsNeedClock() == 1) {
+        if (!before && relation.getIsNeedClock() == 1 && !isRestDay) {
             //每日任务
             dayTaskList = hmEmployTaskService.getEmployTaskList(employRelationId, date);
             //每周任务