|
@@ -39,6 +39,8 @@ import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -307,18 +309,27 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
if(cell!=null){
|
|
|
switch (item.getString("type")){
|
|
|
case "time":cell.setCellType(CellType.NUMERIC);
|
|
|
+ System.out.println(cell.getNumericCellValue());
|
|
|
break;
|
|
|
case "int":cell.setCellType(CellType.NUMERIC);
|
|
|
break;
|
|
|
default:cell.setCellType(CellType.STRING);
|
|
|
}
|
|
|
}
|
|
|
- if(modelName.equals("inchargerId")){
|
|
|
- if(!org.springframework.util.StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
- userNameList.add(cell.getStringCellValue());
|
|
|
+ if(modelName.equals("executorId")){
|
|
|
+ if(!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
+ List<String> executorNames = new ArrayList<>();
|
|
|
+ String stringCellValue = cell.getStringCellValue();
|
|
|
+ // 定义正则表达式,匹配中文字符、英文字符、数字
|
|
|
+ Pattern pattern = Pattern.compile("[\\u4e00-\\u9fa5a-zA-Z0-9]+");
|
|
|
+ Matcher matcher = pattern.matcher(stringCellValue);
|
|
|
+ while (matcher.find()) {
|
|
|
+ // 将匹配到的部分添加到人名列表中
|
|
|
+ executorNames.add(matcher.group());
|
|
|
+ }
|
|
|
+ userNameList.addAll(executorNames);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -357,6 +368,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
if(cell!=null){
|
|
|
switch (item.getString("type")){
|
|
|
case "time":cell.setCellType(CellType.NUMERIC);
|
|
|
+ System.out.println(cell.getNumericCellValue());
|
|
|
break;
|
|
|
case "int":cell.setCellType(CellType.NUMERIC);
|
|
|
break;
|
|
@@ -386,21 +398,39 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
}
|
|
|
}
|
|
|
}*/
|
|
|
- if(modelName.equals("inchargerId")){
|
|
|
+ if(modelName.equals("executorId")){
|
|
|
if(!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
- String userName = cell.getStringCellValue();
|
|
|
- Optional<User> first;
|
|
|
- if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
- Optional<User> optional = targetUserList.stream().filter(tl -> tl.getName().equals(userName)).findFirst();
|
|
|
- first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(userName))||(optional.isPresent()&&u.getCorpwxUserid()!=null&&u.getCorpwxUserid().equals(optional.get().getCorpwxUserid()))).findFirst();
|
|
|
- }else {
|
|
|
- first= userList.stream().filter(u -> u.getName().equals(userName)||(u.getJobNumber()!=null&&u.getJobNumber().equals(userName))).findFirst();
|
|
|
+
|
|
|
+ List<String> executorNames = new ArrayList<>();
|
|
|
+ String stringCellValue = cell.getStringCellValue();
|
|
|
+ // 定义正则表达式,匹配中文字符、英文字符、数字
|
|
|
+ Pattern pattern = Pattern.compile("[\\u4e00-\\u9fa5a-zA-Z0-9]+");
|
|
|
+ Matcher matcher = pattern.matcher(stringCellValue);
|
|
|
+ while (matcher.find()) {
|
|
|
+ // 将匹配到的部分添加到人名列表中
|
|
|
+ executorNames.add(matcher.group());
|
|
|
+ }
|
|
|
+
|
|
|
+ ArrayList<String> executorIds = new ArrayList<>();
|
|
|
+ for (String userName : executorNames) {
|
|
|
+ Optional<User> first;
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ Optional<User> optional = targetUserList.stream().filter(tl -> tl.getName().equals(userName)).findFirst();
|
|
|
+ first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(userName))||(optional.isPresent()&&u.getCorpwxUserid()!=null&&u.getCorpwxUserid().equals(optional.get().getCorpwxUserid()))).findFirst();
|
|
|
+ }else {
|
|
|
+ first= userList.stream().filter(u -> u.getName().equals(userName)||(u.getJobNumber()!=null&&u.getJobNumber().equals(userName))).findFirst();
|
|
|
+ }
|
|
|
+ if (first.isPresent()) {
|
|
|
+ executorNames.add(first.get().getId());
|
|
|
+ } else {
|
|
|
+ throw new Exception("["+userName+"]在系统中不存在");
|
|
|
+ }
|
|
|
}
|
|
|
- if (first.isPresent()) {
|
|
|
- task.setOwnerId(first.get().getId());
|
|
|
- } else {
|
|
|
- throw new Exception("["+userName+"]在系统中不存在");
|
|
|
+ StringJoiner joiner = new StringJoiner(",");
|
|
|
+ for (String executorId : executorIds) {
|
|
|
+ joiner.add(executorId);
|
|
|
}
|
|
|
+ task.setExecutorId(joiner.toString()==null?"":joiner.toString());
|
|
|
}
|
|
|
}
|
|
|
/*if(cell.getCellType()==CellType.STRING.getCode()&&!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
@@ -409,19 +439,38 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
|
|
|
|
|
|
}*/
|
|
|
- if (cell != null && cell.getCellTypeEnum() != CellType.BLANK) {
|
|
|
- if (cell.getCellTypeEnum() == CellType.STRING && cell.getStringCellValue() != null && !cell.getStringCellValue().isEmpty()) {
|
|
|
- // 字符串类型不为空
|
|
|
- method.invoke(task,cell.getStringCellValue());
|
|
|
- } else if (cell.getCellTypeEnum() == CellType.NUMERIC) {
|
|
|
- // 数值类型不为空
|
|
|
- double numericCellValue = cell.getNumericCellValue();
|
|
|
- if (type.getSimpleName().equals("Integer")){
|
|
|
- int intValue = (int) numericCellValue;
|
|
|
- method.invoke(task,intValue);
|
|
|
+ if(modelName.equals("taskName")){
|
|
|
+ if(!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
+ task.setTaskName(cell.getStringCellValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(modelName.equals("priority")){
|
|
|
+ if(!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
+ switch (cell.getStringCellValue()){
|
|
|
+ case "底":task.setStatus(0);
|
|
|
+ break;
|
|
|
+ case "中":task.setStatus(1);
|
|
|
+ break;
|
|
|
+ case "高":task.setStatus(2);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(modelName.equals("startDate")){
|
|
|
+ if(cell != null && cell.getCellTypeEnum() != CellType.BLANK){
|
|
|
+ if (cell.getCellTypeEnum() == CellType.NUMERIC){
|
|
|
+ double numericCellValue = cell.getNumericCellValue();
|
|
|
+ long daysSince1900 = (long) numericCellValue - 2;
|
|
|
+ task.setStartDate(LocalDate.of(1900, 1, 1).plusDays(daysSince1900));
|
|
|
}
|
|
|
- else {
|
|
|
- method.invoke(task, numericCellValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(modelName.equals("endDate")){
|
|
|
+ if(cell != null && cell.getCellTypeEnum() != CellType.BLANK){
|
|
|
+ if (cell.getCellTypeEnum() == CellType.NUMERIC){
|
|
|
+ double numericCellValue = cell.getNumericCellValue();
|
|
|
+ long daysSince1900 = (long) numericCellValue - 2;
|
|
|
+ task.setEndDate(LocalDate.of(1900, 1, 1).plusDays(daysSince1900));
|
|
|
}
|
|
|
}
|
|
|
}
|