信用修改
This commit is contained in:
+78
-26
@@ -1665,19 +1665,19 @@ public class UserShipperApplicationService {
|
||||
// 根据查询结果同步数据
|
||||
com.alibaba.fastjson.JSONObject dataJson = resultJson.getJSONObject("data");
|
||||
if (dataJson != null) {
|
||||
// 解析现有的orgCode数组
|
||||
com.alibaba.fastjson.JSONArray orgCodeArray = new com.alibaba.fastjson.JSONArray();
|
||||
if (StringUtils.isNotEmpty(userShipperEntity1.getOrgCode())) {
|
||||
try {
|
||||
orgCodeArray = com.alibaba.fastjson.JSONArray.parseArray(userShipperEntity1.getOrgCode());
|
||||
} catch (Exception e) {
|
||||
log.warn("解析现有orgCode失败,将创建新的数组,shipperId={}", userShipperEntity1.getShipperId());
|
||||
}
|
||||
}
|
||||
|
||||
// 同步额度数据(limitdatas)
|
||||
com.alibaba.fastjson.JSONArray limitdatas = dataJson.getJSONArray("limitdatas");
|
||||
if (limitdatas != null && !limitdatas.isEmpty()) {
|
||||
// 解析现有的orgCode数组
|
||||
com.alibaba.fastjson.JSONArray orgCodeArray = new com.alibaba.fastjson.JSONArray();
|
||||
if (StringUtils.isNotEmpty(userShipperEntity1.getOrgCode())) {
|
||||
try {
|
||||
orgCodeArray = com.alibaba.fastjson.JSONArray.parseArray(userShipperEntity1.getOrgCode());
|
||||
} catch (Exception e) {
|
||||
log.warn("解析现有orgCode失败,将创建新的数组,shipperId={}", userShipperEntity1.getShipperId());
|
||||
}
|
||||
}
|
||||
|
||||
// 将limitdatas按orgcode值合并到orgCode数组中
|
||||
for (int i = 0; i < limitdatas.size(); i++) {
|
||||
com.alibaba.fastjson.JSONObject limitItem = limitdatas.getJSONObject(i);
|
||||
@@ -1711,9 +1711,6 @@ public class UserShipperApplicationService {
|
||||
}
|
||||
}
|
||||
|
||||
// 保存更新后的orgCode数组
|
||||
userShipperEntity1.setOrgCode(orgCodeArray.toJSONString());
|
||||
|
||||
// 使用limitdatas中的数据更新额度字段
|
||||
com.alibaba.fastjson.JSONObject firstLimitData = limitdatas.getJSONObject(0);
|
||||
userShipperEntity1.setLimitTime(new Date());
|
||||
@@ -1737,6 +1734,32 @@ public class UserShipperApplicationService {
|
||||
log.info("第一次循环,删除货主所有协议明细,shipperId={}", userShipperEntity1.getShipperId());
|
||||
}
|
||||
|
||||
// 将agreedaydatas保存到orgCode数组中,与code同一级别
|
||||
String currentOrgCodeStr = String.valueOf(orgCode);
|
||||
boolean foundOrg = false;
|
||||
for (int j = 0; j < orgCodeArray.size(); j++) {
|
||||
com.alibaba.fastjson.JSONObject orgItem = orgCodeArray.getJSONObject(j);
|
||||
String orgItemCode = orgItem.getString("code");
|
||||
|
||||
// 找到当前组织,将agreedaydatas添加到该组织对象中
|
||||
if (currentOrgCodeStr.equals(orgItemCode)) {
|
||||
orgItem.put("agreedaydatas", agreedaydatas);
|
||||
foundOrg = true;
|
||||
log.info("将agreedaydatas添加到code={}的组织中,共{}条", orgItemCode, agreedaydatas.size());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果没找到,创建新组织对象
|
||||
if (!foundOrg) {
|
||||
com.alibaba.fastjson.JSONObject newOrgItem = new com.alibaba.fastjson.JSONObject();
|
||||
newOrgItem.put("code", orgCode);
|
||||
newOrgItem.put("agreedaydatas", agreedaydatas);
|
||||
orgCodeArray.add(newOrgItem);
|
||||
log.info("创建新组织并添加agreedaydatas,code={},共{}条", orgCode, agreedaydatas.size());
|
||||
}
|
||||
|
||||
// 同时插入到agreement_details表
|
||||
for (int i = 0; i < agreedaydatas.size(); i++) {
|
||||
com.alibaba.fastjson.JSONObject agreeItem = agreedaydatas.getJSONObject(i);
|
||||
AgreementDetails agreementDetails = new AgreementDetails();
|
||||
@@ -1754,6 +1777,9 @@ public class UserShipperApplicationService {
|
||||
} else {
|
||||
log.info("赊销额度查询无agreedaydatas返回,跳过协议明细同步,custcode={},orgcode={}", userShipperEntity1.getCustomerNcCode(), orgcode);
|
||||
}
|
||||
|
||||
// 保存更新后的orgCode数组(统一在最后保存)
|
||||
userShipperEntity1.setOrgCode(orgCodeArray.toJSONString());
|
||||
} else {
|
||||
log.info("赊销额度查询无data返回,跳过更新,custcode={},orgcode={}", userShipperEntity1.getCustomerNcCode(), orgcode);
|
||||
}
|
||||
@@ -1905,19 +1931,19 @@ public class UserShipperApplicationService {
|
||||
// 根据查询结果同步数据
|
||||
com.alibaba.fastjson.JSONObject dataJson = resultJson.getJSONObject("data");
|
||||
if (dataJson != null) {
|
||||
// 解析现有的orgCode数组(提到外面,limitdatas和agreedaydatas共用)
|
||||
com.alibaba.fastjson.JSONArray orgCodeArray = new com.alibaba.fastjson.JSONArray();
|
||||
if (StringUtils.isNotEmpty(userShipperEntity1.getOrgCode())) {
|
||||
try {
|
||||
orgCodeArray = com.alibaba.fastjson.JSONArray.parseArray(userShipperEntity1.getOrgCode());
|
||||
} catch (Exception e) {
|
||||
log.warn("解析现有orgCode失败,将创建新的数组,shipperId={}", userShipperEntity1.getShipperId());
|
||||
}
|
||||
}
|
||||
|
||||
// 同步额度数据(limitdatas)
|
||||
com.alibaba.fastjson.JSONArray limitdatas = dataJson.getJSONArray("limitdatas");
|
||||
if (limitdatas != null && !limitdatas.isEmpty()) {
|
||||
// 解析现有的orgCode数组
|
||||
com.alibaba.fastjson.JSONArray orgCodeArray = new com.alibaba.fastjson.JSONArray();
|
||||
if (StringUtils.isNotEmpty(userShipperEntity1.getOrgCode())) {
|
||||
try {
|
||||
orgCodeArray = com.alibaba.fastjson.JSONArray.parseArray(userShipperEntity1.getOrgCode());
|
||||
} catch (Exception e) {
|
||||
log.warn("解析现有orgCode失败,将创建新的数组,shipperId={}", userShipperEntity1.getShipperId());
|
||||
}
|
||||
}
|
||||
|
||||
// 将limitdatas按orgcode值合并到orgCode数组中
|
||||
for (int i = 0; i < limitdatas.size(); i++) {
|
||||
com.alibaba.fastjson.JSONObject limitItem = limitdatas.getJSONObject(i);
|
||||
@@ -1951,9 +1977,6 @@ public class UserShipperApplicationService {
|
||||
}
|
||||
}
|
||||
|
||||
// 保存更新后的orgCode数组
|
||||
userShipperEntity1.setOrgCode(orgCodeArray.toJSONString());
|
||||
|
||||
// 使用limitdatas中的数据更新额度字段
|
||||
com.alibaba.fastjson.JSONObject firstLimitData = limitdatas.getJSONObject(0);
|
||||
userShipperEntity1.setLimitTime(new Date());
|
||||
@@ -1977,6 +2000,32 @@ public class UserShipperApplicationService {
|
||||
log.info("第一次循环,删除货主所有协议明细,shipperId={}", userShipperEntity1.getShipperId());
|
||||
}
|
||||
|
||||
// 将agreedaydatas保存到orgCode数组中,与code同一级别
|
||||
String currentOrgCodeStr = String.valueOf(orgCode);
|
||||
boolean foundOrg = false;
|
||||
for (int j = 0; j < orgCodeArray.size(); j++) {
|
||||
com.alibaba.fastjson.JSONObject orgItem = orgCodeArray.getJSONObject(j);
|
||||
String orgItemCode = orgItem.getString("code");
|
||||
|
||||
// 找到当前组织,将agreedaydatas添加到该组织对象中
|
||||
if (currentOrgCodeStr.equals(orgItemCode)) {
|
||||
orgItem.put("agreedaydatas", agreedaydatas);
|
||||
foundOrg = true;
|
||||
log.info("将agreedaydatas添加到code={}的组织中,共{}条", orgItemCode, agreedaydatas.size());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果没找到,创建新组织对象
|
||||
if (!foundOrg) {
|
||||
com.alibaba.fastjson.JSONObject newOrgItem = new com.alibaba.fastjson.JSONObject();
|
||||
newOrgItem.put("code", orgCode);
|
||||
newOrgItem.put("agreedaydatas", agreedaydatas);
|
||||
orgCodeArray.add(newOrgItem);
|
||||
log.info("创建新组织并添加agreedaydatas,code={},共{}条", orgCode, agreedaydatas.size());
|
||||
}
|
||||
|
||||
// 同时插入到agreement_details表
|
||||
for (int i = 0; i < agreedaydatas.size(); i++) {
|
||||
com.alibaba.fastjson.JSONObject agreeItem = agreedaydatas.getJSONObject(i);
|
||||
AgreementDetails agreementDetails = new AgreementDetails();
|
||||
@@ -1994,6 +2043,9 @@ public class UserShipperApplicationService {
|
||||
} else {
|
||||
log.info("赊销额度查询无agreedaydatas返回,跳过协议明细同步,custcode={},orgcode={}", userShipperEntity1.getCustomerNcCode(), orgcode);
|
||||
}
|
||||
|
||||
// 保存更新后的orgCode数组(统一在最后保存)
|
||||
userShipperEntity1.setOrgCode(orgCodeArray.toJSONString());
|
||||
} else {
|
||||
log.info("赊销额度查询无data返回,跳过更新,custcode={},orgcode={}", userShipperEntity1.getCustomerNcCode(), orgcode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user