|
|
|
@ -110,6 +110,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private RequestRecordService requestRecordService; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查验发票 |
|
|
|
|
*/ |
|
|
|
@ -122,7 +123,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
String dbName = "business"; |
|
|
|
|
JSONObject checkInvoiceResult = null; |
|
|
|
|
RequestRecord singleInvoiceCheckRecord = requestRecordService.getBaseRequestRecord(JSONObject.toJSONString(pramsMap), |
|
|
|
|
"/singleInvoiceCheck",pramsMap.get("invoiceCode"),pramsMap.get("invoiceNumber"), "singleInvoiceCheck"); |
|
|
|
|
"/singleInvoiceCheck", pramsMap.get("invoiceCode"), pramsMap.get("invoiceNumber"), "singleInvoiceCheck"); |
|
|
|
|
|
|
|
|
|
//挡板开关
|
|
|
|
|
if ("1".equals(isPresure)) { |
|
|
|
@ -139,7 +140,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
requestRecordService.saveSuccessfulRequestRecord(singleInvoiceCheckRecord, JSONObject.toJSONString(data)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}",e); |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}", e); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -156,9 +157,9 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord,0,JSONObject.toJSONString(R.error("发票号码不能为空!")), "发票号码不能为空!"); |
|
|
|
|
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 0, JSONObject.toJSONString(R.error("发票号码不能为空!")), "发票号码不能为空!"); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}",e); |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}", e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("发票号码不能为空!"))); |
|
|
|
@ -175,10 +176,10 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord,0, |
|
|
|
|
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 0, |
|
|
|
|
JSONObject.toJSONString(R.error("开票日期不能为空!")), "开票日期不能为空!"); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}",e); |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}", e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("开票日期不能为空!"))); |
|
|
|
@ -188,10 +189,10 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord,0, |
|
|
|
|
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 0, |
|
|
|
|
JSONObject.toJSONString(R.error("发票类型不能为空!")), "发票类型不能为空!"); |
|
|
|
|
} catch (BaseException e) { |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}",e); |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}", e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("发票类型不能为空!"))); |
|
|
|
@ -207,10 +208,10 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord,0, |
|
|
|
|
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 0, |
|
|
|
|
JSONObject.toJSONString(R.error("金额不能为空!")), "金额不能为空!"); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}",e); |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}", e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("金额不能为空!"))); |
|
|
|
@ -220,10 +221,10 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord,0, |
|
|
|
|
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 0, |
|
|
|
|
JSONObject.toJSONString(R.error("校验码不能为空!")), "校验码不能为空!"); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}",e); |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}", e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("校验码不能为空!"))); |
|
|
|
@ -243,10 +244,10 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord,0, |
|
|
|
|
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 0, |
|
|
|
|
JSONObject.toJSONString(R.error(notes)), notes); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}",e); |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}", e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error(notes))); |
|
|
|
@ -264,12 +265,19 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
String invoiceNo = checkInvoiceByUuid.getInvoiceNo(); |
|
|
|
|
QueryWrapper<BaseTDxRecordInvoiceDetail> detailWrapper = new QueryWrapper<>(); |
|
|
|
|
detailWrapper.eq("uuid", uuid); |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.DETAIL_READ); |
|
|
|
|
List<BaseTDxRecordInvoiceDetail> baseTDxRecordInvoiceDetail = baseTDxRecordInvoiceDetailDao.selectList(detailWrapper); |
|
|
|
|
|
|
|
|
|
List<BaseTDxRecordInvoiceDetail> baseTDxRecordInvoiceDetail = null; |
|
|
|
|
List<TDxVehicleSaleInvoice> vehicleList = null; |
|
|
|
|
if ("10104".equals(pramsMap.get("invoiceType")) || "10105".equals(pramsMap.get("invoiceType"))) { |
|
|
|
|
vehicleList = snPushCheckRecordService.vihicleList(uuid); |
|
|
|
|
} else { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.DETAIL_READ); |
|
|
|
|
baseTDxRecordInvoiceDetail = baseTDxRecordInvoiceDetailDao.selectList(detailWrapper); |
|
|
|
|
} |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_READ); |
|
|
|
|
|
|
|
|
|
if(baseTDxRecordInvoiceDetail == null || baseTDxRecordInvoiceDetail.size() == 0){ |
|
|
|
|
checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap,null); |
|
|
|
|
if ((baseTDxRecordInvoiceDetail == null || baseTDxRecordInvoiceDetail.size() == 0) && (vehicleList == null || vehicleList.size() == 0)) { |
|
|
|
|
checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap, null); |
|
|
|
|
|
|
|
|
|
List<String> activeCallRequest = new ArrayList<>(); |
|
|
|
|
activeCallRequest.add(JSONObject.toJSONString(pramsMap)); |
|
|
|
@ -282,23 +290,27 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
if (!checkInvoiceResult.containsKey("cyjg")) { |
|
|
|
|
//先删除原有主数据,再查验更新主数据和明细数据
|
|
|
|
|
int delete = baseTDxRecordInvoiceDao.delete(recordWrapper); |
|
|
|
|
if(delete > 0) { |
|
|
|
|
if (delete > 0) { |
|
|
|
|
checkInvoiceResult.put("invoiceNo", checkInvoiceResult.getString("invoiceNumber")); |
|
|
|
|
signSaveInvoiceInfoService.saveQueryInvoiceResult(checkInvoiceResult, userid, "1", dbName); |
|
|
|
|
if ("10104".equals(pramsMap.get("invoiceType")) || "10105".equals(pramsMap.get("invoiceType"))) { |
|
|
|
|
vehicleList = snPushCheckRecordService.vihicleList(uuid); |
|
|
|
|
} else { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.DETAIL_READ); |
|
|
|
|
baseTDxRecordInvoiceDetail = baseTDxRecordInvoiceDetailDao.selectList(detailWrapper); |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_READ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.DETAIL_READ); |
|
|
|
|
baseTDxRecordInvoiceDetail = baseTDxRecordInvoiceDetailDao.selectList(detailWrapper); |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_READ); |
|
|
|
|
} |
|
|
|
|
}else if (checkInvoiceResult.containsKey("cyjg") && !"0001".equals(checkInvoiceResult.getString("cyjg"))) { |
|
|
|
|
} else if (checkInvoiceResult.containsKey("cyjg") && !"0001".equals(checkInvoiceResult.getString("cyjg"))) { |
|
|
|
|
data = errorInfo(checkInvoiceResult, data); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 0,JSONObject.toJSONString(data), |
|
|
|
|
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 0, JSONObject.toJSONString(data), |
|
|
|
|
(String) checkInvoiceResult.get("cyjgxx")); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}",e); |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}", e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
@ -308,8 +320,12 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
} |
|
|
|
|
JSONObject checkInvoice = (JSONObject) JSONObject.toJSON(checkInvoiceByUuid); |
|
|
|
|
JSONArray checkInvoiceDetail = (JSONArray) JSONObject.toJSON(baseTDxRecordInvoiceDetail); |
|
|
|
|
JSONObject vehicleDetail = new JSONObject(); |
|
|
|
|
if(vehicleList != null && vehicleList.size() > 0) { |
|
|
|
|
vehicleDetail = (JSONObject) JSONObject.toJSON(vehicleList.get(0)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
convertToResult(checkInvoice, checkInvoiceDetail); |
|
|
|
|
convertToResult(checkInvoice, checkInvoiceDetail, vehicleDetail); |
|
|
|
|
|
|
|
|
|
data.put("data", checkInvoice); |
|
|
|
|
//查验结果保存
|
|
|
|
@ -319,14 +335,14 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
if (checkInvoiceResult != null) { |
|
|
|
|
if (checkInvoiceResult.containsKey("code")) { |
|
|
|
|
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 0,JSONObject.toJSONString(data), |
|
|
|
|
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 0, JSONObject.toJSONString(data), |
|
|
|
|
(String) checkInvoiceResult.get("message")); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
requestRecordService.saveSuccessfulRequestRecord(singleInvoiceCheckRecord,JSONObject.toJSONString(data)); |
|
|
|
|
requestRecordService.saveSuccessfulRequestRecord(singleInvoiceCheckRecord, JSONObject.toJSONString(data)); |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}",e); |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}", e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
@ -357,7 +373,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
requestRecordService.saveSuccessfulRequestRecord(singleInvoiceCheckRecord, JSONObject.toJSONString(data)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}",e); |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}", e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
@ -366,29 +382,29 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap,"1"); |
|
|
|
|
checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap, "1"); |
|
|
|
|
|
|
|
|
|
List<String> activeCallRequest = new ArrayList<>(); |
|
|
|
|
activeCallRequest.add(JSONObject.toJSONString(pramsMap)); |
|
|
|
|
activeCallRequest.add(JSONObject.toJSONString("1")); |
|
|
|
|
singleInvoiceCheckRecord.setActiveCallRequestDetail(JSONObject.toJSONString(activeCallRequest)); |
|
|
|
|
singleInvoiceCheckRecord.setActiveCall("singleCheckInvoice"); |
|
|
|
|
singleInvoiceCheckRecord.setActiveCallResponse(JSONObject.toJSONString(checkInvoiceResult)); |
|
|
|
|
List<String> activeCallRequest = new ArrayList<>(); |
|
|
|
|
activeCallRequest.add(JSONObject.toJSONString(pramsMap)); |
|
|
|
|
activeCallRequest.add(JSONObject.toJSONString("1")); |
|
|
|
|
singleInvoiceCheckRecord.setActiveCallRequestDetail(JSONObject.toJSONString(activeCallRequest)); |
|
|
|
|
singleInvoiceCheckRecord.setActiveCall("singleCheckInvoice"); |
|
|
|
|
singleInvoiceCheckRecord.setActiveCallResponse(JSONObject.toJSONString(checkInvoiceResult)); |
|
|
|
|
|
|
|
|
|
log.info("查验结果为:{}", checkInvoiceResult); |
|
|
|
|
log.info("查验结果为:{}", checkInvoiceResult); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
log.error("查验失败,errormsg:{}",e.getMessage()); |
|
|
|
|
log.error("查验失败,errormsg:{}", e.getMessage()); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord,1,JSONObject.toJSONString(R.error("查验失败,"+e.getMessage())), |
|
|
|
|
"查验失败,异常信息:{}"+JSONObject.toJSONString(e.getMessage())); |
|
|
|
|
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 1, JSONObject.toJSONString(R.error("查验失败," + e.getMessage())), |
|
|
|
|
"查验失败,异常信息:{}" + JSONObject.toJSONString(e.getMessage())); |
|
|
|
|
} catch (Exception exception) { |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}",e); |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}", e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("查验失败,"+e.getMessage()))); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("查验失败," + e.getMessage()))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!checkInvoiceResult.containsKey("code")) { |
|
|
|
@ -399,10 +415,10 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 0,JSONObject.toJSONString(data), |
|
|
|
|
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 0, JSONObject.toJSONString(data), |
|
|
|
|
(String) checkInvoiceResult.get("cyjgxx")); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}",e); |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}", e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
@ -420,9 +436,9 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
requestRecordService.saveSuccessfulRequestRecord(singleInvoiceCheckRecord,JSONObject.toJSONString(data)); |
|
|
|
|
requestRecordService.saveSuccessfulRequestRecord(singleInvoiceCheckRecord, JSONObject.toJSONString(data)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}",e); |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}", e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -432,7 +448,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
Map map = JSONObject.parseObject(JSONObject.toJSONString(object), Map.class); |
|
|
|
|
String taxRate = (String) map.get("taxRate"); |
|
|
|
|
if ("0".equals(taxRate) || "*".equals(taxRate) || "**".equals(taxRate) || "***".equals(taxRate) || "不征税".equals(taxRate) || "免税".equals(taxRate)) { |
|
|
|
|
map.put("taxRate","0.00"); |
|
|
|
|
map.put("taxRate", "0.00"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
data.put("data", checkInvoiceResult); |
|
|
|
@ -442,7 +458,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
} else { |
|
|
|
|
//其他类发票,直接入库
|
|
|
|
|
R data = new R(1000, "default success"); |
|
|
|
|
if(!checkInvoiceResult.isEmpty()) { |
|
|
|
|
if (!checkInvoiceResult.isEmpty()) { |
|
|
|
|
log.info("其他类发票,不做查验,直接入库"); |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
data.put("message", "success"); |
|
|
|
@ -452,15 +468,15 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
log.info("返回给影像系统的结果为:{}", checkInvoiceResult); |
|
|
|
|
|
|
|
|
|
data.put("data", checkInvoiceResult); |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
data.put("message", "error 其他类发票不支持查验"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
requestRecordService.saveSuccessfulRequestRecord(singleInvoiceCheckRecord,JSONObject.toJSONString(data)); |
|
|
|
|
requestRecordService.saveSuccessfulRequestRecord(singleInvoiceCheckRecord, JSONObject.toJSONString(data)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}",e); |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}", e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
@ -469,10 +485,10 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord,0,JSONObject.toJSONString(R.error().put("data", checkInvoiceResult)), |
|
|
|
|
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 0, JSONObject.toJSONString(R.error().put("data", checkInvoiceResult)), |
|
|
|
|
"未知异常,请联系管理员"); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}",e); |
|
|
|
|
log.error("发票查验接口记录保存失败,errormsg:{}", e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error().put("data", checkInvoiceResult))); |
|
|
|
@ -623,7 +639,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
for (int i = 0; i < detailList.size(); i++) { |
|
|
|
|
String taxRateDetail = ""; |
|
|
|
|
JSONObject detail = (JSONObject) detailList.get(i); |
|
|
|
|
if(StringUtils.isNotEmpty(detail.getString("goodsName")) && (detail.getString("goodsName").equals("(详见销货清单)") || detail.getString("goodsName").equals("(详见销货清单)"))){ |
|
|
|
|
if (StringUtils.isNotEmpty(detail.getString("goodsName")) && (detail.getString("goodsName").equals("(详见销货清单)") || detail.getString("goodsName").equals("(详见销货清单)"))) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
Map<String, String> snDetailMap = new HashMap<String, String>(); |
|
|
|
@ -670,19 +686,19 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
if (!"0".equals(taxRateDetail)) { |
|
|
|
|
if (StringUtils.isNoneBlank(taxRateDetail)) { |
|
|
|
|
if (taxRateDetail.contains("%")) { |
|
|
|
|
taxRateDetail = taxRateDetail.replace("%",""); |
|
|
|
|
taxRateDetail = taxRateDetail.replace("%", ""); |
|
|
|
|
} |
|
|
|
|
BigDecimal tax = new BigDecimal(taxRateDetail); |
|
|
|
|
BigDecimal tax1 = tax.divide(new BigDecimal("100")); |
|
|
|
|
if (tax.compareTo(new BigDecimal("0.99")) < 1) { |
|
|
|
|
taxRateDetail = tax.toPlainString(); |
|
|
|
|
}else { |
|
|
|
|
} else { |
|
|
|
|
taxRateDetail = tax1.toPlainString(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
log.error("报错的原因为:{}",e); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("报错的原因为:{}", e); |
|
|
|
|
taxRateDetail = "0.00"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -706,6 +722,194 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
checkInvoice.put("invoiceLineList", returnDetailList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void convertToResult(JSONObject checkInvoice, JSONArray detailArray, JSONObject vehicleList) throws ParseException { |
|
|
|
|
|
|
|
|
|
checkInvoice.put("totalTax", checkInvoice.getString("taxAmount")); |
|
|
|
|
checkInvoice.put("amountTax", checkInvoice.getString("totalAmount")); |
|
|
|
|
checkInvoice.put("totalAmount", checkInvoice.getString("invoiceAmount")); |
|
|
|
|
// 增加备注字段
|
|
|
|
|
checkInvoice.put("remarks", checkInvoice.getString("remark")); |
|
|
|
|
//添加非空判断
|
|
|
|
|
String invoiceCode = null; |
|
|
|
|
if (checkInvoice.get("invoiceCode") != null) { |
|
|
|
|
invoiceCode = checkInvoice.get("invoiceCode").toString(); |
|
|
|
|
} |
|
|
|
|
String invoiceType = checkInvoice.get("invoiceType").toString(); |
|
|
|
|
if ("22".equals(invoiceType)) { |
|
|
|
|
invoiceType = "33"; |
|
|
|
|
} |
|
|
|
|
if ("21".equals(invoiceType)) { |
|
|
|
|
invoiceType = "31"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
checkInvoice.put("invoiceType", invoiceType); |
|
|
|
|
checkInvoice.put("administrativeDivisionNo", ""); |
|
|
|
|
checkInvoice.put("administrativeDivisionName", ""); |
|
|
|
|
|
|
|
|
|
if ("31".equals(invoiceType) || "32".equals(invoiceType) || "185".equals(invoiceType) || "186".equals(invoiceType)) { |
|
|
|
|
checkInvoice.put("invoiceCode", ""); |
|
|
|
|
checkInvoice.put("invoiceNumber", invoiceCode == null ? checkInvoice.get("invoiceNo").toString() : invoiceCode + checkInvoice.get("invoiceNo").toString()); |
|
|
|
|
} else { |
|
|
|
|
checkInvoice.put("invoiceCode", invoiceCode); |
|
|
|
|
checkInvoice.put("invoiceNumber", checkInvoice.get("invoiceNo").toString()); |
|
|
|
|
} |
|
|
|
|
String uuid = ""; |
|
|
|
|
if (invoiceCode != null && StringUtils.isNoneBlank(invoiceCode)) { |
|
|
|
|
uuid = invoiceCode + checkInvoice.get("invoiceNo").toString(); |
|
|
|
|
checkInvoice.put("uuid", uuid); |
|
|
|
|
} else { |
|
|
|
|
uuid = checkInvoice.get("invoiceNo").toString(); |
|
|
|
|
checkInvoice.put("uuid", uuid); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String kprq = checkInvoice.get("invoiceDate").toString(); |
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US); |
|
|
|
|
Date date = sdf.parse(kprq); |
|
|
|
|
String formatStr = new SimpleDateFormat("yyyy-MM-dd").format(date); |
|
|
|
|
log.info("开票日期为:{} ", formatStr); |
|
|
|
|
|
|
|
|
|
checkInvoice.put("billingDate", formatStr); |
|
|
|
|
checkInvoice.put("purchaserName", checkInvoice.get("gfName")); |
|
|
|
|
checkInvoice.put("purchaserTaxNo", checkInvoice.get("gfTaxNo")); |
|
|
|
|
checkInvoice.put("purchaserBank", checkInvoice.get("gfBankAndNo")); |
|
|
|
|
checkInvoice.put("purchaserAddressPhone", checkInvoice.get("gfAddressAndPhone")); |
|
|
|
|
checkInvoice.put("salesName", checkInvoice.get("xfName")); |
|
|
|
|
checkInvoice.put("salesTaxNo", checkInvoice.get("xfTaxNo")); |
|
|
|
|
checkInvoice.put("salesAddressPhone", checkInvoice.get("gfAddressAndPhone")); |
|
|
|
|
checkInvoice.put("salesBank", checkInvoice.get("gfBankAndNo")); |
|
|
|
|
checkInvoice.put("checkCode", checkInvoice.get("checkCode")); |
|
|
|
|
checkInvoice.put("state", "0"); |
|
|
|
|
checkInvoice.put("tollSign", "07"); |
|
|
|
|
//机动车
|
|
|
|
|
if ("03".equals(invoiceType)) { |
|
|
|
|
checkInvoice.put("vehicleType", vehicleList.getString("vehicleType")); |
|
|
|
|
checkInvoice.put("brandModel", vehicleList.getString("factoryModel")); |
|
|
|
|
checkInvoice.put("originPlace", vehicleList.getString("productPlace")); |
|
|
|
|
checkInvoice.put("certificateNo", vehicleList.getString("certificate")); |
|
|
|
|
checkInvoice.put("inspectionListNo", vehicleList.getString("inspectionNum")); |
|
|
|
|
checkInvoice.put("engineNo", vehicleList.getString("engineNo")); |
|
|
|
|
checkInvoice.put("vehicleNo", vehicleList.getString("vehicleNo")); |
|
|
|
|
checkInvoice.put("paymentVoucherNo", vehicleList.getString("taxRecords")); |
|
|
|
|
checkInvoice.put("passengersLimited", vehicleList.getString("limitPeople")); |
|
|
|
|
checkInvoice.put("taxAuthorityNo", vehicleList.getString("taxBureauCode")); |
|
|
|
|
checkInvoice.put("taxAuthorityName", vehicleList.getString("taxBureauName")); |
|
|
|
|
} |
|
|
|
|
//二手车
|
|
|
|
|
if ("15".equals(invoiceType)) { |
|
|
|
|
checkInvoice.put("vehicleType", vehicleList.getString("vehicleType")); |
|
|
|
|
checkInvoice.put("vehicleNo", vehicleList.getString("vehicleNo")); |
|
|
|
|
checkInvoice.put("brandModel", vehicleList.getString("factoryModel")); |
|
|
|
|
checkInvoice.put("licensePlate", vehicleList.getString("plateNo")); |
|
|
|
|
checkInvoice.put("buyerUnitOrIndividual", vehicleList.getString("buyerUnit")); |
|
|
|
|
checkInvoice.put("buyerUnitCodeOrIdNo", vehicleList.getString("buyerUnitCode")); |
|
|
|
|
checkInvoice.put("buyerUnitOrIndividualAddress", vehicleList.getString("buyerUnitAddress")); |
|
|
|
|
checkInvoice.put("sellerUnitOrIndividual", vehicleList.getString("sellerUnit")); |
|
|
|
|
checkInvoice.put("sellerUnitCodeOrIdNo", vehicleList.getString("sellerUnitCode")); |
|
|
|
|
checkInvoice.put("sellerUnitOrIndividualAddress", vehicleList.getString("sellerUnitAddress")); |
|
|
|
|
checkInvoice.put("sellerPhone", vehicleList.getString("sellerPhone")); |
|
|
|
|
checkInvoice.put("lemonMarket", vehicleList.getString("carMarket")); |
|
|
|
|
checkInvoice.put("lemonMarketAddress", vehicleList.getString("carMarketAddress")); |
|
|
|
|
checkInvoice.put("lemonMarketPhone", vehicleList.getString("carMarketPhone")); |
|
|
|
|
checkInvoice.put("lemonMarketBankAndAccount", vehicleList.getString("carMarketBank")); |
|
|
|
|
checkInvoice.put("vehicleAdminOffice", vehicleList.getString("vehicleAdminOffice")); |
|
|
|
|
checkInvoice.put("registrationNo", vehicleList.getString("registrationNo")); |
|
|
|
|
checkInvoice.put("lemonMarketTaxNo", vehicleList.getString("carMarketTaxNo")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String taxRate = ""; |
|
|
|
|
List<Map<String, String>> returnDetailList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
JSONArray detailList = detailArray; |
|
|
|
|
if (detailList != null) { |
|
|
|
|
for (int i = 0; i < detailList.size(); i++) { |
|
|
|
|
String taxRateDetail = ""; |
|
|
|
|
JSONObject detail = (JSONObject) detailList.get(i); |
|
|
|
|
if (StringUtils.isNotEmpty(detail.getString("goodsName")) && (detail.getString("goodsName").equals("(详见销货清单)") || detail.getString("goodsName").equals("(详见销货清单)"))) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
Map<String, String> snDetailMap = new HashMap<String, String>(); |
|
|
|
|
snDetailMap.put("rowNo", i + 1 + ""); |
|
|
|
|
snDetailMap.put("commodityCode", detail.getString("goodsNum")); |
|
|
|
|
snDetailMap.put("commodityName", detail.getString("goodsName")); |
|
|
|
|
snDetailMap.put("specificationModel", detail.getString("model")); |
|
|
|
|
snDetailMap.put("unit", detail.getString("unit")); |
|
|
|
|
String quantity = detail.getString("num"); |
|
|
|
|
snDetailMap.put("quantity", quantity); |
|
|
|
|
|
|
|
|
|
String unitPrice = detail.getString("unitPrice"); |
|
|
|
|
snDetailMap.put("unitPrice", unitPrice); |
|
|
|
|
|
|
|
|
|
if ("11".equals(invoiceType)) { |
|
|
|
|
snDetailMap.put("tax", "0"); |
|
|
|
|
|
|
|
|
|
//如果是卷票计算合计金额
|
|
|
|
|
String hjje = null; |
|
|
|
|
if (detail.getString("detailAmount") != null && detail.getString("taxAmount") != null) { |
|
|
|
|
BigDecimal je = new BigDecimal(detail.getString("detailAmount")); |
|
|
|
|
if (detail.getString("taxAmount") != null) { |
|
|
|
|
hjje = je.add(new BigDecimal(detail.getString("taxAmount"))).toPlainString(); |
|
|
|
|
} else { |
|
|
|
|
hjje = je.toPlainString(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(hjje)) |
|
|
|
|
snDetailMap.put("amount", hjje); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
snDetailMap.put("tax", "***".equals(detail.getString("taxAmount")) ? "0.00" : detail.getString("taxAmount")); |
|
|
|
|
snDetailMap.put("amount", detail.getString("detailAmount")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ("免税".equals(detail.getString("taxRate")) || "不征税".equals(detail.getString("taxRate")) || "***".equals(detail.getString("taxRate"))) { |
|
|
|
|
taxRateDetail = "0"; |
|
|
|
|
snDetailMap.put("taxRate", taxRateDetail); |
|
|
|
|
} else { |
|
|
|
|
if (detail.get("taxRate") != null && StringUtils.isNoneBlank(detail.get("taxRate").toString())) { |
|
|
|
|
try { |
|
|
|
|
taxRateDetail = detail.get("taxRate").toString(); |
|
|
|
|
if (!"0".equals(taxRateDetail)) { |
|
|
|
|
if (StringUtils.isNoneBlank(taxRateDetail)) { |
|
|
|
|
if (taxRateDetail.contains("%")) { |
|
|
|
|
taxRateDetail = taxRateDetail.replace("%", ""); |
|
|
|
|
} |
|
|
|
|
BigDecimal tax = new BigDecimal(taxRateDetail); |
|
|
|
|
BigDecimal tax1 = tax.divide(new BigDecimal("100")); |
|
|
|
|
if (tax.compareTo(new BigDecimal("0.99")) < 1) { |
|
|
|
|
taxRateDetail = tax.toPlainString(); |
|
|
|
|
} else { |
|
|
|
|
taxRateDetail = tax1.toPlainString(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("报错的原因为:{}", e); |
|
|
|
|
taxRateDetail = "0.00"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ("11".equals(invoiceType)) { |
|
|
|
|
taxRateDetail = "0.000"; |
|
|
|
|
} |
|
|
|
|
log.info("明细-发票税率为:{}", taxRateDetail); |
|
|
|
|
snDetailMap.put("taxRate", taxRateDetail); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.info("明细-tax={}", detail.get("taxAmount")); |
|
|
|
|
snDetailMap.put("currentDateEnd", detail.getString("txrqz")); |
|
|
|
|
snDetailMap.put("currentDateStart", detail.getString("txrqq")); |
|
|
|
|
snDetailMap.put("licensePlateNum", detail.getString("cph")); |
|
|
|
|
snDetailMap.put("type", detail.getString("lx")); |
|
|
|
|
|
|
|
|
|
returnDetailList.add(snDetailMap); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
checkInvoice.put("invoiceLineList", returnDetailList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查验发票 |
|
|
|
|
*/ |
|
|
|
@ -718,15 +922,15 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
|
|
|
|
|
List<String> invoiceCodes = new ArrayList<>(); |
|
|
|
|
List<String> invoiceNos = new ArrayList<>(); |
|
|
|
|
RequestRecord record=null; |
|
|
|
|
if (snRequestObject.getInvoiceInfoList()!=null && snRequestObject.getInvoiceInfoList().size()>0) { |
|
|
|
|
snRequestObject.getInvoiceInfoList().stream().forEach(invoiceInfo->{ |
|
|
|
|
RequestRecord record = null; |
|
|
|
|
if (snRequestObject.getInvoiceInfoList() != null && snRequestObject.getInvoiceInfoList().size() > 0) { |
|
|
|
|
snRequestObject.getInvoiceInfoList().stream().forEach(invoiceInfo -> { |
|
|
|
|
invoiceCodes.add(invoiceInfo.getInvoiceCode()); |
|
|
|
|
invoiceNos.add(invoiceInfo.getInvoiceNumber()); |
|
|
|
|
}); |
|
|
|
|
log.info("影像系统同步数据的发票号码为:{}", JSONObject.toJSONString(invoiceNos)); |
|
|
|
|
log.info("影像系统同步数据的发票代码为:{}", JSONObject.toJSONString(invoiceCodes)); |
|
|
|
|
if (invoiceCodes.size()>0) { |
|
|
|
|
if (invoiceCodes.size() > 0) { |
|
|
|
|
record = requestRecordService.getBaseRequestRecord(JSONObject.toJSONString(snRequestObject), |
|
|
|
|
"/syncInvoiceInfo", |
|
|
|
|
JSONObject.toJSONString(invoiceCodes), |
|
|
|
@ -810,9 +1014,9 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
requestRecordService.saveFailedRequestRecord(record,0, JSONObject.toJSONString(R.error(result)), result); |
|
|
|
|
requestRecordService.saveFailedRequestRecord(record, 0, JSONObject.toJSONString(R.error(result)), result); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("发票同步接口记录保存失败,errormsg:{}",e); |
|
|
|
|
log.error("发票同步接口记录保存失败,errormsg:{}", e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error(result))); |
|
|
|
@ -844,7 +1048,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
requestRecordService.saveSuccessfulRequestRecord(record, JSONObject.toJSONString(data)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("发票同步接口记录保存失败,errormsg:{}",e); |
|
|
|
|
log.error("发票同步接口记录保存失败,errormsg:{}", e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
@ -855,10 +1059,10 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
// requestRecordService.saveRecord(pushCheckResultToSAPRecord,1, 1, JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_PUSH_SDNY)), 1);
|
|
|
|
|
try { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
requestRecordService.saveFailedRequestRecord(record,1, JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_PUSH_SDNY)), |
|
|
|
|
"推送sap失败,失败原因:"+"{"+JSONObject.toJSONString(e)+"}"); |
|
|
|
|
requestRecordService.saveFailedRequestRecord(record, 1, JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_PUSH_SDNY)), |
|
|
|
|
"推送sap失败,失败原因:" + "{" + JSONObject.toJSONString(e) + "}"); |
|
|
|
|
} catch (Exception exception) { |
|
|
|
|
log.error("发票同步接口记录保存失败,errormsg:{}",e); |
|
|
|
|
log.error("发票同步接口记录保存失败,errormsg:{}", e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_PUSH_SDNY))); |
|
|
|
@ -885,7 +1089,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
requestRecordService.saveSuccessfulRequestRecord(record, JSONObject.toJSONString(data)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("发票同步接口记录保存失败,errormsg:{}",e); |
|
|
|
|
log.error("发票同步接口记录保存失败,errormsg:{}", e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
@ -910,7 +1114,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
requestRecordService.saveSuccessfulRequestRecord(record, JSONObject.toJSONString(data)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("发票同步接口记录保存失败,errormsg:{}",e); |
|
|
|
|
log.error("发票同步接口记录保存失败,errormsg:{}", e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
@ -923,36 +1127,36 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
requestRecordService.saveFailedRequestRecord(record,1, JSONObject.toJSONString(R.error(CommonConstants.CONNECT_TIMEOUT)), |
|
|
|
|
"同步SAP失败,报错信息为:"+"{"+JSONObject.toJSONString(exception)+"}"); |
|
|
|
|
requestRecordService.saveFailedRequestRecord(record, 1, JSONObject.toJSONString(R.error(CommonConstants.CONNECT_TIMEOUT)), |
|
|
|
|
"同步SAP失败,报错信息为:" + "{" + JSONObject.toJSONString(exception) + "}"); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("发票同步接口记录保存失败,errormsg:{}",e); |
|
|
|
|
log.error("发票同步接口记录保存失败,errormsg:{}", e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.CONNECT_TIMEOUT))); |
|
|
|
|
} catch(NullPointerException exception){ |
|
|
|
|
} catch (NullPointerException exception) { |
|
|
|
|
log.error("同步SAP失败,报错信息为:{}", exception); |
|
|
|
|
exception.printStackTrace(); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
requestRecordService.saveFailedRequestRecord(record,1, JSONObject.toJSONString(R.error(CommonConstants.NULL_POINTER_TIMEOUT)), |
|
|
|
|
"同步SAP失败,报错信息为:"+"{"+JSONObject.toJSONString(exception)+"}"); |
|
|
|
|
requestRecordService.saveFailedRequestRecord(record, 1, JSONObject.toJSONString(R.error(CommonConstants.NULL_POINTER_TIMEOUT)), |
|
|
|
|
"同步SAP失败,报错信息为:" + "{" + JSONObject.toJSONString(exception) + "}"); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("发票同步接口记录保存失败,errormsg:{}",e); |
|
|
|
|
log.error("发票同步接口记录保存失败,errormsg:{}", e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.NULL_POINTER_TIMEOUT))); |
|
|
|
|
} catch(Exception exception){ |
|
|
|
|
} catch (Exception exception) { |
|
|
|
|
log.error("同步SAP失败,报错信息为:{}", exception); |
|
|
|
|
exception.printStackTrace(); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
requestRecordService.saveFailedRequestRecord(record,1, JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_DEFAULT)), |
|
|
|
|
"同步SAP失败,报错信息为:"+"{"+JSONObject.toJSONString(exception)+"}"); |
|
|
|
|
requestRecordService.saveFailedRequestRecord(record, 1, JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_DEFAULT)), |
|
|
|
|
"同步SAP失败,报错信息为:" + "{" + JSONObject.toJSONString(exception) + "}"); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("发票同步接口记录保存失败,errormsg:{}",e); |
|
|
|
|
log.error("发票同步接口记录保存失败,errormsg:{}", e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_DEFAULT))); |
|
|
|
@ -1089,13 +1293,13 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
|
|
|
|
|
if (snInvoiceDetail.getAmount() != null) |
|
|
|
|
sapInvoiceDetail.setZJK(snInvoiceDetail.getAmount()); |
|
|
|
|
sapInvoiceDetail.setZHH(snInvoiceDetail.getRowNo()); |
|
|
|
|
sapInvoiceDetail.setZHH(snInvoiceDetail.getRowNo()); |
|
|
|
|
//将类似于0.03数据格式转化为3.00
|
|
|
|
|
if (snInvoiceDetail.getTaxRate() != null && snInvoiceDetail.getTaxRate() != "") { |
|
|
|
|
String taxRate = snInvoiceDetail.getTaxRate(); |
|
|
|
|
sapInvoiceDetail.setZTAX(taxRate); |
|
|
|
|
if (taxRate.contains("%")){ |
|
|
|
|
taxRate = taxRate.replace("%",""); |
|
|
|
|
if (taxRate.contains("%")) { |
|
|
|
|
taxRate = taxRate.replace("%", ""); |
|
|
|
|
} |
|
|
|
|
if ("0".equals(taxRate) || "*".equals(taxRate) || "**".equals(taxRate) || "***".equals(taxRate) || "不征税".equals(taxRate) || "免税".equals(taxRate)) { |
|
|
|
|
sapInvoiceDetail.setZTAX("0.00"); |
|
|
|
@ -1108,7 +1312,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
sapInvoiceDetail.setZTAX(tax1.toString()); |
|
|
|
|
if (tax1.compareTo(new BigDecimal("99")) > 0) { |
|
|
|
|
sapInvoiceDetail.setZTAX(taxRate); |
|
|
|
|
}else { |
|
|
|
|
} else { |
|
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("#.00"); |
|
|
|
|
String formattedDecimal = decimalFormat.format(tax1); |
|
|
|
|
sapInvoiceDetail.setZTAX(formattedDecimal); |
|
|
|
@ -1183,7 +1387,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
BigDecimal tax = new BigDecimal(taxRate); |
|
|
|
|
info.setZSM(getZSM(tax.toPlainString())); |
|
|
|
|
BigDecimal tax1 = tax.multiply(new BigDecimal("100")); |
|
|
|
|
info.setZTAX(tax1.setScale(2,RoundingMode.FLOOR).toPlainString()); |
|
|
|
|
info.setZTAX(tax1.setScale(2, RoundingMode.FLOOR).toPlainString()); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
if (taxRate != null && "0".equals(taxRate)) { |
|
|
|
@ -1278,12 +1482,12 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
|| "08".equals(snInvoice.getInvoiceType()) || "10".equals(snInvoice.getInvoiceType()) || "11".equals(snInvoice.getInvoiceType()) || "14".equals(snInvoice.getInvoiceType()) |
|
|
|
|
|| "15".equals(snInvoice.getInvoiceType()) || "31".equals(snInvoice.getInvoiceType()) || "32".equals(snInvoice.getInvoiceType())) { |
|
|
|
|
//可查验发票,
|
|
|
|
|
log.info("发票类型为:{}",snInvoice.getInvoiceType()); |
|
|
|
|
log.info("发票类型为:{}", snInvoice.getInvoiceType()); |
|
|
|
|
//0608 区块链发票 并且 checkStatus = 3 的时候 提交sap状态为3(刘振和谈楚才提出需求)
|
|
|
|
|
if("10".equals(snInvoice.getInvoiceType()) && "3".equals(snInvoice.getCheckStatus())){ |
|
|
|
|
if ("10".equals(snInvoice.getInvoiceType()) && "3".equals(snInvoice.getCheckStatus())) { |
|
|
|
|
log.info("区块链发票 传输状态checkStatus = 3"); |
|
|
|
|
info.setZCYZT("3"); |
|
|
|
|
}else { |
|
|
|
|
} else { |
|
|
|
|
info.setZCYZT("1"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|