erp修改
This commit is contained in:
@@ -23,11 +23,11 @@ public interface ErpExternalApi {
|
|||||||
|
|
||||||
@PostMapping(PREFIX + "/submit")
|
@PostMapping(PREFIX + "/submit")
|
||||||
@Operation(summary = "erp数据提交")
|
@Operation(summary = "erp数据提交")
|
||||||
HashMap<String, String> submitDataToErp(@Valid @RequestBody ErpSubmitReqDTO reqDTO);
|
Map<String, String> submitDataToErp(@Valid @RequestBody ErpSubmitReqDTO reqDTO);
|
||||||
|
|
||||||
@PostMapping(PREFIX + "/query")
|
@PostMapping(PREFIX + "/query")
|
||||||
@Operation(summary = "erp数据查询")
|
@Operation(summary = "erp数据查询")
|
||||||
HashMap<String, Object> queryDataToErp(@Valid @RequestBody ErpQueryReqDTO reqDTO);
|
Map<String, Object> queryDataToErp(@Valid @RequestBody ErpQueryReqDTO reqDTO);
|
||||||
|
|
||||||
@PostMapping(PREFIX + "/queryProductiveVersion")
|
@PostMapping(PREFIX + "/queryProductiveVersion")
|
||||||
@Operation(summary = "生产版本数据查询")
|
@Operation(summary = "生产版本数据查询")
|
||||||
|
|||||||
@@ -24,14 +24,19 @@ public class ErpSubmitReqDTO {
|
|||||||
*/
|
*/
|
||||||
@Schema(description = "接口编号,必须,参见RFC功能列表,可调用接口编号范围051-900")
|
@Schema(description = "接口编号,必须,参见RFC功能列表,可调用接口编号范围051-900")
|
||||||
private String funcnr;
|
private String funcnr;
|
||||||
|
|
||||||
@Schema(description = "调用系统业务单据编号,必须,在外部系统唯一,用于关联")
|
@Schema(description = "调用系统业务单据编号,必须,在外部系统唯一,用于关联")
|
||||||
private String bskey;
|
private String bskey;
|
||||||
|
|
||||||
@Schema(description = "SAP系统ID, 必须")
|
@Schema(description = "SAP系统ID, 必须")
|
||||||
private String usrid;
|
private String usrid;
|
||||||
|
|
||||||
@Schema(description = "源调用系统ID,必须")
|
@Schema(description = "源调用系统ID,必须")
|
||||||
private String usrnm;
|
private String usrnm;
|
||||||
// @Schema(description = "签名,uuid+srcsys+密码,MD5 32位小写签名,密码另行约定")
|
|
||||||
// private String sign;
|
@Schema(description = "签名,uuid+srcsys+密码,MD5 32位小写签名,密码另行约定")
|
||||||
|
private String sign;
|
||||||
|
|
||||||
@Schema(description = "具体参数,参见RFC功能列表")
|
@Schema(description = "具体参数,参见RFC功能列表")
|
||||||
private Map<String, Object> req;
|
private Map<String, Object> req;
|
||||||
|
|
||||||
|
|||||||
@@ -40,12 +40,12 @@ public class ErpExternalApiImpl implements ErpExternalApi {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HashMap<String, String> submitDataToErp(ErpSubmitReqDTO reqDTO) {
|
public Map<String, String> submitDataToErp(ErpSubmitReqDTO reqDTO) {
|
||||||
return erpConfig.pushDataToErp(reqDTO);
|
return erpConfig.pushDataToErp(reqDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HashMap<String, Object> queryDataToErp(ErpQueryReqDTO reqDTO) {
|
public Map<String, Object> queryDataToErp(ErpQueryReqDTO reqDTO) {
|
||||||
String funcnr = reqDTO.getFuncnr();
|
String funcnr = reqDTO.getFuncnr();
|
||||||
Map<String, Object> req = reqDTO.getReq();
|
Map<String, Object> req = reqDTO.getReq();
|
||||||
return erpConfig.fetchDataFromERP(funcnr, req);
|
return erpConfig.fetchDataFromERP(funcnr, req);
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ public class ErpBillMainServiceImpl implements ErpBillMainService {
|
|||||||
|
|
||||||
// 抽取重复代码:提交 ERP 并记录日志
|
// 抽取重复代码:提交 ERP 并记录日志
|
||||||
private String submitToErp(ErpSubmitReqDTO reqDTO) {
|
private String submitToErp(ErpSubmitReqDTO reqDTO) {
|
||||||
HashMap<String, String> response = erpExternalApi.submitDataToErp(reqDTO);
|
Map<String, String> response = erpExternalApi.submitDataToErp(reqDTO);
|
||||||
return response.get("resStr");
|
return response.get("resStr");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import org.springframework.http.ResponseEntity;
|
|||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.*;
|
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.*;
|
||||||
@@ -31,7 +32,7 @@ public class ErpConfig {
|
|||||||
/**
|
/**
|
||||||
* 调用ERP接口获取erp数据
|
* 调用ERP接口获取erp数据
|
||||||
*/
|
*/
|
||||||
public HashMap<String, Object> fetchDataFromERP(String funcnr, Map<String, Object> req) {
|
public Map<String, Object> fetchDataFromERP(String funcnr, Map<String, Object> req) {
|
||||||
try {
|
try {
|
||||||
// 构建完整URL
|
// 构建完整URL
|
||||||
String url = "http://" + erpAddress + "/api/rfc/get";
|
String url = "http://" + erpAddress + "/api/rfc/get";
|
||||||
@@ -60,7 +61,7 @@ public class ErpConfig {
|
|||||||
throw exception(ERP_NOT_EXISTS);
|
throw exception(ERP_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
HashMap<String, Object> resMap = new HashMap<>();
|
Map<String, Object> resMap = new ConcurrentHashMap<>();
|
||||||
JSONObject jsonResponse = JSON.parseObject(responseBody);
|
JSONObject jsonResponse = JSON.parseObject(responseBody);
|
||||||
if (jsonResponse == null) {
|
if (jsonResponse == null) {
|
||||||
throw exception(ERP_NOT_JSON_EXISTS);
|
throw exception(ERP_NOT_JSON_EXISTS);
|
||||||
@@ -94,7 +95,7 @@ public class ErpConfig {
|
|||||||
/**
|
/**
|
||||||
* 调用ERP接口更新erp数据
|
* 调用ERP接口更新erp数据
|
||||||
*/
|
*/
|
||||||
public HashMap<String, String> pushDataToErp(ErpSubmitReqDTO reqDTO) {
|
public Map<String, String> pushDataToErp(ErpSubmitReqDTO reqDTO) {
|
||||||
try {
|
try {
|
||||||
// 构建完整URL
|
// 构建完整URL
|
||||||
String url = "http://" + erpAddress + "/api/rfc/post";
|
String url = "http://" + erpAddress + "/api/rfc/post";
|
||||||
@@ -108,15 +109,14 @@ public class ErpConfig {
|
|||||||
requestBody.put("bskey", reqDTO.getBskey());
|
requestBody.put("bskey", reqDTO.getBskey());
|
||||||
requestBody.put("usrid", reqDTO.getUsrid());
|
requestBody.put("usrid", reqDTO.getUsrid());
|
||||||
requestBody.put("usrnm", reqDTO.getUsrnm());
|
requestBody.put("usrnm", reqDTO.getUsrnm());
|
||||||
//todo 密码另行约定
|
// todo 密码另行约定
|
||||||
// requestBody.put("sign", StrUtil.(uuid + sapsys + "密码另行约定"));
|
//requestBody.put("sign", StrUtil.(uuid + sapsys + "密码另行约定"));
|
||||||
if (reqDTO.getReq() != null) {
|
if (reqDTO.getReq() != null) {
|
||||||
requestBody.put("req", reqDTO.getReq());
|
requestBody.put("req", reqDTO.getReq());
|
||||||
}
|
}
|
||||||
// 设置请求头
|
// 设置请求头
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
// 创建HTTP请求实体
|
// 创建HTTP请求实体
|
||||||
HttpEntity<String> requestEntity = new HttpEntity<>(requestBody.toJSONString(), headers);
|
HttpEntity<String> requestEntity = new HttpEntity<>(requestBody.toJSONString(), headers);
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ public class ErpConfig {
|
|||||||
throw exception(ERP_NOT_JSON_EXISTS);
|
throw exception(ERP_NOT_JSON_EXISTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
HashMap<String, String> resMap = new HashMap<>();
|
Map<String, String> resMap = new ConcurrentHashMap<>();
|
||||||
boolean succeed = jsonResponse.getBoolean("succeed");
|
boolean succeed = jsonResponse.getBoolean("succeed");
|
||||||
JSONObject data = jsonResponse.getJSONObject("data");
|
JSONObject data = jsonResponse.getJSONObject("data");
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user