erp定时任务
This commit is contained in:
@@ -35,6 +35,7 @@ public class ErpConfig {
|
|||||||
* 调用ERP接口获取公司数据
|
* 调用ERP接口获取公司数据
|
||||||
*/
|
*/
|
||||||
public JSONArray fetchDataFromERP(String funcnr, Map<String, Object> req) {
|
public JSONArray fetchDataFromERP(String funcnr, Map<String, Object> req) {
|
||||||
|
try {
|
||||||
// 构建完整URL
|
// 构建完整URL
|
||||||
String url = "http://" + erpAddress + "/api/rfc/get";
|
String url = "http://" + erpAddress + "/api/rfc/get";
|
||||||
// 构建请求参数
|
// 构建请求参数
|
||||||
@@ -58,15 +59,13 @@ public class ErpConfig {
|
|||||||
|
|
||||||
// 解析响应结果
|
// 解析响应结果
|
||||||
String responseBody = response.getBody();
|
String responseBody = response.getBody();
|
||||||
if (responseBody == null) {
|
if (responseBody.isEmpty()) {
|
||||||
log.warn("ERP接口返回空响应");
|
log.warn("无所选条件的查询数据"+req);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject jsonResponse = JSON.parseObject(responseBody);
|
JSONObject jsonResponse = JSON.parseObject(responseBody);
|
||||||
if (jsonResponse == null) {
|
if (jsonResponse == null) {
|
||||||
log.warn("ERP接口响应无法解析为JSON");
|
log.warn("ERP接口响应无法解析为JSON");
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 正确获取E_DATA数组
|
// 正确获取E_DATA数组
|
||||||
@@ -77,6 +76,10 @@ public class ErpConfig {
|
|||||||
log.warn("ERP接口调用失败或返回错误标志");
|
log.warn("ERP接口调用失败或返回错误标志");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("调用ERP RFC接口失败: {}", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -91,11 +94,29 @@ public class ErpConfig {
|
|||||||
// 提取有效的 BUKRS 编号
|
// 提取有效的 BUKRS 编号
|
||||||
List<String> existingNumbers = new ArrayList<>();
|
List<String> existingNumbers = new ArrayList<>();
|
||||||
if (dataArray != null) {
|
if (dataArray != null) {
|
||||||
|
// 将dataKey按"-"分割成多个部分
|
||||||
|
String[] keyParts = dataKey.split("-");
|
||||||
existingNumbers = dataArray.stream()
|
existingNumbers = dataArray.stream()
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.map(dataJson -> ((JSONObject) dataJson).getString(dataKey))
|
.map(dataJson -> {
|
||||||
.filter(Objects::nonNull)
|
JSONObject jsonObject = (JSONObject) dataJson;
|
||||||
.map(String::trim) // 去除字符串首尾空格
|
// 根据每个部分逐级获取值并拼接
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (String part : keyParts) {
|
||||||
|
String value = jsonObject.getString(part);
|
||||||
|
if (value != null) {
|
||||||
|
if (sb.length() > 0) {
|
||||||
|
sb.append("-");
|
||||||
|
}
|
||||||
|
sb.append(value.trim());
|
||||||
|
} else {
|
||||||
|
// 如果某一部分为空,则整个值视为无效
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
})
|
||||||
|
.filter(Objects::nonNull) // 过滤掉无效值
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,4 +142,26 @@ public class ErpConfig {
|
|||||||
// 使用 Redis 更新缓存数据
|
// 使用 Redis 更新缓存数据
|
||||||
redisTemplate.opsForValue().set(key, allnumbers);
|
redisTemplate.opsForValue().set(key, allnumbers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getRedisCache(String key) {
|
||||||
|
// 使用 Redis 更新缓存数据
|
||||||
|
return (List<String>)redisTemplate.opsForValue().get("erp"+key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Map<String, String> numbersMap(String key) {
|
||||||
|
// 使用 Redis 获取缓存数据
|
||||||
|
Map<String, String> result = (Map<String, String>) redisTemplate.opsForValue().get(key);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// public void updateRedisCache(String key, List<String> allnumbers) {
|
||||||
|
// // 使用 Redis 更新缓存数据
|
||||||
|
// redisTemplate.opsForValue().set(key, allnumbers);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public List<String> getRedisCache(String key) {
|
||||||
|
// // 使用 Redis 更新缓存数据
|
||||||
|
// return (List<String>)redisTemplate.opsForValue().get("erp"+key);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class OftenEnum {
|
|||||||
//接口编号枚举
|
//接口编号枚举
|
||||||
public enum FuncnrEnum {
|
public enum FuncnrEnum {
|
||||||
公司代码("001", "BUKRS", ""),
|
公司代码("001", "BUKRS", ""),
|
||||||
工厂信息("002", "", ""),
|
工厂信息("002", "WERKS", ""),
|
||||||
客商信息("003", "PARTNER", "DATUM"),
|
客商信息("003", "PARTNER", "DATUM"),
|
||||||
成本中心("004", "", ""),
|
成本中心("004", "", ""),
|
||||||
内部订单("005", "", ""),
|
内部订单("005", "", ""),
|
||||||
@@ -22,11 +22,11 @@ public class OftenEnum {
|
|||||||
采购组织("007", "", ""),
|
采购组织("007", "", ""),
|
||||||
销售组织("008", "", ""),
|
销售组织("008", "", ""),
|
||||||
合同信息("009", "", ""),
|
合同信息("009", "", ""),
|
||||||
资产卡片("010", "", ""),
|
资产卡片("010", "ANLN1-BUKRS", "ERDAT"),
|
||||||
库存信息("011", "", ""),
|
库存信息("011", "", ""),
|
||||||
辅组编码("012", "", ""),
|
辅组编码("012", "", ""),
|
||||||
生产订单("013", "", ""),
|
生产订单("013", "", ""),
|
||||||
BOM清单("014", "", ""),
|
BOM清单("014", "MATNR-STLAL-WERKS", ""),
|
||||||
工艺路线("015", "", ""),
|
工艺路线("015", "", ""),
|
||||||
生产版本("016", "", ""),
|
生产版本("016", "", ""),
|
||||||
生产投料("017", "", ""),
|
生产投料("017", "", ""),
|
||||||
|
|||||||
@@ -101,4 +101,11 @@ public class ErpAssetController {
|
|||||||
BeanUtils.toBean(list, ErpAssetRespVO.class));
|
BeanUtils.toBean(list, ErpAssetRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/getErpAssetTask")
|
||||||
|
@Operation(summary = "定时获得erp更新资产卡片")
|
||||||
|
@PreAuthorize("@ss.hasPermission('sply:erp-asset:query')")
|
||||||
|
public void getErpCompanyTask() {
|
||||||
|
erpAssetService.callErpRfcInterface();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -101,4 +101,11 @@ public class ErpBomController {
|
|||||||
BeanUtils.toBean(list, ErpBomRespVO.class));
|
BeanUtils.toBean(list, ErpBomRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/getErpBomTask")
|
||||||
|
@Operation(summary = "定时获得erp更新物料清单(BOM)")
|
||||||
|
@PreAuthorize("@ss.hasPermission('sply:erp-bom:query')")
|
||||||
|
public void getErpBomTask() {
|
||||||
|
erpBomService.callErpRfcInterface();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -101,4 +101,10 @@ public class ErpContractController {
|
|||||||
BeanUtils.toBean(list, ErpContractRespVO.class));
|
BeanUtils.toBean(list, ErpContractRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/getErpContractTask")
|
||||||
|
@Operation(summary = "定时获得erp更新合同")
|
||||||
|
@PreAuthorize("@ss.hasPermission('sply:erp-contract:query')")
|
||||||
|
public void getErpContractTask() {
|
||||||
|
erpContractService.callErpRfcInterface();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -101,4 +101,12 @@ public class ErpCostcenterController {
|
|||||||
BeanUtils.toBean(list, ErpCostcenterRespVO.class));
|
BeanUtils.toBean(list, ErpCostcenterRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/getErpCostcenterTask")
|
||||||
|
@Operation(summary = "定时获得erp更新成本中心")
|
||||||
|
@PreAuthorize("@ss.hasPermission('sply:erp-costcenter:query')")
|
||||||
|
public void getErpCostcenterTask() {
|
||||||
|
erpCostcenterService.callErpRfcInterface();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -101,4 +101,11 @@ public class ErpFactoryController {
|
|||||||
BeanUtils.toBean(list, ErpFactoryRespVO.class));
|
BeanUtils.toBean(list, ErpFactoryRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/getErpFactoryTask")
|
||||||
|
@Operation(summary = "定时获得erp工厂数据")
|
||||||
|
@PreAuthorize("@ss.hasPermission('sply:erp-factory:create')")
|
||||||
|
public void getErpFactoryTask() {
|
||||||
|
erpFactoryService.callErpRfcInterface();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -101,4 +101,11 @@ public class ErpInternalOrderController {
|
|||||||
BeanUtils.toBean(list, ErpInternalOrderRespVO.class));
|
BeanUtils.toBean(list, ErpInternalOrderRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/getErpInternalOrderTask")
|
||||||
|
@Operation(summary = "定时获得erp更新内部订单数据")
|
||||||
|
@PreAuthorize("@ss.hasPermission('sply:erp-internal-order:create')")
|
||||||
|
public void getErpInternalOrderTask() {
|
||||||
|
erpInternalOrderService.callErpRfcInterface();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -101,4 +101,11 @@ public class ErpProcessController {
|
|||||||
BeanUtils.toBean(list, ErpProcessRespVO.class));
|
BeanUtils.toBean(list, ErpProcessRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/getErpProcessTask")
|
||||||
|
@Operation(summary = "定时获得erp更新工艺路线")
|
||||||
|
@PreAuthorize("@ss.hasPermission('sply:erp-process:create')")
|
||||||
|
public void getErpProcessTask() {
|
||||||
|
erpProcessService.callErpRfcInterface();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -101,4 +101,11 @@ public class ErpProductiveOrderController {
|
|||||||
BeanUtils.toBean(list, ErpProductiveOrderRespVO.class));
|
BeanUtils.toBean(list, ErpProductiveOrderRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/getErpProductiveOrderTask")
|
||||||
|
@Operation(summary = "定时获得erp更新生产订单")
|
||||||
|
@PreAuthorize("@ss.hasPermission('sply:erp-productive-order:create')")
|
||||||
|
public void getErpProductiveOrderTask() {
|
||||||
|
erpProductiveOrderService.callErpRfcInterface();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user