feat: sap功能优化
This commit is contained in:
parent
dbe48a46a2
commit
06ecce096b
|
|
@ -1,5 +1,6 @@
|
|||
package com.nflg.wms.admin;
|
||||
|
||||
import com.sap.conn.jco.JCoException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
|
@ -16,13 +17,14 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
|||
@EnableRetry
|
||||
public class AdminApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args) throws JCoException {
|
||||
SpringApplication.run(AdminApplication.class, args);
|
||||
log.info("服务已启动");
|
||||
// log.info("---------------------- Sa-Token SSO 模式二 Client 端启动成功 ----------------------");
|
||||
// log.info("配置信息:" + SaSsoManager.getClientConfig());
|
||||
|
||||
// SapService sapService= SpringUtil.getBean(SapService.class);
|
||||
// sapService.zwm00_MB017("1309976");
|
||||
// log.info(JSONUtil.toJsonStr(sapService.searchOrder("0000101808")));
|
||||
// log.info(JSONUtil.toJsonStr(sapService.getMaterialInfoInOrder("7500188009","0000101808","2100053760")));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,19 +5,21 @@ import com.nflg.wms.admin.pojo.dto.LdapUserDTO;
|
|||
import com.nflg.wms.admin.service.SapService;
|
||||
import com.nflg.wms.common.pojo.ApiResult;
|
||||
import com.nflg.wms.common.pojo.qo.C_MaterialReturnItemQO;
|
||||
import com.nflg.wms.repository.entity.Language;
|
||||
import com.nflg.wms.repository.service.ILanguageService;
|
||||
import com.nflg.wms.starter.BaseController;
|
||||
import com.sap.conn.jco.JCoException;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
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 tech.powerjob.common.enhance.SafeRunnable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 测试
|
||||
|
|
@ -89,4 +91,14 @@ public class TestController extends BaseController {
|
|||
public ApiResult<List<LdapUserDTO>> syncUsers() {
|
||||
return ApiResult.success(Collections.emptyList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印SAP函数参数,需在控制台查看
|
||||
* @param functionName SAP函数名
|
||||
*/
|
||||
@GetMapping("/sap/function/params")
|
||||
public ApiResult<Void> printSAPFunctionParams(@Valid @RequestParam @NotBlank String functionName) throws JCoException {
|
||||
sapService.printMeta(functionName);
|
||||
return ApiResult.success();
|
||||
}
|
||||
}
|
||||
|
|
@ -21,7 +21,6 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
|
|
@ -354,6 +353,8 @@ public class SapService {
|
|||
private JCoFunction exec(String functionName, Map<String, Object> parameters, Map<String, List<Map<String, Object>>> tables) throws JCoException {
|
||||
log.info("SAP functionName:{}", functionName);
|
||||
JCoFunction function = repository.getFunction(functionName);
|
||||
printMeta(function);
|
||||
|
||||
log.info("SAP ImportParameter:{}", JSONUtil.toJsonStr(parameters));
|
||||
log.info("---{}", function.getImportParameterList().getListMetaData());
|
||||
|
||||
|
|
@ -374,4 +375,58 @@ public class SapService {
|
|||
function.execute(destination);
|
||||
return function;
|
||||
}
|
||||
|
||||
public void printMeta(String functionName) throws JCoException {
|
||||
JCoFunction function = repository.getFunction(functionName);
|
||||
printMeta(function);
|
||||
}
|
||||
|
||||
private void printMeta(JCoFunction function){
|
||||
log.trace("-------------------------------------------------------");
|
||||
log.trace("SAP {} 方法参数信息", function.getName());
|
||||
log.trace("-- Import结构");
|
||||
printParameterField(function.getImportParameterList());
|
||||
log.trace("-- Changing结构");
|
||||
printParameterField(function.getChangingParameterList());
|
||||
log.trace("-- Export结构");
|
||||
printParameterField(function.getExportParameterList());
|
||||
log.trace("-- Table结构");
|
||||
printParameterField(function.getTableParameterList());
|
||||
log.trace("-------------------------------------------------------");
|
||||
}
|
||||
|
||||
private void printParameterField(JCoParameterList parameterList){
|
||||
if (Objects.nonNull(parameterList)) {
|
||||
JCoParameterFieldIterator iterator = parameterList.getParameterFieldIterator();
|
||||
if (Objects.nonNull(iterator)) {
|
||||
while (iterator.hasNextField()) {
|
||||
JCoParameterField field = iterator.nextParameterField();
|
||||
log.trace("名称:{},类型:{},描述:{}", field.getName(), field.getTypeAsString(),field.getDescription());
|
||||
if (field.isTable()){
|
||||
printJCoTable(field.getTable());
|
||||
}else if (field.isStructure()){
|
||||
printStructure(field.getStructure());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void printJCoTable(JCoTable table){
|
||||
log.trace("Table结构");
|
||||
JCoRecordFieldIterator iterator=table.getRecordFieldIterator();
|
||||
while (iterator.hasNextField()) {
|
||||
JCoRecordField field = iterator.nextRecordField();
|
||||
log.trace("名称:{},类型:{},描述:{}", field.getName(), field.getTypeAsString(),field.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
private void printStructure(JCoStructure structure){
|
||||
log.trace("Structure结构");
|
||||
JCoRecordFieldIterator iterator=structure.getRecordFieldIterator();
|
||||
while (iterator.hasNextField()) {
|
||||
JCoRecordField field = iterator.nextRecordField();
|
||||
log.trace("名称:{},类型:{},描述:{}", field.getName(), field.getTypeAsString(),field.getDescription());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ logging:
|
|||
level:
|
||||
root: info
|
||||
com:
|
||||
nflg: debug
|
||||
nflg: trace
|
||||
alibaba:
|
||||
cloud:
|
||||
nacos: debug
|
||||
|
|
|
|||
Loading…
Reference in New Issue