重构系统任务

This commit is contained in:
459816669@qq.com 2022-05-29 19:48:50 +08:00
parent b0738cd4ab
commit 78273d58a1
42 changed files with 1448 additions and 1140 deletions

View File

@ -18,7 +18,7 @@ import com.snow.common.core.page.TableDataInfo;
import com.snow.common.enums.BusinessType; import com.snow.common.enums.BusinessType;
import com.snow.common.utils.poi.ExcelUtil; import com.snow.common.utils.poi.ExcelUtil;
import com.snow.framework.util.ShiroUtils; import com.snow.framework.util.ShiroUtils;
import com.snow.system.domain.SysDictData; import com.snow.common.core.domain.SysDictData;
import com.snow.system.service.ISysDictDataService; import com.snow.system.service.ISysDictDataService;
/** /**

View File

@ -20,7 +20,7 @@ import com.snow.common.core.page.TableDataInfo;
import com.snow.common.enums.BusinessType; import com.snow.common.enums.BusinessType;
import com.snow.common.utils.poi.ExcelUtil; import com.snow.common.utils.poi.ExcelUtil;
import com.snow.framework.util.ShiroUtils; import com.snow.framework.util.ShiroUtils;
import com.snow.system.domain.SysDictType; import com.snow.common.core.domain.SysDictType;
import com.snow.system.service.ISysDictTypeService; import com.snow.system.service.ISysDictTypeService;
/** /**

View File

@ -1,45 +1,42 @@
package com.snow.web.controller.system; package com.snow.web.controller.system;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Lists;
import com.snow.common.annotation.Log;
import com.snow.common.annotation.RepeatSubmit;
import com.snow.common.constant.MessageConstants;
import com.snow.common.core.controller.BaseController;
import com.snow.common.core.domain.AjaxResult;
import com.snow.common.core.domain.MessageEventRequest;
import com.snow.common.core.page.TableDataInfo;
import com.snow.common.enums.BusinessType;
import com.snow.common.enums.DingFlowTaskType;
import com.snow.common.enums.MessageEventType;
import com.snow.common.utils.poi.ExcelUtil;
import com.snow.dingtalk.service.WorkRecodeService;
import com.snow.framework.util.ShiroUtils;
import com.snow.system.domain.SysOaTask;
import com.snow.system.domain.SysOaTaskDistribute;
import com.snow.system.domain.SysUser;
import com.snow.system.service.ISysOaTaskDistributeService;
import com.snow.system.service.ISysOaTaskService;
import org.apache.commons.compress.utils.Sets;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.BetweenFormater;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.google.common.collect.Lists;
import com.snow.common.constant.MessageConstants;
import com.snow.common.core.domain.MessageEventRequest;
import com.snow.common.enums.DingFlowTaskType;
import com.snow.common.enums.DingTalkListenerType;
import com.snow.common.enums.MessageEventType;
import com.snow.framework.util.ShiroUtils;
import com.snow.system.domain.*;
import com.snow.system.domain.SysOaTaskDistribute;
import com.snow.system.event.SyncEvent;
import com.snow.system.service.ISysOaTaskDistributeService;
import com.snow.system.service.ISysUserService;
import org.apache.commons.compress.utils.Sets;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.snow.common.annotation.Log;
import com.snow.common.enums.BusinessType;
import org.springframework.stereotype.Controller;
import com.snow.system.service.ISysOaTaskService;
import com.snow.common.core.controller.BaseController;
import com.snow.common.core.domain.AjaxResult;
import com.snow.common.utils.poi.ExcelUtil;
import com.snow.common.core.page.TableDataInfo;
/** /**
* 系统任务Controller * 系统任务Controller
* 当任务被分配后判断是否同步到钉钉系统 * 当任务被分配后判断是否同步到钉钉系统
@ -48,8 +45,7 @@ import com.snow.common.core.page.TableDataInfo;
*/ */
@Controller @Controller
@RequestMapping("/system/task") @RequestMapping("/system/task")
public class SysOaTaskController extends BaseController public class SysOaTaskController extends BaseController {
{
private String prefix = "system/task"; private String prefix = "system/task";
@Autowired @Autowired
@ -59,10 +55,10 @@ public class SysOaTaskController extends BaseController
private ISysOaTaskDistributeService sysOaTaskDistributeService; private ISysOaTaskDistributeService sysOaTaskDistributeService;
@Autowired @Autowired
private ISysUserService sysUserService; private ApplicationContext applicationContext;
@Autowired @Autowired
private ApplicationContext applicationContext; private WorkRecodeService workRecodeService;
@RequiresPermissions("system:task:view") @RequiresPermissions("system:task:view")
@GetMapping() @GetMapping()
@ -71,18 +67,6 @@ public class SysOaTaskController extends BaseController
return prefix + "/task"; return prefix + "/task";
} }
/**
* 查询系统任务列表
*/
@RequiresPermissions("system:task:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SysOaTask sysOaTask)
{
startPage();
List<SysOaTask> list = sysOaTaskService.selectSysOaTaskList(sysOaTask);
return getDataTable(list);
}
/** /**
* 任务分配列表 * 任务分配列表
@ -90,13 +74,13 @@ public class SysOaTaskController extends BaseController
@RequiresPermissions("system:task:taskDistributeList") @RequiresPermissions("system:task:taskDistributeList")
@PostMapping("/taskDistributeList") @PostMapping("/taskDistributeList")
@ResponseBody @ResponseBody
public TableDataInfo taskDistributeList(SysOaTaskDistribute sysOaTaskDistribute) public TableDataInfo taskDistributeList(SysOaTaskDistribute sysOaTaskDistribute) {
{
startPage(); startPage();
List<SysOaTaskDistribute> list = sysOaTaskDistributeService.selectSysOaTaskDistributeList(sysOaTaskDistribute); List<SysOaTaskDistribute> list = sysOaTaskDistributeService.selectSysOaTaskDistributeList(sysOaTaskDistribute);
if(CollUtil.isNotEmpty(list)){ if(CollUtil.isEmpty(list)){
warpSysOaTask(list); return getDataTable(list);
} }
sysOaTaskDistributeService.warpSysOaTask(list);
return getDataTable(list); return getDataTable(list);
} }
/** /**
@ -105,54 +89,38 @@ public class SysOaTaskController extends BaseController
@RequiresPermissions("system:task:myList") @RequiresPermissions("system:task:myList")
@PostMapping("/myList") @PostMapping("/myList")
@ResponseBody @ResponseBody
public TableDataInfo myList(SysOaTask sysOaTask) public TableDataInfo myList(SysOaTask sysOaTask) {
{
startPage(); startPage();
SysUser sysUser = ShiroUtils.getSysUser(); sysOaTask.setCreateBy(String.valueOf(ShiroUtils.getUserId()));
sysOaTask.setCreateBy(String.valueOf(sysUser.getUserId()));
List<SysOaTask> list = sysOaTaskService.selectSysOaTaskList(sysOaTask); List<SysOaTask> list = sysOaTaskService.selectSysOaTaskList(sysOaTask);
return getDataTable(list); return getDataTable(list);
} }
/** /**
* 我的待处理任务 * 我的待处理任务
* @param sysOaTaskDistribute
* @return
*/ */
@RequiresPermissions("system:task:waitList") @RequiresPermissions("system:task:waitList")
@PostMapping("/waitList") @PostMapping("/waitList")
@ResponseBody @ResponseBody
public TableDataInfo waitList(SysOaTaskDistribute sysOaTaskDistribute) public TableDataInfo waitList(SysOaTaskDistribute sysOaTaskDistribute) {
{
startPage(); startPage();
SysUser sysUser = ShiroUtils.getSysUser(); sysOaTaskDistribute.setTaskDistributeId(String.valueOf(ShiroUtils.getUserId()));
sysOaTaskDistribute.setTaskExecuteStatusList(Lists.newArrayList(DingFlowTaskType.RUNNING.getCode(),DingFlowTaskType.PROCESSING.getCode())); sysOaTaskDistribute.setTaskExecuteStatusList(Lists.newArrayList(DingFlowTaskType.NEW.getCode(),DingFlowTaskType.RUNNING.getCode()));
sysOaTaskDistribute.setTaskDistributeId(String.valueOf(sysUser.getUserId())); return getDataTable(sysOaTaskDistributeService.getSysOaTaskDistribute(sysOaTaskDistribute));
List<SysOaTaskDistribute> sysOaTaskDistributes = sysOaTaskDistributeService.selectSysOaTaskDistributeList(sysOaTaskDistribute);
if(CollUtil.isNotEmpty(sysOaTaskDistributes)){
warpSysOaTask(sysOaTaskDistributes);
}
return getDataTable(sysOaTaskDistributes);
} }
/** /**
* 我处理的任务 * 我处理的任务
* @param sysOaTaskDistribute
* @return
*/ */
@RequiresPermissions("system:task:handleList") @RequiresPermissions("system:task:handleList")
@PostMapping("/handleList") @PostMapping("/handleList")
@ResponseBody @ResponseBody
public TableDataInfo handleList(SysOaTaskDistribute sysOaTaskDistribute) public TableDataInfo handleList(SysOaTaskDistribute sysOaTaskDistribute) {
{
startPage(); startPage();
SysUser sysUser = ShiroUtils.getSysUser(); SysUser sysUser = ShiroUtils.getSysUser();
sysOaTaskDistribute.setTaskExecuteId(String.valueOf(sysUser.getUserId())); sysOaTaskDistribute.setTaskExecuteId(String.valueOf(sysUser.getUserId()));
sysOaTaskDistribute.setTaskExecuteStatus(DingFlowTaskType.COMPLETED.getCode()); sysOaTaskDistribute.setTaskExecuteStatus(DingFlowTaskType.COMPLETED.getCode());
List<SysOaTaskDistribute> sysOaTaskDistributes = sysOaTaskDistributeService.selectSysOaTaskDistributeList(sysOaTaskDistribute); List<SysOaTaskDistribute> sysOaTaskDistributes = sysOaTaskDistributeService.getSysOaTaskDistribute(sysOaTaskDistribute);
if(CollUtil.isNotEmpty(sysOaTaskDistributes)){
warpSysOaTask(sysOaTaskDistributes);
}
return getDataTable(sysOaTaskDistributes); return getDataTable(sysOaTaskDistributes);
} }
@ -163,19 +131,18 @@ public class SysOaTaskController extends BaseController
@Log(title = "系统任务", businessType = BusinessType.EXPORT) @Log(title = "系统任务", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
@ResponseBody @ResponseBody
public AjaxResult export(SysOaTask sysOaTask) public AjaxResult export(SysOaTask sysOaTask) {
{
List<SysOaTask> list = sysOaTaskService.selectSysOaTaskList(sysOaTask); List<SysOaTask> list = sysOaTaskService.selectSysOaTaskList(sysOaTask);
ExcelUtil<SysOaTask> util = new ExcelUtil<SysOaTask>(SysOaTask.class); ExcelUtil<SysOaTask> util = new ExcelUtil<SysOaTask>(SysOaTask.class);
return util.exportExcel(list, "task");
return util.exportExcel(list, "task","系统任务");
} }
/** /**
* 新增系统任务 * 新增系统任务
*/ */
@GetMapping("/add") @GetMapping("/add")
public String add() public String add() {
{
return prefix + "/add"; return prefix + "/add";
} }
@ -186,32 +153,45 @@ public class SysOaTaskController extends BaseController
@Log(title = "系统任务", businessType = BusinessType.INSERT) @Log(title = "系统任务", businessType = BusinessType.INSERT)
@PostMapping("/add") @PostMapping("/add")
@ResponseBody @ResponseBody
public AjaxResult addSave(SysOaTask sysOaTask) @RepeatSubmit
{ @Transactional(rollbackFor = Exception.class)
public AjaxResult addSave(SysOaTask sysOaTask) {
SysUser sysUser = ShiroUtils.getSysUser(); SysUser sysUser = ShiroUtils.getSysUser();
sysOaTask.setCreateBy(String.valueOf(sysUser.getUserId())); sysOaTask.setCreateBy(String.valueOf(sysUser.getUserId()));
return toAjax(sysOaTaskService.insertSysOaTask(sysOaTask)); SysOaTask task= sysOaTaskService.insertSysOaTask(sysOaTask);
//是否同步到钉钉待办,然后把钉钉taskId反写表中
if(sysOaTask.getSyncDingtalk()==1){
String taskId = workRecodeService.createTodoTask(task);
SysOaTask updateTask=new SysOaTask();
updateTask.setTaskNo(task.getTaskNo());
updateTask.setTaskOutsideId(taskId);
sysOaTaskService.updateById(updateTask);
}
return AjaxResult.success();
} }
@RequiresPermissions("system:task:start") @RequiresPermissions("system:task:start")
@PostMapping("/start") @PostMapping("/start")
@ResponseBody @ResponseBody
public AjaxResult start(Long id) public AjaxResult start(Long id) {
{ SysOaTaskDistribute taskDistribute = sysOaTaskDistributeService.getById(id);
SysOaTask task = sysOaTaskService.getById(taskDistribute.getTaskNo());
SysOaTaskDistribute sysOaTaskDistribute =new SysOaTaskDistribute(); SysOaTaskDistribute sysOaTaskDistribute =new SysOaTaskDistribute();
sysOaTaskDistribute.setId(id); sysOaTaskDistribute.setId(id);
sysOaTaskDistribute.setTaskStartTime(new Date()); sysOaTaskDistribute.setTaskStartTime(new Date());
sysOaTaskDistribute.setTaskExecuteStatus(DingFlowTaskType.PROCESSING.getCode()); sysOaTaskDistribute.setTaskExecuteStatus(DingFlowTaskType.RUNNING.getCode());
return toAjax(sysOaTaskDistributeService.updateSysOaTaskDistribute(sysOaTaskDistribute)); if(task.getSyncDingtalk()==1){
workRecodeService.updateTodoTaskExecutorStatus(ShiroUtils.getUserId(),sysOaTaskService.getOutTaskOutsideId(task.getTaskNo()),false);
}
return toAjax(sysOaTaskDistributeService.updateById(sysOaTaskDistribute));
} }
/** /**
* 处理系统任务 * 处理系统任务
*/ */
@GetMapping("/handle/{id}") @GetMapping("/handle/{id}")
public String handle(@PathVariable("id") Long id, ModelMap mmap) public String handle(@PathVariable("id") Long id, ModelMap mmap) {
{
SysOaTaskDistribute sysOaTaskDistribute = sysOaTaskDistributeService.selectSysOaTaskDistributeById(id); SysOaTaskDistribute sysOaTaskDistribute = sysOaTaskDistributeService.selectSysOaTaskDistributeById(id);
warpSysOaTask(Lists.newArrayList(sysOaTaskDistribute)); sysOaTaskDistributeService.warpSysOaTask(Lists.newArrayList(sysOaTaskDistribute));
mmap.put("sysOaTaskDistribute", sysOaTaskDistribute); mmap.put("sysOaTaskDistribute", sysOaTaskDistribute);
return prefix + "/handle"; return prefix + "/handle";
} }
@ -224,18 +204,102 @@ public class SysOaTaskController extends BaseController
@Log(title = "系统任务", businessType = BusinessType.UPDATE) @Log(title = "系统任务", businessType = BusinessType.UPDATE)
@PostMapping("/handle") @PostMapping("/handle")
@ResponseBody @ResponseBody
public AjaxResult handleSave(SysOaTaskDistribute sysOaTaskDistribute) public AjaxResult handleSave(SysOaTaskDistribute sysOaTaskDistribute) {
{ SysOaTaskDistribute taskDistribute = sysOaTaskDistributeService.getById(sysOaTaskDistribute.getId());
SysOaTask task = sysOaTaskService.getById(taskDistribute.getTaskNo());
sysOaTaskDistribute.setTaskCompleteTime(new Date()); sysOaTaskDistribute.setTaskCompleteTime(new Date());
sysOaTaskDistribute.setTaskExecuteId(String.valueOf(ShiroUtils.getUserId())); sysOaTaskDistribute.setTaskExecuteId(String.valueOf(ShiroUtils.getUserId()));
sysOaTaskDistribute.setUpdateBy(String.valueOf(ShiroUtils.getUserId()));
sysOaTaskDistribute.setTaskExecuteStatus(DingFlowTaskType.COMPLETED.getCode()); sysOaTaskDistribute.setTaskExecuteStatus(DingFlowTaskType.COMPLETED.getCode());
//发送站内信
sendInnerMessage(sysOaTaskDistribute); sendInnerMessage(sysOaTaskDistribute);
//事件发送 //更新钉钉任务状态
SyncEvent<SysOaTaskDistribute> syncEvent = new SyncEvent(sysOaTaskDistribute, DingTalkListenerType.UPDATE_TODO_TASK_EXECUTOR_STATUS); if(task.getSyncDingtalk()==1){
applicationContext.publishEvent(syncEvent); workRecodeService.updateTodoTaskExecutorStatus(ShiroUtils.getUserId(),task.getTaskOutsideId(),true);
return toAjax(sysOaTaskDistributeService.updateSysOaTaskDistribute(sysOaTaskDistribute));
} }
return toAjax(sysOaTaskDistributeService.updateById(sysOaTaskDistribute));
}
/**
* 修改系统任务
*/
@GetMapping("/edit/{taskNo}")
public String edit(@PathVariable("taskNo") String taskNo, ModelMap mmap) {
SysOaTask sysOaTask = sysOaTaskService.selectSysOaTaskById(taskNo);
mmap.put("sysOaTask", sysOaTask);
return prefix + "/edit";
}
/**
* 修改保存系统任务
*/
@RequiresPermissions("system:task:edit")
@Log(title = "系统任务", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(SysOaTask sysOaTask) {
LambdaQueryWrapper<SysOaTaskDistribute> eq = new QueryWrapper<SysOaTaskDistribute>().lambda().ne(SysOaTaskDistribute::getTaskExecuteStatus, DingFlowTaskType.NEW.getCode())
.eq(SysOaTaskDistribute::getTaskNo, sysOaTask.getTaskNo());
if(CollUtil.isNotEmpty(sysOaTaskDistributeService.list(eq))){
return AjaxResult.error("只有待执行任务,才能编辑任务");
}
sysOaTask.setUpdateBy(ShiroUtils.getUserId().toString());
if(sysOaTask.getSyncDingtalk()==1){
workRecodeService.updateTodoTask(sysOaTask);
}
return toAjax(sysOaTaskService.updateById(sysOaTask));
}
/**
* 任务详情
* @param taskNo 任务编码
* @param mmap
* @return
*/
@GetMapping("/detail/{id}")
@RequiresPermissions("system:task:detail")
public String detail(@PathVariable("id") String taskNo, ModelMap mmap) {
SysOaTask sysOaTask = sysOaTaskService.selectSysOaTaskById(taskNo);
SysOaTaskDistribute sysOaTaskDistribute=new SysOaTaskDistribute();
sysOaTaskDistribute.setTaskNo(taskNo);
List<SysOaTaskDistribute> sysOaTaskDistributes = sysOaTaskDistributeService.selectSysOaTaskDistributeList(sysOaTaskDistribute);
mmap.put("sysOaTask", sysOaTask);
mmap.put("sysOaTaskDistributes", sysOaTaskDistributes);
return prefix + "/detail";
}
/**
* 我处理的详情
* @param id
* @param mmap
* @return
*/
@GetMapping("/taskDistributedDetail/{id}")
@RequiresPermissions("system:task:taskDistributedDetail")
public String taskDistributedDetail(@PathVariable("id") Long id, ModelMap mmap) {
SysOaTaskDistribute sysOaTaskDistribute = sysOaTaskDistributeService.selectSysOaTaskDistributeById(id);
sysOaTaskDistributeService.warpSysOaTask(Lists.newArrayList(sysOaTaskDistribute));
mmap.put("sysOaTask", sysOaTaskDistribute);
return prefix + "/taskDistributedDetail";
}
/**
* 任务分配详情
* @param id
* @param mmap
* @return
*/
@GetMapping("/taskDistribute/detail/{id}")
@RequiresPermissions("system:taskDistribute:detail")
public String taskDistributeDetail(@PathVariable("id") Long id, ModelMap mmap) {
SysOaTaskDistribute sysOaTaskDistribute = sysOaTaskDistributeService.selectSysOaTaskDistributeById(id);
sysOaTaskDistributeService.warpSysOaTask(Lists.newArrayList(sysOaTaskDistribute));
mmap.put("sysOaTask", sysOaTaskDistribute);
return prefix + "/taskDistributeDetail";
}
/** /**
* 发送站内信 * 发送站内信
@ -256,112 +320,5 @@ public class SysOaTaskController extends BaseController
messageEventDTO.setTemplateCode(MessageConstants.INNER_SYS_TASK_COMPLETE); messageEventDTO.setTemplateCode(MessageConstants.INNER_SYS_TASK_COMPLETE);
applicationContext.publishEvent(messageEventDTO); applicationContext.publishEvent(messageEventDTO);
} }
/**
* 修改系统任务
*/
@GetMapping("/edit/{taskNo}")
public String edit(@PathVariable("taskNo") String taskNo, ModelMap mmap)
{
SysOaTask sysOaTask = sysOaTaskService.selectSysOaTaskById(taskNo);
mmap.put("sysOaTask", sysOaTask);
return prefix + "/edit";
}
/**
* 修改保存系统任务
*/
@RequiresPermissions("system:task:edit")
@Log(title = "系统任务", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(SysOaTask sysOaTask)
{
SysOaTaskDistribute sysOaTaskDistribute=new SysOaTaskDistribute();
sysOaTaskDistribute.setSysOaTask(sysOaTask);
SyncEvent<SysOaTaskDistribute> syncEvent = new SyncEvent(sysOaTaskDistribute, DingTalkListenerType.WORK_RECORD_UPDATE);
applicationContext.publishEvent(syncEvent);
return toAjax(sysOaTaskService.updateSysOaTask(sysOaTask));
}
/**
* 删除系统任务
*/
@RequiresPermissions("system:task:remove")
@Log(title = "系统任务", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(sysOaTaskService.deleteSysOaTaskByIds(ids));
}
/**
* 任务详情
* @param taskNo 任务编码
* @param mmap
* @return
*/
@GetMapping("/detail/{id}")
@RequiresPermissions("system:task:detail")
public String detail(@PathVariable("id") String taskNo, ModelMap mmap)
{
SysOaTask sysOaTask = sysOaTaskService.selectSysOaTaskById(taskNo);
SysOaTaskDistribute sysOaTaskDistribute=new SysOaTaskDistribute();
sysOaTaskDistribute.setTaskNo(taskNo);
List<SysOaTaskDistribute> sysOaTaskDistributes = sysOaTaskDistributeService.selectSysOaTaskDistributeList(sysOaTaskDistribute);
mmap.put("sysOaTask", sysOaTask);
mmap.put("sysOaTaskDistributes", sysOaTaskDistributes);
return prefix + "/detail";
}
/**
* 我处理的详情
* @param taskNo
* @param mmap
* @return
*/
@GetMapping("/taskDistributedDetail/{id}")
@RequiresPermissions("system:task:taskDistributedDetail")
public String taskDistributedDetail(@PathVariable("id") Long id, ModelMap mmap)
{
SysOaTaskDistribute sysOaTaskDistribute = sysOaTaskDistributeService.selectSysOaTaskDistributeById(id);
warpSysOaTask(Lists.newArrayList(sysOaTaskDistribute));
mmap.put("sysOaTask", sysOaTaskDistribute);
return prefix + "/taskDistributedDetail";
}
/**
* 任务分配详情
* @param id
* @param mmap
* @return
*/
@GetMapping("/taskDistribute/detail/{id}")
@RequiresPermissions("system:taskDistribute:detail")
public String taskDistributeDetail(@PathVariable("id") Long id, ModelMap mmap)
{
SysOaTaskDistribute sysOaTaskDistribute = sysOaTaskDistributeService.selectSysOaTaskDistributeById(id);
warpSysOaTask(Lists.newArrayList(sysOaTaskDistribute));
mmap.put("sysOaTask", sysOaTaskDistribute);
return prefix + "/taskDistributeDetail";
}
private void warpSysOaTask(List<SysOaTaskDistribute> sysOaTaskDistributes){
sysOaTaskDistributes.forEach(t->{
SysOaTask sysOaTask = sysOaTaskService.selectSysOaTaskById(t.getTaskNo());
sysOaTask.setCreateBy(sysUserService.selectUserById(Long.parseLong(sysOaTask.getCreateBy())).getUserName());
if(ObjectUtil.isNotNull(t.getTaskDistributeId())){
t.setTaskDistributeId(sysUserService.selectUserById(Long.parseLong(t.getTaskDistributeId())).getUserName());
}
if(ObjectUtil.isNotNull(t.getTaskExecuteId())){
t.setTaskExecuteId(sysUserService.selectUserById(Long.parseLong(t.getTaskExecuteId())).getUserName());
}
if(ObjectUtil.isNotNull(t.getTaskStartTime())&&ObjectUtil.isNotNull(t.getTaskCompleteTime())){
t.setSpendTime(DateUtil.formatBetween(t.getTaskStartTime(),t.getTaskCompleteTime(), BetweenFormater.Level.SECOND));
}
t.setSysOaTask(sysOaTask);
t.setCreateBy(sysUserService.selectUserById(Long.parseLong(t.getCreateBy())).getUserName());
});
}
} }

View File

@ -5,7 +5,7 @@ snow:
# 版本 # 版本
version: 2.0.0 version: 2.0.0
# 版权年份 # 版权年份
copyrightYear: 2021 copyrightYear: 2022
# 实例演示开关 # 实例演示开关
demoEnabled: true demoEnabled: true
# 获取ip地址开关 # 获取ip地址开关

View File

@ -50,7 +50,7 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label is-required">期望完成时间:</label> <label class="col-sm-3 control-label is-required">期望完成时间:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<div class="input-group date"> <div class="input-group datetime">
<input name="expectedTime" class="datetime-input form-control" placeholder="yyyy-MM-dd HH:mm:ss" type="text" required> <input name="expectedTime" class="datetime-input form-control" placeholder="yyyy-MM-dd HH:mm:ss" type="text" required>
</div> </div>
</div> </div>
@ -61,12 +61,13 @@
<input name="taskSource" class="form-control" type="text"> <input name="taskSource" class="form-control" type="text">
</div> </div>
</div> </div>
<!-- <div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">任务跳转URL</label> <label class="col-sm-3 control-label is-required">是否创建钉钉待办</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input name="taskUrl" class="form-control" type="text"> <label class="radio-box"> <input type="radio" name="syncDingtalk" value="0" checked/></label>
<label class="radio-box"> <input type="radio" name="syncDingtalk" value="1" /></label>
</div>
</div> </div>
</div>-->
</form> </form>
</div> </div>
<div class="row"> <div class="row">

View File

@ -6,6 +6,7 @@
<body class="white-bg"> <body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content"> <div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-task-edit" th:object="${sysOaTask}"> <form class="form-horizontal m" id="form-task-edit" th:object="${sysOaTask}">
<input name="taskOutsideId" th:field="*{taskOutsideId}" type="hidden" >
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label is-required">任务编号:</label> <label class="col-sm-3 control-label is-required">任务编号:</label>
<div class="col-sm-8"> <div class="col-sm-8">
@ -42,30 +43,19 @@
<textarea name="taskContent" class="form-control" rows="7" th:field="*{taskContent}"></textarea> <textarea name="taskContent" class="form-control" rows="7" th:field="*{taskContent}"></textarea>
</div> </div>
</div> </div>
<div class="form-group">
<label class="col-sm-3 control-label">执行人:</label>
<div class="col-sm-8">
<div class="input-group">
<input class="form-control" type="hidden" name="taskDistributeId" id="taskDistributeId" th:field="*{taskDistributeId}">
<input class="form-control" type="text" name="transitionPersonName" onclick="selectUserInfo()" id="transitionPersonName" readonly="true">
<span class="input-group-addon"><i class="fa fa-search"></i></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">任务状态:</label>
<div class="col-sm-8">
<select name="taskStatus" class="form-control m-b" th:with="type=${@dict.getType('ding_task_status')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{taskStatus}"></option>
</select>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">任务来源:</label> <label class="col-sm-3 control-label">任务来源:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input name="taskSource" th:field="*{taskSource}" class="form-control" type="text"> <input name="taskSource" th:field="*{taskSource}" class="form-control" type="text">
</div> </div>
</div> </div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">是否创建钉钉待办:</label>
<div class="col-sm-8">
<label class="radio-box"> <input type="radio" name="syncDingtalk" value="0" checked/></label>
<label class="radio-box"> <input type="radio" name="syncDingtalk" value="1" /></label>
</div>
</div>
</form> </form>
</div> </div>
<th:block th:include="include :: footer" /> <th:block th:include="include :: footer" />
@ -74,24 +64,12 @@
$("#form-task-edit").validate({ $("#form-task-edit").validate({
focusCleanup: true focusCleanup: true
}); });
function selectUserInfo() {
var url = "/system/user/selectMultiUser";
$.modal.open("选择用户",url,"","",doSubmit);
}
function submitHandler() { function submitHandler() {
if ($.validate.form()) { if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-task-edit').serialize()); $.operate.save(prefix + "/edit", $('#form-task-edit').serialize());
} }
} }
function doSubmit(index, layero){
var body = layer.getChildFrame('body', index);
var iframeWin = layero.find('iframe')[0];
iframeWin.contentWindow.submitHandler(index, layero);
$("#taskDistributeId").val(body.find('#id').val());
$("#transitionPersonName").val(body.find('#userName').val());
layer.close(index);
}
</script> </script>
</body> </body>
</html> </html>

View File

@ -10,17 +10,19 @@
<div class="tabs-container"> <div class="tabs-container">
<div class="tabs-left"> <div class="tabs-left">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li class="active"> <li class="active">
<a data-toggle="tab" href="#tab-1"> 待处理 <span class="label label-info pull-right"></span></a> <a data-toggle="tab" href="#tab-1"> <span class="font-bold text-info"><i class="fa fa-tasks"></i> 待处理 </span> <span class="label label-info pull-right"></span></a>
</li> </li>
<li class=""> <li class="">
<a data-toggle="tab" href="#tab-2"> 我创建 <span class="label label-info pull-right" ></span></a> <a data-toggle="tab" href="#tab-2"> <span class="font-bold text-info"><i class="fa fa-paint-brush"></i> 我创建 </span> <span class="label label-info pull-right" ></span></a>
</li> </li>
<li class=""> <li class="">
<a data-toggle="tab" href="#tab-3"> 已处理 <span class="label label-info pull-right" ></span></a> <a data-toggle="tab" href="#tab-3"><span class="font-bold text-info"><i class="fa fa-map"></i> 已处理 </span> <span class="label label-info pull-right" ></span></a>
</li> </li>
</ul> </ul>
@ -92,7 +94,7 @@
</form> </form>
</div> </div>
<div class="btn-group-sm" id="toolbar2" role="group"> <div class="btn-group-sm" id="toolbar2" role="group">
<a class="btn btn-success" onclick="$.operate.addTab()" shiro:hasPermission="system:task:add"> <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:task:add">
<i class="fa fa-plus"></i> 添加 <i class="fa fa-plus"></i> 添加
</a> </a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:task:export"> <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:task:export">
@ -188,6 +190,7 @@
return row.sysOaTask.taskName; return row.sysOaTask.taskName;
} }
}, },
{ {
field: 'taskType', field: 'taskType',
title: '任务类型', title: '任务类型',
@ -195,6 +198,13 @@
return $.table.selectDictLabel(taskTypeDatas, row.sysOaTask.taskType); return $.table.selectDictLabel(taskTypeDatas, row.sysOaTask.taskType);
} }
}, },
{
field: 'taskExecuteStatus',
title: '执行状态',
formatter: function(value, row, index) {
return $.table.selectDictLabel(taskStatusDatas, row.sysOaTask.taskType);
}
},
{ {
field: 'createBy', field: 'createBy',
title: '指派人', title: '指派人',
@ -218,10 +228,10 @@
align: 'center', align: 'center',
formatter: function(value, row, index) { formatter: function(value, row, index) {
var actions = []; var actions = [];
if(row.taskExecuteStatus=='RUNNING') { if(row.taskExecuteStatus=='NEW') {
actions.push('<a class="btn btn-info btn-xs ' + startFlag + '" href="javascript:void(0)" onclick="startTask(\''+row.id+'\')"><i class="fa fa-hourglass-start"></i>开始</a> '); actions.push('<a class="btn btn-info btn-xs ' + startFlag + '" href="javascript:void(0)" onclick="startTask(\''+row.id+'\')"><i class="fa fa-hourglass-start"></i>开始</a> ');
} }
if(row.taskExecuteStatus=='PROCESSING') { if(row.taskExecuteStatus=='RUNNING') {
actions.push('<a class="btn btn-success btn-xs ' + handleFlag + '" href="javascript:void(0)" onclick="$.operate.handle(\'' + row.id + '\')"><i class="fa fa-edit"></i>处理</a>'); actions.push('<a class="btn btn-success btn-xs ' + handleFlag + '" href="javascript:void(0)" onclick="$.operate.handle(\'' + row.id + '\')"><i class="fa fa-edit"></i>处理</a>');
} }
return actions.join(''); return actions.join('');
@ -234,7 +244,6 @@
search.taskNo = $("#myTaskNo").val(); search.taskNo = $("#myTaskNo").val();
search.taskStatus = $("#myTaskStatus").val(); search.taskStatus = $("#myTaskStatus").val();
return search; return search;
} }
@ -251,7 +260,6 @@
onExpandRow : function(index, row, $detail) { onExpandRow : function(index, row, $detail) {
initChildTable(index, row, $detail); initChildTable(index, row, $detail);
}, },
modalName: "我创建", modalName: "我创建",
columns: [{ columns: [{
checkbox: true checkbox: true
@ -263,22 +271,25 @@
}, },
{ {
field: 'taskName', field: 'taskName',
title: '任务名称' title: '任务名称',
formatter: function(value, row, index) {
return $.table.tooltip(value);
}
}, },
{ {
field: 'taskContent', field: 'taskContent',
title: '任务内容', title: '任务内容',
formatter: function(value, row, index) { formatter: function(value, row, index) {
return row.taskContent.substring(0,20)+"..."; return $.table.tooltip(value);
} }
}, },
/* { {
field: 'taskStatus', field: 'taskStatus',
title: '任务状态', title: '任务状态',
formatter: function(value, row, index) { formatter: function(value, row, index) {
return $.table.selectDictLabel(taskStatusDatas, value); return $.table.selectDictLabel(taskStatusDatas, value);
} }
},*/ },
{ {
field: 'taskType', field: 'taskType',
title: '任务类型', title: '任务类型',
@ -286,10 +297,6 @@
return $.table.selectDictLabel(taskTypeDatas, value); return $.table.selectDictLabel(taskTypeDatas, value);
} }
}, },
{
field: 'taskSource',
title: '任务来源'
},
{ {
title: '操作', title: '操作',
align: 'center', align: 'center',
@ -297,7 +304,7 @@
var actions = []; var actions = [];
actions.push('<a class="btn btn-info btn-xs " href="javascript:void(0)" onclick="$.operate.detail(\'' + row.taskNo + '\')"><i class="fa fa-eye"></i>详情</a> '); actions.push('<a class="btn btn-info btn-xs " href="javascript:void(0)" onclick="$.operate.detail(\'' + row.taskNo + '\')"><i class="fa fa-eye"></i>详情</a> ');
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.taskNo + '\')"><i class="fa fa-edit"></i>编辑</a> '); actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.taskNo + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.taskNo + '\')"><i class="fa fa-remove"></i>删除</a>'); /* actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.taskNo + '\')"><i class="fa fa-remove"></i>删除</a>');*/
return actions.join(''); return actions.join('');
} }
}] }]

View File

@ -1,9 +1,14 @@
package com.snow.common.annotation; package com.snow.common.annotation;
import com.snow.common.utils.poi.ExcelHandlerAdapter;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.IndexedColors;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import java.math.BigDecimal;
/** /**
* 自定义导出Excel数据注解 * 自定义导出Excel数据注解
@ -45,9 +50,14 @@ public @interface Excel
public String separator() default ","; public String separator() default ",";
/** /**
* 导出类型0数字 1字符串 * BigDecimal 精度 默认:-1(默认不开启BigDecimal格式化)
*/ */
public ColumnType cellType() default ColumnType.STRING; public int scale() default -1;
/**
* BigDecimal 舍入规则 默认:BigDecimal.ROUND_HALF_EVEN
*/
public int roundingMode() default BigDecimal.ROUND_HALF_EVEN;
/** /**
* 导出时在excel中每个列的高度 单位为字符 * 导出时在excel中每个列的高度 单位为字符
@ -89,6 +99,36 @@ public @interface Excel
*/ */
public String targetAttr() default ""; public String targetAttr() default "";
/**
* 是否自动统计数据,在最后追加一行统计数据总和
*/
public boolean isStatistics() default false;
/**
* 导出类型0数字 1字符串
*/
public ColumnType cellType() default ColumnType.STRING;
/**
* 导出字体颜色
*/
public IndexedColors color() default IndexedColors.BLACK;
/**
* 导出字段对齐方式
*/
public HorizontalAlignment align() default HorizontalAlignment.CENTER;
/**
* 自定义数据处理器
*/
public Class<?> handler() default ExcelHandlerAdapter.class;
/**
* 自定义数据处理器参数
*/
public String[] args() default {};
/** /**
* 字段类型0导出导入1仅导出2仅导入 * 字段类型0导出导入1仅导出2仅导入
*/ */
@ -112,7 +152,7 @@ public @interface Excel
public enum ColumnType public enum ColumnType
{ {
NUMERIC(0), STRING(1); NUMERIC(0), STRING(1), IMAGE(2);
private final int value; private final int value;
ColumnType(int value) ColumnType(int value)

View File

@ -1,4 +1,4 @@
package com.snow.system.domain; package com.snow.common.core.domain;
import javax.validation.constraints.*; import javax.validation.constraints.*;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;

View File

@ -1,4 +1,4 @@
package com.snow.system.domain; package com.snow.common.core.domain;
import javax.validation.constraints.*; import javax.validation.constraints.*;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;

View File

@ -9,15 +9,11 @@ package com.snow.common.enums;
public enum DingFlowTaskType { public enum DingFlowTaskType {
NEW("NEW", "未启动"), NEW("NEW", "未启动"),
RUNNING("RUNNING", "处理"), RUNNING("RUNNING", "处理"),
PAUSED("PAUSED", "暂停"), PAUSED("PAUSED", "暂停"),
CANCELED("CANCELED", "取消"), CANCELED("CANCELED", "取消"),
COMPLETED("COMPLETED", "完成"), COMPLETED("COMPLETED", "完成"),
TERMINATED("TERMINATED", "终止"), TERMINATED("TERMINATED", "终止"),
//20211015
PROCESSING("PROCESSING","处理中")
; ;
private final String code; private final String code;

View File

@ -3,6 +3,7 @@ package com.snow.common.utils;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.*;
import java.util.Date; import java.util.Date;
import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateFormatUtils;
@ -159,5 +160,22 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
return day + "" + hour + "小时" + min + "分钟"; return day + "" + hour + "小时" + min + "分钟";
} }
/**
* 增加 LocalDateTime ==> Date
*/
public static Date toDate(LocalDateTime temporalAccessor)
{
ZonedDateTime zdt = temporalAccessor.atZone(ZoneId.systemDefault());
return Date.from(zdt.toInstant());
}
/**
* 增加 LocalDate ==> Date
*/
public static Date toDate(LocalDate temporalAccessor)
{
LocalDateTime localDateTime = LocalDateTime.of(temporalAccessor, LocalTime.of(0, 0, 0));
ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
return Date.from(zdt.toInstant());
}
} }

View File

@ -1,11 +1,11 @@
package com.snow.system.utils; package com.snow.common.utils;
import java.util.List; import java.util.List;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.snow.common.constant.Constants; import com.snow.common.constant.Constants;
import com.snow.common.utils.CacheUtils; import com.snow.common.utils.CacheUtils;
import com.snow.common.utils.StringUtils; import com.snow.common.utils.StringUtils;
import com.snow.system.domain.SysDictData; import com.snow.common.core.domain.SysDictData;
/** /**
* 字典工具类 * 字典工具类
@ -42,8 +42,7 @@ public class DictUtils
Object cacheObj = CacheUtils.get(getCacheName(), getCacheKey(key)); Object cacheObj = CacheUtils.get(getCacheName(), getCacheKey(key));
if (StringUtils.isNotNull(cacheObj)) if (StringUtils.isNotNull(cacheObj))
{ {
List<SysDictData> DictDatas = StringUtils.cast(cacheObj); return StringUtils.cast(cacheObj);
return DictDatas;
} }
return null; return null;
} }
@ -93,7 +92,7 @@ public class DictUtils
{ {
if (value.equals(dict.getDictValue())) if (value.equals(dict.getDictValue()))
{ {
propertyString.append(dict.getDictLabel() + separator); propertyString.append(dict.getDictLabel()).append(separator);
break; break;
} }
} }
@ -133,7 +132,7 @@ public class DictUtils
{ {
if (label.equals(dict.getDictLabel())) if (label.equals(dict.getDictLabel()))
{ {
propertyString.append(dict.getDictValue() + separator); propertyString.append(dict.getDictValue()).append(separator);
break; break;
} }
} }
@ -152,6 +151,16 @@ public class DictUtils
return StringUtils.stripEnd(propertyString.toString(), separator); return StringUtils.stripEnd(propertyString.toString(), separator);
} }
/**
* 删除指定字典缓存
*
* @param key 字典键
*/
public static void removeDictCache(String key)
{
CacheUtils.remove(getCacheName(), getCacheKey(key));
}
/** /**
* 清空字典缓存 * 清空字典缓存
*/ */

View File

@ -132,7 +132,7 @@ public class FileUploadUtils
* @return * @return
* @throws IOException * @throws IOException
*/ */
private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException public static File getAbsoluteFile(String uploadDir, String fileName) throws IOException
{ {
File desc = new File(uploadDir + File.separator + fileName); File desc = new File(uploadDir + File.separator + fileName);
@ -146,7 +146,7 @@ public class FileUploadUtils
return desc; return desc;
} }
private static final String getPathFileName(String uploadDir, String fileName) throws IOException public static final String getPathFileName(String uploadDir, String fileName) throws IOException
{ {
int dirLastIndex = defaultBaseDir.length() + 1; int dirLastIndex = defaultBaseDir.length() + 1;
String currentDir = StringUtils.substring(uploadDir, dirLastIndex); String currentDir = StringUtils.substring(uploadDir, dirLastIndex);

View File

@ -1,14 +1,14 @@
package com.snow.common.utils.file; package com.snow.common.utils.file;
import com.snow.common.config.Global;
import com.snow.common.utils.DateUtils;
import com.snow.common.utils.uuid.IdUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.io.File; import java.io.*;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -19,66 +19,46 @@ import javax.servlet.http.HttpServletResponse;
* *
* @author snow * @author snow
*/ */
public class FileUtils extends org.apache.commons.io.FileUtils public class FileUtils extends org.apache.commons.io.FileUtils {
{
public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+"; public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+";
/** /**
* 输出指定文件的byte数组 * 写数据到文件中
* *
* @param filePath 文件路径 * @param data 数据
* @param os 输出流 * @return 目标文件
* @return * @throws IOException IO异常
*/ */
public static void writeBytes(String filePath, OutputStream os) throws IOException public static String writeImportBytes(byte[] data) throws IOException
{ {
FileInputStream fis = null; return writeBytes(data, Global.getDownloadPath());
try
{
File file = new File(filePath);
if (!file.exists())
{
throw new FileNotFoundException(filePath);
}
fis = new FileInputStream(file);
byte[] b = new byte[1024];
int length;
while ((length = fis.read(b)) > 0)
{
os.write(b, 0, length);
}
}
catch (IOException e)
{
throw e;
}
finally
{
if (os != null)
{
try
{
os.close();
}
catch (IOException e1)
{
e1.printStackTrace();
}
}
if (fis != null)
{
try
{
fis.close();
}
catch (IOException e1)
{
e1.printStackTrace();
}
}
}
} }
/**
* 写数据到文件中
*
* @param data 数据
* @param uploadDir 目标文件
* @return 目标文件
* @throws IOException IO异常
*/
public static String writeBytes(byte[] data, String uploadDir) throws IOException
{
FileOutputStream fos = null;
String pathName = "";
try {
String extension = getFileExtendName(data);
pathName = DateUtils.datePath() + "/" + IdUtils.fastUUID() + "." + extension;
File file = FileUploadUtils.getAbsoluteFile(uploadDir, pathName);
fos = new FileOutputStream(file);
fos.write(data);
} finally {
IOUtils.closeQuietly(fos);
}
return FileUploadUtils.getPathFileName(uploadDir, pathName);
}
/** /**
* 删除文件 * 删除文件
* *
@ -205,4 +185,105 @@ public class FileUtils extends org.apache.commons.io.FileUtils
String encode = URLEncoder.encode(s, StandardCharsets.UTF_8.toString()); String encode = URLEncoder.encode(s, StandardCharsets.UTF_8.toString());
return encode.replaceAll("\\+", "%20"); return encode.replaceAll("\\+", "%20");
} }
/**
* 输出指定文件的byte数组
*
* @param filePath 文件路径
* @param os 输出流
* @return
*/
public static void writeBytes(String filePath, OutputStream os) throws IOException
{
FileInputStream fis = null;
try
{
File file = new File(filePath);
if (!file.exists())
{
throw new FileNotFoundException(filePath);
}
fis = new FileInputStream(file);
byte[] b = new byte[1024];
int length;
while ((length = fis.read(b)) > 0)
{
os.write(b, 0, length);
}
}
catch (IOException e)
{
throw e;
}
finally
{
IOUtils.closeQuietly(os);
IOUtils.closeQuietly(fis);
}
}
/**
* 获取图像后缀
*
* @param photoByte 图像数据
* @return 后缀名
*/
public static String getFileExtendName(byte[] photoByte)
{
String strFileExtendName = "jpg";
if ((photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56)
&& ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97))
{
strFileExtendName = "gif";
}
else if ((photoByte[6] == 74) && (photoByte[7] == 70) && (photoByte[8] == 73) && (photoByte[9] == 70))
{
strFileExtendName = "jpg";
}
else if ((photoByte[0] == 66) && (photoByte[1] == 77))
{
strFileExtendName = "bmp";
}
else if ((photoByte[1] == 80) && (photoByte[2] == 78) && (photoByte[3] == 71))
{
strFileExtendName = "png";
}
return strFileExtendName;
}
/**
* 获取文件名称 /profile/upload/2022/04/16/ruoyi.png -- ruoyi.png
*
* @param fileName 路径名称
* @return 没有文件路径的名称
*/
public static String getName(String fileName)
{
if (fileName == null)
{
return null;
}
int lastUnixPos = fileName.lastIndexOf('/');
int lastWindowsPos = fileName.lastIndexOf('\\');
int index = Math.max(lastUnixPos, lastWindowsPos);
return fileName.substring(index + 1);
}
/**
* 获取不带后缀文件名称 /profile/upload/2022/04/16/ruoyi.png -- ruoyi
*
* @param fileName 路径名称
* @return 没有文件路径和后缀的名称
*/
public static String getNameNotSuffix(String fileName)
{
if (fileName == null)
{
return null;
}
String baseName = FilenameUtils.getBaseName(fileName);
return baseName;
}
} }

View File

@ -0,0 +1,86 @@
package com.snow.common.utils.file;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.util.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.Arrays;
/**
* 图片处理工具类
*
* @author ruoyi
*/
@Slf4j
public class ImageUtils
{
public static byte[] getImage(String imagePath)
{
InputStream is = getFile(imagePath);
try
{
return IOUtils.toByteArray(is);
}
catch (Exception e)
{
log.error("图片加载异常 {}", e);
return null;
}
finally
{
IOUtils.closeQuietly(is);
}
}
public static InputStream getFile(String imagePath)
{
try
{
byte[] result = readFile(imagePath);
result = Arrays.copyOf(result, result.length);
return new ByteArrayInputStream(result);
}
catch (Exception e)
{
log.error("获取图片异常 {}", e);
}
return null;
}
/**
* 读取文件为字节数据
*
* @param url 地址
* @return 字节数据
*/
public static byte[] readFile(String url)
{
InputStream in = null;
try
{
// 网络地址
URL urlObj = new URL(url);
URLConnection urlConnection = urlObj.openConnection();
urlConnection.setConnectTimeout(30 * 1000);
urlConnection.setReadTimeout(60 * 1000);
urlConnection.setDoInput(true);
in = urlConnection.getInputStream();
return IOUtils.toByteArray(in);
}
catch (Exception e)
{
log.error("访问文件异常 {}", e);
return null;
}
finally
{
IOUtils.closeQuietly(in);
}
}
}

View File

@ -0,0 +1,19 @@
package com.snow.common.utils.poi;
/**
* Excel数据格式处理适配器
*
* @author ruoyi
*/
public interface ExcelHandlerAdapter
{
/**
* 格式化
*
* @param value 单元格数据值
* @param args excel注解args参数组
*
* @return 处理后的值
*/
Object format(Object value, String[] args);
}

View File

@ -1,6 +1,7 @@
package com.snow.dingtalk.listener; package com.snow.dingtalk.listener;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.aliyun.dingtalktodo_1_0.models.GetTodoTaskBySourceIdResponseBody; import com.aliyun.dingtalktodo_1_0.models.GetTodoTaskBySourceIdResponseBody;
import com.snow.common.enums.DingTalkListenerType; import com.snow.common.enums.DingTalkListenerType;
@ -36,9 +37,9 @@ public class WorkRecodeEventService implements ISyncDingTalkInfo {
Integer code = eventType.getCode(); Integer code = eventType.getCode();
//钉钉创建待办 //钉钉创建待办
if(code.equals(DingTalkListenerType.WORK_RECODE_CREATE.getCode())){ if(code.equals(DingTalkListenerType.WORK_RECODE_CREATE.getCode())){
SysOaTask sysOaTask=(SysOaTask)syncEvent.getSource(); String sysOaTask=(String)syncEvent.getSource();
log.info("@@创建钉钉待办系统传入的参数:{}",JSON.toJSONString(sysOaTask)); log.info("@@创建钉钉待办系统传入的参数:{}",JSON.toJSONString(sysOaTask));
workRecodeService.createTodoTask(sysOaTask); workRecodeService.createTodoTask(JSONUtil.toBean(sysOaTask,SysOaTask.class));
} }
//更新钉钉待办 //更新钉钉待办
if(code.equals(DingTalkListenerType.WORK_RECORD_UPDATE.getCode())){ if(code.equals(DingTalkListenerType.WORK_RECORD_UPDATE.getCode())){
@ -55,12 +56,12 @@ public class WorkRecodeEventService implements ISyncDingTalkInfo {
//更新任务状态 //更新任务状态
if(code.equals(DingTalkListenerType.UPDATE_TODO_TASK_EXECUTOR_STATUS.getCode())){ if(code.equals(DingTalkListenerType.UPDATE_TODO_TASK_EXECUTOR_STATUS.getCode())){
SysOaTaskDistribute sysOaTaskDistribute=(SysOaTaskDistribute)syncEvent.getSource(); SysOaTaskDistribute sysOaTaskDistribute=(SysOaTaskDistribute)syncEvent.getSource();
GetTodoTaskBySourceIdResponseBody body = workRecodeService.getTodoTaskByBusinessId(String.valueOf(sysOaTaskDistribute.getId())); GetTodoTaskBySourceIdResponseBody body = workRecodeService.getTodoTaskByBusinessId(String.valueOf(sysOaTaskDistribute.getTaskNo()));
boolean isComplete=false; boolean isComplete=false;
if(ObjectUtil.isNotNull(sysOaTaskDistribute.getTaskCompleteTime())){ if(ObjectUtil.isNotNull(sysOaTaskDistribute.getTaskCompleteTime())){
isComplete=true; isComplete=true;
} }
workRecodeService.updateTodoTaskExecutorStatus(body.getId(),isComplete); workRecodeService.updateTodoTaskExecutorStatus(Long.parseLong(sysOaTaskDistribute.getTaskExecuteId()),body.getId(),isComplete);
} }
//钉钉发送普通消息 //钉钉发送普通消息
if(code.equals(DingTalkListenerType.ASYNCSEND_V2.getCode())){ if(code.equals(DingTalkListenerType.ASYNCSEND_V2.getCode())){

View File

@ -52,7 +52,7 @@ public interface WorkRecodeService {
* @param status 是否 * @param status 是否
* @return * @return
*/ */
Boolean updateTodoTaskExecutorStatus(String taskId,Boolean status); Boolean updateTodoTaskExecutorStatus(Long userId,String taskId,Boolean status);
/** /**
* 根据业务id获取待办详情() * 根据业务id获取待办详情()

View File

@ -1,7 +1,9 @@
package com.snow.dingtalk.service.impl; package com.snow.dingtalk.service.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.aliyun.dingtalktodo_1_0.Client; import com.aliyun.dingtalktodo_1_0.Client;
import com.aliyun.dingtalktodo_1_0.models.*; import com.aliyun.dingtalktodo_1_0.models.*;
@ -28,9 +30,7 @@ import com.snow.dingtalk.service.UserService;
import com.snow.dingtalk.service.WorkRecodeService; import com.snow.dingtalk.service.WorkRecodeService;
import com.snow.framework.util.ShiroUtils; import com.snow.framework.util.ShiroUtils;
import com.snow.system.domain.SysOaTask; import com.snow.system.domain.SysOaTask;
import com.snow.system.service.ISysMessageTemplateService; import com.snow.system.domain.SysOaTaskDistribute;
import com.snow.system.service.ISysUserService;
import com.snow.system.service.impl.SysConfigServiceImpl;
import com.taobao.api.ApiException; import com.taobao.api.ApiException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
@ -51,14 +51,9 @@ import java.util.stream.Collectors;
@Service @Service
public class WorkRecodeServiceImpl extends BaseService implements WorkRecodeService { public class WorkRecodeServiceImpl extends BaseService implements WorkRecodeService {
private SysConfigServiceImpl isysConfigService=SpringUtils.getBean(SysConfigServiceImpl.class);
private ISysMessageTemplateService sysMessageTemplateService=SpringUtils.getBean(ISysMessageTemplateService.class);
private UserService userService=SpringUtils.getBean(UserService.class); private UserService userService=SpringUtils.getBean(UserService.class);
private ISysUserService sysUserService=SpringUtils.getBean(ISysUserService.class);
/** /**
* 创建工作待办 * 创建工作待办
@ -120,6 +115,7 @@ public class WorkRecodeServiceImpl extends BaseService implements WorkRecodeServ
} }
try { try {
CreateTodoTaskResponse response = createTodoClient().createTodoTaskWithOptions(userService.getUnionIdBySysUserId(Long.parseLong(sysOaTask.getCreateBy())), createTodoTaskRequest, createTodoTaskHeaders, new RuntimeOptions()); CreateTodoTaskResponse response = createTodoClient().createTodoTaskWithOptions(userService.getUnionIdBySysUserId(Long.parseLong(sysOaTask.getCreateBy())), createTodoTaskRequest, createTodoTaskHeaders, new RuntimeOptions());
log.info("@@创建钉钉待办返回参数:{}", JSONUtil.toJsonStr(response));
return response.getBody().id; return response.getBody().id;
} catch (Exception err) { } catch (Exception err) {
log.error("@@调用钉钉创建待办的时候出现异常,异常信息为:{}",err.getMessage()); log.error("@@调用钉钉创建待办的时候出现异常,异常信息为:{}",err.getMessage());
@ -150,21 +146,23 @@ public class WorkRecodeServiceImpl extends BaseService implements WorkRecodeServ
updateTodoTaskHeaders.xAcsDingtalkAccessToken = getDingTalkTokenV2(); updateTodoTaskHeaders.xAcsDingtalkAccessToken = getDingTalkTokenV2();
UpdateTodoTaskRequest updateTodoTaskRequest = new UpdateTodoTaskRequest() UpdateTodoTaskRequest updateTodoTaskRequest = new UpdateTodoTaskRequest()
.setSubject(sysOaTask.getTaskName()) .setSubject(sysOaTask.getTaskName())
.setDescription(sysOaTask.getTaskContent()) .setDescription(sysOaTask.getTaskContent());
.setExecutorIds(Arrays.asList( List<String> taskDistributeId = sysOaTask.getTaskDistributeId();
"" //执行者id
)); if(CollUtil.isNotEmpty(taskDistributeId)){
//设置是否完成 List<String> executorIds = taskDistributeId.stream().map(t -> {
if(ObjectUtil.isNotNull(sysOaTask.getTaskCompleteTime())){ return userService.getUnionIdBySysUserId(Long.parseLong(t));
updateTodoTaskRequest.setDone(true); }).collect(Collectors.toList());
}else { updateTodoTaskRequest.setExecutorIds(executorIds);
updateTodoTaskRequest.setDone(false);
} }
//设置是否完成
updateTodoTaskRequest.setDone(ObjectUtil.isNotNull(sysOaTask.getTaskCompleteTime()));
if(ObjectUtil.isNotNull(sysOaTask.getExpectedTime())){ if(ObjectUtil.isNotNull(sysOaTask.getExpectedTime())){
updateTodoTaskRequest.setDueTime(sysOaTask.getExpectedTime().getTime()); updateTodoTaskRequest.setDueTime(sysOaTask.getExpectedTime().getTime());
} }
try { try {
UpdateTodoTaskResponse updateTodoTaskResponse = createTodoClient().updateTodoTaskWithOptions(userService.getUnionIdBySysUserId(Long.parseLong(sysOaTask.getUpdateBy())), sysOaTask.getDingTaskId(), updateTodoTaskRequest, updateTodoTaskHeaders, new RuntimeOptions()); String unionId=userService.getUnionIdBySysUserId(Long.parseLong(sysOaTask.getUpdateBy()));
UpdateTodoTaskResponse updateTodoTaskResponse = createTodoClient().updateTodoTaskWithOptions(unionId, sysOaTask.getTaskOutsideId(), updateTodoTaskRequest, updateTodoTaskHeaders, new RuntimeOptions());
return updateTodoTaskResponse.getBody().result; return updateTodoTaskResponse.getBody().result;
}catch (Exception err) { }catch (Exception err) {
log.error("@@调用钉钉更新待办的时候出现异常,异常信息为:{}",err.getMessage()); log.error("@@调用钉钉更新待办的时候出现异常,异常信息为:{}",err.getMessage());
@ -173,18 +171,17 @@ public class WorkRecodeServiceImpl extends BaseService implements WorkRecodeServ
} }
@Override @Override
public Boolean updateTodoTaskExecutorStatus(String taskId,Boolean status) { public Boolean updateTodoTaskExecutorStatus(Long userId,String taskId,Boolean status) {
String unionId= userService.getUnionIdBySysUserId(userId);
UpdateTodoTaskExecutorStatusHeaders updateTodoTaskExecutorStatusHeaders = new UpdateTodoTaskExecutorStatusHeaders(); UpdateTodoTaskExecutorStatusHeaders updateTodoTaskExecutorStatusHeaders = new UpdateTodoTaskExecutorStatusHeaders();
updateTodoTaskExecutorStatusHeaders.xAcsDingtalkAccessToken = getDingTalkTokenV2(); updateTodoTaskExecutorStatusHeaders.xAcsDingtalkAccessToken = getDingTalkTokenV2();
UpdateTodoTaskExecutorStatusRequest.UpdateTodoTaskExecutorStatusRequestExecutorStatusList executorStatusList0 = new UpdateTodoTaskExecutorStatusRequest.UpdateTodoTaskExecutorStatusRequestExecutorStatusList() UpdateTodoTaskExecutorStatusRequest.UpdateTodoTaskExecutorStatusRequestExecutorStatusList executorStatusList0 = new UpdateTodoTaskExecutorStatusRequest.UpdateTodoTaskExecutorStatusRequestExecutorStatusList()
.setId(taskId) .setId(unionId)
.setIsDone(status); .setIsDone(status);
UpdateTodoTaskExecutorStatusRequest updateTodoTaskExecutorStatusRequest = new UpdateTodoTaskExecutorStatusRequest() UpdateTodoTaskExecutorStatusRequest updateTodoTaskExecutorStatusRequest = new UpdateTodoTaskExecutorStatusRequest()
.setExecutorStatusList(Arrays.asList( .setExecutorStatusList(CollUtil.newArrayList(executorStatusList0));
executorStatusList0
));
try { try {
UpdateTodoTaskExecutorStatusResponse response = createTodoClient().updateTodoTaskExecutorStatusWithOptions("PUoiinWIpa2yH2ymhiiGiP6g", taskId, updateTodoTaskExecutorStatusRequest, updateTodoTaskExecutorStatusHeaders, new RuntimeOptions()); UpdateTodoTaskExecutorStatusResponse response = createTodoClient().updateTodoTaskExecutorStatusWithOptions(unionId, taskId, updateTodoTaskExecutorStatusRequest, updateTodoTaskExecutorStatusHeaders, new RuntimeOptions());
return response.getBody().result; return response.getBody().result;
} catch (Exception err) { } catch (Exception err) {
log.error("@@调用钉钉更新办状态的时候出现异常,异常信息为:{}",err.getMessage()); log.error("@@调用钉钉更新办状态的时候出现异常,异常信息为:{}",err.getMessage());

View File

@ -3,7 +3,7 @@ package com.snow.framework.web.service;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.snow.system.domain.SysDictData; import com.snow.common.core.domain.SysDictData;
import com.snow.system.service.ISysDictDataService; import com.snow.system.service.ISysDictDataService;
import com.snow.system.service.ISysDictTypeService; import com.snow.system.service.ISysDictTypeService;

View File

@ -1,17 +1,5 @@
package com.snow.quartz.controller; package com.snow.quartz.controller;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.snow.common.annotation.Log; import com.snow.common.annotation.Log;
import com.snow.common.core.controller.BaseController; import com.snow.common.core.controller.BaseController;
import com.snow.common.core.domain.AjaxResult; import com.snow.common.core.domain.AjaxResult;
@ -22,6 +10,15 @@ import com.snow.common.utils.poi.ExcelUtil;
import com.snow.quartz.domain.SysJob; import com.snow.quartz.domain.SysJob;
import com.snow.quartz.service.ISysJobService; import com.snow.quartz.service.ISysJobService;
import com.snow.quartz.util.CronUtils; import com.snow.quartz.util.CronUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/** /**
* 调度任务信息操作处理 * 调度任务信息操作处理

View File

@ -49,7 +49,7 @@ public class SyncSysDingTask {
SysOaTask upSysOaTask=new SysOaTask(); SysOaTask upSysOaTask=new SysOaTask();
upSysOaTask.setTaskNo(t.getTaskNo()); upSysOaTask.setTaskNo(t.getTaskNo());
upSysOaTask.setTaskStatus(TaskStatus.FINISH.getCode()); upSysOaTask.setTaskStatus(TaskStatus.FINISH.getCode());
sysOaTaskService.updateSysOaTask(upSysOaTask); sysOaTaskService.updateById(upSysOaTask);
} }
}); });
} }

View File

@ -1,5 +1,9 @@
package com.snow.system.domain; package com.snow.system.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.snow.common.annotation.Excel; import com.snow.common.annotation.Excel;
import com.snow.common.core.domain.BaseEntity; import com.snow.common.core.domain.BaseEntity;
@ -20,12 +24,10 @@ public class SysOaTask extends BaseEntity
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 任务编号 */ /** 任务编号 */
@TableId(type = IdType.NONE)
@Excel(name = "任务编号")
private String taskNo; private String taskNo;
/**
* 钉钉待办taskId
*/
private String dingTaskId;
/** 任务名称 */ /** 任务名称 */
@Excel(name = "任务名称") @Excel(name = "任务名称")
@ -35,26 +37,29 @@ public class SysOaTask extends BaseEntity
@Excel(name = "任务内容") @Excel(name = "任务内容")
private String taskContent; private String taskContent;
@Excel(name = "紧急程度") @Excel(name = "紧急程度",dictType = "sys_oa_task_priority")
private Integer priority; private Integer priority;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "任务期望完成时间",dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date expectedTime; private Date expectedTime;
/** 任务状态(详见数据字典) */ /** 任务状态(详见数据字典) */
@Excel(name = "任务状态", readConverterExp = "详=见数据字典") @Excel(name = "任务状态", readConverterExp = "un_finish=执行中,finish=结束")
private String taskStatus; private String taskStatus;
/** 任务类型(详见数据字典) */ /** 任务类型(详见数据字典) */
@Excel(name = "任务类型", readConverterExp = "详=见数据字典") @Excel(name = "任务类型", dictType = "sys_task_type")
private String taskType; private String taskType;
/** 任务来源 */ /** 任务来源 */
@Excel(name = "任务来源") @Excel(name = "任务来源")
private String taskSource; private String taskSource;
/** 任务外部id */ @Excel(name = "任务状态", readConverterExp = "0=不同步,1=同步")
@Excel(name = "任务外部id") private Integer syncDingtalk;
/** 任务外部id即钉钉id*/
private String taskOutsideId; private String taskOutsideId;
/** 任务跳转URL */ /** 任务跳转URL */
@ -62,21 +67,23 @@ public class SysOaTask extends BaseEntity
private String taskUrl; private String taskUrl;
/** 任务分配人 */ /** 任务分配人 */
@Excel(name = "任务分配人") @Excel(name = "任务执行人")
@TableField(exist = false)
private List<String> taskDistributeId; private List<String> taskDistributeId;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@TableField(exist = false)
private Date taskCompleteTime; private Date taskCompleteTime;
/** 乐观锁 */
@Excel(name = "乐观锁")
private Long revision; private Long revision;
/** 删除标识 */
@Excel(name = "删除标识") @TableLogic
private Long isDelete; private Long isDelete;
@TableField(exist = false)
private List<SysOaTaskDistribute> sysOaTaskDistributeList; private List<SysOaTaskDistribute> sysOaTaskDistributeList;
} }

View File

@ -1,5 +1,9 @@
package com.snow.system.domain; package com.snow.system.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.snow.common.annotation.Excel; import com.snow.common.annotation.Excel;
import com.snow.common.core.domain.BaseEntity; import com.snow.common.core.domain.BaseEntity;
@ -20,6 +24,7 @@ public class SysOaTaskDistribute extends BaseEntity
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 主键ID */ /** 主键ID */
@TableId(type = IdType.AUTO)
private Long id; private Long id;
/** 任务编号 */ /** 任务编号 */
@ -38,6 +43,7 @@ public class SysOaTaskDistribute extends BaseEntity
@Excel(name = "任务执行状态") @Excel(name = "任务执行状态")
private String taskExecuteStatus; private String taskExecuteStatus;
@TableField(exist = false)
private List<String> taskExecuteStatusList; private List<String> taskExecuteStatusList;
/** 任务完成时间 */ /** 任务完成时间 */
@ -65,16 +71,19 @@ public class SysOaTaskDistribute extends BaseEntity
/** 删除标识 */ /** 删除标识 */
@Excel(name = "删除标识") @Excel(name = "删除标识")
@TableLogic
private Long isDelete; private Long isDelete;
/** /**
* 任务花费时间 * 任务花费时间
*/ */
@TableField(exist = false)
private String spendTime; private String spendTime;
/** /**
* 任务主表 * 任务主表
*/ */
@TableField(exist = false)
private SysOaTask sysOaTask; private SysOaTask sysOaTask;
} }

View File

@ -10,6 +10,8 @@ import org.springframework.context.ApplicationEvent;
*/ */
public class SyncEvent<T> extends ApplicationEvent { public class SyncEvent<T> extends ApplicationEvent {
private static final long serialVersionUID = 2315510470385496950L;
private Integer eventType; private Integer eventType;
private T t; private T t;

View File

@ -2,7 +2,7 @@ package com.snow.system.mapper;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import com.snow.system.domain.SysDictData; import com.snow.common.core.domain.SysDictData;
/** /**
* 字典表 数据层 * 字典表 数据层

View File

@ -1,7 +1,7 @@
package com.snow.system.mapper; package com.snow.system.mapper;
import java.util.List; import java.util.List;
import com.snow.system.domain.SysDictType; import com.snow.common.core.domain.SysDictType;
/** /**
* 字典表 数据层 * 字典表 数据层

View File

@ -1,6 +1,6 @@
package com.snow.system.mapper; package com.snow.system.mapper;
import java.util.List; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.snow.system.domain.SysOaTaskDistribute; import com.snow.system.domain.SysOaTaskDistribute;
/** /**
@ -9,61 +9,5 @@ import com.snow.system.domain.SysOaTaskDistribute;
* @author 没用的阿吉 * @author 没用的阿吉
* @date 2021-08-15 * @date 2021-08-15
*/ */
public interface SysOaTaskDistributeMapper public interface SysOaTaskDistributeMapper extends BaseMapper<SysOaTaskDistribute> {
{
/**
* 查询任务分配
*
* @param id 任务分配ID
* @return 任务分配
*/
public SysOaTaskDistribute selectSysOaTaskDistributeById(Long id);
/**
* 根据任务编号查询
* @param taskNo 任务编号
* @return 任务分配
*/
List<SysOaTaskDistribute> selectSysOaTaskDistributeByTaskNo(String taskNo);
/**
* 查询任务分配列表
*
* @param sysOaTaskDistribute 任务分配
* @return 任务分配集合
*/
public List<SysOaTaskDistribute> selectSysOaTaskDistributeList(SysOaTaskDistribute sysOaTaskDistribute);
/**
* 新增任务分配
*
* @param sysOaTaskDistribute 任务分配
* @return 结果
*/
public int insertSysOaTaskDistribute(SysOaTaskDistribute sysOaTaskDistribute);
/**
* 修改任务分配
*
* @param sysOaTaskDistribute 任务分配
* @return 结果
*/
public int updateSysOaTaskDistribute(SysOaTaskDistribute sysOaTaskDistribute);
/**
* 删除任务分配
*
* @param id 任务分配ID
* @return 结果
*/
public int deleteSysOaTaskDistributeById(Long id);
/**
* 批量删除任务分配
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteSysOaTaskDistributeByIds(String[] ids);
} }

View File

@ -1,6 +1,8 @@
package com.snow.system.mapper; package com.snow.system.mapper;
import java.util.List; import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.snow.system.domain.SysOaTask; import com.snow.system.domain.SysOaTask;
/** /**
@ -9,8 +11,7 @@ import com.snow.system.domain.SysOaTask;
* @author 没用的阿吉 * @author 没用的阿吉
* @date 2021-07-29 * @date 2021-07-29
*/ */
public interface SysOaTaskMapper public interface SysOaTaskMapper extends BaseMapper<SysOaTask> {
{
/** /**
* 查询系统任务 * 查询系统任务
* *

View File

@ -1,7 +1,7 @@
package com.snow.system.service; package com.snow.system.service;
import java.util.List; import java.util.List;
import com.snow.system.domain.SysDictData; import com.snow.common.core.domain.SysDictData;
/** /**
* 字典 业务层 * 字典 业务层

View File

@ -2,8 +2,8 @@ package com.snow.system.service;
import java.util.List; import java.util.List;
import com.snow.common.core.domain.Ztree; import com.snow.common.core.domain.Ztree;
import com.snow.system.domain.SysDictData; import com.snow.common.core.domain.SysDictData;
import com.snow.system.domain.SysDictType; import com.snow.common.core.domain.SysDictType;
/** /**
* 字典 业务层 * 字典 业务层

View File

@ -1,6 +1,9 @@
package com.snow.system.service; package com.snow.system.service;
import java.util.List; import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.snow.system.domain.SysOaTaskDistribute; import com.snow.system.domain.SysOaTaskDistribute;
/** /**
@ -9,7 +12,7 @@ import com.snow.system.domain.SysOaTaskDistribute;
* @author 没用的阿吉 * @author 没用的阿吉
* @date 2021-08-15 * @date 2021-08-15
*/ */
public interface ISysOaTaskDistributeService public interface ISysOaTaskDistributeService extends IService<SysOaTaskDistribute>
{ {
/** /**
* 查询任务分配 * 查询任务分配
@ -17,7 +20,7 @@ public interface ISysOaTaskDistributeService
* @param id 任务分配ID * @param id 任务分配ID
* @return 任务分配 * @return 任务分配
*/ */
public SysOaTaskDistribute selectSysOaTaskDistributeById(Long id); SysOaTaskDistribute selectSysOaTaskDistributeById(Long id);
/** /**
* 查询任务分配列表 * 查询任务分配列表
@ -25,37 +28,16 @@ public interface ISysOaTaskDistributeService
* @param sysOaTaskDistribute 任务分配 * @param sysOaTaskDistribute 任务分配
* @return 任务分配集合 * @return 任务分配集合
*/ */
public List<SysOaTaskDistribute> selectSysOaTaskDistributeList(SysOaTaskDistribute sysOaTaskDistribute); List<SysOaTaskDistribute> selectSysOaTaskDistributeList(SysOaTaskDistribute sysOaTaskDistribute);
/** /**
* 新增任务分配 * 获取我处理的和我待处理任务
*
* @param sysOaTaskDistribute 任务分配 * @param sysOaTaskDistribute 任务分配
* @return 结果 * @return 结果
*/ */
public int insertSysOaTaskDistribute(SysOaTaskDistribute sysOaTaskDistribute); List<SysOaTaskDistribute> getSysOaTaskDistribute(SysOaTaskDistribute sysOaTaskDistribute);
/** void warpSysOaTask(List<SysOaTaskDistribute> sysOaTaskDistributes);
* 修改任务分配
*
* @param sysOaTaskDistribute 任务分配
* @return 结果
*/
public int updateSysOaTaskDistribute(SysOaTaskDistribute sysOaTaskDistribute);
/**
* 批量删除任务分配
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteSysOaTaskDistributeByIds(String ids);
/**
* 删除任务分配信息
*
* @param id 任务分配ID
* @return 结果
*/
public int deleteSysOaTaskDistributeById(Long id);
} }

View File

@ -1,6 +1,8 @@
package com.snow.system.service; package com.snow.system.service;
import java.util.List; import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.snow.system.domain.SysOaTask; import com.snow.system.domain.SysOaTask;
/** /**
@ -9,15 +11,14 @@ import com.snow.system.domain.SysOaTask;
* @author 没用的阿吉 * @author 没用的阿吉
* @date 2021-07-29 * @date 2021-07-29
*/ */
public interface ISysOaTaskService public interface ISysOaTaskService extends IService<SysOaTask> {
{
/** /**
* 查询系统任务 * 查询系统任务
* *
* @param taskNo 系统任务ID * @param taskNo 系统任务ID
* @return 系统任务 * @return 系统任务
*/ */
public SysOaTask selectSysOaTaskById(String taskNo); SysOaTask selectSysOaTaskById(String taskNo);
/** /**
* 查询系统任务列表 * 查询系统任务列表
@ -25,7 +26,7 @@ public interface ISysOaTaskService
* @param sysOaTask 系统任务 * @param sysOaTask 系统任务
* @return 系统任务集合 * @return 系统任务集合
*/ */
public List<SysOaTask> selectSysOaTaskList(SysOaTask sysOaTask); List<SysOaTask> selectSysOaTaskList(SysOaTask sysOaTask);
/** /**
* 新增系统任务 * 新增系统任务
@ -33,29 +34,13 @@ public interface ISysOaTaskService
* @param sysOaTask 系统任务 * @param sysOaTask 系统任务
* @return 结果 * @return 结果
*/ */
public int insertSysOaTask(SysOaTask sysOaTask); SysOaTask insertSysOaTask(SysOaTask sysOaTask);
/** /**
* 修改系统任务 * 根据任务编号获取三方id
* * @param taskNo 任务id
* @param sysOaTask 系统任务 * @return
* @return 结果
*/ */
public int updateSysOaTask(SysOaTask sysOaTask); String getOutTaskOutsideId(String taskNo);
/**
* 批量删除系统任务
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteSysOaTaskByIds(String ids);
/**
* 删除系统任务信息
*
* @param taskNo 系统任务ID
* @return 结果
*/
public int deleteSysOaTaskById(String taskNo);
} }

View File

@ -9,7 +9,6 @@ import com.snow.common.enums.DingTalkListenerType;
import com.snow.common.utils.DateUtils; import com.snow.common.utils.DateUtils;
import com.snow.common.utils.StringUtils; import com.snow.common.utils.StringUtils;
import com.snow.system.domain.DingtalkCallBackEvent; import com.snow.system.domain.DingtalkCallBackEvent;
import com.snow.system.domain.SysDictData;
import com.snow.system.event.SyncEvent; import com.snow.system.event.SyncEvent;
import com.snow.system.mapper.DingtalkCallBackEventMapper; import com.snow.system.mapper.DingtalkCallBackEventMapper;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;

View File

@ -2,11 +2,11 @@ package com.snow.system.service.impl;
import java.util.List; import java.util.List;
import com.snow.system.utils.DictUtils; import com.snow.common.utils.DictUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.snow.common.core.text.Convert; import com.snow.common.core.text.Convert;
import com.snow.system.domain.SysDictData; import com.snow.common.core.domain.SysDictData;
import com.snow.system.mapper.SysDictDataMapper; import com.snow.system.mapper.SysDictDataMapper;
import com.snow.system.service.ISysDictDataService; import com.snow.system.service.ISysDictDataService;

View File

@ -4,8 +4,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import com.snow.system.domain.SysDictType; import com.snow.common.core.domain.SysDictType;
import com.snow.system.utils.DictUtils; import com.snow.common.utils.DictUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -14,7 +14,7 @@ import com.snow.common.core.domain.Ztree;
import com.snow.common.core.text.Convert; import com.snow.common.core.text.Convert;
import com.snow.common.exception.BusinessException; import com.snow.common.exception.BusinessException;
import com.snow.common.utils.StringUtils; import com.snow.common.utils.StringUtils;
import com.snow.system.domain.SysDictData; import com.snow.common.core.domain.SysDictData;
import com.snow.system.mapper.SysDictDataMapper; import com.snow.system.mapper.SysDictDataMapper;
import com.snow.system.mapper.SysDictTypeMapper; import com.snow.system.mapper.SysDictTypeMapper;
import com.snow.system.service.ISysDictTypeService; import com.snow.system.service.ISysDictTypeService;

View File

@ -1,13 +1,24 @@
package com.snow.system.service.impl; package com.snow.system.service.impl;
import java.util.List; import cn.hutool.core.collection.CollUtil;
import com.snow.common.utils.DateUtils; import cn.hutool.core.date.BetweenFormater;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.snow.common.enums.DingFlowTaskType;
import com.snow.system.domain.SysOaTask;
import com.snow.system.domain.SysOaTaskDistribute;
import com.snow.system.domain.SysUser;
import com.snow.system.mapper.SysOaTaskDistributeMapper;
import com.snow.system.service.ISysOaTaskDistributeService;
import com.snow.system.service.ISysOaTaskService;
import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.snow.system.mapper.SysOaTaskDistributeMapper;
import com.snow.system.domain.SysOaTaskDistribute; import java.util.List;
import com.snow.system.service.ISysOaTaskDistributeService;
import com.snow.common.core.text.Convert;
/** /**
* 任务分配Service业务层处理 * 任务分配Service业务层处理
@ -16,11 +27,14 @@ import com.snow.common.core.text.Convert;
* @date 2021-08-15 * @date 2021-08-15
*/ */
@Service @Service
public class SysOaTaskDistributeServiceImpl implements ISysOaTaskDistributeService public class SysOaTaskDistributeServiceImpl extends ServiceImpl<SysOaTaskDistributeMapper,SysOaTaskDistribute> implements ISysOaTaskDistributeService {
{
@Autowired
private SysOaTaskDistributeMapper sysOaTaskDistributeMapper;
@Autowired
private ISysOaTaskService sysOaTaskService;
@Autowired
private SysUserServiceImpl sysUserService;
/** /**
* 查询任务分配 * 查询任务分配
* *
@ -30,7 +44,7 @@ public class SysOaTaskDistributeServiceImpl implements ISysOaTaskDistributeServi
@Override @Override
public SysOaTaskDistribute selectSysOaTaskDistributeById(Long id) public SysOaTaskDistribute selectSysOaTaskDistributeById(Long id)
{ {
return sysOaTaskDistributeMapper.selectSysOaTaskDistributeById(id); return this.getById(id);
} }
/** /**
@ -40,58 +54,45 @@ public class SysOaTaskDistributeServiceImpl implements ISysOaTaskDistributeServi
* @return 任务分配 * @return 任务分配
*/ */
@Override @Override
public List<SysOaTaskDistribute> selectSysOaTaskDistributeList(SysOaTaskDistribute sysOaTaskDistribute) public List<SysOaTaskDistribute> selectSysOaTaskDistributeList(SysOaTaskDistribute sysOaTaskDistribute) {
{ LambdaQueryWrapper<SysOaTaskDistribute> lambda = new QueryWrapper<SysOaTaskDistribute>().lambda();
return sysOaTaskDistributeMapper.selectSysOaTaskDistributeList(sysOaTaskDistribute); lambda.eq(ObjectUtil.isNotEmpty(sysOaTaskDistribute.getTaskNo()),SysOaTaskDistribute::getTaskNo,sysOaTaskDistribute.getTaskNo());
lambda.in(CollUtil.isNotEmpty(sysOaTaskDistribute.getTaskExecuteStatusList()),SysOaTaskDistribute::getTaskExecuteStatus,sysOaTaskDistribute.getTaskExecuteStatusList());
lambda.eq(ObjectUtil.isNotEmpty(sysOaTaskDistribute.getTaskDistributeId()),SysOaTaskDistribute::getTaskDistributeId,sysOaTaskDistribute.getTaskDistributeId());
lambda.eq(ObjectUtil.isNotEmpty(sysOaTaskDistribute.getTaskExecuteId()),SysOaTaskDistribute::getTaskExecuteId,sysOaTaskDistribute.getTaskExecuteId());
lambda.eq(ObjectUtil.isNotEmpty(sysOaTaskDistribute.getTaskExecuteStatus()),SysOaTaskDistribute::getTaskExecuteStatus,sysOaTaskDistribute.getTaskExecuteStatus());
lambda.eq(ObjectUtil.isNotEmpty(sysOaTaskDistribute.getTaskCompleteTime()),SysOaTaskDistribute::getTaskCompleteTime,sysOaTaskDistribute.getTaskCompleteTime());
lambda.eq(ObjectUtil.isNotEmpty(sysOaTaskDistribute.getTaskStartTime()),SysOaTaskDistribute::getTaskStartTime,sysOaTaskDistribute.getTaskStartTime());
lambda.eq(ObjectUtil.isNotEmpty(sysOaTaskDistribute.getTaskSuspendTime()),SysOaTaskDistribute::getTaskSuspendTime,sysOaTaskDistribute.getTaskSuspendTime());
return this.list(lambda);
} }
/**
* 新增任务分配
*
* @param sysOaTaskDistribute 任务分配
* @return 结果
*/
@Override @Override
public int insertSysOaTaskDistribute(SysOaTaskDistribute sysOaTaskDistribute) public List<SysOaTaskDistribute> getSysOaTaskDistribute(SysOaTaskDistribute sysOaTaskDistribute) {
{ List<SysOaTaskDistribute> sysOaTaskDistributes = this.selectSysOaTaskDistributeList(sysOaTaskDistribute);
sysOaTaskDistribute.setCreateTime(DateUtils.getNowDate()); if(CollUtil.isEmpty(sysOaTaskDistributes)){
return sysOaTaskDistributeMapper.insertSysOaTaskDistribute(sysOaTaskDistribute); return sysOaTaskDistributes;
}
warpSysOaTask(sysOaTaskDistributes);
return sysOaTaskDistributes;
} }
/** public void warpSysOaTask(List<SysOaTaskDistribute> sysOaTaskDistributes){
* 修改任务分配 sysOaTaskDistributes.forEach(t->{
* SysOaTask sysOaTask = sysOaTaskService.selectSysOaTaskById(t.getTaskNo());
* @param sysOaTaskDistribute 任务分配 sysOaTask.setCreateBy(sysUserService.selectUserById(Long.parseLong(sysOaTask.getCreateBy())).getUserName());
* @return 结果 if(ObjectUtil.isNotNull(t.getTaskDistributeId())){
*/ t.setTaskDistributeId(sysUserService.selectUserById(Long.parseLong(t.getTaskDistributeId())).getUserName());
@Override }
public int updateSysOaTaskDistribute(SysOaTaskDistribute sysOaTaskDistribute) if(ObjectUtil.isNotNull(t.getTaskExecuteId())){
{ t.setTaskExecuteId(sysUserService.selectUserById(Long.parseLong(t.getTaskExecuteId())).getUserName());
sysOaTaskDistribute.setUpdateTime(DateUtils.getNowDate()); }
return sysOaTaskDistributeMapper.updateSysOaTaskDistribute(sysOaTaskDistribute); if(ObjectUtil.isNotNull(t.getTaskStartTime())&&ObjectUtil.isNotNull(t.getTaskCompleteTime())){
t.setSpendTime(DateUtil.formatBetween(t.getTaskStartTime(),t.getTaskCompleteTime(), BetweenFormater.Level.SECOND));
}
t.setSysOaTask(sysOaTask);
t.setCreateBy(sysUserService.selectUserById(Long.parseLong(t.getCreateBy())).getUserName());
});
} }
/**
* 删除任务分配对象
*
* @param ids 需要删除的数据ID
* @return 结果
*/
@Override
public int deleteSysOaTaskDistributeByIds(String ids)
{
return sysOaTaskDistributeMapper.deleteSysOaTaskDistributeByIds(Convert.toStrArray(ids));
}
/**
* 删除任务分配信息
*
* @param id 任务分配ID
* @return 结果
*/
@Override
public int deleteSysOaTaskDistributeById(Long id)
{
return sysOaTaskDistributeMapper.deleteSysOaTaskDistributeById(id);
}
} }

View File

@ -2,20 +2,17 @@ package com.snow.system.service.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.snow.common.constant.MessageConstants; import com.snow.common.constant.MessageConstants;
import com.snow.common.constant.SequenceConstants; import com.snow.common.constant.SequenceConstants;
import com.snow.common.core.domain.MessageEventRequest; import com.snow.common.core.domain.MessageEventRequest;
import com.snow.common.core.text.Convert;
import com.snow.common.enums.DingFlowTaskType; import com.snow.common.enums.DingFlowTaskType;
import com.snow.common.enums.DingTalkListenerType;
import com.snow.common.enums.MessageEventType; import com.snow.common.enums.MessageEventType;
import com.snow.common.enums.TaskStatus;
import com.snow.common.exception.BusinessException;
import com.snow.common.utils.DateUtils;
import com.snow.system.domain.SysOaTask; import com.snow.system.domain.SysOaTask;
import com.snow.system.domain.SysOaTaskDistribute; import com.snow.system.domain.SysOaTaskDistribute;
import com.snow.system.event.SyncEvent;
import com.snow.system.mapper.SysOaTaskDistributeMapper;
import com.snow.system.mapper.SysOaTaskMapper; import com.snow.system.mapper.SysOaTaskMapper;
import com.snow.system.service.ISysOaTaskDistributeService; import com.snow.system.service.ISysOaTaskDistributeService;
import com.snow.system.service.ISysOaTaskService; import com.snow.system.service.ISysOaTaskService;
@ -25,10 +22,10 @@ import org.apache.commons.compress.utils.Sets;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import java.util.HashMap;
import java.util.*; import java.util.List;
import java.util.Map;
/** /**
* 系统任务Service业务层处理 * 系统任务Service业务层处理
@ -37,17 +34,11 @@ import java.util.*;
* @date 2021-07-29 * @date 2021-07-29
*/ */
@Service @Service
public class SysOaTaskServiceImpl implements ISysOaTaskService public class SysOaTaskServiceImpl extends ServiceImpl<SysOaTaskMapper,SysOaTask> implements ISysOaTaskService {
{
@Autowired
private SysOaTaskMapper sysOaTaskMapper;
@Autowired @Autowired
private ISysOaTaskDistributeService sysOaTaskDistributeService; private ISysOaTaskDistributeService sysOaTaskDistributeService;
@Resource
private SysOaTaskDistributeMapper sysOaTaskDistributeMapper;
@Autowired @Autowired
private ISysUserService sysUserService; private ISysUserService sysUserService;
@ -57,6 +48,7 @@ public class SysOaTaskServiceImpl implements ISysOaTaskService
@Autowired @Autowired
private ApplicationContext applicationContext; private ApplicationContext applicationContext;
/** /**
* 查询系统任务 * 查询系统任务
* *
@ -64,9 +56,8 @@ public class SysOaTaskServiceImpl implements ISysOaTaskService
* @return 系统任务 * @return 系统任务
*/ */
@Override @Override
public SysOaTask selectSysOaTaskById(String taskNo) public SysOaTask selectSysOaTaskById(String taskNo) {
{ return this.getById(taskNo);
return sysOaTaskMapper.selectSysOaTaskById(taskNo);
} }
/** /**
@ -76,9 +67,13 @@ public class SysOaTaskServiceImpl implements ISysOaTaskService
* @return 系统任务 * @return 系统任务
*/ */
@Override @Override
public List<SysOaTask> selectSysOaTaskList(SysOaTask sysOaTask) public List<SysOaTask> selectSysOaTaskList(SysOaTask sysOaTask) {
{ LambdaQueryWrapper<SysOaTask> lambda = new QueryWrapper<SysOaTask>().lambda();
return sysOaTaskMapper.selectSysOaTaskList(sysOaTask); lambda.like(ObjectUtil.isNotEmpty(sysOaTask.getTaskNo()),SysOaTask::getTaskNo,sysOaTask.getTaskNo());
lambda.eq(ObjectUtil.isNotEmpty(sysOaTask.getTaskStatus()),SysOaTask::getTaskStatus,sysOaTask.getTaskStatus());
lambda.eq(ObjectUtil.isNotEmpty(sysOaTask.getPriority()),SysOaTask::getPriority,sysOaTask.getPriority());
lambda.like(ObjectUtil.isNotEmpty(sysOaTask.getTaskName()),SysOaTask::getTaskName,sysOaTask.getTaskName());
return this.list(lambda);
} }
/** /**
@ -88,86 +83,38 @@ public class SysOaTaskServiceImpl implements ISysOaTaskService
* @return 结果 * @return 结果
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) public SysOaTask insertSysOaTask(SysOaTask sysOaTask) {
public int insertSysOaTask(SysOaTask sysOaTask)
{
sysOaTask.setCreateTime(DateUtils.getNowDate());
String newSequenceNo = sequenceService.getNewSequenceNo(SequenceConstants.OA_TASK_SEQUENCE); String newSequenceNo = sequenceService.getNewSequenceNo(SequenceConstants.OA_TASK_SEQUENCE);
sysOaTask.setTaskNo(newSequenceNo); sysOaTask.setTaskNo(newSequenceNo);
sysOaTask.setTaskStatus(TaskStatus.UN_FINISH.getCode()); sysOaTask.setTaskStatus(DingFlowTaskType.NEW.getCode());
//任务执行人
List<String> taskDistributeIdList= sysOaTask.getTaskDistributeId(); List<String> taskDistributeIdList= sysOaTask.getTaskDistributeId();
this.save(sysOaTask);
if(CollUtil.isEmpty(taskDistributeIdList)){
return sysOaTask;
}
List<SysOaTaskDistribute> sysOaTaskDistributeList= Lists.newArrayList(); List<SysOaTaskDistribute> sysOaTaskDistributeList= Lists.newArrayList();
if(CollUtil.isNotEmpty(taskDistributeIdList)){
taskDistributeIdList.forEach(t->{ taskDistributeIdList.forEach(t->{
SysOaTaskDistribute sysOaTaskDistribute=new SysOaTaskDistribute(); SysOaTaskDistribute sysOaTaskDistribute=new SysOaTaskDistribute();
sysOaTaskDistribute.setTaskDistributeId(t); sysOaTaskDistribute.setTaskDistributeId(t);
sysOaTaskDistribute.setTaskNo(newSequenceNo); sysOaTaskDistribute.setTaskNo(newSequenceNo);
sysOaTaskDistribute.setTaskExecuteStatus(DingFlowTaskType.RUNNING.getCode()); sysOaTaskDistribute.setTaskExecuteStatus(DingFlowTaskType.NEW.getCode());
sysOaTaskDistribute.setCreateBy(sysOaTask.getCreateBy()); sysOaTaskDistribute.setCreateBy(sysOaTask.getCreateBy());
sysOaTaskDistributeService.insertSysOaTaskDistribute(sysOaTaskDistribute); sysOaTaskDistributeService.save(sysOaTaskDistribute);
sysOaTaskDistribute.setSysOaTask(sysOaTask); //发送站内信
//发送消息
sendInnerMessage(sysOaTaskDistribute); sendInnerMessage(sysOaTaskDistribute);
sysOaTaskDistributeList.add(sysOaTaskDistribute); sysOaTaskDistributeList.add(sysOaTaskDistribute);
}); });
}
sysOaTask.setSysOaTaskDistributeList(sysOaTaskDistributeList); sysOaTask.setSysOaTaskDistributeList(sysOaTaskDistributeList);
//事件发送 return sysOaTask;
SyncEvent<SysOaTask> syncEvent = new SyncEvent(sysOaTask, DingTalkListenerType.WORK_RECODE_CREATE);
applicationContext.publishEvent(syncEvent);
return sysOaTaskMapper.insertSysOaTask(sysOaTask);
} }
/**
* 修改系统任务
*
* @param sysOaTask 系统任务
* @return 结果
*/
@Override @Override
public int updateSysOaTask(SysOaTask sysOaTask) public String getOutTaskOutsideId(String taskNo) {
{ return this.getOne(new QueryWrapper<SysOaTask>().lambda().eq(SysOaTask::getTaskNo,taskNo)).getTaskOutsideId();
sysOaTask.setUpdateTime(DateUtils.getNowDate());
return sysOaTaskMapper.updateSysOaTask(sysOaTask);
}
/**
* 删除系统任务对象
*
* @param ids 需要删除的数据ID
* @return 结果
*/
@Override
public int deleteSysOaTaskByIds(String ids)
{
List<String> list = Arrays.asList(Convert.toStrArray(ids));
list.forEach(t->{
List<SysOaTaskDistribute> sysOaTaskDistributes = sysOaTaskDistributeMapper.selectSysOaTaskDistributeByTaskNo(t);
if(CollUtil.isNotEmpty(sysOaTaskDistributes)){
throw new BusinessException("任务编号:"+t+"已分配,不允许删除操作");
}
});
return sysOaTaskMapper.deleteSysOaTaskByIds(Convert.toStrArray(ids));
}
/**
* 删除系统任务信息
*
* @param taskNo 系统任务ID
* @return 结果
*/
@Override
public int deleteSysOaTaskById(String taskNo)
{
List<SysOaTaskDistribute> sysOaTaskDistributes = sysOaTaskDistributeMapper.selectSysOaTaskDistributeByTaskNo(taskNo);
if(CollUtil.isNotEmpty(sysOaTaskDistributes)){
throw new BusinessException("任务编号:"+taskNo+"已分配,不允许删除操作");
}
//发送事件
SyncEvent<String> syncEvent = new SyncEvent(taskNo, DingTalkListenerType.WORK_RECODE_CREATE);
applicationContext.publishEvent(syncEvent);
return sysOaTaskMapper.deleteSysOaTaskById(taskNo);
} }
/** /**

View File

@ -26,104 +26,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select id, task_no, task_distribute_id, task_execute_id, task_execute_status, task_complete_time, task_start_time, task_suspend_time, task_feedback, revision, create_by, is_delete, create_time, update_by, update_time from sys_oa_task_distribute select id, task_no, task_distribute_id, task_execute_id, task_execute_status, task_complete_time, task_start_time, task_suspend_time, task_feedback, revision, create_by, is_delete, create_time, update_by, update_time from sys_oa_task_distribute
</sql> </sql>
<select id="selectSysOaTaskDistributeList" parameterType="SysOaTaskDistribute" resultMap="SysOaTaskDistributeResult">
<include refid="selectSysOaTaskDistributeVo"/>
<where>
<if test="taskNo != null and taskNo != ''"> and task_no = #{taskNo}</if>
<if test="taskDistributeId != null and taskDistributeId != ''"> and task_distribute_id = #{taskDistributeId}</if>
<if test="taskExecuteId != null and taskExecuteId != ''"> and task_execute_id = #{taskExecuteId}</if>
<if test="taskExecuteStatus != null and taskExecuteStatus != ''"> and task_execute_status = #{taskExecuteStatus}</if>
<if test="taskExecuteStatusList!= null and taskExecuteStatusList.size()>0">
AND task_execute_status IN
<foreach item="item" index="index" collection="taskExecuteStatusList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="taskCompleteTime != null "> and task_complete_time = #{taskCompleteTime}</if>
<if test="taskStartTime != null "> and task_start_time = #{taskStartTime}</if>
<if test="taskSuspendTime != null "> and task_suspend_time = #{taskSuspendTime}</if>
<if test="taskFeedback != null and taskFeedback != ''"> and task_feedback = #{taskFeedback}</if>
<if test="revision != null "> and revision = #{revision}</if>
<if test="isDelete != null "> and is_delete = #{isDelete}</if>
</where>
</select>
<select id="selectSysOaTaskDistributeById" parameterType="Long" resultMap="SysOaTaskDistributeResult">
<include refid="selectSysOaTaskDistributeVo"/>
where id = #{id}
</select>
<select id="selectSysOaTaskDistributeByTaskNo" parameterType="Long" resultMap="SysOaTaskDistributeResult">
<include refid="selectSysOaTaskDistributeVo"/>
where task_no = #{taskNo} and is_delete=0
</select>
<insert id="insertSysOaTaskDistribute" parameterType="SysOaTaskDistribute" useGeneratedKeys="true" keyProperty="id">
insert into sys_oa_task_distribute
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="taskNo != null and taskNo != ''">task_no,</if>
<if test="taskDistributeId != null">task_distribute_id,</if>
<if test="taskExecuteId != null">task_execute_id,</if>
<if test="taskExecuteStatus != null">task_execute_status,</if>
<if test="taskCompleteTime != null">task_complete_time,</if>
<if test="taskStartTime != null">task_start_time,</if>
<if test="taskSuspendTime != null">task_suspend_time,</if>
<if test="taskFeedback != null">task_feedback,</if>
<if test="revision != null">revision,</if>
<if test="createBy != null">create_by,</if>
<if test="isDelete != null">is_delete,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="taskNo != null and taskNo != ''">#{taskNo},</if>
<if test="taskDistributeId != null">#{taskDistributeId},</if>
<if test="taskExecuteId != null">#{taskExecuteId},</if>
<if test="taskExecuteStatus != null">#{taskExecuteStatus},</if>
<if test="taskCompleteTime != null">#{taskCompleteTime},</if>
<if test="taskStartTime != null">#{taskStartTime},</if>
<if test="taskSuspendTime != null">#{taskSuspendTime},</if>
<if test="taskFeedback != null">#{taskFeedback},</if>
<if test="revision != null">#{revision},</if>
<if test="createBy != null">#{createBy},</if>
<if test="isDelete != null">#{isDelete},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateSysOaTaskDistribute" parameterType="SysOaTaskDistribute">
update sys_oa_task_distribute
<trim prefix="SET" suffixOverrides=",">
<if test="taskNo != null and taskNo != ''">task_no = #{taskNo},</if>
<if test="taskDistributeId != null">task_distribute_id = #{taskDistributeId},</if>
<if test="taskExecuteId != null">task_execute_id = #{taskExecuteId},</if>
<if test="taskExecuteStatus != null">task_execute_status = #{taskExecuteStatus},</if>
<if test="taskCompleteTime != null">task_complete_time = #{taskCompleteTime},</if>
<if test="taskStartTime != null">task_start_time = #{taskStartTime},</if>
<if test="taskSuspendTime != null">task_suspend_time = #{taskSuspendTime},</if>
<if test="taskFeedback != null">task_feedback = #{taskFeedback},</if>
<if test="revision != null">revision = #{revision},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="isDelete != null">is_delete = #{isDelete},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteSysOaTaskDistributeById" parameterType="Long">
delete from sys_oa_task_distribute where id = #{id}
</delete>
<delete id="deleteSysOaTaskDistributeByIds" parameterType="String">
delete from sys_oa_task_distribute where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper> </mapper>

View File

@ -26,98 +26,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectSysOaTaskVo"> <sql id="selectSysOaTaskVo">
select task_no, task_name, expected_time,priority,task_content, task_status, task_type, task_source, task_outside_id, task_url, revision, create_by, is_delete, create_time, update_by, update_time from sys_oa_task select task_no, task_name, expected_time,priority,task_content, task_status, task_type, task_source, task_outside_id, task_url, revision, create_by, is_delete, create_time, update_by, update_time from sys_oa_task
</sql> </sql>
<select id="selectSysOaTaskList" parameterType="SysOaTask" resultMap="SysOaTaskResult">
<include refid="selectSysOaTaskVo"/>
<where>
<if test="taskName != null and taskName != ''"> and task_name like concat('%', #{taskName}, '%')</if>
<if test="taskContent != null and taskContent != ''"> and task_content = #{taskContent}</if>
<if test="taskStatus != null and taskStatus != ''"> and task_status = #{taskStatus}</if>
<if test="taskType != null and taskType != ''"> and task_type = #{taskType}</if>
<if test="taskSource != null and taskSource != ''"> and task_source = #{taskSource}</if>
<if test="taskOutsideId != null and taskOutsideId != ''"> and task_outside_id = #{taskOutsideId}</if>
<if test="priority != null "> and priority = #{priority}</if>
<if test="revision != null "> and revision = #{revision}</if>
<if test="isDelete != null "> and is_delete = #{isDelete}</if>
</where>
</select>
<select id="selectSysOaTaskById" parameterType="String" resultMap="SysOaTaskResult">
<include refid="selectSysOaTaskVo"/>
where task_no = #{taskNo}
</select>
<insert id="insertSysOaTask" parameterType="SysOaTask">
insert into sys_oa_task
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="taskNo != null">task_no,</if>
<if test="taskName != null and taskName != ''">task_name,</if>
<if test="taskContent != null">task_content,</if>
<if test="taskStatus != null">task_status,</if>
<if test="taskType != null">task_type,</if>
<if test="priority != null">priority,</if>
<if test="expectedTime != null">expected_time,</if>
<if test="taskSource != null">task_source,</if>
<if test="taskOutsideId != null">task_outside_id,</if>
<if test="taskUrl != null">task_url,</if>
<if test="revision != null">revision,</if>
<if test="createBy != null">create_by,</if>
<if test="isDelete != null">is_delete,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="taskNo != null">#{taskNo},</if>
<if test="taskName != null and taskName != ''">#{taskName},</if>
<if test="taskContent != null">#{taskContent},</if>
<if test="taskStatus != null">#{taskStatus},</if>
<if test="taskType != null">#{taskType},</if>
<if test="priority != null">#{priority},</if>
<if test="expectedTime != null">#{expectedTime},</if>
<if test="taskSource != null">#{taskSource},</if>
<if test="taskOutsideId != null">#{taskOutsideId},</if>
<if test="taskUrl != null">#{taskUrl},</if>
<if test="revision != null">#{revision},</if>
<if test="createBy != null">#{createBy},</if>
<if test="isDelete != null">#{isDelete},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateSysOaTask" parameterType="SysOaTask">
update sys_oa_task
<trim prefix="SET" suffixOverrides=",">
<if test="taskName != null and taskName != ''">task_name = #{taskName},</if>
<if test="taskContent != null">task_content = #{taskContent},</if>
<if test="taskStatus != null">task_status = #{taskStatus},</if>
<if test="taskType != null">task_type = #{taskType},</if>
<if test="priority != null">priority=#{priority},</if>
<if test="expectedTime != null">expected_time=#{expectedTime},</if>
<if test="taskSource != null">task_source = #{taskSource},</if>
<if test="taskOutsideId != null">task_outside_id = #{taskOutsideId},</if>
<if test="taskUrl != null">task_url = #{taskUrl},</if>
<if test="revision != null">revision = #{revision},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="isDelete != null">is_delete = #{isDelete},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where task_no = #{taskNo}
</update>
<delete id="deleteSysOaTaskById" parameterType="String">
delete from sys_oa_task where task_no = #{taskNo}
</delete>
<delete id="deleteSysOaTaskByIds" parameterType="String">
delete from sys_oa_task where task_no in
<foreach item="taskNo" collection="array" open="(" separator="," close=")">
#{taskNo}
</foreach>
</delete>
</mapper> </mapper>