|
@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.spire.xls.*;
|
|
@@ -686,7 +687,7 @@ public class ExcelTabController extends BladeController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ saveOldHtmlConfig(aPrivate, htmlString);
|
|
|
File writefile = new File(thmlUrl);
|
|
|
FileUtil.writeToFile(writefile, doc.html(), Boolean.parseBoolean("UTF-8"));
|
|
|
|
|
@@ -732,6 +733,119 @@ public class ExcelTabController extends BladeController {
|
|
|
return R.success("关联成功");
|
|
|
}
|
|
|
|
|
|
+ public void saveOldHtmlConfig(WbsTreePrivate wbsTreePrivate, String htmlString){
|
|
|
+ // 获取原默认值配置
|
|
|
+ List<TextdictInfoVO> defaultConfigs = new ArrayList<>();
|
|
|
+ {
|
|
|
+ IPage<TextdictInfoVO> result = textdictInfoService.analysisHtmlDefault(wbsTreePrivate.getPKeyId() + "");
|
|
|
+ if (result != null && result.getRecords() != null && !result.getRecords().isEmpty()) {
|
|
|
+ result.getRecords().forEach(config -> {
|
|
|
+ if (config.getId() == null || config.getId() <= 0) {
|
|
|
+ defaultConfigs.add(config);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 读取新的html内容
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
+ // 将原配置信息写入到新的html中,先通过colKey匹配,再通过colName匹配。如果匹配不上,则保存到数据库。后续手动配置、修改
|
|
|
+ defaultConfigs.removeIf(config -> {
|
|
|
+ String colKey = config.getColKey();
|
|
|
+ Element element = null;
|
|
|
+ if (colKey != null && !colKey.isEmpty()) {
|
|
|
+ element = doc.select("[keyname='" + config.getColKey() + "']").first();
|
|
|
+ if (element == null && colKey.contains("__")) {
|
|
|
+ element = doc.select("[keyname*='" + colKey.split("__")[0] + "']").first();
|
|
|
+ String point = colKey.split("__")[1];
|
|
|
+ if (element == null && point.contains("_")) {
|
|
|
+ String[] split = point.split("_");
|
|
|
+ element = doc.select("[trindex='" + split[0] + "'],[tdindex='" + split[1] + "']").first();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (element == null) {
|
|
|
+ element = doc.select("[placeholder='" + config.getColName() + "']").first();
|
|
|
+ }
|
|
|
+ if (element != null) {
|
|
|
+ element.removeAttr("defText");
|
|
|
+ element.attr("defText", config.getSigRoleName());
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ if (!defaultConfigs.isEmpty()) {
|
|
|
+ List<TextdictInfo> saves = new ArrayList<>();
|
|
|
+ defaultConfigs.forEach(config -> {
|
|
|
+ TextdictInfo info = new TextdictInfo();
|
|
|
+ info.setId(SnowFlakeUtil.getId());
|
|
|
+ info.setTabId(wbsTreePrivate.getPKeyId() + "");
|
|
|
+ info.setExcelId(wbsTreePrivate.getExcelId() == null ? null : wbsTreePrivate.getExcelId() + "");
|
|
|
+ info.setType(config.getType());
|
|
|
+ info.setColKey(config.getColKey());
|
|
|
+ info.setColName(config.getColName());
|
|
|
+ info.setSigRoleName(config.getSigRoleName());
|
|
|
+ info.setProjectId(wbsTreePrivate.getProjectId());
|
|
|
+ info.setName("编辑默认值");
|
|
|
+ saves.add( info);
|
|
|
+ });
|
|
|
+ textdictInfoService.saveOrUpdateBatch(saves);
|
|
|
+ }
|
|
|
+ // 获取原电签配置
|
|
|
+ TextdictInfoVO textdictInfo = new TextdictInfoVO();
|
|
|
+ textdictInfo.setProjectId(wbsTreePrivate.getProjectId());
|
|
|
+ textdictInfo.setTabId(wbsTreePrivate.getPKeyId() + "");
|
|
|
+ textdictInfo.setShowType(1);
|
|
|
+ textdictInfo.setType(2);
|
|
|
+ IPage<TextdictInfoVO> signConfigs = textdictInfoService.selectTextdictInfoPage(new Page<>(1, 1000), textdictInfo);
|
|
|
+ if (signConfigs != null && signConfigs.getRecords() != null && !signConfigs.getRecords().isEmpty()) {
|
|
|
+ List<TextdictInfoVO> signConfigList = signConfigs.getRecords();
|
|
|
+ signConfigList.removeIf(config -> {
|
|
|
+ String colKey = config.getColKey();
|
|
|
+ Element element = null;
|
|
|
+ if (colKey != null && !colKey.isEmpty()) {
|
|
|
+ element = doc.select("[keyname='" + config.getColKey() + "']").first();
|
|
|
+ if (element == null && colKey.contains("__")) {
|
|
|
+ element = doc.select("[keyname*='" + colKey.split("__")[0] + "']").first();
|
|
|
+ String point = colKey.split("__")[1];
|
|
|
+ if (element == null && point.contains("_")) {
|
|
|
+ String[] split = point.split("_");
|
|
|
+ element = doc.select("[trindex='" + split[0] + "'],[tdindex='" + split[1] + "']").first();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (element == null) {
|
|
|
+ element = doc.select("[placeholder='" + config.getColName() + "']").first();
|
|
|
+ }
|
|
|
+ if (element != null) {
|
|
|
+ int i = 5;
|
|
|
+ Element parent = element.parent();
|
|
|
+ while (i > 0 && parent != null) {
|
|
|
+ if (parent.hasAttr("title")) {
|
|
|
+ element.attr("dqid", config.getId() + "");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ parent = parent.parent();
|
|
|
+ i--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ if (!signConfigList.isEmpty()) {
|
|
|
+ String ids = signConfigList.stream().map(config -> config.getId() + "").collect(Collectors.joining("||"));
|
|
|
+ Element table = doc.select("table").first();
|
|
|
+ if (table != null) {
|
|
|
+ Element tr = table.select("tr").last();
|
|
|
+ if (tr != null) {
|
|
|
+ Element td = tr.select("td").last();
|
|
|
+ if (td != null) {
|
|
|
+ td.attr("dqid", ids);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 质检 获取html接口
|