|
|
@@ -8,6 +8,9 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import com.mixsmart.utils.StringUtils;
|
|
|
import io.swagger.annotations.*;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.jsoup.Jsoup;
|
|
|
+import org.jsoup.nodes.Document;
|
|
|
+import org.jsoup.select.Elements;
|
|
|
import org.springblade.business.entity.TrialSelfInspectionRecord;
|
|
|
import org.springblade.business.vo.SaveLogContractVO;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
@@ -19,10 +22,7 @@ import org.springblade.core.mp.support.Query;
|
|
|
import org.springblade.core.secure.BladeUser;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.support.Kv;
|
|
|
-import org.springblade.core.tool.utils.CollectionUtil;
|
|
|
-import org.springblade.core.tool.utils.Func;
|
|
|
-import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
-import org.springblade.core.tool.utils.StringUtil;
|
|
|
+import org.springblade.core.tool.utils.*;
|
|
|
|
|
|
import org.springblade.manager.dto.NameRuleDto;
|
|
|
import org.springblade.manager.dto.WbsTreePrivateDTO2;
|
|
|
@@ -31,6 +31,7 @@ import org.springblade.manager.entity.*;
|
|
|
import org.springblade.manager.mapper.WbsTreeContractMapper;
|
|
|
import org.springblade.manager.mapper.WbsTreePrivateMapper;
|
|
|
import org.springblade.manager.service.*;
|
|
|
+import org.springblade.manager.utils.FileUtils;
|
|
|
import org.springblade.manager.vo.*;
|
|
|
import org.springblade.manager.wrapper.WbsTreePrivateWrapper;
|
|
|
import org.springblade.system.cache.DictCache;
|
|
|
@@ -43,6 +44,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.FileNotFoundException;
|
|
|
import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -401,6 +403,65 @@ public class WbsTreePrivateController extends BladeController {
|
|
|
@RequestParam("projectId") String projectId) {
|
|
|
R<List<WbsNodeTableVO>> r = findNodeTableByCondition(parentId, wbsId, projectId);
|
|
|
List<WbsNodeTableVO> data = r.getData();
|
|
|
+ //解析html
|
|
|
+ data.forEach(f -> {
|
|
|
+ String htmlUrl = f.getHtmlUrl();
|
|
|
+ String initTableId = f.getInitTableId();
|
|
|
+ if(StringUtil.isNotBlank(htmlUrl) && StringUtils.isNotEmpty(initTableId)){
|
|
|
+ //获取元素表数据
|
|
|
+ List<WbsFormElement> wbsFormElements = wbsFormElementService.getBaseMapper().selectList(Wrappers.<WbsFormElement>lambdaQuery()
|
|
|
+ .eq(WbsFormElement::getFId, initTableId)
|
|
|
+ .eq(WbsFormElement::getIsDeleted, 0)
|
|
|
+ );
|
|
|
+
|
|
|
+ List<String> keys = wbsFormElements.stream().map(WbsFormElement::getEKey).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //解析html
|
|
|
+ // 读取html页面信息
|
|
|
+ InputStream inputStream = null;
|
|
|
+ try {
|
|
|
+ inputStream = FileUtils.getInputStreamByUrl(htmlUrl);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException("解析html失败");
|
|
|
+ }
|
|
|
+ String htmlString = IoUtil.readToString(inputStream);
|
|
|
+ // 样式集合
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
+ //获取所有input标签
|
|
|
+ Elements inputs = doc.select("el-input");
|
|
|
+
|
|
|
+ //判断标签是否存在id属性
|
|
|
+ inputs.forEach(input -> {
|
|
|
+ String id = input.attr("id");
|
|
|
+ if(StringUtils.isEmpty(id)){
|
|
|
+ f.setHtmlElementError(1);
|
|
|
+ input.attr("htmlElementError", "1");
|
|
|
+ } else {
|
|
|
+ /**
|
|
|
+ * 判断当前元素是否符合格式
|
|
|
+ * 1、是否存在key_
|
|
|
+ * 2、是否存在__
|
|
|
+ * 3、key_后面是否为数字
|
|
|
+ * 4、__后面是否为坐标
|
|
|
+ * 5、key是否在元素库中存在
|
|
|
+ */
|
|
|
+ if(!id.contains("key_")
|
|
|
+ || !id.contains("__")
|
|
|
+ || !StringUtils.isNumber(id.split("__")[0].replace("key_",""))
|
|
|
+ || !id.split("__")[1].contains("_")
|
|
|
+ || !StringUtils.isNumber(id.split("__")[1].split("_")[0])
|
|
|
+ || !StringUtils.isNumber(id.split("__")[1].split("_")[1])
|
|
|
+ || !keys.contains(id.split("__")[0])
|
|
|
+ ){
|
|
|
+ f.setHtmlElementError(1);
|
|
|
+ input.attr("htmlElementError", "1");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
List<WbsTreePrivateTableVO> list = new ArrayList<>();
|
|
|
if (data != null && !data.isEmpty()) {
|
|
|
Integer wbsType = data.get(0).getWbsType();
|