k94314517
2024-03-17 947688a33cd6b76917eedd3765e88bd05fdeb20d
server/openapi/src/main/java/com/doumee/api/web/BizResourceController.java
@@ -1,14 +1,20 @@
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;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.model.ApiResponse;
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.core.erp.model.openapi.request.*;
import com.doumee.core.erp.model.openapi.response.*;
import com.doumee.core.utils.Constants;
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;
@@ -17,6 +23,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -40,6 +47,9 @@
    @Autowired
    private SystemDictDataBiz systemDictDataBiz;
    @Autowired
    private VisitsService visitsService;
    @ApiOperation(value = "调用凭据获取接口", notes = "访客端提供,供ERP端调用,向ERP提供统接口调用凭证")
    @GetMapping("/accesstoken")
@@ -48,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
@@ -59,9 +81,19 @@
    })
    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
    @ApiOperation(value = "停车场全量信息接口", notes = "访客端提供,供ERP端调用,ERP端同步全部停车场数据")
    @PostMapping("/resource/park/list")
    @ApiImplicitParams({
@@ -69,9 +101,19 @@
    })
    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
    @ApiOperation(value = "访客出入事件同步接口", notes = "访客端提供,供ERP端调用,ERP端获取访客出入记录信息")
    @PostMapping("/resource/visit/list")
    @ApiImplicitParams({
@@ -79,9 +121,19 @@
    })
    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
    @ApiOperation(value = "门禁出入事件同步接口", notes = "访客端提供,供ERP端调用,ERP端获取门禁出入记录信息")
    @PostMapping("/resource/doorEvent/list")
    @ApiImplicitParams({
@@ -89,9 +141,19 @@
    })
    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
    @ApiOperation(value = "车辆出入事件同步接口", notes = "访客端提供,供ERP端调用,ERP端获取车辆出入记录信息")
    @PostMapping("/resource/carvisit/list")
    @ApiImplicitParams({
@@ -99,9 +161,19 @@
    })
    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
    @ApiOperation(value = "组织变化接口", notes = "访客端提供,供ERP端调用,完成访客端组织信息同步,该接口支持单个组织新增、更新、删除需求")
    @PostMapping("/event/org/update")
    @ApiImplicitParams({
@@ -109,10 +181,19 @@
    })
    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
    @ApiOperation(value = "人员变化接口", notes = "访客端提供,供ERP端调用,完成访客端人员信息同步,该接口支持单个人员新增、更新、删除需求")
    @PostMapping("/event/user/update")
    @ApiImplicitParams({
@@ -120,30 +201,57 @@
    })
    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
    @ApiOperation(value = "人员门禁组授权接口", notes = "访客端提供,供ERP端调用,访客端人员同步门禁组授权信息,该接口支持人员门禁组授权新增、更新、清空需求。")
    @PostMapping("/event/role/userAuthor")
    @ApiImplicitParams({
            @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
    @ApiOperation(value = "车辆授权停车场接口", notes = "访客端提供,供ERP端调用,访客端同步车辆对停车场的使用权限,该接口支持车辆绑定、解绑归属人,支持新增、更新、清空车辆授权信息")
    @PostMapping("/event/park/carAuthor")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "授权token值", required = true)
    })
    public ApiResponse parkCarAuthor(@RequestBody CarAuthorRequest param) {
        erpSyncService.parkCarAuthor(param);
        return  ApiResponse.success(null);
        ApiResponse response = ApiResponse.success(null);
        try {
            erpSyncService.parkCarAuthor(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/park/carAuthor", JSONObject.toJSONString(response),Constants.ZERO);
        return  response;
    }
    @ErpLoginRequired
    @ApiOperation(value = "访客申请审批结果通知接口", notes = "访客端提供,供访客端调用,提交访客申请审批的结果")
    @PostMapping("/event/approve/notice")
    @ApiImplicitParams({
@@ -151,10 +259,37 @@
    })
    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
    @ApiOperation(value = "发起访客申请", notes = "访客端提供,供ERP端调用,ERP端发起访客申请")
    @PostMapping("/resource/createVisit")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "授权token值", required = true)
    })
    public ApiResponse  createVisit(@Valid @RequestBody ErpVisitDTO param) {
        param.setToken(this.getToken());
        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;
    }
    @ApiOperation(value = "FTP账户信息", notes = "访客端提供,供ERP端调用,FTP账户信息,其中【FTP资源访问映射地址】用于图片回显使用," +