|
@@ -169,7 +169,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
User user = userMapper.selectById(token);
|
|
|
taskDto.setCompanyId(user.getCompanyId());
|
|
|
List<TaskExecutor> taskExecutorList = taskExecutorMapper.selectList(new LambdaQueryWrapper<TaskExecutor>().eq(TaskExecutor::getCompanyId,user.getCompanyId()));
|
|
|
- List<TaskLog> taskLogList = taskLogMapper.selectList(new LambdaQueryWrapper<TaskLog>().eq(TaskLog::getCompanyId,user.getCompanyId()));
|
|
|
+ List<TaskLog> taskLogList = taskLogMapper.selectList(new LambdaQueryWrapper<TaskLog>().eq(TaskLog::getCompanyId,user.getCompanyId()).orderByDesc(TaskLog::getModTime));
|
|
|
taskDto.setPageIndex((taskDto.getPageIndex()-1)*taskDto.getPageSize());
|
|
|
List<TasKVo> taskVoList =taskMapper.getPageListTask(taskDto);
|
|
|
for (TasKVo tasKVo : taskVoList) {
|
|
@@ -249,6 +249,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
taskLog.setContent("修改了任务");
|
|
|
taskLog.setUserId(user.getId());
|
|
|
taskLog.setUserName(user.getName());
|
|
|
+ taskLog.setCompanyId(user.getCompanyId());
|
|
|
taskLogMapper.insert(taskLog);
|
|
|
|
|
|
return msg;
|
|
@@ -343,7 +344,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
JSONObject item = configObJSONArray.getJSONObject(i);
|
|
|
String modelName = item.getString("model");
|
|
|
HSSFCell cell = row.getCell(i);
|
|
|
- if(cell!=null){
|
|
|
+ if(cell!=null&&StringUtils.isNotEmpty(cell.getStringCellValue())){
|
|
|
switch (item.getString("type")){
|
|
|
case "time":cell.setCellType(CellType.NUMERIC);
|
|
|
System.out.println(cell.getNumericCellValue());
|
|
@@ -395,6 +396,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
task.setCompanyId(companyId);
|
|
|
task.setCreaterId(user.getId());
|
|
|
task.setCreateDate(LocalDateTime.now());
|
|
|
+ task.setStatus(0);
|
|
|
for (int i = 0; i < cellNum; i++) {
|
|
|
JSONObject item = configObJSONArray.getJSONObject(i);
|
|
|
String modelName = item.getString("model");
|
|
@@ -402,7 +404,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
String getter="get"+className;
|
|
|
String setter="set"+className;
|
|
|
HSSFCell cell = row.getCell(i);
|
|
|
- if(cell!=null){
|
|
|
+ if(cell!=null&&StringUtils.isNotEmpty(cell.getStringCellValue())){
|
|
|
switch (item.getString("type")){
|
|
|
case "time":cell.setCellType(CellType.NUMERIC);
|
|
|
System.out.println(cell.getNumericCellValue());
|
|
@@ -412,10 +414,10 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
default:cell.setCellType(CellType.STRING);
|
|
|
}
|
|
|
}
|
|
|
- Class<Task> taskClass = Task.class;
|
|
|
- Field field = taskClass.getDeclaredField(modelName);
|
|
|
- Class<?> type = field.getType();
|
|
|
- Method method = taskClass.getMethod(setter, type);
|
|
|
+// Class<Task> taskClass = Task.class;
|
|
|
+// Field field = taskClass.getDeclaredField(modelName);
|
|
|
+// Class<?> type = field.getType();
|
|
|
+// Method method = taskClass.getMethod(setter, type);
|
|
|
//校验当前列是否为必填
|
|
|
JSONObject options = item.getJSONObject("options");
|
|
|
JSONObject rules = options.getJSONObject("rules");
|
|
@@ -688,8 +690,14 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
taskLog.setCompanyId(user.getCompanyId());
|
|
|
taskLogs.add(taskLog);
|
|
|
}
|
|
|
- boolean b1 = taskExecutorService.saveOrUpdateBatch(taskExecutors);
|
|
|
- boolean b2 = taskLogService.saveOrUpdateBatch(taskLogs);
|
|
|
+
|
|
|
+ boolean b1 = true;
|
|
|
+ boolean b2 = true;
|
|
|
+ if (!taskExecutors.isEmpty()) {
|
|
|
+ b1=taskExecutorService.saveOrUpdateBatch(taskExecutors);
|
|
|
+ }if (!taskLogs.isEmpty()){
|
|
|
+ b2=taskLogService.saveOrUpdateBatch(taskLogs);
|
|
|
+ }
|
|
|
if (b1&&b2){
|
|
|
return msg;
|
|
|
}else {
|
|
@@ -770,7 +778,22 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
value = String.valueOf(aClass.getMethod("getTaskName").invoke(tasKVo)).equals("null")?"":String.valueOf(aClass.getMethod("getTaskName").invoke(tasKVo));
|
|
|
}
|
|
|
else if(model.equals("priority")){
|
|
|
- value = String.valueOf(aClass.getMethod("getPriority").invoke(tasKVo)).equals("null")?"":String.valueOf(aClass.getMethod("getPriority").invoke(tasKVo));
|
|
|
+// 0-低 1-中 2-高
|
|
|
+ Integer priority = tasKVo.getPriority();
|
|
|
+ switch (priority){
|
|
|
+ case 0:
|
|
|
+ value ="低";
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ value="中";
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ value="高";
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ value="";
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
else if(model.equals("executorId")){
|
|
|
StringJoiner stringJoiner = new StringJoiner(",");
|
|
@@ -785,15 +808,19 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
else if(model.equals("startDate")){
|
|
|
if (tasKVo.getStartDate()!=null){
|
|
|
LocalDateTime startDate = tasKVo.getStartDate();
|
|
|
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- value=format.format(startDate);
|
|
|
+ // 定义日期时间格式
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ // 格式化为字符串
|
|
|
+ value= startDate.format(formatter);
|
|
|
}
|
|
|
}
|
|
|
else if(model.equals("endDate")){
|
|
|
if (tasKVo.getEndDate()!=null){
|
|
|
LocalDateTime endDate = tasKVo.getEndDate();
|
|
|
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- value=format.format(endDate);
|
|
|
+ // 定义日期时间格式
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ // 格式化为字符串
|
|
|
+ value= endDate.format(formatter);
|
|
|
}
|
|
|
}
|
|
|
else if(model.equals("customId")){
|
|
@@ -840,6 +867,140 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg exportDataByTaskIds(String taskIds, HttpServletRequest request) throws Exception {
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
+ SysForm sysForm = sysFormMapper.selectOne(new LambdaQueryWrapper<SysForm>().eq(SysForm::getCompanyId, user.getCompanyId()).eq(SysForm::getCode, "Task").eq(SysForm::getIsCurrent, 1));
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoService.getOne(new LambdaQueryWrapper<WxCorpInfo>().eq(WxCorpInfo::getCompanyId, user.getCompanyId()));
|
|
|
+ List<TaskExecutor> taskExecutorList = taskExecutorMapper.selectList(new LambdaQueryWrapper<TaskExecutor>().eq(TaskExecutor::getCompanyId,user.getCompanyId()));
|
|
|
+ List<TaskLog> taskLogList = taskLogMapper.selectList(new LambdaQueryWrapper<TaskLog>().eq(TaskLog::getCompanyId,user.getCompanyId()));
|
|
|
+ String config = sysForm.getConfig();
|
|
|
+ JSONObject configOb = JSON.parseObject(config);
|
|
|
+ JSONArray configObJSONArray = configOb.getJSONArray("list");
|
|
|
+ List<List<String>> dataList=new ArrayList<>();
|
|
|
+ List<String> titleList=new ArrayList<>();
|
|
|
+ for (int i = 0; i < configObJSONArray.size(); i++) {
|
|
|
+ JSONObject item = configObJSONArray.getJSONObject(i);
|
|
|
+ titleList.add(item.getString("label"));
|
|
|
+ }
|
|
|
+ dataList.add(titleList);//设置表头
|
|
|
+
|
|
|
+ List<TasKVo> taskVoList=new ArrayList<>();
|
|
|
+ if (StringUtils.isNotEmpty(taskIds)){
|
|
|
+ String[] taskIdArray = taskIds.split(",");
|
|
|
+ taskVoList =taskMapper.getListByTaskIds(taskIdArray);
|
|
|
+ }
|
|
|
+ if (!taskVoList.isEmpty()){
|
|
|
+ for (TasKVo tasKVo : taskVoList) {
|
|
|
+ if (!taskExecutorList.isEmpty()){
|
|
|
+ List<TaskExecutor> collect = taskExecutorList.stream().
|
|
|
+ filter(taskExecutor -> taskExecutor.getTaskId().equals(tasKVo.getId())).
|
|
|
+ filter(taskExecutor -> taskExecutor.getCompanyId().equals(user.getCompanyId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!collect.isEmpty()){
|
|
|
+ List<String> collect1 = collect.stream().map(TaskExecutor::getExecutorName).collect(Collectors.toList());
|
|
|
+ tasKVo.setTaskExecutors(collect1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (TasKVo tasKVo : taskVoList) {
|
|
|
+ List<String> item=new ArrayList<>();
|
|
|
+ for (int i = 0; i < configObJSONArray.size(); i++) {
|
|
|
+ JSONObject target = configObJSONArray.getJSONObject(i);
|
|
|
+ String model = target.getString("model");
|
|
|
+// String targetName = model.substring(0, 1).toUpperCase() + model.substring(1);
|
|
|
+ Class<? extends TasKVo> aClass = tasKVo.getClass();
|
|
|
+ String value="";
|
|
|
+// String value = String.valueOf(aClass.getMethod("get" + targetName).invoke(tasKVo)==null?"":aClass.getMethod("get" + targetName).invoke(tasKVo));
|
|
|
+ /*if(model.equals("inchargerId")){
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ value = "$userName"+String.valueOf(aClass.getMethod("getInchargerName").invoke(product))+"$";
|
|
|
+ }else {
|
|
|
+ value = String.valueOf(aClass.getMethod("getInchargerName").invoke(product));
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ /*if(model.equals("sex")){
|
|
|
+ value = String.valueOf(aClass.getMethod("getSex").invoke(tasKVo)).equals("null") ?"":String.valueOf(aClass.getMethod("getSex").invoke(tasKVo));
|
|
|
+ }*/
|
|
|
+ if(model.equals("taskName")){
|
|
|
+ value = String.valueOf(aClass.getMethod("getTaskName").invoke(tasKVo)).equals("null")?"":String.valueOf(aClass.getMethod("getTaskName").invoke(tasKVo));
|
|
|
+ }
|
|
|
+ else if(model.equals("priority")){
|
|
|
+// 0-低 1-中 2-高
|
|
|
+ Integer priority = tasKVo.getPriority();
|
|
|
+ switch (priority){
|
|
|
+ case 0:
|
|
|
+ value ="低";
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ value="中";
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ value="高";
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ value="";
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(model.equals("executorId")){
|
|
|
+ StringJoiner stringJoiner = new StringJoiner(",");
|
|
|
+ List<String> taskExecutors = tasKVo.getTaskExecutors();
|
|
|
+ if (taskExecutors!=null&&!taskExecutors.isEmpty()){
|
|
|
+ for (String taskExecutor : taskExecutors) {
|
|
|
+ stringJoiner.add(taskExecutor);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ value =stringJoiner.length()==0?"":stringJoiner.toString();
|
|
|
+ }
|
|
|
+ else if(model.equals("startDate")){
|
|
|
+ if (tasKVo.getStartDate()!=null){
|
|
|
+ LocalDateTime startDate = tasKVo.getStartDate();
|
|
|
+ // 定义日期时间格式
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ // 格式化为字符串
|
|
|
+ value= startDate.format(formatter);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(model.equals("endDate")){
|
|
|
+ if (tasKVo.getEndDate()!=null){
|
|
|
+ LocalDateTime endDate = tasKVo.getEndDate();
|
|
|
+ // 定义日期时间格式
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ // 格式化为字符串
|
|
|
+ value= endDate.format(formatter);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(model.equals("customId")){
|
|
|
+ value = String.valueOf(aClass.getMethod("getCustomName").invoke(tasKVo)).equals("null")?"":String.valueOf(aClass.getMethod("getCustomName").invoke(tasKVo));
|
|
|
+ }
|
|
|
+ else if(model.equals("businessOpportunityId")){
|
|
|
+ value = String.valueOf(aClass.getMethod("getBusinessName").invoke(tasKVo)).equals("null")?"":String.valueOf(aClass.getMethod("getBusinessName").invoke(tasKVo));
|
|
|
+ }
|
|
|
+ else if(model.equals("orderId")){
|
|
|
+ value = String.valueOf(aClass.getMethod("getOrderName").invoke(tasKVo)).equals("null")?"":String.valueOf(aClass.getMethod("getOrderName").invoke(tasKVo));
|
|
|
+ }
|
|
|
+ else if(model.equals("clueId")){
|
|
|
+ value = String.valueOf(aClass.getMethod("getClueName").invoke(tasKVo)).equals("null")?"":String.valueOf(aClass.getMethod("getClueName").invoke(tasKVo));
|
|
|
+ }
|
|
|
+ else if(model.equals("contactsId")){
|
|
|
+ value = String.valueOf(aClass.getMethod("getContactsName").invoke(tasKVo)).equals("null")?"":String.valueOf(aClass.getMethod("getContactsName").invoke(tasKVo));
|
|
|
+ }
|
|
|
+ else if(model.equals("phone")){
|
|
|
+ value = String.valueOf(aClass.getMethod("getContactsPhone").invoke(tasKVo)).equals("null")?"":String.valueOf(aClass.getMethod("getContactsPhone").invoke(tasKVo));
|
|
|
+ }
|
|
|
+ item.add(value);
|
|
|
+ }
|
|
|
+ dataList.add(item);
|
|
|
+ }
|
|
|
+ String fileName="任务表导出_"+ System.currentTimeMillis();
|
|
|
+ return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo,fileName,dataList,path);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
public void updateTaskRepeatConfigure(Task task){
|
|
|
task.setRepeatType(null).setRepeatEndNever(null).setRepeatEndCount(null)
|
|
|
.setRepeatEndDate(null).setRepeatDesignDay(null).setRepeatDesignSameday(null);
|