|
@@ -8,27 +8,24 @@ import com.management.platform.controller.WeiXinCorpController;
|
|
import com.management.platform.entity.*;
|
|
import com.management.platform.entity.*;
|
|
import com.management.platform.mapper.*;
|
|
import com.management.platform.mapper.*;
|
|
import com.management.platform.service.WxCorpInfoService;
|
|
import com.management.platform.service.WxCorpInfoService;
|
|
|
|
+import com.management.platform.task.SFTPAsyncUploader;
|
|
import com.management.platform.util.*;
|
|
import com.management.platform.util.*;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.core.io.FileSystemResource;
|
|
import org.springframework.core.io.FileSystemResource;
|
|
-import org.springframework.format.annotation.DateTimeFormat;
|
|
|
|
import org.springframework.http.*;
|
|
import org.springframework.http.*;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
import org.springframework.util.MultiValueMap;
|
|
import org.springframework.util.MultiValueMap;
|
|
-import org.springframework.util.unit.DataUnit;
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
import org.springframework.web.client.RestTemplate;
|
|
import org.springframework.web.util.UriComponentsBuilder;
|
|
import org.springframework.web.util.UriComponentsBuilder;
|
|
-import sun.net.www.http.HttpClient;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import java.io.*;
|
|
import java.io.*;
|
|
-import java.lang.reflect.Array;
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.net.URI;
|
|
import java.net.URI;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
@@ -36,7 +33,6 @@ import java.time.*;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.temporal.ChronoUnit;
|
|
import java.time.temporal.ChronoUnit;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
-import java.util.concurrent.Executors;
|
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -103,6 +99,8 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
@Value(value = "${upload.path}")
|
|
@Value(value = "${upload.path}")
|
|
private String path;
|
|
private String path;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private SFTPAsyncUploader sftpAsyncUploader;
|
|
|
|
|
|
@Value(value = "${configEnv.isDev}")
|
|
@Value(value = "${configEnv.isDev}")
|
|
private boolean isDev;
|
|
private boolean isDev;
|
|
@@ -423,7 +421,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public String downloadFile(WxCorpInfo corpInfo, String mediaId) {
|
|
|
|
|
|
+ public File downloadFile(WxCorpInfo corpInfo, String mediaId) {
|
|
try {
|
|
try {
|
|
String corpAccessToken = getCorpAccessToken(corpInfo);
|
|
String corpAccessToken = getCorpAccessToken(corpInfo);
|
|
String url = URL_GET_MEDIA.replaceAll("ACCESS_TOKEN", corpAccessToken).replaceAll("MEDIA_ID", mediaId);
|
|
String url = URL_GET_MEDIA.replaceAll("ACCESS_TOKEN", corpAccessToken).replaceAll("MEDIA_ID", mediaId);
|
|
@@ -432,9 +430,12 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
byte[] body = entity.getBody();
|
|
byte[] body = entity.getBody();
|
|
//写入文件
|
|
//写入文件
|
|
String fileName = mediaId + ".jpg";
|
|
String fileName = mediaId + ".jpg";
|
|
- FileOutputStream fileOutputStream = new FileOutputStream(new File(path + fileName));
|
|
|
|
|
|
+ File file = new File(path + fileName);
|
|
|
|
+ FileOutputStream fileOutputStream = new FileOutputStream(file);
|
|
fileOutputStream.write(body);
|
|
fileOutputStream.write(body);
|
|
fileOutputStream.close();
|
|
fileOutputStream.close();
|
|
|
|
+ sftpAsyncUploader.uploadFileAsync(file);
|
|
|
|
+ return file;
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
@@ -1184,13 +1185,14 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
int sTime = summary_info.getIntValue("earliest_time");//秒
|
|
int sTime = summary_info.getIntValue("earliest_time");//秒
|
|
int eTime = summary_info.getIntValue("lastest_time");//秒
|
|
int eTime = summary_info.getIntValue("lastest_time");//秒
|
|
int regular_work_sec = summary_info.getIntValue("regular_work_sec");//秒
|
|
int regular_work_sec = summary_info.getIntValue("regular_work_sec");//秒
|
|
- Integer standard_work_sec = summary_info.getInteger("standard_work_sec");
|
|
|
|
-
|
|
|
|
ct.setStartTime(DateTimeUtil.getTimeFromSeconds(sTime));
|
|
ct.setStartTime(DateTimeUtil.getTimeFromSeconds(sTime));
|
|
ct.setEndTime(DateTimeUtil.getTimeFromSeconds(eTime));
|
|
ct.setEndTime(DateTimeUtil.getTimeFromSeconds(eTime));
|
|
|
|
+ //下班时间和上班时间不一样,正常应该有regular_work_sec,但是企业微信存在问题,传过来的是0,需要校正
|
|
|
|
+ if (regular_work_sec == 0 && ct.getEndTime() != null && !ct.getEndTime().equals(ct.getStartTime())) {
|
|
|
|
+ ct.setEndTime(ct.getStartTime());
|
|
|
|
+ }
|
|
//有一次有效打卡
|
|
//有一次有效打卡
|
|
boolean hitOnce = (ct.getStartTime().equals(ct.getEndTime()) && !"00:00".equals(ct.getStartTime()));
|
|
boolean hitOnce = (ct.getStartTime().equals(ct.getEndTime()) && !"00:00".equals(ct.getStartTime()));
|
|
- String originHitTime = ct.getStartTime();
|
|
|
|
//直接设置打卡时长,以企业微信的为准,不考虑漏打卡的情况
|
|
//直接设置打卡时长,以企业微信的为准,不考虑漏打卡的情况
|
|
ct.setCardTime(DateTimeUtil.getHoursFromSeconds(regular_work_sec));
|
|
ct.setCardTime(DateTimeUtil.getHoursFromSeconds(regular_work_sec));
|
|
ct.setAskLeaveTime(0.0);
|
|
ct.setAskLeaveTime(0.0);
|
|
@@ -1250,7 +1252,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
if ("00:00".equals(leaveStart)) {
|
|
if ("00:00".equals(leaveStart)) {
|
|
leaveStart = baseMorningStart;
|
|
leaveStart = baseMorningStart;
|
|
}
|
|
}
|
|
- System.out.println("leaveStart==" + leaveStart + ", leaveEnd=" + leaveEnd);
|
|
|
|
|
|
+ if (showLog) System.out.println("leaveStart==" + leaveStart + ", leaveEnd=" + leaveEnd);
|
|
} else {
|
|
} else {
|
|
if (showLog) System.out.println("跨天请假@@@@");
|
|
if (showLog) System.out.println("跨天请假@@@@");
|
|
if (showLog)
|
|
if (showLog)
|
|
@@ -1394,6 +1396,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
System.out.println("" + ct.getStartTime() + "--" + ct.getEndTime());
|
|
System.out.println("" + ct.getStartTime() + "--" + ct.getEndTime());
|
|
timeDelta = DateTimeUtil.getHoursFromSeconds(DateTimeUtil.getSecondsFromTime(ct.getEndTime()) - DateTimeUtil.getSecondsFromTime(ct.getStartTime()));
|
|
timeDelta = DateTimeUtil.getHoursFromSeconds(DateTimeUtil.getSecondsFromTime(ct.getEndTime()) - DateTimeUtil.getSecondsFromTime(ct.getStartTime()));
|
|
//超过下午上班的开始时间,需要减去午休的时间
|
|
//超过下午上班的开始时间,需要减去午休的时间
|
|
|
|
+ System.out.println("下午上班时间=="+baseAfternoonStart);
|
|
if (ct.getEndTime().compareTo(baseAfternoonStart) >= 0) {
|
|
if (ct.getEndTime().compareTo(baseAfternoonStart) >= 0) {
|
|
//重新计算打卡工时时,需要减去中间午休时间
|
|
//重新计算打卡工时时,需要减去中间午休时间
|
|
timeDelta -= restTime;
|
|
timeDelta -= restTime;
|
|
@@ -1401,7 +1404,6 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
} else {
|
|
} else {
|
|
timeDelta = ct.getCardTime();
|
|
timeDelta = ct.getCardTime();
|
|
}
|
|
}
|
|
-
|
|
|
|
if (showLog) System.out.println("上下班间隔时长为==" + timeDelta);
|
|
if (showLog) System.out.println("上下班间隔时长为==" + timeDelta);
|
|
ct.setName(name);
|
|
ct.setName(name);
|
|
//解析请假和外出的情况
|
|
//解析请假和外出的情况
|
|
@@ -1490,7 +1492,12 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
if (timeDelta < 7.5 && ct.getOutdoorTime() > 0) {
|
|
if (timeDelta < 7.5 && ct.getOutdoorTime() > 0) {
|
|
timeDelta += ct.getOutdoorTime();
|
|
timeDelta += ct.getOutdoorTime();
|
|
}
|
|
}
|
|
- double workHours = timeDelta - ct.getAskLeaveTime();
|
|
|
|
|
|
+ double workHours = 0;
|
|
|
|
+ if (needRecaculate) {
|
|
|
|
+ workHours = timeDelta - ct.getAskLeaveTime();
|
|
|
|
+ } else {
|
|
|
|
+ workHours = timeDelta;
|
|
|
|
+ }
|
|
if (workHours < 0) {
|
|
if (workHours < 0) {
|
|
workHours = 0;
|
|
workHours = 0;
|
|
}
|
|
}
|