|
@@ -42,6 +42,7 @@ import java.util.*;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -85,9 +86,25 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
@Resource
|
|
|
private TaskLogService taskLogService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private CustomMapper customMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private BusinessOpportunityMapper businessOpportunityMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private OrderMapper orderMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ClueMapper clueMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ContactsMapper contactsMapper;
|
|
|
+
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public HttpRespMsg addTask(TaskDto taskDto, HttpServletRequest request) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
|
|
@@ -134,7 +151,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
User selectedUser = userMapper.selectById(executorId);
|
|
|
taskExecutor.setExecutorId(executorId)
|
|
|
.setTaskId(task.getId())
|
|
|
- .setExecutorName(selectedUser.getName());
|
|
|
+ .setExecutorName(selectedUser.getName())
|
|
|
+ .setCompanyId(user.getCompanyId());
|
|
|
taskExecutorMapper.insert(taskExecutor);
|
|
|
}
|
|
|
}
|
|
@@ -146,6 +164,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
taskLog.setUserId(userId);
|
|
|
taskLog.setUserName(user.getName());
|
|
|
taskLog.setModTime(LocalDateTime.now());
|
|
|
+ taskLog.setCompanyId(user.getCompanyId());
|
|
|
taskLogMapper.insert(taskLog);
|
|
|
|
|
|
|
|
@@ -158,7 +177,33 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
String token = String.valueOf(request.getHeader("Token"));
|
|
|
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<TasKVo> taskVoList =taskMapper.getPageListTask(taskDto);
|
|
|
+ for (TasKVo tasKVo : taskVoList) {
|
|
|
+ System.out.println(tasKVo.getStartDate());
|
|
|
+ System.out.println(tasKVo.getEndDate());
|
|
|
+ System.out.println(tasKVo.getCreateDate());
|
|
|
+ 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::getExecutorId).collect(Collectors.toList());
|
|
|
+ ArrayList<String> taskExecutorIds = new ArrayList<>(collect1);
|
|
|
+ tasKVo.setTaskExecutors(taskExecutorIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!taskLogList.isEmpty()){
|
|
|
+ List<TaskLog> collect = taskLogList.stream().filter(taskLog -> taskLog.getTaskId().equals(tasKVo.getId()))
|
|
|
+ .filter(taskLog -> taskLog.getCompanyId().equals(user.getCompanyId())).collect(Collectors.toList());
|
|
|
+ if (!collect.isEmpty()){
|
|
|
+ tasKVo.setTaskLogs(collect);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
if (!taskVoList.isEmpty()){
|
|
|
taskVoList.forEach(tasKVo -> {
|
|
|
if (!tasKVo.getTaskExecutors().isEmpty()){
|
|
@@ -180,7 +225,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public HttpRespMsg updateTask(TaskDto taskDto, HttpServletRequest request) {
|
|
|
HttpRespMsg msg=new HttpRespMsg();
|
|
|
String token = String.valueOf(request.getHeader("Token"));
|
|
@@ -234,7 +279,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public HttpRespMsg deleteTasks(List<Integer> taskIds) {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
List<Task> taskList = taskMapper.selectList(new QueryWrapper<Task>().in("id", taskIds));
|
|
@@ -296,6 +341,12 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
List<String> userNameList=new ArrayList<>();
|
|
|
HttpRespMsg respMsg=new HttpRespMsg();
|
|
|
|
|
|
+ List<Contacts> contactsList = contactsMapper.selectList(new LambdaQueryWrapper<Contacts>().eq(Contacts::getIsDelete,0).eq(Contacts::getCompanyId, user.getCompanyId()));
|
|
|
+ List<Custom> customList=customMapper.selectList(new LambdaQueryWrapper<Custom>().eq(Custom::getCompanyId, user.getCompanyId()).eq(Custom::getIsDelete,0));
|
|
|
+ List<BusinessOpportunity> opportunityList = businessOpportunityMapper.selectList(new LambdaQueryWrapper<BusinessOpportunity>()
|
|
|
+ .eq(BusinessOpportunity::getCompanyId, user.getCompanyId()).eq(BusinessOpportunity::getIsDelete, 0));
|
|
|
+ List<Order> orderList = orderMapper.getList(user);
|
|
|
+ List<Clue> clueList = clueMapper.selectList(new LambdaQueryWrapper<Clue>().eq(Clue::getCompanyId, user.getCompanyId()).eq(Clue::getIsDelete, 0).orderByDesc(Clue::getCreateTime));
|
|
|
for (int rowIndex = 1; rowIndex <= rowNum; rowIndex++) {
|
|
|
HSSFRow row = sheet.getRow(rowIndex);
|
|
|
if (row == null) {
|
|
@@ -405,7 +456,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
}
|
|
|
}*/
|
|
|
if(modelName.equals("executorId")){
|
|
|
- if(!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
+ if(cell!=null&&!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
|
|
|
List<String> executorNames = new ArrayList<>();
|
|
|
String stringCellValue = cell.getStringCellValue();
|
|
@@ -451,7 +502,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
}
|
|
|
}
|
|
|
if(modelName.equals("priority")){
|
|
|
- if(!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
+ if(cell!=null&&!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
switch (cell.getStringCellValue()){
|
|
|
case "低":task.setPriority(0);
|
|
|
break;
|
|
@@ -481,11 +532,141 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if(modelName.equals("contactsId")){
|
|
|
+ if(cell!=null&&!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
+ String contactsName = cell.getStringCellValue();
|
|
|
+ List<Contacts> collect = contactsList.stream().filter(contacts -> contacts.getName().equals(contactsName)).collect(Collectors.toList());
|
|
|
+ if (collect.size()>1){
|
|
|
+ throw new Exception("["+contactsName+"]对应的联系人存在多个");
|
|
|
+ }else if (collect.size()==1) {
|
|
|
+ Contacts contacts = collect.get(0);
|
|
|
+ task.setContactsId(contacts.getId());
|
|
|
+ }else {
|
|
|
+ throw new Exception("["+contactsName+"]对应的联系人不存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(modelName.equals("customId")){
|
|
|
+ if(cell!=null&&!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
+ String customName = cell.getStringCellValue();
|
|
|
+ List<Custom> customs = customList.stream().filter(custom -> customName.equals(custom.getCustomName())).collect(Collectors.toList());
|
|
|
+ if (customs.size()>1){
|
|
|
+ throw new Exception("["+customName+"]对应的客户存在多个");
|
|
|
+ }else if (customs.size()==1){
|
|
|
+ Custom custom = customs.get(0);
|
|
|
+ if (task.getContactsId()!=null){
|
|
|
+ boolean isExist = contactsList.stream().anyMatch(contacts -> custom.getId().equals(contacts.getCustomId())&&contacts.getId().equals(task.getContactsId()));
|
|
|
+ if(!isExist){
|
|
|
+ throw new Exception("["+customName+"]对应的客户没有对应填写的联系人");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ task.setCustomId(custom.getId());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ task.setCustomId(custom.getId());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ throw new Exception("["+customName+"]对应的客户不存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (modelName.equals("businessOpportunityId")){
|
|
|
+ if(cell!=null&&!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
+ String businessName = cell.getStringCellValue();
|
|
|
+ List<BusinessOpportunity> collect = opportunityList.stream().filter(o -> businessName.equals(o.getName())).collect(Collectors.toList());
|
|
|
+ if (collect.size()>1){
|
|
|
+ throw new Exception("["+businessName+"]对应的商机存在多个");
|
|
|
+ }else if (collect.size()==1) {
|
|
|
+ BusinessOpportunity businessOpportunity = collect.get(0);
|
|
|
+ if (task.getContactsId()!=null){
|
|
|
+ if (!businessOpportunity.getContactsId().equals(task.getContactsId())){
|
|
|
+ throw new Exception("["+businessName+"]对应的商机没有对应填写的联系人");
|
|
|
+ }else {
|
|
|
+ task.setBusinessOpportunityId(businessOpportunity.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ throw new Exception("["+businessName+"]对应的商机不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (modelName.equals("orderId")){
|
|
|
+ if(cell!=null&&!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
+ String orderName = cell.getStringCellValue();
|
|
|
+ List<Order> collect = orderList.stream().filter(order -> orderName.equals(order.getOrderName())).collect(Collectors.toList());
|
|
|
+ if (collect.size()>1){
|
|
|
+ throw new Exception("["+orderName+"]对应的销售订单存在多个");
|
|
|
+ }else if (collect.size()==1) {
|
|
|
+ Order order=collect.get(0);
|
|
|
+ if (task.getContactsId()!=null){
|
|
|
+ if (!order.getContactsId().equals(task.getContactsId())){
|
|
|
+ throw new Exception("["+orderName+"]对应的销售订单没有对应填写的联系人");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ task.setOrderId(order.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ throw new Exception("["+orderName+"]对应的销售订单不存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (modelName.equals("clueId")) {
|
|
|
+ if (cell!=null&&!StringUtils.isEmpty(cell.getStringCellValue())) {
|
|
|
+ String clueName = cell.getStringCellValue();
|
|
|
+ if (task.getContactsId()!=null){
|
|
|
+ throw new Exception("["+clueName+"]对应的线索不存在联系人");
|
|
|
+ }
|
|
|
+ List<Clue> collect = clueList.stream().filter(clue -> clueName.equals(clue.getClueName())).collect(Collectors.toList());
|
|
|
+ if (!collect.isEmpty()) {
|
|
|
+ Clue clue = collect.get(0);
|
|
|
+ task.setClueId(clue.getId());
|
|
|
+ }else {
|
|
|
+ throw new Exception("["+clueName+"]对应的线索不存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (modelName.equals("phone")) {
|
|
|
+ if (cell!=null&&!StringUtils.isEmpty(cell.getStringCellValue())) {
|
|
|
+ String contactsPhone = cell.getStringCellValue();
|
|
|
+ List<Contacts> collect = contactsList.stream().filter(contacts -> contactsPhone.equals(contacts.getPhone())).collect(Collectors.toList());
|
|
|
+ if (collect.size()>1){
|
|
|
+ throw new Exception("联系人号码"+"["+contactsPhone+"]对应的联系人存在多个");
|
|
|
+ } else if (collect.size() == 1) {
|
|
|
+ Contacts contacts = collect.get(0);
|
|
|
+ if (task.getContactsId()!=null){
|
|
|
+ if (!contacts.getId().equals(task.getContactsId())){
|
|
|
+ throw new Exception("联系人号码"+"["+contactsPhone+"]与联系人不绑定");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ task.setContactsId(contacts.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
importTaskList.add(task);
|
|
|
}
|
|
|
|
|
|
if(importTaskList.size()>0){
|
|
|
+ for (Task task : importTaskList) {
|
|
|
+ if (task.getClueId()!=null &&(task.getCustomId()!=null||task.getBusinessOpportunityId()!=null||task.getOrderId()!=null||task.getContactsId()!=null)){
|
|
|
+ msg.setError("任务:"+task.getTaskName()+"中线索不应与客户/商机/销售订单/联系人一同存在");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ if ((task.getCustomId()!=null&&task.getBusinessOpportunityId()!=null)
|
|
|
+ ||(task.getCustomId()!=null&&task.getOrderId()!=null)
|
|
|
+ ||(task.getOrderId()!=null&&task.getBusinessOpportunityId()!=null)
|
|
|
+ ||(task.getCustomId()!=null&&task.getBusinessOpportunityId()!=null&&task.getOrderId()!=null)){
|
|
|
+ msg.setError("任务:"+task.getTaskName()+"中客户/商机/销售订单不应一同存在");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ }
|
|
|
if(saveOrUpdateBatch(importTaskList)){
|
|
|
ArrayList<TaskExecutor> taskExecutors = new ArrayList<>();
|
|
|
ArrayList<TaskLog> taskLogs = new ArrayList<>();
|
|
@@ -499,6 +680,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
taskExecutor.setTaskId(task.getId());
|
|
|
taskExecutor.setExecutorId(userList.stream().filter(u -> u.getId().equals(userId)).collect(Collectors.toList()).get(0).getId());
|
|
|
taskExecutor.setExecutorName(userList.stream().filter(u -> u.getId().equals(userId)).collect(Collectors.toList()).get(0).getName());
|
|
|
+ taskExecutor.setCompanyId(user.getCompanyId());
|
|
|
taskExecutors.add(taskExecutor);
|
|
|
}
|
|
|
}
|
|
@@ -508,6 +690,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
taskLog.setModTime(LocalDateTime.now());
|
|
|
taskLog.setUserName(user.getName());
|
|
|
taskLog.setUserId(user.getId());
|
|
|
+ taskLog.setCompanyId(user.getCompanyId());
|
|
|
taskLogs.add(taskLog);
|
|
|
}
|
|
|
boolean b1 = taskExecutorService.saveOrUpdateBatch(taskExecutors);
|
|
@@ -620,6 +803,24 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo,fileName,dataList,path);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public HttpRespMsg updateTaskStatus(TaskDto taskDto, HttpServletRequest request) {
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ if (taskDto==null||taskDto.getId()==null){
|
|
|
+ msg.setError("缺少用户的关键信息");
|
|
|
+ }
|
|
|
+ LambdaUpdateWrapper<Task> luw = new LambdaUpdateWrapper<>();
|
|
|
+ luw.set(Task::getStatus,taskDto.getStatus()).eq(Task::getId,taskDto.getStatus());
|
|
|
+ taskMapper.update(null,luw);
|
|
|
+ TaskLog taskLog = new TaskLog();
|
|
|
+ taskLog.setUserId(user.getId()).setTaskId(taskDto.getId()).setUserName(user.getName())
|
|
|
+ .setContent("修改任务状态").setModTime(LocalDateTime.now());
|
|
|
+ taskLogMapper.insert(taskLog);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
public void updateTaskRepeatConfigure(Task task){
|
|
|
task.setRepeatType(null).setRepeatEndNever(null).setRepeatEndCount(null)
|
|
|
.setRepeatEndDate(null).setRepeatDesignDay(null).setRepeatDesignSameday(null);
|