From 947688a33cd6b76917eedd3765e88bd05fdeb20d Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期日, 17 三月 2024 18:09:33 +0800
Subject: [PATCH] ERP接口

---
 server/openapi/src/main/java/com/doumee/api/web/BizResourceController.java |  135 ++++++++++++++++++++++++++++++++++++++------
 1 files changed, 116 insertions(+), 19 deletions(-)

diff --git a/server/openapi/src/main/java/com/doumee/api/web/BizResourceController.java b/server/openapi/src/main/java/com/doumee/api/web/BizResourceController.java
index e5a2eae..c077a10 100644
--- a/server/openapi/src/main/java/com/doumee/api/web/BizResourceController.java
+++ b/server/openapi/src/main/java/com/doumee/api/web/BizResourceController.java
@@ -1,5 +1,6 @@
 package com.doumee.api.web;
 
+import com.alibaba.fastjson.JSONObject;
 import com.doumee.biz.system.SystemDictDataBiz;
 import com.doumee.config.annotation.ErpLoginRequired;
 import com.doumee.core.constants.ResponseStatus;
@@ -13,6 +14,7 @@
 import com.doumee.dao.web.reqeust.ErpVisitDTO;
 import com.doumee.service.business.VisitsService;
 import com.doumee.service.business.ext.ERPSyncService;
+import com.google.gson.JsonObject;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -56,7 +58,19 @@
             @ApiImplicitParam(paramType = "query", dataType = "String", name = "accessSecret", value = "璁块棶绉橀挜锛岀敱璁垮绔彁渚�", required = true)
     })
     public ApiResponse<AccessTokenResponse> accesstoken(@RequestParam  String accessKey, @RequestParam  String accessSecret) {
-        return  ApiResponse.success(erpSyncService.createERPToken(accessKey,accessSecret));
+        ApiResponse response = ApiResponse.success(null);
+        try {
+            response.setData(erpSyncService.createERPToken(accessKey,accessSecret));
+        }catch (BusinessException e){
+            response = ApiResponse.failed(e.getCode(), e.getMessage());
+        }catch (Exception e){
+            response = ApiResponse.failed(ResponseStatus.SERVER_ERROR.getCode(),ResponseStatus.SERVER_ERROR.getMessage());
+        }
+        Map<String,String> param = new HashMap<>();
+        param.put("accessKey",accessKey);
+        param.put("accessSecret",accessSecret);
+        erpSyncService.saveInterfaceLog(param,"/visitbiz/accesstoken", JSONObject.toJSONString(response),Constants.ZERO);
+        return  response;
     }
 
     @ErpLoginRequired
@@ -67,7 +81,16 @@
     })
     public ApiResponse<List<RoleListResponse>> roleList(@RequestBody RoleListRequest param) {
         param.setToken(this.getToken());
-        return  ApiResponse.success(erpSyncService.erpQueryDeviceList(param));
+        ApiResponse response = ApiResponse.success(null);
+        try {
+            response.setData(erpSyncService.erpQueryDeviceList(param));
+        }catch (BusinessException e){
+            response = ApiResponse.failed(e.getCode(), e.getMessage());
+        }catch (Exception e){
+            response = ApiResponse.failed(ResponseStatus.SERVER_ERROR.getCode(),ResponseStatus.SERVER_ERROR.getMessage());
+        }
+        erpSyncService.saveInterfaceLog(param,"/visitbiz/resource/role/lis", JSONObject.toJSONString(response),Constants.ZERO);
+        return  response;
     }
 
     @ErpLoginRequired
@@ -78,7 +101,16 @@
     })
     public ApiResponse<List<ParkListResponse>> parkList(@RequestBody ParkListRequest param) {
         param.setToken(this.getToken());
-        return  ApiResponse.success(erpSyncService.parkList(param));
+        ApiResponse response = ApiResponse.success(null);
+        try {
+            response.setData(erpSyncService.parkList(param));
+        }catch (BusinessException e){
+            response = ApiResponse.failed(e.getCode(), e.getMessage());
+        }catch (Exception e){
+            response = ApiResponse.failed(ResponseStatus.SERVER_ERROR.getCode(),ResponseStatus.SERVER_ERROR.getMessage());
+        }
+        erpSyncService.saveInterfaceLog(param,"/visitbiz/resource/role/list", JSONObject.toJSONString(response),Constants.ZERO);
+        return  response;
     }
 
     @ErpLoginRequired
@@ -89,7 +121,16 @@
     })
     public ApiResponse<PageData<VisitEventListResponse>> visitList (@RequestBody PageWrap<VisitListRequest> pageWrap) {
         pageWrap.getModel().setToken(this.getToken());
-        return ApiResponse.success(erpSyncService.visitListPage(pageWrap));
+        ApiResponse response = ApiResponse.success(null);
+        try {
+            response.setData(erpSyncService.visitListPage(pageWrap));
+        }catch (BusinessException e){
+            response = ApiResponse.failed(e.getCode(), e.getMessage());
+        }catch (Exception e){
+            response = ApiResponse.failed(ResponseStatus.SERVER_ERROR.getCode(),ResponseStatus.SERVER_ERROR.getMessage());
+        }
+        erpSyncService.saveInterfaceLog(pageWrap,"/visitbiz/resource/visit/list", JSONObject.toJSONString(response),Constants.ZERO);
+        return response;
     }
 
     @ErpLoginRequired
@@ -100,7 +141,16 @@
     })
     public ApiResponse<PageData<DoorEventListResponse>> doorEventList (@RequestBody PageWrap<DoorEventListRequest> pageWrap) {
         pageWrap.getModel().setToken(this.getToken());
-        return ApiResponse.success(erpSyncService.doorEventListPage(pageWrap));
+        ApiResponse response = ApiResponse.success(null);
+        try {
+            response.setData(erpSyncService.doorEventListPage(pageWrap));
+        }catch (BusinessException e){
+            response = ApiResponse.failed(e.getCode(), e.getMessage());
+        }catch (Exception e){
+            response = ApiResponse.failed(ResponseStatus.SERVER_ERROR.getCode(),ResponseStatus.SERVER_ERROR.getMessage());
+        }
+        erpSyncService.saveInterfaceLog(pageWrap,"/visitbiz/resource/doorEvent/list", JSONObject.toJSONString(response),Constants.ZERO);
+        return response;
     }
 
     @ErpLoginRequired
@@ -111,7 +161,16 @@
     })
     public ApiResponse<PageData<CarEventListResponse>> carEventList (@RequestBody PageWrap<CarEventListRequest> pageWrap) {
         pageWrap.getModel().setToken(this.getToken());
-        return ApiResponse.success(erpSyncService.carEventList(pageWrap));
+        ApiResponse response = ApiResponse.success(null);
+        try {
+            response.setData(erpSyncService.carEventList(pageWrap));
+        }catch (BusinessException e){
+            response = ApiResponse.failed(e.getCode(), e.getMessage());
+        }catch (Exception e){
+            response = ApiResponse.failed(ResponseStatus.SERVER_ERROR.getCode(),ResponseStatus.SERVER_ERROR.getMessage());
+        }
+        erpSyncService.saveInterfaceLog(pageWrap,"/visitbiz/resource/carvisit/list", JSONObject.toJSONString(response),Constants.ZERO);
+        return response;
     }
 
     @ErpLoginRequired
@@ -122,8 +181,16 @@
     })
     public ApiResponse orgUpdate(@RequestBody OrgUpdateRequest param) {
         param.setToken(this.getToken());
-        erpSyncService.orgUpdate(param);
-        return  ApiResponse.success(null);
+        ApiResponse response = ApiResponse.success(null);
+        try {
+            erpSyncService.orgUpdate(param);
+        }catch (BusinessException e){
+            response = ApiResponse.failed(e.getCode(), e.getMessage());
+        }catch (Exception e){
+            response = ApiResponse.failed(ResponseStatus.SERVER_ERROR.getCode(),ResponseStatus.SERVER_ERROR.getMessage());
+        }
+        erpSyncService.saveInterfaceLog(param,"/visitbiz/event/org/update", JSONObject.toJSONString(response),Constants.ZERO);
+        return  response;
     }
 
     @ErpLoginRequired
@@ -134,8 +201,16 @@
     })
     public ApiResponse userUpdate(@RequestBody UserUpdateRequest param) {
         param.setToken(this.getToken());
-        erpSyncService.userUpdate(param);
-        return  ApiResponse.success(null);
+        ApiResponse response = ApiResponse.success(null);
+        try {
+            erpSyncService.userUpdate(param);
+        }catch (BusinessException e){
+            response = ApiResponse.failed(e.getCode(), e.getMessage());
+        }catch (Exception e){
+            response = ApiResponse.failed(ResponseStatus.SERVER_ERROR.getCode(),ResponseStatus.SERVER_ERROR.getMessage());
+        }
+        erpSyncService.saveInterfaceLog(param,"/visitbiz/event/user/update", JSONObject.toJSONString(response),Constants.ZERO);
+        return  response;
     }
 
     @ErpLoginRequired
@@ -145,8 +220,16 @@
             @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "鎺堟潈token鍊�", required = true)
     })
     public ApiResponse roleUserAuthor(@RequestBody UserAuthorRequest param) {
-        erpSyncService.roleUserAuthor(param);
-        return  ApiResponse.success(null);
+        ApiResponse response = ApiResponse.success(null);
+        try {
+            erpSyncService.roleUserAuthor(param);
+        }catch (BusinessException e){
+            response = ApiResponse.failed(e.getCode(), e.getMessage());
+        }catch (Exception e){
+            response = ApiResponse.failed(ResponseStatus.SERVER_ERROR.getCode(),ResponseStatus.SERVER_ERROR.getMessage());
+        }
+        erpSyncService.saveInterfaceLog(param,"/visitbiz/event/role/userAuthor", JSONObject.toJSONString(response),Constants.ZERO);
+        return  response;
     }
 
     @ErpLoginRequired
@@ -164,9 +247,7 @@
         }catch (Exception e){
             response = ApiResponse.failed(ResponseStatus.SERVER_ERROR.getCode(),ResponseStatus.SERVER_ERROR.getMessage());
         }
-        //-----TODO-------璁版棩蹇�-------start-----
-
-        //-----TODO-------璁版棩蹇�-------end-----
+        erpSyncService.saveInterfaceLog(param,"/visitbiz/event/park/carAuthor", JSONObject.toJSONString(response),Constants.ZERO);
         return  response;
     }
 
@@ -178,8 +259,16 @@
     })
     public ApiResponse approveApply(@RequestBody ApproveNoticeRequest param) {
         param.setToken(this.getToken());
-        erpSyncService.approveApply(param);
-        return  ApiResponse.success(null);
+        ApiResponse response = ApiResponse.success(null);
+        try {
+            erpSyncService.approveApply(param);
+        }catch (BusinessException e){
+            response = ApiResponse.failed(e.getCode(), e.getMessage());
+        }catch (Exception e){
+            response = ApiResponse.failed(ResponseStatus.SERVER_ERROR.getCode(),ResponseStatus.SERVER_ERROR.getMessage());
+        }
+        erpSyncService.saveInterfaceLog(param,"/visitbiz/event/approve/notice", JSONObject.toJSONString(response),Constants.ZERO);
+        return  response;
     }
 
     @ErpLoginRequired
@@ -190,8 +279,16 @@
     })
     public ApiResponse  createVisit(@Valid @RequestBody ErpVisitDTO param) {
         param.setToken(this.getToken());
-        visitsService.createFKForErp(param);
-        return  ApiResponse.success("鎿嶄綔鎴愬姛");
+        ApiResponse response = ApiResponse.success(null);
+        try {
+            visitsService.createFKForErp(param);
+        }catch (BusinessException e){
+            response = ApiResponse.failed(e.getCode(), e.getMessage());
+        }catch (Exception e){
+            response = ApiResponse.failed(ResponseStatus.SERVER_ERROR.getCode(),ResponseStatus.SERVER_ERROR.getMessage());
+        }
+        erpSyncService.saveInterfaceLog(param,"/visitbiz/resource/createVisit", JSONObject.toJSONString(response),Constants.ZERO);
+        return  response;
     }
 
 

--
Gitblit v1.9.3