|
|
@@ -675,7 +675,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
private List<NodeTable> createNodeTables(Long nodeId, String contractId, String projectId, ExecuteType type ,String tableOwner, String recordId) {
|
|
|
List<NodeTable> tableAll = new ArrayList<>();
|
|
|
if (type.equals(ExecuteType.INSPECTION)) {
|
|
|
- List<AppWbsTreeContractVO> treeNode = wbsTreeContractService.searchNodeAllTable(nodeId.toString(), tableOwner, contractId, projectId, null);
|
|
|
+ List<AppWbsTreeContractVO> treeNode = wbsTreeContractService.searchNodeAllTable(nodeId.toString(), tableOwner);
|
|
|
tableAll = BeanUtil.copyProperties(treeNode, NodeTable.class);
|
|
|
} else if (type.equals(ExecuteType.TESTING)) {
|
|
|
List<WbsTreePrivateVO4> wbsTreePrivateVO4s = wbsTreePrivateService.searchNodeAllTable(nodeId.toString(), "1", "9", contractId, projectId, null, null);
|
|
|
@@ -711,8 +711,14 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
} else {
|
|
|
List<WbsTreeContract> list = wbsTreeContractService.getBaseMapper().selectList(Wrappers.<WbsTreeContract>query().lambda().in(WbsTreeContract::getPKeyId, pkeyIds));
|
|
|
if (list.size() > 0) {
|
|
|
+ Map<String, Map<String, String>> htmlElementCellMap = new HashMap<>();
|
|
|
list.forEach(e -> {
|
|
|
- Map<String, String> elementCell = FormulaUtils.getElementCell(e.getHtmlUrl());
|
|
|
+ Map<String, String> map = htmlElementCellMap.get(e.getHtmlUrl());
|
|
|
+ if (map == null) {
|
|
|
+ map = FormulaUtils.getElementCell(e.getHtmlUrl());
|
|
|
+ htmlElementCellMap.put(e.getHtmlUrl(), map);
|
|
|
+ }
|
|
|
+ Map<String, String> elementCell = map;
|
|
|
//扩展中间元素开发 获取字段是辅助字段 并且在html上没有这个字段
|
|
|
List<String> collect = keyMappers.stream().filter(f -> f.getAssist() == 1
|
|
|
&& elementCell.get(f.getField()) == null).map(KeyMapper::getField).collect(Collectors.toList());
|
|
|
@@ -1371,20 +1377,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
Long projectId = Long.parseLong(wtc.getProjectId());
|
|
|
|
|
|
StringBuilder data = new StringBuilder();
|
|
|
- for (TableInfo tableInfo : tableInfoList) {
|
|
|
- if (pKeyIds.toString().contains(tableInfo.getPkeyId())) {
|
|
|
- LinkedHashMap<String, String> dataMap = tableInfo.getDataMap();
|
|
|
- List<String> keys = pKeyIdKeyMap.get(tableInfo.getPkeyId());
|
|
|
- if (dataMap != null && keys != null) {
|
|
|
- for (String key : keys) {
|
|
|
- String value = dataMap.get(key);
|
|
|
- if (StringUtil.hasText(value)) {
|
|
|
- data.append(value).append(",");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ String resultData = "";
|
|
|
|
|
|
if (currentNode != null) {
|
|
|
TableElementConverter tec = new TableElementConverter(tableInfoList, keyMapperList, formulaList, coordinateMap, currentNode, tableAll);
|
|
|
@@ -1397,7 +1390,6 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
tec.before();
|
|
|
// 暂不执行特殊公式
|
|
|
this.formulaService.init(tec).sort(tec).pre(tec).calculate(tec).format(tec);
|
|
|
- tec.after();
|
|
|
} else {
|
|
|
tec.getLog().put(FormulaLog.OTHER, "没有执行任何公式");
|
|
|
}
|
|
|
@@ -1405,12 +1397,48 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
if (data.length() == 0) {
|
|
|
Map<String, FormData> map = tec.getFormDataMap();
|
|
|
List<String> relyList = formula.getRelyList();
|
|
|
- if (relyList != null) {
|
|
|
+ FormData resultFormData = map.get(wbsTreeTable.getInitTableName() + ":" + split1[0]);
|
|
|
+ int index = 0;
|
|
|
+ if (resultFormData != null && resultFormData.getValues() != null) {
|
|
|
+ List<ElementData> values = resultFormData.getValues();
|
|
|
+ int x = 0, y = 0;
|
|
|
+ if (split1.length > 1 && split1[1].contains("_")) {
|
|
|
+ String[] point = split1[1].split("_");
|
|
|
+ try {
|
|
|
+ y = Integer.parseInt(point[0]);
|
|
|
+ x = Integer.parseInt(point[1]);
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ log.error("坐标转换错误,keyname = " + keyname);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (int i = 0; i < values.size(); i++) {
|
|
|
+ if (values.get(i).getY() == y && values.get(i).getX() == x) {
|
|
|
+ String value = values.get(i).stringValue();
|
|
|
+ if (StringUtil.isBlank( value)) {
|
|
|
+ value = "";
|
|
|
+ if (resultFormData.getInitial().size() > i && resultFormData.getInitial().get(i) != null) {
|
|
|
+ value = resultFormData.getInitial().get(i).stringValue();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resultData = value;
|
|
|
+ index = i;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtil.hasText(resultData) && relyList != null) {
|
|
|
+ int tempIndex = index;
|
|
|
relyList.forEach(rely -> {
|
|
|
FormData formData = map.get(rely);
|
|
|
if (formData != null && formData.getValues() != null) {
|
|
|
- String value = formData.getValues().stream().map(ElementData::getValue).filter(Objects::nonNull).map(Objects::toString).collect(Collectors.joining(","));
|
|
|
- data.append(value).append( "☆");
|
|
|
+ if (formData.getValues().size() > tempIndex) {
|
|
|
+ ElementData elementData = formData.getValues().get(tempIndex);
|
|
|
+ if ((elementData == null || StringUtil.isBlank(elementData.stringValue())) && formData.getInitial() != null && formData.getInitial().size() > tempIndex ) {
|
|
|
+ elementData = formData.getInitial().get(tempIndex);
|
|
|
+ }
|
|
|
+ data.append(elementData == null || elementData.getValue() == null ? "" : elementData.getValue().toString());
|
|
|
+ }
|
|
|
+ data.append(" ,");
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -1424,31 +1452,30 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
result.put("elementName", elementName.length() == 0 ? "" : elementName.deleteCharAt(elementName.length() - 1).toString());
|
|
|
result.put("type", type == 0 ? "计算" : "数据获取");
|
|
|
String sourceData = data.length() == 0 ? "" : data.deleteCharAt(data.length() - 1).toString();
|
|
|
- String resultData = "";
|
|
|
- try {
|
|
|
- resultData = tableInfoList.get(0).getDataMap().get(split1[0]);
|
|
|
- if (split1.length > 1) {
|
|
|
- String index = split1[1];
|
|
|
- String[] split = resultData.split("☆");
|
|
|
- if (split.length > 1) {
|
|
|
- resultData = "";
|
|
|
- }
|
|
|
- for (int i = 0; i < split.length; i++) {
|
|
|
- String string = split[i];
|
|
|
- if (string.contains(index)) {
|
|
|
- resultData = string.split("_\\^_")[0];
|
|
|
- String[] split2 = data.toString().split("☆");
|
|
|
- if (i < split2.length) {
|
|
|
- sourceData = split2[i].split("_\\^_")[0];
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- resultData = resultData.replaceAll("(\" *)","");
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("公式计算异常:" + e.getMessage());
|
|
|
- }
|
|
|
+// try {
|
|
|
+// resultData = tableInfoList.get(0).getDataMap().get(split1[0]);
|
|
|
+// if (split1.length > 1) {
|
|
|
+// String index = split1[1];
|
|
|
+// String[] split = resultData.split("☆");
|
|
|
+// if (split.length > 1) {
|
|
|
+// resultData = "";
|
|
|
+// }
|
|
|
+// for (int i = 0; i < split.length; i++) {
|
|
|
+// String string = split[i];
|
|
|
+// if (string.contains(index)) {
|
|
|
+// resultData = string.split("_\\^_")[0];
|
|
|
+// String[] split2 = data.toString().split("☆");
|
|
|
+// if (i < split2.length) {
|
|
|
+// sourceData = split2[i].split("_\\^_")[0];
|
|
|
+// }
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// resultData = resultData.replaceAll("(\" *)","");
|
|
|
+// } catch (Exception e) {
|
|
|
+// log.error("公式计算异常:" + e.getMessage());
|
|
|
+// }
|
|
|
if (resultData != null) {
|
|
|
resultData = resultData.replaceAll("(_\\^_\\d+_\\d+☆?)",",");
|
|
|
if (!resultData.isEmpty() && resultData.charAt(resultData.length() - 1) == ',') {
|
|
|
@@ -1456,6 +1483,9 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
}
|
|
|
}
|
|
|
if (sourceData != null) {
|
|
|
+ if (resultData == null || resultData.isEmpty()) {
|
|
|
+ sourceData = "";
|
|
|
+ }
|
|
|
sourceData = sourceData.replaceAll("(\" *)","").replaceAll("(_\\^_\\d+_\\d+☆?)",",");
|
|
|
if (!sourceData.isEmpty() && sourceData.charAt(sourceData.length() - 1) == ',') {
|
|
|
sourceData = sourceData.substring(0, sourceData.length() - 1);
|
|
|
@@ -1848,6 +1878,123 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
return R.data(tableInfoList2);
|
|
|
// return R.success(fileName1);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存数据, 仅针对同一节点下的表
|
|
|
+ * @param tableInfoList 表数据
|
|
|
+ * @param flag 是否回滚
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public R<Object> saveOrUpdateInfo1(List<TableInfo> tableInfoList,Boolean flag) {
|
|
|
+ List<TableInfo> tableInfoList2 = new ArrayList<>();
|
|
|
+ String fileName1="";
|
|
|
+ if (ListUtils.isNotEmpty(tableInfoList)) {
|
|
|
+ //施工资料填报
|
|
|
+ String pkids = "";
|
|
|
+ StringBuilder log = new StringBuilder("异常:");
|
|
|
+ StringBuilder saveData = new StringBuilder(tableInfoList.toString());
|
|
|
+ try {
|
|
|
+ Set<Long> pKeyIds = tableInfoList.stream().filter(item -> StringUtil.isNumeric(item.getPkeyId())).map(item -> Long.parseLong(item.getPkeyId())).collect(Collectors.toSet());
|
|
|
+ Map<String, WbsTreeContract> contractMap = new HashMap<>();
|
|
|
+ WbsTreeContract wbsTreeContractByP = null;
|
|
|
+ if (!pKeyIds.isEmpty()) {
|
|
|
+ List<WbsTreeContract> list = wbsTreeContractService.list(Wrappers.<WbsTreeContract>query().lambda().in(WbsTreeContract::getPKeyId, pKeyIds));
|
|
|
+ contractMap = list.stream().collect(toMap(item -> item.getPKeyId() + "", item -> item, (k1, k2) -> k1));
|
|
|
+ Set<Long> pIds = list.stream().filter(item -> item.getPId() != null && item.getPId() > 0).map(WbsTreeContract::getPId).collect(Collectors.toSet());
|
|
|
+ if (!pIds.isEmpty()) {
|
|
|
+ wbsTreeContractByP = wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>query().lambda().in(WbsTreeContract::getPKeyId, pIds).last( " limit 1"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (wbsTreeContractByP == null) {
|
|
|
+ return R.fail("没有找到表单数据对应的节点");
|
|
|
+ }
|
|
|
+ for (TableInfo tableInfo : tableInfoList) {
|
|
|
+ WbsTreeContract wbsTreeContract = contractMap.get(tableInfo.getPkeyId());
|
|
|
+ StringBuilder tableName = new StringBuilder("");
|
|
|
+ if (wbsTreeContract == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ tableInfo.setIsTypePrivatePid(wbsTreeContract.getExcelId()+"");
|
|
|
+ tableInfoList2.add(tableInfo);
|
|
|
+ pkids += tableInfo.getPkeyId() + ",";
|
|
|
+ String tabName = wbsTreeContract.getInitTableName();
|
|
|
+ // 判读修改还是 添加
|
|
|
+ String delSql = "delete from " + tabName + " where p_key_id=" + tableInfo.getPkeyId();
|
|
|
+ String sqlInfo = "";
|
|
|
+ LinkedHashMap<String, String> dataMap2 = tableInfo.getDataMap();
|
|
|
+ /*检查发现有p_key_id缺失的情况,导致表单数据丢失,所以强制覆盖*/
|
|
|
+ dataMap2.put("p_key_id", tableInfo.getPkeyId());
|
|
|
+ dataMap2=isPartition(wbsTreeContract,tabName,dataMap2);
|
|
|
+ sqlInfo = buildMTableInsertSql(tabName, dataMap2, SnowFlakeUtil.getId(), null, null).toString();
|
|
|
+
|
|
|
+ UpdateWrapper<WbsTreeContract> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.in("p_key_id", tableInfo.getPkeyId());
|
|
|
+ updateWrapper.set("is_tab_pdf", 2);
|
|
|
+ BladeUser user = AuthUtil.getUser();
|
|
|
+ TransactionStatus transactionStatus = this.beginTransaction(transactionManager1);
|
|
|
+ try {
|
|
|
+ wbsTreeContractService.update(updateWrapper);
|
|
|
+ //添加被张表的操作日志
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ String sqlInfoNew = sqlInfo.replace("\"", "'");
|
|
|
+ sb.append("insert into blade_tab_sql(p_key_id,user_id,create_time,sql_info) VALUES(");
|
|
|
+ sb.append(tableInfo.getPkeyId());sb.append(",");sb.append(user.getUserId());
|
|
|
+ sb.append(","); sb.append("SYSDATE()");sb.append(",\"");sb.append(sqlInfoNew);
|
|
|
+ sb.append("\")");
|
|
|
+
|
|
|
+ jdbcTemplate.execute(delSql);
|
|
|
+ jdbcTemplate.execute(sqlInfo.replace("\\","\\\\"));
|
|
|
+ jdbcTemplate.execute(sb.toString());
|
|
|
+
|
|
|
+ transactionManager1.commit(transactionStatus);
|
|
|
+ } catch (Exception e) {
|
|
|
+ //是否回滚
|
|
|
+ if(flag){
|
|
|
+ transactionManager1.rollback(transactionStatus);
|
|
|
+ log.append(e.getMessage()).append("@@");
|
|
|
+ e.printStackTrace();
|
|
|
+ return R.fail(reason(e.getMessage()));
|
|
|
+ }else {
|
|
|
+ tableName.append(wbsTreeContract.getNodeName()+",");
|
|
|
+ RandomNumberHolder.setLogMessage(tableName.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //处理文件提名
|
|
|
+ fileName1= this.wbsParamService.createFileTitle(wbsTreeContractByP);
|
|
|
+ if(wbsTreeContractByP.getMajorDataType()!=null&&wbsTreeContractByP.getMajorDataType()==4){
|
|
|
+ String sql1="Select sg_suffix,jl_suffix from m_project_info where id="+wbsTreeContractByP.getProjectId()+" and is_deleted=0";
|
|
|
+ List<ProjectInfo> query = jdbcTemplate.query(sql1, new BeanPropertyRowMapper<>(ProjectInfo.class));
|
|
|
+ if(query.size()>0){
|
|
|
+ if(tableInfoList.get(0).getClassify()!=null&&tableInfoList.get(0).getClassify().equals("1")){
|
|
|
+ fileName1=fileName1+(query.get(0).getSgSuffix()==null?"":query.get(0).getSgSuffix());
|
|
|
+ }else {
|
|
|
+ fileName1=fileName1+(query.get(0).getJlSuffix()==null?"":query.get(0).getJlSuffix());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //huangjn 保存成功后调用生成资料查询列表数据
|
|
|
+ this.informationQueryClient.saveOrUpdateInformationQueryData(wbsTreeContractByP.getPKeyId() + "", "首件使用字段", "业务ID(主要将来给首件使用)", fileName1, Integer.parseInt(tableInfoList.get(0).getClassify()), 2, "false", "源文件(首件字段)", "pdf文件(首件字段)", "首件上传总结报告名称", new ArrayList<>());
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("operationObjIds", Func.toStrList(pkids));
|
|
|
+ json.put("operationObjName", wbsTreeContractByP.getNodeName() + "节点数据操作");
|
|
|
+ json.put("saveData", saveData.toString());
|
|
|
+ json.put("projectId", wbsTreeContractByP.getProjectId());
|
|
|
+ json.put("contractId", wbsTreeContractByP.getContractId());
|
|
|
+
|
|
|
+ //保存操作记录
|
|
|
+ this.operationLogClient.saveUserOperationLog(1, "资料填报", "工序填报页面", json);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return R.fail("操作失败");
|
|
|
+ }
|
|
|
+ if (log.length() > 5) {
|
|
|
+ return R.fail(reason(log.toString()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.data(tableInfoList2);
|
|
|
+ }
|
|
|
public LinkedHashMap<String ,String> isPartition(WbsTreeContract wbsTreeContract,String tabName,LinkedHashMap<String, String> dataMap2){
|
|
|
//判断是否需要移除编号 当工序 子分项 分项的划分编码有一个不为null就移除编号
|
|
|
String sqlContractInfo="select * from m_contract_info where id="+wbsTreeContract.getContractId();
|
|
|
@@ -2849,8 +2996,10 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
if (xx >= all) {
|
|
|
int fisRow = mergedCell.getFirstRow();
|
|
|
int firsrCol = mergedCell.getFirstColumn();
|
|
|
-
|
|
|
Cell cell = sheet.getRow(fisRow).getCell(firsrCol);
|
|
|
+ if(cell==null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
short fontIndex = cell.getCellStyle().getFontIndex();
|
|
|
|
|
|
Font oldfontAt = workbook.getFontAt(fontIndex);
|
|
|
@@ -3302,7 +3451,8 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
public void getBussPdfs(String nodeId, String classify, String contractId, String projectId) throws Exception {
|
|
|
String file_path = FileUtils.getSysLocalFileUrl();
|
|
|
// 获取有权限的节点信息
|
|
|
- List<AppWbsTreeContractVO> wbsTreeContractList = wbsTreeContractService.searchNodeAllTable(nodeId, classify, contractId, projectId, null);
|
|
|
+// List<AppWbsTreeContractVO> wbsTreeContractList = wbsTreeContractService.searchNodeAllTable(nodeId, classify, contractId, projectId, null);
|
|
|
+ List<AppWbsTreeContractVO> wbsTreeContractList = wbsTreeContractService.searchNodeAllTable(nodeId, classify);
|
|
|
List<String> data = new ArrayList<>();
|
|
|
if (nodeId.indexOf(":") >= 0) {
|
|
|
nodeId = nodeId.split(":")[0];
|
|
|
@@ -3332,8 +3482,12 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
}
|
|
|
if (data.size() >= 1) {
|
|
|
//资料填报原始pdf合并
|
|
|
- FileUtils.mergePdfPublicMethods(data, listPdf);
|
|
|
+// FileUtils.mergePdfPublicMethods(data, listPdf);
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
+ FileUtils.mergePDFParallel(data, listPdf);
|
|
|
+ long endTime = System.currentTimeMillis();
|
|
|
BladeFile bladeFile = this.newIOSSClient.uploadFile(nodeId + ".pdf", listPdf);
|
|
|
+ System.out.println("pdf合并耗时:" + (endTime - startTime) + "ms, pdf合并个数:" + data.size() + ", pdf 上传耗时:" + (System.currentTimeMillis() - endTime) + "ms");
|
|
|
if(bladeFile == null){
|
|
|
System.out.println("Oss上传失败");
|
|
|
}
|