|
|
@@ -50,7 +50,6 @@ 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;
|
|
|
@@ -101,7 +100,6 @@ public class WbsTreeContractController extends BladeController {
|
|
|
|
|
|
|
|
|
private final ExcelTabController excelTabController;
|
|
|
- private final ExcelTabServiceImpl excelTabServiceImpl;
|
|
|
|
|
|
|
|
|
@GetMapping("/diGuiWbs")
|
|
|
@@ -879,33 +877,18 @@ 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;
|
|
|
}
|
|
|
- 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());
|
|
|
- }
|
|
|
- }
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ Map<String, Object> finalInitId = initId;
|
|
|
entries.forEach(f -> {
|
|
|
//原先是否存在值 是否为☆拼接的多数据
|
|
|
- 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;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ String oldValue = (String) finalInitId.get(f.getKey());
|
|
|
+ if (StringUtils.isNotEmpty(oldValue)) {
|
|
|
//当前keu坐标与数据的对应关系
|
|
|
HashMap<String, String> newCoordinate = new HashMap<>();
|
|
|
//旧数据中需要保留的数据
|
|
|
@@ -933,18 +916,29 @@ public class WbsTreeContractController extends BladeController {
|
|
|
f.setValue(f.getValue() + "☆" + StringUtils.join(oldRetainData, "☆"));
|
|
|
}
|
|
|
}
|
|
|
- finalInitId.put(f.getKey(), f.getValue());
|
|
|
+ if (StringUtils.isNotEmpty(sb.toString())) {
|
|
|
+ sb.append(",");
|
|
|
+ }
|
|
|
+ sb.append(f.getKey()).append("=").append("'").append(f.getValue()).append("'");
|
|
|
});
|
|
|
- StringBuilder stringBuilder = excelTabServiceImpl.buildMTableInsertSql(byId.getInitTableName(), finalInitId, null, null, null);
|
|
|
- sql = stringBuilder.toString();
|
|
|
+ sql = sql + sb + "where id = " + initId.get("id");
|
|
|
} 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();
|
|
|
- StringBuilder stringBuilder = excelTabServiceImpl.buildMTableInsertSql(byId.getInitTableName(), stringStringMap, newPkId, null, wbsTreeContract.getPKeyId());
|
|
|
- sql = stringBuilder.toString();
|
|
|
+ sql = "insert into " + byId.getInitTableName() + " (id,p_key_id," + StringUtils.join(strings, ",") + ") VALUES (" + newPkId + ", " + wbsTreeContract.getPKeyId() + ", " + StringUtils.join(strings1, ",") + ")";
|
|
|
}
|
|
|
|
|
|
- //先删除再添加
|
|
|
- jdbcTemplate.execute("delete from " + byId.getInitTableName() + " where p_key_id = " + wbsTreeContract.getPKeyId());
|
|
|
+
|
|
|
jdbcTemplate.execute(sql);
|
|
|
}
|
|
|
|