|
@@ -5,7 +5,11 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import javassist.Loader;
|
|
|
+import kd.bos.dataentity.entity.DynamicObject;
|
|
|
+import kd.bos.orm.query.QCP;
|
|
|
+import kd.bos.orm.query.QFilter;
|
|
|
import kd.bos.script.annotations.KSObject;
|
|
|
+import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
import org.apache.http.HttpEntity;
|
|
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
import org.apache.http.client.methods.HttpPost;
|
|
@@ -15,6 +19,7 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
import org.apache.http.impl.client.HttpClientBuilder;
|
|
|
import org.apache.http.util.EntityUtils;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.io.OutputStream;
|
|
|
import java.net.HttpURLConnection;
|
|
|
import java.net.URL;
|
|
@@ -29,7 +34,7 @@ import java.util.Iterator;
|
|
|
@KSObject
|
|
|
public class ApiHttpUtils {
|
|
|
|
|
|
- public static String Posthttp(String url, String Params) throws Exception {
|
|
|
+ public static String Posthttp(String url, String Params){
|
|
|
|
|
|
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
|
|
|
|
|
@@ -65,20 +70,38 @@ public class ApiHttpUtils {
|
|
|
StringEntity entity = new StringEntity(object.toString(), ContentType.APPLICATION_JSON);
|
|
|
httpPost.setEntity(entity);
|
|
|
|
|
|
- CloseableHttpResponse response = httpClient.execute(httpPost);
|
|
|
+ CloseableHttpResponse response = null;
|
|
|
+ try {
|
|
|
+ response = httpClient.execute(httpPost);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
|
|
|
HttpEntity responseEntity = response.getEntity();
|
|
|
- com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
if (responseEntity != null) {
|
|
|
- jsonObject = JSON.parseObject(EntityUtils.toString(response.getEntity()));
|
|
|
- return jsonObject.toJSONString();
|
|
|
+ try {
|
|
|
+ jsonObject = JSON.parseObject(EntityUtils.toString(response.getEntity()));
|
|
|
+ JSONArray jsonArray = jsonObject.getJSONObject("boby").getJSONArray("object_list");
|
|
|
+ return jsonArray.toJSONString();
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (httpClient != null) {
|
|
|
- httpClient.close();
|
|
|
+ try {
|
|
|
+ httpClient.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
}
|
|
|
if (response != null) {
|
|
|
- response.close();
|
|
|
+ try {
|
|
|
+ response.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
}
|
|
|
return "";
|
|
|
}
|
|
@@ -111,6 +134,14 @@ public class ApiHttpUtils {
|
|
|
return null;
|
|
|
}
|
|
|
public static String toFiledata(String Params) throws Exception {
|
|
|
+
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("errcode","0000");
|
|
|
+ json.put("traceId","");
|
|
|
+ json.put("description","操作成功");
|
|
|
+ JSONObject data = new JSONObject();
|
|
|
+ json.put("batchNo","");
|
|
|
+ JSONArray recoginitionData = new JSONArray();
|
|
|
if("".equals(Params)){return null;};
|
|
|
JSONArray objects = JSONArray.parseArray(Params);
|
|
|
for(int a=0;a<objects.size();a++){
|
|
@@ -127,95 +158,32 @@ public class ApiHttpUtils {
|
|
|
String value = respenjsons.get("value").toString();
|
|
|
item_list.put(key,value);
|
|
|
}
|
|
|
- if("增值税电子普通发票".equals(type_description)){
|
|
|
- String zzsdzptfp = zzsdzptfp(item_list);
|
|
|
- return zzsdzptfp;
|
|
|
- }else if("行程单".equals(type_description)){
|
|
|
- String jpxcd = jpxcd(item_list);
|
|
|
- return jpxcd;
|
|
|
- } else if ("火车票".equals(type_description)) {
|
|
|
- String hcp = hcp(item_list);
|
|
|
- return hcp;
|
|
|
- } else if ("通用定额发票".equals(type_description)) {
|
|
|
- String tydefp = tydefp(item_list);
|
|
|
- return tydefp;
|
|
|
- }
|
|
|
+ QFilter nckd_File = new QFilter("nckd_filetype", QCP.equals, type_description);
|
|
|
+ DynamicObject nckd_FileData = BusinessDataServiceHelper.loadSingle("nckd_filedataconvert", "id,nckd_filetype", new QFilter[]{nckd_File});
|
|
|
+ JSONObject Filedata = FileData(nckd_FileData,item_list);
|
|
|
+ recoginitionData.add(Filedata);
|
|
|
}
|
|
|
-
|
|
|
- return null;
|
|
|
+ data.put("recoginitionData",recoginitionData);
|
|
|
+ json.put("data",data);
|
|
|
+ return json.toString();
|
|
|
}
|
|
|
|
|
|
|
|
|
- public static String zzsdzptfp(JSONObject item_list) throws Exception {
|
|
|
-
|
|
|
- JSONObject json = new JSONObject();
|
|
|
- json.put("errcode","0000");
|
|
|
- json.put("traceId","");
|
|
|
- json.put("description","操作成功");
|
|
|
- JSONObject data = new JSONObject();
|
|
|
- json.put("batchNo","");
|
|
|
- JSONArray recoginitionData = new JSONArray();
|
|
|
+ public static JSONObject FileData(DynamicObject nckd_FileData,JSONObject item_list) throws Exception {
|
|
|
JSONObject fileObj = new JSONObject();
|
|
|
- fileObj.put("canBeDeduction","");
|
|
|
- fileObj.put("salerName",item_list.getString("vat_invoice_seller_name"));
|
|
|
- fileObj.put("invoiceMoney",item_list.getString("vat_invoice_price_list"));
|
|
|
- fileObj.put("signStatus","");
|
|
|
- fileObj.put("downloadUrl","");
|
|
|
- fileObj.put("fileHash","");
|
|
|
- fileObj.put("invoiceAmount",item_list.getString("vat_invoice_total"));
|
|
|
- fileObj.put("localUrl","");
|
|
|
- fileObj.put("deductionStatus",1);
|
|
|
- fileObj.put("salerTaxNo",item_list.getString("vat_invoice_seller_id_seal"));
|
|
|
-
|
|
|
- fileObj.put("invoiceType",1);
|
|
|
-
|
|
|
- fileObj.put("invoiceNo",item_list.getString("vat_invoice_haoma_large_size"));
|
|
|
- fileObj.put("isRepeat",false);
|
|
|
- fileObj.put("pixel","");
|
|
|
- fileObj.put("oriImageSize","");
|
|
|
- fileObj.put("pdfToImgSnapshotUrl","");
|
|
|
- fileObj.put("orientation","0");
|
|
|
- fileObj.put("batchNo",null);
|
|
|
- fileObj.put("clientId","Vfz636yVhmk9HEu1QTAp");
|
|
|
- fileObj.put("buyerTaxNo",item_list.getString("vat_invoice_rate_payer_id"));
|
|
|
- fileObj.put("warningCode","");
|
|
|
- fileObj.put("originalState",0);
|
|
|
- fileObj.put("companySeal","1");
|
|
|
- fileObj.put("originalUrl","");
|
|
|
- fileObj.put("invoiceDate",item_list.getString("vat_invoice_issue_date"));
|
|
|
- fileObj.put("buyerName",item_list.getString("vat_invoice_payer_name"));
|
|
|
- fileObj.put("invoiceCode",item_list.getString("vat_invoice_daima"));
|
|
|
- fileObj.put("serialNo","");
|
|
|
- fileObj.put("totalAmount",item_list.getString("vat_invoice_total_cover_tax_digits"));
|
|
|
- fileObj.put("taxRate",item_list.getString("vat_invoice_tax_rate"));
|
|
|
- fileObj.put("oriOrientation","0");
|
|
|
- fileObj.put("oriRegion","");
|
|
|
- fileObj.put("rotationAngle","0");
|
|
|
- fileObj.put("snapshotUrl","");
|
|
|
- fileObj.put("imageSerialNo","");
|
|
|
- fileObj.put("recognitionSerialNo","");
|
|
|
- fileObj.put("totalTaxAmount",item_list.getString("vat_invoice_tax_total"));
|
|
|
- fileObj.put("taxAmount",item_list.getString("vat_invoice_tax_list"));
|
|
|
- fileObj.put("region","");
|
|
|
- fileObj.put("isExpend","");
|
|
|
- fileObj.put("expendStatus",null);
|
|
|
- fileObj.put("fileType",1);
|
|
|
- JSONArray items = new JSONArray();
|
|
|
- JSONObject mxFileObj = new JSONObject();
|
|
|
- mxFileObj.put("unitPrice",item_list.getString("vat_invoice_total"));
|
|
|
- mxFileObj.put("taxRate",item_list.getString("vat_invoice_tax_rate_list"));
|
|
|
- mxFileObj.put("unit","");
|
|
|
- mxFileObj.put("num","1");
|
|
|
- mxFileObj.put("detailAmount",item_list.getString("vat_invoice_price_list"));
|
|
|
- mxFileObj.put("taxAmount",item_list.getString("vat_invoice_tax_list"));
|
|
|
- mxFileObj.put("goodsName",item_list.getString("vat_invoice_goods_list"));
|
|
|
-
|
|
|
- items.add(mxFileObj);
|
|
|
- fileObj.put("items",items);
|
|
|
- recoginitionData.add(fileObj);
|
|
|
- data.put("recoginitionData",recoginitionData);
|
|
|
- json.put("data",data);
|
|
|
- return json.toJSONString();
|
|
|
+ for (DynamicObject entryentity : nckd_FileData.getDynamicObjectCollection("nckd_treeentryentity")) {
|
|
|
+ String nckd_keingde = entryentity.getString("nckd_keingde");
|
|
|
+ String nckd_ocr = entryentity.getString("nckd_ocr");
|
|
|
+ String nckd_acquiesce = entryentity.getString("nckd_acquiesce");
|
|
|
+ if(!"".equals(nckd_ocr) && nckd_ocr!=null){
|
|
|
+ fileObj.put(nckd_keingde,item_list.getString(nckd_ocr));
|
|
|
+ }else if(!"".equals(nckd_acquiesce) && nckd_ocr!=null){
|
|
|
+ fileObj.put(nckd_keingde,nckd_acquiesce);
|
|
|
+ }else {
|
|
|
+ fileObj.put(nckd_keingde,"");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return fileObj;
|
|
|
}
|
|
|
|
|
|
public static String jpxcd(JSONObject item_list) throws Exception {
|