|
|
|
@ -16,13 +16,11 @@ import com.dxhy.common.util.InvoiceUtil; |
|
|
|
|
import com.dxhy.common.util.UserInfoUtil; |
|
|
|
|
import com.dxhy.common.utils.BaseContextHandler; |
|
|
|
|
import com.dxhy.common.utils.R; |
|
|
|
|
import com.dxhy.erp.entity.TDxInvoiceReimburse; |
|
|
|
|
import com.dxhy.erp.entity.TdxCheckRecordInvoice; |
|
|
|
|
import com.dxhy.erp.entity.TdxRecordInvoice; |
|
|
|
|
import com.dxhy.erp.entity.sdny.*; |
|
|
|
|
import com.dxhy.erp.service.InvoiceQueryService; |
|
|
|
|
import com.dxhy.erp.service.SNPushCheckRecordService; |
|
|
|
|
import com.dxhy.erp.service.SignCheckRecordService; |
|
|
|
|
import com.dxhy.erp.service.SignSaveInvoiceInfoService; |
|
|
|
|
import com.dxhy.erp.service.*; |
|
|
|
|
import com.dxhy.erp.utils.HmacSHA1Util; |
|
|
|
|
import com.dxhy.erp.utils.ServiceResult; |
|
|
|
|
import io.swagger.models.auth.In; |
|
|
|
@ -69,6 +67,9 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
@Resource |
|
|
|
|
private SignCheckRecordService signCheckRecordService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private TDxInvoiceReimburseService tDxInvoiceReimburseService; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查验发票 |
|
|
|
|
*/ |
|
|
|
@ -85,93 +86,112 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
// String userid = getLoginName();
|
|
|
|
|
// String dbName = getUserInfo().getDbName();
|
|
|
|
|
// String company = getUserInfo().getCompany();
|
|
|
|
|
|
|
|
|
|
JSONObject checkInvoiceResult = null; |
|
|
|
|
InvoiceUtil iu = new InvoiceUtil(pramsMap.get("invoiceCode")); |
|
|
|
|
String fplxdm = iu.getFplxdm(); |
|
|
|
|
if(fplxdm != null) { |
|
|
|
|
//查验类发票,执行查验操作后入库
|
|
|
|
|
log.info("查验类发票,执行查验操作后入库"); |
|
|
|
|
//权限校验
|
|
|
|
|
if (pramsMap.get("invoiceNumber").isEmpty()) { |
|
|
|
|
return ResponseEntity.ok(R.error("发票号码不能为空!")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//权限校验
|
|
|
|
|
if (pramsMap.get("invoiceNumber").isEmpty()) { |
|
|
|
|
return ResponseEntity.ok(R.error("发票号码不能为空!")); |
|
|
|
|
} |
|
|
|
|
pramsMap.put("invoiceNo", pramsMap.get("invoiceNumber")); |
|
|
|
|
|
|
|
|
|
pramsMap.put("invoiceNo", pramsMap.get("invoiceNumber")); |
|
|
|
|
if (!pramsMap.get("billingDate").isEmpty()) { |
|
|
|
|
String billingDate = pramsMap.get("billingDate").replaceAll("-", ""); |
|
|
|
|
iu.setKprq(pramsMap.get("billingDate")); |
|
|
|
|
pramsMap.put("invoiceDate", billingDate); |
|
|
|
|
pramsMap.put("billingDate", billingDate); |
|
|
|
|
} else { |
|
|
|
|
return ResponseEntity.ok(R.error("开票日期不能为空!")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!pramsMap.get("billingDate").isEmpty()) { |
|
|
|
|
String billingDate = pramsMap.get("billingDate").replaceAll("-", ""); |
|
|
|
|
iu.setKprq(pramsMap.get("billingDate")); |
|
|
|
|
pramsMap.put("invoiceDate", billingDate); |
|
|
|
|
pramsMap.put("billingDate", billingDate); |
|
|
|
|
} else { |
|
|
|
|
return ResponseEntity.ok(R.error("开票日期不能为空!")); |
|
|
|
|
} |
|
|
|
|
if (pramsMap.get("invoiceType").isEmpty()) { |
|
|
|
|
return ResponseEntity.ok(R.error("开票日期不能为空!")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (pramsMap.get("invoiceType").isEmpty()) { |
|
|
|
|
return ResponseEntity.ok(R.error("开票日期不能为空!")); |
|
|
|
|
} |
|
|
|
|
if (SNFplxEnum.ZP.getSnFplxDm().equals(pramsMap.get("invoiceType")) |
|
|
|
|
|| SNFplxEnum.JDC.getSnFplxDm().equals(pramsMap.get("invoiceType")) |
|
|
|
|
|| SNFplxEnum.DZZP.getSnFplxDm().equals(pramsMap.get("invoiceType")) |
|
|
|
|
|| SNFplxEnum.ESC.getSnFplxDm().equals(pramsMap.get("invoiceType")) |
|
|
|
|
|| SNFplxEnum.QDZP.getSnFplxDm().equals(pramsMap.get("invoiceType")) |
|
|
|
|
|| SNFplxEnum.QDPP.getSnFplxDm().equals(pramsMap.get("invoiceType"))) { |
|
|
|
|
if (pramsMap.get("totalAmount").isEmpty()) { |
|
|
|
|
return ResponseEntity.ok(R.error("金额不能为空!")); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if (pramsMap.get("checkCode").isEmpty()) { |
|
|
|
|
return ResponseEntity.ok(R.error("校验码不能为空!")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (SNFplxEnum.ZP.getSnFplxDm().equals(pramsMap.get("invoiceType")) |
|
|
|
|
|| SNFplxEnum.JDC.getSnFplxDm().equals(pramsMap.get("invoiceType")) |
|
|
|
|
|| SNFplxEnum.DZZP.getSnFplxDm().equals(pramsMap.get("invoiceType")) |
|
|
|
|
|| SNFplxEnum.ESC.getSnFplxDm().equals(pramsMap.get("invoiceType")) |
|
|
|
|
|| SNFplxEnum.QDZP.getSnFplxDm().equals(pramsMap.get("invoiceType")) |
|
|
|
|
|| SNFplxEnum.QDPP.getSnFplxDm().equals(pramsMap.get("invoiceType"))) { |
|
|
|
|
if (pramsMap.get("totalAmount").isEmpty()) { |
|
|
|
|
return ResponseEntity.ok(R.error("金额不能为空!")); |
|
|
|
|
if ("10107".equals(pramsMap.get("invoiceType")) || "10108".equals(pramsMap.get("invoiceType"))) { |
|
|
|
|
pramsMap.put("invoiceType", "21"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if (pramsMap.get("checkCode").isEmpty()) { |
|
|
|
|
return ResponseEntity.ok(R.error("校验码不能为空!")); |
|
|
|
|
|
|
|
|
|
log.info("发票类型为:{}", pramsMap.get("invoiceType")); |
|
|
|
|
|
|
|
|
|
String uuid = (StringUtils.isBlank(pramsMap.get("invoiceCode")) ? "" : pramsMap.get("invoiceCode")) + pramsMap.get("invoiceNo"); |
|
|
|
|
String notes = invoiceQueryService.checkingInvoiceInfo("business", uuid, getUserInfo()); |
|
|
|
|
if (notes != null) { |
|
|
|
|
return ResponseEntity.ok(R.error(notes)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ("10107".equals(pramsMap.get("invoiceType")) || "10108".equals(pramsMap.get("invoiceType"))){ |
|
|
|
|
pramsMap.put("invoiceType","21"); |
|
|
|
|
} |
|
|
|
|
//查询底账库是否有对应发票,有则直接返回
|
|
|
|
|
TdxCheckRecordInvoice checkInvoiceByUuid = signCheckRecordService.getCheckInvoiceByUuid(uuid); |
|
|
|
|
if (checkInvoiceByUuid != null) { |
|
|
|
|
R data = new R(1000, "default success"); |
|
|
|
|
|
|
|
|
|
log.info("发票类型为:{}",pramsMap.get("invoiceType")); |
|
|
|
|
String checkInvoice = JSONObject.toJSONString(checkInvoiceByUuid); |
|
|
|
|
data.put("data", checkInvoice); |
|
|
|
|
|
|
|
|
|
String uuid = (StringUtils.isBlank(pramsMap.get("invoiceCode")) ? "" : pramsMap.get("invoiceCode")) + pramsMap.get("invoiceNo"); |
|
|
|
|
String notes = invoiceQueryService.checkingInvoiceInfo("business", uuid, getUserInfo()); |
|
|
|
|
if (notes != null) { |
|
|
|
|
return ResponseEntity.ok(R.error(notes)); |
|
|
|
|
} |
|
|
|
|
return ResponseEntity.ok(data); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//查询底账库是否有对应发票,有则直接返回
|
|
|
|
|
TdxCheckRecordInvoice checkInvoiceByUuid = signCheckRecordService.getCheckInvoiceByUuid(uuid); |
|
|
|
|
if (checkInvoiceByUuid != null) { |
|
|
|
|
R data = new R(1000, "default success"); |
|
|
|
|
|
|
|
|
|
String checkInvoice = JSONObject.toJSONString(checkInvoiceByUuid); |
|
|
|
|
data.put("data", checkInvoice); |
|
|
|
|
try { |
|
|
|
|
checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(data); |
|
|
|
|
} |
|
|
|
|
if (!checkInvoiceResult.containsKey("code")) { |
|
|
|
|
R data = new R(1000, "default success"); |
|
|
|
|
data.put("message", "success"); |
|
|
|
|
data.put("data", checkInvoiceResult); |
|
|
|
|
|
|
|
|
|
JSONObject checkInvoiceResult = null; |
|
|
|
|
try { |
|
|
|
|
checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
if (!checkInvoiceResult.containsKey("cyjg")) { |
|
|
|
|
|
|
|
|
|
if (!checkInvoiceResult.containsKey("code")) { |
|
|
|
|
R data = new R(1000, "default success"); |
|
|
|
|
data.put("message","success"); |
|
|
|
|
data.put("data", checkInvoiceResult); |
|
|
|
|
checkInvoiceResult.put("invoiceNo", checkInvoiceResult.getString("invoiceNumber")); |
|
|
|
|
checkInvoiceResult.put("company", company); |
|
|
|
|
log.info("返回给影像系统的结果为:{}", checkInvoiceResult); |
|
|
|
|
signSaveInvoiceInfoService.saveQueryInvoiceResult(checkInvoiceResult, userid, "1", dbName); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(data); |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
//其他类发票,直接入库
|
|
|
|
|
log.info("其他类发票,不做查验,直接入库"); |
|
|
|
|
TDxInvoiceReimburse reimburse = new TDxInvoiceReimburse(); |
|
|
|
|
int insert = tDxInvoiceReimburseService.getBaseMapper().insert(reimburse); |
|
|
|
|
|
|
|
|
|
if (!checkInvoiceResult.containsKey("cyjg")) { |
|
|
|
|
R data = new R(1000, "default success"); |
|
|
|
|
data.put("message", "success"); |
|
|
|
|
|
|
|
|
|
checkInvoiceResult.put("invoiceNo",checkInvoiceResult.getString("invoiceNumber")); |
|
|
|
|
checkInvoiceResult.put("company",company); |
|
|
|
|
log.info("返回给影像系统的结果为:{}",checkInvoiceResult); |
|
|
|
|
signSaveInvoiceInfoService.saveQueryInvoiceResult(checkInvoiceResult, userid, "1", dbName); |
|
|
|
|
if (insert>0) { |
|
|
|
|
checkInvoiceResult.put("invoiceNo", checkInvoiceResult.getString("invoiceNumber")); |
|
|
|
|
checkInvoiceResult.put("company", company); |
|
|
|
|
checkInvoiceResult.put("message", "入库成功"); |
|
|
|
|
log.info("返回给影像系统的结果为:{}", checkInvoiceResult); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
data.put("data", checkInvoiceResult); |
|
|
|
|
return ResponseEntity.ok(data); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//价税分离
|
|
|
|
|
//snPushCheckRecordService.valoremTaxCount();
|
|
|
|
|
} |
|
|
|
|
return ResponseEntity.ok(R.error().put("data", checkInvoiceResult)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -188,6 +208,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
String userid = "101833"; |
|
|
|
|
String dbName = "business"; |
|
|
|
|
String company = "BIGB"; |
|
|
|
|
String taxNo = "9111112222333344DD"; |
|
|
|
|
|
|
|
|
|
// // 入参统一在入口处理
|
|
|
|
|
// String userid = getLoginName();
|
|
|
|
@ -200,56 +221,27 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
String result = ""; |
|
|
|
|
//入票池
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
Integer integer = snPushCheckRecordService.pushInvoiceToRecordInvoice2(snRequestObject); |
|
|
|
|
|
|
|
|
|
//推送到SAP
|
|
|
|
|
List<SNInvoice> invoiceInfoList = snRequestObject.getInvoiceInfoList(); |
|
|
|
|
|
|
|
|
|
String imageId = snRequestObject.getImageId(); |
|
|
|
|
String compCode = snRequestObject.getCompCode(); |
|
|
|
|
|
|
|
|
|
TDxInvoiceReimburse reimburse = new TDxInvoiceReimburse(); |
|
|
|
|
reimburse.setImageId(imageId); |
|
|
|
|
reimburse.setCompCode(compCode); |
|
|
|
|
|
|
|
|
|
if (invoiceInfoList != null && invoiceInfoList.size() > 0) { |
|
|
|
|
for (SNInvoice invoice : invoiceInfoList) { |
|
|
|
|
String fplxdm = ""; |
|
|
|
|
String snFplx = ""; |
|
|
|
|
String invoiceCode = invoice.getInvoiceCode(); |
|
|
|
|
if(StringUtils.isNoneBlank(invoiceCode)) { |
|
|
|
|
InvoiceUtil iu = new InvoiceUtil(invoiceCode); |
|
|
|
|
fplxdm = iu.getFplxdm(); |
|
|
|
|
}else{ |
|
|
|
|
|
|
|
|
|
snFplx = invoice.getInvoiceType(); |
|
|
|
|
|
|
|
|
|
if(SNFplxEnum.HCP.getSnFplxDm().equals(snFplx)){ |
|
|
|
|
fplxdm = "92"; |
|
|
|
|
invoice.setInvoiceType(fplxdm); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(SNFplxEnum.KYQCP.getSnFplxDm().equals(snFplx)){ |
|
|
|
|
fplxdm = "94"; |
|
|
|
|
invoice.setInvoiceType(fplxdm); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(SNFplxEnum.JPXCD.getSnFplxDm().equals(snFplx)){ |
|
|
|
|
fplxdm = "90"; |
|
|
|
|
invoice.setInvoiceType(fplxdm); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//价税分离
|
|
|
|
|
if(SNFplxEnum.HCP.getFplxDm().equals(fplxdm) || SNFplxEnum.KYQCP.getFplxDm().equals(fplxdm) || SNFplxEnum.JPXCD.getFplxDm().equals(fplxdm)){ |
|
|
|
|
InvoiceInfo invoiceInfo = convertToInvoiceInfo(invoice); |
|
|
|
|
ServiceResult<InvoiceInfo> invoiceResult = snPushCheckRecordService.valoremTaxCount(invoiceInfo, "Y"); |
|
|
|
|
InvoiceInfo data = invoiceResult.getData(); |
|
|
|
|
|
|
|
|
|
invoice.setIsDeductible(data.getIsDeductible()); |
|
|
|
|
invoice.setTaxRate(data.getTaxRate()); |
|
|
|
|
invoice.setTotalAmount(data.getInvoiceAmount().toString()); |
|
|
|
|
invoice.setTotalTax(data.getTaxAmount().toString()); |
|
|
|
|
} |
|
|
|
|
String invoiceNo = invoice.getInvoiceNumber(); |
|
|
|
|
reimburse = snPushCheckRecordService.updateInvoicePoll(snRequestObject, company, taxNo, reimburse, invoice, fplxdm, invoiceCode, invoiceNo); |
|
|
|
|
|
|
|
|
|
//推送到SAP
|
|
|
|
|
SNSAPObject object = convertToSapOnject(invoice, imageId,compCode); |
|
|
|
|
log.info("推送山能数据:{}",JSONObject.toJSONString(object)); |
|
|
|
|
|
|
|
|
@ -276,6 +268,12 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
return ResponseEntity.ok(R.error(CommonConstants.MSG_ERR_DEFAULT)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查验发票 |
|
|
|
|
*/ |
|
|
|
@ -305,38 +303,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
return signature; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private InvoiceInfo convertToInvoiceInfo(SNInvoice snInvoice) { |
|
|
|
|
InvoiceInfo invoice = new InvoiceInfo(); |
|
|
|
|
invoice.setInvoiceTypeCode(snInvoice.getInvoiceType()); |
|
|
|
|
|
|
|
|
|
Date date = new Date(); |
|
|
|
|
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
|
try { |
|
|
|
|
date = ft.parse(snInvoice.getBillingDate()); |
|
|
|
|
} catch (ParseException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
invoice.setInvoiceDate(date); |
|
|
|
|
|
|
|
|
|
invoice.setIdentityNumber(snInvoice.getIdcardNo()); |
|
|
|
|
invoice.setPassenger(snInvoice.getRiderName()); |
|
|
|
|
invoice.setDepartCity(snInvoice.getStationGetOn()); |
|
|
|
|
invoice.setArriveCity(snInvoice.getStationGetOff()); |
|
|
|
|
if("92".equals(invoice.getInvoiceTypeCode())){ |
|
|
|
|
if(snInvoice.getAmountTax() != null) |
|
|
|
|
invoice.setInvoiceAmount(new BigDecimal(snInvoice.getAmountTax())); |
|
|
|
|
} |
|
|
|
|
if("90".equals(invoice.getInvoiceTypeCode())) { |
|
|
|
|
invoice.setFare(snInvoice.getNoTaxAmount()); |
|
|
|
|
invoice.setFuelSurcharge(snInvoice.getFuelSurcharge()); |
|
|
|
|
} |
|
|
|
|
if(snInvoice.getNoTaxAmount() != null){ |
|
|
|
|
BigDecimal amount = new BigDecimal(snInvoice.getNoTaxAmount()); |
|
|
|
|
invoice.setInvoiceAmount(amount); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return invoice; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private SNSAPObject convertToSapOnject(SNInvoice snInvoice, String imageId,String compCode) { |
|
|
|
|
|
|
|
|
|