|
@@ -49,6 +49,7 @@ import java.net.URLEncoder;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Path;
|
|
|
import java.nio.file.Paths;
|
|
|
+import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.List;
|
|
@@ -280,6 +281,12 @@ public class WbsTreeContractController extends BladeController {
|
|
|
return R.data(list);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 客户端-下载元素表对应的excel模板
|
|
|
+ *
|
|
|
+ * @author liuyc
|
|
|
+ * @date 2023年8月30日15:44:55
|
|
|
+ */
|
|
|
@SneakyThrows
|
|
|
@GetMapping("/download-excel")
|
|
|
@ApiOperationSupport(order = 13)
|
|
@@ -355,7 +362,7 @@ public class WbsTreeContractController extends BladeController {
|
|
|
try (ServletOutputStream outputStream = response.getOutputStream();
|
|
|
ByteArrayOutputStream byteArrayOutputStreamResult = new ByteArrayOutputStream()) {
|
|
|
//设置响应头
|
|
|
- response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(tab.getFullName(), "UTF-8") + ".xlsx");
|
|
|
+ response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(ObjectUtil.isNotEmpty(tab.getFullName()) ? tab.getFullName() : tab.getNodeName(), "UTF-8") + ".xlsx");
|
|
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
poiWorkbook.write(byteArrayOutputStreamResult);
|
|
|
byte[] excelBytesResult = byteArrayOutputStreamResult.toByteArray();
|
|
@@ -439,6 +446,12 @@ public class WbsTreeContractController extends BladeController {
|
|
|
cellStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 客户端-导入excel数据到对应元素表中
|
|
|
+ *
|
|
|
+ * @author liuyc
|
|
|
+ * @date 2023年8月29日
|
|
|
+ */
|
|
|
@PostMapping("/import-excel")
|
|
|
@ApiOperationSupport(order = 14)
|
|
|
@ApiOperation(value = "客户端-导入excel数据到对应元素表中", notes = "传入表的pKeyId、excel文件file")
|
|
@@ -456,6 +469,7 @@ public class WbsTreeContractController extends BladeController {
|
|
|
String doubleSlashRegex_XG = ".*\\/[^\\/]*\\/.*"; //匹配包含两个斜杠且不相邻的字符串
|
|
|
String dateFormatRegex_yyyyMdd = "\\d{4}/\\d{1,2}/\\d{1,2}"; //yyyy/M/dd格式
|
|
|
String dateFormatRegex_yyyyMMdd = "\\d{4}/\\d{2}/\\d{2}"; //yyyy/MM/dd格式
|
|
|
+ String dateFormatRegex_chinese = "(\\d{4}年\\d{1,2}月\\d{1,2}日|\\d{4}年\\d{2}月\\d{2}日)"; //“2023年1月1日、2023年01月01日”这两种格式
|
|
|
SimpleDateFormat inputDateFormat = new SimpleDateFormat("yyyy/M/dd");
|
|
|
SimpleDateFormat outputDateFormat = new SimpleDateFormat("yyyy年MM月dd日");
|
|
|
|
|
@@ -490,12 +504,16 @@ public class WbsTreeContractController extends BladeController {
|
|
|
for (int j = 0; j < tdElements1.size(); j++) {
|
|
|
Element td1 = tdElements1.get(j);
|
|
|
Element td2 = tdElements2.get(j);
|
|
|
- //String x1 = getX1Attribute(td1);
|
|
|
- //String y1 = getY1Attribute(td1);
|
|
|
String keyName = getKeyNameFromChildElement(td1);
|
|
|
if (StringUtils.isNotEmpty(keyName)) {
|
|
|
String divValue = td2.text(); //获取文本值
|
|
|
if (StringUtils.isNotEmpty(divValue)) {
|
|
|
+ if (parseDateRange(divValue).size() == 2) {
|
|
|
+ //判断范围日期
|
|
|
+ List<String> dateArr = parseDateRange(divValue);
|
|
|
+ stringStringMap.put(keyName, dateArr);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
//判断是否存在两个斜杠,且不在一起,那么视为日期格式
|
|
|
Pattern pattern_XG = Pattern.compile(doubleSlashRegex_XG);
|
|
|
Matcher matcher_XG = pattern_XG.matcher(divValue);
|
|
@@ -512,8 +530,16 @@ public class WbsTreeContractController extends BladeController {
|
|
|
Date date = inputDateFormat.parse(divValue);
|
|
|
divValue = outputDateFormat.format(date);
|
|
|
}
|
|
|
+
|
|
|
+ } else if (divValue.contains("年") && divValue.contains("月") && divValue.contains("日")) {
|
|
|
+ //判断如:“2023年1月1日、2023年01月01日”这两种格式
|
|
|
+ Pattern pattern_chinese = Pattern.compile(dateFormatRegex_chinese);
|
|
|
+ Matcher matcher_chinese = pattern_chinese.matcher(divValue);
|
|
|
+ if (matcher_chinese.matches()) {
|
|
|
+ Date date = outputDateFormat.parse(divValue);
|
|
|
+ divValue = outputDateFormat.format(date);
|
|
|
+ }
|
|
|
}
|
|
|
- //String mapKey = keyName + "***" + x1 + "_" + y1;
|
|
|
stringStringMap.put(keyName, divValue);
|
|
|
}
|
|
|
}
|
|
@@ -552,6 +578,53 @@ public class WbsTreeContractController extends BladeController {
|
|
|
return R.data(null, "没有获取到excel中的数据");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 判断日期范围格式数据,以下12种格式
|
|
|
+ * 2023-01-01-2023-01-30 或 2023-01-01~2023-01-30
|
|
|
+ * 2023-1-1-2023-1-30 或 2023-1-1~2023-1-30
|
|
|
+ * 2023/01/01-2023/01/30 或 2023/01/01~2023/01/30
|
|
|
+ * 2023/1/1-2023/1/30 或 2023/1/1~2023/1/30
|
|
|
+ * 2023年01月01日-2023年01月30日 或 2023年01月01日~2023年01月30日
|
|
|
+ * 2023年1月1日-2023年1月30日 或 2023年1月1日~2023年01月30日
|
|
|
+ *
|
|
|
+ * @param inputDateStr
|
|
|
+ * @return
|
|
|
+ * @throws ParseException
|
|
|
+ */
|
|
|
+ public static List<String> parseDateRange(String inputDateStr) throws ParseException {
|
|
|
+ String[] patterns = {
|
|
|
+ "(\\d{4}[年\\/-]\\d{1,2}[月\\/-]\\d{1,2}[日]?)[-~](\\d{4}[年\\/-]\\d{1,2}[月\\/-]\\d{1,2}[日]?)"
|
|
|
+ };
|
|
|
+ for (String pattern : patterns) {
|
|
|
+ Pattern regex = Pattern.compile(pattern);
|
|
|
+ Matcher matcher = regex.matcher(inputDateStr);
|
|
|
+ if (matcher.find()) {
|
|
|
+ String startDateStr = matcher.group(1);
|
|
|
+ String endDateStr = matcher.group(2);
|
|
|
+ boolean var1 = startDateStr.contains("年");
|
|
|
+ boolean var2 = startDateStr.contains("-");
|
|
|
+ boolean var3 = startDateStr.contains("/");
|
|
|
+ SimpleDateFormat inputDateFormat = null;
|
|
|
+ SimpleDateFormat outputDateFormat = new SimpleDateFormat("yyyy年MM月dd日");
|
|
|
+ if (var1) {
|
|
|
+ inputDateFormat = new SimpleDateFormat("yyyy年MM月dd日");
|
|
|
+ } else if (var2) {
|
|
|
+ inputDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ } else if (var3) {
|
|
|
+ inputDateFormat = new SimpleDateFormat("yyyy/MM/dd");
|
|
|
+ }
|
|
|
+ if (inputDateFormat != null) {
|
|
|
+ Date startDate = inputDateFormat.parse(startDateStr);
|
|
|
+ Date endDate = inputDateFormat.parse(endDateStr);
|
|
|
+ String resultStartDateStr = outputDateFormat.format(startDate);
|
|
|
+ String resultEndDateStr = outputDateFormat.format(endDate);
|
|
|
+ return Arrays.asList(resultStartDateStr, resultEndDateStr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+
|
|
|
private static boolean deleteFolder(Path folderPath) throws IOException {
|
|
|
if (Files.exists(folderPath)) {
|
|
|
Files.walk(folderPath)
|
|
@@ -574,14 +647,6 @@ public class WbsTreeContractController extends BladeController {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- private static String getX1Attribute(Element element) {
|
|
|
- return element.select("[x1]").attr("x1");
|
|
|
- }
|
|
|
-
|
|
|
- private static String getY1Attribute(Element element) {
|
|
|
- return element.select("[y1]").attr("y1");
|
|
|
- }
|
|
|
-
|
|
|
private static String getKeyNameFromChildElement(Element element) {
|
|
|
//TODO Element UI的时间标签待补全
|
|
|
String[] tagNames = {"el-input", "el-date-picker", "el-time-picker", "hc-form-select-search", "hc-table-form-upload", "hc-form-checkbox-group", "el-radio-group", "el-select"};
|
|
@@ -608,6 +673,14 @@ public class WbsTreeContractController extends BladeController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 懒加载获取合同段隐蔽工程节点树
|
|
|
+ *
|
|
|
+ * @param contractId
|
|
|
+ * @param parentId
|
|
|
+ * @author liuyc
|
|
|
+ * @date 2023年8月30日15:44:28
|
|
|
+ */
|
|
|
@PostMapping("/getConcealedWorksNodeTree")
|
|
|
@ApiOperationSupport(order = 15)
|
|
|
@ApiOperation(value = "懒加载获取合同段隐蔽工程节点树", notes = "传入合同段id、父级id")
|