diff --git b/.gitignore a/.gitignore
new file mode 100644
index 0000000..1f635d8
--- /dev/null
+++ a/.gitignore
@@ -0,0 +1,2 @@
+lib
+target
diff --git b/ReadMe.txt a/ReadMe.txt
new file mode 100644
index 0000000..3d20ae8
--- /dev/null
+++ a/ReadMe.txt
@@ -0,0 +1,15 @@
+Camel Router Spring Project
+===========================
+
+To build this project use
+
+ mvn install
+
+To run this project with Maven use
+
+ mvn camel:run
+
+For more help see the Apache Camel documentation
+
+ http://camel.apache.org/
+
diff --git b/olmcrm.iml a/olmcrm.iml
new file mode 100644
index 0000000..7821051
--- /dev/null
+++ a/olmcrm.iml
@@ -0,0 +1,121 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git b/pom.xml a/pom.xml
new file mode 100644
index 0000000..8b0c17c
--- /dev/null
+++ a/pom.xml
@@ -0,0 +1,259 @@
+
+
+
+ 4.0.0
+
+ com.olm
+ olmcrm
+ jar
+ A tools for crm's report output PDF
+ 3.0-SNAPSHOT
+
+
+ olm-crm-pdf
+
+
+ UTF-8
+ UTF-8
+ 2.13.3
+
+
+
+
+
+
+ org.apache.camel
+ camel-bom
+ 3.4.2
+ import
+ pom
+
+
+ ingageSDK
+ ingageSDK
+ 1.0
+
+
+
+
+
+
+
+ org.apache.camel
+ camel-core
+
+
+ org.apache.camel
+ camel-spring-main
+
+
+ ingageSDK
+ ingageSDK
+ 1.0
+
+
+
+
+ com.alibaba
+ fastjson
+ 1.2.47
+
+
+
+ org.eclipse.birt.runtime.3_7_1
+ com.lowagie.text
+ 2.1.7
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.apache.camel
+ camel-test-spring
+ test
+
+
+
+ org.apache.httpcomponents
+ httpclient
+ 4.5.3
+
+
+
+ net.sf.json-lib
+ json-lib
+ 2.4
+ jdk15
+
+
+ commons-logging
+ commons-logging
+
+
+ commons-lang
+ commons-lang
+
+
+
+
+
+ commons-httpclient
+ commons-httpclient
+ 3.1
+
+
+ commons-codec
+ commons-codec
+
+
+ commons-logging
+ commons-logging
+
+
+
+
+ com.itextpdf
+ itextpdf
+ 5.5.11
+
+
+
+ com.itextpdf
+ itext-asian
+ 5.2.0
+
+
+ cn.hutool
+ hutool-all
+ 5.7.22
+
+
+ org.projectlombok
+ lombok
+ 1.18.24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.apache.logging.log4j
+ log4j-api
+ ${log4j2.version}
+
+
+ org.apache.logging.log4j
+ log4j-core
+ ${log4j2.version}
+
+
+ org.apache.logging.log4j
+ log4j-slf4j-impl
+ 2.13.3
+
+
+ slf4j-api
+ org.slf4j
+
+
+
+
+ commons-logging
+ commons-logging
+ 1.2
+
+
+
+
+ install
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+ 3.1.1
+
+
+
+ true
+ lib/
+
+ com.olm.common.RequestUtilsItext
+
+
+
+
+ jar-with-dependencies
+
+
+
+
+ make-assembly
+ package
+
+ single
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.6.0
+
+ 1.8
+ 1.8
+ UTF-8
+
+ ${project.basedir}/libs
+
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+ 3.1.0
+
+ UTF-8
+
+
+
+
+
+
diff --git b/src/data/message1.xml a/src/data/message1.xml
new file mode 100644
index 0000000..2b6d64c
--- /dev/null
+++ a/src/data/message1.xml
@@ -0,0 +1,6 @@
+
+
+ James
+ Strachan
+ London
+
\ No newline at end of file
diff --git b/src/data/message2.xml a/src/data/message2.xml
new file mode 100644
index 0000000..dce1d94
--- /dev/null
+++ a/src/data/message2.xml
@@ -0,0 +1,6 @@
+
+
+ Hiram
+ Chirino
+ Tampa
+
\ No newline at end of file
diff --git b/src/main/java/com/olm/common/RequestUtilsItext.java a/src/main/java/com/olm/common/RequestUtilsItext.java
new file mode 100644
index 0000000..877f847
--- /dev/null
+++ a/src/main/java/com/olm/common/RequestUtilsItext.java
@@ -0,0 +1,481 @@
+package com.olm.common;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.itextpdf.text.DocumentException;
+import com.olm.util.Configure;
+import com.olm.util.FileUtilText;
+import com.olm.util.LasMonth;
+import com.rkhd.platform.sdk.http.CommonData;
+import com.rkhd.platform.sdk.http.CommonHttpClient;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.http.client.utils.DateUtils;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Objects;
+
+import static com.olm.util.TokenTest.getAccessTokenString;
+
+/**
+ * ClassName:RequestUtilsItext Package:PACKAGE_NAME Date:2020/7/27 Auth:penghui@olm.com.cn
+ */
+@Slf4j
+public class RequestUtilsItext {
+ private static String fistAll;
+ private static String fileoutpath;
+ private static boolean isDebug= false;
+
+ public static void main(String args[]) {
+ log.info("开始执行");
+ // YYYY-MM-DD
+ Calendar cd = Calendar.getInstance();
+ Date ld = new LasMonth.LastMonthDate().convert(cd);//上个月25号
+ Date lld = new LasMonth.LastLastMonthDate().convert(cd);// 上上个月26号
+ if(args!=null && args.length>0){
+ String rq = "";
+ for(String s : args){
+ if (StrUtil.contains(s, "-")){
+ rq = s;
+ break;
+ }
+ }
+ if(StrUtil.isEmpty(rq)){
+ lld = new LasMonth.LastLastMonthDate().convert(cd);
+ }else{
+ lld = DateUtil.parseDate(rq);
+ }
+ log.info("获取数据的开始时间" + rq);
+ }
+
+ log.info("time " + DateUtil.now());
+ fileoutpath = Configure.getValue("fileoutpath");
+ if (StrUtil.contains(fileoutpath, "2022")){
+ fileoutpath = fileoutpath.replace("2022", DateUtil.format(DateUtil.date(), "YYYY"));
+ }
+ fistAll = Configure.getValue("fistAll");
+ FileUtilText.writeTxtFile("------------------------------------- \n");
+ //当前时间
+ log.info("-------------------------------------");
+ log.info("执行开始时间:" + DateUtil.now());
+ //生成PDF
+ autoGenPdf(ld, lld);
+
+ log.info("执行结束时间:" + DateUtil.now());
+ log.info("-------------------------------------");
+
+ }
+
+ /**
+ * 生成PDF
+ * @param ld 截止时间(上个月25号)
+ * @param lld 开始时间(上上个月26号)
+ */
+ private static void autoGenPdf(Date ld, Date lld){
+ FileUtilText.writeTxtFile("执行开始时间:" + DateUtil.now());
+ String accessToken = getAccessTokenString();
+ CommonHttpClient rkhdHttpClient = CommonHttpClient.instance();
+
+ FileUtilText.writeTxtFile("非驻场业务-服务报告单:");
+ //执行非驻场业务.需要通过limit n,m 取值
+ if (fistAll.equals("true")) {
+ //2022-09-24 模板ID有修改 2445020587458656
+ int[] steeps = RequestUtilsItext.getstep();
+ for (int setp : steeps) {
+ RequestUtilsItext.fzc(rkhdHttpClient, accessToken, setp, ld, lld);
+ log.info("服务报告单处理数:" + setp);
+ }
+ } else {
+ RequestUtilsItext.fzc(rkhdHttpClient, accessToken, 1, ld, lld);
+ log.info("服务报告单处理.");
+ }
+
+
+ if (!isDebug){
+ //执行驻场-售后派工单。400多条。打印模板id:794158019789010,fieldJob
+ FileUtilText.writeTxtFile("执行驻场-售后派工单:");
+ RequestUtilsItext.zc(rkhdHttpClient, accessToken, ld, lld);
+ //执行驻场-售后派工单-管理层创建。500多条。打印模板id:805605251514666,fieldJob
+ FileUtilText.writeTxtFile("售后派工单-管理层创建:");
+ RequestUtilsItext.zcnew(rkhdHttpClient, accessToken, "驻场", "售后派工单-管理层创建", "805605251514666", ld, lld);
+ //派工单-驻场-售前派工单.301条。 804204168790256 805605105664259
+ FileUtilText.writeTxtFile("售前派工单:");
+ RequestUtilsItext.zcnew(rkhdHttpClient, accessToken, null, "售前派工单", "804204168790256", ld, lld);
+ //派工单-售前派工单-管理层创建.146条。 805605105664259
+ FileUtilText.writeTxtFile("售前派工单-管理层创建:");
+ RequestUtilsItext.zcnew(rkhdHttpClient, accessToken, null, "售前派工单-管理层创建", "805605105664259", ld, lld);
+ //派工单-提前执行派工单.80条 805603764846892
+ FileUtilText.writeTxtFile("提前执行派工单:");
+ RequestUtilsItext.zcnew(rkhdHttpClient, accessToken, null, "提前执行派工单", "805603764846892", ld, lld);
+ //派工单-提前执行派工单.63条 805604259545318
+ FileUtilText.writeTxtFile("提前执行派工单-管理层创建:");
+ RequestUtilsItext.zcnew(rkhdHttpClient, accessToken, null, "提前执行派工单-管理层创建", "805604259545318", ld, lld);
+ }
+ FileUtilText.writeTxtFile("执行结束时间:" +DateUtil.now());
+ FileUtilText.writeTxtFile("-------------------------------------");
+ }
+
+
+ /**
+ * 获取数据Get类型
+ * @param rkhdHttpClient
+ * @param accessToken
+ * @param urls
+ * @return
+ */
+ public static byte[] getRecord(CommonHttpClient rkhdHttpClient, String accessToken, String urls) {
+ CommonData data = new CommonData();
+ try {
+ data.putHeader("Authorization", accessToken);
+ data.setCall_type("GET");
+ data.setCallString(urls);
+ JSONObject response = JSONObject.parseObject(rkhdHttpClient.execute(data).getResult());
+ if (StrUtil.isEmpty(response.getString("data"))) {
+ log.info("getRecord数据查询错误." + urls);
+ return null;
+ }
+ return response.getBytes("data");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ /**
+ * 获取数据POST类型
+ * @param crmHttpClient 销售易客户端
+ * @param accessToken token
+ * @param xoql 查询的SQL
+ * @return
+ */
+ public static JSONArray postRecord(CommonHttpClient crmHttpClient, String accessToken, String xoql) {
+ CommonData data = new CommonData();
+ try {
+ data.putHeader("Authorization", accessToken);
+ data.setCall_type("POST");
+ data.setCallString("https://api.xiaoshouyi.com/rest/data/v2.0/query/xoql");
+ data.putFormData("xoql", xoql);
+ data.putFormData("useSimpleCode", true);
+ JSONObject response = JSONObject.parseObject(crmHttpClient.execute(data).getResult());
+ JSONObject result = JSONObject.parseObject(response.getString("data"));
+ // 2023-11-22 判断是否存在key
+ if (result != null && result.containsKey("records")){
+ return result.getJSONArray("records");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ /**
+ * 获取数据Post类型
+ * @param rkhdHttpClient
+ * @param accessToken
+ * @param xoql
+ * @return
+ */
+ public static JSONObject postRecordObject(CommonHttpClient rkhdHttpClient, String accessToken, String xoql) {
+ CommonData data = new CommonData();
+ try {
+ data.putHeader("Authorization", accessToken);
+ data.setCall_type("POST");
+ data.setCallString("https://api.xiaoshouyi.com/rest/data/v2.0/query/xoql");
+ data.putFormData("xoql", xoql);
+ data.putFormData("useSimpleCode", true);
+ JSONObject response = JSONObject.parseObject(rkhdHttpClient.execute(data).getResult());
+ JSONObject result = JSONObject.parseObject(response.getString("data"));
+ //JSONObject records = result.getJSONArray("data");
+/* if (response.getString("records") == null){
+ System.out.println("postRecord数据查询错误.");
+ }*/
+ //return records;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ /**
+ * 非驻场
+ *
+ * @param rkhdHttpClient
+ * @param accessToken
+ */
+ public static void fzc(CommonHttpClient rkhdHttpClient, String accessToken, int setps, Date ld, Date lld) {
+ try {
+ //处理服务报告单----非驻场,包含售前、售后
+ //获得上上个月26号到上个月25号的服务报告单
+ //驻场类型--非驻场
+ Long customItem52 = Long.parseLong("2");
+ //获得时间访问
+ //SimpleDateFormat format233 = new SimpleDateFormat("yyyy-MM-dd");
+ //Calendar d = Calendar.getInstance();
+ //Date ld = new LasMonth.LastMonthDate().convert(d);
+ //Date lld = new LasMonth.LastLastMonthDate().convert(d);
+ //lld = DateUtil.parseDate("2022-01-01");
+ //ld = DateUtil.parseDate("2022-01-31");
+
+ StringBuilder fzc = new StringBuilder();
+ fzc.append("select id,name,customItem1__c,customItem29__c,customItem52__c, D1__c,customItem98__c,customItem42__c ");
+ fzc.append(", customItem68__c, customItem40__c, customItem72__c, customItem68__c ");
+ fzc.append(" from customEntity1__c ");
+ fzc.append(" where approvalStatus= 3 ");
+ fzc.append(" and customItem52__c = ");
+ fzc.append(customItem52);
+ if (fistAll.equals("true")) {
+ fzc.append(" order by name asc");
+ fzc.append(" limit ");
+ fzc.append(setps);
+ fzc.append(",");
+ fzc.append("3000");
+ } else {
+ fzc.append(" and D1__c > ");
+ fzc.append(lld.getTime());
+ fzc.append(" and D1__c < ");
+ fzc.append(ld.getTime());
+ }
+ //fzc.append(" and customItem42__c like '%秦皇岛%'");//and customItem42__c like '%秦皇岛%'
+ log.info("查询报告单总数SQL --> " + fzc.toString());
+ JSONArray records = RequestUtilsItext.postRecord(rkhdHttpClient, accessToken, fzc.toString());
+ assert records != null;
+ int itemNum = records.size();
+ FileUtilText.writeTxtFile("非驻场-售后服务报告单-" + "总数:" + itemNum);
+ for (int i = 0; i < itemNum; i++) {
+ StringBuilder sb = new StringBuilder();
+ String id = StrUtil.toString(records.getJSONObject(i).get("id"));
+ String fname = StrUtil.toString(records.getJSONObject(i).get("name"));
+ String officename = StrUtil.toString(records.getJSONObject(i).getString("customItem98__c"));//分公司销售部
+ String custemname = StrUtil.toString(records.getJSONObject(i).getString("customItem42__c"));//客户名
+ String customItem29__c = StrUtil.toString(records.getJSONObject(i).getString("customItem29__c"));//合同号
+ sb.append("https://api.xiaoshouyi.com/rest/template/v2.0/customEntity1__c/");
+ sb.append(id);
+ //sb.append("/756457200189639");
+ sb.append("/2445020587458656"); //新模板
+ //System.out.println("文件数:" + records.size() + "-" + i);
+ log.info("文件数:" +itemNum + "-" + i);
+ log.info("获取每个服务报告单的详情信息,URL : " + sb.toString());
+ byte[] reportData = RequestUtilsItext.getRecord(rkhdHttpClient, accessToken, sb.toString());
+ if (reportData!=null){
+ new RequestUtilsItext().writePdf(reportData, fname, officename, custemname, customItem29__c);
+ }else{
+ log.info("未获取到数据!");
+ }
+ }
+ FileUtilText.writeTxtFile("非驻场-售后服务报告单-" + "总数:" + itemNum + ",执行完成.");
+ } catch (Exception e) {
+ FileUtilText.writeTxtFile("非驻场-售后服务报告单-" + ",执行失败.");
+ System.out.println("Exception:" + e);
+ }
+ }
+
+ /**
+ * 派工单-驻场-售后派工单 现在都是管理层创建,只有400条左右是早期工程师创建输入这个范围,一次性输出。
+ *
+ * @param rkhdHttpClient
+ * @param accessToken
+ * @param ld lastDay
+ * @param lld lastLastDay
+ */
+ public static void zc(CommonHttpClient rkhdHttpClient, String accessToken, Date ld, Date lld) {
+ try {
+ //处理服务报告单----驻场,包含售后派工单
+ //获得上上个月26号到上个月25号的服务报告单
+ //驻场类型--驻场
+ //获得时间访问
+ //SimpleDateFormat format233 = new SimpleDateFormat("yyyy-MM-dd");
+ //Calendar d = Calendar.getInstance();
+ //Date ld = new LasMonth.LastMonthDate().convert(d);
+ //Date lld = new LasMonth.LastLastMonthDate().convert(d);
+ StringBuilder zc = new StringBuilder();
+ zc.append("select id,customItem31__c,caseNo,customItem91__c,fieldJobAccountId,fieldJobAccountId from fieldJob where customItem55__c ='驻场' and customItem48__c ='售后派工单' ");
+ //现在都是管理层创建,只有400条左右输入这个范围,所以去掉过滤。
+ if (!fistAll.equals("true")) {
+ zc.append(" and appointmentEndTime > ");
+ zc.append(lld.getTime());
+ zc.append(" and appointmentEndTime < ");
+ zc.append(ld.getTime());
+ }
+ log.info("驻场工单执行SQL: " + zc.toString());
+ JSONArray records = RequestUtilsItext.postRecord(rkhdHttpClient, accessToken, zc.toString());
+ //获得客户列表
+ String custemsql = "select id,accountName from account";
+ JSONArray custemrecords = RequestUtilsItext.postRecord(rkhdHttpClient, accessToken, custemsql);
+ HashMap hashMap = new HashMap();
+ for (int j = 0; j < custemrecords.size(); j++) {
+ hashMap.put(custemrecords.getJSONObject(j).get("id"), custemrecords.getJSONObject(j).get("accountName"));
+ }
+ int recordsNum = records.size();
+ FileUtilText.writeTxtFile("驻场-售后派工单-" + "总数:" + recordsNum);
+ for (int i = 0; i < recordsNum; i++) {
+ StringBuffer sb = new StringBuffer();
+ Object id = records.getJSONObject(i).get("id");
+ Object fname = records.getJSONObject(i).get("caseNo");
+ Object officename = records.getJSONObject(i).getString("customItem91__c");
+ Object customItem31__c = records.getJSONObject(i).getString("customItem31__c");
+ Object custemname = records.getJSONObject(i).getString("fieldJobAccountId"); //客户id
+ sb.append("https://api.xiaoshouyi.com/rest/template/v2.0/fieldJob/");
+ sb.append(id.toString());
+ sb.append("/794158019789010");
+ //System.out.println("文件数:" + records.size() + "-" + i);
+ log.info("文件数:" + recordsNum + "-" + i);
+ byte[] printdate = RequestUtilsItext.getRecord(rkhdHttpClient, accessToken, sb.toString());
+ new RequestUtilsItext().writePdf(printdate, fname.toString(), officename.toString(), hashMap.get(custemname.toString()).toString(), customItem31__c.toString());
+ }
+ FileUtilText.writeTxtFile("驻场-售后派工单-" + "总数:" + recordsNum + ",执行完成.");
+ } catch (Exception e) {
+ FileUtilText.writeTxtFile("驻场-售后派工单-" + ",执行失败.");
+ System.out.println("Exception:" + e);
+ }
+ }
+
+ /**
+ * 派工单-驻场-售前派工单 804204168790256 805605105664259 派工单-驻场-提前执行派工单 805604259545318 805603764846892 派工单-驻场-提前执行派工单-管理层创建 派工单-驻场-售前派工单-管理层创建 派工单-驻场-售后派工单-管理层创建 805605251514666 794158019789010
+ *
+ * @param rkhdHttpClient
+ * @param accessToken
+ * @param ld lastDay
+ * @param lld lastLastDay
+ */
+ public static void zcnew(CommonHttpClient rkhdHttpClient, String accessToken, String customItem55, String customItem48, String templatePrintId, Date ld, Date lld) {
+ try {
+ //处理服务报告单----驻场,包含售前、售后
+ //获得上上个月26号到上个月25号的服务报告单
+ //驻场类型--驻场
+ //获得时间访问
+ //SimpleDateFormat format233 = new SimpleDateFormat("yyyy-MM-dd");
+ //Calendar d = Calendar.getInstance();
+ //Date ld = new LasMonth.LastMonthDate().convert(d);
+ //Date lld = new LasMonth.LastLastMonthDate().convert(d);
+ StringBuilder zc = new StringBuilder();
+ zc.append("select id,caseNo,customItem91__c,customItem31__c,fieldJobAccountId,fieldJobAccountId from fieldJob where ");
+ zc.append("1=1");
+ if (customItem55 != null) {
+ zc.append(" and customItem55__c = ");
+ zc.append("'");
+ zc.append(customItem55);
+ zc.append("'");
+ }
+ zc.append(" and customItem48__c = ");
+ zc.append("'");
+ zc.append(customItem48);
+ zc.append("'");
+ //现在都是管理层创建,只有400条左右输入这个范围,所以去掉过滤。
+ if (!fistAll.equals("true")) {
+ zc.append(" and appointmentEndTime > ");
+ zc.append(lld.getTime());
+ zc.append(" and appointmentEndTime < ");
+ zc.append(ld.getTime());
+ }
+ log.info("驻场(new)工单执行SQL: " + zc.toString());
+ JSONArray records = RequestUtilsItext.postRecord(rkhdHttpClient, accessToken, zc.toString());
+ //获得客户列表
+ String custemsql = "select id,accountName from account";
+ JSONArray custemrecords = RequestUtilsItext.postRecord(rkhdHttpClient, accessToken, custemsql);
+ HashMap hashMap = new HashMap();
+ for (int j = 0; j < Objects.requireNonNull(custemrecords).size(); j++) {
+ hashMap.put(custemrecords.getJSONObject(j).get("id"), custemrecords.getJSONObject(j).get("accountName"));
+ }
+ assert records != null;
+ int recordsNum = records.size();
+ FileUtilText.writeTxtFile("总数:" + recordsNum);
+ for (int i = 0; i < recordsNum; i++) {
+ StringBuffer sb = new StringBuffer();
+ Object id = records.getJSONObject(i).get("id");
+ Object fname = records.getJSONObject(i).get("caseNo");
+ Object officename = records.getJSONObject(i).getString("customItem91__c");
+ Object customItem31__c = records.getJSONObject(i).getString("customItem31__c");
+ Object custemname = records.getJSONObject(i).getString("fieldJobAccountId"); //客户id
+ sb.append("https://api.xiaoshouyi.com/rest/template/v2.0/fieldJob/");
+ sb.append(id.toString());
+ sb.append("/");
+ sb.append(templatePrintId);
+ //System.out.println("文件数:" + records.size() + "-" + i);
+ log.info("文件数:" + recordsNum + "-" + i);
+ byte[] printdate = RequestUtilsItext.getRecord(rkhdHttpClient, accessToken, sb.toString());
+ new RequestUtilsItext().writePdf(printdate, fname.toString(), officename.toString(), hashMap.get(custemname.toString()).toString(), customItem31__c.toString());
+ }
+ FileUtilText.writeTxtFile("总数:" + recordsNum + ",执行完成");
+ } catch (Exception e) {
+ FileUtilText.writeTxtFile(",执行失败.");
+ log.error("生成驻场报告时异常", e);
+ }
+ }
+
+ /**
+ * 步长
+ * @return
+ */
+ public static int[] getstep() {
+ int[] data = new int[9];
+ data[0] = 0;
+ data[1] = 3000;
+ data[2] = 6000;
+ data[3] = 9000;
+ data[4] = 12000;
+ data[5] = 15000;
+ data[6] = 18000;
+ data[7] = 21000;
+ data[8] = 24000;
+ return data;
+ }
+
+
+ /**
+ * 生成PDF
+ * @param s
+ * @param id
+ * @param officeName
+ * @param customerName
+ * @param customItem29__c
+ * @throws DocumentException
+ */
+ public void writePdf(byte[] s, String id, String officeName, String customerName, String customItem29__c){
+ String outpath = fileoutpath;
+ String pdffile;
+ try {
+ String oficname = outpath.concat(officeName);//分公司
+ String custname = oficname.concat(File.separator).concat(customerName);//客户名称
+ if (customItem29__c != null) {
+ pdffile = custname.concat(File.separator).concat(customItem29__c).concat("_").concat(id).concat(".pdf");
+ } else {
+ pdffile = custname.concat(File.separator).concat(id).concat(".pdf");
+ }
+ //判断是否存在,如果不存在则创建
+ this.creatDir(custname, pdffile);
+ FileOutputStream fOut = new FileOutputStream(new File(pdffile));
+ fOut.write(s);
+ fOut.close();
+ } catch (Exception e) {
+ log.error("创建PDF文件时异常", e);
+ }
+ }
+
+ /**
+ * 判断文件、文件夹是否存在,不存在时新建
+ * @param filePath
+ * @param fileName
+ * @throws IOException
+ */
+ public void creatDir(String filePath, String fileName) throws IOException {
+ File file_path = new File(filePath);
+ if (!file_path.exists()) { //用来测试此路径名表示的文件或目录是否存在
+ boolean isOk= file_path.mkdirs();//创建目录
+ if (isOk){
+ log.info("文件夹不存在,自动创建成功!"+ filePath);
+ }
+ }
+ File file = new File(fileName);
+ if (!file.exists()) {
+ boolean isOk= file.createNewFile();//创建文件
+ if (isOk){
+ log.info("文件不存在,自动创建成功!" + fileName);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git b/src/main/java/com/olm/common/RequestUtilsLowagie.java a/src/main/java/com/olm/common/RequestUtilsLowagie.java
new file mode 100644
index 0000000..7266c73
--- /dev/null
+++ a/src/main/java/com/olm/common/RequestUtilsLowagie.java
@@ -0,0 +1,378 @@
+package com.olm.common;
+
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.lowagie.text.DocumentException;
+import com.olm.util.Configure;
+import com.olm.util.FileUtilText;
+import com.olm.util.LasMonth;
+import com.rkhd.platform.sdk.http.CommonData;
+import com.rkhd.platform.sdk.http.CommonHttpClient;
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.logging.Logger;
+
+import static com.olm.util.TokenTest.getAccessTokenString;
+@Slf4j
+/**
+ * ClassName:RequestUtils Package:PACKAGE_NAME Date:2020/7/27 Auth:penghui@olm.com.cn
+ */
+public class RequestUtilsLowagie {
+ static Logger logger = Logger.getLogger(String.valueOf(RequestUtilsLowagie.class));
+ static String fistAll;
+ static String fileoutpath;
+
+ public static byte[] getRecord(CommonHttpClient rkhdHttpClient, String accessToken, String urls) {
+ CommonData data = new CommonData();
+ try {
+ data.putHeader("Authorization", accessToken);
+ data.setCall_type("GET");
+ data.setCallString(urls);
+ JSONObject response = JSONObject.parseObject(rkhdHttpClient.execute(data).getResult());
+ if (response.getString("data") == null) {
+ System.out.println("getRecord数据查询错误." + urls);
+ }
+ return response.getBytes("data");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public static JSONArray postRecord(CommonHttpClient rkhdHttpClient, String accessToken, String xoql) {
+ CommonData data = new CommonData();
+ try {
+ data.putHeader("Authorization", accessToken);
+ data.setCall_type("POST");
+ data.setCallString("https://api.xiaoshouyi.com/rest/data/v2.0/query/xoql");
+ data.putFormData("xoql", xoql);
+ data.putFormData("useSimpleCode", true);
+ JSONObject response = JSONObject.parseObject(rkhdHttpClient.execute(data).getResult());
+ log.info("CRM接口返回信息:" + response.toJSONString());
+ JSONObject result = JSONObject.parseObject(response.getString("data"));
+ if (result!= null && result.containsKey("records")){
+ return result.getJSONArray("records");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public static JSONObject postRecordObject(CommonHttpClient rkhdHttpClient, String accessToken, String xoql) {
+ CommonData data = new CommonData();
+ try {
+ data.putHeader("Authorization", accessToken);
+ data.setCall_type("POST");
+ data.setCallString("https://api.xiaoshouyi.com/rest/data/v2.0/query/xoql");
+ data.putFormData("xoql", xoql);
+ data.putFormData("useSimpleCode", true);
+ JSONObject response = JSONObject.parseObject(rkhdHttpClient.execute(data).getResult());
+ JSONObject result = JSONObject.parseObject(response.getString("data"));
+ //JSONObject records = result.getJSONArray("data");
+/* if (response.getString("records") == null){
+ System.out.println("postRecord数据查询错误.");
+ }*/
+ return result;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ /**
+ * 非驻场
+ *
+ * @param rkhdHttpClient
+ * @param accessToken
+ */
+ public static void fzc(CommonHttpClient rkhdHttpClient, String accessToken, int setps) {
+ try {
+ //处理服务报告单----非驻场,包含售前、售后
+ //获得上上个月26号到上个月25号的服务报告单
+ //驻场类型--非驻场
+ Long customItem52 = Long.parseLong("2");
+ //获得时间访问
+ SimpleDateFormat format233 = new SimpleDateFormat("yyyy-MM-dd");
+ Calendar d = Calendar.getInstance();
+ Date ld = new LasMonth.LastMonthDate().convert(d);
+ Date lld = new LasMonth.LastLastMonthDate().convert(d);
+ StringBuffer fzc = new StringBuffer();
+ fzc.append("select id,name,customItem1__c,customItem29__c,customItem52__c,D1__c,customItem98__c,customItem42__c from customEntity1__c where approvalStatus= 3");
+ fzc.append(" and customItem52__c = ");
+ fzc.append(customItem52);
+ if (fistAll.equals("true")) {
+ fzc.append(" order by name asc");
+ fzc.append(" limit ");
+ fzc.append(setps);
+ fzc.append(",");
+ fzc.append("3000");
+ } else {
+ fzc.append(" and D1__c > ");
+ fzc.append(lld.getTime());
+ fzc.append(" and D1__c < ");
+ fzc.append(ld.getTime());
+ }
+ JSONArray records = RequestUtilsLowagie.postRecord(rkhdHttpClient, accessToken, fzc.toString());
+ FileUtilText.writeTxtFile("非驻场-售后服务报告单-" + "总数:" + records.size());
+ for (int i = 0; i < records.size(); i++) {
+ StringBuffer sb = new StringBuffer();
+ Object id = records.getJSONObject(i).get("id");
+ Object fname = records.getJSONObject(i).get("name");
+ Object officename = records.getJSONObject(i).getString("customItem98__c");
+ Object custemname = records.getJSONObject(i).getString("customItem42__c");
+ Object customItem29__c = records.getJSONObject(i).getString("customItem29__c");
+ sb.append("https://api.xiaoshouyi.com/rest/template/v2.0/customEntity1__c/");
+ sb.append(id.toString());
+ sb.append("/756457200189639");
+ System.out.println("文件数:" + records.size() + "-" + i);
+ logger.info("文件数:" + records.size() + "-" + i);
+ byte[] printdate = RequestUtilsLowagie.getRecord(rkhdHttpClient, accessToken, sb.toString());
+ new RequestUtilsLowagie().writePdf(printdate, fname.toString(), officename.toString(), custemname.toString(), customItem29__c.toString());
+ }
+ FileUtilText.writeTxtFile("非驻场-售后服务报告单-" + "总数:" + records.size() + ",执行完成.");
+ } catch (Exception e) {
+ FileUtilText.writeTxtFile("非驻场-售后服务报告单-" + ",执行失败.");
+ System.out.println("Exception:" + e);
+ }
+ }
+
+ /**
+ * 派工单-驻场-售后派工单 现在都是管理层创建,只有400条左右是早期工程师创建输入这个范围,一次性输出。
+ *
+ * @param rkhdHttpClient
+ * @param accessToken
+ */
+ public static void zc(CommonHttpClient rkhdHttpClient, String accessToken) {
+ try {
+ //处理服务报告单----驻场,包含售后派工单
+ //获得上上个月26号到上个月25号的服务报告单
+ //驻场类型--驻场
+ //获得时间访问
+ SimpleDateFormat format233 = new SimpleDateFormat("yyyy-MM-dd");
+ Calendar d = Calendar.getInstance();
+ Date ld = new LasMonth.LastMonthDate().convert(d);
+ Date lld = new LasMonth.LastLastMonthDate().convert(d);
+ StringBuffer fzc = new StringBuffer();
+ fzc.append("select id,customItem31__c,caseNo,customItem91__c,fieldJobAccountId,fieldJobAccountId from fieldJob where customItem55__c ='驻场' and customItem48__c ='售后派工单'");
+ //现在都是管理层创建,只有400条左右输入这个范围,所以去掉过滤。
+ if (!fistAll.equals("true")) {
+ fzc.append(" and appointmentEndTime > ");
+ fzc.append(lld.getTime());
+ fzc.append(" and appointmentEndTime < ");
+ fzc.append(ld.getTime());
+ }
+ JSONArray records = RequestUtilsLowagie.postRecord(rkhdHttpClient, accessToken, fzc.toString());
+ //获得客户列表
+ String custemsql = "select id,accountName from account";
+ JSONArray custemrecords = RequestUtilsLowagie.postRecord(rkhdHttpClient, accessToken, custemsql);
+ HashMap hashMap = new HashMap();
+ for (int j = 0; j < custemrecords.size(); j++) {
+ hashMap.put(custemrecords.getJSONObject(j).get("id"), custemrecords.getJSONObject(j).get("accountName"));
+ }
+ FileUtilText.writeTxtFile("驻场-售后派工单-" + "总数:" + records.size());
+ for (int i = 0; i < records.size(); i++) {
+ StringBuffer sb = new StringBuffer();
+ Object id = records.getJSONObject(i).get("id");
+ Object fname = records.getJSONObject(i).get("caseNo");
+ Object officename = records.getJSONObject(i).getString("customItem91__c");
+ Object customItem31__c = records.getJSONObject(i).getString("customItem31__c");
+ Object custemname = records.getJSONObject(i).getString("fieldJobAccountId"); //客户id
+ sb.append("https://api.xiaoshouyi.com/rest/template/v2.0/fieldJob/");
+ sb.append(id.toString());
+ sb.append("/794158019789010");
+ System.out.println("文件数:" + records.size() + "-" + i);
+ logger.info("文件数:" + records.size() + "-" + i);
+ byte[] printdate = RequestUtilsLowagie.getRecord(rkhdHttpClient, accessToken, sb.toString());
+ new RequestUtilsLowagie().writePdf(printdate, fname.toString(), officename.toString(), hashMap.get(custemname.toString()).toString(), customItem31__c.toString());
+ }
+ FileUtilText.writeTxtFile("驻场-售后派工单-" + "总数:" + records.size() + ",执行完成.");
+ } catch (Exception e) {
+ FileUtilText.writeTxtFile("驻场-售后派工单-" + ",执行失败.");
+ System.out.println("Exception:" + e);
+ }
+ }
+
+ /**
+ * 派工单-驻场-售前派工单 804204168790256 805605105664259 派工单-驻场-提前执行派工单 805604259545318 805603764846892 派工单-驻场-提前执行派工单-管理层创建 派工单-驻场-售前派工单-管理层创建 派工单-驻场-售后派工单-管理层创建 805605251514666 794158019789010
+ *
+ * @param rkhdHttpClient
+ * @param accessToken
+ */
+ public static void zcnew(CommonHttpClient rkhdHttpClient, String accessToken, String customItem55, String customItem48, String templatePrintId) {
+ try {
+ //处理服务报告单----驻场,包含售前、售后
+ //获得上上个月26号到上个月25号的服务报告单
+ //驻场类型--驻场
+ //获得时间访问
+ Calendar d = Calendar.getInstance();
+ Date ld = new LasMonth.LastMonthDate().convert(d);
+ Date lld = new LasMonth.LastLastMonthDate().convert(d);
+ StringBuffer fzc = new StringBuffer();
+ fzc.append("select id,caseNo,customItem91__c,customItem31__c,fieldJobAccountId,fieldJobAccountId from fieldJob where ");
+ fzc.append("1=1");
+ if (customItem55 != null) {
+ fzc.append(" and customItem55__c = ");
+ fzc.append("'");
+ fzc.append(customItem55);
+ fzc.append("'");
+ }
+ fzc.append(" and customItem48__c = ");
+ fzc.append("'");
+ fzc.append(customItem48);
+ fzc.append("'");
+ //现在都是管理层创建,只有400条左右输入这个范围,所以去掉过滤。
+ if (!fistAll.equals("true")) {
+ fzc.append(" and appointmentEndTime > ");
+ fzc.append(lld.getTime());
+ fzc.append(" and appointmentEndTime < ");
+ fzc.append(ld.getTime());
+ }
+ JSONArray records = RequestUtilsLowagie.postRecord(rkhdHttpClient, accessToken, fzc.toString());
+ //获得客户列表
+ String custemsql = "select id,accountName from account";
+ JSONArray custemrecords = RequestUtilsLowagie.postRecord(rkhdHttpClient, accessToken, custemsql);
+ HashMap hashMap = new HashMap();
+ for (int j = 0; j < custemrecords.size(); j++) {
+ hashMap.put(custemrecords.getJSONObject(j).get("id"), custemrecords.getJSONObject(j).get("accountName"));
+ }
+ FileUtilText.writeTxtFile("总数:" + records.size());
+ for (int i = 0; i < records.size(); i++) {
+ StringBuffer sb = new StringBuffer();
+ Object id = records.getJSONObject(i).get("id");
+ Object fname = records.getJSONObject(i).get("caseNo");
+ Object officename = records.getJSONObject(i).getString("customItem91__c");
+ Object customItem31__c = records.getJSONObject(i).getString("customItem31__c");
+ Object custemname = records.getJSONObject(i).getString("fieldJobAccountId"); //客户id
+ sb.append("https://api.xiaoshouyi.com/rest/template/v2.0/fieldJob/");
+ sb.append(id.toString());
+ sb.append("/");
+ sb.append(templatePrintId);
+ System.out.println("文件数:" + records.size() + "-" + i);
+ logger.info("文件数:" + records.size() + "-" + i);
+ byte[] printdate = RequestUtilsLowagie.getRecord(rkhdHttpClient, accessToken, sb.toString());
+ new RequestUtilsLowagie().writePdf(printdate, fname.toString(), officename.toString(), hashMap.get(custemname.toString()).toString(), customItem31__c.toString());
+ }
+ FileUtilText.writeTxtFile("总数:" + records.size() + ",执行完成");
+ } catch (Exception e) {
+ FileUtilText.writeTxtFile(",执行失败.");
+ System.out.println("Exception:" + e);
+ }
+ }
+
+ public static int[] getstep() {
+ int data[] = new int[9];
+ data[0] = 0;
+ data[1] = 3000;
+ data[2] = 6000;
+ data[3] = 9000;
+ data[4] = 12000;
+ data[5] = 15000;
+ data[6] = 18000;
+ data[7] = 21000;
+ data[8] = 24000;
+ return data;
+ }
+
+ public static void main(String args[]) throws URISyntaxException, IOException {
+ fileoutpath = Configure.getValue("fileoutpath");
+ if (StrUtil.contains(fileoutpath, "2022")){
+ fileoutpath = fileoutpath.replace("2022", DateUtil.format(DateUtil.date(), "YYYY"));
+ }
+ fistAll = Configure.getValue("fistAll");
+ FileUtilText.writeTxtFile("------------------------------------- \n");
+
+ //当前时间
+ Calendar calendar = Calendar.getInstance();
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ System.out.println(formatter.format(calendar.getTime()));
+ logger.info("-------------------------------------");
+ logger.info("执行开始时间:" + formatter.format(calendar.getTime()));
+ FileUtilText.writeTxtFile("执行开始时间:" + formatter.format(new Date()));
+ String accessToken = getAccessTokenString();
+ CommonHttpClient rkhdHttpClient = CommonHttpClient.instance();
+ FileUtilText.writeTxtFile("非驻场业务-服务报告单:");
+ //执行非驻场业务.需要通过limit n,m 取值
+ if (fistAll.equals("true")) {
+ int[] setps = RequestUtilsLowagie.getstep();
+ for (int setp : setps) {
+ RequestUtilsLowagie.fzc(rkhdHttpClient, accessToken, setp);
+ System.out.println("服务报告单处理数:" + setp);
+ }
+ } else {
+ RequestUtilsLowagie.fzc(rkhdHttpClient, accessToken, 1);
+ System.out.println("服务报告单处理每月数.");
+ }
+
+ //执行驻场-售后派工单。400多条。打印模板id:794158019789010,fieldJob
+ FileUtilText.writeTxtFile("执行驻场-售后派工单:");
+ RequestUtilsLowagie.zc(rkhdHttpClient, accessToken);
+ //执行驻场-售后派工单-管理层创建。500多条。打印模板id:805605251514666,fieldJob
+ FileUtilText.writeTxtFile("售后派工单-管理层创建:");
+ RequestUtilsLowagie.zcnew(rkhdHttpClient, accessToken, "驻场", "售后派工单-管理层创建", "805605251514666");
+ //派工单-驻场-售前派工单.301条。 804204168790256 805605105664259
+ FileUtilText.writeTxtFile("售前派工单:");
+ RequestUtilsLowagie.zcnew(rkhdHttpClient, accessToken, null, "售前派工单", "804204168790256");
+ //派工单-售前派工单-管理层创建.146条。 805605105664259
+ FileUtilText.writeTxtFile("售前派工单-管理层创建:");
+ RequestUtilsLowagie.zcnew(rkhdHttpClient, accessToken, null, "售前派工单-管理层创建", "805605105664259");
+ //派工单-提前执行派工单.80条 805603764846892
+ FileUtilText.writeTxtFile("提前执行派工单:");
+ RequestUtilsLowagie.zcnew(rkhdHttpClient, accessToken, null, "提前执行派工单", "805603764846892");
+ //派工单-提前执行派工单.63条 805604259545318
+ FileUtilText.writeTxtFile("提前执行派工单-管理层创建:");
+ RequestUtilsLowagie.zcnew(rkhdHttpClient, accessToken, null, "提前执行派工单-管理层创建", "805604259545318");
+
+ FileUtilText.writeTxtFile("执行结束时间:" + DateUtil.now());
+ FileUtilText.writeTxtFile("-------------------------------------");
+
+ }
+
+ public void writePdf(byte[] s, String id, String officename, String custemname, String customItem29__c) throws IOException, DocumentException {
+ String outpath = fileoutpath;
+ String pdffile = null;
+ try {
+ String oficname = outpath.concat(officename);//分公司
+ String custname = oficname.concat(File.separator).concat(custemname);//客户名称
+ if (customItem29__c != null) {
+ pdffile = custname.concat(File.separator).concat(customItem29__c).concat("_").concat(id).concat(".pdf");
+ } else {
+ pdffile = custname.concat(File.separator).concat(id).concat(".pdf");
+ }
+ //判断是否存在,如果不存在则创建
+ this.creatDir(custname, pdffile);
+ FileOutputStream fileOutputStream = new FileOutputStream(new File(pdffile));
+ if (fileOutputStream == null) {
+ System.out.println("文件数据为空:" + id);
+ }
+ fileOutputStream.write(s);
+ fileOutputStream.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void creatDir(String filePath, String filename) throws IOException {
+ File file = new File(filePath);
+ if (!file.exists()) { //用来测试此路径名表示的文件或目录是否存在
+ //file.isDirectory(); //来判断这是不是一个文件夹。
+ file.mkdirs();//创建目录
+ System.out.println("文件夹不存在");
+ }
+ File file2 = new File(filename);
+ if (!file2.exists()) {
+ file2.createNewFile();//创建文件
+ System.out.println("文件不存在");
+ }
+ }
+}
\ No newline at end of file
diff --git b/src/main/java/com/olm/del/HttpClientUtilBak.java a/src/main/java/com/olm/del/HttpClientUtilBak.java
new file mode 100644
index 0000000..158d3bf
--- /dev/null
+++ a/src/main/java/com/olm/del/HttpClientUtilBak.java
@@ -0,0 +1,129 @@
+package com.olm.del;
+
+import com.olm.util.JSONUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * ClassName:HttpClientUtil Package:com.olm.util Date:2020/7/27 Auth:penghui@olm.com.cn
+ */
+
+/**
+ * HttpClient工具类
+ */
+public class HttpClientUtilBak {
+
+ /**请求编码*/
+ private static final String DEFAULT_CHARSET = "UTF-8";
+
+ /**
+ * 执行HTTP POST请求
+ * @param url url
+ * @param param 参数
+ * @return
+ */
+ public static String httpPostWithJSON(String url, Map param) {
+ CloseableHttpClient client = null;
+ try {
+ if (url == null || url.trim().length() == 0) {
+ throw new Exception("URL is null");
+ }
+ HttpPost httpPost = new HttpPost(url);
+ client = HttpClients.createDefault();
+ if (param != null) {
+ StringEntity entity = new StringEntity(JSONUtils.toJSONString(param), DEFAULT_CHARSET);//解决中文乱码问题
+ entity.setContentEncoding(DEFAULT_CHARSET);
+ entity.setContentType("application/json");
+ httpPost.setEntity(entity);
+ }
+ HttpResponse resp = client.execute(httpPost);
+ if (resp.getStatusLine().getStatusCode() == 200) {
+ return EntityUtils.toString(resp.getEntity(), DEFAULT_CHARSET);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ close(client);
+ }
+ return null;
+ }
+
+ /**
+ * 执行HTTP GET请求
+ * @param url url
+ * @param param 参数
+ * @return
+ */
+ public static String httpGetWithJSON(String url, Map param) {
+ CloseableHttpClient client = null;
+ try {
+ if (url == null || url.trim().length() == 0) {
+ throw new Exception("URL is null");
+ }
+ client = HttpClients.createDefault();
+ if (param != null) {
+ StringBuffer sb = new StringBuffer("?");
+ for (String key : param.keySet()) {
+ sb.append(key).append("=").append(param.get(key)).append("&");
+ }
+ url = url.concat(sb.toString());
+ url = url.substring(0, url.length() - 1);
+ }
+ HttpGet httpGet = new HttpGet(url);
+ httpGet.addHeader("Accept", "text/html");
+ httpGet.addHeader("Accept-Charset", "utf-8");
+ httpGet.addHeader("Accept-Encoding", "gzip");
+ httpGet.addHeader("Accept-Language", "en-US,en");
+ //httpGet.addHeader("Authorization","Bearer ca4b6e4550d791b636e9a1d06869985fc0c2e1314ba85392a76bc94fc58b3ca9.MzYxNzk1");
+ httpGet.addHeader("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.160 Safari/537.22");
+
+ HttpResponse resp = client.execute(httpGet);
+ if (resp.getStatusLine().getStatusCode() == 200) {
+ return EntityUtils.toString(resp.getEntity(), DEFAULT_CHARSET);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ close(client);
+ }
+ return null;
+ }
+
+ /**
+ * 关闭HTTP请求
+ * @param client
+ */
+ private static void close(CloseableHttpClient client) {
+ if (client == null) {
+ return;
+ }
+ try {
+ client.close();
+ } catch (Exception e) {
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ Map param = new HashMap();
+ param.put("grant_type", "password");
+ param.put("Client_Id", "c97fbd8aca50ba94068da6ded23905df");
+ param.put("Client_Secret", "7a4d178ebf1d55229fd28c5cb18703da");
+ param.put("Redirect_Uri", "https://api.xiaoshouyi.com");
+ param.put("userName", "");
+ param.put("password", "");
+
+ String result = httpPostWithJSON("https://api.xiaoshouyi.com/oauth2/token", param);
+ //String result = httpGetWithJSON("https://api.xiaoshouyi.com/oauth2/token", param);
+ System.out.println("result:" + result);
+ }
+
+
+}
\ No newline at end of file
diff --git b/src/main/java/com/olm/del/TokenTest1.java a/src/main/java/com/olm/del/TokenTest1.java
new file mode 100644
index 0000000..9dff4dc
--- /dev/null
+++ a/src/main/java/com/olm/del/TokenTest1.java
@@ -0,0 +1,52 @@
+package com.olm.del;
+import org.apache.commons.httpclient.NameValuePair;
+import org.apache.commons.httpclient.methods.PostMethod;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+/**
+ * ClassName:TokenTest1 Package:com.olm.util Date:2020/7/27 Auth:penghui@olm.com.cn
+ */
+public class TokenTest1 {
+
+
+ public static void main(String[] args) {
+ try {
+ new TokenTest1().getToken("https://api.xiaoshouyi.com/oauth2/token");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public String getToken(String postURL) throws Exception {
+ PostMethod postMethod = new PostMethod(postURL);
+ postMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
+ //参数设置,需要注意的就是里边不能传NULL,要传空字符串
+ NameValuePair[] data = {
+ new NameValuePair("grant_type", "password"),
+ new NameValuePair("Client_Id", "c97fbd8aca50ba94068da6ded23905df"),
+ new NameValuePair("Client_Secret", "7a4d178ebf1d55229fd28c5cb18703da"),
+ new NameValuePair("Redirect_Uri", "https://api.xiaoshouyi.com"),
+ new NameValuePair("userName", "lyp@olm.com.cn"),
+ new NameValuePair("password", "lyp123456")
+
+ };
+ postMethod.setRequestBody(data);
+ org.apache.commons.httpclient.HttpClient httpClient = new org.apache.commons.httpclient.HttpClient();
+ httpClient.executeMethod(postMethod);
+/* String result = postMethod.getResponseBodyAsString();
+ System.out.println(result);*/
+
+ InputStream inputStream = postMethod.getResponseBodyAsStream();
+ BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
+ StringBuffer stringBuffer = new StringBuffer();
+ String str = "";
+ while ((str = br.readLine()) != null) {
+ stringBuffer.append(str);
+ }
+ System.out.println(stringBuffer);
+ return null;
+ }
+}
diff --git b/src/main/java/com/olm/util/Configure.java a/src/main/java/com/olm/util/Configure.java
new file mode 100644
index 0000000..658092e
--- /dev/null
+++ a/src/main/java/com/olm/util/Configure.java
@@ -0,0 +1,51 @@
+package com.olm.util;
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.InputStream;
+import java.util.Properties;
+
+@Slf4j
+public class Configure {
+
+ private static final Properties config;
+
+ static {
+ log.info("初始化加载配置!");
+ String filePath = "config.properties";
+ config = new Properties();
+ try {
+ ClassLoader CL = Configure.class.getClassLoader();
+ InputStream in;
+ if (CL != null) {
+ in = CL.getResourceAsStream(filePath);
+ } else {
+ in = ClassLoader.getSystemResourceAsStream(filePath);
+ }
+ config.load(in);
+ assert in != null;
+ in.close();
+ } catch (Exception e) {
+ log.error("加载配置异常", e);
+ }
+ }
+
+ public static String getValue(String key) {
+ if (config.containsKey(key)) {
+ return config.getProperty(key);
+ } else {
+ return "";
+ }
+ }
+
+ public static int getValueInt(String key) {
+ String value = getValue(key);
+ int valueInt = 0;
+ try {
+ valueInt = Integer.parseInt(value);
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ return valueInt;
+ }
+ return valueInt;
+ }
+}
\ No newline at end of file
diff --git b/src/main/java/com/olm/util/DateTime2Millis.java a/src/main/java/com/olm/util/DateTime2Millis.java
new file mode 100644
index 0000000..1ecbd3f
--- /dev/null
+++ a/src/main/java/com/olm/util/DateTime2Millis.java
@@ -0,0 +1,140 @@
+package com.olm.util;
+
+import cn.hutool.core.date.DateUtil;
+
+import java.text.SimpleDateFormat;
+import java.time.*;
+import java.time.format.DateTimeFormatter;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * ClassName:DateTime2Millis Package:com.olm.util Date:2020/8/6 Auth:penghui@olm.com.cn
+ */
+public class DateTime2Millis {
+ private static final String FORMAT_STR = "yyyy-MM-dd HH:mm:ss";
+
+ public static void main(String[] args) {
+ System.out.println("====== JDK7及之前 ======");
+ Long l1 = getMillis1();
+ Long l2 = date2Millis(new Date());
+ Long l3 = calendar2Millis(Calendar.getInstance());
+ Long l4 = string2Millis(new SimpleDateFormat(FORMAT_STR).format(new Date()), FORMAT_STR);//为了与以上几个保持一致
+ System.out.println(l1 + "\n" + l2 + "\n" + l3 + "\n" + l4);//会有几毫秒的差别
+
+ System.out.println("====== JDK8 ======");
+ Long l5 = getMillis2();
+ Long l6 = localDateTime2Millis(LocalDateTime.now());
+ Long l7 = localDate2Millis(LocalDate.now());
+ Long l8 = clock2Millis(Clock.systemUTC());
+ Long l9 = zoneDateTime2Millis(ZonedDateTime.now());
+ Long l10 = string2MillisWithJDK8(LocalDateTime.now().format(DateTimeFormatter.ofPattern(FORMAT_STR)), FORMAT_STR);//为了与以上几个保持一致
+ System.out.println(l5 + "\n" + l6 + "\n" + l7 + "\n" + l8 + "\n" + l9 + "\n" + l10);//会有几毫秒的差别
+ //上上个月26号到上个月25号
+ //首先判断是否是1号
+
+ //2转long型号
+ long customItem52__c = Long.valueOf("2").longValue();
+ System.out.println(customItem52__c);
+ Calendar d = Calendar.getInstance();
+ Date lld = new LasMonth.LastLastMonthDate().convert(d);
+ System.out.println(lld);
+
+ Date startDate = DateUtil.parseDate("2022-09-09");
+ System.out.println(startDate);
+ }
+
+ /**
+ * 获取时间戳
+ */
+ public static Long getMillis1() {
+ return System.currentTimeMillis();
+ }
+
+ /* JDK7及之前 */
+
+ /**
+ * Date转时间戳
+ */
+ public static Long date2Millis(Date date) {
+ return date.getTime();
+ }
+
+ /**
+ * Calendar转时间戳
+ */
+ public static Long calendar2Millis(Calendar calendar) {
+ return calendar.getTime().getTime();
+ }
+
+ /**
+ * 日期字符串转时间戳
+ */
+ public static Long string2Millis(String dateStr, String formatStr) {
+ try {
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat(formatStr);
+ return simpleDateFormat.parse(dateStr).getTime();
+ } catch (Exception e) {
+ return 0L;
+ }
+ }
+
+ /**
+ * 获取时间戳
+ */
+ public static Long getMillis2() {
+ return Instant.now().toEpochMilli();
+ }
+
+ /* JDK8 */
+
+ /**
+ * LocalDateTime转时间戳
+ */
+ public static Long localDateTime2Millis(LocalDateTime localDateTime) {
+ return localDateTime.toInstant(ZoneOffset.ofHours(8)).toEpochMilli();
+ }
+
+ /**
+ * LocalDate转时间戳
+ */
+ public static Long localDate2Millis(LocalDate localDate) {
+ return LocalDateTime.of(localDate, LocalTime.MIN).toInstant(ZoneOffset.ofHours(8)).toEpochMilli();
+ }
+
+ /**
+ * Clock转时间戳
+ */
+ public static Long clock2Millis(Clock clock) {
+ return clock.millis();
+ }
+
+ /**
+ * ZoneDateTIme转时间戳(这个不常用吧~)
+ */
+ public static Long zoneDateTime2Millis(ZonedDateTime zonedDateTime) {
+ return zonedDateTime.toLocalDateTime().toInstant(ZoneOffset.ofHours(8)).toEpochMilli();//!!!好费劲
+ }
+
+ /**
+ * String转时间戳(JDK8)
+ */
+ public static Long string2MillisWithJDK8(String dateStr, String formatStr) {
+ return LocalDateTime.parse(dateStr, DateTimeFormatter.ofPattern(formatStr)).toInstant(ZoneOffset.ofHours(8)).toEpochMilli();
+ }
+
+ /**
+ * 获取前月的第一天
+ */
+ public String getFisrtDayOfMonth() {
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+ Calendar cale = Calendar.getInstance();
+ cale = Calendar.getInstance();
+ cale.add(Calendar.MONTH, 0);
+ cale.set(Calendar.DAY_OF_MONTH, 1);
+ String firstday = format.format(cale.getTime());
+ System.out.println("当月第一天:" + firstday);
+ return firstday;
+ }
+
+}
diff --git b/src/main/java/com/olm/util/FileUtilText.java a/src/main/java/com/olm/util/FileUtilText.java
new file mode 100644
index 0000000..6223d0f
--- /dev/null
+++ a/src/main/java/com/olm/util/FileUtilText.java
@@ -0,0 +1,64 @@
+package com.olm.util;
+
+
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.util.StrUtil;
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.*;
+import java.nio.charset.StandardCharsets;
+import java.sql.Struct;
+import java.util.Date;
+
+/**
+ * ClassName:FileUtilText Package:com.olm.util Date:2020/8/10 Auth:penghui@olm.com.cn
+ */
+@Slf4j
+public class FileUtilText {
+ public static boolean writeTxtFile(String content){
+ String logFile = Configure.getValue("logoutpath");
+ if (StrUtil.contains(logFile, "2022")){
+ logFile = logFile.replace("2022", DateUtil.format(DateUtil.date(), "YYYY"));
+ }
+ File outFile = new File(logFile);
+ String logPath= outFile.getParent();
+ File filePath = new File(logPath);
+ if(!filePath.exists() && !filePath.isDirectory()){
+ boolean mkOk= filePath.mkdirs();
+ if (mkOk){
+ log.info("导出文件夹不存在,自动创建成功!");
+ }
+ }
+ if (!outFile.exists()){
+ try {
+ boolean createOk= outFile.createNewFile();
+ if (createOk){
+ log.info("导出记录不存在,自动创建成功!");
+ }
+ }catch (IOException e){
+ log.error("日期文件创建失败", e);
+ }
+ }
+
+ FileOutputStream fOut;
+ fOut = null;
+ boolean result = false;
+ try {
+ fOut = new FileOutputStream(outFile, true);
+ fOut.write((DateUtil.now() +"\t"+ content + " \r\n").getBytes(StandardCharsets.UTF_8));
+ result = true;
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ if (fOut != null) {
+ try {
+ fOut.close();
+ } catch (IOException e) {
+ log.error("写入文件出错",e);
+ }
+ }
+ }
+ return result;
+ }
+}
diff --git b/src/main/java/com/olm/util/HttpClientUtil.java a/src/main/java/com/olm/util/HttpClientUtil.java
new file mode 100644
index 0000000..c2666f5
--- /dev/null
+++ a/src/main/java/com/olm/util/HttpClientUtil.java
@@ -0,0 +1,128 @@
+package com.olm.util;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * ClassName:HttpClientUtil Package:com.olm.util Date:2020/7/27 Auth:penghui@olm.com.cn
+ */
+
+/**
+ * HttpClient工具类
+ */
+public class HttpClientUtil {
+
+ /**请求编码*/
+ private static final String DEFAULT_CHARSET = "UTF-8";
+
+ /**
+ * 执行HTTP POST请求
+ * @param url url
+ * @param param 参数
+ * @return
+ */
+ public static String httpPostWithJSON(String url, Map param) {
+ CloseableHttpClient client = null;
+ try {
+ if (url == null || url.trim().length() == 0) {
+ throw new Exception("URL is null");
+ }
+ HttpPost httpPost = new HttpPost(url);
+ client = HttpClients.createDefault();
+ if (param != null) {
+ StringEntity entity = new StringEntity(JSONUtils.toJSONString(param), DEFAULT_CHARSET);//解决中文乱码问题
+ entity.setContentEncoding(DEFAULT_CHARSET);
+ entity.setContentType("application/x-www-form-urlencoded;charset=utf-8");
+ httpPost.setEntity(entity);
+ }
+ HttpResponse resp = client.execute(httpPost);
+ if (resp.getStatusLine().getStatusCode() == 200) {
+ return EntityUtils.toString(resp.getEntity(), DEFAULT_CHARSET);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ close(client);
+ }
+ return null;
+ }
+
+ /**
+ * 执行HTTP GET请求
+ * @param url url
+ * @param param 参数
+ * @return
+ */
+ public static String httpGetWithJSON(String url, Map param) {
+ CloseableHttpClient client = null;
+ try {
+ if (url == null || url.trim().length() == 0) {
+ throw new Exception("URL is null");
+ }
+ client = HttpClients.createDefault();
+ if (param != null) {
+ StringBuffer sb = new StringBuffer("?");
+ for (String key : param.keySet()) {
+ sb.append(key).append("=").append(param.get(key)).append("&");
+ }
+ url = url.concat(sb.toString());
+ url = url.substring(0, url.length() - 1);
+ }
+ HttpGet httpGet = new HttpGet(url);
+ httpGet.addHeader("Accept", "text/html");
+ httpGet.addHeader("Accept-Charset", "utf-8");
+ httpGet.addHeader("Accept-Encoding", "gzip");
+ httpGet.addHeader("Accept-Language", "en-US,en");
+ //httpGet.addHeader("Authorization","Bearer ca4b6e4550d791b636e9a1d06869985fc0c2e1314ba85392a76bc94fc58b3ca9.MzYxNzk1");
+ httpGet.addHeader("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.160 Safari/537.22");
+
+ HttpResponse resp = client.execute(httpGet);
+ if (resp.getStatusLine().getStatusCode() == 200) {
+ return EntityUtils.toString(resp.getEntity(), DEFAULT_CHARSET);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ close(client);
+ }
+ return null;
+ }
+
+ /**
+ * 关闭HTTP请求
+ * @param client
+ */
+ private static void close(CloseableHttpClient client) {
+ if (client == null) {
+ return;
+ }
+ try {
+ client.close();
+ } catch (Exception e) {
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ Map param = new HashMap();
+ param.put("grant_type", "password");
+ param.put("Client_Id", "c97fbd8aca50ba94068da6ded23905df");
+ param.put("Client_Secret", "7a4d178ebf1d55229fd28c5cb18703da");
+ param.put("Redirect_Uri", "https://api.xiaoshouyi.com");
+ param.put("userName", "lyp@olm.com.cn");
+ param.put("password", "lyp123456" + "K5vsHr3N");
+
+ String result = httpPostWithJSON("https://api.xiaoshouyi.com/oauth2/token", param);
+ System.out.println("result:" + result);
+ }
+
+
+}
\ No newline at end of file
diff --git b/src/main/java/com/olm/util/JSONUtils.java a/src/main/java/com/olm/util/JSONUtils.java
new file mode 100644
index 0000000..d53d315
--- /dev/null
+++ a/src/main/java/com/olm/util/JSONUtils.java
@@ -0,0 +1,310 @@
+package com.olm.util;
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+import org.apache.commons.beanutils.BeanUtils;
+
+import java.util.*;
+
+/**
+ * ClassName:JSONUtils Package:com.olm.util Date:2020/7/27 Auth:penghui@olm.com.cn
+ */
+public class JSONUtils {
+ /***
+ * 将List对象序列化为JSON文本
+ */
+ public static String toJSONString(List list) {
+ JSONArray jsonArray = JSONArray.fromObject(list);
+ return jsonArray.toString();
+ }
+
+ /***
+ * 将对象序列化为JSON文本
+ * @param object
+ * @return
+ */
+ public static String toJSONString(Object object) {
+ JSONArray jsonArray = JSONArray.fromObject(object);
+ return jsonArray.toString();
+ }
+
+ /***
+ * 将JSON对象数组序列化为JSON文本
+ * @param jsonArray
+ * @return
+ */
+ public static String toJSONString(JSONArray jsonArray) {
+ return jsonArray.toString();
+ }
+
+ /***
+ * 将JSON对象序列化为JSON文本
+ * @param jsonObject
+ * @return
+ */
+ public static String toJSONString(JSONObject jsonObject) {
+ return jsonObject.toString();
+ }
+
+ /***
+ * 将对象转换为List对象
+ * @param object
+ * @return
+ */
+ public static List toArrayList(Object object) {
+ List arrayList = new ArrayList();
+ JSONArray jsonArray = JSONArray.fromObject(object);
+ Iterator it = jsonArray.iterator();
+ while (it.hasNext()) {
+ JSONObject jsonObject = (JSONObject) it.next();
+
+ Iterator keys = jsonObject.keys();
+ while (keys.hasNext()) {
+ Object key = keys.next();
+ Object value = jsonObject.get(key);
+ arrayList.add(value);
+ }
+ }
+ return arrayList;
+ }
+
+ /***
+ * 将对象转换为Collection对象
+ * @param object
+ * @return
+ */
+ public static Collection toCollection(Object object) {
+ JSONArray jsonArray = JSONArray.fromObject(object);
+ return JSONArray.toCollection(jsonArray);
+ }
+
+ /***
+ * 将对象转换为JSON对象数组
+ * @param object
+ * @return
+ */
+ public static JSONArray toJSONArray(Object object) {
+ return JSONArray.fromObject(object);
+ }
+
+ /***
+ * 将对象转换为JSON对象
+ * @param object
+ * @return
+ */
+ public static JSONObject toJSONObject(Object object) {
+ return JSONObject.fromObject(object);
+ }
+
+ /***
+ * 将对象转换为HashMap
+ * @param object
+ * @return
+ */
+ public static HashMap toHashMap(Object object) {
+ HashMap data = new HashMap();
+ JSONObject jsonObject = JSONUtils.toJSONObject(object);
+ Iterator it = jsonObject.keys();
+ while (it.hasNext()) {
+ String key = String.valueOf(it.next());
+ Object value = jsonObject.get(key);
+ data.put(key, value);
+ }
+
+ return data;
+ }
+
+ /***
+ * 将对象转换为List