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) { public InvoiceUtil(String fpdm,String fphm) {
if (fpdm != null && fpdm.length() >= 10) {
this.fpdm = fpdm; this.fpdm = fpdm;
this.getFplx(fpdm,fphm); this.getFplx(fpdm,fphm);
} }
}
/** /**
* 根据发票代码获取发票类型 * 根据发票代码获取发票类型
@ -195,7 +193,7 @@ public class InvoiceUtil {
private void getFplx(String fpdm,String fphm) { private void getFplx(String fpdm,String fphm) {
String invoiceTypeCode; String invoiceTypeCode;
if(fpdm != null && StringUtils.isNoneBlank(fpdm) && fphm.length()>10) {
invoiceTypeCode = fpdm.substring(7, 8); invoiceTypeCode = fpdm.substring(7, 8);
if (fpdm.length() == 12) { if (fpdm.length() == 12) {
@ -244,6 +242,10 @@ public class InvoiceUtil {
} else { } else {
fplxdm = null; 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); fillInDate = fillInDate.substring(0, 10);
if (fillInDate != null && StringUtils.isNotBlank(fillInDate)) if (fillInDate != null && StringUtils.isNotBlank(fillInDate))
map.put("invoiceDate", sdf.format(fillInDate)); map.put("invoiceDate", fillInDate);
} }
if (map.get("qsDate") != null) { if (map.get("qsDate") != null) {

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

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

Loading…
Cancel
Save