|
@@ -1927,7 +1927,7 @@ public R<Boolean> copyContractTreeNode(@RequestBody CopyContractTreeNodeVO vo) {
|
|
|
List<String> keySet = new LinkedList<>();
|
|
|
for (Map.Entry<String, Object> entry : resultMap.entrySet()) {
|
|
|
keySet.add(entry.getKey());
|
|
|
- Object value = reviseValue(eMap, entry.getKey(), entry.getValue());
|
|
|
+ Object value = reviseValue(eMap, entry.getKey(), entry.getValue(), nodeOld.getPKeyId());
|
|
|
if (value != null) {
|
|
|
if (value.toString().contains("\n")) {
|
|
|
value = value.toString().replace("\n", "\\n");
|
|
@@ -2369,10 +2369,49 @@ private Object reviseValue(Map<String, String> p2, String key, Object value) {
|
|
|
}
|
|
|
return value;
|
|
|
}
|
|
|
+ private Object reviseValue(Map<String, String> p2, String key, Object value, Long pKeyId) {
|
|
|
+ try {
|
|
|
+ if (p2.containsKey(key)) {
|
|
|
+ String setting = p2.get(key);
|
|
|
+ if (StringPool.NULL.equals(setting)) {
|
|
|
+ /*擦除原来的内容*/
|
|
|
+ return setting;
|
|
|
+ } else {
|
|
|
+ /*重做随机值*/
|
|
|
+ List<RangeJson> rjs = JSON.parseArray(setting, RangeJson.class);
|
|
|
+ if (value != null && !value.toString().isEmpty() && Func.isNotEmpty(rjs)) {
|
|
|
+ List<RangeJson> rangeJsons = rjs.stream().filter(rj -> rj.getPkeyId().equals(pKeyId)).collect(Collectors.toList());
|
|
|
+ if (!rangeJsons.isEmpty()) {
|
|
|
+ List<String[]> la = Arrays.stream(value.toString().split("☆")).map(s -> s.split("_\\^_")).collect(Collectors.toList());
|
|
|
+ /*全部为一个数的时候不用修改*/
|
|
|
+ if (la.stream().map(a -> a[0]).collect(Collectors.toSet()).size() > 1 || la.size() == 1) {
|
|
|
+ List<String> result = new ArrayList<>();
|
|
|
+ for (String[] a : la) {
|
|
|
+ String v = a[0];
|
|
|
+ String sv;
|
|
|
+ if (v.contains("、")) {
|
|
|
+ sv = Arrays.stream(v.split("[、]")).map(e -> imitate(e, rangeJsons)).collect(Collectors.joining("、"));
|
|
|
+ } else {
|
|
|
+ sv = imitate(v, rangeJsons);
|
|
|
+ }
|
|
|
+ result.add(sv + "_^_" + a[1]);
|
|
|
+ }
|
|
|
+ return String.join("☆", result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return value;
|
|
|
+ }
|
|
|
|
|
|
public String imitate(String v, List<RangeJson> rjs) {
|
|
|
try {
|
|
|
- RangeJson best = rjs.stream().min(Comparator.comparingDouble(j -> Double.parseDouble(v) - Double.parseDouble(j.getDesign()))).orElse(rjs.get(0));
|
|
|
+ RangeJson best = rjs.stream().filter(j -> BaseUtils.isNotEmpty(j.getDesign()))
|
|
|
+ .peek(j -> j.setDesign(j.getDesign().split("/")[0])).min(Comparator.comparingDouble(j -> Double.parseDouble(v) - Double.parseDouble(j.getDesign()))).orElse(rjs.get(0));
|
|
|
// int scale = Math.max(new StringBuilder(v).reverse().indexOf("."), 0);
|
|
|
int scale = BaseUtils.getScaleZero(v, best.getDev(), best.getDesign());
|
|
|
return BaseUtils.rangeList(1, best.getDesign(), best.getDev(), 1, scale, 1).get(0).toString();
|
|
@@ -2394,7 +2433,8 @@ private String reviseCols(Map<String, String> p2, String cols, Long pkeyId, Stri
|
|
|
List<String> colsList = target.stream().filter(k -> k.startsWith("key")).collect(Collectors.toList());
|
|
|
for (String k : colsList) {
|
|
|
if (p2.containsKey(k)) {
|
|
|
- Object value = reviseValue(p2, k, origin.get(k));
|
|
|
+// Object value = reviseValue(p2, k, origin.get(k));
|
|
|
+ Object value = reviseValue(p2, k, origin.get(k), pkeyId);
|
|
|
if (value != null) {
|
|
|
if (value.toString().contains("_^_")) {
|
|
|
value = "'" + value + "'";
|
|
@@ -2542,7 +2582,16 @@ private void addCopyTabData(WbsTreeContract needCopyNode, WbsTreeContract toCopy
|
|
|
String tableName = needTab.getInitTableName();
|
|
|
String col = nodeTabColsMap.get(tableName);
|
|
|
String colVal = nodeTabColsMap.get(tableName);
|
|
|
- colVal = colVal.replaceAll("id,p_key_id,", "'" + SnowFlakeUtil.getId() + "' as id,'" + toCopyNodeTab.getPKeyId() + "' as p_key_id,");
|
|
|
+ String[] split = colVal.split(",");
|
|
|
+ for (int i = 0; i < split.length; i++) {
|
|
|
+ String key = split[i];
|
|
|
+ if (key.equals("id")) {
|
|
|
+ split[i] = "'" + SnowFlakeUtil.getId() + "' as id";
|
|
|
+ } else if (key.equals("p_key_id")) {
|
|
|
+ split[i] = "'" + toCopyNodeTab.getPKeyId() + "' as p_key_id";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ colVal = String.join(",", split);
|
|
|
//delete SQL (先删除旧数据,再新增)
|
|
|
String delSql = "delete from " + tableName + " where p_key_id = " + toCopyNodeTab.getPKeyId() + " ; ";
|
|
|
//insert into SQL
|
|
@@ -2591,7 +2640,16 @@ private void addCopyTabData(WbsTreeContract needCopyNode, WbsTreeContract toCopy
|
|
|
String tableName = objTab.getInitTableName();
|
|
|
String col = nodeTabColsMap.get(tableName);
|
|
|
String colVal = nodeTabColsMap.get(tableName);
|
|
|
- colVal = colVal.replaceAll("id,p_key_id,", "'" + SnowFlakeUtil.getId() + "' as id,'" + objTab.getPKeyId() + "' as p_key_id,");
|
|
|
+ String[] split = colVal.split(",");
|
|
|
+ for (int i = 0; i < split.length; i++) {
|
|
|
+ String key = split[i];
|
|
|
+ if (key.equals("id")) {
|
|
|
+ split[i] = "'" + SnowFlakeUtil.getId() + "' as id";
|
|
|
+ } else if (key.equals("p_key_id")) {
|
|
|
+ split[i] = "'" + objTab.getPKeyId() + "' as p_key_id";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ colVal = String.join(",", split);
|
|
|
//delete SQL (先删除旧数据,再新增)
|
|
|
String delSql = "delete from " + tableName + " where p_key_id = " + objTab.getPKeyId() + " ; ";
|
|
|
//insert into SQL
|
|
@@ -2707,7 +2765,16 @@ private void addCopyNodesAndTabsBuildData(List<WbsTreeContract> addNodeList, Lis
|
|
|
String tableName = obj.getInitTableName();
|
|
|
String col = nodeTabColsMap.get(tableName);
|
|
|
String colVal = nodeTabColsMap.get(tableName);
|
|
|
- colVal = colVal.replaceAll("id,p_key_id,", "'" + SnowFlakeUtil.getId() + "' as id,'" + obj.getPKeyId() + "' as p_key_id,");
|
|
|
+ String[] split = colVal.split(",");
|
|
|
+ for (int i = 0; i < split.length; i++) {
|
|
|
+ String key = split[i];
|
|
|
+ if (key.equals("id")) {
|
|
|
+ split[i] = "'" + SnowFlakeUtil.getId() + "' as id";
|
|
|
+ } else if (key.equals("p_key_id")) {
|
|
|
+ split[i] = "'" + obj.getPKeyId() + "' as p_key_id";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ colVal = String.join(",", split);
|
|
|
//delete SQL (先删除旧数据,再新增)
|
|
|
String delSql = "delete from " + tableName + " where p_key_id = " + obj.getPKeyId() + " ; ";
|
|
|
//insert into SQL
|
|
@@ -2840,7 +2907,16 @@ private void addCopyNodesAndTabsBuildData(List<WbsTreeContract> addNodeList, Lis
|
|
|
StringBuilder copyDataSql = new StringBuilder();
|
|
|
String col = queryProcessDataVO.getAncestors();
|
|
|
String colVal = queryProcessDataVO.getAncestors();
|
|
|
- colVal = colVal.replaceAll("id,p_key_id,", "'" + SnowFlakeUtil.getId() + "' as id,'" + objTab.getPKeyId() + "' as p_key_id,");
|
|
|
+ String[] split = colVal.split(",");
|
|
|
+ for (int i = 0; i < split.length; i++) {
|
|
|
+ String key = split[i];
|
|
|
+ if (key.equals("id")) {
|
|
|
+ split[i] = "'" + SnowFlakeUtil.getId() + "' as id";
|
|
|
+ } else if (key.equals("p_key_id")) {
|
|
|
+ split[i] = "'" + objTab.getPKeyId() + "' as p_key_id";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ colVal = String.join(",", split);
|
|
|
//delete SQL (先删除旧数据,再新增)
|
|
|
String delSql = "delete from " + tableName + " where p_key_id = " + objTab.getPKeyId() + " ; ";
|
|
|
//insert into SQL
|