pom,工艺路线,封装post提交asp

This commit is contained in:
liss
2025-09-24 15:27:45 +08:00
parent 5937f38e83
commit b8d8660356
12 changed files with 328 additions and 81 deletions

View File

@@ -11,6 +11,8 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.HashMap;
@FeignClient(name = ApiConstants.NAME)
@Tag(name = "RPC 服务 - ERP")
public interface ErpExternalApi {
@@ -19,6 +21,6 @@ public interface ErpExternalApi {
@PostMapping(PREFIX + "/submit")
@Operation(summary = "erp数据提交")
ResponseEntity<String> submitDataToErp(@Valid @RequestBody ErpSubmitReqDTO reqDTO);
HashMap<String, String> submitDataToErp(@Valid @RequestBody ErpSubmitReqDTO reqDTO);
}

View File

@@ -7,6 +7,8 @@ import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
/**
* ERP Api 实现类
*
@@ -21,7 +23,7 @@ public class ErpExternalApiImpl implements ErpExternalApi {
private ErpConfig erpConfig;
@Override
public ResponseEntity<String> submitDataToErp(ErpSubmitReqDTO reqDTO) {
public HashMap<String, String> submitDataToErp(ErpSubmitReqDTO reqDTO) {
return erpConfig.pushDataToErp(reqDTO);
}
}

View File

@@ -82,10 +82,39 @@ public class ErpConfig {
}
}
// GET请求处理
// public HashMap<String, String> getResult(SAPInterfaceResult result) {
// HashMap<String, String> resMap = new HashMap<>();
// String E_RSLT = null;
// JSONObject jsonObject = result.getData();
// //判断 result里的succeed是否为true
// boolean succeed = result.isSucceed();
// if (succeed && "S".equals(jsonObject.getString("E_FLAG"))) {
// JSONObject data = result.getData();
// String flag = "S";
// String E_RESP = data.getString("E_DATA");
//
// String E_MSG = result.getMsg();
//// log.info("请求SAP成功 E_RESP{}", E_RESP);
//// log.info("请求SAP成功 E_MSG{}", E_MSG);
// resMap.put("E_RESP", E_RESP);
// resMap.put("resStr", E_MSG);
// resMap.put("flag", flag);
// return resMap;
// } else {
// String E_MSG = result.getMsg();
// String flag = "E";
// resMap.put("resStr", E_MSG);
// resMap.put("flag", flag);
//// log.info("请求SAP失败 E_MSG{}", E_MSG);
// return resMap;
// }
// }
/**
* 调用ERP接口更新erp数据
*/
public ResponseEntity<String> pushDataToErp(ErpSubmitReqDTO reqDTO) {
public HashMap<String, String> pushDataToErp(ErpSubmitReqDTO reqDTO) {
try {
// 构建完整URL
String url = "http://" + erpAddress + "/api/rfc/post";
@@ -115,13 +144,53 @@ public ResponseEntity<String> pushDataToErp(ErpSubmitReqDTO reqDTO) {
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> response = restTemplate.postForEntity(url, requestEntity, String.class);
return response;
return postResult(response);
} catch (Exception e) {
log.error("调用ERP RFC接口失败:" + e.getMessage(), e);
return ResponseEntity.status(500).body("调用ERP接口失败: " + e.getMessage());
return null;
}
}
// POST请求处理
public HashMap<String, String> postResult(ResponseEntity<String> result) {
HashMap<String, String> resMap = new HashMap<>();
String E_RSLT = null;
boolean succeed = result.getHeaders().containsKey("succeed");
// JSONObject data = result.getBody("data");
// if (data == null) {
// throw new RuntimeException("SAP接口返回值为空," + result.getMsg());
// } else if (succeed && "S".equals(data.getString("E_FLAG"))) {
// String E_FLAG = data.getString("E_FLAG");
// String flag = "S";
// String E_RESP = data.getString("E_RESP");
// String E_MSG = data.getString("ET_MSG");
//// log.info("请求SAP成功 E_RESP{}", E_RESP);
//// log.info("请求SAP成功 E_MSG{}", E_MSG);
// resMap.put("E_RESP", E_RESP);
// resMap.put("resStr", E_MSG);
// resMap.put("flag", flag);
// return resMap;
// } else if (!succeed && "E".equals(data.getString("E_FLAG"))) {
// String E_FLAG = data.getString("E_FLAG");
// String flag = "E";
// String E_RESP = data.getString("E_DATA");
// String E_MSG = data.getString("ET_MSG");
// if (StrUtil.isBlank(E_MSG)) {
// E_MSG = result.getMsg();
// E_MSG = "[{\"MESSAGE\":\"" + result.getMsg() + "\"}]";
// }
// resMap.put("resStr", E_MSG);
// resMap.put("flag", flag);
//// log.info("请求SAP失败 E_MSG{}", E_MSG);
// return resMap;
// } else {
// throw new RuntimeException("SAP接口异常," + result);
// }
return resMap;
}
//list
public Map<String, List<String>> numbers(JSONArray dataArray, String key, String dataKey) {
// 使用 Redis 获取缓存数据

View File

@@ -104,7 +104,7 @@ public class ErpAssetController {
@PostMapping("/getErpAssetTask")
@Operation(summary = "定时获得erp更新资产卡片")
@PreAuthorize("@ss.hasPermission('sply:erp-asset:create')")
public CommonResult<Boolean> getErpCompanyTask() {
public CommonResult<Boolean> getErpAssetTask() {
erpAssetService.callErpRfcInterface();
return success(true);
}

View File

@@ -11,7 +11,7 @@ import java.math.BigDecimal;
public class ErpProcessPageReqVO extends PageParam {
@Schema(description = "工厂编码")
private BigDecimal factoryNumber;
private String factoryNumber;
@Schema(description = "物料编码")
private String materialNumber;

View File

@@ -18,7 +18,7 @@ public class ErpProcessRespVO {
@Schema(description = "工厂编码", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("工厂编码")
private BigDecimal factoryNumber;
private String factoryNumber;
@Schema(description = "物料编码", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("物料编码")

View File

@@ -16,7 +16,7 @@ public class ErpProcessSaveReqVO {
@Schema(description = "工厂编码", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "工厂编码不能为空")
private BigDecimal factoryNumber;
private String factoryNumber;
@Schema(description = "物料编码", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "物料编码不能为空")

View File

@@ -34,7 +34,7 @@ public class ErpProcessDO {
* 工厂编码
*/
@TableField("FACT_NUM")
private BigDecimal factoryNumber;
private String factoryNumber;
/**
* 物料编码
*/
@@ -63,7 +63,7 @@ public class ErpProcessDO {
/**
* 计量单位
*/
@TableField("UOM")
@TableField("UNT")
private String uom;
/**
* 用途

View File

@@ -48,7 +48,7 @@ public class ErpProcessDetailDO {
/**
* 作业的计量单位
*/
@TableField("UOM")
@TableField("UNT")
private String uom;
/**
* 工作中心编号

View File

@@ -312,8 +312,8 @@ public class ErpBomServiceImpl implements ErpBomService {
items.add(item);
req.put("item", items);
reqDTO.setReq(req);
ResponseEntity<String> response = erpExternalApi.submitDataToErp(reqDTO);
if (response.getStatusCode() == HttpStatus.OK) {
HashMap<String, String> response = erpExternalApi.submitDataToErp(reqDTO);
if (response.get("result").isEmpty()) {
log.info("ERP数据提交成功");
}
}

Some files were not shown because too many files have changed in this diff Show More