|
|
@@ -50,6 +50,7 @@ import org.springblade.manager.service.INodeBaseInfoService;
|
|
|
import org.springblade.manager.service.IWbsParamService;
|
|
|
import org.springblade.manager.service.IWbsTreeContractService;
|
|
|
import org.springblade.manager.service.IWbsTreePrivateService;
|
|
|
+import org.springblade.manager.service.impl.ExcelTabServiceImpl;
|
|
|
import org.springblade.manager.service.impl.NodeBaseInfoServiceImpl;
|
|
|
import org.springblade.manager.service.impl.WbsTreeContractServiceImpl;
|
|
|
import org.springblade.manager.utils.FileUtils;
|
|
|
@@ -100,6 +101,7 @@ public class WbsTreeContractController extends BladeController {
|
|
|
|
|
|
|
|
|
private final ExcelTabController excelTabController;
|
|
|
+ private final ExcelTabServiceImpl excelTabServiceImpl;
|
|
|
|
|
|
|
|
|
@GetMapping("/diGuiWbs")
|
|
|
@@ -877,18 +879,33 @@ public class WbsTreeContractController extends BladeController {
|
|
|
}
|
|
|
String sql = null;
|
|
|
if (initId != null) {
|
|
|
- sql = "update " + byId.getInitTableName() + " set ";
|
|
|
//导入的数据
|
|
|
Set<Map.Entry<String, String>> entries = stringStringMap.entrySet();
|
|
|
if(entries.isEmpty()){
|
|
|
continue;
|
|
|
}
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
- Map<String, Object> finalInitId = initId;
|
|
|
+ Map<String, String> finalInitId = new HashMap<>();
|
|
|
+ for (Map.Entry<String, Object> entry : initId.entrySet()) {
|
|
|
+ if (entry.getValue() != null) {
|
|
|
+ finalInitId.put(entry.getKey(), entry.getValue().toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
entries.forEach(f -> {
|
|
|
//原先是否存在值 是否为☆拼接的多数据
|
|
|
- String oldValue = (String) finalInitId.get(f.getKey());
|
|
|
- if (StringUtils.isNotEmpty(oldValue)) {
|
|
|
+ String oldValue = finalInitId.get(f.getKey());
|
|
|
+ //key_201是否存在值
|
|
|
+ String key201 = finalInitId.get("key_201");
|
|
|
+ if (StringUtils.isNotEmpty(oldValue) || (StringUtils.isNotEmpty(key201) && key201.contains(f.getKey()))) {
|
|
|
+ if(StringUtils.isEmpty(oldValue)){
|
|
|
+ String[] split = key201.split("\\$\\$");
|
|
|
+ for (String s : split) {
|
|
|
+ if(s.contains(f.getKey())){
|
|
|
+ oldValue = s.split(":")[1];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//当前keu坐标与数据的对应关系
|
|
|
HashMap<String, String> newCoordinate = new HashMap<>();
|
|
|
//旧数据中需要保留的数据
|
|
|
@@ -916,29 +933,18 @@ public class WbsTreeContractController extends BladeController {
|
|
|
f.setValue(f.getValue() + "☆" + StringUtils.join(oldRetainData, "☆"));
|
|
|
}
|
|
|
}
|
|
|
- if (StringUtils.isNotEmpty(sb.toString())) {
|
|
|
- sb.append(",");
|
|
|
- }
|
|
|
- sb.append(f.getKey()).append("=").append("'").append(f.getValue()).append("'");
|
|
|
+ finalInitId.put(f.getKey(), f.getValue());
|
|
|
});
|
|
|
- sql = sql + sb + "where id = " + initId.get("id");
|
|
|
+ StringBuilder stringBuilder = excelTabServiceImpl.buildMTableInsertSql(byId.getInitTableName(), finalInitId, null, null, null);
|
|
|
+ sql = stringBuilder.toString();
|
|
|
} else {
|
|
|
- Set<String> strings = stringStringMap.keySet();
|
|
|
- if(strings.isEmpty()){
|
|
|
- continue;
|
|
|
- }
|
|
|
- Collection<String> values = stringStringMap.values();
|
|
|
- //转换成sql能够使用的字符串
|
|
|
- ArrayList<String> strings1 = new ArrayList<>();
|
|
|
- values.forEach(f -> {
|
|
|
- f = "'" + f + "'";
|
|
|
- strings1.add(f);
|
|
|
- });
|
|
|
long newPkId = SnowFlakeUtil.getId();
|
|
|
- sql = "insert into " + byId.getInitTableName() + " (id,p_key_id," + StringUtils.join(strings, ",") + ") VALUES (" + newPkId + ", " + wbsTreeContract.getPKeyId() + ", " + StringUtils.join(strings1, ",") + ")";
|
|
|
+ StringBuilder stringBuilder = excelTabServiceImpl.buildMTableInsertSql(byId.getInitTableName(), stringStringMap, newPkId, null, wbsTreeContract.getPKeyId());
|
|
|
+ sql = stringBuilder.toString();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ //先删除再添加
|
|
|
+ jdbcTemplate.execute("delete from " + byId.getInitTableName() + " where p_key_id = " + wbsTreeContract.getPKeyId());
|
|
|
jdbcTemplate.execute(sql);
|
|
|
}
|
|
|
|