From 871d4095b07cedacb7fbef4c38d64982f539c404 Mon Sep 17 00:00:00 2001
From: fei.wang <wf18701153496@163.com>
Date: 星期四, 09 五月 2024 15:40:15 +0800
Subject: [PATCH] 测试提交

---
 src/main/java/com/flow/quartz/MyJob.java |  276 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 276 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/flow/quartz/MyJob.java b/src/main/java/com/flow/quartz/MyJob.java
new file mode 100644
index 0000000..b3638bc
--- /dev/null
+++ b/src/main/java/com/flow/quartz/MyJob.java
@@ -0,0 +1,276 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by FernFlower decompiler)
+//
+
+package com.flow.quartz;
+
+import cn.hutool.json.JSONArray;
+import cn.hutool.json.JSONObject;
+import com.flow.pojo.Card;
+import com.flow.service.CardService;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Base64;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class MyJob {
+    @Autowired
+    CardService cardService;
+
+    public MyJob() {
+    }
+
+    public void execute() throws NoSuchAlgorithmException, InvalidKeyException, IOException, ParseException {
+        String accessKey = "448c2cedcdce41428a290d144e81ab6e";
+        String str = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+        String accessSecret = "RgoIWycMYGmQfrLwLuT2VWawAhwMO8w7P9zh2dZp";
+        String nonce = "";
+        Date now = new Date();
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
+        String Timestamp = dateFormat.format(now);
+        int length = 30;
+        Random random = new Random();
+
+        for (int i = length; i > 0; --i) {
+            int index = random.nextInt(str.length());
+            nonce = nonce + str.charAt(index);
+        }
+
+        String stringSignTemp = accessKey + nonce + Timestamp;
+        Mac sha256Hmac = Mac.getInstance("HmacSHA256");
+        SecretKeySpec secretKeySpec = new SecretKeySpec(accessSecret.getBytes(StandardCharsets.UTF_8), "HmacSHA256");
+        sha256Hmac.init(secretKeySpec);
+        byte[] hmacBytes = sha256Hmac.doFinal(stringSignTemp.getBytes(StandardCharsets.UTF_8));
+        String sign = Base64.getEncoder().encodeToString(hmacBytes);
+        String targetUrl = "https://api.spruceiot.cn/api/v1/sim/list/query?pageIndex=1&pageSize=10";
+        URL url = new URL(targetUrl);
+        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+        connection.setRequestProperty("Accept-Charset", "UTF-8");
+        connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
+        connection.setRequestProperty("Access-Control-Allow-Origin", "http://localhost:8080");
+        connection.setRequestProperty("AccessKey", accessKey);
+        connection.setRequestProperty("Nonce", nonce);
+        connection.setRequestProperty("Timestamp", Timestamp);
+        connection.setRequestProperty("Sign", sign);
+        connection.connect();
+        BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
+        StringBuilder response1 = new StringBuilder();
+
+        String line;
+        while ((line = reader.readLine()) != null) {
+            response1.append(line);
+        }
+
+        reader.close();
+        connection.disconnect();
+        JSONObject jsonObject = new JSONObject(response1);
+        int code = jsonObject.getInt("code");
+        String message = jsonObject.getStr("message");
+        JSONObject result = jsonObject.getJSONObject("result");
+        int total1 = result.getInt("total");
+        JSONArray list = result.getJSONArray("list");
+        System.out.println("瀹氭椂鍣ㄦ墽琛屾垚鍔燂紒鏇存柊鏁版嵁");
+        int num = total1;  //绗笁鏂规墍鏈夊崱鍙�
+        int t = 0;
+        int total = 90;
+        int num1 = 0;
+        int numm = 0;
+
+        int index;
+        String nonce1;
+        String Timestamp1;
+        String stringSignTemp1;
+        String line1;
+        String stt1;
+        while (numm < num) {
+            ++num1;
+            System.out.println("绗�" + num1 + "娆¤皟鐢ㄦ帴鍙d粠" + t + "鍒�" + total + "缁撴潫:鎬绘潯鏁�" + num);
+            List<Card> card = this.cardService.proxyfindCard();
+            String stt = ""; //浠庢暟鎹簱鏌ヨ鐨勫崱鍙�
+
+            for (int i = t; i < total; ++i) {
+                ++numm;
+                if (numm == 90) {
+                    stt = stt + ((Card) card.get(i)).getCardnumber();
+                } else {
+                    if (card.size() <= i) {
+                        break;
+                    } else {
+                        stt = stt + ((Card) card.get(i)).getCardnumber() + ",";
+                    }
+
+                }
+            }
+            stt1 = "";
+
+            for (int i = length; i > 0; --i) {
+                index = random.nextInt(str.length());
+                stt1 = stt1 + str.charAt(index);
+            }
+
+            Date now1 = new Date();
+            SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyyMMddHHmmss");
+            nonce1 = dateFormat1.format(now1);
+            stringSignTemp1 = accessKey + stt1 + nonce1;
+
+            byte[] hmacBytes1 = sha256Hmac.doFinal(stringSignTemp1.getBytes(StandardCharsets.UTF_8));
+            Timestamp1 = Base64.getEncoder().encodeToString(hmacBytes1);
+            stringSignTemp1 = "https://api.spruceiot.cn/api/v1/sim/detail/batch/query";
+            stringSignTemp1 = stringSignTemp1 + "?cNo=" + stt.replaceAll("\\s+", "");
+            URL url1 = new URL(stringSignTemp1);
+            HttpURLConnection connection1 = (HttpURLConnection) url1.openConnection();
+            connection1.setRequestProperty("Accept-Charset", "UTF-8");
+            connection1.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
+            connection1.setRequestProperty("Access-Control-Allow-Origin", "http://localhost:8080");
+            connection1.setRequestProperty("AccessKey", accessKey);
+            connection1.setRequestProperty("Nonce", stt1);
+            connection1.setRequestProperty("Timestamp", nonce1);
+            connection1.setRequestProperty("Sign", Timestamp1);
+            connection1.connect();
+            BufferedReader reader1 = new BufferedReader(new InputStreamReader(connection1.getInputStream(), "UTF-8"));
+            StringBuilder response11 = new StringBuilder();
+
+
+            while ((line1 = reader1.readLine()) != null) {
+                response11.append(line1);
+            }
+
+            reader1.close();
+            connection1.disconnect();
+            JSONObject jsonObject1 = new JSONObject(response11);
+            int code1 = jsonObject1.getInt("code");
+            line1 = jsonObject1.getStr("message");
+            JSONArray resultArray = jsonObject1.getJSONArray("result");
+            Calendar calendar = Calendar.getInstance();
+            SimpleDateFormat date1 = new SimpleDateFormat("yyyy-MM-dd :hh:mm:ss");
+            if (resultArray!=null) {
+                for (int i = 0; i < resultArray.size(); ++i) {
+                    Card cardl = new Card();
+                    JSONObject item1 = resultArray.getJSONObject(i);
+                    cardl.setCardnumber(item1.getStr("iccid"));
+                    cardl.setOperator(item1.getStr("operators"));
+                    cardl.setCarddate(item1.getStr("serviceStartDate"));
+                    cardl.setEnddate(item1.getStr("serviceEndDate"));
+                    cardl.setEnterdate(item1.getStr("serviceStartDate"));
+                    cardl.setZflow(item1.getInt("dataLimit"));
+                    cardl.setSyflow(item1.getInt("dataUsage"));
+                    cardl.setSyll(item1.getInt("dataLimit") - item1.getInt("dataUsage"));
+                    cardl.setStatus(item1.getStr("status"));
+                    cardl.setIccid(item1.getStr("msisdn"));
+                    this.cardService.proxyupXinXi(cardl);
+                }
+                t += 90;
+                total += 90;
+                try {
+                    TimeUnit.SECONDS.sleep(12L);
+                } catch (InterruptedException var59) {
+                    var59.printStackTrace();
+                }
+            }else{
+                break;
+            }
+
+        }
+//
+//        int sheng = num % 90;
+//        List<Card> card = this.cardService.proxyfindCard();
+//        stt1 = "";
+//        int i = 0;
+//        index = sheng - 1;
+//
+//        for (int j = num - sheng; j < num - 1; ++j) {
+//            ++i;
+//            if (i == index) {
+//                stt1 = stt1 + ((Card) card.get(j)).getCardnumber();
+//            } else {
+//                stt1 = stt1 + ((Card) card.get(j)).getCardnumber() + ",";
+//            }
+//        }
+//
+//        nonce1 = "";
+//
+//        for (i = length; i > 0; --i) {
+//            index = random.nextInt(str.length());
+//            nonce1 = nonce1 + str.charAt(index);
+//        }
+//
+//        Date now1 = new Date();
+//        SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyyMMddHHmmss");
+//        Timestamp1 = dateFormat1.format(now1);
+//        stringSignTemp1 = accessKey + nonce1 + Timestamp1;
+//        byte[] hmacBytes1 = sha256Hmac.doFinal(stringSignTemp1.getBytes(StandardCharsets.UTF_8));
+//        String sign1 = Base64.getEncoder().encodeToString(hmacBytes1);
+//        String targetUrl1 = "https://api.spruceiot.cn/api/v1/sim/detail/batch/query";
+//        targetUrl1 = targetUrl1 + "?cNo=" + stt1.replaceAll("\\s+", "");
+//        URL url1 = new URL(targetUrl1);
+//        HttpURLConnection connection1 = (HttpURLConnection) url1.openConnection();
+//        connection1.setRequestProperty("Accept-Charset", "UTF-8");
+//        connection1.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
+//        connection1.setRequestProperty("Access-Control-Allow-Origin", "http://localhost:8080");
+//        connection1.setRequestProperty("AccessKey", accessKey);
+//        connection1.setRequestProperty("Nonce", nonce1);
+//        connection1.setRequestProperty("Timestamp", Timestamp1);
+//        connection1.setRequestProperty("Sign", sign1);
+//        connection1.connect();
+//        BufferedReader reader1 = new BufferedReader(new InputStreamReader(connection1.getInputStream(), "UTF-8"));
+//        StringBuilder response11 = new StringBuilder();
+//
+//        while ((line1 = reader1.readLine()) != null) {
+//            response11.append(line1);
+//        }
+//
+//        reader1.close();
+//        connection1.disconnect();
+//        JSONObject jsonObject1 = new JSONObject(response11);
+//        int code1 = jsonObject1.getInt("code");
+//        String message1 = jsonObject1.getStr("message");
+//        JSONArray resultArray = jsonObject1.getJSONArray("result");
+//        Calendar calendar = Calendar.getInstance();
+//        SimpleDateFormat date2 = new SimpleDateFormat("yyyy-MM-dd :hh:mm:ss");
+//
+//        for (i = 0; i < resultArray.size(); ++i) {
+//            Card cardl = new Card();
+//            JSONObject item1 = resultArray.getJSONObject(i);
+//            cardl.setCardnumber(item1.getStr("iccid"));
+//            cardl.setOperator(item1.getStr("operators"));
+//            cardl.setCarddate(item1.getStr("serviceStartDate"));
+//            cardl.setEnddate(item1.getStr("serviceEndDate"));
+//            cardl.setEnterdate(item1.getStr("serviceStartDate"));
+//            cardl.setZflow(item1.getInt("dataLimit"));
+//            cardl.setSyflow(item1.getInt("dataUsage"));
+//            cardl.setStatus(item1.getStr("status"));
+//            cardl.setIccid(item1.getStr("msisdn"));
+//            cardl.setSyll(item1.getInt("dataLimit") - item1.getInt("dataUsage"));
+//
+////            Date date = new Date();
+////            Date endDay=date2.parse(cardl.getEnddate());//缁撴潫鏃堕棿
+////            Long starTime = date.getTime();
+////            Long endTime=endDay.getTime();
+////            Long num11=endTime-starTime;//鏃堕棿鎴崇浉宸殑姣鏁�
+////            cardl.setRemainingdays(+num11/24/60/60/1000+"澶�");
+////            cardl.setUptime(date2.format(calendar.getTime()));
+//            this.cardService.proxyupXinXi(cardl);
+//        }
+
+        System.out.println("寰幆缁撴潫,绛夊緟瀹氭椂鍣ㄨЕ鍙戝啀娆¤皟鐢�");
+    }
+}

--
Gitblit v1.9.3