|
|
@@ -1,1300 +0,0 @@
|
|
|
-package com.uas.platform.b2b.service.impl;
|
|
|
-
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.uas.platform.b2b.dao.PurchaseApBillOutDao;
|
|
|
-import com.uas.platform.b2b.dao.PurchaseApBillOutInfoDao;
|
|
|
-import com.uas.platform.b2b.model.*;
|
|
|
-import com.uas.platform.b2b.service.SOAPConsoleService;
|
|
|
-import com.uas.platform.b2b.support.SystemSession;
|
|
|
-import com.uas.platform.core.util.HttpUtil;
|
|
|
-
|
|
|
-import com.uas.sso.common.encrypt.base64.Base64;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.ui.ModelMap;
|
|
|
-import java.io.BufferedReader;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.InputStreamReader;
|
|
|
-import java.io.UnsupportedEncodingException;
|
|
|
-import java.lang.reflect.Field;
|
|
|
-import java.net.*;
|
|
|
-import java.text.DecimalFormat;
|
|
|
-import java.util.*;
|
|
|
-
|
|
|
-
|
|
|
-/**
|
|
|
- * Created by 黄诚天 on 2017/7/10.
|
|
|
- */
|
|
|
-@Service
|
|
|
-public class SOAPConsoleServiceImpl implements SOAPConsoleService {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- PurchaseApBillOutDao purchaseApBillOutDao;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- PurchaseApBillOutInfoDao purchaseApBillOutInfoDao;
|
|
|
-
|
|
|
- DecimalFormat df = new DecimalFormat("#.00");
|
|
|
-
|
|
|
- //获取每种发票的库存信息
|
|
|
- @Override
|
|
|
- public ModelMap getRepertoryMessage() {
|
|
|
- ModelMap map = new ModelMap();
|
|
|
- Integer InfoKind = 0; //发票类型; 0-专票 2-普票
|
|
|
-
|
|
|
- int SID = SoapSIDType.GETREPERTORYMEAASGE.getValue();
|
|
|
- JSONObject SIDParam = new JSONObject();
|
|
|
- SIDParam.put("InfoKind",InfoKind);
|
|
|
- JSONObject resultJo = getSOAPJson(SID, SIDParam);
|
|
|
-
|
|
|
- if ("3011".equals(resultJo.getString("retcode"))) {
|
|
|
- SoapRepertyMessage srm = JSONObject.parseObject(resultJo.toJSONString(),SoapRepertyMessage.class);
|
|
|
- map.put("srm",srm);
|
|
|
- } else if (resultJo.getString("error") != null) {
|
|
|
- map.put("error",resultJo.getString("error"));
|
|
|
- } else {
|
|
|
- map.put("error",resultJo.getString("retmsg"));
|
|
|
- }
|
|
|
-
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- //发票开具
|
|
|
- @Override
|
|
|
- public ModelMap invoiceIssued(PurchaseApBillOut apBillOut) {
|
|
|
- ModelMap map = new ModelMap();
|
|
|
- StringBuilder errorMsg = new StringBuilder();
|
|
|
-
|
|
|
- Integer invoiceType = 0;//专票
|
|
|
- //获取购方开票信息
|
|
|
- PurchaseApBillOutInfo customerApBillOutInfo = apBillOut.getCustomerApBillOutInfo();
|
|
|
- String customerTaxNr = customerApBillOutInfo.getTaxNr();
|
|
|
- //发票种类为普票时可以为空值,专票时为必填
|
|
|
- if (invoiceType != 2 && customerTaxNr == null) {
|
|
|
- map.put("error", errorMsg.append("获取不到购方税号"));
|
|
|
- }
|
|
|
-
|
|
|
- String customerName = customerApBillOutInfo.getEnName();
|
|
|
- //普票时,若购方税号为空,则购方名称必填
|
|
|
- if (invoiceType == 2 && customerTaxNr == null && customerName == null) {
|
|
|
- map.put("error", errorMsg.append("获取不到购方名"));
|
|
|
- }
|
|
|
-
|
|
|
- String issuer = SystemSession.getUser().getUserName();
|
|
|
- if (issuer == null) {
|
|
|
- map.put("error", errorMsg.append("获取不到开票人信息"));
|
|
|
- } else if (issuer.length() > 8) {
|
|
|
- map.put("error", errorMsg.append("开票人名字不得超过八个字母或四个汉字"));
|
|
|
- }
|
|
|
-
|
|
|
- Boolean listed = false; //false:不开具清单 true:开具清单
|
|
|
- if (listed == null) {
|
|
|
- map.put("error", errorMsg.append("获取不到清单标志,系统无法判断是否开具清单"));
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- String customerAddressTel = customerApBillOutInfo.getAddress() + " " + customerApBillOutInfo.getTel();
|
|
|
-
|
|
|
- //发票种类为普票时可以为空值,专票时为必填
|
|
|
- if (invoiceType != 2 && customerAddressTel == null) {
|
|
|
- map.put("error", errorMsg.append("获取不到购方地址电话"));
|
|
|
- }
|
|
|
-
|
|
|
- String customerBankAccountNr = customerApBillOutInfo.getBankAccountNr();
|
|
|
- //发票种类为普票时可以为空值,专票时为必填
|
|
|
- if (invoiceType != 2 && customerBankAccountNr == null) {
|
|
|
- map.put("error", errorMsg.append("获取不到购方银行账户"));
|
|
|
- }
|
|
|
-
|
|
|
- //获取销方开票信息
|
|
|
- PurchaseApBillOutInfo apBillOutInfo = apBillOut.getApBillOutInfo();
|
|
|
- String sellerTaxNr = apBillOutInfo.getTaxNr();
|
|
|
- String sellerBankAccountNr = apBillOutInfo.getBankAccountNr();
|
|
|
- if (sellerBankAccountNr == null) {
|
|
|
- sellerBankAccountNr = "";
|
|
|
- }
|
|
|
-
|
|
|
- String payee = apBillOutInfo.getPayee();
|
|
|
- if (payee == null) {
|
|
|
- map.put("error", errorMsg.append("获取不到收款人信息"));
|
|
|
- } else if (payee.length() > 8) {
|
|
|
- map.put("error", errorMsg.append("收款人名字不得超过八个字母或四个汉字"));
|
|
|
- }
|
|
|
-
|
|
|
- String checker = apBillOutInfo.getChecker();
|
|
|
- if (checker == null) {
|
|
|
- map.put("error", errorMsg.append("获取不到复核人信息"));
|
|
|
- } else if (checker.length() > 8) {
|
|
|
- map.put("error", errorMsg.append("复核人名字不得超过八个字母或四个汉字"));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- String sellerAddressTel = apBillOutInfo.getAddress() + " " + apBillOutInfo.getTel();
|
|
|
- if (sellerAddressTel == null) {
|
|
|
- sellerAddressTel = "";
|
|
|
- }
|
|
|
-
|
|
|
- String documentNr = apBillOut.getCode();//TODO 数据来源 判断
|
|
|
- if (documentNr == null) {
|
|
|
- documentNr = "";
|
|
|
- }
|
|
|
-
|
|
|
- String memo = null;//TODO
|
|
|
- if (memo == null) {
|
|
|
- memo = "";
|
|
|
- }
|
|
|
-
|
|
|
- Integer CheckEWM = 0; //TODO
|
|
|
-
|
|
|
-
|
|
|
- //获取明细信息
|
|
|
- Set<PurchaseApBillOutItem> apBillOutItems = apBillOut.getItems();
|
|
|
- PurchaseApBillOutItem[] items = new PurchaseApBillOutItem[apBillOutItems.size()];
|
|
|
- apBillOutItems.toArray(items);
|
|
|
- SoapInvoiceItem[] invoiceItems = new SoapInvoiceItem[apBillOutItems.size()];
|
|
|
- for (int i = 0; i < items.length; i++) {
|
|
|
- Product product = items[i].getProduct();
|
|
|
- SoapInvoiceItem invoiceItem = new SoapInvoiceItem();
|
|
|
-
|
|
|
- String productName = product.getTitle();
|
|
|
- //productName = "测试商品";
|
|
|
- if (productName == null) {
|
|
|
- map.put("error", errorMsg.append("获取不到商品名称"));
|
|
|
- } else {
|
|
|
- invoiceItem.setProductName(productName);
|
|
|
- }
|
|
|
-
|
|
|
- Boolean includeTax = true;
|
|
|
- if (includeTax == null) {
|
|
|
- map.put("error", errorMsg.append("获取不到" + productName + "的含税标志"));
|
|
|
- } else {
|
|
|
- invoiceItem.setIncludeTax(includeTax);
|
|
|
- }
|
|
|
-
|
|
|
- Double taxRate = 0.17; //items[i].getTaxrate()/100
|
|
|
- if (taxRate == null) {
|
|
|
- map.put("error", errorMsg.append("获取不到" + productName + "的税率"));
|
|
|
- } else {
|
|
|
- invoiceItem.setTaxRate(taxRate);
|
|
|
- }
|
|
|
-
|
|
|
- Double value = items[i].getPrice() * items[i].getNowQty();
|
|
|
- if (value == null) {
|
|
|
- map.put("error", errorMsg.append("获取不到" + productName + "的金额"));
|
|
|
- } else {
|
|
|
- invoiceItem.setValue(Double.parseDouble(df.format(value)));
|
|
|
- }
|
|
|
- Double tax = (value*taxRate)/1.17;
|
|
|
- if (tax == null) {
|
|
|
- map.put("error", errorMsg.append("获取不到" + productName + "的税额"));
|
|
|
- } else {
|
|
|
- invoiceItem.setTax(Double.parseDouble(df.format(tax)));
|
|
|
- }
|
|
|
-
|
|
|
- String GoodsNoVer = product.getGoodsnover();
|
|
|
- GoodsNoVer = "13.0";
|
|
|
- if (GoodsNoVer == null) {
|
|
|
- map.put("error", errorMsg.append("获取不到" + productName + "编码版本号"));
|
|
|
- } else {
|
|
|
- invoiceItem.setGoodsNoVer(GoodsNoVer);
|
|
|
- }
|
|
|
-
|
|
|
- String GoodsTaxNo = product.getGoodstaxno();
|
|
|
- GoodsTaxNo = "109051303"; //1080413020000000000 //1090513030000000000
|
|
|
- if (GoodsTaxNo == null) {
|
|
|
- map.put("error", errorMsg.append("获取不到" + productName + "的税收分类编码"));
|
|
|
- } else {
|
|
|
- invoiceItem.setGoodsTaxNo(GoodsTaxNo);
|
|
|
- }
|
|
|
-
|
|
|
- String TaxPre = product.getTaxpre();
|
|
|
- TaxPre = "0";
|
|
|
- if (TaxPre == null) {
|
|
|
- map.put("error", errorMsg.append("获取不到" + productName + "的是否享受优惠政策"));
|
|
|
- } else {
|
|
|
- invoiceItem.setTaxPre(TaxPre);
|
|
|
- }
|
|
|
-
|
|
|
- Double price = items[i].getPrice();//不能从产品库中获取单价
|
|
|
- Double quantity = items[i].getNowQty();
|
|
|
- //数量和单价要一起传或者一起不传,不能只传其中一个
|
|
|
- if (price != null && quantity != null) {
|
|
|
- invoiceItem.setPrice(price);
|
|
|
- invoiceItem.setQuantity(quantity);
|
|
|
- } else {
|
|
|
- map.put("error", errorMsg.append("明细" + productName + "的单价或数量缺失"));
|
|
|
- }
|
|
|
-
|
|
|
- String productUnit = product.getUnit();
|
|
|
- if (productUnit == null) {
|
|
|
- productUnit = "";
|
|
|
- }
|
|
|
- invoiceItem.setProductUnit(productUnit);
|
|
|
-
|
|
|
- String productSpec = product.getSpec();
|
|
|
- if (productSpec == null) {
|
|
|
- productSpec = "";
|
|
|
- }
|
|
|
- invoiceItem.setProductSpec(productSpec);
|
|
|
-
|
|
|
- String TaxPreCon = product.getTaxprecon();
|
|
|
- if (TaxPreCon == null) {
|
|
|
- TaxPreCon = "";
|
|
|
- }
|
|
|
- invoiceItem.setTaxPreCon(TaxPreCon);
|
|
|
-
|
|
|
- String ZeroTax = null; //TODO
|
|
|
- if (ZeroTax == null) {
|
|
|
- ZeroTax = "";
|
|
|
- }
|
|
|
- invoiceItem.setZeroTax(ZeroTax);
|
|
|
-
|
|
|
- String CropGoodsNo = null; //TODO
|
|
|
- if (CropGoodsNo == null) {
|
|
|
- CropGoodsNo = "";
|
|
|
- }
|
|
|
- invoiceItem.setCropGoodsNo(CropGoodsNo);
|
|
|
-
|
|
|
- //TaxDeduction 差额税使用,非差额税可以为空
|
|
|
- String TaxDeduction = null; //TODO
|
|
|
- if (TaxDeduction == null) {
|
|
|
- TaxDeduction = "";
|
|
|
- }
|
|
|
- invoiceItem.setTaxDeduction(TaxDeduction);
|
|
|
-
|
|
|
- invoiceItems[i] = invoiceItem;
|
|
|
- }
|
|
|
-
|
|
|
- int SID = SoapSIDType.INVOICEISSUED.getValue();
|
|
|
- JSONObject SIDParam = new JSONObject(16,true);
|
|
|
-
|
|
|
- SIDParam.put("invoiceType",invoiceType);
|
|
|
- SIDParam.put("customerName",customerName);
|
|
|
- SIDParam.put("customerTaxNr",customerTaxNr );
|
|
|
- SIDParam.put("customerAddressTel",customerAddressTel);
|
|
|
- SIDParam.put("customerBankAccountNr",customerBankAccountNr);
|
|
|
- SIDParam.put("sellerBankAccountNr",sellerBankAccountNr);
|
|
|
- SIDParam.put("sellerAddressTel",sellerAddressTel);
|
|
|
- SIDParam.put("invoiceItems",invoiceItems);
|
|
|
- SIDParam.put("documentNr",documentNr);
|
|
|
- SIDParam.put("payee",payee);
|
|
|
- SIDParam.put("checker",checker);
|
|
|
- SIDParam.put("listed",listed);
|
|
|
- SIDParam.put("issuer",issuer);
|
|
|
- SIDParam.put("memo",memo);
|
|
|
- SIDParam.put("CheckEWM",CheckEWM);
|
|
|
-
|
|
|
- /*InvoiceParam invoiceParam = new InvoiceParam();
|
|
|
- invoiceParam.setInvoiceType(invoiceType);
|
|
|
- invoiceParam.setCustomerName(customerName);
|
|
|
- invoiceParam.setCustomerTaxNr(customerTaxNr);
|
|
|
- invoiceParam.setCustomerAddressTel(customerAddressTel);
|
|
|
- invoiceParam.setCustomerBankAccountNr(customerBankAccountNr);
|
|
|
- invoiceParam.setSellerBankAccountNr(sellerBankAccountNr);
|
|
|
- invoiceParam.setSellerAddressTel(sellerAddressTel);
|
|
|
- invoiceParam.setInvoiceItems(Arrays.asList(invoiceItems));
|
|
|
- invoiceParam.setDocumentNr(documentNr);
|
|
|
- invoiceParam.setPayee(payee);
|
|
|
- invoiceParam.setChecker(checker);
|
|
|
- invoiceParam.setListed(listed);
|
|
|
- invoiceParam.setIssuer(issuer);
|
|
|
- invoiceParam.setMemo(memo);
|
|
|
- invoiceParam.setCheckEWM(CheckEWM);
|
|
|
-
|
|
|
- String hehe = JsonUtil2.parse(invoiceParam);*/
|
|
|
-
|
|
|
- /*SIDParam.put("sellerTaxNr",sellerTaxNr);
|
|
|
- SIDParam.put("kpdh",kpdh);
|
|
|
- SIDParam.put("kpfwqh",kpfwqh);*/
|
|
|
-
|
|
|
- if (map.size() > 0) {
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- JSONObject resultJo = getSOAPJson(SID, SIDParam);
|
|
|
- if ("4011".equals(resultJo.getString("retcode"))) {
|
|
|
- apBillOut.setRetmsg(resultJo.getString("retmsg"));
|
|
|
- apBillOut.setInfoAmount(resultJo.getDouble("InfoAmount"));
|
|
|
- apBillOut.setInfoTaxAmount(resultJo.getDouble("InfoTaxAmount"));
|
|
|
- apBillOut.setInfoDate(resultJo.getString("InfoDate"));
|
|
|
- apBillOut.setInfoTypeCode(resultJo.getString("InfoTypeCode"));
|
|
|
- apBillOut.setInfoNumber(resultJo.getString("InfoNumber"));
|
|
|
- apBillOut.setHisInfoTypeCode(resultJo.getString("hisInfoTypeCode"));
|
|
|
- apBillOut.setHisInfoNumber(resultJo.getString("hisInfoNumber"));
|
|
|
- apBillOut.setHisInfoKind(resultJo.getString("hisInfoKind"));
|
|
|
- apBillOut.setListFlag(resultJo.getInteger("ListFlag"));
|
|
|
- apBillOut.setNsrsbh(resultJo.getString("nsrsbh"));
|
|
|
- apBillOut.setKpdh(resultJo.getString("kpdh"));
|
|
|
- apBillOut.setKpfwqh(resultJo.getString("kpfwqh"));
|
|
|
- //修改开票单状态
|
|
|
- apBillOut.setCheckStatus("已开票");
|
|
|
-
|
|
|
- try {
|
|
|
- purchaseApBillOutDao.save(apBillOut);
|
|
|
- } catch (Exception e) {
|
|
|
- map.put("dbError","开具发票成功,但过程中数据库更新开票单失败,需要人工紧急处理,作废此开票单据");
|
|
|
- }
|
|
|
-
|
|
|
- map.put("apBillOut",apBillOut);
|
|
|
- } else if (resultJo.getString("error") != null) {
|
|
|
- map.put("error",errorMsg.append(resultJo.getString("error")));
|
|
|
- } else {
|
|
|
- map.put("resultJo",resultJo);
|
|
|
- //map.put("error","发票开具失败");
|
|
|
- map.put("error",errorMsg.append(resultJo.getString("retmsg")));
|
|
|
- }
|
|
|
-
|
|
|
- String s = SIDParam.toString();
|
|
|
-
|
|
|
- map.put("SIDParam",SIDParam.toJSONString());
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- //发票打印
|
|
|
- @Override
|
|
|
- public ModelMap invoicePrint(PurchaseApBillOut apBillOut, Integer PrintKind) {
|
|
|
- ModelMap map = new ModelMap();
|
|
|
- StringBuilder errorMsg = new StringBuilder();
|
|
|
- Integer InfoKind = 0;//发票种类
|
|
|
-
|
|
|
- String InfoNumber = apBillOut.getInfoNumber();
|
|
|
- if (InfoNumber == null) {
|
|
|
- map.put("error",errorMsg.append("获取发票号码失败"));
|
|
|
- }
|
|
|
-
|
|
|
- String InfoTypeCode = apBillOut.getInfoTypeCode();
|
|
|
- if (InfoTypeCode == null) {
|
|
|
- map.put("error",errorMsg.append("获取发票代码失败"));
|
|
|
- }
|
|
|
-
|
|
|
- //可为空,0:打印发票 1:打印清单(与SID=3效果一样)
|
|
|
- if (PrintKind != null && PrintKind != 0 && PrintKind != 1) {
|
|
|
- map.put("error",errorMsg.append("打印类型错误"));
|
|
|
- }
|
|
|
-
|
|
|
- if (map.size() > 0) {
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- int SID = SoapSIDType.INVOICEPRINT.getValue();
|
|
|
- JSONObject SIDParam = new JSONObject(true);
|
|
|
- if (InfoKind == null) {
|
|
|
- SIDParam.put("InfoKind", "");
|
|
|
- } else {
|
|
|
- SIDParam.put("InfoKind", InfoKind);
|
|
|
- }
|
|
|
-
|
|
|
- SIDParam.put("InfoNumber", InfoNumber);
|
|
|
- SIDParam.put("InfoTypeCode", InfoTypeCode);
|
|
|
- SIDParam.put("PrintKind", PrintKind);
|
|
|
-
|
|
|
- Integer ShowPrintDlg = 1;//可为空,固定值0:不弹出参数设置窗口1:弹出参数设置窗口
|
|
|
- if (ShowPrintDlg == null) {
|
|
|
- SIDParam.put("ShowPrintDlg", "");
|
|
|
- } else {
|
|
|
- SIDParam.put("ShowPrintDlg", ShowPrintDlg);
|
|
|
- }
|
|
|
-
|
|
|
- JSONObject resultJo = getSOAPJson(SID, SIDParam);
|
|
|
- if ("5011".equals(resultJo.getString("retcode"))) {
|
|
|
- map.put("retmsg",resultJo.getString("retmsg"));
|
|
|
-
|
|
|
- //添加打印次数
|
|
|
- apBillOut.setPrint((short) ((apBillOut.getPrint() == null ? 0 : apBillOut.getPrint()) + 1));
|
|
|
-
|
|
|
- try {
|
|
|
- purchaseApBillOutDao.save(apBillOut);
|
|
|
- } catch (Exception e) {
|
|
|
- map.put("dbError","发票打印成功,但过程中数据库更新开票单打印次数失败,需要人工处理干预");
|
|
|
- }
|
|
|
-
|
|
|
- } else if (resultJo.getString("error") != null) {
|
|
|
- map.put("error",errorMsg.append(resultJo.getString("error")));
|
|
|
- } else {
|
|
|
- map.put("resultJo",resultJo);
|
|
|
- //map.put("error","发票打印失败");
|
|
|
- map.put("error",errorMsg.append(resultJo.getString("retmsg")));
|
|
|
- }
|
|
|
-
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- //清单打印 (需发票中有清单(开票是可以选择是否开具清单))
|
|
|
- @Override
|
|
|
- public ModelMap listPrint(PurchaseApBillOut apBillOut) {
|
|
|
- ModelMap map = new ModelMap();
|
|
|
- StringBuilder errorMsg = new StringBuilder();
|
|
|
- Integer InfoKind = 0;//发票种类
|
|
|
-
|
|
|
- String InfoNumber = apBillOut.getInfoNumber();
|
|
|
- if (InfoNumber == null) {
|
|
|
- map.put("error",errorMsg.append("获取发票号码失败"));
|
|
|
- }
|
|
|
-
|
|
|
- String InfoTypeCode = apBillOut.getInfoTypeCode();
|
|
|
- if (InfoTypeCode == null) {
|
|
|
- map.put("error",errorMsg.append("获取发票代码失败"));
|
|
|
- }
|
|
|
-
|
|
|
- Integer ShowPrintDlg = 1;//可为空,固定值0:不弹出参数设置窗口1:弹出参数设置窗口
|
|
|
-
|
|
|
- if (map.size() > 0) {
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- int SID = SoapSIDType.LISTPRINT.getValue();
|
|
|
- JSONObject SIDParam = new JSONObject(true);
|
|
|
- if (InfoKind == null) {
|
|
|
- SIDParam.put("InfoKind", "");
|
|
|
- } else {
|
|
|
- SIDParam.put("InfoKind", InfoKind);
|
|
|
- }
|
|
|
- SIDParam.put("InfoNumber", InfoNumber);
|
|
|
- SIDParam.put("InfoTypeCode", InfoTypeCode);
|
|
|
- if (ShowPrintDlg == null) {
|
|
|
- SIDParam.put("ShowPrintDlg", "");
|
|
|
- } else {
|
|
|
- SIDParam.put("ShowPrintDlg", ShowPrintDlg);
|
|
|
- }
|
|
|
-
|
|
|
- JSONObject resultJo = getSOAPJson(SID, SIDParam);
|
|
|
- if ("5011".equals(resultJo.getString("retcode"))) {
|
|
|
- map.put("retmsg",resultJo.getString("retmsg"));
|
|
|
- } else if (resultJo.getString("error") != null) {
|
|
|
- map.put("error",errorMsg.append(resultJo.getString("error")));
|
|
|
- } else {
|
|
|
- //map.put("error","清单打印失败");
|
|
|
- map.put("error",errorMsg.append(resultJo.getString("retmsg")));
|
|
|
- }
|
|
|
-
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- //发票作废
|
|
|
- @Override
|
|
|
- public ModelMap InvoiceCancel(PurchaseApBillOut apBillOut) {
|
|
|
- ModelMap map = new ModelMap();
|
|
|
- StringBuilder errorMsg = new StringBuilder();
|
|
|
- Integer InfoKind = 0;//发票种类
|
|
|
- String InfoNumber = apBillOut.getInfoNumber();
|
|
|
- if (InfoNumber == null) {
|
|
|
- map.put("error",errorMsg.append("获取发票号码失败"));
|
|
|
- }
|
|
|
-
|
|
|
- String InfoTypeCode = apBillOut.getInfoTypeCode();
|
|
|
- if (InfoTypeCode == null) {
|
|
|
- map.put("error",errorMsg.append("获取发票代码失败"));
|
|
|
- }
|
|
|
-
|
|
|
- if (map.size() > 0) {
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- int SID = SoapSIDType.INVOICECANCEL.getValue();
|
|
|
- JSONObject SIDParam = new JSONObject();
|
|
|
- if (InfoKind == null) {
|
|
|
- SIDParam.put("InfoKind", "");
|
|
|
- } else {
|
|
|
- SIDParam.put("InfoKind", InfoKind);
|
|
|
- }
|
|
|
- SIDParam.put("InfoNumber", InfoNumber);
|
|
|
- SIDParam.put("InfoTypeCode", InfoTypeCode);
|
|
|
- JSONObject resultJo = getSOAPJson(SID, SIDParam);
|
|
|
-
|
|
|
- if ("6011".equals(resultJo.getString("retcode"))) {
|
|
|
- map.put("retmsg",resultJo.getString("retmsg"));
|
|
|
- map.put("retcode",resultJo.getString("retcode"));
|
|
|
- //修改开票单状态
|
|
|
- apBillOut.setCheckStatus("已作废");
|
|
|
- apBillOut.setRetmsg(resultJo.getString("retmsg"));
|
|
|
-
|
|
|
- try {
|
|
|
- purchaseApBillOutDao.save(apBillOut);
|
|
|
- } catch (Exception e) {
|
|
|
- map.put("dbError","发票作废成功,但过程中数据库更新开票单失败,需要人工处理干预");
|
|
|
- }
|
|
|
- } else if (resultJo.getString("error") != null) {
|
|
|
- map.put("error",errorMsg.append(resultJo.getString("error")));
|
|
|
- } else {
|
|
|
- //map.put("error","发票作废失败");
|
|
|
- map.put("error",errorMsg.append(resultJo.getString("retmsg")));
|
|
|
- }
|
|
|
-
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- //查询发票信息 //ToDO 批量查询发票
|
|
|
- @Override
|
|
|
- public ModelMap queryInvoiceMessage(PurchaseApBillOut apBillOut, Integer mqdbz, Integer mdybz) {
|
|
|
- ModelMap map = new ModelMap();
|
|
|
- StringBuilder errorMsg = new StringBuilder();
|
|
|
- Boolean flag = true; //默认true为查询发票信息,false为批量发票查询
|
|
|
-
|
|
|
- Integer fpzl = 0;//发票种类 0:专票2:普票
|
|
|
- String xsdh = null;//销售单号 //TODO 是否必填
|
|
|
- String gfmc = null;
|
|
|
- String gfsh = null;
|
|
|
- String kpjh = null;//开票机号 //TODO
|
|
|
- String xfmc = null;//销方名称
|
|
|
- String xfsh = null;//销方税号
|
|
|
- String fpdm = null;//发票代码
|
|
|
- String fphm = null;//发票号码
|
|
|
- Integer zfbz = 0;//作废标志 //TODO(0未作废 1已作废)
|
|
|
- Integer qdbz = mqdbz;//清单标志 默认0//TODO(0:非清单发票 1:清单发票)
|
|
|
- //以下为非必填项
|
|
|
- String kpdh = null; //TODO 对方说暂留
|
|
|
- Integer dybz = mdybz;//打印标志 //TODO(1已打印 0未打印)
|
|
|
- Integer bsbz = 0;//报税标志 //TODO
|
|
|
- Integer RecNo = null; //TODO 对方说暂留
|
|
|
- String BeginDate = null; //"2017-07-01";//开始日期yyyy-MM-dd//TODO
|
|
|
- String EndDate = null; //"2017-08--30";//截至日期yyyy-MM-dd//TODO
|
|
|
- //下面分页可根据需要传
|
|
|
- Integer PageSize = null;//分页大小:一次查询返回的最大记录数//TODO
|
|
|
- Integer PageIndex = null;//当前页序号,第一页为1
|
|
|
-
|
|
|
- if (apBillOut != null) {
|
|
|
- xsdh= apBillOut.getCode();
|
|
|
- kpjh = apBillOut.getKpdh();
|
|
|
- fpdm= apBillOut.getInfoTypeCode();
|
|
|
- fphm = apBillOut.getInfoNumber();
|
|
|
-
|
|
|
- PurchaseApBillOutInfo custApBillOutInfo = apBillOut.getCustomerApBillOutInfo();
|
|
|
- if (custApBillOutInfo == null) {
|
|
|
- map.put("error",errorMsg.append("获取购方企业开票信息失败"));
|
|
|
- } else {
|
|
|
- gfmc= custApBillOutInfo.getEnName();//购方名称
|
|
|
- if (gfmc == null) {
|
|
|
- map.put("error",errorMsg.append("获取购方企业名称失败"));
|
|
|
- }
|
|
|
-
|
|
|
- gfsh= custApBillOutInfo.getTaxNr();//购方税号
|
|
|
- if (gfsh == null) {
|
|
|
- map.put("error",errorMsg.append("获取购方企业税号失败"));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- PurchaseApBillOutInfo apBillOutInfo = apBillOut.getApBillOutInfo();
|
|
|
- if (apBillOutInfo == null) {
|
|
|
- map.put("error",errorMsg.append("获取购方企业信息失败"));
|
|
|
- } else {
|
|
|
- xfmc= apBillOutInfo.getEnName();
|
|
|
- if (xfmc == null) {
|
|
|
- map.put("error",errorMsg.append("获取销方企业名称失败"));
|
|
|
- }
|
|
|
-
|
|
|
- xfsh= apBillOutInfo.getTaxNr();
|
|
|
- if (xfsh == null) {
|
|
|
- map.put("error",errorMsg.append("获取销方企业税号失败"));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (xsdh == null) {
|
|
|
- map.put("error",errorMsg.append("获取销售单号失败"));
|
|
|
- }
|
|
|
- if (fpdm == null) {
|
|
|
- map.put("error",errorMsg.append("获取发票代码失败"));
|
|
|
- }
|
|
|
- if (fphm == null) {
|
|
|
- map.put("error",errorMsg.append("获取发票号码失败"));
|
|
|
- }
|
|
|
- if (kpjh == null) {
|
|
|
- map.put("error",errorMsg.append("获取开票机号失败"));
|
|
|
- }
|
|
|
- if (zfbz == null) {
|
|
|
- map.put("error",errorMsg.append("获取作废标志失败"));
|
|
|
- }
|
|
|
- if (qdbz == null) {
|
|
|
- map.put("error",errorMsg.append("获取清单标志失败"));
|
|
|
- }
|
|
|
-
|
|
|
- //批量查询发票 kpdh RecNo
|
|
|
- if (xsdh == null && gfmc == null && gfsh == null &&
|
|
|
- kpjh == null && xfmc == null && xfsh == null &&
|
|
|
- fpdm == null && fphm == null && zfbz == null &&
|
|
|
- qdbz == null && dybz == null && bsbz == null &&
|
|
|
- fpzl != null && BeginDate != null && EndDate != null) {
|
|
|
-
|
|
|
- map.clear();
|
|
|
- flag = false;
|
|
|
- //TODO 置""?
|
|
|
-
|
|
|
- } else {
|
|
|
- if (map.size() > 0) {
|
|
|
- return map;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //非必填项
|
|
|
- if (kpdh == null && flag) {
|
|
|
- kpdh = "";
|
|
|
- }
|
|
|
- if (BeginDate == null && flag) {
|
|
|
- BeginDate = "";
|
|
|
- }
|
|
|
- if (EndDate == null && flag) {
|
|
|
- EndDate = "";
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- int SID = SoapSIDType.QUERYINVOICEMESSAGE.getValue();
|
|
|
- JSONObject SIDParam = new JSONObject(true);
|
|
|
- if (fpzl == null && flag) {
|
|
|
- SIDParam.put("fpzl", "");
|
|
|
- } else {
|
|
|
- SIDParam.put("fpzl", fpzl);
|
|
|
- }
|
|
|
-
|
|
|
- SIDParam.put("xsdh", xsdh);
|
|
|
- SIDParam.put("gfmc", gfmc);
|
|
|
- SIDParam.put("gfsh", gfsh);
|
|
|
- SIDParam.put("kpjh", kpjh);
|
|
|
- SIDParam.put("xfmc", xfmc);
|
|
|
- SIDParam.put("xfsh", xfsh);
|
|
|
- SIDParam.put("fpdm", fpdm);
|
|
|
- SIDParam.put("fphm", fphm);
|
|
|
- SIDParam.put("kpdh", kpdh);
|
|
|
- SIDParam.put("zfbz", zfbz);
|
|
|
- SIDParam.put("qdbz", qdbz);
|
|
|
-
|
|
|
- if (dybz == null && flag) {
|
|
|
- SIDParam.put("dybz", "");
|
|
|
- } else {
|
|
|
- SIDParam.put("dybz", dybz);
|
|
|
- }
|
|
|
- if (bsbz == null && flag) {
|
|
|
- SIDParam.put("bsbz", "");
|
|
|
- } else {
|
|
|
- SIDParam.put("bsbz", bsbz);
|
|
|
- }
|
|
|
- if (RecNo == null && flag) {
|
|
|
- SIDParam.put("RecNo", "");
|
|
|
- } else {
|
|
|
- SIDParam.put("RecNo", RecNo);
|
|
|
- }
|
|
|
-
|
|
|
- SIDParam.put("BeginDate", BeginDate);
|
|
|
- SIDParam.put("EndDate", EndDate);
|
|
|
-
|
|
|
- if (PageSize == null && flag) {
|
|
|
- SIDParam.put("PageSize", "");
|
|
|
- } else {
|
|
|
- SIDParam.put("PageSize", PageSize);
|
|
|
- }
|
|
|
- if (PageIndex == null && flag) {
|
|
|
- SIDParam.put("PageIndex", "");
|
|
|
- } else {
|
|
|
- SIDParam.put("PageIndex", PageIndex);
|
|
|
- }
|
|
|
-
|
|
|
- JSONObject resultJo = getSOAPJson(SID, SIDParam);
|
|
|
-
|
|
|
- if ("0".equals(resultJo.getString("retcode"))) {
|
|
|
- SoapQueryInvoiceMessage sqim = JSONObject.parseObject(resultJo.toJSONString(), SoapQueryInvoiceMessage.class);
|
|
|
- map.put("sqim",sqim);
|
|
|
- } else if (resultJo.getString("error") != null) {
|
|
|
- map.put("error",errorMsg.append(resultJo.getString("error")));
|
|
|
- } else {
|
|
|
- //map.put("error","查询发票失败");
|
|
|
- map.put("error",errorMsg.append(resultJo.getString("retmsg")));
|
|
|
- }
|
|
|
-
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- //查询库存信息 //TODO SoapQueryRepertyMessage字段类型Integet改为了String
|
|
|
- @Override
|
|
|
- public ModelMap queryRepertyMessage() {
|
|
|
- ModelMap map = new ModelMap();
|
|
|
- int SID = SoapSIDType.QUERYREPERTORYMEAASGE.getValue();
|
|
|
- JSONObject resultJo = getSOAPJson(SID, null);
|
|
|
-
|
|
|
- if ("0".equals(resultJo.getString("retcode"))) {
|
|
|
- SoapQueryRepertyMessage sqrm = JSONObject.parseObject(resultJo.toJSONString(), SoapQueryRepertyMessage.class);
|
|
|
- map.put("sqrm",sqrm);
|
|
|
- } else if (resultJo.getString("error") != null) {
|
|
|
- map.put("error",resultJo.getString("error"));
|
|
|
- } else {
|
|
|
- //map.put("error","查询库存信息失败");
|
|
|
- map.put("error",resultJo.getString("retmsg"));
|
|
|
- }
|
|
|
-
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- //查询下一发票机库存信息 //TODO SoapQueryNextRepertyMessage Integer
|
|
|
- @Override
|
|
|
- public ModelMap queryNextRepertyMessage() {
|
|
|
- ModelMap map = new ModelMap();
|
|
|
- int SID = SoapSIDType.QUERYNEXTREPERTORYMEAASGE.getValue();
|
|
|
- JSONObject resultJo = getSOAPJson(SID, null);
|
|
|
-
|
|
|
- if ("1011".equals(resultJo.getString("retcode"))) {
|
|
|
- SoapQueryNextRepertyMessage sqnrm = JSONObject.parseObject(resultJo.toJSONString(), SoapQueryNextRepertyMessage.class);
|
|
|
- map.put("sqnrm",sqnrm);
|
|
|
- } else if (resultJo.getString("error") != null) {
|
|
|
- map.put("error",resultJo.getString("error"));
|
|
|
- } else {
|
|
|
- //map.put("error","查询下一发票机库存信息失败");
|
|
|
- map.put("error",resultJo.getString("retmsg"));
|
|
|
- }
|
|
|
-
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- //启动开票服务
|
|
|
- @Override
|
|
|
- public ModelMap startBillOut() {
|
|
|
- ModelMap map = new ModelMap();
|
|
|
- int SID = SoapSIDType.STARTBILLOUT.getValue();
|
|
|
- JSONObject resultJo = getSOAPJson(SID, null);
|
|
|
-
|
|
|
- if ("1011".equals(resultJo.getString("retcode"))) {
|
|
|
- SoapStartBillOut ssbo = JSONObject.parseObject(resultJo.toJSONString(), SoapStartBillOut.class);//TODO PtVer
|
|
|
- map.put("ssbo",ssbo);
|
|
|
- } else if (resultJo.getString("error") != null) {
|
|
|
- map.put("error",resultJo.getString("error"));
|
|
|
- } else {
|
|
|
- //map.put("error","启动开票服务信息失败");
|
|
|
- map.put("error",resultJo.getString("retmsg"));
|
|
|
- }
|
|
|
-
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- //关闭开票服务
|
|
|
- @Override
|
|
|
- public ModelMap closeBillOut() {
|
|
|
- ModelMap map = new ModelMap();
|
|
|
- int SID = SoapSIDType.CLOSEBILLOUT.getValue();
|
|
|
- JSONObject resultJo = getSOAPJson(SID, null);
|
|
|
-
|
|
|
- if ("0".equals(resultJo.getString("retcode"))) {
|
|
|
- map.put("retmsg",resultJo.getString("retmsg"));
|
|
|
- } else if (resultJo.getString("error") != null) {
|
|
|
- map.put("error",resultJo.getString("error"));
|
|
|
- } else {
|
|
|
- //map.put("error","关闭开票服务信息失败");
|
|
|
- map.put("error",resultJo.getString("retmsg"));
|
|
|
- }
|
|
|
-
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- //发票上传 //TODO
|
|
|
- @Override
|
|
|
- public ModelMap invoiceUpload(PurchaseApBillOut apBillOut) {
|
|
|
- ModelMap map = new ModelMap();
|
|
|
- StringBuilder errorMsg = new StringBuilder();
|
|
|
- //TODO 获取属性值
|
|
|
- String fpdm = apBillOut.getInfoTypeCode();//上传的发票代码
|
|
|
- if (fpdm == null) {
|
|
|
- map.put("error",errorMsg.append("获取上传的发票代码失败"));
|
|
|
- }
|
|
|
-
|
|
|
- String fphm = apBillOut.getInfoNumber();//上传的发票号码
|
|
|
- if (fphm == null) {
|
|
|
- map.put("error",errorMsg.append("获取上传的发票号码失败"));
|
|
|
- }
|
|
|
-
|
|
|
- if (map.size() > 0) {
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- int SID = SoapSIDType.INVOICEUPLOAD.getValue();
|
|
|
- JSONObject SIDParam = new JSONObject(true);
|
|
|
- SIDParam.put("fpdm", fpdm);
|
|
|
- SIDParam.put("fphm", fphm);
|
|
|
-
|
|
|
- JSONObject resultJo = getSOAPJson(SID, SIDParam);
|
|
|
-
|
|
|
- if ("0".equals(resultJo.getString("retcode"))) {
|
|
|
- map.put("retmsg",resultJo.getString("retmsg"));
|
|
|
- } else if (resultJo.getString("error") != null) {
|
|
|
- map.put("error",errorMsg.append(resultJo.getString("error")));
|
|
|
- } else {
|
|
|
- //map.put("error","发票上传失败");
|
|
|
- map.put("error",errorMsg.append(resultJo.getString("retmsg")));
|
|
|
- }
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- //发票状态更新 //TODO 需先上传发票
|
|
|
- @Override
|
|
|
- public ModelMap invoiceStatusUpdate() {
|
|
|
- ModelMap map = new ModelMap();
|
|
|
- int SID = SoapSIDType.INVOICESTATUSUPDATE.getValue();
|
|
|
- JSONObject resultJo = getSOAPJson(SID, null);
|
|
|
-
|
|
|
- if ("8050".equals(resultJo.getString("retcode"))) {
|
|
|
- SoapInvoiceStatusUpdate sisu = JSONObject.parseObject(resultJo.toJSONString(), SoapInvoiceStatusUpdate.class);
|
|
|
- map.put("sisu",sisu);
|
|
|
- } else if (resultJo.getString("error") != null) {
|
|
|
- map.put("error",resultJo.getString("error"));
|
|
|
- } else {
|
|
|
- //map.put("error","发票状态更新失败");
|
|
|
- map.put("error",resultJo.getString("retmsg"));
|
|
|
- }
|
|
|
-
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- //单张发票查询
|
|
|
- @Override
|
|
|
- public ModelMap singleInvoiceQuery(PurchaseApBillOut apBillOut) {
|
|
|
- ModelMap map = new ModelMap();
|
|
|
- StringBuilder errorMsg = new StringBuilder();
|
|
|
- //注意:xsdbh与fpzl、fpdm、fphm是互斥条件,传销售单号就不按照fpzl,fpdm,fphm来查询
|
|
|
- Integer fpzl = 0;//发票种类 0专票,2普票,11货运发票,12机动车发票,51电子发票 //TODO
|
|
|
- String fpdm = apBillOut.getInfoTypeCode();//发票代码 10位
|
|
|
- if (fpdm == null) {
|
|
|
- fpdm = "";
|
|
|
- }
|
|
|
-
|
|
|
- String fphm = apBillOut.getInfoNumber();//发票号码8位
|
|
|
- if (fphm == null) {
|
|
|
- fphm = "";
|
|
|
- }
|
|
|
-
|
|
|
- //以下为非必填项
|
|
|
- String xsdbh = null; //apBillOut.getCode();//销售单编号
|
|
|
- if (xsdbh == null) {
|
|
|
- xsdbh = "";
|
|
|
- }
|
|
|
-
|
|
|
- if (!((fpzl != null && !"".equals(fpdm) && !"".equals(fphm)) ^ (!"".equals(xsdbh)))) {
|
|
|
- if (fpzl == null) {
|
|
|
- map.put("error",errorMsg.append("获取发票种类失败"));
|
|
|
- }
|
|
|
- if ("".equals(fpdm)) {
|
|
|
- map.put("error",errorMsg.append("获取发票代码失败"));
|
|
|
- }
|
|
|
- if ("".equals(fphm)) {
|
|
|
- map.put("error",errorMsg.append("获取发票号码失败"));
|
|
|
- }
|
|
|
- if ("".equals(xsdbh)) {
|
|
|
- map.put("error",errorMsg.append("获取销售单编号失败"));
|
|
|
- }
|
|
|
- map.put("error",errorMsg.append("销售单编号与发票种类、发票代码、发票号码是互斥条件"));
|
|
|
- }
|
|
|
-
|
|
|
- if (map.size() > 0) {
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- int SID = SoapSIDType.SINGLEINVOICEQUERY.getValue();
|
|
|
- JSONObject SIDParam = new JSONObject(true);
|
|
|
- SIDParam.put("xsdbh", xsdbh);
|
|
|
- SIDParam.put("fpzl", fpzl);
|
|
|
- SIDParam.put("fpdm", fpdm);
|
|
|
- SIDParam.put("fphm", fphm);
|
|
|
-
|
|
|
- JSONObject resultJo = getSOAPJson(SID, SIDParam);
|
|
|
-
|
|
|
- if ("0".equals(resultJo.getString("retcode"))) {
|
|
|
- SoapSingleInvoiceQuery ssiq = JSONObject.parseObject(resultJo.toJSONString(), SoapSingleInvoiceQuery.class);
|
|
|
- map.put("ssiq", ssiq);
|
|
|
- } else if (resultJo.getString("error") != null) {
|
|
|
- map.put("error",errorMsg.append(resultJo.getString("error")));
|
|
|
- } else {
|
|
|
- //map.put("error","单张发票查询失败");
|
|
|
- map.put("error",errorMsg.append(resultJo.getString("retmsg")));
|
|
|
- }
|
|
|
-
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- //TODO 批处理接口 SID=20
|
|
|
-
|
|
|
- //机动车发票填开
|
|
|
- @Override
|
|
|
- public SoapMotorInvoiceIssued motorInvoiceIssued(String json) {
|
|
|
- String documentNr = "";//单据号
|
|
|
- Integer CheckEWM = 0;//开票标志 0:开票 1:校验 2:空白作废
|
|
|
- Integer infoKind = 12;//发票种类 12 为机动车 //TODO ?
|
|
|
- String Jdckind = "1";//1 旧机动车,2新机动车
|
|
|
- String infoClientName = "";//购货单位
|
|
|
- String idCard = "";//身份证号、组织机构代码
|
|
|
- String vehicleKind = "";//车辆类型
|
|
|
- String brandModel = "";//厂牌型号
|
|
|
- String originPlace = "";//产地
|
|
|
- String vehicleNo = "";//车辆识别代号、车辆号码
|
|
|
- //String documentNr = "";//销售单号 //TODO ?
|
|
|
- String infoInvoicer = "";//开票人
|
|
|
- Double amountTaxTotal = 0.0;//价税合计
|
|
|
- Integer infoTaxRate = 0;//11标识11%
|
|
|
-
|
|
|
- //以下为非必填项
|
|
|
- String sellerTaxNr = null;//销方税号(可为空)
|
|
|
- Integer kpdh = null;//开票点号(可为空)
|
|
|
- Integer kpfwqh = 0;//开票服务器号
|
|
|
- //以上信息传入则会比较是否一致,不一致就不能开票
|
|
|
- String infoClientTaxCode = "";//新机动车纳税人识别号
|
|
|
- String qualityCertificate = "";//合格证号
|
|
|
- String impCertificateNo = "";//进口证明文书号
|
|
|
- String commInspectionNo = "";//商标单号(商检单号)
|
|
|
- String enginNo = "";//发动机号
|
|
|
- String manufacturerName = "";//生产厂家名称
|
|
|
- String sellerPhone = "";//销货单位电话
|
|
|
- String sellerAccount = "";//销货单位账号
|
|
|
- String sellerAddress = "";//地址
|
|
|
- String sellerBank = "";//开户行
|
|
|
- String tonnage = "";//吨位
|
|
|
- String peopleNo = "";//限乘人数
|
|
|
- String infoNotes = "";//备注
|
|
|
- String GoodsNoVer = "";//税收分类编码版本号
|
|
|
- String GoodsTaxNo = "";//税收分类编码
|
|
|
- String TaxPre = "";//是否享受优惠政策
|
|
|
- String TaxPreCon = "";//优惠正常内容(可不传)
|
|
|
- String ZeroTax = "";//零税率标识(可不传)
|
|
|
- String CropGoodsNo = "";//企业自编码(可不传)
|
|
|
-
|
|
|
- JSONObject jo = JSON.parseObject(json);
|
|
|
- //TODO 获取属性值
|
|
|
-
|
|
|
- int SID = SoapSIDType.MOTORINVOICEISSUED.getValue();
|
|
|
- JSONObject SIDParam = new JSONObject();
|
|
|
- SIDParam.put("sellerTaxNr", sellerTaxNr);
|
|
|
- SIDParam.put("kpdh", kpdh);
|
|
|
- SIDParam.put("kpfwqh", kpfwqh);
|
|
|
- SIDParam.put("documentNr", documentNr);
|
|
|
- SIDParam.put("CheckEWM", CheckEWM);
|
|
|
- SIDParam.put("infoKind", infoKind);
|
|
|
- SIDParam.put("Jdckind", Jdckind);
|
|
|
- SIDParam.put("infoClientName", infoClientName);
|
|
|
- SIDParam.put("infoClientTaxCode", infoClientTaxCode);
|
|
|
- SIDParam.put("idCard", idCard);
|
|
|
- SIDParam.put("vehicleKind", vehicleKind);
|
|
|
- SIDParam.put("brandModel", brandModel);
|
|
|
- SIDParam.put("originPlace", originPlace);
|
|
|
- SIDParam.put("qualityCertificate", qualityCertificate);
|
|
|
- SIDParam.put("impCertificateNo", impCertificateNo);
|
|
|
- SIDParam.put("commInspectionNo", commInspectionNo);
|
|
|
- SIDParam.put("enginNo", enginNo);
|
|
|
- SIDParam.put("vehicleNo", vehicleNo);
|
|
|
- SIDParam.put("manufacturerName", manufacturerName);
|
|
|
- SIDParam.put("infoInvoicer", infoInvoicer);
|
|
|
- SIDParam.put("amountTaxTotal", amountTaxTotal);
|
|
|
- SIDParam.put("sellerPhone", sellerPhone);
|
|
|
- SIDParam.put("sellerAccount", sellerAccount);
|
|
|
- SIDParam.put("sellerAddress", sellerAddress);
|
|
|
- SIDParam.put("sellerBank", sellerBank);
|
|
|
- SIDParam.put("infoTaxRate", infoTaxRate);
|
|
|
- SIDParam.put("tonnage", tonnage);
|
|
|
- SIDParam.put("peopleNo", peopleNo);
|
|
|
- SIDParam.put("infoNotes", infoNotes);
|
|
|
- SIDParam.put("GoodsNoVer", GoodsNoVer);
|
|
|
- SIDParam.put("GoodsTaxNo", GoodsTaxNo);
|
|
|
- SIDParam.put("TaxPre", TaxPre);
|
|
|
- SIDParam.put("TaxPreCon", TaxPreCon);
|
|
|
- SIDParam.put("ZeroTax", ZeroTax);
|
|
|
- SIDParam.put("CropGoodsNo", CropGoodsNo);
|
|
|
-
|
|
|
- JSONObject resultJo = getSOAPJson(SID, SIDParam);
|
|
|
- SoapMotorInvoiceIssued smii = JSON.toJavaObject(resultJo, SoapMotorInvoiceIssued.class);
|
|
|
- return smii;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //机动车发票查询
|
|
|
- @Override
|
|
|
- public SoapMotorInvoiceQuery motorInvoiceQuery(String json) {
|
|
|
- String xsdh = "";//销售单号 //TODO 是否必填
|
|
|
- String gfmc = "";//购方名称
|
|
|
- String xfmc = "";//销方名称
|
|
|
- String xfsh = "";//销方税号
|
|
|
- String fpdm = "";//发票代码
|
|
|
- String fphm = "";//发票号码
|
|
|
- Integer kpjh = 0;//开票机号
|
|
|
- Integer zfbz = 0;//作废标志
|
|
|
- Integer qdbz = 0;//清单标志
|
|
|
- Integer dybz = 0;//打印标志
|
|
|
-
|
|
|
- //以下为非必填项
|
|
|
- String gfsh = "";//购方税号
|
|
|
- Integer bsbz = 0;//报税标志
|
|
|
- String BeginDate = "";//开始日期yyyy-MM-dd
|
|
|
- String EndDate = "";//截至日期yyyy-MM-dd
|
|
|
- //下面分页可根据需要传
|
|
|
- Integer PageSize = 0;//分页大小:一次查询返回的最大记录数
|
|
|
- Integer PageIndex = 1;//当前页序号,第一页为1
|
|
|
-
|
|
|
- JSONObject jo = JSON.parseObject(json);
|
|
|
- //TODO 获取属性值
|
|
|
-
|
|
|
- int SID = SoapSIDType.MOTORINVOICEQUERY.getValue();
|
|
|
- JSONObject SIDParam = new JSONObject();
|
|
|
- SIDParam.put("xsdh", xsdh);
|
|
|
- SIDParam.put("gfmc", gfmc);
|
|
|
- SIDParam.put("gfsh", gfsh);
|
|
|
- SIDParam.put("xfmc", xfmc);
|
|
|
- SIDParam.put("xfsh", xfsh);
|
|
|
- SIDParam.put("fpdm", fpdm);
|
|
|
- SIDParam.put("fphm", fphm);
|
|
|
- SIDParam.put("kpjh", kpjh);
|
|
|
- SIDParam.put("zfbz", zfbz);
|
|
|
- SIDParam.put("qdbz", qdbz);
|
|
|
- SIDParam.put("dybz", dybz);
|
|
|
- SIDParam.put("bsbz", bsbz);
|
|
|
- SIDParam.put("BeginDate", BeginDate);
|
|
|
- SIDParam.put("EndDate", EndDate);
|
|
|
- SIDParam.put("PageSize", PageSize);
|
|
|
- SIDParam.put("PageIndex", PageIndex);
|
|
|
-
|
|
|
- JSONObject resultJo = getSOAPJson(SID, SIDParam);
|
|
|
- SoapMotorInvoiceQuery smiq = JSON.toJavaObject(resultJo, SoapMotorInvoiceQuery.class);
|
|
|
- return smiq;
|
|
|
- }
|
|
|
-
|
|
|
- //金税设备查询 SID=25
|
|
|
- @Override
|
|
|
- public ModelMap taxEquipmentQuery() {
|
|
|
- ModelMap map = new ModelMap();
|
|
|
-
|
|
|
- int SID = SoapSIDType.TAXEQUIPMENTQUERY.getValue();
|
|
|
- JSONObject SIDParam = new JSONObject();
|
|
|
- String str = "<?xml version=\"1.0\" encoding=\"GBK\"?><FPXT_COM_INPUT><ID>0400</ID><DATA></DATA></FPXT_COM_INPUT>";
|
|
|
- SIDParam.put("SIDParam", str);
|
|
|
-
|
|
|
- JSONObject resultJo = getSOAPJson(SID, SIDParam);
|
|
|
-
|
|
|
- if ("0".equals(resultJo.getString("retcode"))) {
|
|
|
- map.put("resultJo",resultJo);
|
|
|
-
|
|
|
- //单纯想查看responseMsg解析后的内容
|
|
|
- String responseMsg = resultJo.getString("responseMsg");
|
|
|
- responseMsg = responseMsg.split("<DATA>")[1].split("</DATA>")[0];
|
|
|
- responseMsg = getFromBase64(responseMsg);
|
|
|
- map.put("responseMsg",responseMsg);
|
|
|
-
|
|
|
- } else if (resultJo.getString("error") != null) {
|
|
|
- map.put("error",resultJo.getString("error"));
|
|
|
- } else {
|
|
|
- //map.put("error","查询金税设备失败");
|
|
|
- map.put("error",resultJo.getString("retmsg"));
|
|
|
- }
|
|
|
-
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- private JSONObject getSOAPJson(int SID, JSONObject SIDParam) {
|
|
|
-
|
|
|
- //获取当前企业
|
|
|
- Long enUu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
- String ipAndPort = purchaseApBillOutInfoDao.findByUu(enUu).getIp();
|
|
|
- String[] ipAndPortArr = ipAndPort.split(":");
|
|
|
- String ip = ipAndPortArr[0].trim();
|
|
|
- String port = "8888";//默认端口号
|
|
|
- if (ipAndPortArr.length == 2 && !"".equals(ipAndPortArr[1].trim()))
|
|
|
- {
|
|
|
- port = ipAndPortArr[1].trim();
|
|
|
- }
|
|
|
-
|
|
|
- JSONObject resultJo = new JSONObject();
|
|
|
- String param = null;
|
|
|
- if (SIDParam != null) {
|
|
|
- String SIDParamString = SIDParam.toJSONString(); //JSON.toJSONString(SIDParam, new PascalNameFilter())
|
|
|
- if (SID == 1) {
|
|
|
- SIDParamString = SIDParamString.replaceAll("cropGoodsNo", "CropGoodsNo").replaceAll("goodsTaxNo", "GoodsTaxNo").replaceAll("taxDeduction", "TaxDeduction").replaceAll("taxPre", "TaxPre").replaceAll("taxPreCon", "TaxPreCon").replaceAll("zeroTax", "ZeroTax");
|
|
|
- }
|
|
|
- param = getBase64(SIDParamString);
|
|
|
- }
|
|
|
-
|
|
|
- try {
|
|
|
- String url = "http://" +ip + ":" + port + "/InvSvr?SID=" + SID + "&SIDParam=" + param;
|
|
|
- String response = HttpUtil.sendPost(url, null);
|
|
|
- JSONObject responseJo = JSON.parseObject(response);
|
|
|
- String result = responseJo.getString("ENCMSG");
|
|
|
- result = getFromBase64(result);
|
|
|
- resultJo = JSON.parseObject(result);
|
|
|
- } catch (NullPointerException e) { // 加一个connectException
|
|
|
- resultJo.put("error", "从开票接口获取数据失败");
|
|
|
- e.printStackTrace();
|
|
|
- } catch (Exception e) {
|
|
|
- resultJo.put("error", "链接航天开票接口失败");
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- return resultJo;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private JSONObject getSOAPJson1(int SID, JSONObject SIDParam) {
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
- sb.append("http://127.0.0.1:8888/InvSvr?");//192.168.253.112
|
|
|
- sb.append("SID=").append(SID);
|
|
|
- String str = SIDParam.toJSONString();
|
|
|
-
|
|
|
- str = getBase64(str);
|
|
|
-
|
|
|
- sb.append("&SIDParam=").append(str);
|
|
|
- URLConnection conn = null;
|
|
|
- BufferedReader rd = null;
|
|
|
- JSONObject resultJo = new JSONObject();
|
|
|
- String result = "";
|
|
|
- String res = "";
|
|
|
- try {
|
|
|
- URL url = new URL(str);
|
|
|
- conn = url.openConnection();
|
|
|
- conn.setRequestProperty("accept", "*/*");
|
|
|
- //conn.setRequestProperty("Accept-Charset", "GBK");
|
|
|
- conn.setRequestProperty("connection", "Keep-Alive");
|
|
|
- conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
|
|
|
- conn.connect();
|
|
|
- rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
|
|
- while ((result = rd.readLine()) != null) {
|
|
|
- res = res + result;
|
|
|
- }
|
|
|
- resultJo = JSON.parseObject(res);
|
|
|
-
|
|
|
- } catch (MalformedURLException e) {
|
|
|
- e.printStackTrace();
|
|
|
- } catch (ConnectException e) {
|
|
|
- resultJo.put("error", "链接航天开票接口失败");
|
|
|
- e.printStackTrace();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- try {
|
|
|
- if (rd != null) {
|
|
|
- rd.close();
|
|
|
- }
|
|
|
-
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return resultJo;
|
|
|
- }
|
|
|
-
|
|
|
- //return resultJo;
|
|
|
- }
|
|
|
-
|
|
|
- // 加密
|
|
|
- public static String getBase64(String str) {
|
|
|
- byte[] b = null;
|
|
|
- String s = null;
|
|
|
- try {
|
|
|
- b = str.getBytes("GB2312");
|
|
|
-// s = URLEncoder.encode(str,"GB2312");
|
|
|
-// str = new String(str.getBytes("UTF-8"), "GB2312");
|
|
|
- } catch (UnsupportedEncodingException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- if (b != null) {
|
|
|
-// s = new BASE64Encoder().encode(b);
|
|
|
- s = Base64.toBase64String(b);
|
|
|
- s= s.replaceAll("\\+","_");
|
|
|
- }
|
|
|
- return s;
|
|
|
- }
|
|
|
-
|
|
|
- // 解密
|
|
|
- public static String getFromBase64(String s) {
|
|
|
- s = s.replaceAll("_", "+");
|
|
|
-
|
|
|
- byte[] b = null;
|
|
|
- String result = null;
|
|
|
- if (s != null) {
|
|
|
- //BASE64Decoder decoder = new BASE64Decoder();
|
|
|
- try {
|
|
|
- //b = decoder.decodeBuffer(s);
|
|
|
- b = Base64.decode(s);
|
|
|
- result = new String(b, "GB2312");
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- private static class JsonUtil2 {
|
|
|
-
|
|
|
- /**
|
|
|
- * 将对象转化为JSON字符串
|
|
|
- *
|
|
|
- * @param object 要转化成json的对象
|
|
|
- * @return 返回Json字符串
|
|
|
- */
|
|
|
- public static String parse(Object object) {
|
|
|
- // TODO 请完成
|
|
|
- if (object == null)
|
|
|
- return "{}";
|
|
|
- Class clazz = object.getClass();
|
|
|
-
|
|
|
- try {
|
|
|
- if (clazz.getName().startsWith("java.lang.String")) { // String字符串
|
|
|
- return parseString(object);
|
|
|
- } else if (clazz.isPrimitive() || clazz.getName().startsWith("java.lang")) { // 基本属性类型及其封装类型
|
|
|
- return parsePrimitive(object);
|
|
|
- } else if (Collection.class.isAssignableFrom(clazz)) { //集合
|
|
|
- return parseCollection(object);
|
|
|
- } else if (Object.class.isAssignableFrom(clazz)) { //其他对象
|
|
|
- return parseObject(object);
|
|
|
- }
|
|
|
- } catch (IllegalAccessException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return "{}";
|
|
|
- }
|
|
|
-
|
|
|
- private static String parseObject(Object object) throws IllegalAccessException {
|
|
|
- StringBuffer tempSb = new StringBuffer(); //用于临时拼接集合的解析
|
|
|
- tempSb.append("{");
|
|
|
-
|
|
|
- Class c = object.getClass();
|
|
|
- Field[] fs = c.getDeclaredFields();
|
|
|
- for (int i = 0; i < fs.length; i++) {//遍历对象的所有属性
|
|
|
- Field field = fs[i];
|
|
|
- field.setAccessible(true);
|
|
|
- String key = field.getName(); // Json字符串的key值
|
|
|
- Object value = field.get(object); // 解析前的值,为Object对象
|
|
|
- if (Collection.class.isAssignableFrom(field.getType())) {
|
|
|
- tempSb.append("\"" + key + "\":" + parseCollection(value));
|
|
|
- continue;
|
|
|
- }
|
|
|
- tempSb.append("\"" + key + "\":" + parse(value));
|
|
|
- if (i != fs.length - 1) { // 当不是最后一个属性时,添加逗号
|
|
|
- tempSb.append(",");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- tempSb.append("}");
|
|
|
- return String.valueOf(tempSb);
|
|
|
- }
|
|
|
-
|
|
|
- private static String parseCollection(Object object) {
|
|
|
- if (object == null) {
|
|
|
- return "[]";
|
|
|
- }
|
|
|
-
|
|
|
- StringBuffer tempSb = new StringBuffer(); //用于临时拼接集合的解析
|
|
|
- tempSb.append("[");
|
|
|
-
|
|
|
- //使用迭代器遍历集合中的对象
|
|
|
- Iterator iterator = ((Collection<?>) object).iterator();
|
|
|
- while (iterator.hasNext()) {
|
|
|
- Object obj = iterator.next();
|
|
|
- tempSb.append(parse(obj));
|
|
|
- if (iterator.hasNext()) {
|
|
|
- tempSb.append(",");
|
|
|
- }
|
|
|
- }
|
|
|
- tempSb.append("]");
|
|
|
- return String.valueOf(tempSb);
|
|
|
- }
|
|
|
-
|
|
|
- private static String parsePrimitive(Object object) {
|
|
|
- return String.valueOf(object);
|
|
|
- }
|
|
|
-
|
|
|
- private static String parseString(Object object) {
|
|
|
- return "\"" + object + "\"";
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-
|