|
@@ -17,6 +17,7 @@
|
|
|
package org.springblade.manager.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.jsoup.Jsoup;
|
|
@@ -25,10 +26,8 @@ import org.jsoup.nodes.Element;
|
|
|
import org.jsoup.select.Elements;
|
|
|
import org.springblade.common.constant.CommonConstant;
|
|
|
import org.springblade.common.utils.CommonUtil;
|
|
|
-import org.springblade.core.tool.utils.FileUtil;
|
|
|
-import org.springblade.core.tool.utils.Func;
|
|
|
-import org.springblade.core.tool.utils.IoUtil;
|
|
|
-import org.springblade.core.tool.utils.ResourceUtil;
|
|
|
+import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
+import org.springblade.core.tool.utils.*;
|
|
|
import org.springblade.manager.entity.TextdictInfo;
|
|
|
import org.springblade.manager.entity.WbsTreePrivate;
|
|
|
import org.springblade.manager.mapper.TextdictInfoMapper;
|
|
@@ -39,18 +38,14 @@ import org.springblade.manager.utils.FileUtils;
|
|
|
import org.springblade.manager.vo.TextdictBy345VO;
|
|
|
import org.springblade.manager.vo.TextdictInfoVO;
|
|
|
import org.springblade.system.cache.ParamCache;
|
|
|
-import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.io.File;
|
|
|
-import java.io.FileInputStream;
|
|
|
-import java.io.FileNotFoundException;
|
|
|
-import java.io.InputStream;
|
|
|
+import java.io.*;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
import java.util.stream.Collectors;
|
|
|
-import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 参数信息表 服务实现类
|
|
@@ -83,7 +78,7 @@ public class TextdictInfoServiceImpl extends ServiceImpl<TextdictInfoMapper, Tex
|
|
|
Elements keyNames = ek.getElementsByAttribute("keyname");
|
|
|
if(Func.isNotEmpty(keyNames)){
|
|
|
for(Element keyName:keyNames){
|
|
|
- keys.addAll(Func.toStrList("\\|\\|",keyName.attr("keyname")));
|
|
|
+ keys.add(keyName.attr("keyname"));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -99,6 +94,7 @@ public class TextdictInfoServiceImpl extends ServiceImpl<TextdictInfoMapper, Tex
|
|
|
if (textdict != null) {
|
|
|
textdict.forEach(textdictInfoVO -> textdictInfoVO.setIsSystem(2));
|
|
|
}
|
|
|
+ addSign(textdict, doc, privateInfo, dqid);
|
|
|
} else if (textdictList != null && !textdictList.isEmpty()) {
|
|
|
Map<String, Map<String, TextdictInfoVO>> map = textdict.stream().collect(Collectors.groupingBy(TextdictInfoVO::getColKey, Collectors.toMap(TextdictInfoVO::getSigRoleId, v -> v, (v1, v2) -> v1)));
|
|
|
List<TextdictInfoVO> collect = textdictList.stream().filter(textdictInfoVO -> {
|
|
@@ -110,6 +106,7 @@ public class TextdictInfoServiceImpl extends ServiceImpl<TextdictInfoMapper, Tex
|
|
|
return true;
|
|
|
}).collect(Collectors.toList());
|
|
|
textdict.addAll(collect);
|
|
|
+ addSign(collect, doc, privateInfo, dqid);
|
|
|
}
|
|
|
if (!keys.isEmpty()) {
|
|
|
TextdictInfoVO temp = null;
|
|
@@ -150,6 +147,63 @@ public class TextdictInfoServiceImpl extends ServiceImpl<TextdictInfoMapper, Tex
|
|
|
}
|
|
|
return page.setRecords(textdict);
|
|
|
}
|
|
|
+ private void addSign(List<TextdictInfoVO> collect, Document doc, WbsTreePrivate privateInfo, List<String> dqid) {
|
|
|
+ if (collect == null || collect.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<TextdictInfoVO> textdict = collect;
|
|
|
+ if (dqid != null && !dqid.isEmpty()) {
|
|
|
+ textdict = collect.stream().filter(textdictInfoVO -> !dqid.contains(textdictInfoVO.getId() + "")).collect(Collectors.toList());
|
|
|
+ if (textdict.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //解析
|
|
|
+ Element table = doc.select("table").first();
|
|
|
+ Elements trs = table.select("tr");
|
|
|
+ AtomicBoolean isUpdate = new AtomicBoolean(false);
|
|
|
+ textdict.forEach(textdictInfoVO -> {
|
|
|
+ if (StringUtil.hasText(textdictInfoVO.getColKey())) {
|
|
|
+ String keky = textdictInfoVO.getColKey();
|
|
|
+ String[] trtd = keky.split("__")[1].split("_");
|
|
|
+ Element element = trs.get(Integer.parseInt(trtd[0])).select("td").get(Integer.parseInt(trtd[1]));
|
|
|
+ String ids = element.attr("dqId");
|
|
|
+ if (StringUtil.hasText(ids) && ids.contains(textdictInfoVO.getId() + "")) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ids = StringUtil.hasText(ids) ? ids + "||" + textdictInfoVO.getId() : textdictInfoVO.getId() + "";
|
|
|
+ element.removeAttr("dqId");
|
|
|
+ element.attr("dqId", ids);
|
|
|
+ if (textdictInfoVO.getType() == 2) { //个人签字 不能用户输入
|
|
|
+ if (element.html().contains("el-tooltip")) {
|
|
|
+ element.children().get(0).children().get(0).attr(":readonly", "true");
|
|
|
+ } else {
|
|
|
+ element.children().get(0).attr(":readonly", "true");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ isUpdate.set(true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (!isUpdate.get()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String file_path = FileUtils.getSysLocalFileUrl();
|
|
|
+ String filecode = SnowFlakeUtil.getId() + "";
|
|
|
+ String thmlUrl = file_path + "privateUrlCopy/" + privateInfo.getProjectId()+"/"+filecode + ".html";
|
|
|
+ try {
|
|
|
+ File file_out = ResourceUtil.getFile(thmlUrl);
|
|
|
+ if(!file_out.exists()){
|
|
|
+ FileUtils.ensureFileExists(thmlUrl);
|
|
|
+ }
|
|
|
+ File writefile = new File(thmlUrl);
|
|
|
+ FileUtil.writeToFile(writefile, doc.html(), Boolean.parseBoolean("UTF-8"));
|
|
|
+ wbsTreePrivateMapper.update(null,Wrappers.<WbsTreePrivate>lambdaUpdate().eq(WbsTreePrivate::getPKeyId, privateInfo.getPKeyId()).set(WbsTreePrivate::getHtmlUrl, thmlUrl));
|
|
|
+ privateInfo.setHtmlUrl(thmlUrl);
|
|
|
+ baseMapper.updateHtmlUrl(thmlUrl, privateInfo.getProjectId(), privateInfo.getPKeyId());
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public TextdictInfoVO selectTextdictInfoById(TextdictInfo textdictInfo) {
|