package com.fzzy.igds.api.v1; import com.fzzy.igds.api.v1.data.ApiV1Req; import com.fzzy.igds.api.v1.data.ApiV1Resp; import com.fzzy.igds.api.v1.service.*; import com.fzzy.igds.api.v1.util.ApiV1Constant; import com.fzzy.igds.constant.Constant; import com.fzzy.igds.domain.GatewaySer; import com.fzzy.igds.service.GatewaySerService; import com.alibaba.fastjson.JSONObject; import lombok.extern.slf4j.Slf4j; import com.ruoyi.common.utils.StringUtils; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; /** * @Description 监管接口解析入口 * @Author CZT * @Date 2026/1/7 10:25 */ @Slf4j @Controller @RequestMapping("api/igdss/v1") public class ApiV1Controller { @Resource private GatewaySerService gatewaySerService; @Resource private ApiV1Service3010 apiV1Service3010; @Resource private ApiV1Service3020 apiV1Service3020; @Resource private ApiV1Service3021 apiV1Service3021; @Resource private ApiV1Service3030 apiV1Service3030; @Resource private ApiV1Service3031 apiV1Service3031; @PostMapping @ResponseBody public ApiV1Resp gateway(@RequestBody ApiV1Req req) { log.info("质押监管接口V1,收到库区网关信息={}", req); try { //参数校验 if (req == null) { return ApiV1Resp.error("参数有误!", req); } //校验接口编码和网关SN if (StringUtils.isEmpty(req.getFunctionId()) || StringUtils.isEmpty(req.getSn())) { return ApiV1Resp.error("参数有误!", req); } //校验网关是否存在 GatewaySer gatewaySer = gatewaySerService.getCacheSerById(null, req.getSn()); if (null == gatewaySer) { return ApiV1Resp.error("当前网关暂未添加,请核查!", req); } //异步更新网关状态 gatewaySerService.updateStatus(gatewaySer, Constant.YN_Y, ApiV1Constant.API_FUNCTION_3010.equals(req.getFunctionId())); //解析 String functionId = req.getFunctionId(); switch (functionId) { case ApiV1Constant.API_FUNCTION_3010: return apiV1Service3010.analysis(req, gatewaySer); case ApiV1Constant.API_FUNCTION_3020: return apiV1Service3020.analysis(req, gatewaySer); case ApiV1Constant.API_FUNCTION_3021: return apiV1Service3021.analysis(req, gatewaySer); case ApiV1Constant.API_FUNCTION_3030: return apiV1Service3030.analysis(req, gatewaySer); case ApiV1Constant.API_FUNCTION_3031: return apiV1Service3031.analysis(req, gatewaySer); } return ApiV1Resp.error("接口编码<" + functionId + ">不存在,请核查!", req); } catch (Exception e) { log.info("质押监管接口V1,接口解析异常={}", e.toString()); return ApiV1Resp.error("解析异常!", req); } } }