소스 검색

企业微信拍照的备份

seyason 2 년 전
부모
커밋
792fb3fecd

+ 2 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/WxCorpInfoService.java

@@ -8,6 +8,7 @@ import com.management.platform.entity.WxCorpInfo;
 import com.management.platform.util.HttpRespMsg;
 
 import javax.servlet.http.HttpServletRequest;
+import java.io.File;
 import java.time.LocalDateTime;
 import java.util.HashMap;
 import java.util.List;
@@ -29,7 +30,7 @@ public interface WxCorpInfoService extends IService<WxCorpInfo> {
 
     public void sendWXCorpTemplateMsg(WxCorpInfo corpInfo, String corpUserid, JSONObject msg);
 
-    public String downloadFile(WxCorpInfo corpInfo, String mediaId);
+    public File downloadFile(WxCorpInfo corpInfo, String mediaId);
 
     public String testDownloadFile();
 

+ 1 - 12
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -10,6 +10,7 @@ import com.management.platform.entity.*;
 import com.management.platform.entity.vo.*;
 import com.management.platform.mapper.*;
 import com.management.platform.service.*;
+import com.management.platform.task.SFTPAsyncUploader;
 import com.management.platform.util.*;
 import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage;
 import me.chanjar.weixin.mp.api.WxMpService;
@@ -120,8 +121,6 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
     @Resource
     ReportExtraDegreeMapper reportExtraDegreeMapper;
     @Resource
-    private ReportController reportController;
-    @Resource
     WxCorpInfoService wxCorpInfoService;
     @Resource
     ProjectCategoryMapper projectCategoryMapper;
@@ -154,8 +153,6 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
     @Resource
     private UserMapper userMapper;
     @Resource
-    private TimeCalculationMapper timeCalculationMapper;
-    @Resource
     private ProjectMapper projectMapper;
     @Resource
     private CompanyDingdingService companyDingdingService;
@@ -178,14 +175,10 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
     @Resource
     private ReportAuditorSettingMapper reportAuditorSettingMapper;
     @Resource
-    private UserRecentTaskMapper userRecentTaskMapper;
-    @Resource
     private PpMembsMapper ppMembsMapper;
     @Resource
     private StagesMapper stagesMapper;
     @Resource
-    private UserSalaryService userSalaryService;
-    @Resource
     LocaleInformationMapper localeInformationMapper;
     @Resource
     private AuditWorkflowTimeSettingMapper auditWorkflowTimeSettingMapper;
@@ -209,12 +202,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
     private DepartmentOtherManagerMapper departmentOtherManagerMapper;
     @Resource
     private ExcelExportService excelExportService;
-    @Resource
-    private CorpwxJobResultMapper corpwxJobResultMapper;
     @Autowired
     RestTemplate restTemplate;
-    @Resource
-    private TimeAutoExcludeMapper timeAutoExcludeMapper;
 
     @Resource
     private ReportAuditLogService reportAuditLogService;

+ 20 - 13
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/WxCorpInfoServiceImpl.java

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