|
@@ -18,6 +18,7 @@ package org.springblade.manager.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.spire.xls.Workbook;
|
|
|
import com.spire.xls.Worksheet;
|
|
|
import io.swagger.annotations.*;
|
|
@@ -45,6 +46,7 @@ import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.constant.BladeConstant;
|
|
|
import org.springblade.core.tool.utils.*;
|
|
|
import org.springblade.manager.entity.*;
|
|
|
+import org.springblade.manager.mapper.WbsTreePrivateMapper;
|
|
|
import org.springblade.manager.service.*;
|
|
|
import org.springblade.manager.vo.*;
|
|
|
import org.springblade.manager.wrapper.ExcelTabWrapper;
|
|
@@ -77,7 +79,7 @@ public class ExcelTabController extends BladeController {
|
|
|
// wes 基本信息表
|
|
|
private final IWbsTreeService wbsTreeService;
|
|
|
// excel 解析结构
|
|
|
- private final IExctabCellService exctabCellService;
|
|
|
+ //private final IExctabCellService exctabCellService;
|
|
|
|
|
|
private final IOSSClient iossClient;
|
|
|
|
|
@@ -85,11 +87,16 @@ public class ExcelTabController extends BladeController {
|
|
|
private final IWbsTreePrivateService wbsTreePrivateService;
|
|
|
|
|
|
// 清表表格解析信息
|
|
|
- private final ILinkdataInfoService linkdataInfoService;
|
|
|
+ //private final ILinkdataInfoService linkdataInfoService;
|
|
|
|
|
|
// 元素信息表-
|
|
|
private final IWbsFormElementService wbsFormElementService;
|
|
|
|
|
|
+ // 元素信息表-
|
|
|
+ private final IWbsTreeContractService wbsTreeContractService;
|
|
|
+
|
|
|
+ private final WbsTreePrivateMapper wbsTreePrivateMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 详情
|
|
|
*/
|
|
@@ -339,11 +346,6 @@ public class ExcelTabController extends BladeController {
|
|
|
String[] pk_id = info.getLinkIds().split(",");
|
|
|
for(String pkInfo : pk_id){
|
|
|
|
|
|
- /*wbsTree.setPKeyId(Long.parseLong(pkInfo));
|
|
|
- WbsTreePrivate aPrivate = wbsTreePrivateService.getOne(Condition.getQueryWrapper(wbsTree));
|
|
|
- aPrivate.setExcelId(excelTab.getId());
|
|
|
- aPrivate.setIsLinkTable(2);*/
|
|
|
-
|
|
|
UpdateWrapper<WbsTreePrivate> updateWrapper = new UpdateWrapper<>();
|
|
|
updateWrapper.in("p_key_id",Long.parseLong(pkInfo));
|
|
|
updateWrapper.set("is_link_table",2);
|
|
@@ -402,6 +404,9 @@ public class ExcelTabController extends BladeController {
|
|
|
FileUtil.copy(file_in,file_out);
|
|
|
updateWrapper.set("html_url",thmlUrl);
|
|
|
wbsTreePrivateService.update(updateWrapper);
|
|
|
+ //关联项目下所有的合同段
|
|
|
+ wbsTreeContractService.updateAllNodeTabById(aPrivate);
|
|
|
+
|
|
|
|
|
|
// 匹配关联
|
|
|
File file1 = ResourceUtil.getFile(thmlUrl);
|
|
@@ -420,7 +425,7 @@ public class ExcelTabController extends BladeController {
|
|
|
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().indexOf("el-input")>=0){
|
|
|
String titleName = element.attr("title");
|
|
|
double maxScore = 0.6;
|
|
|
String lastName = "";
|
|
@@ -436,15 +441,18 @@ public class ExcelTabController extends BladeController {
|
|
|
if(MathUtil.sim(titleName,ysName) > maxScore){
|
|
|
attrInfo = elementInfo.getEKey()+"="+i+"_"+j;
|
|
|
lastName = ysName ;
|
|
|
+ maxScore = MathUtil.sim(titleName,ysName);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- System.out.println(titleName +"——"+lastName);
|
|
|
- element.children().get(0).attr("placeholder",lastName).attr("v-model","formData."+attrInfo).attr("keyName",attrInfo);
|
|
|
+ String oncklickText = "'"+lastName +"',"+i+","+j;
|
|
|
+ element.children().get(0).attr("placeholder",lastName).attr("@focus","getInformation("+oncklickText+")").attr("keyName",attrInfo).attr("weighing",maxScore+"");//.attr("v-model","formData."+attrInfo);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ File writefile = new File(thmlUrl);
|
|
|
+ FileUtil.writeToFile(writefile, doc.html(), Boolean.parseBoolean("UTF-8"));
|
|
|
return R.success("关联成功");
|
|
|
}
|
|
|
|
|
@@ -456,28 +464,34 @@ public class ExcelTabController extends BladeController {
|
|
|
@ApiOperationSupport(order = 16)
|
|
|
@ApiOperation(value = "清表生成html", notes = "清表生成html")
|
|
|
@ApiImplicitParams(value = {
|
|
|
- @ApiImplicitParam(name = "excelId", value = "excelId", required = true)
|
|
|
+ @ApiImplicitParam(name = "pkeyId", value = "pkeyId", required = true)
|
|
|
})
|
|
|
- public R getExcelHtmlByBuss(Long excelId) throws IOException {
|
|
|
- ExcelTab excelTab = excelTabService.getById(excelId);
|
|
|
- if(excelTab ==null ){
|
|
|
+ public R getExcelHtmlByBuss(Long pkeyId) throws IOException {
|
|
|
+
|
|
|
+ WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
+ .eq(WbsTreeContract::getPKeyId, pkeyId));
|
|
|
+ if(wbsTreeContract ==null ){
|
|
|
return R.fail("该数据下无此节点!");
|
|
|
}
|
|
|
- if(excelTab.getHtmlUrl()==null){
|
|
|
+ if(wbsTreeContract.getHtmlUrl()==null){
|
|
|
return R.fail("请上传清表!");
|
|
|
}
|
|
|
-
|
|
|
- File file1 = ResourceUtil.getFile(excelTab.getHtmlUrl());
|
|
|
+ File file1 = ResourceUtil.getFile(wbsTreeContract.getHtmlUrl());
|
|
|
FileInputStream fileInputStream = new FileInputStream(file1);
|
|
|
- String htmlString = IoUtil.readToString(fileInputStream);
|
|
|
+ String htmlString = IoUtil.readToString(fileInputStream);
|
|
|
// 解析 style
|
|
|
Document doc = Jsoup.parse(htmlString);
|
|
|
Element table = doc.select("table").first();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
doc.select("Col").remove();
|
|
|
fileInputStream.close();
|
|
|
return R.data(table+"");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 清表生成html
|
|
|
*/
|
|
@@ -485,19 +499,20 @@ public class ExcelTabController extends BladeController {
|
|
|
@ApiOperationSupport(order = 15)
|
|
|
@ApiOperation(value = "清表生成html", notes = "清表生成html")
|
|
|
@ApiImplicitParams(value = {
|
|
|
- @ApiImplicitParam(name = "excelId", value = "excelId", required = true)
|
|
|
+ @ApiImplicitParam(name = "pkeyId", value = "pkeyId", required = true)
|
|
|
})
|
|
|
- public R getExcelHtml(Long excelId) throws IOException {
|
|
|
- ExcelTab excelTab = excelTabService.getById(excelId);
|
|
|
+ public R getExcelHtml(Long pkeyId) throws IOException {
|
|
|
|
|
|
- if(excelTab ==null ){
|
|
|
+ WbsTreePrivate wbsTreePrivate = wbsTreePrivateMapper.getByPKeyId(pkeyId);
|
|
|
+
|
|
|
+ if(wbsTreePrivate ==null ){
|
|
|
return R.fail("该数据下无此节点!");
|
|
|
}
|
|
|
- if(excelTab.getHtmlUrl()==null){
|
|
|
+ if(wbsTreePrivate.getHtmlUrl()==null){
|
|
|
return R.fail("请上传清表!");
|
|
|
}
|
|
|
|
|
|
- File file1 = ResourceUtil.getFile(excelTab.getHtmlUrl());
|
|
|
+ File file1 = ResourceUtil.getFile(wbsTreePrivate.getHtmlUrl());
|
|
|
FileInputStream fileInputStream = new FileInputStream(file1);
|
|
|
String htmlString = IoUtil.readToString(fileInputStream);
|
|
|
// 解析 style
|
|
@@ -508,215 +523,7 @@ public class ExcelTabController extends BladeController {
|
|
|
return R.data(table+"");
|
|
|
}
|
|
|
|
|
|
- public static void explianHtml1111(String htmlURl) throws IOException {
|
|
|
-
|
|
|
- File file1 = ResourceUtil.getFile(htmlURl);
|
|
|
- FileInputStream inputStream = new FileInputStream(file1);
|
|
|
-
|
|
|
- // 测试
|
|
|
- String htmlString = IoUtil.readToString(inputStream);
|
|
|
-
|
|
|
- // 样式集合
|
|
|
- Map<String ,String > styleMap = new HashMap<>();
|
|
|
- // 解析 style
|
|
|
- Document doc = Jsoup.parse(htmlString);
|
|
|
- Element style = doc.select("style").first();
|
|
|
-
|
|
|
- Matcher cssMatcher = Pattern.compile("(\\w+)\\s*[{]([^}]+)[}]").matcher(style.html());
|
|
|
- while (cssMatcher.find()) {
|
|
|
- styleMap.put(cssMatcher.group(1),cssMatcher.group(2));
|
|
|
- }
|
|
|
- // 解析 总行和总列
|
|
|
- Element table = doc.select("table").first();
|
|
|
- Elements trs = table.select("tr");
|
|
|
-
|
|
|
- // 获取总行列数
|
|
|
- int maxCol = doc.select("Col").size();
|
|
|
- String [] rowData = new String[trs.size()+1];
|
|
|
-
|
|
|
- int s_index = 0;
|
|
|
- boolean index_stat = false;
|
|
|
- int xy_type = 1 ;
|
|
|
- // 横向计算
|
|
|
- for(int i = 0 ;i < trs.size() ;i++) {
|
|
|
- Element tr = trs.get(i);
|
|
|
- Elements tds = tr.select("td");
|
|
|
-
|
|
|
- int x_width = 0 ;
|
|
|
- int y_width = 0 ;
|
|
|
- int text_width = 0;
|
|
|
- //区域计算
|
|
|
- for (int j = 0; j < tds.size(); j++) {
|
|
|
- Element data = tds.get(j);
|
|
|
- String keyId = data.attr("class");
|
|
|
-
|
|
|
- int colspan = data.attr("COLSPAN").equals("") ? 1 : Integer.parseInt(data.attr("COLSPAN"));
|
|
|
- String classInfo = styleMap.get(keyId);
|
|
|
- data.removeAttr("class");
|
|
|
- data.attr("style",styleMap.get(keyId).replaceAll("break-word","inherit"));
|
|
|
- // 第一列
|
|
|
-
|
|
|
- // 计算线开始
|
|
|
- if(classInfo.indexOf("border-left-style")>=0 && classInfo.indexOf("border-top-style")>=0 && classInfo.indexOf("border-bottom-style")>=0 && classInfo.indexOf("border-right-style")>=0){
|
|
|
- x_width += colspan;
|
|
|
- }
|
|
|
-
|
|
|
- // 计算结束
|
|
|
- if(classInfo.indexOf("border-left-style")< 0 && classInfo.indexOf("border-bottom-style")<0 && classInfo.indexOf("border-right-style")<0){
|
|
|
- y_width += colspan;
|
|
|
- }
|
|
|
-
|
|
|
- String name = data.text().replaceAll("[^\u4E00-\u9FA5]", "");
|
|
|
- if(!name.isEmpty()){
|
|
|
- text_width += colspan;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(index_stat){
|
|
|
- //是否需要改变
|
|
|
- if(maxCol == y_width ){
|
|
|
- index_stat = false ;
|
|
|
- xy_type+=1;
|
|
|
- }
|
|
|
- if(maxCol == text_width){
|
|
|
- xy_type+=1;
|
|
|
- }
|
|
|
- }else{ // 区域外
|
|
|
- if(maxCol == x_width ){
|
|
|
- index_stat = true ;
|
|
|
- xy_type+=1;
|
|
|
- }
|
|
|
- }
|
|
|
- tr.attr("indexStat",index_stat+"");
|
|
|
-
|
|
|
- int x= 0;
|
|
|
- for (int j = 0; j < tds.size(); j++) {
|
|
|
- Element data = tds.get(j);
|
|
|
-
|
|
|
- int colspan = data.attr("COLSPAN").equals("") ? 0 : Integer.parseInt(data.attr("COLSPAN"));
|
|
|
- int rowspan = data.attr("ROWSPAN").equals("") ? 0 : Integer.parseInt(data.attr("ROWSPAN"));
|
|
|
-
|
|
|
- Map<String, String> textObject = new HashMap<>();
|
|
|
- // 计算
|
|
|
- int x1 =0;
|
|
|
- int x2 =0;
|
|
|
- int y1 =0;
|
|
|
- int y2 =0;
|
|
|
- //x
|
|
|
- // X 坐标
|
|
|
- if(colspan==0){
|
|
|
- x1 = x+1;
|
|
|
- x2 = x+1;
|
|
|
- x= x +1;
|
|
|
- }else{
|
|
|
- x1 = x+1;
|
|
|
- x2 = x+colspan;
|
|
|
- x = x+colspan;
|
|
|
- }
|
|
|
- String textInfo = data.text().trim();
|
|
|
-
|
|
|
- // y 坐标
|
|
|
- y1=i+1;
|
|
|
- if(rowspan==0){
|
|
|
- y2 = i+1;
|
|
|
- }else{
|
|
|
- y2 = i+rowspan;
|
|
|
- for(int k=0;k<rowspan-1;k++){
|
|
|
- String dataInfo = rowData[k+2+i];
|
|
|
- if(dataInfo==null){
|
|
|
- dataInfo = x1+":"+x2;
|
|
|
- }else{
|
|
|
- String [] dataInfo2 = dataInfo.split(",");
|
|
|
- String dataInfo3 = dataInfo2[dataInfo2.length-1];
|
|
|
- int mx1 = Integer.parseInt(dataInfo3.split(":")[0]);
|
|
|
- int mx2 = Integer.parseInt(dataInfo3.split(":")[1]);
|
|
|
- if(mx2+1==x1){
|
|
|
- dataInfo = dataInfo+","+mx1+":"+x2;
|
|
|
- }else{
|
|
|
- dataInfo = dataInfo+","+x1+":"+x2;
|
|
|
- }
|
|
|
- }
|
|
|
- rowData[k+2+i] = dataInfo;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- String getRowInfo = rowData[y1];
|
|
|
- if(getRowInfo!=null){
|
|
|
- String [] dataInfo2 = getRowInfo.split(",");
|
|
|
- if(getRowInfo.indexOf("1")>=0 && j==0){
|
|
|
- for(int m =0;m<dataInfo2.length ;m++){
|
|
|
- int mx1 = Integer.parseInt(dataInfo2[m].split(":")[0]);
|
|
|
- int mx2 = Integer.parseInt(dataInfo2[m].split(":")[1]);
|
|
|
- x = mx2;
|
|
|
- }
|
|
|
- x1 = x+x1;
|
|
|
- x2 = x+x2;
|
|
|
- x = x+1 ; //计算自己
|
|
|
- }else{
|
|
|
- for(int m =0;m<dataInfo2.length ;m++){
|
|
|
- int mx1 = Integer.parseInt(dataInfo2[m].split(":")[0]);
|
|
|
- int mx2 = Integer.parseInt(dataInfo2[m].split(":")[1]);
|
|
|
- if(x2+1 == mx1){
|
|
|
- x = mx2 ;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- System.out.println(StringUtil.trimAllWhitespace(textInfo)+""+StringUtil.trimAllWhitespace(textInfo).length());
|
|
|
- data.text(textInfo.replaceAll(" ",""));
|
|
|
-
|
|
|
- // 设置td 属性
|
|
|
- data.attr("trIndex",i+"");
|
|
|
- data.attr("tdIndex",j+"");
|
|
|
- data.attr("x1",x1+"");
|
|
|
- data.attr("x2",x2+"");
|
|
|
- data.attr("y1",y1+"");
|
|
|
- data.attr("y2",y2+"");
|
|
|
- data.attr("xytype",xy_type+"");
|
|
|
- String parm = i+","+j+","+x1+","+x2+","+y1+","+y2+",$event";
|
|
|
- // 设置文本信息
|
|
|
- if(textInfo.indexOf("年")>=0 && textInfo.indexOf("月")>=0&& textInfo.indexOf("日")>=0){
|
|
|
- data.empty().append("<el-date-picker style='width:100%;height:100%' trIndex="+i+" tdIndex="+j+" x1="+x1+" x2="+x2+" y1="+y1+" y2="+y2+" type='date' format='YYYY年MM月DD日' placeholder='请选择时间'> </el-date-picker>");
|
|
|
- }
|
|
|
-
|
|
|
- if(textInfo.isEmpty() || textInfo.equals("/") || textInfo.equals("-")){
|
|
|
- if(index_stat){
|
|
|
- if(rowspan>=1){
|
|
|
- data.empty().append("<el-input type='textarea' @contextmenu.prevent.native='RightClick("+parm+")' trIndex="+i+" tdIndex="+j+" x1="+x1+" x2="+x2+" y1="+y1+" y2="+y2+" style='width:100%;height:100%' :rows="+rowspan*2+" placeholder=''> </el-input>");
|
|
|
- }else{
|
|
|
- data.empty().append("<el-input type='text' @contextmenu.prevent.native='RightClick("+parm+")' trIndex="+i+" tdIndex="+j+" x1="+x1+" x2="+x2+" y1="+y1+" y2="+y2+" style='width:100%;height:100%' placeholder=''> </el-input>");
|
|
|
- }
|
|
|
- }else{
|
|
|
- if(j==0 ){
|
|
|
- if(colspan ==maxCol && i>=1 && i<=2){
|
|
|
- if(rowspan>=1){
|
|
|
- data.empty().append("<el-input type='textarea' @contextmenu.prevent.native='RightClick("+parm+")' trIndex="+i+" tdIndex="+j+" x1="+x1+" x2="+x2+" y1="+y1+" y2="+y2+" style='width:100%;height:100%' :rows="+rowspan*2+" placeholder=''> </el-input>");
|
|
|
- }else{
|
|
|
- data.empty().append("<el-input type='text' @contextmenu.prevent.native='RightClick("+parm+")' trIndex="+i+" tdIndex="+j+" x1="+x1+" x2="+x2+" y1="+y1+" y2="+y2+" style='width:100%;height:100%' placeholder=''> </el-input>");
|
|
|
- }
|
|
|
- }
|
|
|
- }else{
|
|
|
- Element bforData = tds.get(j-1);
|
|
|
- if(!bforData.text().isEmpty()){
|
|
|
- if(rowspan>=1){
|
|
|
- data.empty().append("<el-input type='textarea' @contextmenu.prevent.native='RightClick("+parm+")' trIndex="+i+" tdIndex="+j+" x1="+x1+" x2="+x2+" y1="+y1+" y2="+y2+" style='width:100%;height:100%' :rows="+rowspan*2+" placeholder=''> </el-input>");
|
|
|
- }else{
|
|
|
- data.empty().append("<el-input type='text' @contextmenu.prevent.native='RightClick("+parm+")' trIndex="+i+" tdIndex="+j+" x1="+x1+" x2="+x2+" y1="+y1+" y2="+y2+" style='width:100%;height:100%' placeholder=''> </el-input>");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 写入
|
|
|
|
|
|
- FileUtil.writeToFile(file1, doc.html(), Boolean.parseBoolean("UTF-8"));
|
|
|
- inputStream.close();
|
|
|
- System.out.println("完成");
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
*保存用户填报数据接口
|