Min 11 meses atrás
pai
commit
b2c4ccab6c

+ 1 - 1
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/controller/WxCorpInfoController.java

@@ -91,7 +91,7 @@ public class WxCorpInfoController {
         filter1.put("value",1);
         jsonArrayFilter.add(filter1);
         JSONObject filter2 = new JSONObject();
-        filter2.put("key","sp_status ");
+        filter2.put("key","sp_status");
         filter2.put("value",2);
         jsonArrayFilter.add(filter2);
         JSONArray approvalInfo = wxCorpInfoService.getApprovalInfo(7, startDate, endDate, "", jsonArrayFilter);

+ 24 - 14
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/impl/WxCorpInfoServiceImpl.java

@@ -1987,7 +1987,15 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
         return msg;
     }
 
-
+    public static long toUNix(LocalDateTime localDateTime) {
+        // 转换为ZonedDateTime
+        ZonedDateTime zonedDateTime = localDateTime.atZone(ZoneId.systemDefault());
+        // 转换为Instant
+        Instant instant = zonedDateTime.toInstant();
+        // 获取UNIX时间戳
+        long unixTimestamp = instant.getEpochSecond();
+        return unixTimestamp;
+    }
 
     /**
      * 批量获取审批单号
@@ -1999,12 +2007,10 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
         DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd");
         LocalDateTime startDateTime = LocalDate.parse(startDate, df).atTime(LocalTime.MIN);
         LocalDateTime endDateTime = LocalDate.parse(endDate, df).atTime(LocalTime.MAX);
-        long startTime = startDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli() -
-                LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
-        long endTime = endDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli() -
-                LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
+        long startTime = toUNix(startDateTime);
+        long endTime = toUNix(endDateTime);
         WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id",companyId));
-        String url=BATCH_GET_APPROVAL_INFO.replace("ACCESS_TOKEN",getCorpAccessToken(wxCorpInfo));
+        String url=BATCH_GET_APPROVAL_INFO.replace("ACCESS_TOKEN",getCorpAgentAccessToken(wxCorpInfo));
         HttpHeaders headers = new HttpHeaders();
         RestTemplate restTemplate = new RestTemplate();
         MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
@@ -2022,14 +2028,18 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
             JSONArray jsonArray=new JSONArray();
             String resp = ResponseEntity.getBody();
             JSONObject jsonObject = JSONObject.parseObject(resp);
-            JSONArray sp_no_list = jsonObject.getJSONArray("sp_no_list");
-            jsonArray.addAll(sp_no_list);
-            if(jsonObject.containsKey("new_next_cursor")){
-                String new_next_cursor = jsonObject.getString("new_next_cursor");
-                JSONArray approvalInfo = getApprovalInfo(companyId, startDate, endDate, new_next_cursor, filterArray);
-                jsonArray.addAll(approvalInfo);
+            if(jsonObject.getString("errmsg").equals("ok")){
+                JSONArray sp_no_list = jsonObject.getJSONArray("sp_no_list");
+                jsonArray.addAll(sp_no_list);
+                if(jsonObject.containsKey("new_next_cursor")){
+                    String new_next_cursor = jsonObject.getString("new_next_cursor");
+                    JSONArray approvalInfo = getApprovalInfo(companyId, startDate, endDate, new_next_cursor, filterArray);
+                    jsonArray.addAll(approvalInfo);
+                }
+                System.out.println(jsonArray);
+                return jsonArray;
             }
-            return jsonArray;
+            System.out.println(jsonObject.getString("errmsg"));
         }
         return null;
     }
@@ -2038,7 +2048,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
     @Override
     public String getApprovalInfoDetail(Integer companyId,String spNo) throws Exception {
         WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id",companyId));
-        String url=GET_APPROVAL_DETAIL.replace("ACCESS_TOKEN",getCorpAccessToken(wxCorpInfo));
+        String url=GET_APPROVAL_DETAIL.replace("ACCESS_TOKEN",getCorpAgentAccessToken(wxCorpInfo));
         HttpHeaders headers = new HttpHeaders();
         RestTemplate restTemplate = new RestTemplate();
         MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");