yusm 1 年間 前
コミット
2c6b04b331

+ 5 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/TaskController.java

@@ -89,6 +89,11 @@ public class TaskController {
         return taskService.exportData(taskDto,request);
     }
 
+    @RequestMapping("exportDataByTaskIds")
+    public HttpRespMsg exportData(String taskIds) throws Exception {
+        return taskService.exportDataByTaskIds(taskIds,request);
+    }
+
     @RequestMapping("updateTaskStatus")
     public HttpRespMsg updateTaskStatus(TaskDto taskDto) throws Exception {
         System.out.println("===========>"+taskDto.getStatus());

+ 2 - 2
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/Task.java

@@ -133,8 +133,8 @@ public class Task extends Model<Task> {
     /**
      * 重复结束 在  ? 日期YYYY-MM-DD之后
      */
-    @JsonFormat(pattern = "yyyy-MM-dd")
-    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @TableField("repeat_end_date")
     private LocalDateTime repeatEndDate;
 

+ 1 - 1
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/mapper/SalesOrderMapper.java

@@ -17,6 +17,6 @@ import java.util.List;
  */
 public interface SalesOrderMapper extends BaseMapper<SalesOrder> {
 
-    @Select("select * from `order` WHERE company_id = #{companyId} AND is_delete = 0 ")
+    @Select("select * from `sales_order` WHERE company_id = #{companyId} AND is_delete = 0 ")
     List<SalesOrder> getList(User user);
 }

+ 2 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/mapper/TaskMapper.java

@@ -66,4 +66,6 @@ public interface TaskMapper extends BaseMapper<Task> {
     void updateRepeatConfig(Task task);
     @Select("select * , (select `name` from `user` where id = executor_id) executorName from task where clue_id = #{id} ORDER BY id DESC")
     List<Task> selectByInfoList(Clue clue1);
+
+    List<TasKVo> getListByTaskIds(@Param("taskIdArray") String[] taskIdArray);
 }

+ 2 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/TaskService.java

@@ -35,4 +35,6 @@ public interface TaskService extends IService<Task> {
     HttpRespMsg exportData(TaskDto taskDto, HttpServletRequest request) throws Exception;
 
     HttpRespMsg updateTaskStatus(TaskDto taskDto, HttpServletRequest request);
+
+    HttpRespMsg exportDataByTaskIds(String taskIds, HttpServletRequest request) throws Exception;
 }

+ 175 - 14
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/TaskServiceImpl.java

@@ -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);

+ 25 - 2
fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/TaskMapper.xml

@@ -104,7 +104,9 @@
             left join  `sales_order` on task.order_id=`sales_order`.id
             left join  clue on task.clue_id=clue.id
             left join  contacts on task.contacts_id=contacts.id
-            inner join task_executor on task.id=task_executor.task_id
+            <if test=" executorName!= null and executorName != '' " >
+                inner join task_executor on task.id=task_executor.task_id
+            </if>
 
         <where>
             and 1=1 and task.is_delete=0
@@ -168,7 +170,10 @@
         left join  `sales_order` on task.order_id=`sales_order`.id
         left join  clue on task.clue_id=clue.id
         left join  contacts on task.contacts_id=contacts.id
-        inner join task_executor on task.id=task_executor.task_id
+        <if test=" executorName!= null and executorName != '' " >
+            inner join task_executor on task.id=task_executor.task_id
+        </if>
+
 
         <where>
             and 1=1 and task.is_delete=0
@@ -214,6 +219,24 @@
             </if>
         </where>
     </select>
+    <select id="getListByTaskIds" resultType="com.management.platform.entity.vo.TasKVo">
+        select task.* ,
+        custom.custom_name,
+        business_opportunity.name businessName,
+        `sales_order`.order_name ,
+        clue.clue_name,
+        contacts.name contacts_name ,contacts.phone
+        from task
+        left join  custom on task.custom_id=custom.id
+        left join  business_opportunity on task.business_opportunity_id=business_opportunity.id
+        left join  `sales_order` on task.order_id=`sales_order`.id
+        left join  clue on task.clue_id=clue.id
+        left join  contacts on task.contacts_id=contacts.id
+        WHERE  task.id IN
+        <foreach item="taskId" collection="taskIdArray" open="(" separator="," close=")">
+            #{taskId}
+        </foreach>
+    </select>
 
     <update id="updateRepeatConfig">
         update task