|
@@ -7,18 +7,27 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import jodd.util.ArraysUtil;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.jsoup.Jsoup;
|
|
|
import org.jsoup.nodes.Document;
|
|
|
+import org.jsoup.nodes.Element;
|
|
|
+import org.jsoup.select.Elements;
|
|
|
import org.springblade.business.entity.ConstructionLedger;
|
|
|
import org.springblade.business.feign.ConstructionLedgerFeignClient;
|
|
|
import org.springblade.business.feign.InformationQueryClient;
|
|
|
+import org.springblade.business.vo.QueryProcessDataVO;
|
|
|
+import org.springblade.common.constant.CommonConstant;
|
|
|
+import org.springblade.common.utils.CommonUtil;
|
|
|
import org.springblade.common.utils.FileUtils;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.node.ForestNodeMerger;
|
|
|
import org.springblade.core.tool.utils.*;
|
|
|
import org.springblade.manager.dto.RangeInfo;
|
|
@@ -33,16 +42,15 @@ import org.springblade.manager.mapper.WbsTreePrivateMapper;
|
|
|
import org.springblade.manager.service.IWbsTreeContractService;
|
|
|
import org.springblade.manager.utils.DiffListUtil;
|
|
|
import org.springblade.manager.vo.*;
|
|
|
+import org.springblade.system.cache.ParamCache;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.LinkedCaseInsensitiveMap;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
-import java.io.File;
|
|
|
-import java.io.FileInputStream;
|
|
|
-import java.io.FileNotFoundException;
|
|
|
-import java.io.IOException;
|
|
|
+import java.io.*;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.regex.Matcher;
|
|
@@ -539,24 +547,27 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void syncCurrentFormInProject(Long pKeyId) {
|
|
|
- WbsTreeContract node = this.getOne(new LambdaQueryWrapper<WbsTreeContract>().eq(WbsTreeContract::getPKeyId, pKeyId));
|
|
|
- baseMapper.syncCurrentFormInProject(node);
|
|
|
+ public void syncCurrentFormToAllContract(WbsTreePrivate wbsTreePrivate) {
|
|
|
+ baseMapper.syncCurrentFormToAllContract(wbsTreePrivate);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean syncTabData(String pKeyId) {
|
|
|
+ public boolean syncTabData(String pKeyId) throws Exception {
|
|
|
WbsTreeContract node = baseMapper.selectOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, pKeyId));
|
|
|
if (node != null) {
|
|
|
+ //表maps
|
|
|
+ Map<String, String> sgTabMaps = new LinkedHashMap<>();
|
|
|
+ Map<String, String> jlTabMaps = new LinkedHashMap<>();
|
|
|
+
|
|
|
List<WbsTreeContract> tabs = baseMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getParentId, node.getId())
|
|
|
- .select(WbsTreeContract::getNodeName, WbsTreeContract::getTableOwner, WbsTreeContract::getPKeyId, WbsTreeContract::getInitTableName, WbsTreeContract::getSort, WbsTreeContract::getFullName, WbsTreeContract::getUpdateTime, WbsTreeContract::getOldId)
|
|
|
+ .select(WbsTreeContract::getNodeName, WbsTreeContract::getTableOwner, WbsTreeContract::getPKeyId, WbsTreeContract::getInitTableName, WbsTreeContract::getSort, WbsTreeContract::getFullName, WbsTreeContract::getUpdateTime)
|
|
|
.eq(WbsTreeContract::getContractId, node.getContractId()).eq(WbsTreeContract::getType, 2)
|
|
|
.eq(WbsTreeContract::getWbsId, node.getWbsId()).eq(WbsTreeContract::getWbsType, node.getWbsType())
|
|
|
.eq(WbsTreeContract::getStatus, 1));
|
|
|
|
|
|
+ //初始化表
|
|
|
List<WbsTreeContract> sgTab = tabs.stream().filter(f -> "1,2,3".contains(f.getTableOwner())).collect(Collectors.toList());
|
|
|
List<WbsTreeContract> jlTab = tabs.stream().filter(f -> "4,5,6".contains(f.getTableOwner())).collect(Collectors.toList());
|
|
|
-
|
|
|
List<WbsTreeContract> sgTabSort = sgTab.stream()
|
|
|
.sorted((a, b) -> {
|
|
|
Integer aSort = a.getSort() != null ? a.getSort() : 0;
|
|
@@ -579,41 +590,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
return aUpdateTime.compareTo(bUpdateTime);
|
|
|
})
|
|
|
.collect(Collectors.toList());
|
|
|
-
|
|
|
- Map<String, String> sgYsNodeMaps = new HashMap<>();
|
|
|
- Map<String, String> jlYsNodeMaps = new HashMap<>();
|
|
|
- Map<String, String> plYsMaps = new HashMap<>();
|
|
|
-
|
|
|
- Map<String, String> sgCopyNodeMaps = new HashMap<>();
|
|
|
- Map<String, String> jlCopyNodeMaps = new HashMap<>();
|
|
|
- Map<String, String> plJlNodeMaps = new HashMap<>();
|
|
|
-
|
|
|
- for (WbsTreeContract wbsTreeContract : sgTabSort) {
|
|
|
- if (wbsTreeContract.getOldId() == null) {
|
|
|
- //施工原始表
|
|
|
- String s = extractAlphameric(wbsTreeContract.getNodeName());
|
|
|
- if (StringUtils.isNotEmpty(s)) {
|
|
|
- sgYsNodeMaps.put(s + "---" + wbsTreeContract.getPKeyId(), wbsTreeContract.getInitTableName());
|
|
|
- }
|
|
|
- } else {
|
|
|
- //复制表
|
|
|
- if (wbsTreeContract.getNodeName().contains("__")) {
|
|
|
- String s = extractAlphameric(wbsTreeContract.getNodeName());
|
|
|
- if (StringUtils.isNotEmpty(s)) {
|
|
|
- sgCopyNodeMaps.put(s + "---" + wbsTreeContract.getPKeyId(), wbsTreeContract.getInitTableName());
|
|
|
- }
|
|
|
- }
|
|
|
- //原始频率表
|
|
|
- if (wbsTreeContract.getNodeName().contains("_PL_")) {
|
|
|
- String s = extractAlphameric(wbsTreeContract.getNodeName());
|
|
|
- if (StringUtils.isNotEmpty(s)) {
|
|
|
- plYsMaps.put(s + "---" + wbsTreeContract.getPKeyId(), wbsTreeContract.getInitTableName());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
List<WbsTreeContract> jlTabSort = jlTab.stream()
|
|
|
.sorted((a, b) -> {
|
|
|
Integer aSort = a.getSort() != null ? a.getSort() : 0;
|
|
@@ -637,79 +613,359 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
})
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
+ for (WbsTreeContract wbsTreeContract : sgTabSort) {
|
|
|
+ //质检表
|
|
|
+ String s = extractAlphameric(wbsTreeContract.getNodeName());
|
|
|
+ if (StringUtils.isNotEmpty(s)) {
|
|
|
+ sgTabMaps.put(s + "---" + wbsTreeContract.getPKeyId(), wbsTreeContract.getInitTableName());
|
|
|
+ }
|
|
|
+ }
|
|
|
for (WbsTreeContract wbsTreeContract : jlTabSort) {
|
|
|
- if (wbsTreeContract.getOldId() == null) {
|
|
|
- //监理原始表
|
|
|
- String s = extractAlphameric(wbsTreeContract.getNodeName());
|
|
|
- if (StringUtils.isNotEmpty(s)) {
|
|
|
- jlYsNodeMaps.put(s + "---" + wbsTreeContract.getPKeyId(), wbsTreeContract.getInitTableName());
|
|
|
+ //监理表
|
|
|
+ String s = extractAlphameric(wbsTreeContract.getNodeName());
|
|
|
+ if (StringUtils.isNotEmpty(s)) {
|
|
|
+ jlTabMaps.put(s + "---" + wbsTreeContract.getPKeyId(), wbsTreeContract.getInitTableName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //构造表数据
|
|
|
+ List<InsertDataVO> resultData = new LinkedList<>();
|
|
|
+ this.syncTabDataImpl(sgTabMaps, jlTabMaps, resultData);
|
|
|
+
|
|
|
+ //入库处理
|
|
|
+ if (resultData.size() > 0) {
|
|
|
+ List<String> resultSQLS = new ArrayList<>();
|
|
|
+ Map<String, List<InsertDataVO>> maps = resultData.stream().filter(f -> f.getKey().contains("key_")).collect(Collectors.groupingBy(InsertDataVO::getInitTabName));
|
|
|
+
|
|
|
+ //对应入库的监理表的所有有效字段
|
|
|
+ Map<String, List<String>> filedTabMaps = new LinkedHashMap<>();
|
|
|
+ Set<String> initTabNames = maps.keySet();
|
|
|
+ for (String initTabName : initTabNames) {
|
|
|
+ List<QueryProcessDataVO> tabColsAllByTabName = informationQueryClient.getNodeChildTabColsAllByTabName(initTabName);
|
|
|
+ List<String> keys = tabColsAllByTabName.stream().map(QueryProcessDataVO::getAncestors).collect(Collectors.toList());
|
|
|
+ if (keys.size() > 0) {
|
|
|
+ filedTabMaps.put(initTabName, keys);
|
|
|
}
|
|
|
- } else {
|
|
|
- //复制表
|
|
|
- if (wbsTreeContract.getNodeName().contains("__")) {
|
|
|
- String s = extractAlphameric(wbsTreeContract.getNodeName());
|
|
|
- if (StringUtils.isNotEmpty(s)) {
|
|
|
- jlCopyNodeMaps.put(s + "---" + wbsTreeContract.getPKeyId(), wbsTreeContract.getInitTableName());
|
|
|
+ }
|
|
|
+
|
|
|
+ //数据处理
|
|
|
+ for (Map.Entry<String, List<InsertDataVO>> oneTabData : maps.entrySet()) {
|
|
|
+ String initTabName = oneTabData.getKey();
|
|
|
+ List<InsertDataVO> dataValue = oneTabData.getValue();
|
|
|
+ //监理表的所有有效字段
|
|
|
+ List<String> keysAll = Func.toStrList(filedTabMaps.get(initTabName).get(0));
|
|
|
+
|
|
|
+ //一张实体表中,多组数据,复制表共用同一张实体表,只是pKeyId不同
|
|
|
+ Map<String, List<InsertDataVO>> oneTab = dataValue.stream().collect(Collectors.groupingBy(InsertDataVO::getPKeyId));
|
|
|
+
|
|
|
+ for (Map.Entry<String, List<InsertDataVO>> tab : oneTab.entrySet()) {
|
|
|
+ String tabPKeyId = tab.getKey();
|
|
|
+ List<InsertDataVO> tabData = tab.getValue();
|
|
|
+ StringBuilder dataSql = new StringBuilder();
|
|
|
+ List<String> keys = new LinkedList<>();
|
|
|
+ List<String> values = new LinkedList<>();
|
|
|
+ for (InsertDataVO vo : tabData) {
|
|
|
+ String key = vo.getKey();
|
|
|
+ if (!keysAll.contains(key)) {
|
|
|
+ continue; //如果key不在监理表keysAll中,就跳过
|
|
|
+ }
|
|
|
+ if (!keys.contains(key)) { //解决重复key值问题
|
|
|
+ keys.add(key);
|
|
|
+ String data = vo.getData();
|
|
|
+ values.add(data);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- //频率表
|
|
|
- if (wbsTreeContract.getNodeName().contains("_PL_")) {
|
|
|
- String s = extractAlphameric(wbsTreeContract.getNodeName());
|
|
|
- if (StringUtils.isNotEmpty(s)) {
|
|
|
- plJlNodeMaps.put(s + "---" + wbsTreeContract.getPKeyId(), wbsTreeContract.getInitTableName());
|
|
|
+ if (keys.size() > 0 && values.size() > 0 && keys.size() == values.size()) {
|
|
|
+ //delete SQL(删除旧数据,去重)
|
|
|
+ String delSql = "delete from " + initTabName + " where p_key_id = " + tabPKeyId + ";";
|
|
|
+ //insert SQL(新增)
|
|
|
+ dataSql.append(delSql).append("insert into ")
|
|
|
+ .append(initTabName).append(" (id,p_key_id,group_id,")
|
|
|
+ .append(String.join(",", keys))
|
|
|
+ .append(") values (")
|
|
|
+ .append(SnowFlakeUtil.getId()).append(",")
|
|
|
+ .append(tabPKeyId).append(",null,")
|
|
|
+ .append(values.stream()
|
|
|
+ .map(s -> "'" + s + "'")
|
|
|
+ .collect(Collectors.joining(",")))
|
|
|
+ .append(");");
|
|
|
+
|
|
|
+ resultSQLS.add(dataSql.toString());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //入库
|
|
|
+ if (resultSQLS.size() > 0) {
|
|
|
+ List<List<String>> partition = Lists.partition(resultSQLS, 10);
|
|
|
+ for (List<String> strings : partition) {
|
|
|
+ jdbcTemplate.execute(StringUtils.join(strings, " "));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ return true;
|
|
|
|
|
|
+ } else {
|
|
|
+ throw new ServiceException("未获取到当前节点信息,请联系管理员");
|
|
|
}
|
|
|
- return false;
|
|
|
}
|
|
|
|
|
|
- private void syncTabDataImpl(Map<String, String> sgData, Map<String, String> jlData, WbsTreeContract node) {
|
|
|
- for (Map.Entry<String, String> sgTab : sgData.entrySet()) {
|
|
|
+ /**
|
|
|
+ * 构造数据
|
|
|
+ *
|
|
|
+ * @param sgData
|
|
|
+ * @param jlData
|
|
|
+ * @param resultData
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ private void syncTabDataImpl
|
|
|
+ (Map<String, String> sgData, Map<String, String> jlData, List<InsertDataVO> resultData) throws
|
|
|
+ Exception {
|
|
|
+ for (Map.Entry<String, String> sgTab : sgData.entrySet()) { //质检表
|
|
|
String[] split = sgTab.getKey().split("---");
|
|
|
String nodeNameRe = split[0];
|
|
|
String pKeyId = split[1];
|
|
|
String initTabName = sgTab.getValue();
|
|
|
- for (Map.Entry<String, String> jlTab : jlData.entrySet()) {
|
|
|
+
|
|
|
+ String htmlString = this.getHtmlString(pKeyId);
|
|
|
+
|
|
|
+ for (Map.Entry<String, String> jlTab : jlData.entrySet()) { //监理表
|
|
|
String[] splitJl = jlTab.getKey().split("---");
|
|
|
String nodeNameReJL = splitJl[0];
|
|
|
String pKeyIdJL = splitJl[1];
|
|
|
String initTabNameJL = jlTab.getValue();
|
|
|
|
|
|
- //相同表,复制数据
|
|
|
+ //表的代码名称相同,就复制数据,例如:G10=G10
|
|
|
if (nodeNameRe.equals(nodeNameReJL)) {
|
|
|
- //当前原始施工表
|
|
|
- WbsTreeContract wbsTreeContract = baseMapper.selectOne(Wrappers.<WbsTreeContract>lambdaQuery()
|
|
|
- .eq(WbsTreeContract::getPKeyId, pKeyId).eq(WbsTreeContract::getStatus, 1).eq(WbsTreeContract::getIsBussShow, 1));
|
|
|
- if (wbsTreeContract != null) {
|
|
|
- //获取initTabId,获取表字段
|
|
|
- WbsTreePrivate initTabId = wbsTreePrivateMapper.selectOne(Wrappers.<WbsTreePrivate>lambdaQuery()
|
|
|
- .select(WbsTreePrivate::getInitTableId)
|
|
|
- .eq(WbsTreePrivate::getProjectId, node.getProjectId())
|
|
|
- .eq(WbsTreePrivate::getWbsId, node.getWbsId())
|
|
|
- .eq(WbsTreePrivate::getNodeName, node.getNodeName())
|
|
|
- .eq(WbsTreePrivate::getId, node.getId())
|
|
|
- .eq(WbsTreePrivate::getWbsType, node.getWbsType())
|
|
|
- .eq(WbsTreePrivate::getType, 2)
|
|
|
- .eq(WbsTreePrivate::getStatus, 1));
|
|
|
-
|
|
|
- if (initTabId != null) { //表元素字段
|
|
|
- List<WbsFormElement> elementList = jdbcTemplate.query("select * from m_wbs_form_element where f_id = " + initTabId.getInitTableId(), new BeanPropertyRowMapper<>(WbsFormElement.class));
|
|
|
- }
|
|
|
- //TODO
|
|
|
|
|
|
- }
|
|
|
+ String htmlStringJL = this.getHtmlString(pKeyIdJL);
|
|
|
+
|
|
|
+ //获取质检实体表对应数据
|
|
|
+ List<Map<String, Object>> mapsList = jdbcTemplate.queryForList("select * from " + initTabName + " where p_key_id = " + pKeyId);
|
|
|
+ if (mapsList.size() > 0) {
|
|
|
+ LinkedCaseInsensitiveMap<Object> maps = (LinkedCaseInsensitiveMap<Object>) mapsList.get(0);
|
|
|
+ LinkedHashMap<String, Object> resultMaps = new LinkedHashMap<>(maps);
|
|
|
+ resultMaps.entrySet().removeIf(entry -> entry.getValue() == null || entry.getValue().toString().trim().isEmpty()); //排除空串
|
|
|
+
|
|
|
+ for (Map.Entry<String, Object> obj : resultMaps.entrySet()) {
|
|
|
+ String key = obj.getKey();
|
|
|
+ Object value = obj.getValue();
|
|
|
+
|
|
|
+ //非跨单元格(一个单元格)
|
|
|
+ if (value.toString().contains("_^_") && !value.toString().contains("☆")) {
|
|
|
+ String[] fieldArr = value.toString().split("_\\^_");
|
|
|
+ String data = fieldArr[0];
|
|
|
+ String index = fieldArr[1];
|
|
|
+ String findIndex = key + "__" + index;
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(htmlString)) {
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
+ Elements td = doc.select("el-input[keyname~=" + findIndex + ".*]");
|
|
|
+ if (td.size() == 0) {
|
|
|
+ //日期格式
|
|
|
+ td = doc.select("el-date-picker[keyname~=" + findIndex + ".*]");
|
|
|
+ }
|
|
|
+ if (td.size() == 0) {
|
|
|
+ //图片格式
|
|
|
+ td = doc.select("hc-table-form-upload[keyname~=" + findIndex + ".*]");
|
|
|
+ }
|
|
|
+ if (td.size() == 0) {
|
|
|
+ //复选框
|
|
|
+ td = doc.select("hc-form-checkbox-group[keyname~=" + findIndex + ".*]");
|
|
|
+ }
|
|
|
+ if (td.size() == 0) {
|
|
|
+ //下拉框
|
|
|
+ td = doc.select("el-select[keyname~=" + findIndex + ".*]");
|
|
|
+ }
|
|
|
+ String placeholderValue = "";
|
|
|
+ if (td.size() >= 1) {
|
|
|
+ for (Element element : td) {
|
|
|
+ placeholderValue = element.attr("placeholderxx");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- //复制完直接跳过
|
|
|
- break;
|
|
|
+ //警告,空串跳过
|
|
|
+ if (!placeholderValue.contains("警告") && StringUtils.isNotEmpty(placeholderValue)) {
|
|
|
+ if (StringUtils.isNotEmpty(htmlStringJL)) {
|
|
|
+ Document docJL = Jsoup.parse(htmlStringJL);
|
|
|
+ Elements tdJL = docJL.select("el-input[placeholderxx~=" + this.escapeRegex(placeholderValue) + ".*]");
|
|
|
+ if (tdJL.size() == 0) {
|
|
|
+ //日期格式
|
|
|
+ tdJL = docJL.select("el-date-picker[placeholderxx~=" + this.escapeRegex(placeholderValue) + ".*]");
|
|
|
+ }
|
|
|
+ if (tdJL.size() == 0) {
|
|
|
+ //图片格式
|
|
|
+ tdJL = docJL.select("hc-table-form-upload[placeholderxx~=" + this.escapeRegex(placeholderValue) + ".*]");
|
|
|
+ }
|
|
|
+ if (tdJL.size() == 0) {
|
|
|
+ //复选框
|
|
|
+ tdJL = docJL.select("hc-form-checkbox-group[placeholderxx~=" + this.escapeRegex(placeholderValue) + ".*]");
|
|
|
+ }
|
|
|
+ if (tdJL.size() == 0) {
|
|
|
+ //下拉框
|
|
|
+ tdJL = docJL.select("el-select[placeholderxx~=" + this.escapeRegex(placeholderValue) + ".*]");
|
|
|
+ }
|
|
|
+ if (tdJL.size() >= 1) {
|
|
|
+ for (Element element : tdJL) {
|
|
|
+ String keyname = element.attr("keyname");
|
|
|
+ if (StringUtils.isNotEmpty(keyname)) {
|
|
|
+ String[] keynameJL = keyname.split("__");
|
|
|
+ String keyJL = keynameJL[0];
|
|
|
+ String keyJLIndex = keynameJL[1];
|
|
|
+
|
|
|
+ InsertDataVO vo = new InsertDataVO();
|
|
|
+ vo.setPKeyId(pKeyIdJL);
|
|
|
+ vo.setInitTabName(initTabNameJL);
|
|
|
+ if (keyJL.length() > 3) { //排除key=key的时候,也就是找不到key值,正常为key_X
|
|
|
+ vo.setKey(keyJL);
|
|
|
+ vo.setData(data + "_^_" + keyJLIndex);
|
|
|
+ resultData.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //跨单元格(多个单元格)
|
|
|
+ } else if (value.toString().contains("_^_") && value.toString().contains("☆")) {
|
|
|
+ String[] oneCells = value.toString().split("☆"); //一个单元格
|
|
|
+
|
|
|
+ List<String> values = new ArrayList<>();
|
|
|
+
|
|
|
+ for (String cell : oneCells) {
|
|
|
+ String[] fieldArr = cell.split("_\\^_");
|
|
|
+ String data = fieldArr[0];
|
|
|
+ String index = fieldArr[1];
|
|
|
+ String findIndex = key + "__" + index;
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(htmlString)) {
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
+ Elements td = doc.select("el-input[keyname~=" + findIndex + ".*]");
|
|
|
+ if (td.size() == 0) {
|
|
|
+ //日期格式
|
|
|
+ td = doc.select("el-date-picker[keyname~=" + findIndex + ".*]");
|
|
|
+ }
|
|
|
+ if (td.size() == 0) {
|
|
|
+ //图片格式
|
|
|
+ td = doc.select("hc-table-form-upload[keyname~=" + findIndex + ".*]");
|
|
|
+ }
|
|
|
+ if (td.size() == 0) {
|
|
|
+ //复选框
|
|
|
+ td = doc.select("hc-form-checkbox-group[keyname~=" + findIndex + ".*]");
|
|
|
+ }
|
|
|
+ if (td.size() == 0) {
|
|
|
+ //下拉框
|
|
|
+ td = doc.select("el-select[keyname~=" + findIndex + ".*]");
|
|
|
+ }
|
|
|
+ String placeholderValue = "";
|
|
|
+ if (td.size() >= 1) {
|
|
|
+ for (Element element : td) {
|
|
|
+ placeholderValue = element.attr("placeholderxx");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //警告,空串跳过
|
|
|
+ if (!placeholderValue.contains("警告") && StringUtils.isNotEmpty(placeholderValue)) {
|
|
|
+ if (StringUtils.isNotEmpty(htmlStringJL)) {
|
|
|
+ Document docJL = Jsoup.parse(htmlStringJL);
|
|
|
+ Elements tdJL = docJL.select("el-input[placeholderxx~=" + this.escapeRegex(placeholderValue) + ".*]");
|
|
|
+ if (tdJL.size() == 0) {
|
|
|
+ //日期格式
|
|
|
+ tdJL = docJL.select("el-date-picker[keyname~=" + this.escapeRegex(placeholderValue) + ".*]");
|
|
|
+ }
|
|
|
+ if (tdJL.size() == 0) {
|
|
|
+ //图片格式
|
|
|
+ tdJL = docJL.select("hc-table-form-upload[placeholderxx~=" + this.escapeRegex(placeholderValue) + ".*]");
|
|
|
+ }
|
|
|
+ if (tdJL.size() == 0) {
|
|
|
+ //复选框
|
|
|
+ tdJL = docJL.select("hc-form-checkbox-group[placeholderxx~=" + this.escapeRegex(placeholderValue) + ".*]");
|
|
|
+ }
|
|
|
+ if (tdJL.size() == 0) {
|
|
|
+ //下拉框
|
|
|
+ tdJL = docJL.select("el-select[placeholderxx~=" + this.escapeRegex(placeholderValue) + ".*]");
|
|
|
+ }
|
|
|
+ if (tdJL.size() >= 1) {
|
|
|
+ for (Element element : tdJL) {
|
|
|
+ String keyname = element.attr("keyname");
|
|
|
+ if (StringUtils.isNotEmpty(keyname)) {
|
|
|
+ String[] keynameJL = keyname.split("__");
|
|
|
+ String keyJL = keynameJL[0];
|
|
|
+ if (keyJL.length() > 3) { //排除key=key的时候,也就是找不到key值,正常为key_X
|
|
|
+ String keyJLIndex = keynameJL[1];
|
|
|
+ if (keyJLIndex.equals(index)) { //位置相同才复制
|
|
|
+ values.add(data + "_^_" + keyJLIndex + "---" + keyJL);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Set<String> dataResult = new HashSet<>();
|
|
|
+ Set<String> keyResult = new HashSet<>();
|
|
|
+ for (String v : values) {
|
|
|
+ String[] split1 = v.split("---");
|
|
|
+ dataResult.add(split1[0]);
|
|
|
+ keyResult.add(split1[1]);
|
|
|
+ }
|
|
|
+ if (dataResult.size() > 0 && keyResult.size() > 0) {
|
|
|
+ InsertDataVO vo = new InsertDataVO();
|
|
|
+ vo.setPKeyId(pKeyIdJL);
|
|
|
+ vo.setInitTabName(initTabNameJL);
|
|
|
+ vo.setKey(keyResult.stream().findAny().orElse(null));
|
|
|
+ vo.setData(StringUtils.join(dataResult, "☆"));
|
|
|
+ resultData.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取html页面信息
|
|
|
+ *
|
|
|
+ * @param pkeyId
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ private String getHtmlString(String pkeyId) throws Exception {
|
|
|
+ String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
+ String sys_file_net_url = ParamCache.getValue(CommonConstant.SYS_FILE_NET_URL);
|
|
|
+ WbsTreeContract wbsTreeContract = baseMapper.selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
+ .select(WbsTreeContract::getHtmlUrl)
|
|
|
+ .eq(WbsTreeContract::getPKeyId, pkeyId));
|
|
|
+ if (wbsTreeContract == null || wbsTreeContract.getHtmlUrl() == null) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ String fileUrl = wbsTreeContract.getHtmlUrl();
|
|
|
+ File file1 = ResourceUtil.getFile(fileUrl);
|
|
|
+ InputStream fileInputStream;
|
|
|
+ if (file1.exists()) {
|
|
|
+ fileInputStream = new FileInputStream(file1);
|
|
|
+ } else {
|
|
|
+ String path = sys_file_net_url + fileUrl.replaceAll("//", "/").replaceAll(file_path, "");
|
|
|
+ fileInputStream = CommonUtil.getOSSInputStream(path);
|
|
|
+ }
|
|
|
+
|
|
|
+ String htmlString = IoUtil.readToString(fileInputStream);
|
|
|
+ htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
+ return doc.select("table").first() + "";
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 截取字符串中的英文和数字,返回处理后的字符串
|
|
@@ -721,18 +977,26 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
if (str == null) {
|
|
|
return "";
|
|
|
}
|
|
|
-
|
|
|
Pattern pattern = Pattern.compile("[a-zA-Z0-9\\.]+");
|
|
|
Matcher matcher = pattern.matcher(str);
|
|
|
-
|
|
|
StringBuilder resultBuilder = new StringBuilder();
|
|
|
while (matcher.find()) {
|
|
|
- resultBuilder.append(matcher.group());
|
|
|
+ String match = matcher.group();
|
|
|
+ match = match.replace(".", "");
|
|
|
+ resultBuilder.append(match);
|
|
|
}
|
|
|
-
|
|
|
return resultBuilder.toString();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 转义字符串
|
|
|
+ *
|
|
|
+ * @param input
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String escapeRegex(String input) {
|
|
|
+ return Pattern.quote(input);
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public List<WbsTreeContract> updateAllNodeTabById(WbsTreePrivate aPrivate) {
|
|
@@ -820,7 +1084,8 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public WbsTreeContractVO4 importWbsContract(MultipartFile excelFile, String primaryKeyId, Integer isSplicingNumber) throws IOException {
|
|
|
+ public WbsTreeContractVO4 importWbsContract(MultipartFile excelFile, String primaryKeyId, Integer
|
|
|
+ isSplicingNumber) throws IOException {
|
|
|
File file = FileUtils.convert(excelFile);
|
|
|
String canonicalPath = file.getCanonicalPath();
|
|
|
try {
|
|
@@ -843,7 +1108,8 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- private WbsTreeContractVO4 importSubmitWbsContractNodes(ArrayList<Map<String, String>> result, String primaryKeyId, Integer isSplicingNumber) {
|
|
|
+ private WbsTreeContractVO4 importSubmitWbsContractNodes(ArrayList<Map<String, String>> result, String
|
|
|
+ primaryKeyId, Integer isSplicingNumber) {
|
|
|
WbsTreeContract wbsTreeContractRoot = baseMapper.selectOne(Wrappers.<WbsTreeContract>query().lambda().eq(WbsTreeContract::getPKeyId, primaryKeyId));
|
|
|
//获取当前节点下所有子节点
|
|
|
List<WbsTreeContractVO> wbsTreeContractVOS = contractInfoMapper.tree4(wbsTreeContractRoot.getContractId(), String.valueOf(wbsTreeContractRoot.getId()));
|
|
@@ -1020,7 +1286,8 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
- private List<WbsTreeContractVO> buildFailDataTree(List<WbsTreeContractVO> failData, List<WbsTreeContractVO> successData, Long parentIdRoot) {
|
|
|
+ private List<WbsTreeContractVO> buildFailDataTree
|
|
|
+ (List<WbsTreeContractVO> failData, List<WbsTreeContractVO> successData, Long parentIdRoot) {
|
|
|
List<WbsTreeContractVO> resultData = new ArrayList<>();
|
|
|
resultData.addAll(successData);
|
|
|
resultData.addAll(failData);
|
|
@@ -1079,7 +1346,8 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private List<Map<Integer, String>> getResultList(ArrayList<Map<String, String>> result, Integer isSplicingNumber) {
|
|
|
+ private List<Map<Integer, String>> getResultList(ArrayList<Map<String, String>> result, Integer
|
|
|
+ isSplicingNumber) {
|
|
|
List<Map<Integer, String>> resultList = new ArrayList<>();
|
|
|
String str = "\\s*|\r|\n|\t";
|
|
|
for (Map<String, String> map : result) {
|
|
@@ -1163,7 +1431,8 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
return resultList;
|
|
|
}
|
|
|
|
|
|
- private List<WbsTreeContract> findAllNodeList(String wbsTreeIds, String projectId, String contractId, String wbsId) {
|
|
|
+ private List<WbsTreeContract> findAllNodeList(String wbsTreeIds, String projectId, String contractId, String
|
|
|
+ wbsId) {
|
|
|
String[] ids = wbsTreeIds.split(",");
|
|
|
List<WbsTreeContract> list = new ArrayList<>();
|
|
|
for (String id : ids) {
|