|
@@ -138,6 +138,7 @@ public class EntityAnalyse {
|
|
|
image.delete();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 批量上传文件
|
|
|
*
|
|
@@ -147,7 +148,7 @@ public class EntityAnalyse {
|
|
|
*/
|
|
|
public static String[] uploadImageList(List<File> list, String token, String ENV) throws IOException {
|
|
|
String[] dataResult = new String[list.size()];
|
|
|
- for(int i=0;i<list.size();i++){
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
File image = list.get(i);
|
|
|
String url = "";
|
|
|
if ("3".equals(ENV)) {
|
|
@@ -722,24 +723,28 @@ public class EntityAnalyse {
|
|
|
// 执行请求操作,并拿到结果(同步阻塞)
|
|
|
String body = EntityUtils.toString(httpClient.execute(httpPost).getEntity());
|
|
|
JSONObject jsonObject = JSONObject.parseObject(body);
|
|
|
- if ("异常".equals(jsonObject.getJSONArray("result").getJSONObject(0).getString("validateStatus"))) {
|
|
|
- JSONArray jsonArray = jsonObject.getJSONArray("result").getJSONObject(0).getJSONArray("validateResult");
|
|
|
- String result = "";
|
|
|
- for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
- if ("异常".equals(jsonArray.getJSONObject(i).getString("flag"))) {
|
|
|
- result = result + jsonArray.getJSONObject(i).getString("message");
|
|
|
+ if ("1001".equals(jsonObject.getString("status"))) {
|
|
|
+ if ("异常".equals(jsonObject.getJSONArray("result").getJSONObject(0).getString("validateStatus"))) {
|
|
|
+ JSONArray jsonArray = jsonObject.getJSONArray("result").getJSONObject(0).getJSONArray("validateResult");
|
|
|
+ String result = "";
|
|
|
+ for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
+ if ("异常".equals(jsonArray.getJSONObject(i).getString("flag"))) {
|
|
|
+ result = result + jsonArray.getJSONObject(i).getString("message");
|
|
|
+ }
|
|
|
}
|
|
|
+ System.out.println("result = " + result);
|
|
|
+ return result;
|
|
|
+ } else if ("待校验".equals(jsonObject.getJSONArray("result").getJSONObject(0).getString("validateStatus"))) {
|
|
|
+ String result = "待校验";
|
|
|
+ System.out.println("result = " + result);
|
|
|
+ return result;
|
|
|
+ } else if ("通过".equals(jsonObject.getJSONArray("result").getJSONObject(0).getString("validateStatus"))) {
|
|
|
+ String result = (jsonObject.getJSONArray("result").getJSONObject(0).getString("validateStatus"));
|
|
|
+ System.out.println("result = " + result);
|
|
|
+ return result;
|
|
|
}
|
|
|
- System.out.println("result = " + result);
|
|
|
- return result;
|
|
|
- } else if ("待校验".equals(jsonObject.getJSONArray("result").getJSONObject(0).getString("validateStatus"))) {
|
|
|
- String result = "待校验";
|
|
|
- System.out.println("result = " + result);
|
|
|
- return result;
|
|
|
- } else if ("通过".equals(jsonObject.getJSONArray("result").getJSONObject(0).getString("validateStatus"))) {
|
|
|
- String result = (jsonObject.getJSONArray("result").getJSONObject(0).getString("validateStatus"));
|
|
|
- System.out.println("result = " + result);
|
|
|
- return result;
|
|
|
+ } else {
|
|
|
+ return "系统异常";
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
throw e;
|
|
@@ -783,24 +788,28 @@ public class EntityAnalyse {
|
|
|
// 执行请求操作,并拿到结果(同步阻塞)
|
|
|
String body = EntityUtils.toString(httpClient.execute(httpPost).getEntity());
|
|
|
JSONObject jsonObject = JSONObject.parseObject(body);
|
|
|
- if ("异常".equals(jsonObject.getJSONArray("result").getJSONObject(0).getString("validateStatus"))) {
|
|
|
- JSONArray jsonArray = jsonObject.getJSONArray("result").getJSONObject(0).getJSONArray("validateResult");
|
|
|
- String result = "";
|
|
|
- for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
- if ("异常".equals(jsonArray.getJSONObject(i).getString("flag"))) {
|
|
|
- result = result + jsonArray.getJSONObject(i).getString("message");
|
|
|
+ if ("1001".equals(jsonObject.getString("status"))) {
|
|
|
+ if ("异常".equals(jsonObject.getJSONArray("result").getJSONObject(0).getString("validateStatus"))) {
|
|
|
+ JSONArray jsonArray = jsonObject.getJSONArray("result").getJSONObject(0).getJSONArray("validateResult");
|
|
|
+ String result = "";
|
|
|
+ for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
+ if ("异常".equals(jsonArray.getJSONObject(i).getString("flag"))) {
|
|
|
+ result = result + jsonArray.getJSONObject(i).getString("message");
|
|
|
+ }
|
|
|
}
|
|
|
+ System.out.println("result = " + result);
|
|
|
+ return result;
|
|
|
+ } else if ("待校验".equals(jsonObject.getJSONArray("result").getJSONObject(0).getString("validateStatus"))) {
|
|
|
+ String result = "待校验";
|
|
|
+ System.out.println("result = " + result);
|
|
|
+ return result;
|
|
|
+ } else if ("通过".equals(jsonObject.getJSONArray("result").getJSONObject(0).getString("validateStatus"))) {
|
|
|
+ String result = (jsonObject.getJSONArray("result").getJSONObject(0).getString("validateStatus"));
|
|
|
+ System.out.println("result = " + result);
|
|
|
+ return result;
|
|
|
}
|
|
|
- System.out.println("result = " + result);
|
|
|
- return result;
|
|
|
- } else if ("待校验".equals(jsonObject.getJSONArray("result").getJSONObject(0).getString("validateStatus"))) {
|
|
|
- String result = "待校验";
|
|
|
- System.out.println("result = " + result);
|
|
|
- return result;
|
|
|
- } else if ("通过".equals(jsonObject.getJSONArray("result").getJSONObject(0).getString("validateStatus"))) {
|
|
|
- String result = (jsonObject.getJSONArray("result").getJSONObject(0).getString("validateStatus"));
|
|
|
- System.out.println("result = " + result);
|
|
|
- return result;
|
|
|
+ } else {
|
|
|
+ return "系统异常";
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
throw e;
|
|
@@ -840,24 +849,28 @@ public class EntityAnalyse {
|
|
|
// 执行请求操作,并拿到结果(同步阻塞)
|
|
|
String body = EntityUtils.toString(httpClient.execute(httpPost).getEntity());
|
|
|
JSONObject jsonObject = JSONObject.parseObject(body);
|
|
|
- if ("异常".equals(jsonObject.getJSONArray("result").getJSONObject(0).getString("validateStatus"))) {
|
|
|
- JSONArray jsonArray = jsonObject.getJSONArray("result").getJSONObject(0).getJSONArray("validateResult");
|
|
|
- String result = "";
|
|
|
- for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
- if ("异常".equals(jsonArray.getJSONObject(i).getString("flag"))) {
|
|
|
- result = result + jsonArray.getJSONObject(i).getString("message");
|
|
|
+ if ("1001".equals(jsonObject.getString("status"))) {
|
|
|
+ if ("异常".equals(jsonObject.getJSONArray("result").getJSONObject(0).getString("validateStatus"))) {
|
|
|
+ JSONArray jsonArray = jsonObject.getJSONArray("result").getJSONObject(0).getJSONArray("validateResult");
|
|
|
+ String result = "";
|
|
|
+ for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
+ if ("异常".equals(jsonArray.getJSONObject(i).getString("flag"))) {
|
|
|
+ result = result + jsonArray.getJSONObject(i).getString("message");
|
|
|
+ }
|
|
|
}
|
|
|
+ System.out.println("result = " + result);
|
|
|
+ return result;
|
|
|
+ } else if ("待校验".equals(jsonObject.getJSONArray("result").getJSONObject(0).getString("validateStatus"))) {
|
|
|
+ String result = "待校验";
|
|
|
+ System.out.println("result = " + result);
|
|
|
+ return result;
|
|
|
+ } else if ("通过".equals(jsonObject.getJSONArray("result").getJSONObject(0).getString("validateStatus"))) {
|
|
|
+ String result = (jsonObject.getJSONArray("result").getJSONObject(0).getString("validateStatus"));
|
|
|
+ System.out.println("result = " + result);
|
|
|
+ return result;
|
|
|
}
|
|
|
- System.out.println("result = " + result);
|
|
|
- return result;
|
|
|
- } else if ("待校验".equals(jsonObject.getJSONArray("result").getJSONObject(0).getString("validateStatus"))) {
|
|
|
- String result = "待校验";
|
|
|
- System.out.println("result = " + result);
|
|
|
- return result;
|
|
|
- } else if ("通过".equals(jsonObject.getJSONArray("result").getJSONObject(0).getString("validateStatus"))) {
|
|
|
- String result = (jsonObject.getJSONArray("result").getJSONObject(0).getString("validateStatus"));
|
|
|
- System.out.println("result = " + result);
|
|
|
- return result;
|
|
|
+ } else {
|
|
|
+ return "系统异常";
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
throw e;
|
|
@@ -1398,6 +1411,7 @@ public class EntityAnalyse {
|
|
|
File file = writeImageToDisk(getImageFromNetByUrl(url));
|
|
|
return file;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* url资源转化为file流
|
|
|
*
|
|
@@ -1414,27 +1428,26 @@ public class EntityAnalyse {
|
|
|
int pageCount = doc.getNumberOfPages();
|
|
|
|
|
|
//pdf转图片后分块
|
|
|
- int number = pageCount/6 + 1;
|
|
|
+ int number = pageCount / 6 + 1;
|
|
|
//保存文件标识
|
|
|
boolean flag = true;
|
|
|
//管局最多上传6张图片
|
|
|
for (int i = 0; i < 6; i++) {
|
|
|
BufferedImage image = null;
|
|
|
- for(int j=i*number;j<(i+1)*number;j++){
|
|
|
- if(j>=pageCount){
|
|
|
+ for (int j = i * number; j < (i + 1) * number; j++) {
|
|
|
+ if (j >= pageCount) {
|
|
|
flag = false;
|
|
|
break;
|
|
|
}
|
|
|
- if(j == 0){
|
|
|
+ if (j == 0) {
|
|
|
image = renderer.renderImageWithDPI(j, 72);
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else {
|
|
|
BufferedImage tmpImage = renderer.renderImageWithDPI(j, 72);
|
|
|
- image = mergeImage(image,tmpImage,true,true,true,0,null);
|
|
|
+ image = mergeImage(image, tmpImage, true, true, true, 0, null);
|
|
|
}
|
|
|
}
|
|
|
- if(flag){
|
|
|
- file = new File("templates" + File.separator + "tmpPdf"+i+".png");
|
|
|
+ if (flag) {
|
|
|
+ file = new File("templates" + File.separator + "tmpPdf" + i + ".png");
|
|
|
ImageIO.write(image, "png", file);
|
|
|
list.add(file);
|
|
|
}
|
|
@@ -1445,6 +1458,7 @@ public class EntityAnalyse {
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
+
|
|
|
public static byte[] getImageStream(File file) {
|
|
|
byte[] buffer = null;
|
|
|
FileInputStream fis;
|
|
@@ -1459,12 +1473,12 @@ public class EntityAnalyse {
|
|
|
fis.close();
|
|
|
bos.close();
|
|
|
buffer = bos.toByteArray();
|
|
|
- if(file.exists()) {
|
|
|
+ if (file.exists()) {
|
|
|
file.delete();
|
|
|
}
|
|
|
} catch (FileNotFoundException e) {
|
|
|
e.printStackTrace();
|
|
|
- }catch (IOException e) {
|
|
|
+ } catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return buffer;
|
|
@@ -1497,13 +1511,14 @@ public class EntityAnalyse {
|
|
|
|
|
|
/**
|
|
|
* 合并两个图片
|
|
|
- * @param first 图片1
|
|
|
- * @param second 图片2
|
|
|
- * @param horizontal 等于true,则两个图片水平合并显示, 否则两个图片垂直合并显示
|
|
|
- * @param center 图片是否水平居中, horizontal 等于 false 垂直合并才有效
|
|
|
+ *
|
|
|
+ * @param first 图片1
|
|
|
+ * @param second 图片2
|
|
|
+ * @param horizontal 等于true,则两个图片水平合并显示, 否则两个图片垂直合并显示
|
|
|
+ * @param center 图片是否水平居中, horizontal 等于 false 垂直合并才有效
|
|
|
* @param transparent 合并后的图片背景是否透明色
|
|
|
- * @param gap 图片之间的间距
|
|
|
- * @param color 图片的背景颜色
|
|
|
+ * @param gap 图片之间的间距
|
|
|
+ * @param color 图片的背景颜色
|
|
|
* @return 返回合并之后的图片
|
|
|
*/
|
|
|
public static BufferedImage mergeImage(BufferedImage first, BufferedImage second, boolean horizontal, boolean center, boolean transparent, int gap, Color color) throws IOException {
|
|
@@ -1571,6 +1586,7 @@ public class EntityAnalyse {
|
|
|
// 返回合并后的图片对象
|
|
|
return target;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 将获取的字节数组保存为文件写入硬盘
|
|
|
*
|
|
@@ -1594,6 +1610,7 @@ public class EntityAnalyse {
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 将获取的字节数组保存为文件写入硬盘
|
|
|
*
|