From b137b47b8e3222f346c41a4970454146fcbf3e5b Mon Sep 17 00:00:00 2001 From: xuliangwei Date: Mon, 10 Jul 2023 10:26:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../erp/controller/InterfaceController.java | 27 ++- .../controller/SDNYMainProcessController.java | 168 ++++++++++++++---- 2 files changed, 159 insertions(+), 36 deletions(-) diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/controller/InterfaceController.java b/dxhy-erp/src/main/java/com/dxhy/erp/controller/InterfaceController.java index 10875bbd..e4ca2456 100644 --- a/dxhy-erp/src/main/java/com/dxhy/erp/controller/InterfaceController.java +++ b/dxhy-erp/src/main/java/com/dxhy/erp/controller/InterfaceController.java @@ -1220,10 +1220,15 @@ public class InterfaceController extends AbstractController { EsOutPutResp esOutPutResp=invoiceAuthService.receiveErpInvoiceMessage(erpInvoiceData.getIS_INPUT()); outPut.setES_OUTPUT(esOutPutResp); - if (esOutPutResp.getZMESSAGE().contains("不存在")) { - requestRecordService.saveRecord(receiveErpInvoiceMessageRecord, 1,1, JsonUtils.getInstance().toJsonString(outPut),0); - } else { - requestRecordService.saveRecord(receiveErpInvoiceMessageRecord, 0,0, JsonUtils.getInstance().toJsonString(outPut)); + try { + if (esOutPutResp.getZMESSAGE().contains("不存在")) { + requestRecordService.saveRecord(receiveErpInvoiceMessageRecord, 1,1, JsonUtils.getInstance().toJsonString(outPut),0); + } else { + requestRecordService.saveRecord(receiveErpInvoiceMessageRecord, 0,0, JsonUtils.getInstance().toJsonString(outPut)); + } + } catch (Exception e) { + log.error("FI847接口记录保存失败,errormsg:{}",e.getMessage()); + e.printStackTrace(); } return JsonUtils.getInstance().toJsonString(outPut); @@ -1277,7 +1282,12 @@ public class InterfaceController extends AbstractController { es.setZMESSAGE("底账数据不存在"); outPut.setES_OUTPUT(es); - requestRecordService.saveRecord(transferOutRecord, 1, 1, JsonUtils.getInstance().toJsonString(outPut), 0); + try { + requestRecordService.saveRecord(transferOutRecord, 1, 1, JsonUtils.getInstance().toJsonString(outPut), 0); + } catch (Exception e) { + log.error("FI849接口记录保存失败,errormsg:{}",e.getMessage()); + e.printStackTrace(); + } return JsonUtils.getInstance().toJsonString(outPut); } @@ -1324,7 +1334,12 @@ public class InterfaceController extends AbstractController { } } - requestRecordService.saveRecord(transferOutRecord,0, 0, transfer); + try { + requestRecordService.saveRecord(transferOutRecord,0, 0, transfer); + } catch (Exception e) { + log.error("FI849接口记录保存失败,errormsg:{}",e.getMessage()); + e.printStackTrace(); + } return transfer; }catch (Exception e){ diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java b/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java index b4865294..be492996 100644 --- a/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java +++ b/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java @@ -18,11 +18,8 @@ import com.dxhy.erp.entity.*; import com.dxhy.erp.entity.sdny.*; import com.dxhy.erp.model.InvoiceDetailInfo; import com.dxhy.erp.service.*; -import com.dxhy.erp.service.impl.GatherServiceImpl; import com.dxhy.erp.utils.Base64; -import com.dxhy.erp.utils.CheckUtil; import com.dxhy.erp.utils.HmacSHA1Util; -import com.google.gson.JsonArray; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; @@ -134,7 +131,13 @@ public class SDNYMainProcessController extends AbstractController { data.put("message", "success"); data.put("data", checkInvoiceResult); - requestRecordService.saveRecord(singleInvoiceCheckRecord, 0,0, JSONObject.toJSONString(data)); + try { + requestRecordService.saveRecord(singleInvoiceCheckRecord, 0,0, JSONObject.toJSONString(data)); + } catch (Exception e) { + log.error("发票查验接口记录保存失败,errormsg:{}",e.getMessage()); + e.printStackTrace(); + + } return ResponseEntity.ok(JSONObject.toJSONString(data)); } @@ -147,7 +150,12 @@ public class SDNYMainProcessController extends AbstractController { //权限校验 if (StringUtils.isBlank(pramsMap.get("invoiceNumber"))) { - requestRecordService.saveRecord(singleInvoiceCheckRecord,1,1,JSONObject.toJSONString(R.error("发票号码不能为空!")),0); + try { + requestRecordService.saveRecord(singleInvoiceCheckRecord,1,1,JSONObject.toJSONString(R.error("发票号码不能为空!")),0); + } catch (Exception e) { + log.error("发票查验接口记录保存失败,errormsg:{}",e.getMessage()); + e.printStackTrace(); + } return ResponseEntity.ok(JSONObject.toJSONString(R.error("发票号码不能为空!"))); } @@ -161,14 +169,24 @@ public class SDNYMainProcessController extends AbstractController { pramsMap.put("billingDate", billingDate); } else { - requestRecordService.saveRecord(singleInvoiceCheckRecord,1,1,JSONObject.toJSONString(R.error("开票日期不能为空!")), 0); + try { + requestRecordService.saveRecord(singleInvoiceCheckRecord,1,1,JSONObject.toJSONString(R.error("开票日期不能为空!")), 0); + } catch (Exception e) { + log.error("发票查验接口记录保存失败,errormsg:{}",e.getMessage()); + e.printStackTrace(); + } return ResponseEntity.ok(JSONObject.toJSONString(R.error("开票日期不能为空!"))); } if (StringUtils.isBlank(pramsMap.get("invoiceType"))) { - requestRecordService.saveRecord(singleInvoiceCheckRecord,1,1,JSONObject.toJSONString(R.error("发票类型不能为空!")), 0); + try { + requestRecordService.saveRecord(singleInvoiceCheckRecord,1,1,JSONObject.toJSONString(R.error("发票类型不能为空!")), 0); + } catch (Exception e) { + log.error("发票查验接口记录保存失败,errormsg:{}",e.getMessage()); + e.printStackTrace(); + } return ResponseEntity.ok(JSONObject.toJSONString(R.error("发票类型不能为空!"))); } @@ -181,14 +199,24 @@ public class SDNYMainProcessController extends AbstractController { || SNFplxEnum.QDPP.getSnFplxDm().equals(pramsMap.get("invoiceType"))) { if (StringUtils.isBlank(pramsMap.get("totalAmount"))) { - requestRecordService.saveRecord(singleInvoiceCheckRecord,1,1,JSONObject.toJSONString(R.error("金额不能为空!")), 0); + try { + requestRecordService.saveRecord(singleInvoiceCheckRecord,1,1,JSONObject.toJSONString(R.error("金额不能为空!")), 0); + } catch (Exception e) { + log.error("发票查验接口记录保存失败,errormsg:{}",e.getMessage()); + e.printStackTrace(); + } return ResponseEntity.ok(JSONObject.toJSONString(R.error("金额不能为空!"))); } } else { if (StringUtils.isBlank(pramsMap.get("checkCode"))) { - requestRecordService.saveRecord(singleInvoiceCheckRecord,1,1,JSONObject.toJSONString(R.error("校验码不能为空!")), 0); + try { + requestRecordService.saveRecord(singleInvoiceCheckRecord,1,1,JSONObject.toJSONString(R.error("校验码不能为空!")), 0); + } catch (Exception e) { + log.error("发票查验接口记录保存失败,errormsg:{}",e.getMessage()); + e.printStackTrace(); + } return ResponseEntity.ok(JSONObject.toJSONString(R.error("校验码不能为空!"))); } @@ -205,7 +233,12 @@ public class SDNYMainProcessController extends AbstractController { String notes = invoiceQueryService.checkingInvoiceInfo("business", uuid, getUserInfo()); if (notes != null) { - requestRecordService.saveRecord(singleInvoiceCheckRecord,1,1,JSONObject.toJSONString(R.error(notes)), 0); + try { + requestRecordService.saveRecord(singleInvoiceCheckRecord,1,1,JSONObject.toJSONString(R.error(notes)), 0); + } catch (Exception e) { + log.error("发票查验接口记录保存失败,errormsg:{}",e.getMessage()); + e.printStackTrace(); + } return ResponseEntity.ok(JSONObject.toJSONString(R.error(notes))); } @@ -261,14 +294,19 @@ public class SDNYMainProcessController extends AbstractController { //查验结果保存 // saveCheckLog(pramsMap, checkInvoice); - if (checkInvoiceResult!=null && checkInvoiceResult.containsKey("code")) { - if (checkInvoiceResult.containsKey("cyjg")) { - requestRecordService.saveRecord(singleInvoiceCheckRecord,1,1,JSONObject.toJSONString(data), 0); + try { + if (checkInvoiceResult!=null && checkInvoiceResult.containsKey("code")) { + if (checkInvoiceResult.containsKey("cyjg")) { + requestRecordService.saveRecord(singleInvoiceCheckRecord,1,1,JSONObject.toJSONString(data), 0); - } - } else { - requestRecordService.saveRecord(singleInvoiceCheckRecord,0,0,JSONObject.toJSONString(data)); + } + } else { + requestRecordService.saveRecord(singleInvoiceCheckRecord,0,0,JSONObject.toJSONString(data)); + } + } catch (Exception e) { + log.error("发票查验接口记录保存失败,errormsg:{}",e.getMessage()); + e.printStackTrace(); } return ResponseEntity.ok(JSONObject.toJSONString(data)); @@ -295,7 +333,12 @@ public class SDNYMainProcessController extends AbstractController { //查验结果保存 // saveCheckLog(pramsMap,checkInvoice); - requestRecordService.saveRecord(singleInvoiceCheckRecord,0,0,JSONObject.toJSONString(data)); + try { + requestRecordService.saveRecord(singleInvoiceCheckRecord,0,0,JSONObject.toJSONString(data)); + } catch (Exception e) { + log.error("发票查验接口记录保存失败,errormsg:{}",e.getMessage()); + e.printStackTrace(); + } return ResponseEntity.ok(JSONObject.toJSONString(data)); } @@ -315,7 +358,12 @@ public class SDNYMainProcessController extends AbstractController { e.printStackTrace(); log.error("查验失败,errormsg:{}",e.getMessage()); - requestRecordService.saveRecord(singleInvoiceCheckRecord,1,1,JSONObject.toJSONString(R.error("查验失败,"+e.getMessage())), 1); + try { + requestRecordService.saveRecord(singleInvoiceCheckRecord,1,1,JSONObject.toJSONString(R.error("查验失败,"+e.getMessage())), 1); + } catch (Exception exception) { + log.error("发票查验接口记录保存失败,errormsg:{}",e.getMessage()); + exception.printStackTrace(); + } return ResponseEntity.ok(JSONObject.toJSONString(R.error("查验失败,"+e.getMessage()))); } @@ -326,7 +374,12 @@ public class SDNYMainProcessController extends AbstractController { R data = new R(); data = errorInfo(checkInvoiceResult, data); - requestRecordService.saveRecord(singleInvoiceCheckRecord,1,1,JSONObject.toJSONString(data), 0); + try { + requestRecordService.saveRecord(singleInvoiceCheckRecord,1,1,JSONObject.toJSONString(data), 0); + } catch (Exception e) { + log.error("发票查验接口记录保存失败,errormsg:{}",e.getMessage()); + e.printStackTrace(); + } return ResponseEntity.ok(JSONObject.toJSONString(data)); @@ -342,7 +395,12 @@ public class SDNYMainProcessController extends AbstractController { log.info("返回给影像系统的结果为:{}", checkInvoiceResult); signSaveInvoiceInfoService.saveQueryInvoiceResult(checkInvoiceResult, userid, "1", dbName); - requestRecordService.saveRecord(singleInvoiceCheckRecord,0,0,JSONObject.toJSONString(data)); + try { + requestRecordService.saveRecord(singleInvoiceCheckRecord,0,0,JSONObject.toJSONString(data)); + } catch (Exception e) { + log.error("发票查验接口记录保存失败,errormsg:{}",e.getMessage()); + e.printStackTrace(); + } } return ResponseEntity.ok(JSONObject.toJSONString(data)); @@ -364,13 +422,23 @@ public class SDNYMainProcessController extends AbstractController { data.put("data", checkInvoiceResult); - requestRecordService.saveRecord(singleInvoiceCheckRecord,0,0,JSONObject.toJSONString(data)); + try { + requestRecordService.saveRecord(singleInvoiceCheckRecord,0,0,JSONObject.toJSONString(data)); + } catch (Exception e) { + log.error("发票查验接口记录保存失败,errormsg:{}",e.getMessage()); + e.printStackTrace(); + } return ResponseEntity.ok(JSONObject.toJSONString(data)); } - requestRecordService.saveRecord(singleInvoiceCheckRecord,1,1,JSONObject.toJSONString(R.error().put("data", checkInvoiceResult)),0); + try { + requestRecordService.saveRecord(singleInvoiceCheckRecord,1,1,JSONObject.toJSONString(R.error().put("data", checkInvoiceResult)),0); + } catch (Exception e) { + log.error("发票查验接口记录保存失败,errormsg:{}",e.getMessage()); + e.printStackTrace(); + } return ResponseEntity.ok(JSONObject.toJSONString(R.error().put("data", checkInvoiceResult))); } @@ -700,7 +768,12 @@ public class SDNYMainProcessController extends AbstractController { R data = new R(1000, "default success"); data.put("data", result); - requestRecordService.saveRecord(record,0, 0, JSONObject.toJSONString(R.error(result))); + try { + requestRecordService.saveRecord(record,0, 0, JSONObject.toJSONString(R.error(result))); + } catch (Exception e) { + log.error("发票同步接口记录保存失败,errormsg:{}",e.getMessage()); + e.printStackTrace(); + } return ResponseEntity.ok(JSONObject.toJSONString(R.error(result))); } @@ -729,7 +802,12 @@ public class SDNYMainProcessController extends AbstractController { R data = new R(1000, "default success"); data.put("data", result); - requestRecordService.saveRecord(record,0, 0, JSONObject.toJSONString(data)); + try { + requestRecordService.saveRecord(record,0, 0, JSONObject.toJSONString(data)); + } catch (Exception e) { + log.error("发票同步接口记录保存失败,errormsg:{}",e.getMessage()); + e.printStackTrace(); + } return ResponseEntity.ok(JSONObject.toJSONString(data)); } catch (Exception e) { @@ -737,7 +815,12 @@ public class SDNYMainProcessController extends AbstractController { log.error("", e); // requestRecordService.saveRecord(pushCheckResultToSAPRecord,1, 1, JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_PUSH_SDNY)), 1); - requestRecordService.saveRecord(record,1, 1, JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_PUSH_SDNY)), 1); + try { + requestRecordService.saveRecord(record,1, 1, JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_PUSH_SDNY)), 1); + } catch (Exception exception) { + log.error("发票同步接口记录保存失败,errormsg:{}",e.getMessage()); + exception.printStackTrace(); + } return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_PUSH_SDNY))); } @@ -759,7 +842,12 @@ public class SDNYMainProcessController extends AbstractController { R data = new R(1000, "default success"); data.put("data", ""); - requestRecordService.saveRecord(record,0, 0, JSONObject.toJSONString(data)); + try { + requestRecordService.saveRecord(record,0, 0, JSONObject.toJSONString(data)); + } catch (Exception e) { + log.error("发票同步接口记录保存失败,errormsg:{}",e.getMessage()); + e.printStackTrace(); + } return ResponseEntity.ok(JSONObject.toJSONString(data)); } else { @@ -779,7 +867,12 @@ public class SDNYMainProcessController extends AbstractController { R data = new R(1000, "default success"); data.put("data", ""); - requestRecordService.saveRecord(record,0, 0, JSONObject.toJSONString(data)); + try { + requestRecordService.saveRecord(record,0, 0, JSONObject.toJSONString(data)); + } catch (Exception e) { + log.error("发票同步接口记录保存失败,errormsg:{}",e.getMessage()); + e.printStackTrace(); + } return ResponseEntity.ok(JSONObject.toJSONString(data)); @@ -789,21 +882,36 @@ public class SDNYMainProcessController extends AbstractController { log.error("同步SAP失败,报错信息为:{}", exception); exception.printStackTrace(); - requestRecordService.saveRecord(record,1, 1, JSONObject.toJSONString(R.error(CommonConstants.CONNECT_TIMEOUT)),1); + try { + requestRecordService.saveRecord(record,1, 1, JSONObject.toJSONString(R.error(CommonConstants.CONNECT_TIMEOUT)),1); + } catch (Exception e) { + log.error("发票同步接口记录保存失败,errormsg:{}",e.getMessage()); + e.printStackTrace(); + } return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.CONNECT_TIMEOUT))); } catch(NullPointerException exception){ log.error("同步SAP失败,报错信息为:{}", exception); exception.printStackTrace(); - requestRecordService.saveRecord(record,1, 1, JSONObject.toJSONString(R.error(CommonConstants.NULL_POINTER_TIMEOUT)), 1); + try { + requestRecordService.saveRecord(record,1, 1, JSONObject.toJSONString(R.error(CommonConstants.NULL_POINTER_TIMEOUT)), 1); + } catch (Exception e) { + log.error("发票同步接口记录保存失败,errormsg:{}",e.getMessage()); + e.printStackTrace(); + } return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.NULL_POINTER_TIMEOUT))); } catch(Exception exception){ log.error("同步SAP失败,报错信息为:{}", exception); exception.printStackTrace(); - requestRecordService.saveRecord(record,1, 1, JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_DEFAULT)),1); + try { + requestRecordService.saveRecord(record,1, 1, JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_DEFAULT)),1); + } catch (Exception e) { + log.error("发票同步接口记录保存失败,errormsg:{}",e.getMessage()); + e.printStackTrace(); + } return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_DEFAULT))); }