|
|
@@ -2,8 +2,11 @@ package com.ruoyi.system.service.impl;
|
|
|
|
|
|
import java.sql.SQLException;
|
|
|
import java.sql.SQLIntegrityConstraintViolationException;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
+import java.time.Duration;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
import javax.validation.Validator;
|
|
|
|
|
|
@@ -14,6 +17,7 @@ import com.ruoyi.project.domain.ProjectTask;
|
|
|
import com.ruoyi.project.mapper.ProjectStaffMapper;
|
|
|
import com.ruoyi.project.mapper.ProjectStaffRecordMapper;
|
|
|
import com.ruoyi.project.mapper.ProjectTaskMapper;
|
|
|
+import com.ruoyi.system.domain.UserClockDtails;
|
|
|
import com.ruoyi.system.mapper.*;
|
|
|
import com.ruoyi.system.service.ISysDeptService;
|
|
|
import com.ruoyi.weChat.service.WeChatService;
|
|
|
@@ -692,6 +696,8 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
private Long getCompany(Long deptId) {
|
|
|
log.debug("depID="+deptId);
|
|
|
SysDept sysDept = deptService.selectDeptById(deptId);
|
|
|
@@ -701,5 +707,123 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
if (split.length>2)return Long.valueOf(split[2]);
|
|
|
else return deptId;
|
|
|
}
|
|
|
+ @Override
|
|
|
+ public List<UserClockDtails> pushUserClock(List<Map<Integer, String>> maps) {
|
|
|
+ List<UserClockDtails> list=new ArrayList<>();
|
|
|
+ List<String> names=new ArrayList<>();
|
|
|
+ int month =0;
|
|
|
+ int year =0;
|
|
|
+ int days=0;
|
|
|
+ Map<Integer,String> hand=new HashMap<>();
|
|
|
+ if (!maps.isEmpty()){
|
|
|
+ for (int i = 0; i < maps.size(); i++) {
|
|
|
+ //获取头部
|
|
|
+ if (i==0){
|
|
|
+ Map<Integer, String> map = maps.get(i);
|
|
|
+ String head = map.get(0);
|
|
|
+ int i1 = head.indexOf(":")+1;
|
|
|
+ int i2 = head.indexOf("至");
|
|
|
+ String startClockTime = head.substring(i1, i2).trim();
|
|
|
+ String endClockTime = head.substring(i2+1).trim();
|
|
|
+ System.out.println(startClockTime+"~"+endClockTime);
|
|
|
+ LocalDate date = LocalDate.parse(startClockTime, DateTimeFormatter.ISO_DATE);
|
|
|
+ month=date.getMonthValue();
|
|
|
+ year = date.getYear();
|
|
|
+ }else if (i==2){
|
|
|
+ hand=maps.get(2);
|
|
|
+ }else {
|
|
|
+ Map<Integer, String> map = maps.get(i);
|
|
|
+ UserClockDtails userClockDtails=new UserClockDtails();
|
|
|
+ //每一条是一个人的当月打卡
|
|
|
+ for (int j = 0; j < map.size(); j++) {
|
|
|
+ String s = map.get(j);
|
|
|
+ if (j==0)userClockDtails.setName(s);
|
|
|
+ else if (j==1)userClockDtails.setGroupName(s.replace("\n","-").replace(" ",""));
|
|
|
+ else if (j==2)userClockDtails.setDepName(s.replace("\n","-"));
|
|
|
+ else if (j==3)userClockDtails.setJobNumber(s);
|
|
|
+ else if (j==4)userClockDtails.setPosition(s);
|
|
|
+ else if (j==5)userClockDtails.setUserId(s);
|
|
|
+ //前5为基本信息,后面则是打卡信息
|
|
|
+ else {
|
|
|
+ UserClockDtails newUserlock=new UserClockDtails(userClockDtails);
|
|
|
+ if(StringUtils.isNotEmpty(s)){
|
|
|
+ String[] split = s.split("\n");
|
|
|
+ if (split.length==1)newUserlock.setStauts(1);
|
|
|
+ String regex = "\\d+";
|
|
|
+ if (hand.get(j).matches(regex)){
|
|
|
+ days=Integer.parseInt(hand.get(j));
|
|
|
+ }else {
|
|
|
+ days++;
|
|
|
+ }
|
|
|
+ newUserlock.setClockDate(s);
|
|
|
+ newUserlock.setClockTime(LocalDate.of(year,month,days));
|
|
|
+ int startHour = Integer.parseInt(split[0].split(":")[0].trim());
|
|
|
+ int startMinute = Integer.parseInt(split[0].split(":")[1].trim());
|
|
|
+ LocalDateTime startTime=LocalDateTime.of(year,month,days,startHour,startMinute);
|
|
|
+ newUserlock.setStartTime(startTime);
|
|
|
+ if (newUserlock.getStauts()==0){
|
|
|
+ int endHour = Integer.parseInt(split[split.length - 1].split(":")[0].trim());
|
|
|
+ int endMinute = Integer.parseInt(split[split.length - 1].split(":")[1].trim());
|
|
|
+ LocalDateTime endTime=LocalDateTime.of(year,month,days,endHour,endMinute);
|
|
|
+ newUserlock.setEndTime(endTime);
|
|
|
+ Double hours = getHuors(startTime, endTime);
|
|
|
+ newUserlock.setDuration(hours);
|
|
|
+ }else {
|
|
|
+ newUserlock.setDuration(0d);
|
|
|
+ }
|
|
|
+ if (!names.contains(newUserlock.getName())){
|
|
|
+ names.add(newUserlock.getName());
|
|
|
+ }
|
|
|
+ list.add(newUserlock);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ names.forEach(System.out::println);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private Double getHuors(LocalDateTime startTime, LocalDateTime endTime) {
|
|
|
+ //打卡时间处理
|
|
|
+ if (startTime.getHour()<=8&&startTime.getMinute()<30){
|
|
|
+ startTime=startTime.withHour(8);
|
|
|
+ startTime=startTime.withMinute(30);
|
|
|
+ }else if (startTime.getHour()>8&&startTime.getMinute()>30){
|
|
|
+ startTime=startTime.withMinute(startTime.getHour()+1);
|
|
|
+ startTime=startTime.withMinute(0);
|
|
|
+ }else if (startTime.getHour()>8&&startTime.getMinute()<30){
|
|
|
+ startTime=startTime.withMinute(30);
|
|
|
+ }
|
|
|
+ if (endTime.getHour()<18 &&endTime.getMinute()<30){
|
|
|
+ endTime=endTime.withMinute(0);
|
|
|
+ }else if (endTime.getHour()>=18&&endTime.getMinute()<30){
|
|
|
+ endTime=endTime.withMinute(0);
|
|
|
+ }else if (endTime.getHour()>=18&&endTime.getMinute()>30){
|
|
|
+ endTime=endTime.withMinute(30);
|
|
|
+ }
|
|
|
+ Duration duration = Duration.between(startTime, endTime);
|
|
|
+ long minutes = duration.toMinutes();
|
|
|
+ long l = minutes / 30;
|
|
|
+ double l1 = (double) (l / 2);
|
|
|
+ long l2 = l % 2;
|
|
|
+ if (l2==1){
|
|
|
+ l1+=0.5;
|
|
|
+ }
|
|
|
+ //在12点之前
|
|
|
+ if (startTime.getHour()<13&&endTime.getHour()>13&&endTime.getHour()<18){
|
|
|
+ l1=l1-1.5;
|
|
|
+ }else if (startTime.getHour()<13&&endTime.getHour()>17){
|
|
|
+ l1=l1-2;
|
|
|
+ }else if (startTime.getHour()>=13&&endTime.getHour()>17){
|
|
|
+ l1=l1-0.5;
|
|
|
+ }
|
|
|
+ return l1;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|