erp定时任务去除try/catch
This commit is contained in:
@@ -110,45 +110,39 @@ public class ErpAssetServiceImpl implements ErpAssetService {
|
||||
@Transactional
|
||||
@XxlJob("getErpAssetTask")
|
||||
public void callErpRfcInterface() {
|
||||
try {
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.资产卡片;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
String key = "erpMap" + funcnr;
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
// 构建req参数
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String companyKey ="erpMap"+ OftenEnum.FuncnrEnum.公司代码.getFuncnr();
|
||||
Map<String,Long> redisCache = myRedisConfig.getRedisCacheMap(companyKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
|
||||
}
|
||||
for (String number : redisCache.keySet()) {
|
||||
req.put("BUKRS", number);
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray==null) {
|
||||
continue;
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (CollUtil.isEmpty(dataArrayALL)) {
|
||||
throw exception(ERP_ASSET_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("调用ERP RFC接口失败: {}", e);
|
||||
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.资产卡片;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
String key = "erpMap" + funcnr;
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
// 构建req参数
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String companyKey = "erpMap" + OftenEnum.FuncnrEnum.公司代码.getFuncnr();
|
||||
Map<String, Long> redisCache = myRedisConfig.getRedisCacheMap(companyKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
|
||||
}
|
||||
for (String number : redisCache.keySet()) {
|
||||
req.put("BUKRS", number);
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null) {
|
||||
continue;
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (CollUtil.isEmpty(dataArrayALL)) {
|
||||
throw exception(ERP_ASSET_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -202,7 +196,7 @@ public class ErpAssetServiceImpl implements ErpAssetService {
|
||||
Map<String, Long> deleteNumbers = new HashMap<>();
|
||||
for (String number : numbers.keySet()) {
|
||||
if (!dataArrayNumbers.contains(number)) {
|
||||
deleteNumbers.put(number,numbers.get(number));
|
||||
deleteNumbers.put(number, numbers.get(number));
|
||||
}
|
||||
}
|
||||
return new ProcessingResult(toUpdate, toInsert, deleteNumbers, key);
|
||||
@@ -222,8 +216,8 @@ public class ErpAssetServiceImpl implements ErpAssetService {
|
||||
.in(ErpAssetDO::getMainAssetNumber, result.toInsert.stream().map(ErpAssetDO::getMainAssetNumber).collect(Collectors.toList()))
|
||||
);
|
||||
Map<String, Long> numberIdMap = insertedRecords.stream()
|
||||
.collect(Collectors.toMap(asset -> asset.getCompanyNumber() + "-" + asset.getMainAssetNumber(), ErpAssetDO::getId));
|
||||
myRedisConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
.collect(Collectors.toMap(asset -> asset.getCompanyNumber() + "-" + asset.getMainAssetNumber(), ErpAssetDO::getId,(existing, replacement) -> replacement));
|
||||
myRedisConfig.addRedisCacheMap(result.key, numberIdMap);
|
||||
}
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpAssetMapper.updateBatch(result.toUpdate);
|
||||
@@ -242,10 +236,10 @@ public class ErpAssetServiceImpl implements ErpAssetService {
|
||||
private static class ProcessingResult {
|
||||
private final List<ErpAssetDO> toUpdate;
|
||||
private final List<ErpAssetDO> toInsert;
|
||||
private final Map<String,Long> deleteNumbers;
|
||||
private final Map<String, Long> deleteNumbers;
|
||||
private final String key;
|
||||
|
||||
public ProcessingResult(List<ErpAssetDO> toUpdate, List<ErpAssetDO> toInsert, Map<String,Long> deleteNumbers, String key) {
|
||||
public ProcessingResult(List<ErpAssetDO> toUpdate, List<ErpAssetDO> toInsert, Map<String, Long> deleteNumbers, String key) {
|
||||
this.toUpdate = toUpdate;
|
||||
this.toInsert = toInsert;
|
||||
this.deleteNumbers = deleteNumbers;
|
||||
|
||||
@@ -117,44 +117,38 @@ public class ErpBomServiceImpl implements ErpBomService {
|
||||
@Transactional
|
||||
@XxlJob("getErpBomTask")
|
||||
public void callErpRfcInterface() {
|
||||
try {
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.BOM清单;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
String key = "erpMap" + funcnr;
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String factKey = "erpMap" + OftenEnum.FuncnrEnum.工厂信息.getFuncnr();
|
||||
Map<String, Long> redisCache = myRedisConfig.getRedisCacheMap(factKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
throw exception(ERP_FACTORY_REDIS_NOT_EXISTS);
|
||||
}
|
||||
for (String factoryNumber : redisCache.keySet()) {
|
||||
req.put("WERKS", factoryNumber);
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (CollUtil.isEmpty(dataArrayALL)) {
|
||||
throw exception(ERP_BOM_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("调用ERP RFC接口失败: {}", e);
|
||||
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.BOM清单;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
String key = "erpMap" + funcnr;
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String factKey = "erpMap" + OftenEnum.FuncnrEnum.工厂信息.getFuncnr();
|
||||
Map<String, Long> redisCache = myRedisConfig.getRedisCacheMap(factKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
throw exception(ERP_FACTORY_REDIS_NOT_EXISTS);
|
||||
}
|
||||
for (String factoryNumber : redisCache.keySet()) {
|
||||
req.put("WERKS", factoryNumber);
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (CollUtil.isEmpty(dataArrayALL)) {
|
||||
throw exception(ERP_BOM_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -258,7 +252,7 @@ public class ErpBomServiceImpl implements ErpBomService {
|
||||
private final List<ErpBomDetailDO> erpBomDetailDOList;
|
||||
|
||||
public ProcessingResult(List<ErpBomDO> toUpdate, String key, Map<String, Long> addnumbers,
|
||||
List<String> deleteNumbers, List<ErpBomDetailDO> erpBomDetailDOList) {
|
||||
List<String> deleteNumbers, List<ErpBomDetailDO> erpBomDetailDOList) {
|
||||
this.toUpdate = toUpdate;
|
||||
this.key = key;
|
||||
this.addnumbers = addnumbers;
|
||||
|
||||
@@ -121,32 +121,25 @@ public class ErpCompanyServiceImpl implements ErpCompanyService {
|
||||
@Transactional
|
||||
@XxlJob("getCompanyTask")
|
||||
public void callErpRfcInterface() {
|
||||
try {
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.公司代码;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, null);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (CollUtil.isEmpty(dataArray)) {
|
||||
throw exception(ERP_COMPANY_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArray, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
|
||||
} catch (Exception e) {
|
||||
// log.error("调用ERP RFC接口失败: {}", e);
|
||||
throw e;
|
||||
// throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.公司代码;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, null);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (CollUtil.isEmpty(dataArray)) {
|
||||
throw exception(ERP_COMPANY_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArray, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -284,10 +277,10 @@ public class ErpCompanyServiceImpl implements ErpCompanyService {
|
||||
HttpEntity<String> requestEntity = new HttpEntity<>(requestBody.toJSONString(), headers);
|
||||
// 发送POST请求
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
try{
|
||||
try {
|
||||
ResponseEntity<String> response = restTemplate.postForEntity(url, requestEntity, String.class);
|
||||
return url + requestEntity + response;
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
return url + requestEntity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,53 +183,47 @@ public class ErpContractServiceImpl implements ErpContractService {
|
||||
@Transactional
|
||||
@XxlJob("getErpContractTask")
|
||||
public void callErpRfcInterface() {
|
||||
try {
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.合同信息;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.合同信息;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String commanyKey = "erpMap" + OftenEnum.FuncnrEnum.公司代码.getFuncnr();
|
||||
Map<String, Long> redisCache = myRedisConfig.getRedisCacheMap(commanyKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
return;
|
||||
}
|
||||
String cstmKey = "erpMap" + OftenEnum.FuncnrEnum.客商信息.getFuncnr();
|
||||
Map<String, Long> redisCachecstmKey = myRedisConfig.getRedisCacheMap(cstmKey);
|
||||
if (CollUtil.isEmpty(redisCachecstmKey)) {
|
||||
return;
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (String INEDR : new String[]{"1", "2"}) {
|
||||
req.put("INEDR", INEDR);
|
||||
for (String number : redisCache.keySet()) {
|
||||
req.put("BUKRS", number);
|
||||
for (String partner : redisCachecstmKey.keySet()) {
|
||||
req.put("PARTNER", partner);
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String commanyKey = "erpMap" + OftenEnum.FuncnrEnum.公司代码.getFuncnr();
|
||||
Map<String, Long> redisCache = myRedisConfig.getRedisCacheMap(commanyKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
return;
|
||||
}
|
||||
String cstmKey = "erpMap" + OftenEnum.FuncnrEnum.客商信息.getFuncnr();
|
||||
Map<String, Long> redisCachecstmKey = myRedisConfig.getRedisCacheMap(cstmKey);
|
||||
if (CollUtil.isEmpty(redisCachecstmKey)) {
|
||||
return;
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (String INEDR : new String[]{"1", "2"}) {
|
||||
req.put("INEDR", INEDR);
|
||||
for (String number : redisCache.keySet()) {
|
||||
req.put("BUKRS", number);
|
||||
for (String partner : redisCachecstmKey.keySet()) {
|
||||
req.put("PARTNER", partner);
|
||||
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, null);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray!= null) {
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, null);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray != null) {
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollUtil.isEmpty(dataArrayALL)) {
|
||||
throw exception(ERP_CONTRACT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("调用ERP RFC接口失败: {}", e);
|
||||
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
|
||||
}
|
||||
if (CollUtil.isEmpty(dataArrayALL)) {
|
||||
throw exception(ERP_CONTRACT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -76,12 +76,12 @@ public class ErpCostcenterServiceImpl implements ErpCostcenterService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteErpCostcenterListByIds(List<Long> ids) {
|
||||
public void deleteErpCostcenterListByIds(List<Long> ids) {
|
||||
// 校验存在
|
||||
validateErpCostcenterExists(ids);
|
||||
// 删除
|
||||
erpCostcenterMapper.deleteByIds(ids);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateErpCostcenterExists(List<Long> ids) {
|
||||
List<ErpCostcenterDO> list = erpCostcenterMapper.selectByIds(ids);
|
||||
@@ -110,46 +110,40 @@ public class ErpCostcenterServiceImpl implements ErpCostcenterService {
|
||||
@Transactional
|
||||
@XxlJob("getErpCostcenterTask")
|
||||
public void callErpRfcInterface() {
|
||||
try {
|
||||
OftenEnum.FuncnrEnum funcnrEnum =OftenEnum.FuncnrEnum.成本中心;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erpMap" + funcnr;
|
||||
if (myRedisConfig.getRedisCacheMap( key).isEmpty()){
|
||||
initializeMap(key);
|
||||
}
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String commanyKey ="erpMap"+ OftenEnum.FuncnrEnum.公司代码.getFuncnr();
|
||||
Map<String,Long> redisCache = myRedisConfig.getRedisCacheMap(commanyKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
return;
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (String number : redisCache.keySet()) {
|
||||
req.put("BUKRS", number);
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (CollUtil.isEmpty(dataArrayALL)) {
|
||||
throw exception(ERP_COSTCENTER_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL,funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("调用ERP RFC接口失败: {}", e);
|
||||
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.成本中心;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erpMap" + funcnr;
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String commanyKey = "erpMap" + OftenEnum.FuncnrEnum.公司代码.getFuncnr();
|
||||
Map<String, Long> redisCache = myRedisConfig.getRedisCacheMap(commanyKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
return;
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (String number : redisCache.keySet()) {
|
||||
req.put("BUKRS", number);
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (CollUtil.isEmpty(dataArrayALL)) {
|
||||
throw exception(ERP_COSTCENTER_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,7 +172,7 @@ public class ErpCostcenterServiceImpl implements ErpCostcenterService {
|
||||
DO.setEndDate(LocalDateTime.parse(dataJson.getString("DATBI") + "T00:00:00"));
|
||||
}
|
||||
DO.setScopeName(dataJson.getString("FKBTX"));
|
||||
if (numbers.get(number)!=null) {
|
||||
if (numbers.get(number) != null) {
|
||||
// 更新
|
||||
DO.setId(numbers.get(number));
|
||||
toUpdate.add(DO);
|
||||
@@ -196,7 +190,7 @@ public class ErpCostcenterServiceImpl implements ErpCostcenterService {
|
||||
deleteNumbers.add(number);
|
||||
}
|
||||
}
|
||||
return new ProcessingResult(toUpdate, toInsert,deleteNumbers,key);
|
||||
return new ProcessingResult(toUpdate, toInsert, deleteNumbers, key);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,7 +210,7 @@ public class ErpCostcenterServiceImpl implements ErpCostcenterService {
|
||||
);
|
||||
Map<String, Long> numberIdMap = insertedRecords.stream()
|
||||
.collect(Collectors.toMap(ErpCostcenterDO::getNumber, ErpCostcenterDO::getId));
|
||||
myRedisConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
myRedisConfig.addRedisCacheMap(result.key, numberIdMap);
|
||||
}
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpCostcenterMapper.updateBatch(result.toUpdate);
|
||||
@@ -224,7 +218,7 @@ public class ErpCostcenterServiceImpl implements ErpCostcenterService {
|
||||
if (!result.deleteNumbers.isEmpty()) {
|
||||
// 使用 in 条件批量删除,提高删除效率
|
||||
erpCostcenterMapper.delete(new LambdaQueryWrapperX<ErpCostcenterDO>().in(ErpCostcenterDO::getNumber, result.deleteNumbers));
|
||||
myRedisConfig.deleteRedisCacheMap(result.key,result.deleteNumbers);
|
||||
myRedisConfig.deleteRedisCacheMap(result.key, result.deleteNumbers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,13 +231,14 @@ public class ErpCostcenterServiceImpl implements ErpCostcenterService {
|
||||
private final List<String> deleteNumbers;
|
||||
private final String key;
|
||||
|
||||
public ProcessingResult(List<ErpCostcenterDO> toUpdate, List<ErpCostcenterDO> toInsert,List<String> deleteNumbers,String key) {
|
||||
public ProcessingResult(List<ErpCostcenterDO> toUpdate, List<ErpCostcenterDO> toInsert, List<String> deleteNumbers, String key) {
|
||||
this.toUpdate = toUpdate;
|
||||
this.toInsert = toInsert;
|
||||
this.deleteNumbers = deleteNumbers;
|
||||
this.key = key;
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeMap(String key) {
|
||||
Map<String, Long> existingNumbers = erpCostcenterMapper.selectList(new LambdaQueryWrapperX<ErpCostcenterDO>())
|
||||
.stream()
|
||||
|
||||
@@ -110,50 +110,44 @@ public class ErpCustomerServiceImpl implements ErpCustomerService {
|
||||
@Transactional
|
||||
@XxlJob("getErpCustomerTask")
|
||||
public void callErpRfcInterface() {
|
||||
try {
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.客商信息;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.客商信息;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
// 构建req参数
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
List<Map<String, String>> datumList = new ArrayList<>();
|
||||
Map<String, String> datumEntry = new HashMap<>();
|
||||
// 构建datum参数数组
|
||||
datumEntry.put("sign", "I");
|
||||
datumEntry.put("option", "EQ");
|
||||
datumEntry.put("low", LocalDate.now().toString());
|
||||
datumList.add(datumEntry);
|
||||
req.put(funcnrEnum.getDatekey(), datumList);
|
||||
|
||||
// 1. 调用ERP接口获取数据
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
for (OftenEnum.ModeTypeEnum type : OftenEnum.ModeTypeEnum.values()) {
|
||||
req.put("mode", type.modetype);
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get(funcnrEnum.getDatakey());
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (dataArrayALL.isEmpty()){
|
||||
throw exception(ERP_CUSTOMER_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("调用ERP RFC接口失败: {}", e);
|
||||
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
// 构建req参数
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
List<Map<String, String>> datumList = new ArrayList<>();
|
||||
Map<String, String> datumEntry = new HashMap<>();
|
||||
// 构建datum参数数组
|
||||
datumEntry.put("sign", "I");
|
||||
datumEntry.put("option", "EQ");
|
||||
datumEntry.put("low", LocalDate.now().toString());
|
||||
datumList.add(datumEntry);
|
||||
req.put(funcnrEnum.getDatekey(), datumList);
|
||||
|
||||
// 1. 调用ERP接口获取数据
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
for (OftenEnum.ModeTypeEnum type : OftenEnum.ModeTypeEnum.values()) {
|
||||
req.put("mode", type.modetype);
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get(funcnrEnum.getDatakey());
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (dataArrayALL.isEmpty()) {
|
||||
throw exception(ERP_CUSTOMER_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,25 +163,30 @@ public class ErpCustomerServiceImpl implements ErpCustomerService {
|
||||
for (int i = 0; i < dataArray.size(); i++) {
|
||||
JSONObject dataJson = dataArray.getJSONObject(i);
|
||||
if (dataJson != null) {
|
||||
String number = dataJson.getString(funcnrEnum.getDatakey()).trim();
|
||||
String number = dataJson.getString(funcnrEnum.getDatakey());
|
||||
if (number != null) {
|
||||
number = number.trim();
|
||||
}
|
||||
ErpCustomerDO DO = new ErpCustomerDO();
|
||||
DO.setName(dataJson.getString("NAME_ORG1"));
|
||||
DO.setNumber(number);
|
||||
DO.setAccountGroup(dataJson.getString("BU_GROUP"));
|
||||
DO.setDescription(dataJson.getString("BU_SORT1"));
|
||||
DO.setCenterNumber(dataJson.getString("BU_SORT2"));
|
||||
if (!dataJson.getString("CRDAT").equals("0000-00-00")) {
|
||||
DO.setCreateDate(LocalDateTime.parse(dataJson.getString("CRDAT") + "T00:00:00"));
|
||||
String crdat = dataJson.getString("CRDAT");
|
||||
if (crdat != null && !crdat.equals("0000-00-00")) {
|
||||
DO.setCreateDate(LocalDateTime.parse(crdat + "T00:00:00"));
|
||||
}
|
||||
if (!dataJson.getString("CHDAT").equals("0000-00-00")) {
|
||||
DO.setRepairDate(LocalDateTime.parse(dataJson.getString("CHDAT") + "T00:00:00"));
|
||||
String chdat = dataJson.getString("CHDAT");
|
||||
if (chdat != null && !chdat.equals("0000-00-00")) {
|
||||
DO.setRepairDate(LocalDateTime.parse(chdat + "T00:00:00"));
|
||||
}
|
||||
DO.setIsGiveback(dataJson.getString("XDELE"));
|
||||
DO.setIsProvisional(dataJson.getString("XBLCK"));
|
||||
// DO.setType(type.modetype);
|
||||
|
||||
// 使用 Map 优化查找效率,避免每次遍历 comnumbers 列表
|
||||
if (numbers.get(number)!=null) {
|
||||
if (number != null && numbers.get(number) != null) {
|
||||
// 更新
|
||||
DO.setId(numbers.get(number));
|
||||
toUpdate.add(DO);
|
||||
@@ -218,7 +217,7 @@ public class ErpCustomerServiceImpl implements ErpCustomerService {
|
||||
);
|
||||
Map<String, Long> numberIdMap = insertedRecords.stream()
|
||||
.collect(Collectors.toMap(ErpCustomerDO::getNumber, ErpCustomerDO::getId));
|
||||
myRedisConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
myRedisConfig.addRedisCacheMap(result.key, numberIdMap);
|
||||
}
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpCustomerMapper.updateBatch(result.toUpdate);
|
||||
|
||||
@@ -55,7 +55,7 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
|
||||
// 插入
|
||||
ErpFactoryDO erpFactory = BeanUtils.toBean(createReqVO, ErpFactoryDO.class);
|
||||
// 工厂编码自动生成,格式 GC-0001,依次新增
|
||||
if (erpFactory.getNumber() == null){
|
||||
if (erpFactory.getNumber() == null) {
|
||||
String maxCode = erpFactoryMapper.selectMaxCode();
|
||||
if (maxCode == null) {
|
||||
erpFactory.setNumber("GC-0001");
|
||||
@@ -80,7 +80,7 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
|
||||
validateErpFactoryExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ErpFactoryDO updateObj = BeanUtils.toBean(updateReqVO, ErpFactoryDO.class);
|
||||
if (updateObj.getType().equals("ERP")||updateObj.getIsEnable().equals("1")){
|
||||
if (updateObj.getType().equals("ERP") || updateObj.getIsEnable().equals("1")) {
|
||||
throw exception(ERP_FACTORY_NOT_ALLOW_UPDATE);
|
||||
}
|
||||
erpFactoryMapper.updateById(updateObj);
|
||||
@@ -95,12 +95,12 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteErpFactoryListByIds(List<Long> ids) {
|
||||
public void deleteErpFactoryListByIds(List<Long> ids) {
|
||||
// 校验存在
|
||||
validateErpFactoryExists(ids);
|
||||
// 删除
|
||||
erpFactoryMapper.deleteByIds(ids);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateErpFactoryExists(List<Long> ids) {
|
||||
List<ErpFactoryDO> list = erpFactoryMapper.selectByIds(ids);
|
||||
@@ -164,53 +164,47 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
|
||||
@Transactional
|
||||
@XxlJob("getErpFactoryTask")
|
||||
public void callErpRfcInterface() {
|
||||
try {
|
||||
OftenEnum.FuncnrEnum funcnrEnum =OftenEnum.FuncnrEnum.工厂信息;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String companykey = "erpMap" + OftenEnum.FuncnrEnum.公司代码.getFuncnr();
|
||||
Map<String,Long> redisCache = myRedisConfig.getRedisCacheMap(companykey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
|
||||
}
|
||||
for (String companyNumber : redisCache.keySet()) {
|
||||
req.put("BUKRS", companyNumber);
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
// 往每个子项中添加BUKRS字段
|
||||
for (int j = 0; j < dataArray.size(); j++) {
|
||||
JSONObject item = dataArray.getJSONObject(j);
|
||||
if (item != null) {
|
||||
item.put("BUKRS", companyNumber);
|
||||
}
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (CollUtil.isEmpty(dataArrayALL)) {
|
||||
throw exception(ERP_FACTORY_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL,funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("调用ERP RFC接口失败: {}", e);
|
||||
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.工厂信息;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String companykey = "erpMap" + OftenEnum.FuncnrEnum.公司代码.getFuncnr();
|
||||
Map<String, Long> redisCache = myRedisConfig.getRedisCacheMap(companykey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
|
||||
}
|
||||
for (String companyNumber : redisCache.keySet()) {
|
||||
req.put("BUKRS", companyNumber);
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
// 往每个子项中添加BUKRS字段
|
||||
for (int j = 0; j < dataArray.size(); j++) {
|
||||
JSONObject item = dataArray.getJSONObject(j);
|
||||
if (item != null) {
|
||||
item.put("BUKRS", companyNumber);
|
||||
}
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (CollUtil.isEmpty(dataArrayALL)) {
|
||||
throw exception(ERP_FACTORY_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -232,7 +226,7 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
|
||||
DO.setNumber(number);
|
||||
DO.setErpCompanyNumber(dataJson.getString("BUKRS"));
|
||||
DO.setType("ERP");
|
||||
if (numbers.get(number)!=null) {
|
||||
if (numbers.get(number) != null) {
|
||||
// 更新
|
||||
DO.setId(numbers.get(number));
|
||||
toUpdate.add(DO);
|
||||
@@ -251,7 +245,7 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
|
||||
deleteNumbers.add(number);
|
||||
}
|
||||
}
|
||||
return new ProcessingResult(toUpdate, toInsert,key,deleteNumbers);
|
||||
return new ProcessingResult(toUpdate, toInsert, key, deleteNumbers);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -271,7 +265,7 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
|
||||
);
|
||||
Map<String, Long> numberIdMap = insertedRecords.stream()
|
||||
.collect(Collectors.toMap(ErpFactoryDO::getNumber, ErpFactoryDO::getId));
|
||||
myRedisConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
myRedisConfig.addRedisCacheMap(result.key, numberIdMap);
|
||||
}
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpFactoryMapper.updateBatch(result.toUpdate);
|
||||
@@ -292,7 +286,7 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
|
||||
private final String key;
|
||||
private final List<String> deleteNumbers;
|
||||
|
||||
public ProcessingResult(List<ErpFactoryDO> toUpdate, List<ErpFactoryDO> toInsert,String key,List<String> deleteNumbers) {
|
||||
public ProcessingResult(List<ErpFactoryDO> toUpdate, List<ErpFactoryDO> toInsert, String key, List<String> deleteNumbers) {
|
||||
this.toUpdate = toUpdate;
|
||||
this.toInsert = toInsert;
|
||||
this.key = key;
|
||||
|
||||
@@ -108,47 +108,41 @@ public class ErpInternalOrderServiceImpl implements ErpInternalOrderService {
|
||||
@Transactional
|
||||
@XxlJob("getErpInternalOrderTask")
|
||||
public void callErpRfcInterface() {
|
||||
try {
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.内部订单;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String companyCode = "erpMap" + OftenEnum.FuncnrEnum.公司代码.getFuncnr();
|
||||
Map<String,Long> redisCache = myRedisConfig.getRedisCacheMap(companyCode);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (String number : redisCache.keySet()) {
|
||||
req.put("BUKRS", number);
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (CollUtil.isEmpty(dataArrayALL)) {
|
||||
throw exception(ERP_INTERNAL_ORDER_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("调用ERP RFC接口失败: {}", e);
|
||||
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.内部订单;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String companyCode = "erpMap" + OftenEnum.FuncnrEnum.公司代码.getFuncnr();
|
||||
Map<String, Long> redisCache = myRedisConfig.getRedisCacheMap(companyCode);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (String number : redisCache.keySet()) {
|
||||
req.put("BUKRS", number);
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (CollUtil.isEmpty(dataArrayALL)) {
|
||||
throw exception(ERP_INTERNAL_ORDER_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,7 +165,7 @@ public class ErpInternalOrderServiceImpl implements ErpInternalOrderService {
|
||||
DO.setType(dataJson.getString("AUART"));
|
||||
DO.setIsOff(dataJson.getString("PHAS3"));
|
||||
DO.setIsFinish(dataJson.getString("PHAS2"));
|
||||
if (numbers.get(number)!=null) {
|
||||
if (numbers.get(number) != null) {
|
||||
// 更新
|
||||
DO.setId(numbers.get(number));
|
||||
toUpdate.add(DO);
|
||||
@@ -210,7 +204,7 @@ public class ErpInternalOrderServiceImpl implements ErpInternalOrderService {
|
||||
);
|
||||
Map<String, Long> numberIdMap = insertedRecords.stream()
|
||||
.collect(Collectors.toMap(ErpInternalOrderDO::getNumber, ErpInternalOrderDO::getId));
|
||||
myRedisConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
myRedisConfig.addRedisCacheMap(result.key, numberIdMap);
|
||||
}
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpInternalOrderMapper.updateBatch(result.toUpdate);
|
||||
|
||||
@@ -164,7 +164,7 @@ public class ErpMaterialServiceImpl implements ErpMaterialService {
|
||||
MaterialOtherDTO dto = new MaterialOtherDTO();
|
||||
dto.setMaterialNumber(respVO.getDownCenterNumber());
|
||||
List<MaterialOtherDTO> dtos = baseApi.getMaterialOtherNoPage(dto);
|
||||
if (dtos != null){
|
||||
if (dtos != null) {
|
||||
respVO.setMaterialOtherDTOS(dtos);
|
||||
}
|
||||
}
|
||||
@@ -178,43 +178,37 @@ public class ErpMaterialServiceImpl implements ErpMaterialService {
|
||||
@Transactional
|
||||
@XxlJob("getErpMaterialTask")
|
||||
public void callErpRfcInterface() {
|
||||
try {
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.物料数据;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erp" + funcnrEnum.getFuncnr();
|
||||
if (myRedisConfig.getRedisCache(key) == null) {
|
||||
initialize(key);
|
||||
}
|
||||
|
||||
// 构建req参数
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
List<Map<String, String>> datumList = new ArrayList<>();
|
||||
Map<String, String> datumEntry = new HashMap<>();
|
||||
datumEntry.put("sign", "I");
|
||||
datumEntry.put("option", "EQ");
|
||||
// datumEntry.put("low", "2021-05-20");
|
||||
datumEntry.put("low", LocalDate.now().toString());
|
||||
datumList.add(datumEntry);
|
||||
req.put(funcnrEnum.getDatekey(), datumList);
|
||||
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (CollUtil.isEmpty(dataArray)) {
|
||||
throw exception(ERP_MATERIAL_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArray, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("调用ERP RFC接口失败: {}", e);
|
||||
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.物料数据;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erp" + funcnrEnum.getFuncnr();
|
||||
if (myRedisConfig.getRedisCache(key) == null) {
|
||||
initialize(key);
|
||||
}
|
||||
|
||||
// 构建req参数
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
List<Map<String, String>> datumList = new ArrayList<>();
|
||||
Map<String, String> datumEntry = new HashMap<>();
|
||||
datumEntry.put("sign", "I");
|
||||
datumEntry.put("option", "EQ");
|
||||
// datumEntry.put("low", "2021-05-20");
|
||||
datumEntry.put("low", LocalDate.now().toString());
|
||||
datumList.add(datumEntry);
|
||||
req.put(funcnrEnum.getDatekey(), datumList);
|
||||
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (CollUtil.isEmpty(dataArray)) {
|
||||
throw exception(ERP_MATERIAL_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArray, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -66,12 +66,12 @@ public class ErpProcessDetailServiceImpl implements ErpProcessDetailService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteErpProcessDetailListByIds(List<Long> ids) {
|
||||
public void deleteErpProcessDetailListByIds(List<Long> ids) {
|
||||
// 校验存在
|
||||
validateErpProcessDetailExists(ids);
|
||||
// 删除
|
||||
erpProcessDetailMapper.deleteByIds(ids);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateErpProcessDetailExists(List<Long> ids) {
|
||||
List<ErpProcessDetailDO> list = erpProcessDetailMapper.selectByIds(ids);
|
||||
@@ -115,10 +115,10 @@ public class ErpProcessDetailServiceImpl implements ErpProcessDetailService {
|
||||
List<String> dataArrayNumbers = new ArrayList<>();
|
||||
Map<String, Long> existingNumbers = myRedisConfig.getRedisCacheMap(key);
|
||||
for (ErpProcessDetailDO updateReqVO : updateReqVOS) {
|
||||
if (updateReqVO.getProcessingName() == null|| updateReqVO.getProcessingName().isEmpty()){
|
||||
if (updateReqVO.getProcessingName() == null || updateReqVO.getProcessingName().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
String mapKey = updateReqVO.getProcessId() + "-" + updateReqVO.getProcessingNumber();
|
||||
String mapKey = updateReqVO.getProcessId() + "-" + updateReqVO.getProcessingNumber()+"-" + updateReqVO.getWorkCenterNumber();
|
||||
if (existingNumbers.containsKey(mapKey)) {
|
||||
updateReqVO.setId(existingNumbers.get(mapKey));
|
||||
}
|
||||
@@ -149,10 +149,12 @@ public class ErpProcessDetailServiceImpl implements ErpProcessDetailService {
|
||||
new LambdaQueryWrapperX<ErpProcessDetailDO>()
|
||||
.in(ErpProcessDetailDO::getProcessId, result.toInsert.stream().map(ErpProcessDetailDO::getProcessId).distinct().collect(Collectors.toList()))
|
||||
.in(ErpProcessDetailDO::getProcessingNumber, result.toInsert.stream().map(ErpProcessDetailDO::getProcessingNumber).distinct().collect(Collectors.toList()))
|
||||
// .in(ErpProcessDetailDO::getProcessingName, result.toInsert.stream().map(ErpProcessDetailDO::getProcessingName).distinct().collect(Collectors.toList()))
|
||||
.in(ErpProcessDetailDO::getWorkCenterNumber, result.toInsert.stream().map(ErpProcessDetailDO::getWorkCenterNumber).distinct().collect(Collectors.toList()))
|
||||
);
|
||||
Map<String, Long> numberIdMap = insertedRecords.stream()
|
||||
.collect(Collectors.toMap(asset -> asset.getProcessId() + "-" + asset.getProcessingNumber(), ErpProcessDetailDO::getId));
|
||||
.collect(Collectors.toMap(
|
||||
asset -> asset.getProcessId() + "-" + asset.getProcessingNumber() + "-" + asset.getWorkCenterNumber(),
|
||||
ErpProcessDetailDO::getId, (existing, replacement) -> replacement));
|
||||
myRedisConfig.addRedisCacheMap(result.key, numberIdMap);
|
||||
}
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
@@ -186,7 +188,7 @@ public class ErpProcessDetailServiceImpl implements ErpProcessDetailService {
|
||||
List<ErpProcessDetailDO> assets = erpProcessDetailMapper.selectList(new LambdaQueryWrapperX<ErpProcessDetailDO>());
|
||||
Map<String, Long> existingNumbers = new HashMap<>();
|
||||
for (ErpProcessDetailDO asset : assets) {
|
||||
String mapKey = asset.getProcessId() + "-" + asset.getProcessingNumber();
|
||||
String mapKey = asset.getProcessId() + "-" + asset.getProcessingNumber()+ "-" + asset.getWorkCenterNumber();
|
||||
existingNumbers.put(mapKey, asset.getId());
|
||||
}
|
||||
myRedisConfig.addRedisCacheMap(key, existingNumbers);
|
||||
|
||||
@@ -114,45 +114,39 @@ public class ErpProcessServiceImpl implements ErpProcessService {
|
||||
@Transactional
|
||||
@XxlJob("getErpProcessTask")
|
||||
public void callErpRfcInterface() {
|
||||
try {
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.工艺路线;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
String key = "erpMap" + funcnr;
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String factKey = "erpMap" + OftenEnum.FuncnrEnum.工厂信息.getFuncnr();
|
||||
Map<String, Long> redisCache = myRedisConfig.getRedisCacheMap(factKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
throw exception(ERP_FACTORY_NOT_EXISTS);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (String factoryNumber : redisCache.keySet()) {
|
||||
req.put("WERKS", factoryNumber);
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (dataArrayALL.isEmpty()){
|
||||
throw exception(ERP_PROCESS_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("调用ERP RFC接口失败: {}", e);
|
||||
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.工艺路线;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
String key = "erpMap" + funcnr;
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String factKey = "erpMap" + OftenEnum.FuncnrEnum.工厂信息.getFuncnr();
|
||||
Map<String, Long> redisCache = myRedisConfig.getRedisCacheMap(factKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
throw exception(ERP_FACTORY_NOT_EXISTS);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (String factoryNumber : redisCache.keySet()) {
|
||||
req.put("WERKS", factoryNumber);
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (dataArrayALL.isEmpty()) {
|
||||
throw exception(ERP_PROCESS_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,16 +165,25 @@ public class ErpProcessServiceImpl implements ErpProcessService {
|
||||
JSONObject dataJson = dataArray.getJSONObject(i);
|
||||
if (dataJson != null) {
|
||||
ErpProcessDO DO = new ErpProcessDO();
|
||||
DO.setFactoryNumber(dataJson.getString("WERKS"));
|
||||
DO.setMaterialNumber(dataJson.getString("MATNR"));
|
||||
DO.setMaterialName(dataJson.getString("MAKTX"));
|
||||
DO.setBlineGroup(dataJson.getString("PLNAL"));
|
||||
DO.setGroupCount(dataJson.getLong("PLNNR"));
|
||||
DO.setBlineDescription(dataJson.getString("KTEXT"));
|
||||
DO.setUom(dataJson.getString("PLNME"));
|
||||
DO.setUseDescription(dataJson.getString("VERWE"));
|
||||
DO.setStatus(dataJson.getString("STATU"));
|
||||
String number = DO.getFactoryNumber() + "-" + DO.getMaterialNumber() + "-" + DO.getBlineGroup();
|
||||
DO.setFactoryNumber(dataJson.getString("WERKS").trim());
|
||||
DO.setMaterialNumber(dataJson.getString("MATNR").trim());
|
||||
DO.setMaterialName(dataJson.getString("MAKTX").trim());
|
||||
DO.setBlineGroup(dataJson.getString("PLNAL").trim());
|
||||
Long groupCount = null;
|
||||
String plnnrStr = dataJson.getString("PLNNR");
|
||||
if (plnnrStr != null && !plnnrStr.trim().isEmpty()) {
|
||||
try {
|
||||
groupCount = Long.valueOf(plnnrStr.trim());
|
||||
} catch (NumberFormatException e) {
|
||||
log.error("转换PLNNR为Long类型失败: " + plnnrStr, e);
|
||||
}
|
||||
}
|
||||
DO.setGroupCount(groupCount);
|
||||
DO.setBlineDescription(dataJson.getString("KTEXT").trim());
|
||||
DO.setUom(dataJson.getString("PLNME").trim());
|
||||
DO.setUseDescription(dataJson.getString("VERWE").trim());
|
||||
DO.setStatus(dataJson.getString("STATU").trim());
|
||||
String number = DO.getFactoryNumber() + "-" + DO.getMaterialNumber() + "-" + DO.getBlineGroup().trim()+"-" + DO.getGroupCount();
|
||||
dataArrayNumbers.add(number);
|
||||
if (numbers.get(number) != null) {
|
||||
// 更新
|
||||
@@ -271,7 +274,7 @@ public class ErpProcessServiceImpl implements ErpProcessService {
|
||||
List<ErpProcessDO> bomList = erpProcessMapper.selectList(new LambdaQueryWrapperX<ErpProcessDO>());
|
||||
Map<String, Long> existingNumbers = new HashMap<>();
|
||||
for (ErpProcessDO bom : bomList) {
|
||||
String mapKey = bom.getFactoryNumber() + "-" + bom.getMaterialNumber() + "-" + bom.getBlineGroup();
|
||||
String mapKey = bom.getFactoryNumber() + "-" + bom.getMaterialNumber() + "-" + bom.getBlineGroup()+"-" + bom.getGroupCount();
|
||||
existingNumbers.put(mapKey, bom.getId());
|
||||
}
|
||||
myRedisConfig.addRedisCacheMap(key, existingNumbers);
|
||||
|
||||
@@ -183,49 +183,43 @@ public class ErpProductiveOrderServiceImpl implements ErpProductiveOrderService
|
||||
@Transactional
|
||||
@XxlJob("getErpProductiveOrderTask")
|
||||
public void callErpRfcInterface() {
|
||||
try {
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.生产订单;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.生产订单;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
List<Map<String, String>> datumList = new ArrayList<>();
|
||||
Map<String, String> datumEntry = new HashMap<>();
|
||||
// 构建datum参数数组
|
||||
datumEntry.put("sign", "I");
|
||||
datumEntry.put("option", "EQ");
|
||||
datumEntry.put("low", LocalDate.now().toString());
|
||||
datumList.add(datumEntry);
|
||||
req.put(funcnrEnum.getDatekey(), datumList);
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
List<String> redisCache = myRedisConfig.getRedisCache(OftenEnum.FuncnrEnum.工厂信息.getFuncnr());
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
throw exception(ERP_FACTORY_NOT_EXISTS);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (String number : redisCache) {
|
||||
req.put("WERKS", number);
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (dataArrayALL.isEmpty()){
|
||||
throw exception(ERP_PRODUCTIVE_ORDER_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("调用ERP RFC接口失败: {}", e);
|
||||
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
List<Map<String, String>> datumList = new ArrayList<>();
|
||||
Map<String, String> datumEntry = new HashMap<>();
|
||||
// 构建datum参数数组
|
||||
datumEntry.put("sign", "I");
|
||||
datumEntry.put("option", "EQ");
|
||||
datumEntry.put("low", LocalDate.now().toString());
|
||||
datumList.add(datumEntry);
|
||||
req.put(funcnrEnum.getDatekey(), datumList);
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
List<String> redisCache = myRedisConfig.getRedisCache(OftenEnum.FuncnrEnum.工厂信息.getFuncnr());
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
throw exception(ERP_FACTORY_NOT_EXISTS);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (String number : redisCache) {
|
||||
req.put("WERKS", number);
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (dataArrayALL.isEmpty()) {
|
||||
throw exception(ERP_PRODUCTIVE_ORDER_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -74,12 +74,12 @@ public class ErpProductiveVersionServiceImpl implements ErpProductiveVersionServ
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteErpProductiveVersionListByIds(List<Long> ids) {
|
||||
public void deleteErpProductiveVersionListByIds(List<Long> ids) {
|
||||
// 校验存在
|
||||
validateErpProductiveVersionExists(ids);
|
||||
// 删除
|
||||
erpProductiveVersionMapper.deleteByIds(ids);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateErpProductiveVersionExists(List<Long> ids) {
|
||||
List<ErpProductiveVersionDO> list = erpProductiveVersionMapper.selectByIds(ids);
|
||||
@@ -108,47 +108,41 @@ public class ErpProductiveVersionServiceImpl implements ErpProductiveVersionServ
|
||||
@Transactional
|
||||
@XxlJob("getErpProductiveVersionTask")
|
||||
public void callErpRfcInterface() {
|
||||
try {
|
||||
OftenEnum.FuncnrEnum funcnrEnum =OftenEnum.FuncnrEnum.生产版本;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String factKey ="erpMap"+ OftenEnum.FuncnrEnum.工厂信息.getFuncnr();
|
||||
Map<String,Long> redisCache = myRedisConfig.getRedisCacheMap(factKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
throw exception(ERP_FACTORY_NOT_EXISTS);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (String number : redisCache.keySet()) {
|
||||
req.put("WERKS", number);
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (dataArrayALL.isEmpty()){
|
||||
throw exception(ERP_PRODUCTIVE_VERSION_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL,funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("调用ERP RFC接口失败: {}", e);
|
||||
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.生产版本;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String factKey = "erpMap" + OftenEnum.FuncnrEnum.工厂信息.getFuncnr();
|
||||
Map<String, Long> redisCache = myRedisConfig.getRedisCacheMap(factKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
throw exception(ERP_FACTORY_NOT_EXISTS);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (String number : redisCache.keySet()) {
|
||||
req.put("WERKS", number);
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (dataArrayALL.isEmpty()) {
|
||||
throw exception(ERP_PRODUCTIVE_VERSION_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,15 +159,17 @@ public class ErpProductiveVersionServiceImpl implements ErpProductiveVersionServ
|
||||
JSONObject dataJson = dataArray.getJSONObject(i);
|
||||
if (dataJson != null) {
|
||||
ErpProductiveVersionDO DO = new ErpProductiveVersionDO();
|
||||
DO.setFactoryNumber(dataJson.getString("MATNR").trim());
|
||||
DO.setMaterialNumber(dataJson.getString("WERKS").trim());
|
||||
DO.setProductiveVersionNumber(dataJson.getString("VERID").trim());
|
||||
DO.setFactoryNumber(dataJson.getString("MATNR") != null ? dataJson.getString("MATNR").trim() : null);
|
||||
DO.setMaterialNumber(dataJson.getString("WERKS") != null ? dataJson.getString("WERKS").trim() : null);
|
||||
DO.setProductiveVersionNumber(dataJson.getString("VERID") != null ? dataJson.getString("VERID").trim() : null);
|
||||
DO.setProductiveVersionName(dataJson.getString("TEXT1"));
|
||||
DO.setBomNumber(dataJson.getString("STLAL"));
|
||||
DO.setBlineGroup(dataJson.getString("PLNNR"));
|
||||
DO.setGroupCount(Long.valueOf(dataJson.getString("ALNAL").trim()));
|
||||
String number = dataJson.getString("MATNR").trim()+"-"+dataJson.getString("WERKS").trim()+"-"+dataJson.getString("VERID").trim();
|
||||
if (numbers.get(number)!=null) {
|
||||
String alnalValue = dataJson.getString("ALNAL");
|
||||
// 修复:增加对空字符串的判断
|
||||
DO.setGroupCount(alnalValue != null && !alnalValue.trim().isEmpty() ? Long.valueOf(alnalValue.trim()) : null);
|
||||
String number = dataJson.getString("MATNR").trim() + "-" + dataJson.getString("WERKS").trim() + "-" + dataJson.getString("VERID").trim();
|
||||
if (numbers.get(number) != null) {
|
||||
// 更新
|
||||
DO.setId(numbers.get(number));
|
||||
toUpdate.add(DO);
|
||||
@@ -188,11 +184,11 @@ public class ErpProductiveVersionServiceImpl implements ErpProductiveVersionServ
|
||||
Map<String, Long> deleteNumbers = new HashMap<>();
|
||||
for (String number : numbers.keySet()) {
|
||||
if (!dataArrayNumbers.contains(number)) {
|
||||
deleteNumbers.put(number,numbers.get(number));
|
||||
deleteNumbers.put(number, numbers.get(number));
|
||||
}
|
||||
}
|
||||
|
||||
return new ProcessingResult(toUpdate, toInsert,key,deleteNumbers);
|
||||
return new ProcessingResult(toUpdate, toInsert, key, deleteNumbers);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -210,13 +206,13 @@ public class ErpProductiveVersionServiceImpl implements ErpProductiveVersionServ
|
||||
.in(ErpProductiveVersionDO::getProductiveVersionNumber, result.toInsert.stream().map(ErpProductiveVersionDO::getProductiveVersionNumber).collect(Collectors.toList()))
|
||||
);
|
||||
Map<String, Long> numberIdMap = insertedRecords.stream()
|
||||
.collect(Collectors.toMap(asset -> asset.getFactoryNumber() + "-" + asset.getMaterialNumber()+ "-" + asset.getProductiveVersionNumber(), ErpProductiveVersionDO::getId));
|
||||
myRedisConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
.collect(Collectors.toMap(asset -> asset.getFactoryNumber() + "-" + asset.getMaterialNumber() + "-" + asset.getProductiveVersionNumber(), ErpProductiveVersionDO::getId));
|
||||
myRedisConfig.addRedisCacheMap(result.key, numberIdMap);
|
||||
}
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpProductiveVersionMapper.updateBatch(result.toUpdate);
|
||||
}
|
||||
if (!result.deleteNumbers.isEmpty()){
|
||||
if (!result.deleteNumbers.isEmpty()) {
|
||||
// 使用流式处理和批处理优化删除逻辑
|
||||
List<Long> idsToDelete = new ArrayList<>(result.deleteNumbers.values());
|
||||
erpProductiveVersionMapper.deleteByIds(idsToDelete);
|
||||
@@ -233,7 +229,7 @@ public class ErpProductiveVersionServiceImpl implements ErpProductiveVersionServ
|
||||
private final String key;
|
||||
private final Map<String, Long> deleteNumbers;
|
||||
|
||||
public ProcessingResult(List<ErpProductiveVersionDO> toUpdate, List<ErpProductiveVersionDO> toInsert,String key,Map<String, Long> deleteNumbers) {
|
||||
public ProcessingResult(List<ErpProductiveVersionDO> toUpdate, List<ErpProductiveVersionDO> toInsert, String key, Map<String, Long> deleteNumbers) {
|
||||
this.toUpdate = toUpdate;
|
||||
this.toInsert = toInsert;
|
||||
this.key = key;
|
||||
|
||||
@@ -74,12 +74,12 @@ public class ErpPurchaseOrganizationServiceImpl implements ErpPurchaseOrganizati
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteErpPurchaseOrganizationListByIds(List<Long> ids) {
|
||||
public void deleteErpPurchaseOrganizationListByIds(List<Long> ids) {
|
||||
// 校验存在
|
||||
validateErpPurchaseOrganizationExists(ids);
|
||||
// 删除
|
||||
erpPurchaseOrganizationMapper.deleteByIds(ids);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateErpPurchaseOrganizationExists(List<Long> ids) {
|
||||
List<ErpPurchaseOrganizationDO> list = erpPurchaseOrganizationMapper.selectByIds(ids);
|
||||
@@ -108,55 +108,49 @@ public class ErpPurchaseOrganizationServiceImpl implements ErpPurchaseOrganizati
|
||||
@Transactional
|
||||
@XxlJob("getErpPurchaseOrganizationTask")
|
||||
public void callErpRfcInterface() {
|
||||
try {
|
||||
OftenEnum.FuncnrEnum funcnrEnum =OftenEnum.FuncnrEnum.采购组织;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
// String factKey ="erpMap"+ OftenEnum.FuncnrEnum.工厂信息.getFuncnr();
|
||||
String factKey ="erpMap"+ OftenEnum.FuncnrEnum.公司代码.getFuncnr();
|
||||
Map<String,Long> redisCache = myRedisConfig.getRedisCacheMap(factKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (String number : redisCache.keySet()) {
|
||||
req.put("BUKRS", number);
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
// 往每个子项中添加BUKRS字段
|
||||
for (int j = 0; j < dataArray.size(); j++) {
|
||||
JSONObject item = dataArray.getJSONObject(j);
|
||||
if (item != null) {
|
||||
item.put("BUKRS", number);
|
||||
}
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (dataArrayALL.isEmpty()){
|
||||
throw exception(ERP_PURCHASE_ORGANIZATION_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL,funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("调用ERP RFC接口失败: {}", e);
|
||||
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.采购组织;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
// String factKey ="erpMap"+ OftenEnum.FuncnrEnum.工厂信息.getFuncnr();
|
||||
String factKey = "erpMap" + OftenEnum.FuncnrEnum.公司代码.getFuncnr();
|
||||
Map<String, Long> redisCache = myRedisConfig.getRedisCacheMap(factKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (String number : redisCache.keySet()) {
|
||||
req.put("BUKRS", number);
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
// 往每个子项中添加BUKRS字段
|
||||
for (int j = 0; j < dataArray.size(); j++) {
|
||||
JSONObject item = dataArray.getJSONObject(j);
|
||||
if (item != null) {
|
||||
item.put("BUKRS", number);
|
||||
}
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (dataArrayALL.isEmpty()) {
|
||||
throw exception(ERP_PURCHASE_ORGANIZATION_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -177,7 +171,7 @@ public class ErpPurchaseOrganizationServiceImpl implements ErpPurchaseOrganizati
|
||||
DO.setName(dataJson.getString("EKOTX"));
|
||||
DO.setNumber(number);
|
||||
DO.setCompanyNumber(dataJson.getString("BUKRS"));
|
||||
if (numbers.get(number)!=null) {
|
||||
if (numbers.get(number) != null) {
|
||||
// 更新
|
||||
DO.setId(numbers.get(number));
|
||||
toUpdate.add(DO);
|
||||
@@ -196,7 +190,7 @@ public class ErpPurchaseOrganizationServiceImpl implements ErpPurchaseOrganizati
|
||||
}
|
||||
}
|
||||
|
||||
return new ProcessingResult(toUpdate, toInsert,key,deleteNumbers);
|
||||
return new ProcessingResult(toUpdate, toInsert, key, deleteNumbers);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,12 +210,12 @@ public class ErpPurchaseOrganizationServiceImpl implements ErpPurchaseOrganizati
|
||||
);
|
||||
Map<String, Long> numberIdMap = insertedRecords.stream()
|
||||
.collect(Collectors.toMap(ErpPurchaseOrganizationDO::getNumber, ErpPurchaseOrganizationDO::getId));
|
||||
myRedisConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
myRedisConfig.addRedisCacheMap(result.key, numberIdMap);
|
||||
}
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpPurchaseOrganizationMapper.updateBatch(result.toUpdate);
|
||||
}
|
||||
if (!result.deleteNumbers.isEmpty()){
|
||||
if (!result.deleteNumbers.isEmpty()) {
|
||||
// 使用 in 条件批量删除,提高删除效率
|
||||
erpPurchaseOrganizationMapper.delete(new LambdaQueryWrapperX<ErpPurchaseOrganizationDO>().in(ErpPurchaseOrganizationDO::getNumber, result.deleteNumbers));
|
||||
myRedisConfig.deleteRedisCacheMap(result.key, result.deleteNumbers);
|
||||
@@ -237,7 +231,7 @@ public class ErpPurchaseOrganizationServiceImpl implements ErpPurchaseOrganizati
|
||||
private final String key;
|
||||
private final List<String> deleteNumbers;
|
||||
|
||||
public ProcessingResult(List<ErpPurchaseOrganizationDO> toUpdate, List<ErpPurchaseOrganizationDO> toInsert,String key,List<String> deleteNumbers) {
|
||||
public ProcessingResult(List<ErpPurchaseOrganizationDO> toUpdate, List<ErpPurchaseOrganizationDO> toInsert, String key, List<String> deleteNumbers) {
|
||||
this.toUpdate = toUpdate;
|
||||
this.toInsert = toInsert;
|
||||
this.key = key;
|
||||
|
||||
@@ -74,12 +74,12 @@ public class ErpSalesOrganizationServiceImpl implements ErpSalesOrganizationServ
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteErpSalesOrganizationListByIds(List<Long> ids) {
|
||||
public void deleteErpSalesOrganizationListByIds(List<Long> ids) {
|
||||
// 校验存在
|
||||
validateErpSalesOrganizationExists(ids);
|
||||
// 删除
|
||||
erpSalesOrganizationMapper.deleteByIds(ids);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateErpSalesOrganizationExists(List<Long> ids) {
|
||||
List<ErpSalesOrganizationDO> list = erpSalesOrganizationMapper.selectByIds(ids);
|
||||
@@ -108,54 +108,48 @@ public class ErpSalesOrganizationServiceImpl implements ErpSalesOrganizationServ
|
||||
@Transactional
|
||||
@XxlJob("getErpSalesOrganizationTask")
|
||||
public void callErpRfcInterface() {
|
||||
try {
|
||||
OftenEnum.FuncnrEnum funcnrEnum =OftenEnum.FuncnrEnum.销售组织;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String factKey ="erpMap"+ OftenEnum.FuncnrEnum.公司代码.getFuncnr();
|
||||
Map<String,Long> redisCache = myRedisConfig.getRedisCacheMap(factKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (String number : redisCache.keySet()) {
|
||||
req.put("BUKRS", number);
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
// 往每个子项中添加BUKRS字段
|
||||
for (int j = 0; j < dataArray.size(); j++) {
|
||||
JSONObject item = dataArray.getJSONObject(j);
|
||||
if (item != null) {
|
||||
item.put("BUKRS", number);
|
||||
}
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (dataArrayALL.isEmpty()){
|
||||
throw exception(ERP_SALES_ORGANIZATION_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL,funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("调用ERP RFC接口失败: {}", e);
|
||||
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.销售组织;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String factKey = "erpMap" + OftenEnum.FuncnrEnum.公司代码.getFuncnr();
|
||||
Map<String, Long> redisCache = myRedisConfig.getRedisCacheMap(factKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (String number : redisCache.keySet()) {
|
||||
req.put("BUKRS", number);
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
// 往每个子项中添加BUKRS字段
|
||||
for (int j = 0; j < dataArray.size(); j++) {
|
||||
JSONObject item = dataArray.getJSONObject(j);
|
||||
if (item != null) {
|
||||
item.put("BUKRS", number);
|
||||
}
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (dataArrayALL.isEmpty()) {
|
||||
throw exception(ERP_SALES_ORGANIZATION_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,7 +170,7 @@ public class ErpSalesOrganizationServiceImpl implements ErpSalesOrganizationServ
|
||||
DO.setName(dataJson.getString("VTEXT"));
|
||||
DO.setNumber(number);
|
||||
DO.setCompanyNumber(dataJson.getString("BUKRS"));
|
||||
if (numbers.get(number)!=null) {
|
||||
if (numbers.get(number) != null) {
|
||||
// 更新
|
||||
DO.setId(numbers.get(number));
|
||||
toUpdate.add(DO);
|
||||
@@ -184,7 +178,7 @@ public class ErpSalesOrganizationServiceImpl implements ErpSalesOrganizationServ
|
||||
// 新增
|
||||
toInsert.add(DO);
|
||||
}
|
||||
dataArrayNumbers.add( number);
|
||||
dataArrayNumbers.add(number);
|
||||
}
|
||||
}
|
||||
// 过滤出numbers中有,但dataArray中KOSTL没有的记录,即为需要删除的数据
|
||||
@@ -194,7 +188,7 @@ public class ErpSalesOrganizationServiceImpl implements ErpSalesOrganizationServ
|
||||
deleteNumbers.add(number);
|
||||
}
|
||||
}
|
||||
return new ProcessingResult(toUpdate, toInsert,key,deleteNumbers);
|
||||
return new ProcessingResult(toUpdate, toInsert, key, deleteNumbers);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,7 +208,7 @@ public class ErpSalesOrganizationServiceImpl implements ErpSalesOrganizationServ
|
||||
);
|
||||
Map<String, Long> numberIdMap = insertedRecords.stream()
|
||||
.collect(Collectors.toMap(ErpSalesOrganizationDO::getNumber, ErpSalesOrganizationDO::getId));
|
||||
myRedisConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
myRedisConfig.addRedisCacheMap(result.key, numberIdMap);
|
||||
}
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpSalesOrganizationMapper.updateBatch(result.toUpdate);
|
||||
@@ -235,7 +229,7 @@ public class ErpSalesOrganizationServiceImpl implements ErpSalesOrganizationServ
|
||||
private final String key;
|
||||
private final List<String> deleteNumbers;
|
||||
|
||||
public ProcessingResult(List<ErpSalesOrganizationDO> toUpdate, List<ErpSalesOrganizationDO> toInsert,String key,List<String> deleteNumbers) {
|
||||
public ProcessingResult(List<ErpSalesOrganizationDO> toUpdate, List<ErpSalesOrganizationDO> toInsert, String key, List<String> deleteNumbers) {
|
||||
this.toUpdate = toUpdate;
|
||||
this.toInsert = toInsert;
|
||||
this.key = key;
|
||||
|
||||
@@ -169,54 +169,48 @@ public class ErpWarehouseServiceImpl implements ErpWarehouseService {
|
||||
@Transactional
|
||||
@XxlJob("getErpWarehouseTask")
|
||||
public void callErpRfcInterface() {
|
||||
try {
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.库位信息;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String factKey = "erpMap" + OftenEnum.FuncnrEnum.工厂信息.getFuncnr();
|
||||
Map<String, Long> redisCache = myRedisConfig.getRedisCacheMap(factKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
throw exception(ERP_FACTORY_NOT_EXISTS);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (String number : redisCache.keySet()) {
|
||||
req.put("WERKS", number);
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
// 往每个子项中添加BUKRS字段
|
||||
for (int j = 0; j < dataArray.size(); j++) {
|
||||
JSONObject item = dataArray.getJSONObject(j);
|
||||
if (item != null) {
|
||||
item.put("WERKS", number);
|
||||
}
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (dataArrayALL.isEmpty()) {
|
||||
throw exception(ERP_WAREHOUSE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("调用ERP RFC接口失败: {}", e);
|
||||
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.库位信息;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String factKey = "erpMap" + OftenEnum.FuncnrEnum.工厂信息.getFuncnr();
|
||||
Map<String, Long> redisCache = myRedisConfig.getRedisCacheMap(factKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
throw exception(ERP_FACTORY_NOT_EXISTS);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (String number : redisCache.keySet()) {
|
||||
req.put("WERKS", number);
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
// 往每个子项中添加BUKRS字段
|
||||
for (int j = 0; j < dataArray.size(); j++) {
|
||||
JSONObject item = dataArray.getJSONObject(j);
|
||||
if (item != null) {
|
||||
item.put("WERKS", number);
|
||||
}
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (dataArrayALL.isEmpty()) {
|
||||
throw exception(ERP_WAREHOUSE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user