增值税
This commit is contained in:
+5
-1
@@ -21,6 +21,10 @@
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: com.baidu.aip:java-sdk:4.12.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.json:json:20160810" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.26" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-simple:1.7.26" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.1.4.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.1.4.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.1.4.RELEASE" level="project" />
|
||||
@@ -103,11 +107,11 @@
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: mysql:mysql-connector-java:5.1.46" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.sf.ehcache:ehcache:2.10.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.26" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jsoup:jsoup:1.11.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.56" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.11" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.11" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.coobird:thumbnailator:0.4.8" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -14,4 +14,12 @@
|
||||
<version>2.0.1</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.baidu.aip</groupId>
|
||||
<artifactId>java-sdk</artifactId>
|
||||
<version>4.12.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.cwhelp.common.api.baidu;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baidu.aip.ocr.AipOcr;
|
||||
import com.cwhelp.common.api.baidu.entity.vatinvoice.VatInvoiceResult;
|
||||
import com.cwhelp.common.api.baidu.entity.vatinvoice.WordsResult;
|
||||
import org.json.JSONObject;
|
||||
import sun.misc.BASE64Encoder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* @author: yan.y
|
||||
* @Description:
|
||||
* @Date: Created in 21:16 2019/10/5
|
||||
*/
|
||||
public class BaiduAipOCR {
|
||||
|
||||
private static final String APP_ID = "16956531";
|
||||
private static final String API_KEY = "hLXMPm45eMxUDl3BVELvZAjV";
|
||||
private static final String SECRET_KEY = "UeNdsyE23QFHLUx1Ge9D3kfrNwH6Eixl";
|
||||
|
||||
private static AipOcr client = null;
|
||||
|
||||
static {
|
||||
initAipOcr();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*/
|
||||
private static void initAipOcr(){
|
||||
if (null == client) {
|
||||
client = new AipOcr(APP_ID, API_KEY, SECRET_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 百度OCR接口 增值税发票
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
public static VatInvoiceResult queryBaiduVatInvoiceApi(File file){
|
||||
byte[] data = null;
|
||||
// 读取图片字节数组
|
||||
try {
|
||||
InputStream in = new FileInputStream(file);
|
||||
data = new byte[in.available()];
|
||||
in.read(data);
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
JSONObject result = client.vatInvoice(data, null);
|
||||
VatInvoiceResult vatInvoiceResult = JSON.parseObject(result.toString(), VatInvoiceResult.class);
|
||||
return vatInvoiceResult;
|
||||
}
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.cwhelp.common.api.baidu.entity.vatinvoice;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author: yan.y
|
||||
* @Description:
|
||||
* @Date: Created in 23:32 2019/10/5
|
||||
*/
|
||||
@Data
|
||||
public class CommodityAmount implements Serializable {
|
||||
private String row;
|
||||
|
||||
private String word;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.cwhelp.common.api.baidu.entity.vatinvoice;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author: yan.y
|
||||
* @Description:
|
||||
* @Date: Created in 23:32 2019/10/5
|
||||
*/
|
||||
@Data
|
||||
public class CommodityName implements Serializable {
|
||||
private String row;
|
||||
|
||||
private String word;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.cwhelp.common.api.baidu.entity.vatinvoice;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author: yan.y
|
||||
* @Description:
|
||||
* @Date: Created in 23:32 2019/10/5
|
||||
*/
|
||||
@Data
|
||||
public class CommodityNum implements Serializable {
|
||||
private String row;
|
||||
|
||||
private String word;
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.cwhelp.common.api.baidu.entity.vatinvoice;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author: yan.y
|
||||
* @Description:
|
||||
* @Date: Created in 23:32 2019/10/5
|
||||
*/
|
||||
@Data
|
||||
public class CommodityPrice implements Serializable {
|
||||
|
||||
private String row;
|
||||
|
||||
private String word;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.cwhelp.common.api.baidu.entity.vatinvoice;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author: yan.y
|
||||
* @Description:
|
||||
* @Date: Created in 23:32 2019/10/5
|
||||
*/
|
||||
@Data
|
||||
public class CommodityTax implements Serializable {
|
||||
private String row;
|
||||
|
||||
private String word;
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.cwhelp.common.api.baidu.entity.vatinvoice;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author: yan.y
|
||||
* @Description:
|
||||
* @Date: Created in 23:32 2019/10/5
|
||||
*/
|
||||
@Data
|
||||
public class CommodityTaxRate implements Serializable {
|
||||
private String row;
|
||||
|
||||
private String word;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.cwhelp.common.api.baidu.entity.vatinvoice;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author: yan.y
|
||||
* @Description:
|
||||
* @Date: Created in 23:32 2019/10/5
|
||||
*/
|
||||
@Data
|
||||
public class CommodityType implements Serializable {
|
||||
private String row;
|
||||
|
||||
private String word;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.cwhelp.common.api.baidu.entity.vatinvoice;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author: yan.y
|
||||
* @Description:
|
||||
* @Date: Created in 23:32 2019/10/5
|
||||
*/
|
||||
@Data
|
||||
public class CommodityUnit implements Serializable {
|
||||
private String row;
|
||||
|
||||
private String word;
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.cwhelp.common.api.baidu.entity.vatinvoice;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author: yan.y
|
||||
* @Description:
|
||||
* @Date: Created in 23:49 2019/10/5
|
||||
*/
|
||||
@Data
|
||||
public class VatInvoiceResult {
|
||||
|
||||
private String log_id;
|
||||
|
||||
private WordsResult words_result;
|
||||
|
||||
private String words_result_num;
|
||||
|
||||
private String direction;
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.cwhelp.common.api.baidu.entity.vatinvoice;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: yan.y
|
||||
* @Description:
|
||||
* @Date: Created in 23:24 2019/10/5
|
||||
*/
|
||||
@Data
|
||||
public class WordsResult implements Serializable {
|
||||
|
||||
//销售方
|
||||
private String SellerAddress;
|
||||
|
||||
private String SellerRegisterNum;
|
||||
|
||||
private String SellerName;
|
||||
|
||||
private String SellerBank;
|
||||
|
||||
// 发票信息
|
||||
private String Remarks;
|
||||
|
||||
private String CheckCode;
|
||||
|
||||
private String InvoiceNum;
|
||||
|
||||
private String InvoiceCode;
|
||||
|
||||
private String InvoiceDate;
|
||||
|
||||
private String InvoiceType;
|
||||
|
||||
private String AmountInFiguers;
|
||||
|
||||
private String AmountInWords;
|
||||
|
||||
//购买方
|
||||
private String PurchaserRegisterNum;
|
||||
|
||||
private String PurchaserName;
|
||||
|
||||
private String PurchaserAddress;
|
||||
|
||||
private String PurchaserBank;
|
||||
|
||||
//商品
|
||||
private List<CommodityName> CommodityName;
|
||||
|
||||
private List<CommodityType> CommodityType;
|
||||
|
||||
private List<CommodityUnit> CommodityUnit;
|
||||
|
||||
private List<CommodityNum> CommodityNum;
|
||||
|
||||
private List<CommodityPrice> CommodityPrice;
|
||||
|
||||
private List<CommodityAmount> CommodityAmount;
|
||||
|
||||
private List<CommodityTaxRate> CommodityTaxRate;
|
||||
|
||||
private List<CommodityTax> CommodityTax;
|
||||
|
||||
private String TotalAmount;
|
||||
|
||||
private String TotalTax;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WordsResult{" +
|
||||
"SellerAddress='" + SellerAddress + '\'' +
|
||||
", SellerRegisterNum='" + SellerRegisterNum + '\'' +
|
||||
", SellerName='" + SellerName + '\'' +
|
||||
", SellerBank='" + SellerBank + '\'' +
|
||||
", Remarks='" + Remarks + '\'' +
|
||||
", CheckCode='" + CheckCode + '\'' +
|
||||
", InvoiceNum='" + InvoiceNum + '\'' +
|
||||
", InvoiceCode='" + InvoiceCode + '\'' +
|
||||
", InvoiceDate='" + InvoiceDate + '\'' +
|
||||
", AmountInFiguers='" + AmountInFiguers + '\'' +
|
||||
", AmountInWords='" + AmountInWords + '\'' +
|
||||
", PurchaserRegisterNum='" + PurchaserRegisterNum + '\'' +
|
||||
", PurchaserName='" + PurchaserName + '\'' +
|
||||
", PurchaserAddress='" + PurchaserAddress + '\'' +
|
||||
", PurchaserBank='" + PurchaserBank + '\'' +
|
||||
", CommodityName=" + CommodityName +
|
||||
", CommodityType=" + CommodityType +
|
||||
", CommodityUnit=" + CommodityUnit +
|
||||
", CommodityNum=" + CommodityNum +
|
||||
", CommodityPrice=" + CommodityPrice +
|
||||
", CommodityAmount=" + CommodityAmount +
|
||||
", CommodityTaxRate=" + CommodityTaxRate +
|
||||
", CommodityTax=" + CommodityTax +
|
||||
", TotalAmount='" + TotalAmount + '\'' +
|
||||
", TotalTax='" + TotalTax + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.cwhelp.common.api.baidu.entity.vatinvoice.enums;
|
||||
|
||||
/**
|
||||
* @author: yan.y
|
||||
* @Description:
|
||||
* @Date: Created in 0:46 2019/10/6
|
||||
*/
|
||||
public enum VatInvoiceTypeEnum {
|
||||
|
||||
ORDINARY_VAT_INVOICE("普通发票",0),
|
||||
SPECIAL_VAT_INVOICE("专用发票",1);
|
||||
|
||||
public String invoiceType;
|
||||
|
||||
public int invoiceCode;
|
||||
|
||||
VatInvoiceTypeEnum(String invoiceType, int invoiceCode) {
|
||||
this.invoiceType = invoiceType;
|
||||
this.invoiceCode = invoiceCode;
|
||||
}
|
||||
|
||||
public static int getVatInvoiceCode(String invoiceType) {
|
||||
VatInvoiceTypeEnum[] values = VatInvoiceTypeEnum.values();
|
||||
for (VatInvoiceTypeEnum value : values) {
|
||||
if (value.invoiceType.equals(invoiceType)) {
|
||||
return value.invoiceCode;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -18,14 +18,14 @@ import java.net.URI;
|
||||
* @Modified by:
|
||||
*/
|
||||
public class HttpYoushangFapiaoUtil {
|
||||
private static final String url = "https://fapiao.youshang.com/GuoShuiAction.do";
|
||||
private static final String URL = "https://fapiao.youshang.com/GuoShuiAction.do";
|
||||
|
||||
public static final JSONObject getVatInfoiceInfo(JSONObject params){
|
||||
final String action = "findInvoiceResult";
|
||||
JSONObject result = new JSONObject();
|
||||
try {
|
||||
HttpClient httpClient = HttpClients.createDefault();
|
||||
URIBuilder uriBuilder = new URIBuilder(url);
|
||||
URIBuilder uriBuilder = new URIBuilder(URL);
|
||||
URI uri = uriBuilder.addParameter("action", action)
|
||||
.addParameter("fpdm", params.getString("fpdm"))
|
||||
.addParameter("fphm", params.getString("fphm"))
|
||||
@@ -46,5 +46,4 @@ public class HttpYoushangFapiaoUtil {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.TreeMap;
|
||||
@@ -147,4 +148,11 @@ public class ToolUtil {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static boolean checkListSize(List list) {
|
||||
if (list.size() > 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user