Merge remote-tracking branch 'origin/dev0310' into dev0310

release
zhenghaiyang@ele-cloud.com 2 years ago
commit 8704527ea8
  1. 8
      dxhy-common/src/main/java/com/dxhy/common/util/InvoiceUtil.java
  2. 2
      dxhy-customs/src/main/java/com/dxhy/customs/service/impl/CustomsSignServiceImpl.java
  3. 58
      dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java
  4. 38
      dxhy-erp/src/main/java/com/dxhy/erp/service/SNPushCheckRecordService.java
  5. 6
      dxhy-erp/src/main/java/com/dxhy/erp/service/impl/GatherServiceImpl.java

@ -108,11 +108,9 @@ public class InvoiceUtil {
}
public InvoiceUtil(String fpdm,String fphm) {
if (fpdm != null && fpdm.length() >= 10) {
this.fpdm = fpdm;
this.getFplx(fpdm,fphm);
}
}
/**
* 根据发票代码获取发票类型
@ -195,7 +193,7 @@ public class InvoiceUtil {
private void getFplx(String fpdm,String fphm) {
String invoiceTypeCode;
if(fpdm != null && StringUtils.isNoneBlank(fpdm) && fphm.length()>10) {
invoiceTypeCode = fpdm.substring(7, 8);
if (fpdm.length() == 12) {
@ -244,6 +242,10 @@ public class InvoiceUtil {
} else {
fplxdm = null;
}
}else if (StringUtils.isBlank(fpdm) && fphm.length() == 20) {
fplxdm = FplxEnum.QDZZP.getFplxDm();
fplxmc = FplxEnum.QDZZP.getFplxMc(FplxEnum.QDPP.getIndex());
}
}

@ -563,7 +563,7 @@ public class CustomsSignServiceImpl extends MpBaseServiceImpl<CustomsRecordDao,
fillInDate = fillInDate.substring(0, 10);
if (fillInDate != null && StringUtils.isNotBlank(fillInDate))
map.put("invoiceDate", sdf.format(fillInDate));
map.put("invoiceDate", fillInDate);
}
if (map.get("qsDate") != null) {

@ -76,7 +76,7 @@ public class SDNYMainProcessController extends AbstractController {
@PostMapping("/sn/singleInvoiceCheck")
@ResponseBody
@SysLog("发票查验")
public ResponseEntity<Map<String,Object>> singleInvoiceCheck(@RequestBody Map<String, String> pramsMap) {
public ResponseEntity<String> singleInvoiceCheck(@RequestBody Map<String, String> pramsMap) {
log.info("传入的参数为:{}",pramsMap);
String userid = "101833";
String dbName = "business";
@ -89,12 +89,12 @@ public class SDNYMainProcessController extends AbstractController {
JSONObject checkInvoiceResult = null;
InvoiceUtil iu = new InvoiceUtil(pramsMap.get("invoiceCode"));
String fplxdm = iu.getFplxdm();
if(fplxdm != null) {
if(fplxdm != null || "10107".equals(pramsMap.get("invoiceType")) || "10108".equals(pramsMap.get("invoiceType"))) {
//查验类发票,执行查验操作后入库
log.info("查验类发票,执行查验操作后入库");
//权限校验
if (pramsMap.get("invoiceNumber").isEmpty()) {
return ResponseEntity.ok(R.error("发票号码不能为空!"));
return ResponseEntity.ok(JSONObject.toJSONString(R.error("发票号码不能为空!")));
}
pramsMap.put("invoiceNo", pramsMap.get("invoiceNumber"));
@ -105,11 +105,11 @@ public class SDNYMainProcessController extends AbstractController {
pramsMap.put("invoiceDate", billingDate);
pramsMap.put("billingDate", billingDate);
} else {
return ResponseEntity.ok(R.error("开票日期不能为空!"));
return ResponseEntity.ok(JSONObject.toJSONString(R.error("开票日期不能为空!")));
}
if (pramsMap.get("invoiceType").isEmpty()) {
return ResponseEntity.ok(R.error("开票日期不能为空!"));
return ResponseEntity.ok(JSONObject.toJSONString(R.error("开票日期不能为空!")));
}
if (SNFplxEnum.ZP.getSnFplxDm().equals(pramsMap.get("invoiceType"))
@ -119,11 +119,11 @@ public class SDNYMainProcessController extends AbstractController {
|| SNFplxEnum.QDZP.getSnFplxDm().equals(pramsMap.get("invoiceType"))
|| SNFplxEnum.QDPP.getSnFplxDm().equals(pramsMap.get("invoiceType"))) {
if (pramsMap.get("totalAmount").isEmpty()) {
return ResponseEntity.ok(R.error("金额不能为空!"));
return ResponseEntity.ok(JSONObject.toJSONString(R.error("金额不能为空!")));
}
} else {
if (pramsMap.get("checkCode").isEmpty()) {
return ResponseEntity.ok(R.error("校验码不能为空!"));
return ResponseEntity.ok(JSONObject.toJSONString(R.error("校验码不能为空!")));
}
}
@ -136,7 +136,7 @@ public class SDNYMainProcessController extends AbstractController {
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(JSONObject.toJSONString(R.error(notes)));
}
//查询底账库是否有对应发票,有则直接返回
@ -147,7 +147,7 @@ public class SDNYMainProcessController extends AbstractController {
String checkInvoice = JSONObject.toJSONString(checkInvoiceByUuid);
data.put("data", checkInvoice);
return ResponseEntity.ok(data);
return ResponseEntity.ok(JSONObject.toJSONString(data));
}
@ -170,7 +170,7 @@ public class SDNYMainProcessController extends AbstractController {
signSaveInvoiceInfoService.saveQueryInvoiceResult(checkInvoiceResult, userid, "1", dbName);
}
return ResponseEntity.ok(data);
return ResponseEntity.ok(JSONObject.toJSONString(data));
}
}else{
//其他类发票,直接入库
@ -189,10 +189,10 @@ public class SDNYMainProcessController extends AbstractController {
}
data.put("data", checkInvoiceResult);
return ResponseEntity.ok(data);
return ResponseEntity.ok(JSONObject.toJSONString(data));
}
return ResponseEntity.ok(R.error().put("data", checkInvoiceResult));
return ResponseEntity.ok(JSONObject.toJSONString(R.error().put("data", checkInvoiceResult)));
}
/**
@ -201,7 +201,7 @@ public class SDNYMainProcessController extends AbstractController {
@PostMapping("/sn/syncInvoiceInfo")
@ResponseBody
@SysLog("同步发票信息")
public ResponseEntity<Map<String,Object>> syncInvoiceInfo(@RequestBody SNRequestObject snRequestObject) {
public ResponseEntity<String> syncInvoiceInfo(@RequestBody SNRequestObject snRequestObject) {
log.info("影像系统同步数据:{}",JSONObject.toJSONString(snRequestObject));
@ -239,7 +239,13 @@ public class SDNYMainProcessController extends AbstractController {
String snFplx = "";
String invoiceCode = invoice.getInvoiceCode();
String invoiceNo = invoice.getInvoiceNumber();
reimburse = snPushCheckRecordService.updateInvoicePoll(snRequestObject, company, taxNo, reimburse, invoice, fplxdm, invoiceCode, invoiceNo);
result = snPushCheckRecordService.updateInvoicePoll(snRequestObject, company, taxNo, reimburse, invoice, fplxdm, invoiceCode, invoiceNo);
if(!"ok".equals(result) && !"0000".equals(result)){
R data = new R(1000, "default success");
data.put("data", result);
return ResponseEntity.ok(JSONObject.toJSONString(data));
}
//推送到SAP
SNSAPObject object = convertToSapOnject(invoice, imageId,compCode);
@ -254,18 +260,18 @@ public class SDNYMainProcessController extends AbstractController {
} catch (Exception e) {
e.printStackTrace();
log.error("", e);
return ResponseEntity.ok(R.error(CommonConstants.MSG_ERR_PUSH_SDNY));
return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_PUSH_SDNY)));
}
}
}
R data = new R(1000, "default success");
data.put("data", result);
return ResponseEntity.ok(data);
return ResponseEntity.ok(JSONObject.toJSONString(data));
} catch (Exception e) {
e.printStackTrace();
}
return ResponseEntity.ok(R.error(CommonConstants.MSG_ERR_DEFAULT));
return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_DEFAULT)));
}
@ -289,16 +295,14 @@ public class SDNYMainProcessController extends AbstractController {
String dataExchangeId = paramMap.get("dataExchangeId");
TreeMap<String, String> sortMap = new TreeMap<>();
sortMap.put(ConfigurerInfo.SECRETID, secretId);
sortMap.put(ConfigurerInfo.DATA_EXCHANGE_ID, dataExchangeId);
sortMap.put(ConfigurerInfo.ENCRYPTCODE, "0");
sortMap.put(ConfigurerInfo.ZIPCODE, "0");
sortMap.put(ConfigurerInfo.CONTENT, content);
sortMap.put("SecretId", secretId);
sortMap.put("dataExchangeId", dataExchangeId);
sortMap.put("encryptCode", "0");
sortMap.put("zipCode", "0");
sortMap.put("content", content);
String url = "POST"+ ip +"/invoice/jxpt/api/v5/"+ apiCode +"?";
String data = "POST"+ ip +"/invoice/jxpt/api/v5/"+ apiCode +"?SecretId="+ secretId + "&content="+ content +"&dataExchangeId="+ dataExchangeId +"&encryptCode=0&zipCode=0";
String signature = HmacSHA1Util.genSign(url, sortMap,secretKey);
return signature;
}
@ -332,7 +336,7 @@ public class SDNYMainProcessController extends AbstractController {
info.setZJKZM(snInvoice.getImportCertificateNo());
info.setZDJZH(snInvoice.getCertificateNo());
info.setZGFMC(snInvoice.getPurchaserName());
if(snInvoice.getTotalAmount() != null && snInvoice.getTotalAmount() != null) {
if(snInvoice.getTotalAmount() != null && snInvoice.getTotalTax() != null) {
BigDecimal total = new BigDecimal(snInvoice.getTotalAmount());
BigDecimal tax = new BigDecimal(snInvoice.getTotalTax());
BigDecimal subtract = total.subtract(tax);
@ -384,7 +388,11 @@ public class SDNYMainProcessController extends AbstractController {
sapInvoiceDetail.setZSL(snInvoiceDetail.getQuantity());
sapInvoiceDetail.setZSM(info.getZSM());
sapInvoiceDetail.setZGGXH(snInvoiceDetail.getSpecificationModel());
if(snInvoice.getInvoiceCode() != null) {
sapInvoiceDetail.setZTID(snInvoice.getInvoiceCode() + snInvoice.getInvoiceNumber());
}else{
sapInvoiceDetail.setZTID(snInvoice.getInvoiceNumber());
}
sapInvoiceDetailList.add(sapInvoiceDetail);
}

@ -157,7 +157,9 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
recordInvoice.setInvoiceCode(fpdm);
recordInvoice.setInvoiceNo(fphm);
recordInvoice.setInvoiceAmount(new BigDecimal(je));
if(se != null) {
recordInvoice.setTaxAmount(new BigDecimal(se));
}
recordInvoice.setXfTaxNo(xfsh);
recordInvoice.setGfTaxNo(gfsbh);
recordInvoice.setGfName(gfmc);
@ -504,15 +506,17 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
int index = taxRateDetail.indexOf("%");
if (index > 0) {
taxRateDetail = taxRateDetail.substring(0, taxRateDetail.length() - 1);
int num = Integer.parseInt(taxRateDetail);
Float num = Float.parseFloat(taxRateDetail);
if (num > 9) {
taxRateDetail = "0." + taxRateDetail;
} else {
if(!taxRateDetail.startsWith("0")){
taxRateDetail = "0.0" + taxRateDetail;
}
}
}
}
}
if ("11".equals(invoiceType)) {
taxRateDetail = "0.000";
@ -549,7 +553,8 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
return jsonObject;
}
public TDxInvoiceReimburse updateInvoicePoll(@RequestBody SNRequestObject snRequestObject, String company, String taxNo, TDxInvoiceReimburse reimburse, SNInvoice invoice, String fplxdm, String invoiceCode, String invoiceNo) throws Exception {
public String updateInvoicePoll(@RequestBody SNRequestObject snRequestObject, String company, String taxNo, TDxInvoiceReimburse reimburse, SNInvoice invoice, String fplxdm, String invoiceCode, String invoiceNo) throws Exception {
String result = "0000";
//判断发票类型
fplxdm = getFplx(invoice, fplxdm);
@ -559,13 +564,26 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
|| SNFplxEnum.JPXCD.getFplxDm().equals(fplxdm) || SNFplxEnum.CP.getFplxDm().equals(fplxdm)
|| SNFplxEnum.KYQCP.getFplxDm().equals(fplxdm)) {
InvoiceInfo invoiceInfo = convertToInvoiceInfo(invoice);
log.info("进行价税分离的发票信息为:{}", invoiceInfo);
ServiceResult<InvoiceInfo> invoiceResult = this.valoremTaxCount(invoiceInfo, "Y");
InvoiceInfo data = invoiceResult.getData();
if (data != null) {
invoice.setIsDeductible(data.getIsDeductible());
invoice.setTaxRate(data.getTaxRate());
if(data.getInvoiceAmount() != null) {
invoice.setTotalAmount(data.getInvoiceAmount().toString());
}
if(data.getTaxAmount() != null) {
invoice.setTotalTax(data.getTaxAmount().toString());
}
}
if (!"ok".equals(invoiceResult.getMsg()) && !"0000".equals(invoiceResult.getMsg())) {
log.info("价税分离失败:{}",invoiceResult.getMsg());
return invoiceResult.getMsg();
}
reimburse = convertToReimburse(invoice, reimburse, fplxdm, company);
@ -598,7 +616,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
}
}
return reimburse;
return result;
}
private TDxInvoiceReimburse convertToReimburse(SNInvoice invoice, TDxInvoiceReimburse reimburse, String fplxdm, String company) {
@ -768,11 +786,11 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
}
// 校验客票可抵扣条件
ServiceResult<?> result = checkIsDeduction(invoiceInfo);
if (!result.getResult()) {
logger.error("客票价税计算失败:" + result.getMsg());
return fail(result.getMsg());
}
// ServiceResult<?> result = checkIsDeduction(invoiceInfo);
// if (!result.getResult()) {
// logger.error("客票价税计算失败:" + result.getMsg());
// return fail(result.getMsg());
// }
// 设置可抵扣标识
invoiceInfo.setIsDeductible(isDeductible);
// 设置税率
@ -802,11 +820,13 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
}
// 铁路客票:税额=票面金额÷(1+9%)×9%
} else if (invoiceInfo.getInvoiceTypeCode().equals(Constant.RAILWAY_TICKET_CODE)) {
if (invoiceInfo.getInvoiceAmount() != null)
invoiceInfo.setTaxAmount(invoiceInfo.getInvoiceAmount()
.divide(new BigDecimal("1.09"), 6, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("0.09")));
// 公路、水路、其他客票:税额=票面金额÷(1+3%)×3%
} else if (!invoiceInfo.getInvoiceTypeCode().equals(Constant.VALUE_ADDED_TAX_INVOICE_ELECTRONIC_CODE)
&& !invoiceInfo.getInvoiceTypeCode().equals(Constant.VALUE_ADDED_TAX_INVOICE_ELECTRONIC_PASSENGER_CODE)) {
if (invoiceInfo.getInvoiceAmount() != null)
invoiceInfo.setInvoiceAmount(invoiceInfo.getInvoiceAmount()
.divide(new BigDecimal("1.03"), 6, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("0.03")));
}

@ -749,10 +749,8 @@ public class GatherServiceImpl extends MpBaseServiceImpl<TdxRecordInvoiceDao, Td
String dbName = "business";
DynamicContextHolder.push(dbName + DbConstant.BUSINESS_READ);
Map<String, String> param = JSONObject.parseObject(map.get("data").getBytes(),Map.class);
ResponseEntity<?> responseEntity = mainService.singleInvoiceCheck(param);
String body = responseEntity.getBody().toString();
body = body.replaceAll("=",":");
ResponseEntity<String> responseEntity = mainService.singleInvoiceCheck(param);
String body = responseEntity.getBody();
// Map<String, String> resultMap = Arrays.asList(body.split("=")).stream()
// .map(elem -> elem.split(":"))

Loading…
Cancel
Save