|
@@ -11,6 +11,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.UUID;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 规则关联账户 阈值
|
|
* 规则关联账户 阈值
|
|
*
|
|
*
|
|
@@ -50,19 +54,60 @@ public class RuleAccountThresholdServiceImpl extends ServiceImpl<RuleAccountThre
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ Long groupId = groupJson.getLong("groupId");
|
|
|
|
+ Integer isCopy = groupJson.getInteger("isCopy");
|
|
|
|
+
|
|
|
|
+ String batchNo = UUID.randomUUID().toString().replace(" ", "");
|
|
|
|
+
|
|
for (int j = 0; j < ruleDetail.size(); j++) {
|
|
for (int j = 0; j < ruleDetail.size(); j++) {
|
|
- JSONObject ruleJson = ruleDetail.getJSONObject(j);
|
|
|
|
- Long ruleId = ruleJson.getLong("ruleId");
|
|
|
|
- if (Check.isNull(ruleId)) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- String threshold = ruleJson.getString("threshold");
|
|
|
|
- if (Check.isNull(threshold)) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- RuleAccountThreshold updateThreshold = new RuleAccountThreshold();
|
|
|
|
- /*if (threshold.contains("[") && threshold.contains("]")) {
|
|
|
|
- *//* String replace = threshold.replace("[", "").replace("]", "");
|
|
|
|
|
|
+ if (isCopy == 1) { // 规则组可复制
|
|
|
|
+ JSONArray ruleDetailArr = ruleDetail.getJSONArray(i);
|
|
|
|
+ if (Check.isNull(ruleDetailArr)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ Map<String, Object> deleteMap = new HashMap<>();
|
|
|
|
+ deleteMap.put("account_id", accountId);
|
|
|
|
+ deleteMap.put("group_id", groupId);
|
|
|
|
+ ruleAccountThresholdMapper.deleteByMap(deleteMap);
|
|
|
|
+ for (int k = 0; k < ruleDetailArr.size(); k++) {
|
|
|
|
+ JSONObject ruleJson = ruleDetailArr.getJSONObject(k);
|
|
|
|
+ if (Check.isNull(ruleJson)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ Long ruleId = ruleJson.getLong("ruleId");
|
|
|
|
+ if (Check.isNull(ruleId)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ String threshold = ruleJson.getString("threshold");
|
|
|
|
+ if (Check.isNull(threshold)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ RuleAccountThreshold addRuleAccountThreshold = new RuleAccountThreshold();
|
|
|
|
+ addRuleAccountThreshold.setAccountId(accountId);
|
|
|
|
+ addRuleAccountThreshold.setGroupId(groupId);
|
|
|
|
+ addRuleAccountThreshold.setThreshold(threshold);
|
|
|
|
+ addRuleAccountThreshold.setRuleId(ruleId);
|
|
|
|
+ addRuleAccountThreshold.setBatchNo(batchNo);
|
|
|
|
+ int insert = ruleAccountThresholdMapper.insert(addRuleAccountThreshold);
|
|
|
|
+ if (insert > 0) {
|
|
|
|
+ updateCount += 1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (isCopy == 0) {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ JSONObject ruleJson = ruleDetail.getJSONObject(j);
|
|
|
|
+ Long ruleId = ruleJson.getLong("ruleId");
|
|
|
|
+ if (Check.isNull(ruleId)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ String threshold = ruleJson.getString("threshold");
|
|
|
|
+ if (Check.isNull(threshold)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ RuleAccountThreshold updateThreshold = new RuleAccountThreshold();
|
|
|
|
+ /*if (threshold.contains("[") && threshold.contains("]")) {
|
|
|
|
+ *//* String replace = threshold.replace("[", "").replace("]", "");
|
|
List<String> strings = Arrays.asList(replace.split(","));
|
|
List<String> strings = Arrays.asList(replace.split(","));
|
|
JSONArray array = new JSONArray();
|
|
JSONArray array = new JSONArray();
|
|
for (int k = 0; k < strings.size(); k++) {
|
|
for (int k = 0; k < strings.size(); k++) {
|
|
@@ -74,13 +119,14 @@ public class RuleAccountThresholdServiceImpl extends ServiceImpl<RuleAccountThre
|
|
} else {
|
|
} else {
|
|
|
|
|
|
}*/
|
|
}*/
|
|
- updateThreshold.setThreshold(threshold);
|
|
|
|
- QueryWrapper<RuleAccountThreshold> updateQueryWrapper = new QueryWrapper();
|
|
|
|
- updateQueryWrapper.eq("account_id", accountId);
|
|
|
|
- updateQueryWrapper.eq("rule_id", ruleId);
|
|
|
|
- int update = ruleAccountThresholdMapper.update(updateThreshold, updateQueryWrapper);
|
|
|
|
- if (update > 0) {
|
|
|
|
- updateCount += 1;
|
|
|
|
|
|
+ updateThreshold.setThreshold(threshold);
|
|
|
|
+ QueryWrapper<RuleAccountThreshold> updateQueryWrapper = new QueryWrapper();
|
|
|
|
+ updateQueryWrapper.eq("account_id", accountId);
|
|
|
|
+ updateQueryWrapper.eq("rule_id", ruleId);
|
|
|
|
+ int update = ruleAccountThresholdMapper.update(updateThreshold, updateQueryWrapper);
|
|
|
|
+ if (update > 0) {
|
|
|
|
+ updateCount += 1;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|