add:修改SAP配置

This commit is contained in:
zhangzq
2026-11-03 14:12:09 +08:00
parent 4dcb180343
commit 91fd55f40c
3 changed files with 30 additions and 8 deletions

View File

@@ -15,10 +15,13 @@ import org.nl.wms.ext_manage.sap.api.dto.ReceiptConfirmRequest;
import org.nl.wms.ext_manage.sap.api.dto.SubcontractConfirmRequest;
import org.nl.wms.ext_manage.sap.api.dto.SubcontractReverseRequest;
import org.nl.wms.system_manage.service.param.ISysParamService;
import org.nl.wms.system_manage.service.param.dao.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.annotation.PostConstruct;
@Service
@Slf4j
public class SapApi {
@@ -26,8 +29,9 @@ public class SapApi {
private ISysParamService sysParamService;
//TODO 系统参数添加
private static final String BASIC_AUTH_USER = "sb-44f42158-6589-470d-94e2-cb4ff68ff64e!b6440|it-rt-prd-mc97okah!b39";
private static final String BASIC_AUTH_PASSWORD = "07c6eebc-1ff3-4f73-a4d8-870757951649$WTL_Vf-jxg8aWRlTvxP8BC8oloOYosae2JzQykImlpg=";
private static String BASIC_AUTH_USER = "sb-44f42158-6589-470d-94e2-cb4ff68ff64e!b6440|it-rt-prd-mc97okah!b39";
private static String BASIC_AUTH_PASSWORD = "07c6eebc-1ff3-4f73-a4d8-870757951649$WTL_Vf-jxg8aWRlTvxP8BC8oloOYosae2JzQykImlpg=";
public static String SAP_INBOUND_URL = "https://prd-mc97okah.it-cpi010-rt.cpi.cn40.apps.platform.sapcloud.cn/http/PRD/Inbound";
/**
* MM054 交货单收货确认
@@ -91,13 +95,10 @@ public class SapApi {
return postQuery("SAP物料查询[" + SapConstant.INTF_MDG012 + "]", request);
}
private JSONObject postQuery(String bizLabel, Object request) {
String param = request instanceof String ? (String) request : JSON.toJSONString(request);
log.info("{}请求:{}", bizLabel, param);
try {
String resultMsg = HttpRequest.post(SapConstant.SAP_INBOUND_URL)
String resultMsg = HttpRequest.post(SAP_INBOUND_URL)
.basicAuth(BASIC_AUTH_USER, BASIC_AUTH_PASSWORD)
.body(param)
.execute()
@@ -116,7 +117,7 @@ public class SapApi {
String param = request instanceof String ? (String) request : JSON.toJSONString(request);
log.info("{}请求:{}", bizLabel, param);
try {
String resultMsg = HttpRequest.post(SapConstant.SAP_INBOUND_URL)
String resultMsg = HttpRequest.post(SAP_INBOUND_URL)
.basicAuth(BASIC_AUTH_USER, BASIC_AUTH_PASSWORD)
.body(param)
.execute()
@@ -185,4 +186,20 @@ public class SapApi {
throw new BadRequestException(StrUtil.blankToDefault(message, bizLabel + "失败"));
}
}
@PostConstruct
public void urlInit() {
final Param sapUrl = sysParamService.findByCode("SAP_URL");
if (sapUrl!=null && org.apache.commons.lang3.StringUtils.isNotEmpty(sapUrl.getValue())){
SAP_INBOUND_URL = sapUrl.getValue();
}
final Param sapUser = sysParamService.findByCode("SAP_USER");
if (sapUrl!=null && org.apache.commons.lang3.StringUtils.isNotEmpty(sapUrl.getValue())){
BASIC_AUTH_USER = sapUser.getValue();
}
final Param sapPw = sysParamService.findByCode("SAP_PW");
if (sapUrl!=null && org.apache.commons.lang3.StringUtils.isNotEmpty(sapUrl.getValue())){
BASIC_AUTH_PASSWORD = sapPw.getValue();
}
}
}

View File

@@ -5,7 +5,6 @@ public class SapConstant {
/** SAP CPI Inbound 统一接口地址(各业务接口共用,通过 header.intf_id 区分 )TODO 系统参数添加 */
public static final String SAP_INBOUND_URL2 = "https://dev-12nylocm.it-cpi010-rt.cpi.cn40.apps.platform.sapcloud.cn/http/ERP/Inbound";
public static final String SAP_INBOUND_URL3 = "https://dev-12nylocm.it-cpi010-rt.cpi.cn40.apps.platform.sapcloud.cn/http/QAS/Inbound";
public static final String SAP_INBOUND_URL = "https://prd-mc97okah.it-cpi010-rt.cpi.cn40.apps.platform.sapcloud.cn/http/PRD900/Inbound";
/** 接口编号:交货单确认 */
public static final String INTF_MM054 = "MM054";

View File

@@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j;
import org.nl.common.base.ResponseData;
import org.nl.common.domain.query.PageQuery;
import org.nl.common.logging.annotation.Log;
import org.nl.wms.ext_manage.sap.api.SapApi;
import org.nl.wms.system_manage.service.param.ISysParamService;
import org.nl.wms.system_manage.service.param.dao.Param;
import org.springframework.beans.factory.annotation.Autowired;
@@ -34,6 +35,8 @@ class SysParamController {
@Autowired
private ISysParamService paramService;
@Autowired
private SapApi sapApi;
@GetMapping
@Log("查询系统参数")
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page){
@@ -51,6 +54,9 @@ class SysParamController {
@Log("修改系统参数")
public ResponseEntity<Object> update(@Validated @RequestBody Param param){
paramService.update(param);
if (param.getCode().equals("SAP_URL")){
sapApi.urlInit();
}
return ResponseData.build();
}