From 5134773e86c2cc9d31809b18d13585eb16393b19 Mon Sep 17 00:00:00 2001 From: fengyuan_yang <1976974459@qq.com> Date: Tue, 4 Nov 2025 16:17:32 +0800 Subject: [PATCH] =?UTF-8?q?2025-11-04=20pc=E6=8E=A5=E5=8F=A3=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../boxManage/data/SoReceiveCasesData.java | 1 + .../boxManage/entity/SoReceiveCases.java | 1 + .../controller/InterfaceLogController.java | 72 +++++++++ .../sys/dao/ApiLogValuesDetailDao.java | 25 +++ .../modules/sys/dao/ApiLogValuesHeadDao.java | 24 +++ .../modules/sys/dao/InterfaceLogDao.java | 32 ++++ .../modules/sys/entity/ApiLogEntity.java | 91 +++++++++++ .../sys/entity/ApiLogValuesDetailEntity.java | 56 +++++++ .../sys/entity/ApiLogValuesHeadEntity.java | 50 ++++++ .../sys/service/InterfaceLogService.java | 33 ++++ .../service/impl/InterfaceLogServiceImpl.java | 150 ++++++++++++++++++ .../mapper/sys/ApiLogValuesDetailDao.xml | 45 ++++++ .../mapper/sys/ApiLogValuesHeadDao.xml | 43 +++++ .../resources/mapper/sys/InterfaceLogDao.xml | 118 ++++++++++++++ 14 files changed, 741 insertions(+) create mode 100644 src/main/java/com/gaotao/modules/sys/controller/InterfaceLogController.java create mode 100644 src/main/java/com/gaotao/modules/sys/dao/ApiLogValuesDetailDao.java create mode 100644 src/main/java/com/gaotao/modules/sys/dao/ApiLogValuesHeadDao.java create mode 100644 src/main/java/com/gaotao/modules/sys/dao/InterfaceLogDao.java create mode 100644 src/main/java/com/gaotao/modules/sys/entity/ApiLogEntity.java create mode 100644 src/main/java/com/gaotao/modules/sys/entity/ApiLogValuesDetailEntity.java create mode 100644 src/main/java/com/gaotao/modules/sys/entity/ApiLogValuesHeadEntity.java create mode 100644 src/main/java/com/gaotao/modules/sys/service/InterfaceLogService.java create mode 100644 src/main/java/com/gaotao/modules/sys/service/impl/InterfaceLogServiceImpl.java create mode 100644 src/main/resources/mapper/sys/ApiLogValuesDetailDao.xml create mode 100644 src/main/resources/mapper/sys/ApiLogValuesHeadDao.xml create mode 100644 src/main/resources/mapper/sys/InterfaceLogDao.xml diff --git a/src/main/java/com/gaotao/modules/boxManage/data/SoReceiveCasesData.java b/src/main/java/com/gaotao/modules/boxManage/data/SoReceiveCasesData.java index 8508c36..c7a9b65 100644 --- a/src/main/java/com/gaotao/modules/boxManage/data/SoReceiveCasesData.java +++ b/src/main/java/com/gaotao/modules/boxManage/data/SoReceiveCasesData.java @@ -44,4 +44,5 @@ public class SoReceiveCasesData extends SoReceiveCases { + diff --git a/src/main/java/com/gaotao/modules/boxManage/entity/SoReceiveCases.java b/src/main/java/com/gaotao/modules/boxManage/entity/SoReceiveCases.java index 4283e8e..224d6f3 100644 --- a/src/main/java/com/gaotao/modules/boxManage/entity/SoReceiveCases.java +++ b/src/main/java/com/gaotao/modules/boxManage/entity/SoReceiveCases.java @@ -187,4 +187,5 @@ public class SoReceiveCases { + diff --git a/src/main/java/com/gaotao/modules/sys/controller/InterfaceLogController.java b/src/main/java/com/gaotao/modules/sys/controller/InterfaceLogController.java new file mode 100644 index 0000000..c753894 --- /dev/null +++ b/src/main/java/com/gaotao/modules/sys/controller/InterfaceLogController.java @@ -0,0 +1,72 @@ +package com.gaotao.modules.sys.controller; + +import com.gaotao.common.utils.PageUtils; +import com.gaotao.common.utils.R; +import com.gaotao.modules.sys.service.InterfaceLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +/** + * 接口日志管理 + */ +@RestController +@RequestMapping("/sys/interfaceLog") +public class InterfaceLogController { + + @Autowired + private InterfaceLogService interfaceLogService; + + /** + * 查询接口日志列表 + */ + @PostMapping("/list") + public R list(@RequestBody Map params) { + PageUtils page = interfaceLogService.queryPage(params); + return R.ok().put("page", page); + } + + /** + * 查询接口参数详情 + */ + @PostMapping("/getParams") + public R getParams(@RequestBody Map params) { + String site = (String) params.get("site"); + String buNo = (String) params.get("buNo"); + String requestId = (String) params.get("requestId"); + Integer requestGroupId = params.get("requestGroupId") != null ? + Integer.parseInt(params.get("requestGroupId").toString()) : null; + + return interfaceLogService.getParams(site, buNo, requestId, requestGroupId); + } + + /** + * 批量删除接口日志 + */ + @PostMapping("/delete") + public R delete(@RequestBody Map params) { + Object[] idsObj = (Object[]) params.get("ids"); + Long[] ids = new Long[idsObj.length]; + for (int i = 0; i < idsObj.length; i++) { + ids[i] = Long.parseLong(idsObj[i].toString()); + } + + return interfaceLogService.deleteBatch(ids); + } + + /** + * 批量重试接口 + */ + @PostMapping("/retry") + public R retry(@RequestBody Map params) { + Object[] idsObj = (Object[]) params.get("ids"); + Long[] ids = new Long[idsObj.length]; + for (int i = 0; i < idsObj.length; i++) { + ids[i] = Long.parseLong(idsObj[i].toString()); + } + + return interfaceLogService.retryBatch(ids); + } +} + diff --git a/src/main/java/com/gaotao/modules/sys/dao/ApiLogValuesDetailDao.java b/src/main/java/com/gaotao/modules/sys/dao/ApiLogValuesDetailDao.java new file mode 100644 index 0000000..63edcad --- /dev/null +++ b/src/main/java/com/gaotao/modules/sys/dao/ApiLogValuesDetailDao.java @@ -0,0 +1,25 @@ +package com.gaotao.modules.sys.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.gaotao.modules.sys.entity.ApiLogValuesDetailEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * 接口日志参数明细表DAO + */ +@Mapper +public interface ApiLogValuesDetailDao extends BaseMapper { + + /** + * 查询接口参数明细列表 + */ + List> queryDetailList(@Param("site") String site, + @Param("buNo") String buNo, + @Param("requestId") String requestId, + @Param("requestGroupId") Integer requestGroupId); +} + diff --git a/src/main/java/com/gaotao/modules/sys/dao/ApiLogValuesHeadDao.java b/src/main/java/com/gaotao/modules/sys/dao/ApiLogValuesHeadDao.java new file mode 100644 index 0000000..8cfc067 --- /dev/null +++ b/src/main/java/com/gaotao/modules/sys/dao/ApiLogValuesHeadDao.java @@ -0,0 +1,24 @@ +package com.gaotao.modules.sys.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.gaotao.modules.sys.entity.ApiLogValuesHeadEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Map; + +/** + * 接口日志参数主表DAO + */ +@Mapper +public interface ApiLogValuesHeadDao extends BaseMapper { + + /** + * 查询接口参数主表 + */ + Map queryHead(@Param("site") String site, + @Param("buNo") String buNo, + @Param("requestId") String requestId, + @Param("requestGroupId") Integer requestGroupId); +} + diff --git a/src/main/java/com/gaotao/modules/sys/dao/InterfaceLogDao.java b/src/main/java/com/gaotao/modules/sys/dao/InterfaceLogDao.java new file mode 100644 index 0000000..c72fee3 --- /dev/null +++ b/src/main/java/com/gaotao/modules/sys/dao/InterfaceLogDao.java @@ -0,0 +1,32 @@ +package com.gaotao.modules.sys.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.gaotao.modules.sys.entity.ApiLogEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * 接口日志DAO + */ +@Mapper +public interface InterfaceLogDao extends BaseMapper { + + /** + * 查询接口日志列表 + */ + List> queryList(Map params); + + /** + * 查询接口日志总数 + */ + int queryTotal(Map params); + + /** + * 批量删除 + */ + int deleteBatch(@Param("ids") Long[] ids); +} + diff --git a/src/main/java/com/gaotao/modules/sys/entity/ApiLogEntity.java b/src/main/java/com/gaotao/modules/sys/entity/ApiLogEntity.java new file mode 100644 index 0000000..3e386b0 --- /dev/null +++ b/src/main/java/com/gaotao/modules/sys/entity/ApiLogEntity.java @@ -0,0 +1,91 @@ +package com.gaotao.modules.sys.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 接口日志 + */ +@Data +@TableName("api_log") +public class ApiLogEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + private Long id; + + // 站点 + private String site; + + // BU编号 + private String buNo; + + // 接口日志ID + private String requestId; + + // 接口名称 + private String interfaceName; + + // 接口分组ID + private Integer requestGroupId; + + // 关联单据号 + private String reDocumentNo; + + // 关联单据类型 + private String reDocumentType; + + // 关联单号 + private String orderNo; + + // 关联单行号 + private String seqNo; + + // 状态码 + private String statusCode; + + // 消息 + private String message; + + // 请求数据 + private String requestData; + + // 来源系统 + private String sourceSystem; + + // 目标系统 + private String targetSystem; + + // 是否需要重试 + private Integer needRetryFlag; + + // 已重试次数 + private Integer retryCount; + + // 最大重试次数 + private Integer maxRetryCount; + + // 重试间隔(分钟) + private Integer retryInterval; + + // 下次重试时间 + private Date nextRetryTime; + + // 上次重试时间 + private Date lastRetryTime; + + // 上次返回内容 + private String lastResponseData; + + // 创建人 + private String createdBy; + + // 创建时间 + private Date createdDate; +} + diff --git a/src/main/java/com/gaotao/modules/sys/entity/ApiLogValuesDetailEntity.java b/src/main/java/com/gaotao/modules/sys/entity/ApiLogValuesDetailEntity.java new file mode 100644 index 0000000..8de93b9 --- /dev/null +++ b/src/main/java/com/gaotao/modules/sys/entity/ApiLogValuesDetailEntity.java @@ -0,0 +1,56 @@ +package com.gaotao.modules.sys.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 接口日志参数明细表 + */ +@Data +@TableName("api_log_values_detail") +public class ApiLogValuesDetailEntity implements Serializable { + private static final long serialVersionUID = 1L; + + // 站点 + private String site; + + // BU编号 + private String buNo; + + // 请求ID + private String requestId; + + // 请求分组ID + private Integer requestGroupId; + + // 接口参数1-20 + private String orderref1; + private String orderref2; + private String orderref3; + private String orderref4; + private String orderref5; + private String orderref6; + private String orderref7; + private String orderref8; + private String orderref9; + private String orderref10; + private String orderref11; + private String orderref12; + private String orderref13; + private String orderref14; + private String orderref15; + private String orderref16; + private String orderref17; + private String orderref18; + private String orderref19; + private String orderref20; + + // 分组ID + @TableId(type = IdType.AUTO) + private Integer groupId; +} + diff --git a/src/main/java/com/gaotao/modules/sys/entity/ApiLogValuesHeadEntity.java b/src/main/java/com/gaotao/modules/sys/entity/ApiLogValuesHeadEntity.java new file mode 100644 index 0000000..6cafd7a --- /dev/null +++ b/src/main/java/com/gaotao/modules/sys/entity/ApiLogValuesHeadEntity.java @@ -0,0 +1,50 @@ +package com.gaotao.modules.sys.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 接口日志参数主表 + */ +@Data +@TableName("api_log_values_head") +public class ApiLogValuesHeadEntity implements Serializable { + private static final long serialVersionUID = 1L; + + // 站点 + private String site; + + // BU编号 + private String buNo; + + // 请求ID + private String requestId; + + // 请求分组ID + private Integer requestGroupId; + + // 接口参数1-20 + private String orderref1; + private String orderref2; + private String orderref3; + private String orderref4; + private String orderref5; + private String orderref6; + private String orderref7; + private String orderref8; + private String orderref9; + private String orderref10; + private String orderref11; + private String orderref12; + private String orderref13; + private String orderref14; + private String orderref15; + private String orderref16; + private String orderref17; + private String orderref18; + private String orderref19; + private String orderref20; +} + diff --git a/src/main/java/com/gaotao/modules/sys/service/InterfaceLogService.java b/src/main/java/com/gaotao/modules/sys/service/InterfaceLogService.java new file mode 100644 index 0000000..cd01ba8 --- /dev/null +++ b/src/main/java/com/gaotao/modules/sys/service/InterfaceLogService.java @@ -0,0 +1,33 @@ +package com.gaotao.modules.sys.service; + +import com.gaotao.common.utils.PageUtils; +import com.gaotao.common.utils.R; + +import java.util.Map; + +/** + * 接口日志服务 + */ +public interface InterfaceLogService { + + /** + * 查询接口日志列表(分页) + */ + PageUtils queryPage(Map params); + + /** + * 查询接口参数(主表+明细) + */ + R getParams(String site, String buNo, String requestId, Integer requestGroupId); + + /** + * 批量删除接口日志 + */ + R deleteBatch(Long[] ids); + + /** + * 批量重试接口 + */ + R retryBatch(Long[] ids); +} + diff --git a/src/main/java/com/gaotao/modules/sys/service/impl/InterfaceLogServiceImpl.java b/src/main/java/com/gaotao/modules/sys/service/impl/InterfaceLogServiceImpl.java new file mode 100644 index 0000000..b368615 --- /dev/null +++ b/src/main/java/com/gaotao/modules/sys/service/impl/InterfaceLogServiceImpl.java @@ -0,0 +1,150 @@ +package com.gaotao.modules.sys.service.impl; + +import com.gaotao.common.utils.PageUtils; +import com.gaotao.common.utils.R; +import com.gaotao.modules.sys.dao.ApiLogValuesDetailDao; +import com.gaotao.modules.sys.dao.ApiLogValuesHeadDao; +import com.gaotao.modules.sys.dao.InterfaceLogDao; +import com.gaotao.modules.sys.service.InterfaceLogService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; + +/** + * 接口日志服务实现 + */ +@Service("interfaceLogService") +public class InterfaceLogServiceImpl implements InterfaceLogService { + + private static final Logger logger = LoggerFactory.getLogger(InterfaceLogServiceImpl.class); + + @Autowired + private InterfaceLogDao interfaceLogDao; + + @Autowired + private ApiLogValuesHeadDao apiLogValuesHeadDao; + + @Autowired + private ApiLogValuesDetailDao apiLogValuesDetailDao; + + @Override + public PageUtils queryPage(Map params) { + // 获取分页参数 + int page = Integer.parseInt(params.getOrDefault("page", 1).toString()); + int limit = Integer.parseInt(params.getOrDefault("limit", 10).toString()); + + // 计算offset + int offset = (page - 1) * limit; + params.put("offset", offset); + params.put("limit", limit); + + // 查询列表 + List> list = interfaceLogDao.queryList(params); + + // 查询总数 + int total = interfaceLogDao.queryTotal(params); + + // 构造分页结果 + PageUtils pageUtil = new PageUtils(list, total, limit, page); + + return pageUtil; + } + + @Override + public R getParams(String site, String buNo, String requestId, Integer requestGroupId) { + try { + // 查询主表数据 + Map head = apiLogValuesHeadDao.queryHead(site, buNo, requestId, requestGroupId); + + // 查询明细数据 + List> detailList = apiLogValuesDetailDao.queryDetailList(site, buNo, requestId, requestGroupId); + + // 构造返回的JSON结构 + Map result = new LinkedHashMap<>(); + + // 处理主表数据(将orderref1-20映射为"接口参数1"-"接口参数20") + if (head != null) { + for (int i = 1; i <= 20; i++) { + String key = "orderref" + i; + Object value = head.get(key); + if (value != null && !value.toString().trim().isEmpty()) { + result.put("接口参数" + i, value); + } + } + } + + // 处理明细数据 + if (detailList != null && !detailList.isEmpty()) { + List> detailResultList = new ArrayList<>(); + + for (Map detail : detailList) { + Map detailResult = new LinkedHashMap<>(); + + for (int i = 1; i <= 20; i++) { + String key = "orderref" + i; + Object value = detail.get(key); + if (value != null && !value.toString().trim().isEmpty()) { + detailResult.put("接口参数" + i, value); + } + } + + if (!detailResult.isEmpty()) { + detailResultList.add(detailResult); + } + } + + if (!detailResultList.isEmpty()) { + result.put("DetailList", detailResultList); + } + } + + return R.ok().put("params", result); + } catch (Exception e) { + logger.error("查询接口参数失败", e); + return R.error("查询接口参数失败: " + e.getMessage()); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public R deleteBatch(Long[] ids) { + try { + if (ids == null || ids.length == 0) { + return R.error("请选择要删除的记录"); + } + + int count = interfaceLogDao.deleteBatch(ids); + + return R.ok().put("count", count); + } catch (Exception e) { + logger.error("批量删除接口日志失败", e); + return R.error("批量删除失败: " + e.getMessage()); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public R retryBatch(Long[] ids) { + try { + if (ids == null || ids.length == 0) { + return R.error("请选择要重试的记录"); + } + + // TODO: 这里可以实现具体的重试逻辑 + // 例如:更新重试次数、下次重试时间等 + // 或者触发实际的接口调用 + + logger.info("批量重试接口,记录数: {}", ids.length); + + return R.ok().put("message", "重试请求已提交"); + } catch (Exception e) { + logger.error("批量重试接口失败", e); + return R.error("批量重试失败: " + e.getMessage()); + } + } +} + diff --git a/src/main/resources/mapper/sys/ApiLogValuesDetailDao.xml b/src/main/resources/mapper/sys/ApiLogValuesDetailDao.xml new file mode 100644 index 0000000..2ec8136 --- /dev/null +++ b/src/main/resources/mapper/sys/ApiLogValuesDetailDao.xml @@ -0,0 +1,45 @@ + + + + + + + + + + diff --git a/src/main/resources/mapper/sys/ApiLogValuesHeadDao.xml b/src/main/resources/mapper/sys/ApiLogValuesHeadDao.xml new file mode 100644 index 0000000..21102e4 --- /dev/null +++ b/src/main/resources/mapper/sys/ApiLogValuesHeadDao.xml @@ -0,0 +1,43 @@ + + + + + + + + + + diff --git a/src/main/resources/mapper/sys/InterfaceLogDao.xml b/src/main/resources/mapper/sys/InterfaceLogDao.xml new file mode 100644 index 0000000..05008ca --- /dev/null +++ b/src/main/resources/mapper/sys/InterfaceLogDao.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + DELETE FROM api_log WHERE id IN + + #{id} + + + + +