Files
pachongdelete/src/main/java/com/example/sso/controller/DeleteData.java
2025-09-25 09:52:41 +08:00

186 lines
5.7 KiB
Java

package com.example.sso.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.sso.dao.UpData;
import com.example.sso.util.V5utils;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class DeleteData {
@Scheduled(cron = "0 0 4 2 * *")
public void main() {
Boolean b = true;
String ID = "";
while (b) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("app_id","628eeaace7f28c00089a60cc");
jsonObject.put("entry_id","666973a2507c72e064cc585d");
jsonObject.put("limit",10000);
if (!ID.isEmpty()) {
jsonObject.put("data_id", ID);
}
if (!ID.isEmpty()) {
jsonObject.put("data_id", ID);
}
JSONArray jsonArray = new JSONArray();
jsonArray.add("sjyxx");
jsonObject.put("fields",jsonArray);
JSONObject filter = new JSONObject();
filter.put("rel","and");
JSONArray cond = new JSONArray();
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("field","sjyxx");
jsonObject1.put("method","eq");
JSONArray value = new JSONArray();
value.add("失效");
jsonObject1.put("value",value);
cond.add(jsonObject1);
filter.put("cond",cond);
jsonObject.put("filter",filter);
String jsonString = jsonObject.toJSONString();
String list = V5utils.list(jsonString);
JSONObject jsonObject2 = JSON.parseObject(list);
JSONArray jsonArray1 = jsonObject2.getJSONArray("data");
int size = jsonArray1.size();
if (size < 10000) {
for (Object o : jsonArray1) {
JSONObject test = (JSONObject) o;
String id = test.getString("_id");
JSONObject jsonObject11 = new JSONObject();
jsonObject11.put("app_id","628eeaace7f28c00089a60cc");
jsonObject11.put("entry_id","666973a2507c72e064cc585d");
jsonObject11.put("data_id",id);
String jsonString1 = jsonObject11.toJSONString();
V5utils.delete(jsonString1);
}
b = false;
} else {
for (Object o : jsonArray1) {
JSONObject test = (JSONObject) o;
String id = test.getString("_id");
JSONObject jsonObject11 = new JSONObject();
jsonObject11.put("app_id","628eeaace7f28c00089a60cc");
jsonObject11.put("entry_id","666973a2507c72e064cc585d");
jsonObject11.put("data_id",id);
String jsonString1 = jsonObject11.toJSONString();
V5utils.delete(jsonString1);
ID = id;
}
}
}
}
@Scheduled(cron = "0 0 4 16 * *")
public void main1() {
Boolean b = true;
String ID = "";
JSONArray jsonArrayEND = new JSONArray();
while (b) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("app_id","628eeaace7f28c00089a60cc");
jsonObject.put("entry_id","666973a2507c72e064cc585d");
jsonObject.put("limit",10000);
if (!ID.isEmpty()) {
jsonObject.put("data_id", ID);
}
JSONArray jsonArray = new JSONArray();
jsonArray.add("sjyxx");
jsonObject.put("fields",jsonArray);
JSONObject filter = new JSONObject();
filter.put("rel","and");
JSONArray cond = new JSONArray();
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("field","sjyxx");
jsonObject1.put("method","eq");
JSONArray value = new JSONArray();
value.add("失效");
jsonObject1.put("value",value);
cond.add(jsonObject1);
filter.put("cond",cond);
jsonObject.put("filter",filter);
String jsonString = jsonObject.toJSONString();
String list = V5utils.list(jsonString);
JSONObject jsonObject2 = JSON.parseObject(list);
JSONArray jsonArray1 = jsonObject2.getJSONArray("data");
int size = jsonArray1.size();
if (size < 10000) {
for (Object o : jsonArray1) {
JSONObject test = (JSONObject) o;
String id = test.getString("_id");
JSONObject jsonObject11 = new JSONObject();
jsonObject11.put("app_id","628eeaace7f28c00089a60cc");
jsonObject11.put("entry_id","666973a2507c72e064cc585d");
jsonObject11.put("data_id",id);
String jsonString1 = jsonObject11.toJSONString();
V5utils.delete(jsonString1);
}
b = false;
} else {
for (Object o : jsonArray1) {
JSONObject test = (JSONObject) o;
String id = test.getString("_id");
JSONObject jsonObject11 = new JSONObject();
jsonObject11.put("app_id","628eeaace7f28c00089a60cc");
jsonObject11.put("entry_id","666973a2507c72e064cc585d");
jsonObject11.put("data_id",id);
String jsonString1 = jsonObject11.toJSONString();
V5utils.delete(jsonString1);
ID = id;
}
}
}
}
}