|
@@ -22,6 +22,7 @@ import org.apache.poi.xssf.usermodel.XSSFRow;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -33,6 +34,7 @@ import java.io.*;
|
|
|
import java.lang.reflect.Field;
|
|
|
import java.lang.reflect.Method;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
@@ -52,6 +54,9 @@ import java.util.stream.Collectors;
|
|
|
@Transactional
|
|
|
public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements TaskService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ContactsService contactsService;
|
|
|
+
|
|
|
@Resource
|
|
|
private UserMapper userMapper;
|
|
|
@Resource
|
|
@@ -61,6 +66,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
@Resource
|
|
|
private TaskExecutorMapper taskExecutorMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private SysFunctionService sysFunctionService;
|
|
|
+
|
|
|
@Resource
|
|
|
private TaskRepeatDesignMapper taskRepeatDesignMapper;
|
|
|
|
|
@@ -119,9 +127,12 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
BeanUtils.copyProperties(taskDto,task);
|
|
|
task.setCreateDate(LocalDateTime.now());//任务的创建时间
|
|
|
//根据任务的开始时间与当下时间判断任务的状态
|
|
|
- if (taskDto.getStartDate()==null||taskDto.getStartDate().isAfter(LocalDateTime.now())){
|
|
|
+ if (taskDto.getStartDate()!=null&&taskDto.getStartDate().isAfter(LocalDateTime.now())){
|
|
|
task.setStatus(0);
|
|
|
- }else {
|
|
|
+ }else if (taskDto.getEndDate()!=null&&taskDto.getEndDate().isBefore(LocalDateTime.now())){
|
|
|
+ task.setStatus(3);
|
|
|
+ } else if (taskDto.getStartDate()!=null&&taskDto.getStartDate().isBefore(LocalDateTime.now())&&taskDto.getEndDate()!=null&&taskDto.getEndDate().isAfter(LocalDateTime.now()))
|
|
|
+ {
|
|
|
task.setStatus(1);
|
|
|
}
|
|
|
task.setCreaterName(user.getName());
|
|
@@ -175,6 +186,21 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
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()).orderByDesc(TaskLog::getModTime));
|
|
|
taskDto.setPageIndex((taskDto.getPageIndex()-1)*taskDto.getPageSize());
|
|
|
+
|
|
|
+ boolean isAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看全部任务");
|
|
|
+ boolean isNotAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看负责部门任务");
|
|
|
+
|
|
|
+ if (isAll){
|
|
|
+ System.out.println("do nothing");
|
|
|
+ }else if (isNotAll){
|
|
|
+ Integer departmentId = user.getDepartmentId();//找出对应的部门id
|
|
|
+ taskDto.setDepartmentId(departmentId);
|
|
|
+ }else {
|
|
|
+ //查看负责人为自己和null的数据
|
|
|
+ taskDto.setDepartmentIdByMyselfOrNull(user.getId());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
List<TasKVo> taskVoList =taskMapper.getPageListTask(taskDto);
|
|
|
for (TasKVo tasKVo : taskVoList) {
|
|
|
if (!taskExecutorList.isEmpty()){
|
|
@@ -270,7 +296,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
}
|
|
|
List<Task> taskList = taskMapper.selectList(new QueryWrapper<Task>().in("id", taskIds));
|
|
|
if (!taskList.isEmpty()){
|
|
|
- List<Task> collect = taskList.stream().filter(task ->task.getStatus()!=0&& task.getStatus() != 2).collect(Collectors.toList());
|
|
|
+ List<Task> collect = taskList.stream().filter(task ->task.getStatus()!=null&&task.getStatus()!=0&&task.getStatus()!=2).collect(Collectors.toList());
|
|
|
if (collect.size()>0){
|
|
|
msg.setError("存在任务未完成,不能删除");
|
|
|
return msg;
|
|
@@ -324,6 +350,37 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
JSONObject configOb = JSON.parseObject(config);
|
|
|
JSONArray configObJSONArray = configOb.getJSONArray("list");
|
|
|
|
|
|
+ //可能存在栅格布局的情况需要特殊处理
|
|
|
+ List<String> modelNameList=new ArrayList<>();
|
|
|
+ List<String> typeList=new ArrayList<>();
|
|
|
+ List<String> labelList=new ArrayList<>();
|
|
|
+ List<Boolean> requiredList=new ArrayList<>();
|
|
|
+
|
|
|
+ for (int i = 0; i < configObJSONArray.size(); i++) {
|
|
|
+ JSONObject jsonObject = configObJSONArray.getJSONObject(i);
|
|
|
+ if(jsonObject.getString("type").equals("grid")){
|
|
|
+ JSONArray columns = jsonObject.getJSONArray("columns");
|
|
|
+ for (int i1 = 0; i1 < columns.size(); i1++) {
|
|
|
+ JSONObject columnsJSONObject = columns.getJSONObject(i1);
|
|
|
+ JSONArray list = columnsJSONObject.getJSONArray("list");
|
|
|
+ for (int i2 = 0; i2 < list.size(); i2++) {
|
|
|
+ JSONObject object = list.getJSONObject(i2);
|
|
|
+ modelNameList.add(object.getString("model"));
|
|
|
+ typeList.add(object.getString("type"));
|
|
|
+ labelList.add(object.getString("label"));
|
|
|
+ Boolean required = object.getJSONObject("options").getJSONObject("rules").getBoolean("required");
|
|
|
+ requiredList.add(required);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ modelNameList.add(jsonObject.getString("model"));
|
|
|
+ typeList.add(jsonObject.getString("type"));
|
|
|
+ labelList.add(jsonObject.getString("label"));
|
|
|
+ Boolean required = jsonObject.getJSONObject("options").getJSONObject("rules").getBoolean("required");
|
|
|
+ requiredList.add(required);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
List<Task> importTaskList=new ArrayList<>();
|
|
|
List<String> userNameList=new ArrayList<>();
|
|
|
HttpRespMsg respMsg=new HttpRespMsg();
|
|
@@ -347,19 +404,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
int cellNum = row.getLastCellNum();
|
|
|
|
|
|
for (int i = 0; i < cellNum; i++) {
|
|
|
- JSONObject item = configObJSONArray.getJSONObject(i);
|
|
|
- String modelName = item.getString("model");
|
|
|
+ String modelName = modelNameList.get(i);
|
|
|
XSSFCell cell = row.getCell(i);
|
|
|
-/* if(cell!=null&&StringUtils.isNotEmpty(cell.getStringCellValue())){
|
|
|
- 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("executorId")){
|
|
|
if(!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
List<String> executorNames = new ArrayList<>();
|
|
@@ -402,22 +448,26 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
task.setCompanyId(companyId);
|
|
|
task.setCreaterId(user.getId());
|
|
|
task.setCreateDate(LocalDateTime.now());
|
|
|
- task.setStatus(0);
|
|
|
+// task.setStatus(0);
|
|
|
task.setIsDelete(0);
|
|
|
+
|
|
|
+ //统计 线索不应与客户/商机/销售订单/联系人一同存在
|
|
|
+ boolean b1=false; //客户/商机/销售订单/联系人
|
|
|
+ boolean b2=false;//线索
|
|
|
+
|
|
|
+ //客户/商机/销售订单不应一同存在
|
|
|
+ boolean b3=false;//客户
|
|
|
+ boolean b4=false;//商机
|
|
|
+ boolean b5=false;//销售订单
|
|
|
+
|
|
|
for (int i = 0; i < cellNum; i++) {
|
|
|
- JSONObject item = configObJSONArray.getJSONObject(i);
|
|
|
- String modelName = item.getString("model");
|
|
|
+ String modelName = modelNameList.get(i);
|
|
|
String className = modelName.substring(0, 1).toUpperCase() + modelName.substring(1);
|
|
|
String getter="get"+className;
|
|
|
String setter="set"+className;
|
|
|
XSSFCell cell = row.getCell(i);
|
|
|
- if(cell!=null&&StringUtils.isNotEmpty(cell.getStringCellValue())){
|
|
|
- switch (item.getString("type")){
|
|
|
- case "time":cell.setCellType(CellType.NUMERIC);
|
|
|
- System.out.println(cell.getNumericCellValue());
|
|
|
- break;
|
|
|
- case "int":cell.setCellType(CellType.NUMERIC);
|
|
|
- break;
|
|
|
+ if(cell!=null){
|
|
|
+ switch (typeList.get(i)){
|
|
|
default:cell.setCellType(CellType.STRING);
|
|
|
}
|
|
|
}
|
|
@@ -425,25 +475,14 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
// 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");
|
|
|
- Boolean required = rules.getBoolean("required");
|
|
|
- if(required){
|
|
|
- if(StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
- msg.setError(item.getString("label")+"值不能为空值");
|
|
|
+
|
|
|
+ if(requiredList.get(i)){
|
|
|
+ if(cell==null||StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
+ msg.setError(labelList.get(i)+"值不能为空值");
|
|
|
return msg;
|
|
|
}
|
|
|
}
|
|
|
- /*if(modelName.equals("taskCode")){
|
|
|
- if(!org.springframework.util.StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
- //系统中同公司已存在的产品编码 更新
|
|
|
- Optional<Task> first = taskList.stream().filter(p ->p.getTaskCode()!=null&& p.getTaskCode().equals(cell.getStringCellValue())).findFirst();
|
|
|
- if(first.isPresent()){
|
|
|
- task.setId(first.get().getId());
|
|
|
- }
|
|
|
- }
|
|
|
- }*/
|
|
|
+
|
|
|
if(modelName.equals("executorId")){
|
|
|
if(cell!=null&&!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
|
|
@@ -469,7 +508,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
if (first.isPresent()) {
|
|
|
executorIds.add(first.get().getId());
|
|
|
} else {
|
|
|
- throw new Exception("["+userName+"]在系统中不存在");
|
|
|
+ msg.setError("["+userName+"]在系统中不存在");
|
|
|
+ return msg;
|
|
|
}
|
|
|
}
|
|
|
StringJoiner joiner = new StringJoiner(",");
|
|
@@ -485,12 +525,12 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
|
|
|
|
|
|
}*/
|
|
|
- if(modelName.equals("taskName")){
|
|
|
+ else if(modelName.equals("taskName")){
|
|
|
if(!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
task.setTaskName(cell.getStringCellValue());
|
|
|
}
|
|
|
}
|
|
|
- if(modelName.equals("priority")){
|
|
|
+ else if(modelName.equals("priority")){
|
|
|
if(cell!=null&&!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
switch (cell.getStringCellValue()){
|
|
|
case "低":task.setPriority(0);
|
|
@@ -502,150 +542,162 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if(modelName.equals("startDate")){
|
|
|
+ else if(modelName.equals("startDate")){
|
|
|
if(cell != null && cell.getCellTypeEnum() != CellType.BLANK){
|
|
|
- if (cell.getCellTypeEnum() == CellType.NUMERIC){
|
|
|
- Date dateCellValue = cell.getDateCellValue();
|
|
|
- if (dateCellValue.before(new Date(-2208988800L))){
|
|
|
- continue;
|
|
|
- }else {
|
|
|
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- String string = format.format(dateCellValue);
|
|
|
- System.out.println(string);
|
|
|
- DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
- LocalDateTime time = LocalDateTime.parse(string, dateTimeFormatter);
|
|
|
- task.setStartDate(time);
|
|
|
- }
|
|
|
+ if(!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
+ DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ task.setStartDate(LocalDateTime.parse(cell.getStringCellValue(),df));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if(modelName.equals("endDate")){
|
|
|
+ else if(modelName.equals("endDate")){
|
|
|
if(cell != null && cell.getCellTypeEnum() != CellType.BLANK){
|
|
|
- if (cell.getCellTypeEnum() == CellType.NUMERIC){
|
|
|
- Date dateCellValue = cell.getDateCellValue();
|
|
|
- if (dateCellValue.before(new Date(-2208988800L))){
|
|
|
- continue;
|
|
|
- }else {
|
|
|
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- String string = format.format(dateCellValue);
|
|
|
- System.out.println(string);
|
|
|
- DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
- LocalDateTime time = LocalDateTime.parse(string, dateTimeFormatter);
|
|
|
- task.setEndDate(time);
|
|
|
- }
|
|
|
+ if(!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
+ DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ task.setEndDate(LocalDateTime.parse(cell.getStringCellValue(),df));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(modelName.equals("contactsId")){
|
|
|
+ else if(modelName.equals("contactsId")){
|
|
|
if(cell!=null&&!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
+ b1=true;
|
|
|
+
|
|
|
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) {
|
|
|
+ if (!collect.isEmpty()) {
|
|
|
Contacts contacts = collect.get(0);
|
|
|
task.setContactsId(contacts.getId());
|
|
|
}else {
|
|
|
- throw new Exception("["+contactsName+"]对应的联系人不存在");
|
|
|
+ msg.setError("["+contactsName+"]对应的联系人不存在");
|
|
|
+ return msg;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(modelName.equals("customId")){
|
|
|
+ else if(modelName.equals("customId")){
|
|
|
if(cell!=null&&!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
+ b1=true;
|
|
|
+ b3=true;
|
|
|
+
|
|
|
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+"]对应的客户存在多个");
|
|
|
+ msg.setError("["+customName+"]对应的客户存在多个");
|
|
|
+ return msg;
|
|
|
}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+"]对应的客户没有对应填写的联系人");
|
|
|
+ msg.setError("["+customName+"]对应的客户没有对应填写的联系人");
|
|
|
+ return msg;
|
|
|
}
|
|
|
else {
|
|
|
task.setCustomId(custom.getId());
|
|
|
+ task.setTaskType(0);
|
|
|
}
|
|
|
}else {
|
|
|
task.setCustomId(custom.getId());
|
|
|
+ task.setTaskType(0);
|
|
|
}
|
|
|
}else {
|
|
|
- throw new Exception("["+customName+"]对应的客户不存在");
|
|
|
+ msg.setError("["+customName+"]对应的客户不存在");
|
|
|
+ return msg;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (modelName.equals("businessOpportunityId")){
|
|
|
+ else if (modelName.equals("businessOpportunityId")){
|
|
|
if(cell!=null&&!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
+ b1=true;
|
|
|
+ b4=true;
|
|
|
+
|
|
|
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+"]对应的商机存在多个");
|
|
|
+ msg.setError("["+businessName+"]名称,对应的商机存在多个");
|
|
|
+ return msg;
|
|
|
}else if (collect.size()==1) {
|
|
|
BusinessOpportunity businessOpportunity = collect.get(0);
|
|
|
if (task.getContactsId()!=null){
|
|
|
if (!businessOpportunity.getContactsId().equals(task.getContactsId())){
|
|
|
- throw new Exception("["+businessName+"]对应的商机没有对应填写的联系人");
|
|
|
+ msg.setError("["+businessName+"]对应的商机没有对应填写的联系人");
|
|
|
+ return msg;
|
|
|
}else {
|
|
|
task.setBusinessOpportunityId(businessOpportunity.getId());
|
|
|
+ task.setTaskType(1);
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
- throw new Exception("["+businessName+"]对应的商机不存在");
|
|
|
+ msg.setError("["+businessName+"]对应的商机不存在");
|
|
|
+ return msg;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- if (modelName.equals("orderId")){
|
|
|
+ else if (modelName.equals("orderId")){
|
|
|
if(cell!=null&&!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
+ b1=true;
|
|
|
+ b5=true;
|
|
|
+
|
|
|
String orderName = cell.getStringCellValue();
|
|
|
List<SalesOrder> collect = orderList.stream().filter(order -> orderName.equals(order.getOrderName())).collect(Collectors.toList());
|
|
|
if (collect.size()>1){
|
|
|
- throw new Exception("["+orderName+"]对应的销售订单存在多个");
|
|
|
+ msg.setError("["+orderName+"]对应的销售订单存在多个");
|
|
|
+ return msg;
|
|
|
}else if (collect.size()==1) {
|
|
|
SalesOrder order=collect.get(0);
|
|
|
if (task.getContactsId()!=null){
|
|
|
if (!order.getContactsId().equals(task.getContactsId())){
|
|
|
- throw new Exception("["+orderName+"]对应的销售订单没有对应填写的联系人");
|
|
|
+ msg.setError("["+orderName+"]对应的销售订单没有对应填写的联系人");
|
|
|
+ return msg;
|
|
|
}
|
|
|
else {
|
|
|
task.setOrderId(order.getId());
|
|
|
+ task.setTaskType(2);
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
- throw new Exception("["+orderName+"]对应的销售订单不存在");
|
|
|
+ msg.setError("["+orderName+"]对应的销售订单不存在");
|
|
|
+ return msg;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (modelName.equals("clueId")) {
|
|
|
+ else if (modelName.equals("clueId")) {
|
|
|
if (cell!=null&&!StringUtils.isEmpty(cell.getStringCellValue())) {
|
|
|
+ b2=true;
|
|
|
+
|
|
|
String clueName = cell.getStringCellValue();
|
|
|
if (task.getContactsId()!=null){
|
|
|
- throw new Exception("["+clueName+"]对应的线索不存在联系人");
|
|
|
+ msg.setError("["+clueName+"]对应的线索不存在联系人");
|
|
|
+ return msg;
|
|
|
}
|
|
|
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());
|
|
|
+ task.setTaskType(3);
|
|
|
}else {
|
|
|
- throw new Exception("["+clueName+"]对应的线索不存在");
|
|
|
+ msg.setError("["+clueName+"]对应的线索不存在");
|
|
|
+ return msg;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (modelName.equals("phone")) {
|
|
|
+ else 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+"]对应的联系人存在多个");
|
|
|
+ msg.setError("联系人号码"+"["+contactsPhone+"]对应的联系人存在多个");
|
|
|
+ return msg;
|
|
|
} else if (collect.size() == 1) {
|
|
|
Contacts contacts = collect.get(0);
|
|
|
if (task.getContactsId()!=null){
|
|
|
if (!contacts.getId().equals(task.getContactsId())){
|
|
|
- throw new Exception("联系人号码"+"["+contactsPhone+"]与联系人不绑定");
|
|
|
+ msg.setError("联系人号码"+"["+contactsPhone+"]与联系人不绑定");
|
|
|
+ return msg;
|
|
|
}
|
|
|
}else {
|
|
|
task.setContactsId(contacts.getId());
|
|
@@ -654,7 +706,28 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+ else {
|
|
|
+ if(cell!=null && !StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
+ Class<Task> taskClass = Task.class;
|
|
|
+ Field field = taskClass.getDeclaredField(modelName);
|
|
|
+ Class<?> type = field.getType();
|
|
|
+ Method method = taskClass.getMethod(setter, type);
|
|
|
+ System.out.println(cell.getStringCellValue());
|
|
|
+ method.invoke(task,cell.getStringCellValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+ if (b1&&b2){
|
|
|
+ msg.setError("任务名称:"+task.getTaskName()+",线索不应与客户/商机/销售订单/联系人一同存在");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ if (b3&&b4&&b5){
|
|
|
+ msg.setError("任务名称:"+task.getTaskName()+",客户/商机/销售订单不应一同存在");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
importTaskList.add(task);
|
|
|
}
|
|
|
|
|
@@ -671,6 +744,37 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
msg.setError("任务:"+task.getTaskName()+"中客户/商机/销售订单不应一同存在");
|
|
|
return msg;
|
|
|
}
|
|
|
+ if (task.getStartDate()!=null&&task.getStartDate().isAfter(LocalDateTime.now())){
|
|
|
+ task.setStatus(0);
|
|
|
+ }else if (task.getEndDate()!=null&&task.getEndDate().isBefore(LocalDateTime.now())){
|
|
|
+ task.setStatus(3);
|
|
|
+ } else if (task.getStartDate()!=null&&task.getStartDate().isBefore(LocalDateTime.now())&&task.getEndDate()!=null&&task.getEndDate().isAfter(LocalDateTime.now()))
|
|
|
+ {
|
|
|
+ task.setStatus(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断客户/商机/销售订单跟联系人时候绑定
|
|
|
+ if (task.getTaskType()!=null&&task.getTaskType()<3&&task.getContactsId()!=null){
|
|
|
+ HttpRespMsg httpRespMsg = contactsService.getAllContacts(task.getBusinessOpportunityId(), task.getOrderId(), task.getCustomId(), request);
|
|
|
+ List<Contacts> list = (List<Contacts>) httpRespMsg.getData();
|
|
|
+ if (!list.isEmpty()){
|
|
|
+ boolean present = list.stream().anyMatch(contacts -> contacts.getId().equals(task.getContactsId()));
|
|
|
+ if (!present){
|
|
|
+ String type="";
|
|
|
+ //客户0, 商机1 ,订单2 ,
|
|
|
+ if (task.getTaskType()==0){
|
|
|
+ type="客户";
|
|
|
+ }else if (task.getTaskType()==1){
|
|
|
+ type="商机";
|
|
|
+ }else {
|
|
|
+ type="订单";
|
|
|
+ }
|
|
|
+ msg.setError("存在"+type+"与联系人不一一对应:");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
if(saveOrUpdateBatch(importTaskList)){
|
|
|
ArrayList<TaskExecutor> taskExecutors = new ArrayList<>();
|
|
@@ -762,7 +866,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
dataList.add(titleList);//设置表头
|
|
|
|
|
|
taskDto.setCompanyId(user.getCompanyId());
|
|
|
- taskDto.setPageIndex(null).setPageSize(null);//暂时部不分页
|
|
|
+ taskDto.setPageIndex(null).setPageSize(null);
|
|
|
List<TasKVo> taskVoList =taskMapper.getPageListTask(taskDto);
|
|
|
if (!taskVoList.isEmpty()){
|
|
|
for (TasKVo tasKVo : taskVoList) {
|