|
@@ -3,15 +3,16 @@ package com.jpsoft.shinestar.modules.base.service.impl;
|
|
|
import com.github.pagehelper.Page;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.jpsoft.shinestar.modules.base.entity.PersonDeviceLog;
|
|
|
-import com.jpsoft.shinestar.modules.base.service.PersonDeviceLogService;
|
|
|
-import com.jpsoft.shinestar.modules.base.service.WorkOverPersonService;
|
|
|
+import com.jpsoft.shinestar.modules.base.entity.WorkPersonScheduling;
|
|
|
+import com.jpsoft.shinestar.modules.base.entity.WorkShiftInfo;
|
|
|
+import com.jpsoft.shinestar.modules.base.service.*;
|
|
|
import com.jpsoft.shinestar.modules.base.dao.WorkOverPersonDAO;
|
|
|
import com.jpsoft.shinestar.modules.base.entity.WorkOverPerson;
|
|
|
-import com.jpsoft.shinestar.modules.base.service.WorkOverService;
|
|
|
import com.jpsoft.shinestar.modules.common.dto.Sort;
|
|
|
import com.jpsoft.shinestar.modules.sys.entity.DataDictionary;
|
|
|
import com.jpsoft.shinestar.modules.sys.service.DataDictionaryService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.joda.time.DateTime;
|
|
|
import org.joda.time.Minutes;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -20,9 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @author 墨鱼_mo
|
|
@@ -45,6 +44,12 @@ public class WorkOverPersonServiceImpl implements WorkOverPersonService {
|
|
|
@Autowired
|
|
|
private WorkOverService workOverService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private WorkPersonSchedulingService workPersonSchedulingService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WorkShiftInfoService workShiftInfoService;
|
|
|
+
|
|
|
@Override
|
|
|
public WorkOverPerson get(String id) {
|
|
|
// TODO Auto-generated method stub
|
|
@@ -170,10 +175,57 @@ public class WorkOverPersonServiceImpl implements WorkOverPersonService {
|
|
|
}
|
|
|
|
|
|
if(!exist){
|
|
|
+ boolean allowUpdate = false;
|
|
|
+
|
|
|
//查询该员工半小时内是否还有加班,如果有则直接取计划结束时间作为实际完成时间
|
|
|
WorkOverPerson nextWorkOverPerson = findOneByPersonIdAndDate(personId, endTime.plusMinutes(30).toDate());
|
|
|
|
|
|
if (nextWorkOverPerson != null) {
|
|
|
+ allowUpdate = true;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //加班结束时间是否与上班时间重复
|
|
|
+ SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ WorkPersonScheduling workPersonScheduling = workPersonSchedulingService.findByPersonIdSchedulingDay(personId, sdf1.parse(day));
|
|
|
+
|
|
|
+ if(workPersonScheduling!=null) {
|
|
|
+ String shiftIds = workPersonScheduling.getShiftIds();
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(shiftIds)) {
|
|
|
+ String[] shiftIdArr = shiftIds.split(",");
|
|
|
+
|
|
|
+ List<WorkShiftInfo> shiftList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (String shiftId : shiftIdArr) {
|
|
|
+ WorkShiftInfo workShiftInfo = workShiftInfoService.get(shiftId);
|
|
|
+
|
|
|
+ if (workShiftInfo != null) {
|
|
|
+ if (!workShiftInfo.getNumber().equals("0")) {
|
|
|
+ shiftList.add(workShiftInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (shiftList.size() > 0) {
|
|
|
+ //按照上班考勤开始时间排序
|
|
|
+ shiftList.sort(Comparator.comparing(e -> e.getWorkStartTime()));
|
|
|
+
|
|
|
+ SimpleDateFormat fullFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
+
|
|
|
+ //上班考勤开始时间
|
|
|
+ DateTime workTime = new DateTime(fullFormat.parse(day + " " + shiftList.get(0).getWorkTime()));
|
|
|
+
|
|
|
+ int minutes = Minutes.minutesBetween(new DateTime(endTime),new DateTime(workTime)).getMinutes();
|
|
|
+
|
|
|
+ if(Math.abs(minutes)<=30){
|
|
|
+ allowUpdate = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(allowUpdate) {
|
|
|
WorkOverPerson workOverPerson = get(id);
|
|
|
|
|
|
if (workOverPerson.getBeginTime() == null) {
|