新火炬后端单体项目初始化代码
zhangherong
9 天以前 e6d788eef335aa02ac306e984c44affa68ab971c
art: 新增系统第三方集成调用日志表,切面服务实现
已添加9个文件
已修改5个文件
1040 ■■■■■ 文件已修改
db/双林新火炬MES数据库设计.pdma.json 450 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/codegenerate/JeecgOneUtil.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/common/aspect/ApiLogAspect.java 152 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/common/aspect/annotation/ApiLog.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/common/constant/ApiLogCategoryEnum.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/sap/controller/SAPTestController.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/sap/service/ProductionOrderSync.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/sap/service/impl/ProductionOrderSyncImpl.java 174 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/system/controller/SysApiLogController.java 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/system/entity/SysApiLog.java 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/system/mapper/SysApiLogMapper.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/system/mapper/xml/SysApiLogMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/system/service/ISysApiLogService.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/system/service/impl/SysApiLogServiceImpl.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
db/Ë«ÁÖлð¾æMESÊý¾Ý¿âÉè¼Æ.pdma.json
@@ -2,9 +2,9 @@
  "name": "双林新火炬MES数据库设计",
  "describe": "描述双薪新火炬MES数据库设计详情",
  "avatar": "",
  "version": "4.9.4",
  "version": "4.9.2",
  "createdTime": "2025-3-10 16:38:19",
  "updatedTime": "2025-7-28 20:46:22",
  "updatedTime": "2025-7-30 14:19:17",
  "dbConns": [],
  "profile": {
    "default": {
@@ -68299,6 +68299,449 @@
      "correlations": [],
      "indexes": [],
      "type": "P"
    },
    {
      "id": "8C08DDB8-C3E9-4FBF-B4CE-EAB9BCFE1E38",
      "env": {
        "base": {
          "nameSpace": "",
          "codeRoot": ""
        }
      },
      "defKey": "sys_api_log",
      "defName": "系统第三方集成接口日志",
      "comment": "",
      "properties": {
        "partitioned by": "(date string)",
        "row format delimited": "",
        "fields terminated by ','": "",
        "collection items terminated by '-'": "",
        "map keys terminated by ':'": "",
        "store as textfile;": ""
      },
      "sysProps": {
        "nameTemplate": "{defKey}[{defName}]"
      },
      "notes": {},
      "headers": [
        {
          "refKey": "hideInGraph",
          "hideInGraph": true
        },
        {
          "refKey": "defKey",
          "freeze": false,
          "hideInGraph": false
        },
        {
          "refKey": "defName",
          "freeze": false,
          "hideInGraph": false
        },
        {
          "refKey": "primaryKey",
          "freeze": false,
          "hideInGraph": false
        },
        {
          "refKey": "notNull",
          "freeze": false,
          "hideInGraph": true
        },
        {
          "refKey": "autoIncrement",
          "freeze": false,
          "hideInGraph": true
        },
        {
          "refKey": "domain",
          "freeze": false,
          "hideInGraph": true
        },
        {
          "refKey": "type",
          "freeze": false,
          "hideInGraph": false
        },
        {
          "refKey": "len",
          "freeze": false,
          "hideInGraph": false
        },
        {
          "refKey": "scale",
          "freeze": false,
          "hideInGraph": false
        },
        {
          "refKey": "comment",
          "freeze": false,
          "hideInGraph": true
        },
        {
          "refKey": "refDict",
          "freeze": false,
          "hideInGraph": true
        },
        {
          "refKey": "defaultValue",
          "freeze": false,
          "hideInGraph": true
        },
        {
          "refKey": "isStandard",
          "freeze": false,
          "hideInGraph": false
        },
        {
          "refKey": "uiHint",
          "freeze": false,
          "hideInGraph": true
        },
        {
          "refKey": "extProps",
          "freeze": false,
          "hideInGraph": true
        },
        {
          "refKey": "attr1",
          "freeze": false,
          "hideInGraph": true
        },
        {
          "refKey": "attr2",
          "freeze": false,
          "hideInGraph": true
        },
        {
          "refKey": "attr3",
          "freeze": false,
          "hideInGraph": true
        },
        {
          "refKey": "attr4",
          "freeze": false,
          "hideInGraph": true
        },
        {
          "refKey": "attr5",
          "freeze": false,
          "hideInGraph": true
        },
        {
          "refKey": "attr6",
          "freeze": false,
          "hideInGraph": true
        },
        {
          "refKey": "attr7",
          "freeze": false,
          "hideInGraph": true
        },
        {
          "refKey": "attr8",
          "freeze": false,
          "hideInGraph": true
        },
        {
          "refKey": "attr9",
          "freeze": false,
          "hideInGraph": true
        }
      ],
      "fields": [
        {
          "defKey": "id",
          "defName": "主键",
          "comment": "",
          "type": "",
          "len": "",
          "scale": "",
          "primaryKey": true,
          "notNull": true,
          "autoIncrement": false,
          "defaultValue": "",
          "hideInGraph": false,
          "refDict": "",
          "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64",
          "extProps": {},
          "domain": "16120F75-6AA7-4483-868D-F07F511BB081",
          "id": "493A6ADA-F893-45D2-AC93-D3090DC02B0D"
        },
        {
          "defKey": "create_by",
          "defName": "创建人",
          "comment": "",
          "domain": "54611CCC-CA4B-42E1-9F32-4944C85B85A6",
          "type": "",
          "len": "",
          "scale": "",
          "primaryKey": false,
          "notNull": false,
          "autoIncrement": false,
          "defaultValue": "",
          "hideInGraph": true,
          "refDict": "",
          "uiHint": "",
          "id": "C9EFA288-7FAB-408E-87FB-91A4C08BDF73",
          "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64"
        },
        {
          "defKey": "create_time",
          "defName": "创建时间",
          "comment": "",
          "domain": "7CFFA0D3-6A93-4DDC-BC10-DF21211064DC",
          "type": "",
          "len": "",
          "scale": "",
          "primaryKey": false,
          "notNull": false,
          "autoIncrement": false,
          "defaultValue": "",
          "hideInGraph": true,
          "refDict": "",
          "uiHint": "",
          "id": "E239E79C-CBF1-42DA-907E-2FCADECD2C67",
          "baseType": "89D69E81-EA34-42EE-9FA2-93B8BD27E098"
        },
        {
          "defKey": "api_category",
          "defName": "API分类",
          "comment": "",
          "type": "",
          "len": "",
          "scale": "",
          "primaryKey": false,
          "notNull": false,
          "autoIncrement": false,
          "defaultValue": "",
          "hideInGraph": false,
          "refDict": "",
          "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64",
          "extProps": {},
          "domain": "73FD2BAD-2358-4336-B96D-45DC897BD792",
          "id": "F49D357B-7349-4B9D-9907-191F2F94DA3B"
        },
        {
          "defKey": "api_name",
          "defName": "接口名称",
          "comment": "",
          "type": "",
          "len": "",
          "scale": "",
          "primaryKey": false,
          "notNull": false,
          "autoIncrement": false,
          "defaultValue": "",
          "hideInGraph": false,
          "refDict": "",
          "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64",
          "extProps": {},
          "domain": "9092C4E0-1A54-4859-ABBB-5B62DBC27573",
          "id": "66F55A69-EE62-442E-926D-97695E82BE19"
        },
        {
          "defKey": "request_time",
          "defName": "请求时间",
          "comment": "",
          "type": "",
          "len": "",
          "scale": "",
          "primaryKey": false,
          "notNull": false,
          "autoIncrement": false,
          "defaultValue": "",
          "hideInGraph": false,
          "refDict": "",
          "baseType": "89D69E81-EA34-42EE-9FA2-93B8BD27E098",
          "extProps": {},
          "domain": "7CFFA0D3-6A93-4DDC-BC10-DF21211064DC",
          "id": "42B46C10-65A4-410E-A238-3A3F86018945"
        },
        {
          "defKey": "response_time",
          "defName": "响应时间",
          "comment": "",
          "type": "",
          "len": "",
          "scale": "",
          "primaryKey": false,
          "notNull": false,
          "autoIncrement": false,
          "defaultValue": "",
          "hideInGraph": false,
          "refDict": "",
          "baseType": "89D69E81-EA34-42EE-9FA2-93B8BD27E098",
          "extProps": {},
          "domain": "7CFFA0D3-6A93-4DDC-BC10-DF21211064DC",
          "id": "628E5760-93A0-4779-85A9-C0231AD79EBC"
        },
        {
          "defKey": "request_method",
          "defName": "请求方式",
          "comment": "",
          "type": "",
          "len": "",
          "scale": "",
          "primaryKey": false,
          "notNull": false,
          "autoIncrement": false,
          "defaultValue": "",
          "hideInGraph": false,
          "refDict": "",
          "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64",
          "extProps": {},
          "domain": "73FD2BAD-2358-4336-B96D-45DC897BD792",
          "id": "AF639452-207A-474B-9C76-266BDD0F6BA5"
        },
        {
          "defKey": "request_url",
          "defName": "请求URL",
          "comment": "",
          "type": "",
          "len": "",
          "scale": "",
          "primaryKey": false,
          "notNull": false,
          "autoIncrement": false,
          "defaultValue": "",
          "hideInGraph": false,
          "refDict": "",
          "baseType": "B17BDED3-085F-40E1-9019-3B79CF2BF075",
          "extProps": {},
          "domain": "13DE7063-440C-426F-B1DF-25EC824C6DB8",
          "id": "A3AD6177-3EAE-4ADC-BC22-1B29AC035DD1"
        },
        {
          "defKey": "request_headers",
          "defName": "请求头",
          "comment": "",
          "type": "",
          "len": "",
          "scale": "",
          "primaryKey": false,
          "notNull": false,
          "autoIncrement": false,
          "defaultValue": "",
          "hideInGraph": false,
          "refDict": "",
          "baseType": "B17BDED3-085F-40E1-9019-3B79CF2BF075",
          "extProps": {},
          "domain": "13DE7063-440C-426F-B1DF-25EC824C6DB8",
          "id": "2BA704F8-36C4-4B4D-BF63-C721376D4B7E"
        },
        {
          "defKey": "request_body",
          "defName": "请求体",
          "comment": "",
          "type": "",
          "len": "",
          "scale": "",
          "primaryKey": false,
          "notNull": false,
          "autoIncrement": false,
          "defaultValue": "",
          "hideInGraph": false,
          "refDict": "",
          "baseType": "B17BDED3-085F-40E1-9019-3B79CF2BF075",
          "extProps": {},
          "domain": "13DE7063-440C-426F-B1DF-25EC824C6DB8",
          "id": "4DBE1100-12B3-4CFD-B0B1-4AFE5A9033AB"
        },
        {
          "defKey": "response_code",
          "defName": "响应编码",
          "comment": "",
          "type": "",
          "len": "",
          "scale": "",
          "primaryKey": false,
          "notNull": false,
          "autoIncrement": false,
          "defaultValue": "",
          "hideInGraph": false,
          "refDict": "",
          "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64",
          "extProps": {},
          "domain": "54611CCC-CA4B-42E1-9F32-4944C85B85A6",
          "id": "4CD23738-EE0F-4029-9465-9CDF3E7CD461"
        },
        {
          "defKey": "response_message",
          "defName": "响应消息",
          "comment": "",
          "type": "",
          "len": "",
          "scale": "",
          "primaryKey": false,
          "notNull": false,
          "autoIncrement": false,
          "defaultValue": "",
          "hideInGraph": false,
          "refDict": "",
          "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64",
          "extProps": {},
          "domain": "9092C4E0-1A54-4859-ABBB-5B62DBC27573",
          "id": "E872F6CA-7D7A-40F1-959D-FD35447BB5A1"
        },
        {
          "defKey": "response_body",
          "defName": "响应体",
          "comment": "",
          "type": "",
          "len": "",
          "scale": "",
          "primaryKey": false,
          "notNull": false,
          "autoIncrement": false,
          "defaultValue": "",
          "hideInGraph": false,
          "refDict": "",
          "baseType": "B17BDED3-085F-40E1-9019-3B79CF2BF075",
          "extProps": {},
          "domain": "13DE7063-440C-426F-B1DF-25EC824C6DB8",
          "id": "AC48A8A8-E320-4E79-AFA7-4FDB1059961F"
        },
        {
          "defKey": "request_status",
          "defName": "状态",
          "comment": "成功、失败",
          "type": "",
          "len": "",
          "scale": "",
          "primaryKey": false,
          "notNull": false,
          "autoIncrement": false,
          "defaultValue": "",
          "hideInGraph": false,
          "refDict": "",
          "baseType": "1D764C4A-6F9F-421E-B11A-6F3E23B51811",
          "extProps": {},
          "domain": "6BC8F04B-6CFA-4995-98D3-318F5CDD774E",
          "id": "4CCFBCCD-0681-4B6F-BAE8-624063397C72"
        },
        {
          "defKey": "method",
          "defName": "调用方法",
          "comment": "",
          "type": "",
          "len": "",
          "scale": "",
          "primaryKey": false,
          "notNull": false,
          "autoIncrement": false,
          "defaultValue": "",
          "hideInGraph": false,
          "refDict": "",
          "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64",
          "extProps": {},
          "domain": "9092C4E0-1A54-4859-ABBB-5B62DBC27573",
          "id": "112770C9-963A-40F4-BCDF-289177A84824"
        }
      ],
      "correlations": [],
      "indexes": [],
      "type": "P"
    }
  ],
  "views": [],
@@ -69073,7 +69516,8 @@
        "ED18EDD7-96F9-4CCA-93F0-633567955063",
        "ADF40C7F-5C97-4196-BCA7-E780FCC8E2FB",
        "27A01955-9C87-4E63-9A2A-8B489835879F",
        "D36AAD93-CF06-45C1-8058-430304D98601"
        "D36AAD93-CF06-45C1-8058-430304D98601",
        "8C08DDB8-C3E9-4FBF-B4CE-EAB9BCFE1E38"
      ],
      "refViews": [],
      "refDiagrams": [],
src/main/java/org/jeecg/codegenerate/JeecgOneUtil.java
@@ -6,10 +6,10 @@
public class JeecgOneUtil {
    public static void main(String[] args) throws Exception {
        TableVo tableVo = new TableVo();
        tableVo.setTableName("lsw_material");
        tableVo.setEntityName("LswMaterial");
        tableVo.setEntityPackage("lsw");
        tableVo.setFtlDescription("线边库物料信息");
        tableVo.setTableName("sys_api_log");
        tableVo.setEntityName("SysApiLog");
        tableVo.setEntityPackage("system");
        tableVo.setFtlDescription("系统第三方集成接口日志");
        new CodeGenerateOne(tableVo).generateCodeFile(null);
    }
}
src/main/java/org/jeecg/common/aspect/ApiLogAspect.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,152 @@
package org.jeecg.common.aspect;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sap.conn.jco.*;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.jeecg.common.aspect.annotation.ApiLog;
import org.jeecg.common.constant.ApiLogCategoryEnum;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.modules.mdc.util.ThrowableUtil;
import org.jeecg.modules.system.entity.SysApiLog;
import org.jeecg.modules.system.service.ISysApiLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Aspect
@Component
public class ApiLogAspect {
    @Autowired
    private ISysApiLogService apiLogService;
    @Autowired
    private ObjectMapper objectMapper;
    @Pointcut("@annotation(org.jeecg.common.aspect.annotation.ApiLog)")
    public void logPointCut() {
    }
    @Around("logPointCut()")
    public Object around(ProceedingJoinPoint point) {
        SysApiLog dto = new SysApiLog();
        dto.setRequestTime(new Date());
        //执行方法
        Object result = null;
        try {
            result = point.proceed();
            //执行时长(毫秒)
            dto.setResponseTime(new Date());
            //保存日志
            saveApiLog(dto, point, result);
        } catch (Throwable e) {
            //执行时长(毫秒)
            dto.setResponseTime(new Date());
            //保存日志
            saveErrorLog(dto, point, e);
        }
        return result;
    }
    private void saveApiLog(SysApiLog dto, ProceedingJoinPoint joinPoint, Object result) {
        MethodSignature signature = (MethodSignature) joinPoint.getSignature();
        Method method = signature.getMethod();
        ApiLog syslog = method.getAnnotation(ApiLog.class);
        if (syslog != null) {
            String apiName = syslog.apiName();
            ApiLogCategoryEnum apiCategory = syslog.apiCategory();
            //注解上的描述,操作日志内容
            dto.setApiName(apiName);
            dto.setApiCategory(apiCategory.name());
            switch (apiCategory) {
                case SAP:
                    dto.setRequestMethod("RFC");
                    if (result instanceof Map) {
                        Map<String, Object> map = (Map<String, Object>) result;
                        dto.setResponseCode(map.get("ztype").toString());
                        dto.setResponseMessage(map.get("zmess").toString());
                        dto.setRequestBody(map.get("importParameters").toString());
                        dto.setResponseBody(parseSAPResponseResult(map.get("result")));
                    }
                    break;
                case WMS:
                    dto.setRequestMethod("Webservice");
                    break;
                case FEI_SHU:
                    dto.setRequestMethod("Http");
                    break;
            }
        }
        //请求的方法名
        String className = joinPoint.getTarget().getClass().getName();
        String methodName = signature.getName();
        dto.setMethod(className + "." + methodName + "()");
        dto.setRequestStatus(0);
        apiLogService.save(dto);
    }
    private void saveErrorLog(SysApiLog dto, ProceedingJoinPoint joinPoint, Throwable e) {
        MethodSignature signature = (MethodSignature) joinPoint.getSignature();
        Method method = signature.getMethod();
        ApiLog syslog = method.getAnnotation(ApiLog.class);
        if (syslog != null) {
            String apiName = syslog.apiName();
            ApiLogCategoryEnum apiCategory = syslog.apiCategory();
            //注解上的描述,操作日志内容
            dto.setApiName(apiName);
            dto.setApiCategory(apiCategory.name());
            switch (apiCategory) {
                case SAP:
                    dto.setRequestMethod("RFC");
                    break;
                case WMS:
                    dto.setRequestMethod("Webservice");
                    break;
                case FEI_SHU:
                    dto.setRequestMethod("Http");
                    break;
            }
        }
        //请求的方法名
        String className = joinPoint.getTarget().getClass().getName();
        String methodName = signature.getName();
        dto.setMethod(className + "." + methodName + "()");
        dto.setRequestStatus(-1);
        dto.setResponseCode("-1");
        dto.setResponseMessage("请求异常,请查看响应体!");
        dto.setResponseBody(ThrowableUtil.getStackTrace(e));
        apiLogService.save(dto);
    }
    private String parseSAPResponseResult(Object result) {
        List<JSONObject> items = new ArrayList<>();
        if (result instanceof List) {
            List<Object> list = (List<Object>) result;
            try {
                for (Object obj : list) {
                    String json = objectMapper.writeValueAsString(obj);
                    JSONObject item = JSONObject.parseObject(json, Feature.OrderedField);
                    items.add(item);
                }
            } catch (JsonProcessingException e) {
                throw new JeecgBootException(e);
            }
        }
        return items.toString();
    }
}
src/main/java/org/jeecg/common/aspect/annotation/ApiLog.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,22 @@
package org.jeecg.common.aspect.annotation;
import org.jeecg.common.constant.ApiLogCategoryEnum;
import java.lang.annotation.*;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ApiLog {
    /**
     * API名称
     * @return
     */
    String apiName() default "";
    /**
     * API分类
     * @return
     */
    ApiLogCategoryEnum apiCategory() default ApiLogCategoryEnum.SAP;
}
src/main/java/org/jeecg/common/constant/ApiLogCategoryEnum.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,21 @@
package org.jeecg.common.constant;
/**
 * ç¬¬ä¸‰æ–¹é›†æˆæŽ¥å£å¯¹æŽ¥ç±»åž‹
 */
public enum ApiLogCategoryEnum {
    SAP,  //SAP接口对接
    WMS, //WMS接口对接
    FEI_SHU, //飞书接口对接
    ;
    public static ApiLogCategoryEnum getInstance(String code) {
        ApiLogCategoryEnum[] values = ApiLogCategoryEnum.values();
        for (ApiLogCategoryEnum value : values) {
            if (value.name().equals(code)) {
                return value;
            }
        }
        return null;
    }
}
src/main/java/org/jeecg/modules/sap/controller/SAPTestController.java
@@ -11,6 +11,8 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@Api(tags = "SAP集成测试")
@RestController
@RequestMapping("/sap/client")
@@ -28,10 +30,10 @@
        return Result.ok(test);
    }
    @ApiOperation(value = "SAP集成测试-测试接口", notes = "SAP集成测试-测试接口")
    @ApiOperation(value = "SAP集成测试-生产订单同步接口", notes = "SAP集成测试-生产订单同步接口")
    @GetMapping("/syncProductionOrder")
    public Result<?> syncProductionOrder() {
        productionOrderSync.syncProductionOrder();
        return Result.ok();
    public Result<?> syncProductionOrder() throws Exception {
        Map<String, Object> resultMap = productionOrderSync.syncProductionOrder();
        return Result.ok(resultMap);
    }
}
src/main/java/org/jeecg/modules/sap/service/ProductionOrderSync.java
@@ -1,8 +1,10 @@
package org.jeecg.modules.sap.service;
import java.util.Map;
public interface ProductionOrderSync {
    /**
     * åŒæ­¥ç”Ÿæˆè®¢å•
     */
    void syncProductionOrder();
    Map<String, Object> syncProductionOrder() throws Exception;
}
src/main/java/org/jeecg/modules/sap/service/impl/ProductionOrderSyncImpl.java
@@ -1,7 +1,13 @@
package org.jeecg.modules.sap.service.impl;
import com.sap.conn.jco.*;
import com.alibaba.fastjson.JSONObject;
import com.sap.conn.jco.JCoDestination;
import com.sap.conn.jco.JCoFunction;
import com.sap.conn.jco.JCoRepository;
import com.sap.conn.jco.JCoTable;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.aspect.annotation.ApiLog;
import org.jeecg.common.constant.ApiLogCategoryEnum;
import org.jeecg.config.sap.SapRfcConnectionManager;
import org.jeecg.modules.sap.FunctionConst;
import org.jeecg.modules.sap.dto.ProductionOrderDTO;
@@ -10,7 +16,9 @@
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * ç”Ÿæˆè®¢å•同步服务
@@ -35,81 +43,97 @@
    @Override
    public void syncProductionOrder() {
    @ApiLog(apiName = "生产订单同步接口(ZPPF_033_1)", apiCategory = ApiLogCategoryEnum.SAP)
    public Map<String, Object> syncProductionOrder() throws Exception {
        Map<String, Object> resultMap = new HashMap<>();
        JCoDestination destination = connectionManager.getDestination();
        try {
            JCoRepository repository = destination.getRepository();
            JCoFunction function = repository.getFunction(FunctionConst.ZPPF_033_1);
            if (function == null) {
                throw new RuntimeException("RFC å‡½æ•° ZPPF_033_1 æœªæ‰¾åˆ°ï¼");
            }
            // è®¾ç½®è¾“入参数
            //订单号查询条件
//            JCoTable AUFNRTable = function.getTableParameterList().getTable("ZTAB_AUFNR");
            //订单类型 æ ‡å‡†ç”Ÿäº§è®¢å•
            JCoTable AUARTTable = function.getTableParameterList().getTable("ZTAB_AUART");
            AUARTTable.appendRow();
            AUARTTable.setValue("AUART", orderTypeCode1);
            //八分厂调度
            JCoTable FEVORTable = function.getTableParameterList().getTable("ZTAB_FEVOR");
            FEVORTable.appendRow();
            FEVORTable.setValue("FEVOR", productionManager);
            //新火炬
            JCoTable WERKSTable = function.getTableParameterList().getTable("ZTAB_WERKS");
            WERKSTable.appendRow();
            WERKSTable.setValue("WERKS", factoryCode);
            //订单状态
            JCoTable TXT04Table = function.getTableParameterList().getTable("ZTAB_TXT04");
            TXT04Table.appendRow();
            TXT04Table.setValue("TXT04", orderStatus);
            // æ‰§è¡Œè°ƒç”¨
            function.execute(destination);
            //获取返回结果
            String zmess = function.getExportParameterList().getValue("ZMESS").toString();
            String ztype = function.getExportParameterList().getValue("ZTYPE").toString();//S æ ‡è¯† æˆåŠŸ
            if(!"S".equals(ztype)){
                log.error("获取订单信息失败,ZTYPE={}, ZMESS={}", ztype, zmess);
                return;
            }
            // èŽ·å–è¾“å‡ºå‚æ•°
            JCoTable outputTable = function.getTableParameterList().getTable("ZTAB_OUT");
            int numRows = outputTable.getNumRows();
            List<ProductionOrderDTO> resultList = new ArrayList<>();
            ProductionOrderDTO dto;
            for (int i = 0; i < numRows; i++) {
                outputTable.setRow(i);
                dto = new ProductionOrderDTO();
                dto.setKDPOS(outputTable.getString("KDPOS"));
                dto.setCHARG(outputTable.getString("CHARG"));
                dto.setMAKTX(outputTable.getString("MAKTX"));
                dto.setMATNR(outputTable.getString("MATNR"));
                dto.setKDAUF(outputTable.getString("KDAUF"));
                dto.setAUFNR(outputTable.getString("AUFNR"));
                dto.setDAUAT(outputTable.getString("DAUAT"));
                dto.setGAMNG(outputTable.getString("GAMNG"));
                dto.setGMEIN(outputTable.getString("GMEIN"));
                dto.setAPRIO(outputTable.getString("APRIO"));
                dto.setAUFPL(outputTable.getString("AUFPL"));
                dto.setSTLNR(outputTable.getString("STLNR"));
                dto.setDWERK(outputTable.getString("DWERK"));
                dto.setNAME1(outputTable.getString("NAME1"));
                dto.setFEVOR(outputTable.getString("FEVOR"));
                dto.setTXT(outputTable.getString("TXT"));
                dto.setUSNAM(outputTable.getString("USNAM"));
                dto.setUDATE(outputTable.getString("UDATE"));
                dto.setLAEDA(outputTable.getString("LAEDA"));
                dto.setTIMES(outputTable.getString("TIMES"));
                dto.setTXT04(outputTable.getString("TXT04"));
                dto.setTXT30(outputTable.getString("TXT30"));
                dto.setGSTRP(outputTable.getString("GSTRP"));
                dto.setGLTRP(outputTable.getString("GLTRP"));
                //添加结果集
                resultList.add(dto);
                log.info(dto.toString());
            }
        } catch (JCoException e) {
            log.error(e.getMessage(), e);
        JCoRepository repository = destination.getRepository();
        JCoFunction function = repository.getFunction(FunctionConst.ZPPF_033_1);
        if (function == null) {
            throw new RuntimeException("RFC å‡½æ•° ZPPF_033_1 æœªæ‰¾åˆ°ï¼");
        }
        // è®¾ç½®è¾“入参数
        //订单号查询条件
//            JCoTable AUFNRTable = function.getTableParameterList().getTable("ZTAB_AUFNR");
        List<JSONObject> items = new ArrayList<>();
        //订单类型 æ ‡å‡†ç”Ÿäº§è®¢å•
        JCoTable AUARTTable = function.getTableParameterList().getTable("ZTAB_AUART");
        AUARTTable.appendRow();
        AUARTTable.setValue("AUART", orderTypeCode1);
        //组装请求参数
        JSONObject item1 = new JSONObject();
        item1.put("AUART", orderTypeCode1);
        items.add(item1);
        //八分厂调度
        JCoTable FEVORTable = function.getTableParameterList().getTable("ZTAB_FEVOR");
        FEVORTable.appendRow();
        FEVORTable.setValue("FEVOR", productionManager);
        //组装请求参数
        JSONObject item2 = new JSONObject();
        item2.put("FEVOR", productionManager);
        items.add(item2);
        //新火炬
        JCoTable WERKSTable = function.getTableParameterList().getTable("ZTAB_WERKS");
        WERKSTable.appendRow();
        WERKSTable.setValue("WERKS", factoryCode);
        //组装请求参数
        JSONObject item3 = new JSONObject();
        item3.put("WERKS", factoryCode);
        items.add(item3);
        //订单状态
        JCoTable TXT04Table = function.getTableParameterList().getTable("ZTAB_TXT04");
        TXT04Table.appendRow();
        TXT04Table.setValue("TXT04", orderStatus);
        //组装请求参数
        JSONObject item4 = new JSONObject();
        item4.put("TXT04", orderStatus);
        items.add(item4);
        // æ‰§è¡Œè°ƒç”¨
        function.execute(destination);
        //获取返回结果
        String zmess = function.getExportParameterList().getValue("ZMESS").toString();
        String ztype = function.getExportParameterList().getValue("ZTYPE").toString();//S æ ‡è¯† æˆåŠŸ
        // èŽ·å–è¾“å‡ºå‚æ•°
        JCoTable outputTable = function.getTableParameterList().getTable("ZTAB_OUT");
        int numRows = outputTable.getNumRows();
        List<ProductionOrderDTO> resultList = new ArrayList<>();
        ProductionOrderDTO dto;
        for (int i = 0; i < numRows; i++) {
            outputTable.setRow(i);
            dto = new ProductionOrderDTO();
            dto.setKDPOS(outputTable.getString("KDPOS"));
            dto.setCHARG(outputTable.getString("CHARG"));
            dto.setMAKTX(outputTable.getString("MAKTX"));
            dto.setMATNR(outputTable.getString("MATNR"));
            dto.setKDAUF(outputTable.getString("KDAUF"));
            dto.setAUFNR(outputTable.getString("AUFNR"));
            dto.setDAUAT(outputTable.getString("DAUAT"));
            dto.setGAMNG(outputTable.getString("GAMNG"));
            dto.setGMEIN(outputTable.getString("GMEIN"));
            dto.setAPRIO(outputTable.getString("APRIO"));
            dto.setAUFPL(outputTable.getString("AUFPL"));
            dto.setSTLNR(outputTable.getString("STLNR"));
            dto.setDWERK(outputTable.getString("DWERK"));
            dto.setNAME1(outputTable.getString("NAME1"));
            dto.setFEVOR(outputTable.getString("FEVOR"));
            dto.setTXT(outputTable.getString("TXT"));
            dto.setUSNAM(outputTable.getString("USNAM"));
            dto.setUDATE(outputTable.getString("UDATE"));
            dto.setLAEDA(outputTable.getString("LAEDA"));
            dto.setTIMES(outputTable.getString("TIMES"));
            dto.setTXT04(outputTable.getString("TXT04"));
            dto.setTXT30(outputTable.getString("TXT30"));
            dto.setGSTRP(outputTable.getString("GSTRP"));
            dto.setGLTRP(outputTable.getString("GLTRP"));
            //添加结果集
            resultList.add(dto);
            log.info(dto.toString());
        }
        resultMap.put("zmess", zmess);
        resultMap.put("ztype", ztype);
        resultMap.put("importParameters", items);
        resultMap.put("result", resultList);
        return resultMap;
    }
}
src/main/java/org/jeecg/modules/system/controller/SysApiLogController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,58 @@
package org.jeecg.modules.system.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.system.entity.SysApiLog;
import org.jeecg.modules.system.service.ISysApiLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
 /**
 * @Description: ç³»ç»Ÿç¬¬ä¸‰æ–¹é›†æˆæŽ¥å£æ—¥å¿—
 * @Author: jeecg-boot
 * @Date:   2025-07-30
 * @Version: V1.0
 */
@Slf4j
@Api(tags="系统第三方集成接口日志")
@RestController
@RequestMapping("/system/sysApiLog")
public class SysApiLogController extends JeecgController<SysApiLog, ISysApiLogService> {
    @Autowired
    private ISysApiLogService sysApiLogService;
    /**
     * åˆ†é¡µåˆ—表查询
     *
     * @param sysApiLog
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "系统第三方集成接口日志-分页列表查询")
    @ApiOperation(value="系统第三方集成接口日志-分页列表查询", notes="系统第三方集成接口日志-分页列表查询")
    @GetMapping(value = "/list")
    public Result<?> queryPageList(SysApiLog sysApiLog,
                                   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                   HttpServletRequest req) {
        QueryWrapper<SysApiLog> queryWrapper = QueryGenerator.initQueryWrapper(sysApiLog, req.getParameterMap());
        Page<SysApiLog> page = new Page<SysApiLog>(pageNo, pageSize);
        IPage<SysApiLog> pageList = sysApiLogService.page(page, queryWrapper);
        return Result.OK(pageList);
    }
}
src/main/java/org/jeecg/modules/system/entity/SysApiLog.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,86 @@
package org.jeecg.modules.system.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
 * @Description: ç³»ç»Ÿç¬¬ä¸‰æ–¹é›†æˆæŽ¥å£æ—¥å¿—
 * @Author: jeecg-boot
 * @Date:   2025-07-30
 * @Version: V1.0
 */
@Data
@TableName("sys_api_log")
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="sys_api_log对象", description="系统第三方集成接口日志")
public class SysApiLog implements Serializable {
    /**主键*/
    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "主键")
    private String id;
    /**创建人*/
    @ApiModelProperty(value = "创建人")
    private String createBy;
    /**创建时间*/
    @ApiModelProperty(value = "创建时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    /**API分类*/
    @ApiModelProperty(value = "API分类")
    @Dict(dicCode = "api_log_category")
    private String apiCategory;
    /**接口名称*/
    @ApiModelProperty(value = "接口名称")
    private String apiName;
    /**请求时间*/
    @ApiModelProperty(value = "请求时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date requestTime;
    /**响应时间*/
    @ApiModelProperty(value = "响应时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date responseTime;
    /**请求方式*/
    @ApiModelProperty(value = "请求方式")
    private String requestMethod;
    /**请求完成URL*/
    @ApiModelProperty(value = "请求URL")
    private String requestUrl;
    /**请求头*/
    @ApiModelProperty(value = "请求头")
    private String requestHeaders;
    /**请求体*/
    @ApiModelProperty(value = "请求体")
    private String requestBody;
    /**响应编码*/
    @ApiModelProperty(value = "响应编码")
    private String responseCode;
    /**响应消息*/
    @ApiModelProperty(value = "响应消息")
    private String responseMessage;
    /**响应体*/
    @ApiModelProperty(value = "响应体")
    private String responseBody;
    /**状态;成功、失败*/
    @ApiModelProperty(value = "状态;成功、失败")
    private Integer requestStatus;
    /**调用方法*/
    @ApiModelProperty(value = "调用方法")
    private String method;
}
src/main/java/org/jeecg/modules/system/mapper/SysApiLogMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,17 @@
package org.jeecg.modules.system.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.system.entity.SysApiLog;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
 * @Description: ç³»ç»Ÿç¬¬ä¸‰æ–¹é›†æˆæŽ¥å£æ—¥å¿—
 * @Author: jeecg-boot
 * @Date:   2025-07-30
 * @Version: V1.0
 */
public interface SysApiLogMapper extends BaseMapper<SysApiLog> {
}
src/main/java/org/jeecg/modules/system/mapper/xml/SysApiLogMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.system.mapper.SysApiLogMapper">
</mapper>
src/main/java/org/jeecg/modules/system/service/ISysApiLogService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,14 @@
package org.jeecg.modules.system.service;
import org.jeecg.modules.system.entity.SysApiLog;
import com.baomidou.mybatisplus.extension.service.IService;
/**
 * @Description: ç³»ç»Ÿç¬¬ä¸‰æ–¹é›†æˆæŽ¥å£æ—¥å¿—
 * @Author: jeecg-boot
 * @Date:   2025-07-30
 * @Version: V1.0
 */
public interface ISysApiLogService extends IService<SysApiLog> {
}
src/main/java/org/jeecg/modules/system/service/impl/SysApiLogServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,19 @@
package org.jeecg.modules.system.service.impl;
import org.jeecg.modules.system.entity.SysApiLog;
import org.jeecg.modules.system.mapper.SysApiLogMapper;
import org.jeecg.modules.system.service.ISysApiLogService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
 * @Description: ç³»ç»Ÿç¬¬ä¸‰æ–¹é›†æˆæŽ¥å£æ—¥å¿—
 * @Author: jeecg-boot
 * @Date:   2025-07-30
 * @Version: V1.0
 */
@Service
public class SysApiLogServiceImpl extends ServiceImpl<SysApiLogMapper, SysApiLog> implements ISysApiLogService {
}