|
@@ -884,6 +884,72 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
public boolean addTabInfoByRan(RangeInfo info, List<Object> moreData, String[] excLenght) throws InterruptedException {
|
|
|
WbsTreeContract wbsInfo = this.baseMapper.selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
.eq(WbsTreeContract::getPKeyId, info.getPkId()));
|
|
|
+ // ,key1=value1,key2=value2
|
|
|
+ StringBuilder update = new StringBuilder();
|
|
|
+ // ,key1,key2
|
|
|
+ StringBuilder insert = new StringBuilder();
|
|
|
+ // ,value1,value2
|
|
|
+ StringBuilder insertValue = new StringBuilder();
|
|
|
+ // ,value1,value2
|
|
|
+ StringBuilder key201Value = new StringBuilder();
|
|
|
+ //解析html
|
|
|
+// if(info.getIsCopyThisData()){
|
|
|
+ List<String> keys = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ String fileUrl = wbsInfo.getHtmlUrl();
|
|
|
+ InputStream fileInputStream = org.springblade.manager.utils.FileUtils.getInputStreamByUrl(fileUrl);
|
|
|
+
|
|
|
+ String htmlString = IoUtil.readToString(fileInputStream);
|
|
|
+ // 样式集合
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
+
|
|
|
+ //获取所有照片
|
|
|
+ Elements selectImgs = doc.select("hc-table-form-upload");
|
|
|
+ for (Element element : selectImgs) {
|
|
|
+ String keyname = element.attr("keyname");
|
|
|
+ keys.add(keyname);
|
|
|
+ }
|
|
|
+ //获取所有日期
|
|
|
+ Elements selectDates = doc.select("el-date-picker");
|
|
|
+ for (Element element : selectDates) {
|
|
|
+ String keyname = element.attr("keyname");
|
|
|
+ keys.add(keyname);
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ String s1 = "select * from " + wbsInfo.getInitTableName() + " where p_key_id= " + wbsInfo.getPKeyId();
|
|
|
+
|
|
|
+ //获取当前表数据
|
|
|
+ List<Map<String, Object>> list = jdbcTemplate.queryForList(s1);
|
|
|
+
|
|
|
+
|
|
|
+ if(CollectionUtil.isNotEmpty(keys) && CollectionUtil.isNotEmpty(list)){
|
|
|
+ Map<String, Object> jsonObject = list.get(0);
|
|
|
+
|
|
|
+ keys.forEach(f -> {
|
|
|
+ String s = f.split("__")[0];
|
|
|
+ String string = (String) jsonObject.get(s);
|
|
|
+
|
|
|
+ //判断当前字段是否超过80 超过就存在key_201中
|
|
|
+ if(isSaveKey201(s)){
|
|
|
+ if(StringUtils.isNotEmpty(key201Value.toString())){
|
|
|
+ key201Value.append("$$");
|
|
|
+ }
|
|
|
+ key201Value.append(s).append(":").append("'").append(string).append("'");
|
|
|
+ } else {
|
|
|
+ update.append(",").append(s).append("=").append("'").append(string).append("'");
|
|
|
+ insert.append(",").append(s);
|
|
|
+ insertValue.append(",").append("'").append(string).append("'");
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+// }
|
|
|
+
|
|
|
|
|
|
String cols = Arrays.stream(excLenght).collect(Collectors.joining(StringPool.COMMA));
|
|
|
//查询复制表有多少张
|
|
@@ -923,24 +989,55 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
boolean flag = isSaveKey201(info, wbsInfo, dataCol);
|
|
|
if (!DataMap.isEmpty()) {
|
|
|
- String updateSql = "update " + wbsInfo.getInitTableName() + " set " + info.getKey() + "=";
|
|
|
- if (flag) {
|
|
|
- updateSql = "update " + wbsInfo.getInitTableName() + " set key_201 = concat(IFNULL(key_201,''),'$$'," + "'" + info.getKey() + ":" + dataCol + "') where p_key_id= " + wbsTreeContract.getPKeyId() + ";";
|
|
|
+ //是否同步数据
|
|
|
+ if(info.getIsCopyThisData()){
|
|
|
+ //如果存在字段大于80的
|
|
|
+ if(StringUtils.isNotEmpty(key201Value.toString())){
|
|
|
+ String updateSql = "update " + wbsInfo.getInitTableName() + " set key_201 = concat(IFNULL(key_201,''),'$$'," + "'" + info.getKey() + ":" + dataCol + "','$$'," + key201Value + ") where p_key_id= " + wbsTreeContract.getPKeyId() + ";";
|
|
|
+ addSql.append(updateSql);
|
|
|
+ }
|
|
|
+ //存在需要更新单独数据
|
|
|
+ if(StringUtils.isNotEmpty(update.toString())){
|
|
|
+ String updateSql = "update " + wbsInfo.getInitTableName() + " set " + info.getKey() + "=" + "'" + dataCol + "'" + update + " where p_key_id=" + wbsTreeContract.getPKeyId() + " ;";
|
|
|
+ addSql.append(updateSql);
|
|
|
+ }
|
|
|
+ moreData = moreData.stream().skip(excLenght.length).map(com.mixsmart.utils.StringUtils::handleNull).collect(Collectors.toList());
|
|
|
} else {
|
|
|
- updateSql = updateSql + "'" + dataCol + "' where p_key_id=" + wbsTreeContract.getPKeyId() + " ;";
|
|
|
+
|
|
|
+ String updateSql = "update " + wbsInfo.getInitTableName() + " set " + info.getKey() + "=";
|
|
|
+ if (flag) {
|
|
|
+ updateSql = "update " + wbsInfo.getInitTableName() + " set key_201 = concat(IFNULL(key_201,''),'$$'," + "'" + info.getKey() + ":" + dataCol + "') where p_key_id= " + wbsTreeContract.getPKeyId() + ";";
|
|
|
+ } else {
|
|
|
+ updateSql = updateSql + "'" + dataCol + "' where p_key_id=" + wbsTreeContract.getPKeyId() + " ;";
|
|
|
+ }
|
|
|
+ moreData = moreData.stream().skip(excLenght.length).map(com.mixsmart.utils.StringUtils::handleNull).collect(Collectors.toList());
|
|
|
+ addSql.append(updateSql);
|
|
|
}
|
|
|
- moreData = moreData.stream().skip(excLenght.length).map(com.mixsmart.utils.StringUtils::handleNull).collect(Collectors.toList());
|
|
|
- addSql.append(updateSql);
|
|
|
} else {
|
|
|
long dataId = SnowFlakeUtil.getId();
|
|
|
- String insertSql = "insert into " + wbsInfo.getInitTableName() + "(id,p_key_id," + info.getKey() + ") VALUES (" + dataId + "," + wbsTreeContract.getPKeyId() + ",'";
|
|
|
- if (flag) {
|
|
|
- insertSql = "insert into " + wbsInfo.getInitTableName() + "(id,p_key_id,key_201) values (" + dataId + "," + wbsTreeContract.getPKeyId() + ",'" + info.getKey() + ":" + dataCol + "');";
|
|
|
- } else {
|
|
|
- insertSql = insertSql + dataCol + "');";
|
|
|
+ //是否同步数据
|
|
|
+ if(info.getIsCopyThisData()){
|
|
|
+ //如果存在字段大于80的
|
|
|
+ if(StringUtils.isNotEmpty(key201Value.toString())){
|
|
|
+ String insertSql = "insert into " + wbsInfo.getInitTableName() + "(id,p_key_id,key_201) values (" + dataId + "," + wbsTreeContract.getPKeyId() + ",concat('" + info.getKey() + ":" + dataCol + "','$$'," + key201Value + "));";
|
|
|
+ addSql.append(insertSql);
|
|
|
+ }
|
|
|
+ //存在需要更新单独数据
|
|
|
+ if(StringUtils.isNotEmpty(insert.toString()) && StringUtils.isNotEmpty(insertValue.toString()) ){
|
|
|
+ String insertSql = "insert into " + wbsInfo.getInitTableName() + "(id,p_key_id," + info.getKey() + insert + ") VALUES (" + dataId + "," + wbsTreeContract.getPKeyId() + ",'" + dataCol + "'" + insertValue + ");";
|
|
|
+ addSql.append(insertSql);
|
|
|
+ }
|
|
|
+ moreData = moreData.stream().skip(excLenght.length).map(com.mixsmart.utils.StringUtils::handleNull).collect(Collectors.toList());
|
|
|
+ }else{
|
|
|
+ String insertSql = "insert into " + wbsInfo.getInitTableName() + "(id,p_key_id," + info.getKey() + ") VALUES (" + dataId + "," + wbsTreeContract.getPKeyId() + ",'";
|
|
|
+ if (flag) {
|
|
|
+ insertSql = "insert into " + wbsInfo.getInitTableName() + "(id,p_key_id,key_201) values (" + dataId + "," + wbsTreeContract.getPKeyId() + ",'" + info.getKey() + ":" + dataCol + "');";
|
|
|
+ } else {
|
|
|
+ insertSql = insertSql + dataCol + "');";
|
|
|
+ }
|
|
|
+ moreData = moreData.stream().skip(excLenght.length).map(com.mixsmart.utils.StringUtils::handleNull).collect(Collectors.toList());
|
|
|
+ addSql.append(insertSql);
|
|
|
}
|
|
|
- moreData = moreData.stream().skip(excLenght.length).map(com.mixsmart.utils.StringUtils::handleNull).collect(Collectors.toList());
|
|
|
- addSql.append(insertSql);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -994,7 +1091,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
dataSize = moreData.size();
|
|
|
}
|
|
|
long dataId = SnowFlakeUtil.getId();
|
|
|
- String insertSql = "insert into " + wbsInfo.getInitTableName() + "(id,p_key_id," + info.getKey() + ") VALUES (" + dataId + "," + wbsTreeContract.getPKeyId() + ",'";
|
|
|
String dataCol = "";
|
|
|
for (int j = 0; j < dataSize; j++) {
|
|
|
if (j == dataSize - 1) {
|
|
@@ -1003,13 +1099,30 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
dataCol = dataCol + moreData.get(j) + "_^_" + excLenght[j] + "☆";
|
|
|
}
|
|
|
}
|
|
|
- if (isSaveKey201(info, wbsInfo, dataCol)) {
|
|
|
- insertSql = "insert into " + wbsInfo.getInitTableName() + "(id,p_key_id,key_201) values (" + dataId + "," + wbsTreeContract.getPKeyId() + ",'" + info.getKey() + ":" + dataCol + "');";
|
|
|
- } else {
|
|
|
- insertSql = insertSql + dataCol + "');";
|
|
|
+
|
|
|
+ //是否同步数据
|
|
|
+ if(info.getIsCopyThisData()){
|
|
|
+ //如果存在字段大于80的
|
|
|
+ if(StringUtils.isNotEmpty(key201Value.toString())){
|
|
|
+ String insertSql = "insert into " + wbsInfo.getInitTableName() + "(id,p_key_id,key_201) values (" + dataId + "," + wbsTreeContract.getPKeyId() + ",concat('" + info.getKey() + ":" + dataCol + "','$$'," + key201Value + "));";
|
|
|
+ addSql.append(insertSql);
|
|
|
+ }
|
|
|
+ //存在需要更新单独数据
|
|
|
+ if(StringUtils.isNotEmpty(insert.toString()) && StringUtils.isNotEmpty(insertValue.toString()) ){
|
|
|
+ String insertSql = "insert into " + wbsInfo.getInitTableName() + "(id,p_key_id," + info.getKey() + insert + ") VALUES (" + dataId + "," + wbsTreeContract.getPKeyId() + ",'" + dataCol + "'" + insertValue + ");";
|
|
|
+ addSql.append(insertSql);
|
|
|
+ }
|
|
|
+ moreData = moreData.stream().skip(excLenght.length).map(com.mixsmart.utils.StringUtils::handleNull).collect(Collectors.toList());
|
|
|
+ }else{
|
|
|
+ String insertSql = "insert into " + wbsInfo.getInitTableName() + "(id,p_key_id," + info.getKey() + ") VALUES (" + dataId + "," + wbsTreeContract.getPKeyId() + ",'";
|
|
|
+ if (isSaveKey201(info, wbsInfo, dataCol)) {
|
|
|
+ insertSql = "insert into " + wbsInfo.getInitTableName() + "(id,p_key_id,key_201) values (" + dataId + "," + wbsTreeContract.getPKeyId() + ",'" + info.getKey() + ":" + dataCol + "');";
|
|
|
+ } else {
|
|
|
+ insertSql = insertSql + dataCol + "');";
|
|
|
+ }
|
|
|
+ moreData = moreData.stream().skip(excLenght.length).map(com.mixsmart.utils.StringUtils::handleNull).collect(Collectors.toList());
|
|
|
+ addSql.append(insertSql);
|
|
|
}
|
|
|
- moreData = moreData.stream().skip(excLenght.length).map(com.mixsmart.utils.StringUtils::handleNull).collect(Collectors.toList());
|
|
|
- addSql.append(insertSql);
|
|
|
}
|
|
|
// 插入数据
|
|
|
this.baseMapper.insertBatchSomeColumn(addList);
|
|
@@ -1026,6 +1139,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private boolean isSaveKey201(RangeInfo info, WbsTreeContract wbsInfo, String dataCol) {
|
|
|
boolean flag = false;
|
|
|
try {
|
|
@@ -1051,6 +1165,22 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
return flag;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 判断字段是否超过80
|
|
|
+ * @param key
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private boolean isSaveKey201(String key) {
|
|
|
+ boolean flag = false;
|
|
|
+ try {
|
|
|
+ String[] split = key.split("_");
|
|
|
+ flag = split.length > 1 && StringUtil.isNumeric(split[1]) && Integer.parseInt(split[1]) > 80;
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
@Override
|
|
|
public void syncCurrentFormToAllContract(WbsTreePrivate wbsTreePrivate) {
|
|
|
baseMapper.syncCurrentFormToAllContract(wbsTreePrivate);
|