|
@@ -4,6 +4,7 @@ package kd.imc.rim.utils;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import javassist.Loader;
|
|
|
import kd.bos.script.annotations.KSObject;
|
|
|
import org.apache.http.HttpEntity;
|
|
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
@@ -18,6 +19,8 @@ import java.io.OutputStream;
|
|
|
import java.net.HttpURLConnection;
|
|
|
import java.net.URL;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.Base64;
|
|
|
import java.util.Date;
|
|
|
import java.util.Iterator;
|
|
@@ -33,35 +36,33 @@ public class ApiHttpUtils {
|
|
|
|
|
|
HttpPost httpPost = new HttpPost(url);
|
|
|
httpPost.setHeader("Content-type", "application/json;charset=utf-8");
|
|
|
- httpPost.setHeader("mesgtype", "bills_crop_base64");
|
|
|
- httpPost.setHeader("channelcode", "JSX");
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
+ JSONObject head = new JSONObject();
|
|
|
+ head.put("mesgtype","bills_crop_base64");
|
|
|
+ head.put("channelcode","JSX");
|
|
|
Date date = new Date();
|
|
|
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
|
|
|
String formatDate = dateFormat.format(date);
|
|
|
- httpPost.setHeader("channeldate", formatDate);
|
|
|
- long time = new Date().getTime();
|
|
|
- String channeltime = Long.toString(time);
|
|
|
- httpPost.setHeader("channeltime",channeltime);
|
|
|
- long l = System.currentTimeMillis();
|
|
|
- String channelserno = Long.toString(l);
|
|
|
- httpPost.setHeader("channelserno", channelserno);
|
|
|
- httpPost.setHeader("brno", "");
|
|
|
- httpPost.setHeader("tellerno", "*DMY");
|
|
|
- httpPost.setHeader("terminalno", "");
|
|
|
- httpPost.setHeader("APP_", "");
|
|
|
- httpPost.setHeader("reserve", "");
|
|
|
- httpPost.setHeader("dealcode", "");
|
|
|
- httpPost.setHeader("dealmsg", "");
|
|
|
- httpPost.setHeader("App_key", "XYK_DPJ_KEY");
|
|
|
- httpPost.setHeader("App_secret", "XYK_DPJ_SECRET");
|
|
|
- JSONObject object = new JSONObject();
|
|
|
- object.put("file_base64",Params);
|
|
|
+ head.put("channeldate",formatDate);
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ DateTimeFormatter hHmmss = DateTimeFormatter.ofPattern("HHmmss");
|
|
|
+ DateTimeFormatter yyyyMMddHHmmssSSSS = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSSS");
|
|
|
+ String channeltime = now.format(hHmmss);
|
|
|
+ String hHmmssSSS1 = now.format(yyyyMMddHHmmssSSSS);
|
|
|
+ head.put("channeltime",channeltime);
|
|
|
+ head.put("channelserno",hHmmssSSS1);
|
|
|
+ head.put("bron","");
|
|
|
+ head.put("tellerno","");
|
|
|
+ head.put("reserve","");
|
|
|
+ head.put("dealcode","");
|
|
|
+ head.put("dealmsg","");
|
|
|
+ head.put("App_key","XYK_DEJ_Key");
|
|
|
+ head.put("APP_secret","XYK_DEJ_SECRET");
|
|
|
+ JSONObject body = new JSONObject();
|
|
|
+ body.put("file_base64",Params);
|
|
|
+ object.put("head",head);
|
|
|
+ object.put("body",body);
|
|
|
StringEntity entity = new StringEntity(object.toString(), ContentType.APPLICATION_JSON);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
httpPost.setEntity(entity);
|
|
|
|
|
|
CloseableHttpResponse response = httpClient.execute(httpPost);
|
|
@@ -109,23 +110,43 @@ public class ApiHttpUtils {
|
|
|
catch (Exception e) { e.printStackTrace(); }
|
|
|
return null;
|
|
|
}
|
|
|
- public static String toJsonString(String Params) throws Exception {
|
|
|
+ public static String toFiledata(String Params) throws Exception {
|
|
|
if("".equals(Params)){return null;};
|
|
|
JSONArray objects = JSONArray.parseArray(Params);
|
|
|
- Object object = objects.get(0);
|
|
|
- JSONObject respenjson = (JSONObject) JSONObject.toJSON(object);
|
|
|
- JSONArray itemList = respenjson.getJSONArray("item_list");
|
|
|
- JSONObject item_list = new JSONObject();
|
|
|
- for (int i=0;i<itemList.size();i++){
|
|
|
- Object obj = itemList.get(i);
|
|
|
- net.sf.json.JSONObject respenjsons = (net.sf.json.JSONObject) JSONObject.toJSON(obj);
|
|
|
- Iterator it = respenjsons.keys();
|
|
|
- while(it.hasNext()){
|
|
|
- String key = (String) it.next();
|
|
|
- String value = respenjsons.getString(key);
|
|
|
+ for(int a=0;a<objects.size();a++){
|
|
|
+ Object object = objects.get(a);
|
|
|
+ JSONObject respenjson = (JSONObject) JSONObject.toJSON(object);
|
|
|
+ String type_description = respenjson.getString("type_description");
|
|
|
+ if("".equals(type_description)){return null;};
|
|
|
+ JSONArray itemList = respenjson.getJSONArray("item_list");
|
|
|
+ JSONObject item_list = new JSONObject();
|
|
|
+ for (int i=0;i<itemList.size();i++){
|
|
|
+ Object obj = itemList.get(i);
|
|
|
+ JSONObject respenjsons = (JSONObject) JSONObject.toJSON(obj);
|
|
|
+ String key = respenjsons.get("key").toString();
|
|
|
+ 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;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static String zzsdzptfp(JSONObject item_list) throws Exception {
|
|
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("errcode","0000");
|
|
@@ -136,17 +157,19 @@ public class ApiHttpUtils {
|
|
|
JSONArray recoginitionData = new JSONArray();
|
|
|
JSONObject fileObj = new JSONObject();
|
|
|
fileObj.put("canBeDeduction","");
|
|
|
- fileObj.put("salerName","");
|
|
|
- fileObj.put("invoiceMoney","");
|
|
|
+ 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","");
|
|
|
+ fileObj.put("invoiceAmount",item_list.getString("vat_invoice_total"));
|
|
|
fileObj.put("localUrl","");
|
|
|
fileObj.put("deductionStatus",1);
|
|
|
- fileObj.put("salerTaxNo","");
|
|
|
+ fileObj.put("salerTaxNo",item_list.getString("vat_invoice_seller_id_seal"));
|
|
|
+
|
|
|
fileObj.put("invoiceType",1);
|
|
|
- fileObj.put("invoiceNo","");
|
|
|
+
|
|
|
+ fileObj.put("invoiceNo",item_list.getString("vat_invoice_haoma_large_size"));
|
|
|
fileObj.put("isRepeat",false);
|
|
|
fileObj.put("pixel","");
|
|
|
fileObj.put("oriImageSize","");
|
|
@@ -154,38 +177,38 @@ public class ApiHttpUtils {
|
|
|
fileObj.put("orientation","0");
|
|
|
fileObj.put("batchNo",null);
|
|
|
fileObj.put("clientId","Vfz636yVhmk9HEu1QTAp");
|
|
|
- fileObj.put("buyerTaxNo","");
|
|
|
+ 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","");
|
|
|
- fileObj.put("buyerName","");
|
|
|
- fileObj.put("invoiceCode","");
|
|
|
+ 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","");
|
|
|
- fileObj.put("taxRate","");
|
|
|
+ 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","");
|
|
|
- fileObj.put("taxAmount","");
|
|
|
+ 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","");
|
|
|
- mxFileObj.put("taxRate","");
|
|
|
+ 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","");
|
|
|
- mxFileObj.put("taxAmount","");
|
|
|
- mxFileObj.put("goodsName","");
|
|
|
+ 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);
|
|
@@ -194,4 +217,68 @@ public class ApiHttpUtils {
|
|
|
json.put("data",data);
|
|
|
return json.toJSONString();
|
|
|
}
|
|
|
+
|
|
|
+ public static String jpxcd(JSONObject item_list) throws Exception {
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String hcp(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();
|
|
|
+ JSONObject fileObj = new JSONObject();
|
|
|
+ fileObj.put("canBeDeduction","");
|
|
|
+ fileObj.put("stationGetOn",item_list.getString("departure_station"));
|
|
|
+ fileObj.put("passengerName",item_list.getString("passenger_name"));
|
|
|
+ fileObj.put("signStatus","");
|
|
|
+ fileObj.put("downloadUrl","");
|
|
|
+ fileObj.put("fileHash","");
|
|
|
+ fileObj.put("seatNumber",item_list.getString("seat_number"));
|
|
|
+ fileObj.put("localUrl","");
|
|
|
+ fileObj.put("trainNum",item_list.getString("train_number"));
|
|
|
+ fileObj.put("trainTime","");
|
|
|
+ fileObj.put("stationGetOff",item_list.getString("arrival_station"));
|
|
|
+ fileObj.put("deductionStatus",1);
|
|
|
+ fileObj.put("invoiceType","9");
|
|
|
+ fileObj.put("isRepeat",false);
|
|
|
+ fileObj.put("pixel","");
|
|
|
+ fileObj.put("oriImageSize","");
|
|
|
+ fileObj.put("pdfToImgSnapshotUrl","");
|
|
|
+ fileObj.put("orientation","0");
|
|
|
+ fileObj.put("batchNo","");
|
|
|
+ fileObj.put("warningCode","1");
|
|
|
+ fileObj.put("originalState",0);
|
|
|
+ fileObj.put("originalUrl","");
|
|
|
+ fileObj.put("invoiceDate",item_list.getString("departure_date"));
|
|
|
+ fileObj.put("serialNo","");
|
|
|
+ fileObj.put("seat",item_list.getString("class"));
|
|
|
+ fileObj.put("totalAmount",item_list.getString("price"));
|
|
|
+ fileObj.put("taxRate","");
|
|
|
+ fileObj.put("customerIdentityNum",item_list.getString("passenger_id"));
|
|
|
+ fileObj.put("oriOrientation","0");
|
|
|
+ fileObj.put("oriRegion","0");
|
|
|
+ fileObj.put("rotationAngle","");
|
|
|
+ fileObj.put("snapshotUrl","");
|
|
|
+ fileObj.put("imageSerialNo","");
|
|
|
+ fileObj.put("printingSequenceNo",item_list.getString("number"));
|
|
|
+ fileObj.put("recognitionSerialNo","");
|
|
|
+ fileObj.put("businessType",1);
|
|
|
+ fileObj.put("region","");
|
|
|
+
|
|
|
+ recoginitionData.add(fileObj);
|
|
|
+ data.put("recoginitionData",recoginitionData);
|
|
|
+ json.put("data",data);
|
|
|
+ return json.toJSONString();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String tydefp(JSONObject item_list) throws Exception {
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|