客商erp更新优化
This commit is contained in:
@@ -25,7 +25,7 @@ public interface ErrorCodeConstants {
|
||||
|
||||
|
||||
ErrorCode BUSINESS_RULE_NOT_EXISTS = new ErrorCode(1_027_100_001, "规则模型不存在");
|
||||
ErrorCode BUSINESS_ALGORITHM_NOT_EXISTS = new ErrorCode(1_027_100_002, "算法模型不存在");
|
||||
ErrorCode BUSINESS_ALGORITHM_NOT_EXISTS = new ErrorCode(1_027_100_002, "算法模型不存在");
|
||||
ErrorCode BUSINESS_DIMENSION_NOT_EXISTS = new ErrorCode(1_027_200_001, "经营指标维度不存在");
|
||||
ErrorCode BUSINESS_INDICATOR_NOT_EXISTS = new ErrorCode(1_027_200_002, "经营指标不存在");
|
||||
ErrorCode BUSINESS_DICTIONARY_TYPE_NOT_EXISTS = new ErrorCode(1_027_200_003, "业务字典类型不存在");
|
||||
|
||||
@@ -119,44 +119,93 @@ public class ErpCustomerServiceImpl implements ErpCustomerService {
|
||||
initialize(key);
|
||||
}
|
||||
//循环近五年日期,
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
LocalDate endDate = LocalDate.now();
|
||||
LocalDate startDate = endDate.minusYears(5);
|
||||
for (LocalDate date = startDate; !date.isAfter(endDate); date = date.plusDays(1)) {
|
||||
// 构建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", date.toString());
|
||||
datumList.add(datumEntry);
|
||||
req.put(funcnrEnum.getDatekey(), datumList);
|
||||
// JSONArray dataArrayALL = new JSONArray();
|
||||
// LocalDate endDate = LocalDate.now();
|
||||
// LocalDate startDate = endDate.minusYears(5);
|
||||
// for (LocalDate date = startDate; !date.isAfter(endDate); date = date.plusDays(1)) {
|
||||
// 构建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接口获取数据
|
||||
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()) {
|
||||
// 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 (dataArray.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 处理数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
ProcessingResult result = processData(dataArray, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
}
|
||||
|
||||
|
||||
// @Override
|
||||
// @Transactional
|
||||
// @XxlJob("getErpCustomerTask")
|
||||
// public void callErpRfcInterface() {
|
||||
// OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.客商信息;
|
||||
// String funcnr = funcnrEnum.getFuncnr();
|
||||
//
|
||||
// String key = "erp" + funcnrEnum.getFuncnr();
|
||||
// List<String> allnumbers = myRedisConfig.getRedisCache(key);
|
||||
// List<String> numbers = null;
|
||||
// if (allnumbers != null) {
|
||||
// //取前100的数据
|
||||
// numbers = allnumbers.stream().limit(100).collect(Collectors.toList());
|
||||
// JSONArray dataArrayALL = new JSONArray();
|
||||
// //循环近五年日期,
|
||||
// for (String number : numbers) {
|
||||
// // 构建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", number);
|
||||
// datumList.add(datumEntry);
|
||||
// req.put("PARTNER", datumList);
|
||||
//
|
||||
// // 1. 调用ERP接口获取数据
|
||||
// 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("E_RESP");
|
||||
// if (dataArray == null || dataArray.isEmpty()) {
|
||||
// continue;
|
||||
// }
|
||||
// dataArrayALL.addAll(dataArray);
|
||||
// }
|
||||
// }
|
||||
// if (dataArrayALL.isEmpty()) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// // 2. 处理数据,区分新增和更新
|
||||
// ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
//
|
||||
// // 3. 批量保存数据
|
||||
// saveData(result);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 处理数据,区分新增和更新
|
||||
*/
|
||||
@@ -171,7 +220,7 @@ 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(funcnr.getDatakey());
|
||||
String number = dataJson.getString("PARTNER");
|
||||
if (number != null) {
|
||||
number = number.trim();
|
||||
}
|
||||
@@ -191,7 +240,7 @@ public class ErpCustomerServiceImpl implements ErpCustomerService {
|
||||
}
|
||||
DO.setIsGiveback(dataJson.getString("XDELE"));
|
||||
DO.setIsProvisional(dataJson.getString("XBLCK"));
|
||||
DO.setTaxNumber(dataJson.getString("TAXNO"));
|
||||
DO.setTaxNumber(dataJson.getString("TAXNUM"));
|
||||
|
||||
if (comnumbers.contains(number)) {
|
||||
// 更新
|
||||
@@ -217,7 +266,7 @@ public class ErpCustomerServiceImpl implements ErpCustomerService {
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpCustomerMapper.updateBatchByNumber(result.toUpdate);
|
||||
}
|
||||
myRedisConfig.updateRedisCache(result.key, result.allnumbers);
|
||||
// myRedisConfig.updateRedisCache(result.key, result.allnumbers);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<if test="item.isProvisional != null">IS_PRVS = #{item.isProvisional},</if>
|
||||
<if test="item.taxNumber != null">TAX_NUM = #{item.taxNumber},</if>
|
||||
</set>
|
||||
WHERE NUM = #{item.downCenterNumber}
|
||||
WHERE NUM = #{item.number}
|
||||
</foreach>
|
||||
</update>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user