xuhy
6 天以前 89351ad17c81b37495f21d4dfbf28f0d306a155a
ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/utils/PrivateNumberUtil.java
@@ -15,6 +15,9 @@
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.Date;
import java.util.concurrent.TimeUnit;
@@ -68,8 +71,15 @@
                    log.info("获取token:{}",string);
                    JSONObject jsonObject = JSONObject.parseObject(string);
                    JSONObject tokenJson = jsonObject.getJSONObject("token");
                    Date expiresAt = tokenJson.getDate("expires_at");
                    redisService.setCacheObject("PRIVATE_NUMBER:",token,expiresAt.getTime()-System.currentTimeMillis(), TimeUnit.MILLISECONDS);
                    // 2025-10-23T07:27:59.224000Z
                    String expiresAt = tokenJson.getString("expires_at");
                    // 将字符串解析为Instant
                    Instant instant = Instant.parse(expiresAt);
                    // 转换为Date
                    Date date = Date.from(instant);
//                    String replace = expiresAt.substring(0, expiresAt.lastIndexOf(".")).replace("T", " ");
//                    Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(replace);
                    redisService.setCacheObject("PRIVATE_NUMBER:",token,date.getTime()-System.currentTimeMillis(), TimeUnit.MILLISECONDS);
                } catch (IOException e) {
                    throw new ServiceException(e.getMessage());
                }
@@ -132,6 +142,7 @@
                            multipartFile.getBytes()
                    );
                    builder.addFormDataPart("files", multipartFile.getOriginalFilename(), fileBody);
                    System.err.println("文件名称+"+multipartFile.getOriginalFilename());
                }
            }
        } catch (IOException e) {
@@ -156,6 +167,7 @@
                    JSONObject jsonObject = JSONObject.parseObject(string);
                    String result = jsonObject.getString("result");
                    if("Upload Successful.".equals(result)){
                        System.err.println("返回的文件名称+"+file.getOriginalFilename());
                        return R.ok(file.getOriginalFilename(),"");
                    }else {
                        String failReason = jsonObject.getString("failReason");