|
@@ -2,24 +2,35 @@ package org.springblade.manager.feign;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.spire.xls.*;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+import org.jsoup.Jsoup;
|
|
|
+import org.jsoup.nodes.Document;
|
|
|
+import org.jsoup.nodes.Element;
|
|
|
+import org.jsoup.nodes.Node;
|
|
|
+import org.jsoup.select.Elements;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springblade.business.dto.TrialSelfInspectionRecordDTO;
|
|
|
+import org.springblade.business.entity.ContractLog;
|
|
|
import org.springblade.business.entity.InformationQuery;
|
|
|
+import org.springblade.business.feign.ContractLogClient;
|
|
|
import org.springblade.business.feign.InformationQueryClient;
|
|
|
+import org.springblade.common.utils.CommonUtil;
|
|
|
+import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.oss.model.BladeFile;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
-import org.springblade.core.tool.utils.Func;
|
|
|
-import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
-import org.springblade.core.tool.utils.ResourceUtil;
|
|
|
+import org.springblade.core.tool.utils.*;
|
|
|
import org.springblade.manager.bean.TableInfo;
|
|
|
import org.springblade.manager.controller.ExcelTabController;
|
|
|
-import org.springblade.manager.entity.ExcelTab;
|
|
|
-import org.springblade.manager.entity.TrialSelfDataRecord;
|
|
|
+import org.springblade.manager.entity.*;
|
|
|
import org.springblade.manager.enums.ExecuteType;
|
|
|
+import org.springblade.manager.mapper.WbsTreePrivateMapper;
|
|
|
+import org.springblade.manager.service.IContractInfoService;
|
|
|
import org.springblade.manager.service.IExcelTabService;
|
|
|
+import org.springblade.manager.service.IProjectInfoService;
|
|
|
import org.springblade.manager.service.IWbsTreePrivateService;
|
|
|
import org.springblade.manager.utils.FileUtils;
|
|
|
import org.springblade.resource.feign.NewIOSSClient;
|
|
@@ -27,8 +38,14 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import javax.imageio.ImageIO;
|
|
|
+import java.awt.*;
|
|
|
+import java.awt.image.BufferedImage;
|
|
|
import java.io.File;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@RestController
|
|
@@ -41,6 +58,10 @@ public class ExcelTabClientImpl implements ExcelTabClient {
|
|
|
private final InformationQueryClient informationQueryClient;
|
|
|
private final ExcelTabController excelTabController;
|
|
|
private final IWbsTreePrivateService wbsTreePrivateService;
|
|
|
+ private final ContractLogClient contractLogClient;
|
|
|
+ private final WbsTreePrivateMapper wbsTreePrivateMapper;
|
|
|
+ private final IProjectInfoService projectInfoService;
|
|
|
+ private final IContractInfoService contractInfoService;
|
|
|
private static final Logger logger = LoggerFactory.getLogger(ExcelTabClientImpl.class);
|
|
|
|
|
|
@Override
|
|
@@ -171,4 +192,591 @@ public class ExcelTabClientImpl implements ExcelTabClient {
|
|
|
return pdfUrl;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public R<String> getTheContractLogBusinessData(String pkeyId, String nodePrimaryKeyId, String recordTime, String contractId) throws Exception {
|
|
|
+ //获取配置的路径
|
|
|
+ String file_path = FileUtils.getSysLocalFileUrl();
|
|
|
+ if (StringUtils.isEmpty(recordTime)) {
|
|
|
+ recordTime = DateUtil.format(DateUtil.now(), "yyyy-MM-dd");
|
|
|
+ }
|
|
|
+ List<ContractLog> contractLogList = this.contractLogClient.queryContractLogByPrimaryKeyIdAndRecordTimeList(nodePrimaryKeyId, recordTime, contractId);
|
|
|
+ List<String> ids = contractLogList.stream().map(ContractLog::getId).map(String::valueOf).collect(Collectors.toList());
|
|
|
+ if (ids.size() > 0) {
|
|
|
+ //PDF路径
|
|
|
+ List<String> pdfUrls = new ArrayList<>();
|
|
|
+ for (String dataId : ids) {
|
|
|
+ //查询对应的html
|
|
|
+ WbsTreePrivate tableNode = this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getPKeyId, pkeyId));
|
|
|
+
|
|
|
+ if (tableNode == null) {
|
|
|
+ return R.fail("该数据下无此节点!");
|
|
|
+ }
|
|
|
+
|
|
|
+ String htmlString = this.getHtmlString(pkeyId);
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(tableNode.getHtmlUrl()) || StringUtils.isEmpty(htmlString)) {
|
|
|
+ return R.fail("未获取到元素表信息!");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取清表信息
|
|
|
+ ExcelTab excelTab = excelTabService.getById(tableNode.getExcelId());
|
|
|
+ if (excelTab == null) {
|
|
|
+ return R.fail("失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取数据
|
|
|
+ List<Map<String, Object>> businessDataMapList = this.getTheLogBusinessData(dataId, nodePrimaryKeyId, recordTime, contractId).getData();
|
|
|
+ ProjectInfo projectInfo = projectInfoService.getById(tableNode.getProjectId());
|
|
|
+ //处理数据
|
|
|
+ for (Map<String, Object> dataMap : businessDataMapList) {
|
|
|
+ // 获取excel流 和 html流
|
|
|
+ Workbook wb = new Workbook();
|
|
|
+ wb.loadFromMHtml(CommonUtil.getOSSInputStream(excelTab.getFileUrl()));
|
|
|
+ //获取工作表
|
|
|
+ Worksheet sheet = wb.getWorksheets().get(0);
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
+ Element table = doc.select("table").first();
|
|
|
+ Elements trs = table.select("tr");
|
|
|
+ //添加标题
|
|
|
+ CellRange[] columns = sheet.getMergedCells();
|
|
|
+ for (int i = 0; i < columns.length; i++) {
|
|
|
+ CellRange cellRange = columns[i];
|
|
|
+ System.out.println(cellRange.getText());
|
|
|
+ if (cellRange.getStyle().getFont().getSize() >= 12 && Func.isNotEmpty(cellRange.getText())) {
|
|
|
+ String title = projectInfo.getProjectName();
|
|
|
+ if (title.length() >= 30) {
|
|
|
+ cellRange.setRowHeight(40);
|
|
|
+ cellRange.getStyle().setWrapText(true);
|
|
|
+ }
|
|
|
+ cellRange.getStyle().getFont().setSize(18);
|
|
|
+ cellRange.getStyle().setHorizontalAlignment(HorizontalAlignType.Center);
|
|
|
+ cellRange.setText(projectInfo.getProjectName());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ObjectUtil.isNotEmpty(dataMap)) {
|
|
|
+ for (String val : dataMap.keySet()) {
|
|
|
+ boolean flag=false;
|
|
|
+ if (val.indexOf("__") >= 0) {
|
|
|
+ String[] DataVal = val.split("__");
|
|
|
+ String[] xy = DataVal[1].split("_");
|
|
|
+ if (trs.size() > Integer.parseInt(xy[0])) {
|
|
|
+ Element trData = trs.get(Integer.parseInt(xy[0]));
|
|
|
+ Elements tdDatas = trData.select("td");
|
|
|
+ if (tdDatas.size() > Integer.parseInt(xy[1])) {
|
|
|
+ Element data = tdDatas.get(Integer.parseInt(xy[1]));
|
|
|
+ if(data.html().indexOf("date")>=0){
|
|
|
+ flag=true;
|
|
|
+ }
|
|
|
+ if (data.html().indexOf("x1") >= 0 && data.html().indexOf("y1") >= 0) {
|
|
|
+ int x1, y1;
|
|
|
+
|
|
|
+ if (data.html().indexOf("el-tooltip") >= 0) {
|
|
|
+ x1 = Integer.parseInt(data.children().get(0).children().get(0).attr("x1"));
|
|
|
+ y1 = Integer.parseInt(data.children().get(0).children().get(0).attr("y1"));
|
|
|
+ } else {
|
|
|
+ x1 = Integer.parseInt(data.children().get(0).attr("x1"));
|
|
|
+ y1 = Integer.parseInt(data.children().get(0).attr("y1"));
|
|
|
+ }
|
|
|
+ if (x1 == 0) {
|
|
|
+ x1 = 1;
|
|
|
+ }
|
|
|
+ String myData = dataMap.get(val) + "";
|
|
|
+ if (((myData.indexOf("T") >= 0 && myData.indexOf("-") >= 0) || (myData.indexOf(",") >= 0 && myData.indexOf("]") >= 0))&&flag) {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
|
|
+ sdf.setTimeZone(TimeZone.getTimeZone("GTM+8"));
|
|
|
+ SimpleDateFormat formatStr = new SimpleDateFormat("yyyy年MM月dd日");
|
|
|
+ if (myData.indexOf(",") >= 0 && myData.indexOf("]") >= 0) {
|
|
|
+ myData = myData.replace("[", "").replace("]", "").replaceAll("'", "");
|
|
|
+ String[] dataVal = myData.split(",");
|
|
|
+ Date Start_dataStr = sdf.parse(dataVal[0]);
|
|
|
+ Date end_dataStr = sdf.parse(dataVal[1]);
|
|
|
+ String StartDate = formatStr.format(Start_dataStr);
|
|
|
+ String endDate = formatStr.format(end_dataStr);
|
|
|
+ if (StartDate.equals(endDate)) {
|
|
|
+ myData = StartDate;
|
|
|
+ } else {
|
|
|
+ myData = StartDate + "-" + endDate;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ String[] dataStr = myData.split("T")[0].split("-");
|
|
|
+ if (dataStr.length == 3) {
|
|
|
+ myData = StringUtil.format("{}年{}月{}日", dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (myData.indexOf("http") >= 0 && (myData.indexOf("aliyuncs") >= 0 ||myData.indexOf("183.247.216.148") >= 0)) {
|
|
|
+ Element element = trs.get(y1).select("td").get(x1);
|
|
|
+ String[] styles = element.attr("style").split(";");
|
|
|
+ int Height = 0;
|
|
|
+ for (String sty : styles) {
|
|
|
+ if (sty.indexOf("height:") >= 0) {
|
|
|
+ Height = Integer.parseInt(sty.replace("height:", "").replace("px", ""));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ BufferedImage image = ImageIO.read(CommonUtil.getOSSInputStream(myData));
|
|
|
+ ExcelPicture pic = sheet.getPictures().add(y1, x1, image);
|
|
|
+ pic.setHeight(Height);
|
|
|
+ sheet.getCellRange(y1, x1).getStyle().setShrinkToFit(true);
|
|
|
+
|
|
|
+ } else if (data.html().indexOf("hc-form-checkbox-group") >= 0) {
|
|
|
+ CellRange cellRange = sheet.getCellRange(y1, x1);
|
|
|
+ String exceVal = cellRange.getValue().replaceAll(" ", "");
|
|
|
+ //如果有□ 代表 自动生成 如果没有 代表后期添加 需要显示html 中的值
|
|
|
+ if (exceVal.indexOf("□") >= 0) {
|
|
|
+ if (myData.equals("1")) {
|
|
|
+ cellRange.setValue(exceVal.replace("□", "\u2611"));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ List<Node> nodes = data.childNodes();
|
|
|
+ Node node = nodes.get(nodes.size() - 1);
|
|
|
+ String dataJson = node.attr(":objs");
|
|
|
+ if (StringUtils.isNotEmpty(dataJson)) {
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(dataJson);
|
|
|
+ List<Integer> idList = Func.toIntList(myData);
|
|
|
+ int indexx = 0;
|
|
|
+ if (idList.get(0) >= 1) {
|
|
|
+ indexx = idList.get(0) - 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ String dataInfo = jsonArray.getJSONObject(indexx).getString("name");
|
|
|
+ for (int inx = 1; inx < idList.size(); inx++) {
|
|
|
+ int valIndex = idList.get(inx) - 1;
|
|
|
+ dataInfo = dataInfo + "," + jsonArray.getJSONObject(valIndex).getString("name");
|
|
|
+ }
|
|
|
+ cellRange.setValue(dataInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ final CellRange cellRange = sheet.getCellRange(y1, x1);
|
|
|
+ cellRange.setText(myData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 组装电签设置
|
|
|
+ Elements dqids = table.getElementsByAttribute("dqid");
|
|
|
+ for (Element element : dqids) {
|
|
|
+ String dqid = element.attr("dqid");
|
|
|
+ Elements x11 = element.getElementsByAttribute("x1");
|
|
|
+ if (x11 != null && x11.size() >= 1) {
|
|
|
+ Element element1 = x11.get(x11.size() - 1);
|
|
|
+ int x1 = Func.toInt(element1.attr("x1"));
|
|
|
+ int y1 = Func.toInt(element1.attr("y1"));
|
|
|
+
|
|
|
+ CellRange cellRange = sheet.getCellRange(y1, x1);
|
|
|
+ if (cellRange != null) {
|
|
|
+ // 创建字体
|
|
|
+ cellRange.setText(dqid);
|
|
|
+ cellRange.getCellStyle().getExcelFont().setSize(1);
|
|
|
+ cellRange.getCellStyle().getExcelFont().setColor(Color.WHITE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Long fileName = SnowFlakeUtil.getId();
|
|
|
+ String onePdfPath = file_path + "/pdf//" + fileName + ".pdf";
|
|
|
+ sheet.saveToPdf(onePdfPath);
|
|
|
+ BladeFile bladeFile = this.newIOSSClient.uploadFile(fileName + ".pdf", onePdfPath);
|
|
|
+ pdfUrls.add(bladeFile.getLink());
|
|
|
+ wb.dispose();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (pdfUrls.size() > 0) {
|
|
|
+ try {
|
|
|
+ String mergePdfPath = file_path + "/pdf//" + SnowFlakeUtil.getId() + ".pdf";
|
|
|
+ File oldMergePdf = ResourceUtil.getFile(mergePdfPath);
|
|
|
+ if (oldMergePdf.exists()) {
|
|
|
+ oldMergePdf.delete();
|
|
|
+ }
|
|
|
+ FileUtils.mergePdfPublicMethods(pdfUrls, mergePdfPath);
|
|
|
+ BladeFile mergeFile = this.newIOSSClient.uploadFile(SnowFlakeUtil.getId() + new Date().getTime() + ".pdf", mergePdfPath);
|
|
|
+
|
|
|
+ //修改记录,当天的日志所有表的合并pdf都一样,即ids都修改成一样的
|
|
|
+ this.contractLogClient.updateTheLogPdfUrlByIds(StringUtils.join(ids, ","), mergeFile.getLink());
|
|
|
+
|
|
|
+ return R.data("成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return R.fail("数据异常");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.data("成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getHtmlString(String pkeyId) throws Exception {
|
|
|
+ WbsTreePrivate wbsTreePrivate = wbsTreePrivateMapper.selectOne(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
+ .select(WbsTreePrivate::getHtmlUrl)
|
|
|
+ .eq(WbsTreePrivate::getPKeyId, pkeyId));
|
|
|
+ if (wbsTreePrivate == null || wbsTreePrivate.getHtmlUrl() == null) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ String fileUrl = wbsTreePrivate.getHtmlUrl();
|
|
|
+ InputStream fileInputStream = FileUtils.getInputStreamByUrl(fileUrl);
|
|
|
+ String htmlString = IoUtil.readToString(fileInputStream);
|
|
|
+ htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
+ return doc.select("table").first() + "";
|
|
|
+ }
|
|
|
+ public R<List<Map<String, Object>>> getTheLogBusinessData(String theLogId, String nodePrimaryKeyId, String recordTime, String contractId) {
|
|
|
+ List<Map<String, Object>> resultMapList = new ArrayList<>();
|
|
|
+ //数据结果
|
|
|
+ String logId2 = "";
|
|
|
+
|
|
|
+ //获取对应的记录
|
|
|
+ String dataIds;
|
|
|
+ if (StringUtils.isNotEmpty(theLogId)) {
|
|
|
+ String[] split = theLogId.split(",");
|
|
|
+ List<String> ids = new LinkedList<>();
|
|
|
+ for (String logId : split) {
|
|
|
+ ContractLog contractLog = contractLogClient.queryContractLogByIdToObj(logId);
|
|
|
+ ids.add(contractLog.getDataId().toString());
|
|
|
+ }
|
|
|
+ dataIds = ids.stream().filter(Objects::nonNull).collect(Collectors.joining(","));
|
|
|
+ } else {
|
|
|
+ List<ContractLog> contractLogs = this.contractLogClient.queryContractLogByPrimaryKeyIdAndRecordTimeList(nodePrimaryKeyId, recordTime, contractId);
|
|
|
+ if (contractLogs.size() == 0){
|
|
|
+ logId2="";
|
|
|
+ }else {
|
|
|
+ logId2=contractLogs.get(0).getId()+"";
|
|
|
+ }
|
|
|
+ dataIds = contractLogs.stream().map(ContractLog::getDataId).filter(Objects::nonNull).map(String::valueOf).collect(Collectors.joining(","));
|
|
|
+ }
|
|
|
+
|
|
|
+ WbsTreePrivate node = this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getPKeyId, nodePrimaryKeyId));
|
|
|
+ WbsTreePrivate tableNode2 = this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery()
|
|
|
+ .eq(WbsTreePrivate::getParentId, node.getId()).eq(WbsTreePrivate::getProjectId, node.getProjectId()));
|
|
|
+
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(dataIds)) {
|
|
|
+ for (String dataId : dataIds.split(",")) {
|
|
|
+ Map<String, Object> reData = new HashMap<>();
|
|
|
+ reData.put("",logId2);
|
|
|
+ //检查实体表是否存在
|
|
|
+ String tabName = tableNode2.getInitTableName();
|
|
|
+ String isExitSql = " select * from information_schema.TABLES where TABLE_NAME='" + tabName + "'";
|
|
|
+
|
|
|
+ List<Map<String, Object>> tabList = this.jdbcTemplate.queryForList(isExitSql);
|
|
|
+ if (tabList.size() <= 0) {
|
|
|
+ return R.fail("无实体表对应");
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询数据
|
|
|
+ String querySql = "SELECT * FROM " + tabName + " WHERE id = " + dataId + " and group_id = " + tableNode2.getPKeyId();
|
|
|
+
|
|
|
+ List<Map<String, Object>> businessDataMap = this.jdbcTemplate.queryForList(querySql);
|
|
|
+
|
|
|
+ if (businessDataMap.size() > 0) {
|
|
|
+ // 匹配关联
|
|
|
+ try {
|
|
|
+ if (tableNode2.getHtmlUrl()!=null) {
|
|
|
+ InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl(tableNode2.getHtmlUrl());
|
|
|
+ String htmlString = IoUtil.readToString(inputStreamByUrl);
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
+
|
|
|
+ // 模糊匹配
|
|
|
+ Elements dwtitle = doc.select("el-input[placeholder~=.*承包单位]");
|
|
|
+ Elements sgtitle = doc.select("el-input[placeholder~=^施工单位]");
|
|
|
+ Elements sgtitle1 = doc.select("el-input[placeholder=安装单位]");
|
|
|
+ sgtitle.addAll(sgtitle1);
|
|
|
+
|
|
|
+ Elements htdtitle = doc.select("el-input[placeholder~=.*合同号.*]");
|
|
|
+ Elements htdtitle1 = doc.select("el-input[placeholder~=合同段.*]");
|
|
|
+ htdtitle.addAll(htdtitle1);
|
|
|
+
|
|
|
+ Elements jltitle = doc.select("el-input[placeholder~=监理单位.*]");
|
|
|
+
|
|
|
+ Elements bhtitle = doc.select("el-input[placeholder~=^编号]");
|
|
|
+ Elements bhtitle1 = doc.select("el-input[placeholder~=合同编号.*]");
|
|
|
+ bhtitle.addAll(bhtitle1);
|
|
|
+
|
|
|
+
|
|
|
+ Elements xmtitle = doc.select("el-input[placeholder~=^项目名称]");
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 承包单位 承包单位、施工单位:引用施工单位名称 ,
|
|
|
+ * 监理单位:引用监理单位名称
|
|
|
+ * 合同段、所属建设项目(合同段):引用合同段编号
|
|
|
+ *
|
|
|
+ * 施工单位:施工单位 和 安装单位
|
|
|
+ *
|
|
|
+ */
|
|
|
+ ContractInfo contractInfo = contractInfoService.getById(contractId);
|
|
|
+ // 施工单位名称
|
|
|
+ if (dwtitle.size() >= 1) {
|
|
|
+ int y = Integer.parseInt(dwtitle.attr("trindex"));
|
|
|
+ if (y <= 10) {
|
|
|
+ reData.put(dwtitle.attr("keyName"), contractInfo.getConstructionUnitName());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (sgtitle.size() >= 1) {
|
|
|
+ int y = Integer.parseInt(sgtitle.attr("trindex"));
|
|
|
+ if (y <= 10) {
|
|
|
+ reData.put(sgtitle.attr("keyName"), contractInfo.getConstructionUnitName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 合同段名称
|
|
|
+ if (htdtitle.size() >= 1) {
|
|
|
+ for (Element element : htdtitle) {
|
|
|
+ int trindex = Integer.parseInt(element.attr("trindex"));
|
|
|
+ if (trindex <= 8) {
|
|
|
+ reData.put(element.attr("keyName"), contractInfo.getContractNumber());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 监理单位名称
|
|
|
+ if (jltitle.size() >= 1) {
|
|
|
+ for (Element element : jltitle) {
|
|
|
+ int trindex = Integer.parseInt(element.attr("trindex"));
|
|
|
+ if (trindex <= 10) {
|
|
|
+ reData.put(element.attr("keyName"), contractInfo.getSupervisionUnitName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 项目名称
|
|
|
+ if (xmtitle.size() >= 1) {
|
|
|
+ for (Element element : xmtitle) {
|
|
|
+ int trindex = Integer.parseInt(element.attr("trindex"));
|
|
|
+ if (trindex <= 6) {
|
|
|
+ ProjectInfo projectInfo = projectInfoService.getById(tableNode2.getProjectId());
|
|
|
+ reData.put(element.attr("keyName"), projectInfo.getProjectName());
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 日期默认值
|
|
|
+ Elements dateTitle = doc.select("el-date-picker[placeholder~=日期]");
|
|
|
+ //日期默认
|
|
|
+ if (dateTitle.size() >= 1) {
|
|
|
+ for (Element element : dateTitle) {
|
|
|
+ int trindex = Integer.parseInt(element.attr("trindex"));
|
|
|
+ if (trindex <= 10) {
|
|
|
+ reData.put(element.attr("keyName"), recordTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加默认值
|
|
|
+ Elements elements = doc.getElementsByAttribute("defText");
|
|
|
+ if(Func.isNotEmpty(elements) && elements.size()>=1){
|
|
|
+ for(Element eleme: elements){
|
|
|
+ String id = Func.isNull(eleme.attr("id"))?eleme.attr("keyname"):eleme.attr("id");
|
|
|
+ if(Func.isNotEmpty(id)){
|
|
|
+ reData.put(id, eleme.attr("defText"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ for (Map<String, Object> mysqlData : businessDataMap) {
|
|
|
+
|
|
|
+ String querySqlx = "SELECT tree_primary_key_id as primaryKeyId,title as path from u_contract_log_wbs where business_id ='" + dataId + "' and is_deleted = 0";
|
|
|
+ List<Map<String, Object>> businessDat = this.jdbcTemplate.queryForList(querySqlx);
|
|
|
+ reData.put("linkTabIds", businessDat);
|
|
|
+ for (String key : mysqlData.keySet()) {
|
|
|
+ String tabVal = mysqlData.get(key) + "";
|
|
|
+ // 时间段处理
|
|
|
+ if (StringUtils.isNotEmpty(tabVal) && !tabVal.equals("null")) {
|
|
|
+ if (tabVal.indexOf("T") >= 0 && tabVal.indexOf(".000Z]") >= 0) {
|
|
|
+ String[] tabData = tabVal.split("_\\^_");
|
|
|
+ if (reData.containsKey("pickerKey")) {
|
|
|
+ String pickerKey = reData.get("pickerKey") + "," + key + "__" + tabData[1];
|
|
|
+ reData.put("pickerKey", pickerKey);
|
|
|
+ } else {
|
|
|
+ reData.put("pickerKey", key + "__" + tabData[1]);
|
|
|
+ }
|
|
|
+ String sql = tabData[0];
|
|
|
+ sql = sql.replaceAll("\\[", "['");
|
|
|
+ sql = sql.replaceAll("]", "']");
|
|
|
+ sql = sql.replaceAll("000Z,", "000Z',");
|
|
|
+ sql = sql.replaceAll(", 20", ", '20");
|
|
|
+ sql = sql.replaceAll("'", "");
|
|
|
+ reData.put(key + "__" + tabData[1], sql);
|
|
|
+ } else if (tabVal.indexOf("T") >= 0 && tabVal.indexOf(".000Z") >= 0) { //时间
|
|
|
+ String[] tabData = tabVal.split("_\\^_");
|
|
|
+ reData.put(key + "__" + tabData[1], tabData[0]);
|
|
|
+ } else if (tabVal.indexOf("☆") >= 0) {
|
|
|
+ String[] mysql = tabVal.split("☆");
|
|
|
+ for (String data : mysql) {
|
|
|
+ String[] tabData = data.split("_\\^_");
|
|
|
+ reData.put(key + "__" + tabData[1], tabData[0]);
|
|
|
+ }
|
|
|
+ } else if (tabVal.indexOf("_^_") >= 0) {
|
|
|
+ String[] tabData = tabVal.split("_\\^_");
|
|
|
+ if (StringUtils.isNotEmpty(tabData[0])) {
|
|
|
+ if (tabVal.contains("[") && tabVal.contains("年")) {
|
|
|
+ String[] strings = StringUtils.strip(tabData[0], "[]").split(",");
|
|
|
+ reData.put(key + "__" + tabData[1], strings);
|
|
|
+ }
|
|
|
+ if (tabVal.contains("[") && tabVal.contains("]") && tabVal.indexOf(",") >= 0) {
|
|
|
+ String[] strings = StringUtils.strip(tabData[0], "[]").split(",");
|
|
|
+ reData.put(key + "__" + tabData[1], strings);
|
|
|
+ }
|
|
|
+ if(tabVal.contains("[")&&tabVal.contains("]")&&tabVal.indexOf(",")==-1){
|
|
|
+ String[]strings= new String[]{StringUtils.strip(tabData[0],"[]")};
|
|
|
+ reData.put(key+"__"+tabData[1],strings);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ reData.put(key + "__" + tabData[1], tabData[0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ reData.put(key, tabVal);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //移除id和p_key_id
|
|
|
+ reData.remove("p_key_id");
|
|
|
+ reData.remove("classify");
|
|
|
+ reData.remove("contractId");
|
|
|
+ reData.remove("pkeyId");
|
|
|
+ reData.remove("projectId");
|
|
|
+
|
|
|
+ }
|
|
|
+ if (reData.size() > 0) {
|
|
|
+ resultMapList.add(reData);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Map<String, Object> reData2 = new HashMap<>();
|
|
|
+ //获取默认值
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ // 匹配关联
|
|
|
+ Map<String, Object> reData = new HashMap<>();
|
|
|
+ try {
|
|
|
+ if (tableNode2.getHtmlUrl()!=null) {
|
|
|
+ InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl(tableNode2.getHtmlUrl());
|
|
|
+ String htmlString = IoUtil.readToString(inputStreamByUrl);
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
+
|
|
|
+ // 模糊匹配
|
|
|
+ Elements dwtitle = doc.select("el-input[placeholder~=.*承包单位]");
|
|
|
+ Elements sgtitle = doc.select("el-input[placeholder~=^施工单位]");
|
|
|
+ Elements sgtitle1 = doc.select("el-input[placeholder=安装单位]");
|
|
|
+ sgtitle.addAll(sgtitle1);
|
|
|
+
|
|
|
+ Elements htdtitle = doc.select("el-input[placeholder~=.*合同号.*]");
|
|
|
+ Elements htdtitle1 = doc.select("el-input[placeholder~=合同段.*]");
|
|
|
+ htdtitle.addAll(htdtitle1);
|
|
|
+
|
|
|
+ Elements jltitle = doc.select("el-input[placeholder~=监理单位.*]");
|
|
|
+ Elements jltit = doc.select("el-input[placeholder~=监理机构.*]");
|
|
|
+ jltitle.addAll(jltit);
|
|
|
+
|
|
|
+ Elements bhtitle = doc.select("el-input[placeholder~=^编号]");
|
|
|
+ Elements bhtitle1 = doc.select("el-input[placeholder~=合同编号.*]");
|
|
|
+ bhtitle.addAll(bhtitle1);
|
|
|
+
|
|
|
+
|
|
|
+ Elements xmtitle = doc.select("el-input[placeholder~=^项目名称]");
|
|
|
+
|
|
|
+ // 日期默认值
|
|
|
+ Elements dateTitle = doc.select("el-date-picker[placeholder~=日期]");
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 承包单位 承包单位、施工单位:引用施工单位名称 ,
|
|
|
+ * 监理单位:引用监理单位名称
|
|
|
+ * 合同段、所属建设项目(合同段):引用合同段编号
|
|
|
+ *
|
|
|
+ * 施工单位:施工单位 和 安装单位
|
|
|
+ *
|
|
|
+ */
|
|
|
+ ContractInfo contractInfo = contractInfoService.getById(contractId);
|
|
|
+ // 施工单位名称
|
|
|
+ if (dwtitle.size() >= 1) {
|
|
|
+ int y = Integer.parseInt(dwtitle.attr("trindex"));
|
|
|
+ if (y <= 10) {
|
|
|
+ reData.put(dwtitle.attr("keyName"), contractInfo.getConstructionUnitName());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (sgtitle.size() >= 1) {
|
|
|
+ int y = Integer.parseInt(sgtitle.attr("trindex"));
|
|
|
+ if (y <= 10) {
|
|
|
+ reData.put(sgtitle.attr("keyName"), contractInfo.getConstructionUnitName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 合同段名称
|
|
|
+ if (htdtitle.size() >= 1) {
|
|
|
+ for (Element element : htdtitle) {
|
|
|
+ int trindex = Integer.parseInt(element.attr("trindex"));
|
|
|
+ if (trindex <= 8) {
|
|
|
+ reData.put(element.attr("keyName"), contractInfo.getContractNumber());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 监理单位名称
|
|
|
+ if (jltitle.size() >= 1) {
|
|
|
+ for (Element element : jltitle) {
|
|
|
+ int trindex = Integer.parseInt(element.attr("trindex"));
|
|
|
+ if (trindex <= 10) {
|
|
|
+
|
|
|
+ reData.put(element.attr("keyName"), contractInfo.getSupervisionUnitName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 项目名称
|
|
|
+ if (xmtitle.size() >= 1) {
|
|
|
+ for (Element element : xmtitle) {
|
|
|
+ int trindex = Integer.parseInt(element.attr("trindex"));
|
|
|
+ if (trindex <= 6) {
|
|
|
+ ProjectInfo projectInfo = projectInfoService.getById(tableNode2.getProjectId());
|
|
|
+ reData.put(element.attr("keyName"), projectInfo.getProjectName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //日期默认
|
|
|
+ if (dateTitle.size() >= 1) {
|
|
|
+ for (Element element : dateTitle) {
|
|
|
+ int trindex = Integer.parseInt(element.attr("trindex"));
|
|
|
+ if (trindex <= 10) {
|
|
|
+ reData.put(element.attr("keyName"), recordTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 添加默认值
|
|
|
+ Elements elements = doc.getElementsByAttribute("defText");
|
|
|
+ if(Func.isNotEmpty(elements) && elements.size()>=1){
|
|
|
+ for(Element eleme: elements){
|
|
|
+ String id = Func.isNull(eleme.attr("id"))?eleme.attr("keyname"):eleme.attr("id");
|
|
|
+ if(Func.isNotEmpty(id)){
|
|
|
+ reData.put(id, eleme.attr("defText"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (reData.size() > 0) {
|
|
|
+ resultMapList.add(reData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.data(resultMapList);
|
|
|
+ }
|
|
|
+
|
|
|
}
|