package com.newfiber.api.pc.service.impl; import com.alibaba.druid.util.StringUtils; import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.newfiber.api.config.FileVisitProperty; import com.newfiber.api.core.utils.DateUtils; import com.newfiber.api.core.utils.SmsSendUtils; import com.newfiber.api.core.utils.StringUtil; import com.newfiber.api.pc.dao.*; import com.newfiber.api.pc.model.entity.Task; import com.newfiber.api.pc.model.entity.*; import com.newfiber.api.pc.model.vo.*; import com.newfiber.api.pc.service.*; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.lang.reflect.Field; import java.util.*; /** * 任务 * @Author:zhz * @CreateDate:2020/12/1 14:50 * @Description: */ @Service @Transactional(rollbackFor = Exception.class) public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements TaskService { @Autowired private TaskMapper taskMapper; @Autowired private TaskProcessMapper taskProcessMapper; @Autowired private TaskFileMapper taskFileMapper; @Autowired private TaskProcessService taskProcessService; @Autowired private TaskUserService taskUserService; @Autowired private TaskUserMapper taskUserMapper; @Autowired private TaskStateService taskStateService; @Autowired private Data_User_InfoService datauserinfoService; @Autowired private TaskStateMapper taskStateMapper; @Autowired private FileVisitProperty fileVisitProperty; @Autowired private WarnTaskAssService warnTaskAssService; @Autowired private SmsSendUtils smsSendUtils; @Autowired private WarnTeamBossMapper warnTeamBossMapper; @Autowired private WarnTeamBossService warnTeamBossService; @Autowired private WarnTeamSupService warnTeamSupService; @Override public int create(TaskParam param) { //1.创建任务 Task task = createTask(param); //2.创建任务流程和用户状态 createProcess(task,param,task.getId()); createTaskState(param,task.getId()); //3.警情任务中添加的任务 if(!StringUtils.isEmpty(param.getWarnNumber())){ WarnTaskAss warnTaskAss = new WarnTaskAss(); warnTaskAss.setWarnTask(Integer.parseInt(task.getId().toString())); warnTaskAss.setWarnNumber(param.getWarnNumber()); warnTaskAssService.insert(warnTaskAss); } return 1; } @Override public int createOneMapCreate(TaskParam param) { //1.创建任务 Task task = createTask(param); //2.创建任务流程和用户状态 List<TaskUser> taskUsers = new ArrayList<>(); List<TaskTempUserVO> taskTempUserVOS = warnTeamBossMapper.selectAllUser(); for (TaskTempUserVO taskTempUserVO : taskTempUserVOS) { TaskUser boss = new TaskUser(); boss.setId((long)taskTempUserVO.getBossId()); boss.setUserNo(taskTempUserVO.getBossUserNo()); boss.setUserName(taskTempUserVO.getBossName()); boss.setPhone(taskTempUserVO.getBossPhone()); boss.setUnit(taskTempUserVO.getUnit()); boss.setJob(taskTempUserVO.getBossJob()); boss.setUserType(null); boss.setOrgType(taskTempUserVO.getBossOrgType()); boss.setOrgName(taskTempUserVO.getOrgName()); taskUsers.add(boss); if(!org.springframework.util.StringUtils.isEmpty(taskTempUserVO.getSupId())){ TaskUser sup = new TaskUser(); sup.setId((long)taskTempUserVO.getSupId()); sup.setUserNo(taskTempUserVO.getSupUserNo()); sup.setUserName(taskTempUserVO.getSubName()); sup.setPhone(taskTempUserVO.getSupPhone()); sup.setUnit(taskTempUserVO.getUnit()); sup.setJob(taskTempUserVO.getSubJob()); sup.setUserType(Integer.valueOf(taskTempUserVO.getSupUserType())); sup.setOrgType(taskTempUserVO.getSupOrgType()); sup.setOrgName(taskTempUserVO.getOrgName()); taskUsers.add(sup); } } param.setTaskUsers(taskUsers); createProcess(task,param,task.getId()); createTaskState(param,task.getId()); //3.警情任务中添加的任务 if(!StringUtils.isEmpty(param.getWarnNumber())){ WarnTaskAss warnTaskAss = new WarnTaskAss(); warnTaskAss.setWarnTask(Integer.parseInt(task.getId().toString())); warnTaskAss.setWarnNumber(param.getWarnNumber()); warnTaskAssService.insert(warnTaskAss); } return 1; } @Override public int isread(TaskProcessParam taskProcess) { TaskProcess process = new TaskProcess(); process.setTaskId(taskProcess.getTaskId()); process.setOperationUser(taskProcess.getOperationUser()); process.setNextUser(taskProcess.getNextUser()); process.setUnitId(taskProcess.getUnitId()); process.setProsessStatus(2); process.setProsessName("已读"); process.setProcessContent(taskProcess.getOperationUserName()+"已读"); process.setCreateTime(new Date()); taskProcessService.insert(process); TaskUser taskUser = new TaskUser(); taskUser.setId(taskProcess.getTaskUserId()); taskUser.setState(2); taskUser.setStateDesc("已读"); taskUser.setDescription("已查阅"); taskUserService.updateById(taskUser); if(taskProcess.getUserType()!=null && taskProcess.getUserType() == 1){ //改变查看人员的状态 taskStateService.updateTaskState(taskProcess.getTaskId(), taskProcess.getOperationUser(), 2); } return 1; } /** * 创建任务和指派任务流程 * @param param */ private void createProcess(Task task,TaskParam param,Long id) { //任务创建 List<TaskProcess> taskProcesses = new ArrayList<>(); List<TaskState> taskStates = new ArrayList<>(); List<TaskUser> taskUsers = param.getTaskUsers(); Set<Long> units = new HashSet<>(); for (TaskUser taskUser : taskUsers) { //System.out.println(taskUser.getId()); units.add(taskUser.getId()); //任务指派流程 //任务对应的用户状态 taskUser.setState(1); taskUser.setStateDesc("未读"); taskUser.setTaskId(id); taskUser.setUnitId(taskUser.getId()); if(param.getTaskSign()!=null && param.getTaskSign() == 1){ taskUser.setUserType(1); } } for (Long unit : units) { TaskProcess process = new TaskProcess(); process.setTaskId(id); process.setOperationUser(param.getCreateUser()); process.setProsessName("创建任务"); process.setProsessStatus(1); process.setProcessContent(param.getCreateUserName()+"创建任务"); process.setCreateTime(new Date()); process.setUnitId(unit); taskProcesses.add(process); } for (TaskUser taskUser : taskUsers) { TaskProcess process1 = new TaskProcess(); process1.setTaskId(id); process1.setOperationUser(param.getCreateUser()); process1.setProsessName("派发任务"); process1.setProsessStatus(1); process1.setUnitId(taskUser.getId()); process1.setProcessContent(param.getCreateUserName()+"派发任务给"+taskUser.getUserName()); process1.setCreateTime(new Date()); taskProcesses.add(process1); } //发送短信 smsSendUtils.sendTaskMessage(task,taskUsers); //保存流程和用户流程 TaskUser taskUser1 = new TaskUser(); taskUser1.setTaskId(id); taskUser1.setUnitId(taskUsers.get(0).getId()); taskUser1.setUserNo(param.getDutyUser()); taskUser1.setUserType(3); taskProcessService.insertBatch(taskProcesses); taskUserService.insertBatch(taskUsers); } private void createTaskState(TaskParam param,Long id) { //任务创建 List<TaskState> taskStates = new ArrayList<>(); TaskState taskState = new TaskState(); taskState.setTaskState((byte)2); taskState.setOperationUser(param.getDutyUser()); taskState.setTaskId(id); taskStates.add(taskState); List<TaskUser> taskUsers = param.getTaskUsers(); for (TaskUser taskUser : taskUsers) { TaskState taskState1 = new TaskState(); taskState1.setTaskState((byte)1); taskState1.setTaskId(id); taskState1.setOperationUser(taskUser.getUserNo()); taskStates.add(taskState1); } //保存用户状态 taskStateService.insertBatch(taskStates); } /** * 创建任务 * @param param */ private Task createTask(TaskParam param) { Task task = new Task(); BeanUtils.copyProperties(param,task); task.setTaskState(1); task.setTaskStateName("正常"); task.setCreateTime(new Date()); //查询出创建任务人的名称 Data_User_Info user = datauserinfoService.GetUser(param.getDutyUser()); if(user!=null && !StringUtil.isEmpty(user.getUserName())){ task.setDutyUserName(user.getUserName()); } taskMapper.insert(task); //设置taskNo if(task!=null && task.getId()!=null){ StringBuffer sb = new StringBuffer(); sb.append(DateUtils.getYear(new Date())).append("FXRW"). append(StringUtil.autoGenericCode(task.getId().toString(),4)); task.setTaskNo(sb.toString()); taskMapper.updateById(task); } return task; } @Override public int checkTask(TaskProcessParam taskProcess) { //提交审核流程 TaskProcess process = checkTaskProcess(taskProcess); List<TaskFile> taskFiles = taskProcess.getTaskFiles(); if(!taskFiles.isEmpty()){ for (TaskFile taskFile : taskFiles) { taskFile.setProcessId(process.getId()); taskFile.setCreateTime(new Date()); int i = taskFileMapper.updateById(taskFile); } } TaskUser taskUser = new TaskUser(); taskUser.setId(taskProcess.getTaskUserId()); taskUser.setState(3); taskUser.setStateDesc("未审核"); taskUser.setDescription(taskProcess.getDescription()); taskUserService.updateById(taskUser); //处理人 taskStateService.updateTaskState(taskProcess.getTaskId(),taskProcess.getOperationUser(),2); //审核人 taskStateService.updateTaskState(taskProcess.getTaskId(),taskProcess.getNextUser(),1); return 1; } /** * 提交审核流程 * @param taskProcess * @return */ private TaskProcess checkTaskProcess(TaskProcessParam taskProcess) { //提交时判断是否已读 List<TaskProcess> taskProcesses = new ArrayList<>(); if(taskProcess.getTaskState() == 1 && taskProcess.getUserType() == 2){ TaskProcess process = new TaskProcess(); process.setTaskId(taskProcess.getTaskId()); process.setOperationUser(taskProcess.getOperationUser()); process.setNextUser(taskProcess.getNextUser()); process.setProsessStatus(2); process.setProsessName("已读"); process.setUnitId(taskProcess.getUnitId()); process.setProcessContent(taskProcess.getOperationUserName()+"已读"); process.setCreateTime(new Date()); taskProcesses.add(process); } TaskProcess process = new TaskProcess(); process.setTaskId(taskProcess.getTaskId()); process.setOperationUser(taskProcess.getOperationUser()); process.setNextUser(taskProcess.getNextUser()); process.setProsessStatus(3); process.setUnitId(taskProcess.getUnitId()); process.setProsessName(taskProcess.getOperationUserName()+"提交审核"); process.setProcessContent(taskProcess.getDescription()); process.setCreateTime(new Date()); taskProcesses.add(process); taskProcessService.insertBatch(taskProcesses); return process; } @Override public int refuseTask(TaskProcessParam taskProcess) { //添加流程 refuseTaskProcess(taskProcess); //修改用户状态 TaskUser taskUser = new TaskUser(); taskUser.setId(taskProcess.getTaskUserId()); taskUser.setState(2); taskUser.setStateDesc("驳回"); taskUser.setDescription(taskProcess.getDescription()); taskUser.setCheckState(1); taskUser.setCheckStateDesc("驳回"); taskUserService.updateById(taskUser); //处理人 taskStateService.updateTaskState(taskProcess.getTaskId(),taskProcess.getOperationUser(),2); //审核人 taskStateService.updateTaskState(taskProcess.getTaskId(),taskProcess.getNextUser(),1); return 1; } /** * 任务通过流程 * @param taskProcess */ private void refuseTaskProcess(TaskProcessParam taskProcess) { TaskProcess process = new TaskProcess(); process.setTaskId(taskProcess.getTaskId()); process.setOperationUser(taskProcess.getOperationUser()); process.setNextUser(taskProcess.getNextUser()); process.setProsessStatus(4); process.setUnitId(taskProcess.getUnitId()); process.setProsessName(taskProcess.getOperationUserName()+"驳回了"+taskProcess.getNextUserName()+"提交的任务"); process.setProcessContent(taskProcess.getDescription()); process.setCreateTime(new Date()); taskProcessMapper.insertSelective(process); } @Override public int passTask(TaskProcessParam taskProcess) { //添加流程 passTaskProcess(taskProcess); TaskUser taskUser = new TaskUser(); taskUser.setId(taskProcess.getTaskUserId()); taskUser.setState(4); taskUser.setStateDesc("已结办"); taskUser.setDescription(taskProcess.getDescription()); taskUser.setCheckState(2); taskUser.setCheckStateDesc("通过"); taskUserService.updateById(taskUser); //审核人操作完成 taskStateService.updateTaskState(taskProcess.getTaskId(),taskProcess.getOperationUser(),2); return 1; } /** * 任务通过流程 * @param taskProcess */ private void passTaskProcess(TaskProcessParam taskProcess) { TaskProcess process = new TaskProcess(); process.setTaskId(taskProcess.getTaskId()); process.setOperationUser(taskProcess.getOperationUser()); process.setNextUser(taskProcess.getNextUser()); process.setProsessStatus(5); process.setUnitId(taskProcess.getUnitId()); process.setProsessName(taskProcess.getOperationUserName()+"通过了"+taskProcess.getNextUserName()+"提交的任务"); process.setProcessContent(taskProcess.getDescription()); process.setCreateTime(new Date()); taskProcessMapper.insertSelective(process); } @Override public PageInfo<Task> taskAppList(Integer type,String userNo,Integer pageNo,Integer pageSize) { /* if("admin".equalsIgnoreCase(userNo)){ EntityWrapper<Task> wrapper = new EntityWrapper<>(); List<Task> tasks = this.selectList(wrapper); List<Long> taskIds = tasks.stream().map(Task::getId).collect(Collectors.toList()); return getTaskAdminInfo(taskIds); }*/ //判断是否是审核用户 /* List<Task> dutyUser =taskMapper.selectByDutyUser(userNo); if(dutyUser!=null && dutyUser.size()>0){ List<Long> taskIds = dutyUser.stream().map(Task::getId).collect(Collectors.toList()); return getTaskDutyInfo(taskIds); }else{ return getTaskNormalInfo(type, userNo); }*/ return getTaskNormalInfo(type, userNo); } private PageInfo<Task> getTaskAdminInfo(List<Long> taskIds) { List<Task> result = taskMapper.selectDutyTaskList(taskIds); PageInfo<Task> pageInfo = new PageInfo<>(); if (!result.isEmpty()) { for (Task task : result) { //设置审核用户状态为3 task.setUserType(3); //状态为待处理时,设置为不可操作状态 task.setUserState(2); } pageInfo = new PageInfo<Task>(result); } return pageInfo; } /** * 审核用户的查询 * @return */ private PageInfo<Task> getTaskDutyInfo(List<Long> taskIds) { List<Task> result = taskMapper.selectDutyTaskList(taskIds); PageInfo<Task> pageInfo = new PageInfo<>(); if (!result.isEmpty()) { for (Task task : result) { //设置审核用户状态为3 task.setUserType(3); //状态为待处理时,设置为可操作状态 if(task.getState() == 3){ task.setUserState(1); }else{ task.setUserState(2); } } pageInfo = new PageInfo<Task>(result); } return pageInfo; } /** * 普通用户的查询 * @param type * @param userNo * @return */ private PageInfo<Task> getTaskNormalInfo(Integer type, String userNo) { List<Task> result = taskMapper.selectAppTaskList(type, userNo); PageInfo<Task> pageInfo = new PageInfo<>(); if (!result.isEmpty()) { pageInfo = new PageInfo<Task>(result); } return pageInfo; } @Override public TaskVo taskAppInfo(String userNo,String taskUserNo,Integer userType,Long taskId,Long unitId) { //如果是领导用户userType=0 并且查看的为领导信息,查看是否能操作 if(userType!=null && userType == 0 ){ if(userNo.equalsIgnoreCase(taskUserNo)){ userNo = taskUserNo; }else{ userNo = null; } } Task task = taskMapper.selectTaskById(userNo,taskId); //负责人查看后改变已读状态 //isRead(userName, task); TaskVo result = new TaskVo(); BeanUtils.copyProperties(task,result); if(task.getId() != null){ List<TaskProcessVo> taskProcessVos = new ArrayList<>(); taskProcessVos = taskProcessMapper.selectTaskList(task.getId(),unitId); if(!taskProcessVos.isEmpty()){ for (TaskProcessVo taskProcessVo : taskProcessVos) { List<TaskFile> taskFiles = taskProcessVo.getTaskFiles(); taskFiles.removeIf(Objects::isNull); if(taskFiles!=null){ for (TaskFile taskFile : taskProcessVo.getTaskFiles()) { taskFile.setRealPath(fileVisitProperty.getAppPic()+taskFile.getFilePath()); } } } } result.setTaskProcessVos(taskProcessVos); } return result; } @Override public PageInfo<Task> taskPcList(Integer type,String userNo,Integer userType,String taskName,Integer pageNo,Integer pageSize) { if(userType!=null && userType==0){ userNo = null; } PageHelper.startPage(pageNo,pageSize); List<Task> result = taskMapper.selectPcTaskList(type,userNo,taskName); PageInfo<Task> pageInfo = new PageInfo<>(); if(!result.isEmpty()){ pageInfo = new PageInfo<Task>(result); } return pageInfo; } @Override public Page taskPcInfo(String userName,Integer taskId,Integer type,Integer orgType,Integer pageNo,Integer pageSize) { Map<String,Object> map = new HashMap<>(); //查询组织里的任务数量统计 setOrgCount(taskId, type, map); //查询状态统计 TaskUserCount taskUserCounts = taskMapper.selectTaskCount(taskId,orgType); map.put("taskCount",taskUserCounts); PageHelper.startPage(pageNo,1000); List<TaskUser> taskUsers = taskUserMapper.selectListById(taskId,type,orgType); PageInfo<TaskUser> pageInfo = new PageInfo<>(); Page page = new Page(); if(!taskUsers.isEmpty()){ for (TaskUser user : taskUsers) { if(type!=null){ if(type == 1){ if(!DateUtils.getAddTime(-20).before(user.getCreateTime())){ user.setStateDesc("超时未读"); }else{ user.setStateDesc("未读"); } }else if(type == 2){ user.setStateDesc("已读"); }else if(type == 3){ user.setStateDesc("已处理"); }else if(type == 4){ user.setStateDesc("已完成"); }else if(type == 6){ user.setCompleteOverTime(1); if(user.getExpectedEndTime().before(new Date())){ user.setStateDesc("超时未处理"); }else{ user.setStateDesc("未处理"); } } } setProcess(user.getTaskId(),user,fileVisitProperty.getWebPic()); } pageInfo = new PageInfo<TaskUser>(taskUsers); page.setTotal((int)pageInfo.getTotal()); page.setRecords(pageInfo.getList()); page.setCondition(map); return page; }else{ page.setTotal(0); page.setRecords(new ArrayList()); page.setCondition(map); return page; } } @Override public Page taskAppDetail(String userName,Integer taskId,Integer type,Integer orgType,Integer pageNo,Integer pageSize) { Map<String,Object> map = new HashMap<>(); //查询状态统计 TaskUserCount taskUserCounts = taskMapper.selectTaskCount(taskId,orgType); map.put("taskCount",taskUserCounts); //查询组织里的任务数量统计 setOrgCount(taskId, type, map); PageHelper.startPage(pageNo,1000); List<TaskUser> taskUsers = taskUserMapper.selectListById(taskId,type,orgType); PageInfo<TaskUser> pageInfo = new PageInfo<>(); Page page = new Page(); if(!taskUsers.isEmpty()){ for (TaskUser user : taskUsers) { if(type!=null){ if(type == 1){ if(!DateUtils.getAddTime(-20).before(user.getCreateTime())){ user.setStateDesc("超时未读"); }else{ user.setStateDesc("未读"); } }else if(type == 2){ user.setStateDesc("已读"); }else if(type == 3){ user.setStateDesc("已处理"); }else if(type == 4){ user.setStateDesc("已完成"); }else if(type == 6){ user.setCompleteOverTime(1); if(user.getExpectedEndTime().before(new Date())){ user.setStateDesc("超时未处理"); }else{ user.setStateDesc("未处理"); } } } setProcess(user.getTaskId(),user,fileVisitProperty.getAppPic()); } pageInfo = new PageInfo<TaskUser>(taskUsers); page.setTotal((int)pageInfo.getTotal()); page.setRecords(pageInfo.getList()); page.setCondition(map); return page; }else{ page.setTotal(0); page.setRecords(new ArrayList()); page.setCondition(map); return page; } } private void setOrgCount(Integer taskId, Integer type, Map<String, Object> map) { List<TaskOrgCount> total = warnTeamBossMapper.taskOrgType(); List<TaskOrgCount> orgcount = taskUserMapper.selectOrgCount(taskId, type); total.forEach(e->{ orgcount.forEach(e1->{ if(e.getOrgType() == e1.getOrgType()){ e.setCount(e1.getCount()); } }); }); map.put("orgcount", total); } /** * 查询人员 * @param task * @param result */ private void setTaskUsers(Task task, TaskVo result) { List<TaskUser> taskUser = new ArrayList<>(); taskUser = taskUserMapper.selectTaskUserList(Arrays.asList(task.getId())); if(!taskUser.isEmpty()){ for (TaskUser user : taskUser) { if(user.getUserType() == 1 && user.getState()==1 && !DateUtils.getAddTime(-20).before(task.getCreateTime())){ task.setOverTime(1); } } result.setTaskUsers(taskUser); } } /** * 查询流程 * @param taskId * @param result */ private void setProcess(Long taskId, TaskUser result,String path) { List<TaskProcessVo> taskProcessVos = new ArrayList<>(); taskProcessVos = taskProcessMapper.selectTaskList(taskId,result.getUnitId()); if(!taskProcessVos.isEmpty()){ for (TaskProcessVo taskProcessVo : taskProcessVos) { List<TaskFile> taskFiles = taskProcessVo.getTaskFiles(); taskFiles.removeIf(Objects::isNull); if(taskFiles!=null){ for (TaskFile taskFile : taskProcessVo.getTaskFiles()) { taskFile.setRealPath(path+taskFile.getFilePath()); } } } } result.setProcessVos(taskProcessVos); } @Override public int closeTask(TaskProcessParam taskProcess) { TaskProcess process = new TaskProcess(); process.setTaskId(taskProcess.getTaskId()); process.setOperationUser(taskProcess.getOperationUser()+"关闭任务"); process.setNextUser(taskProcess.getNextUser()); process.setProsessStatus(6); process.setUnitId(taskProcess.getUnitId()); process.setProsessName("任务关闭"); process.setProcessContent(taskProcess.getDescription()); process.setCreateTime(new Date()); taskProcessMapper.insertSelective(process); //处理状态编号 taskStateMapper.updateByTaskId(taskProcess.getTaskId()); //将每个人的操作状态改为查看 taskUserMapper.updateByTaskId(taskProcess.getTaskId()); taskUserMapper.updateByTaskId2(taskProcess.getTaskId()); taskUserMapper.updateByTaskId3(taskProcess.getTaskId()); return 1; } @Override public TaskUserCount taskCount(Integer taskId,Integer orgType) { return taskMapper.selectTaskCount(taskId,orgType); } @Override public int relationUser(TaskParam param,Long id) { List<TaskProcess> taskProcesses = new ArrayList<>(); List<TaskUser> taskUsers = param.getTaskUsers(); Set<Long> units = new HashSet<>(); for (TaskUser taskUser : taskUsers) { //System.out.println(taskUser.getId()); units.add(taskUser.getId()); //任务指派流程 //任务对应的用户状态 taskUser.setState(1); taskUser.setStateDesc("未读"); taskUser.setTaskId(param.getId()); taskUser.setUnitId(taskUser.getId()); if(param.getTaskSign()!=null && param.getTaskSign() == 1){ taskUser.setUserType(1); } } for (TaskUser taskUser : taskUsers) { TaskProcess process1 = new TaskProcess(); process1.setTaskId(id); process1.setOperationUser(param.getCreateUser()); process1.setProsessName("派发任务"); process1.setUnitId(taskUser.getId()); process1.setProsessStatus(1); process1.setProcessContent(param.getCreateUserName()+"派发任务给"+taskUser.getUserName()); process1.setCreateTime(new Date()); taskProcesses.add(process1); } //发送短信 Task task = new Task(); BeanUtils.copyProperties(param,task); smsSendUtils.sendTaskMessage(task,taskUsers); //保存流程和用户流程 taskProcessService.insertBatch(taskProcesses); taskUserService.insertBatch(taskUsers); return 1; } public static boolean isAllFieldNull(Object obj) throws Exception{ Class stuCla = (Class) obj.getClass();// 得到类对象 Field[] fs = stuCla.getDeclaredFields();//得到属性集合 boolean flag = true; for (Field f : fs) {//遍历属性 f.setAccessible(true); // 设置属性是可以访问的(私有的也可以) Object val = f.get(obj);// 得到此属性的值 if(val!=null) {//只要有1个属性不为空,那么就不是所有的属性值都为空 flag = false; break; } } return flag; } }