Browse Source

微信请假同步与钉钉请假同步

cs 2 years ago
parent
commit
fe1e478752

+ 2 - 7
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/DingDingServiceImpl.java

@@ -1287,13 +1287,8 @@ public class DingDingServiceImpl implements DingDingService {
                             sheet.setGmtFinished(item.getString("gmt_finished"));
                             Long cha = sheet.getEndDate().toEpochDay() - sheet.getStartDate().toEpochDay() + 1;
                             sheet.setTimeDays((float)cha);
-                            Integer timeType = item.getInteger("timeType");
-                            if (timeType == 0){
-                                TimeType allDay = timeTypeMapper.selectOne(new QueryWrapper<TimeType>().eq("company_id", user.getCompanyId()));
-                                sheet.setTimeHours(sheet.getTimeDays()*allDay.getAllday());
-                            }else {
-                                sheet.setTimeHours(item.getFloat("timeHours"));
-                            }
+                            TimeType allDay = timeTypeMapper.selectOne(new QueryWrapper<TimeType>().eq("company_id", user.getCompanyId()));
+                            sheet.setTimeHours(sheet.getTimeDays()*allDay.getAllday());
                             sheet.setCompanyId(dingding.getCompanyId());
                             sheet.setStatus(0);
                             sheet.setProcinstId(item.getString("procInst_id"));

+ 3 - 5
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/WxCorpInfoServiceImpl.java

@@ -1136,8 +1136,6 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
     //更新审核中的请假单以及查询某时间段的微信请假单
     @Override
     public List<LeaveSheet> wxLeaveNumber(String startTime,String endTime,List<WxCorpInfo> wxCorpInfos,List<LeaveSheet> approvalLeave) throws Exception {
-        String url = "https://qyapi.weixin.qq.com/cgi-bin/oa/getapprovalinfo?access_token=ACCESS_TOKEN";
-        String detailUrl = "https://qyapi.weixin.qq.com/cgi-bin/oa/getapprovaldetail?access_token=ACCESS_TOKEN";
         HttpHeaders headers = new HttpHeaders();
         RestTemplate restTemplate = new RestTemplate();
         ArrayList<LeaveSheet> result = new ArrayList<>();
@@ -1148,13 +1146,13 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
             System.err.println("++++++++++++++++++++++++++++++正在同步更新:"+wxCorpInfo.getCorpName());
             //更新Access_token
             String accessToken = getCorpAccessToken(wxCorpInfo);
-            url = url.replace("ACCESS_TOKEN", accessToken);
+            String url = "https://qyapi.weixin.qq.com/cgi-bin/oa/getapprovalinfo?access_token=" + accessToken;
             //查询并更新审核中的审批单
             System.out.println("+++++++++++++++++++开始查询并更新审核中的审批单+++++++++++++++++++");
             if (approvalLeave.size()!=0){
                 for (LeaveSheet corpInfo : approvalLeave) {
                     if (corpInfo.getCompanyId().equals(wxCorpInfo.getCompanyId())&& StringUtils.isNotEmpty(corpInfo.getProcinstId())){
-                        detailUrl = detailUrl.replace("ACCESS_TOKEN", accessToken);
+                        String detailUrl = "https://qyapi.weixin.qq.com/cgi-bin/oa/getapprovaldetail?access_token=" + accessToken;
                         JSONObject detailMap = new JSONObject();
                         detailMap.put("sp_no",corpInfo.getProcinstId());
                         HttpEntity<JSONObject> detailEntity = new HttpEntity<>(detailMap, headers);
@@ -1241,7 +1239,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                     Object[] sp_no_lists = json.getJSONArray("sp_no_list").toArray();
                     //查询每个审批号审批详情
                     for (int i = 0; i < sp_no_lists.length; i++) {
-                        detailUrl = detailUrl.replace("ACCESS_TOKEN", accessToken);
+                        String detailUrl = "https://qyapi.weixin.qq.com/cgi-bin/oa/getapprovaldetail?access_token=" + accessToken;
                         JSONObject detailMap = new JSONObject();
                         detailMap.put("sp_no", sp_no_lists[i]);
                         HttpEntity<JSONObject> detailEntity = new HttpEntity<>(detailMap, headers);

+ 8 - 10
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/task/TimingTask.java

@@ -166,7 +166,7 @@ public class TimingTask {
     //每天2:11 同步钉钉用户前2天到未来30天时间段的打卡,请假,出差数据
     @Scheduled(cron = "0 11 2 ? * *")
     private void synDingDingWorkData() {
-        if (isDev) return;
+        //if (isDev) return;
         List<TimeType> timeTypeList = timeTypeMapper.selectList(new QueryWrapper<TimeType>().eq("sync_dingding", 1));
         List<Integer> compIds = timeTypeList.stream().map(TimeType::getCompanyId).collect(Collectors.toList());
         //企业内部应用才有权限调用
@@ -261,15 +261,15 @@ public class TimingTask {
                leaveSheet.setOwnerName(user.getName());
                leaveSheet.setStartDate(LocalDate.parse(String.valueOf(map.get("startDate")),dtf));
                leaveSheet.setEndDate(LocalDate.parse(String.valueOf(map.get("endDate")),dtf));
-                int timeType = Integer.parseInt(String.valueOf(map.get("timeType")));
-                leaveSheet.setTimeType(timeType);
+               int timeType = Integer.parseInt(String.valueOf(map.get("timeType")));
+               leaveSheet.setTimeType(timeType);
+               leaveSheet.setTimeDays((Float) map.get("timeDays"));
                if (timeType == 0){
                    TimeType allDay = timeTypeMapper.selectOne(new QueryWrapper<TimeType>().eq("company_id", user.getCompanyId()));
-                   leaveSheet.setTimeHours((Float) map.get("timeDays")*allDay.getAllday());
+                   leaveSheet.setTimeHours(leaveSheet.getTimeDays()*allDay.getAllday());
                }else {
                    leaveSheet.setTimeHours((Float) map.get("timeHours"));
                }
-               leaveSheet.setTimeDays((Float) map.get("timeDays"));
                leaveSheet.setLeaveType(Integer.parseInt(String.valueOf(map.get("leaveType"))));
                leaveSheet.setProcinstId(String.valueOf(map.get("procinstId")));
                leaveSheet.setGmtFinished(String.valueOf(map.get("gmtFinished")));
@@ -316,10 +316,9 @@ public class TimingTask {
     }
 
     //每天1:00 同步昨天的微信请假信息
-    //@Scheduled(cron = "0 0 1 ? * *")
-    @Scheduled(cron = "0 22 10 ? * *")
+    @Scheduled(cron = "0 0 1 ? * *")
     public void synWxLeave() throws Exception {
-        //if (isDev) return;
+        if (isDev) return;
         System.out.println("+++++++++++++++++++微信请假同步开始+++++++++++++++++++");
         String startTime = Long.toString(System.currentTimeMillis()/1000L-86400);
         String endTime = Long.toString(System.currentTimeMillis()/1000L);
@@ -333,8 +332,7 @@ public class TimingTask {
         List<LeaveSheet> approvalLeave = leaveSheetMapper.selectApprovalList();
         //插入请假单并更新审核中的请假单
         List<WxCorpInfo> wxCorpInfos = wxCorpInfoMapper.selectList(new QueryWrapper<WxCorpInfo>().in("company_id",companyId));
-        //List<LeaveSheet> leaveSheets = wxCorpInfoService.wxLeaveNumber(startTime,endTime, wxCorpInfos,approvalLeave);
-        List<LeaveSheet> leaveSheets = wxCorpInfoService.wxLeaveNumber("1663337398","1665223685", wxCorpInfos,approvalLeave);
+        List<LeaveSheet> leaveSheets = wxCorpInfoService.wxLeaveNumber(startTime,endTime, wxCorpInfos,approvalLeave);
         for (LeaveSheet leaveSheet : leaveSheets) {
             leaveSheetMapper.insert(leaveSheet);
         }

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/LeaveSheetMapper.xml

@@ -45,7 +45,7 @@
     <!-- 查询审核中的请假单信息 -->
     <select id="selectApprovalList" resultType="com.management.platform.entity.LeaveSheet">
        select * from leave_sheet
-       where procinst_id is not NULL AND procinst_id != '' and status = 1 and DATEDIFF(NOW(),indate) &lt; 30
+       where procinst_id is not NULL AND procinst_id is not null and status = 1 and DATEDIFF(NOW(),indate) &lt; 30
    </select>
 
     <!-- 查询某段时间内的请假列表 -->