合同下载
This commit is contained in:
@ -1,7 +1,202 @@
|
||||
package com.example.sso.test;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.example.sso.dao.A;
|
||||
import com.example.sso.dao.Files;
|
||||
import com.example.sso.util.APIUtils;
|
||||
import com.example.sso.util.FDaDaUtil;
|
||||
import com.example.sso.util.TimeUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
@Component
|
||||
@Slf4j
|
||||
public class F {
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
//合同单独下载
|
||||
Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
|
||||
@Scheduled(cron = "0 41 18 27 10 ?")
|
||||
|
||||
public static void main1() throws Exception {
|
||||
String saveDir = "/home/fadada/file/";
|
||||
//可以可以无
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
JSONObject ownerId = new JSONObject();
|
||||
ownerId.put("idType", "corp");
|
||||
ownerId.put("openId", "625776ecae6742cb8eb710beedef9b4c");
|
||||
jsonObject.put("ownerId", ownerId);
|
||||
JSONObject listFilter = new JSONObject();
|
||||
listFilter.put("signTaskStatus", "task_finished");
|
||||
jsonObject.put("listFilter", listFilter);
|
||||
String jsonString = jsonObject.toJSONString();
|
||||
String down = FDaDaUtil.list(jsonString);
|
||||
JSONObject jsonObject1 = JSON.parseObject(down);
|
||||
|
||||
//去A类拿分页数据!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
JSONArray jsonArray = A.jsonArray();
|
||||
|
||||
long currentTimestamp = System.currentTimeMillis();
|
||||
|
||||
Long tim = TimeUtils.tim(currentTimestamp);
|
||||
String s = "";
|
||||
String TaskSubject = "";
|
||||
for (Object o : jsonArray) {
|
||||
try {
|
||||
JSONObject oo = (JSONObject) o;
|
||||
String finishTime = oo.getString("finishTime");
|
||||
long parseLong = Long.parseLong(finishTime);
|
||||
if (parseLong >= 1760968800000l && parseLong <= 1761141600000l) {
|
||||
String signTaskId = oo.getString("signTaskId");
|
||||
String signTaskSubject = oo.getString("signTaskSubject");
|
||||
TaskSubject += signTaskSubject + ",";
|
||||
s += signTaskId + ",";
|
||||
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
System.out.println("异常");
|
||||
continue;
|
||||
}
|
||||
|
||||
log.info("完成");
|
||||
}
|
||||
// System.out.println(TaskSubject);
|
||||
|
||||
String substring1 = TaskSubject.substring(0, TaskSubject.length() - 1);
|
||||
|
||||
String[] splitStr1 = splitStr(substring1);
|
||||
|
||||
|
||||
String substring = s.substring(0, s.length() - 1);
|
||||
String[] splitStr = splitStr(substring);
|
||||
System.out.println(splitStr.length);
|
||||
|
||||
for (int i = 0; i < splitStr.length; i++) {
|
||||
String s1 = splitStr[i];
|
||||
String s2 = splitStr1[i];
|
||||
String urls = FDaDaUtil.urls(s1);
|
||||
FDaDaUtil.fileUrl(urls, s2, saveDir);
|
||||
if (s2.contains("$")) {
|
||||
String[] split = s2.split("\\$");
|
||||
String s3 = split[0];
|
||||
String s4 = split[1];
|
||||
String s5 = split[2];
|
||||
//新增简道云文件准备
|
||||
Map<String, String> test = Files.test();
|
||||
JSONObject object = (JSONObject) JSON.toJSON(test);
|
||||
String transactionid = object.getString("transaction_id"); //transaction_id
|
||||
JSONArray list = object.getJSONArray("token_and_url_list");
|
||||
JSONObject token = new JSONObject();
|
||||
for (int j = 0; j < list.size(); j++) {
|
||||
token = list.getJSONObject(j);
|
||||
|
||||
}
|
||||
String tokens = token.getString("token");//token
|
||||
String keys = APIUtils.keys(s2, tokens);
|
||||
|
||||
//新增简道云
|
||||
JSONObject test11 = new JSONObject(); //最外层
|
||||
test11.put("app_id", "628eeaace7f28c00089a60cc");
|
||||
test11.put("entry_id", "65a4d762edb3f1bd573b3e4e");
|
||||
test11.put("transaction_id", transactionid);
|
||||
JSONObject jsonObjectdata = new JSONObject(); //data层
|
||||
JSONObject htlx = new JSONObject(); //合同类型
|
||||
htlx.put("value", s3);
|
||||
JSONObject htbh = new JSONObject(); //合同编号
|
||||
htbh.put("value", s5);
|
||||
JSONObject shfhm = new JSONObject(); //姓名
|
||||
shfhm.put("value", s4);
|
||||
JSONObject htzht = new JSONObject(); //主题
|
||||
htzht.put("value", s2);
|
||||
JSONObject ht = new JSONObject(); //文件
|
||||
JSONArray hts = new JSONArray();
|
||||
hts.add(keys);
|
||||
ht.put("value", hts);
|
||||
jsonObjectdata.put("htlx", htlx);
|
||||
jsonObjectdata.put("shfhm", shfhm);
|
||||
jsonObjectdata.put("htbh", htbh);
|
||||
jsonObjectdata.put("htzht", htzht);
|
||||
jsonObjectdata.put("ht", ht);
|
||||
test11.put("data", jsonObjectdata);
|
||||
String jsonString11 = test11.toJSONString();
|
||||
|
||||
String add = APIUtils.add(jsonString11);
|
||||
System.out.println(add);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String[] splitStr(String str) {
|
||||
return str.split(",");
|
||||
}
|
||||
|
||||
public static String urls() throws Exception {
|
||||
String ids = ids();
|
||||
JSONObject jsonobjects = new JSONObject();
|
||||
JSONObject ownerIds = new JSONObject();
|
||||
ownerIds.put("idType", "corp");
|
||||
ownerIds.put("openId", "625776ecae6742cb8eb710beedef9b4c");
|
||||
jsonobjects.put("ownerId", ownerIds);
|
||||
jsonobjects.put("signTaskId", ids);
|
||||
String jsonString = jsonobjects.toJSONString();
|
||||
String down = FDaDaUtil.down(jsonString);
|
||||
return down;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static String ids() throws Exception {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
JSONObject ownerId = new JSONObject();
|
||||
ownerId.put("idType", "corp");
|
||||
ownerId.put("openId", "625776ecae6742cb8eb710beedef9b4c");
|
||||
jsonObject.put("ownerId", ownerId);
|
||||
JSONObject listFilter = new JSONObject();
|
||||
listFilter.put("signTaskStatus", "task_finished");
|
||||
jsonObject.put("listFilter", listFilter);
|
||||
String jsonString = jsonObject.toJSONString();
|
||||
String down = FDaDaUtil.list(jsonString);
|
||||
JSONObject jsonObject1 = JSON.parseObject(down);
|
||||
JSONArray jsonArray = jsonObject1.getJSONObject("data").getJSONArray("signTasks");
|
||||
|
||||
long currentTimestamp = System.currentTimeMillis();
|
||||
|
||||
// 计算前24小时的时间戳
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(new Date(currentTimestamp));
|
||||
calendar.add(Calendar.HOUR_OF_DAY, -24);
|
||||
//后24小时
|
||||
Calendar calendars = Calendar.getInstance();
|
||||
calendars.setTime(new Date(currentTimestamp));
|
||||
calendars.add(Calendar.HOUR_OF_DAY, 24);
|
||||
long last24hrsTimestamp = calendar.getTimeInMillis();
|
||||
long next24hrsTimestamp = calendars.getTimeInMillis();
|
||||
String s = "";
|
||||
for (Object o : jsonArray) {
|
||||
JSONObject oo = (JSONObject) o;
|
||||
String finishTime = oo.getString("finishTime");
|
||||
long parseLong = Long.parseLong(finishTime);
|
||||
if (parseLong >= last24hrsTimestamp && parseLong <= next24hrsTimestamp) {
|
||||
String signTaskId = oo.getString("signTaskId");
|
||||
s += signTaskId + ",";
|
||||
}
|
||||
|
||||
}
|
||||
String substring = s.substring(0, s.length() - 1);
|
||||
return substring;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user