|
@@ -1,6 +1,5 @@
|
|
|
package org.springblade.manager.service.impl;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.AllArgsConstructor;
|
|
@@ -19,25 +18,21 @@ import org.springblade.manager.dto.TrialSummaryClassificationConfigurationReleva
|
|
|
import org.springblade.manager.entity.*;
|
|
|
import org.springblade.manager.mapper.TrialSummaryClassificationConfigurationMapper;
|
|
|
import org.springblade.manager.service.IExcelTabService;
|
|
|
-import org.springblade.manager.service.ITableInfoService;
|
|
|
import org.springblade.manager.service.ITrialSummaryClassificationConfigurationService;
|
|
|
import org.springblade.manager.service.IWbsFormElementService;
|
|
|
import org.springblade.manager.utils.FileUtils;
|
|
|
import org.springblade.manager.utils.RegularExpressionUtil;
|
|
|
import org.springblade.manager.utils.WbsElementUtil;
|
|
|
import org.springblade.manager.vo.TrialTreeVO;
|
|
|
-import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.FileInputStream;
|
|
|
-import java.io.FileNotFoundException;
|
|
|
import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
-import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@@ -81,33 +76,32 @@ public class TrialSummaryClassificationConfigurationServiceImpl
|
|
|
@Override
|
|
|
public boolean relevancy(TrialSummaryClassificationConfigurationRelevancyDTO dto) throws IOException {
|
|
|
if (ObjectUtil.isNotEmpty(dto.getExcelId()) && ObjectUtil.isNotEmpty(dto.getClassId())) {
|
|
|
- /*关联清表,重新生成html,重构定位信息*/
|
|
|
- String file_path = FileUtils.getSysLocalFileUrl();
|
|
|
+ /*上传excel清表模板后,需要元素识别并添加到元素库;
|
|
|
+ 然后调该接口关联清表,重新生成html,重构定位信息*/
|
|
|
ExcelTab excelTab = excelTabService.getById(dto.getExcelId());
|
|
|
if (ObjectUtil.isEmpty(excelTab)) {
|
|
|
throw new ServiceException("未获取到清表信息");
|
|
|
}
|
|
|
if (ObjectUtil.isEmpty(excelTab.getTabId())) {
|
|
|
- throw new ServiceException("未获取到清表tabId信息");
|
|
|
+ throw new ServiceException("tabId为空,请先在元素识别中添加到元素库");
|
|
|
}
|
|
|
List<WbsFormElement> elementList = wbsFormElementService.selectElementListByFid(excelTab.getTabId());
|
|
|
if (elementList.size() == 0) {
|
|
|
- throw new ServiceException("未获取到清表对应元素信息");
|
|
|
+ throw new ServiceException("未获取到元素信息");
|
|
|
}
|
|
|
|
|
|
//复制模版htmlURL
|
|
|
//File file_in = ResourceUtil.getFile("C:\\Users\\泓创开发\\Desktop\\fsdownload\\1717821792510279680.html");
|
|
|
File file_in = ResourceUtil.getFile(excelTab.getHtmlUrl());
|
|
|
String fileCode = SnowFlakeUtil.getId() + "";
|
|
|
+ String file_path = FileUtils.getSysLocalFileUrl();
|
|
|
String htmlUrl = file_path + "/privateUrl/" + fileCode + ".html";
|
|
|
File file_out = ResourceUtil.getFile(htmlUrl);
|
|
|
FileUtil.copy(file_in, file_out);
|
|
|
|
|
|
- //匹配关联
|
|
|
File file1 = ResourceUtil.getFile(htmlUrl);
|
|
|
String htmlString = IoUtil.readToString(new FileInputStream(file1));
|
|
|
Document doc = Jsoup.parse(htmlString);
|
|
|
- //解析
|
|
|
Element table = doc.select("table").first();
|
|
|
Elements trs = table.select("tr");
|
|
|
for (int i = 0; i < trs.size(); i++) {
|
|
@@ -115,8 +109,7 @@ public class TrialSummaryClassificationConfigurationServiceImpl
|
|
|
Elements tds = tr.select("td");
|
|
|
for (int j = 0; j < tds.size(); j++) {
|
|
|
Element element = tds.get(j);
|
|
|
- if (element.html().indexOf("el-input") >= 0 || element.html().indexOf("el-date-picker") >= 0) {
|
|
|
-
|
|
|
+ if (element.html().contains("el-input") || element.html().contains("el-date-picker")) {
|
|
|
boolean is_true = false;
|
|
|
String titleName = element.attr("title");
|
|
|
double maxScore = 0.48;
|
|
@@ -124,7 +117,6 @@ public class TrialSummaryClassificationConfigurationServiceImpl
|
|
|
String attrInfo = "key" + "__" + i + "_" + j;
|
|
|
String filedType = "";
|
|
|
String filedLength = "";
|
|
|
-
|
|
|
for (WbsFormElement elementInfo : elementList) {
|
|
|
String ysName = elementInfo.getEName();
|
|
|
if (titleName.equals(ysName)) {
|
|
@@ -152,36 +144,32 @@ public class TrialSummaryClassificationConfigurationServiceImpl
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- String oncklickText = "'" + lastName + "'," + i + "," + j;
|
|
|
-
|
|
|
- //字段正则表达式校验
|
|
|
+ String onClickText = "'" + lastName + "'," + i + "," + j;
|
|
|
String regularExpression = "$event" + "," + "'" + RegularExpressionUtil.getRegularExpression(filedType) + "','" + (StringUtils.isNotEmpty(filedType) ? WbsElementUtil.getTypeTips(filedType) : null) + "'," + i + "," + j;
|
|
|
-
|
|
|
if (is_true) {
|
|
|
element.children().get(0).attr("placeholder", lastName)
|
|
|
.attr("weighing", maxScore + "").attr("id", attrInfo).attr("keyName", attrInfo)
|
|
|
.attr("@blur", "getRegularExpression(" + regularExpression + ",'" + filedLength + "')")
|
|
|
.attr("v-model", "formData." + attrInfo)
|
|
|
.attr("maxlength", filedLength);
|
|
|
- if (element.html().indexOf("el-input") >= 0) {
|
|
|
+ if (element.html().contains("el-input")) {
|
|
|
String mousedown = "$event" + "," + "'" + attrInfo + "'";
|
|
|
element.children().get(0).attr("@mouseup.left", "inputLeftClick(" + mousedown + ")");
|
|
|
}
|
|
|
} else {
|
|
|
element.children().get(0)
|
|
|
- //.attr("placeholder", lastName)
|
|
|
.attr("weighing", maxScore + "").attr("id", attrInfo).attr("keyName", attrInfo)
|
|
|
.attr("@blur", "getRegularExpression(" + regularExpression + ",'" + filedLength + "')")
|
|
|
.attr("maxlength", filedLength)
|
|
|
.attr("class", "warnstyle");
|
|
|
}
|
|
|
- element.attr("@click", "getInformation(" + oncklickText + ")");
|
|
|
+ element.attr("@click", "getInformation(" + onClickText + ")");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
File writeFile = new File(htmlUrl);
|
|
|
- FileUtil.writeToFile(writeFile, doc.html(), Boolean.parseBoolean("UTF-8"));
|
|
|
+ FileUtil.writeToFile(writeFile, doc.html(), false);
|
|
|
|
|
|
String updateSql = "UPDATE m_trial_summary_classification_configuration SET excel_id = ?,html_url = ? WHERE id = ?";
|
|
|
Object[] delParams = {dto.getExcelId(), htmlUrl, dto.getClassId()};
|