|
|
|
@ -8,6 +8,8 @@ import cn.hutool.system.oshi.CpuInfo;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.page.PageUtil; |
|
|
|
|
import cn.iocoder.yudao.framework.common.page.PageVO; |
|
|
|
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
|
|
|
|
import cn.iocoder.yudao.framework.security.core.LoginUser; |
|
|
|
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; |
|
|
|
|
import cn.iocoder.yudao.module.farm.controller.admin.resource.dto.ResourceDTO; |
|
|
|
|
import cn.iocoder.yudao.module.farm.controller.admin.resource.dto.ResourceMsgDTO; |
|
|
|
|
import cn.iocoder.yudao.module.farm.controller.admin.task.dto.*; |
|
|
|
@ -25,11 +27,15 @@ import cn.iocoder.yudao.module.farm.dal.mysql.project.ProjectMapper;
|
|
|
|
|
import cn.iocoder.yudao.module.farm.dal.mysql.resource.ResourceMapper; |
|
|
|
|
import cn.iocoder.yudao.module.farm.dal.mysql.resourceType.ResourceTypeMapper; |
|
|
|
|
import cn.iocoder.yudao.module.farm.dal.mysql.taskCate.TaskCateMapper; |
|
|
|
|
import cn.iocoder.yudao.module.farm.enums.TaskMemberEnum; |
|
|
|
|
import cn.iocoder.yudao.module.farm.enums.TaskStatus; |
|
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.CpUser.CpUserDO; |
|
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; |
|
|
|
|
import cn.iocoder.yudao.module.system.dal.mysql.CpUser.CpUserMapper; |
|
|
|
|
import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper; |
|
|
|
|
import cn.iocoder.yudao.module.system.service.CpUser.CpUserService; |
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.zsw.base.R; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
@ -48,6 +54,7 @@ import cn.iocoder.yudao.module.farm.convert.task.TaskConvert;
|
|
|
|
|
import cn.iocoder.yudao.module.farm.dal.mysql.task.TaskMapper; |
|
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
|
|
|
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
|
|
|
|
import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.*; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -79,6 +86,8 @@ public class TaskServiceImpl implements TaskService {
|
|
|
|
|
private ResourceMapper resourceMapper; |
|
|
|
|
@Resource |
|
|
|
|
private DiscussMapper discussMapper; |
|
|
|
|
@Resource |
|
|
|
|
private AdminUserMapper adminUserMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -127,8 +136,56 @@ public class TaskServiceImpl implements TaskService {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public PageResult<TaskDO> getTaskPage(TaskPageReqVO pageReqVO) { |
|
|
|
|
return taskMapper.selectPage(pageReqVO); |
|
|
|
|
public PageResult<TaskAssemblyDTO> getTaskPage(TaskPageReqVO pageReqVO) { |
|
|
|
|
LambdaQueryWrapperX<TaskDO> queryWrapperX = new LambdaQueryWrapperX<>(); |
|
|
|
|
if (ObjectUtil.isNotEmpty(pageReqVO.getMyTask()) && pageReqVO.getMyTask()){ |
|
|
|
|
if (pageReqVO.getMemberEnum().equals(TaskMemberEnum.CREATE)){ |
|
|
|
|
queryWrapperX.eqIfPresent(TaskDO::getCreator, getLoginUserId()); |
|
|
|
|
}else { |
|
|
|
|
AdminUserDO adminUser = adminUserMapper.selectOne(AdminUserDO::getId, getLoginUserId()); |
|
|
|
|
CpUserDO cpUserDO = cpUserMapper.selectOne(CpUserDO::getUserId, adminUser.getCpUserId()); |
|
|
|
|
if (pageReqVO.getMemberEnum().equals(TaskMemberEnum.RESPONSIBLE)){ |
|
|
|
|
queryWrapperX.eq(TaskDO::getMainPerson, cpUserDO.getId()); |
|
|
|
|
}else{ |
|
|
|
|
queryWrapperX.apply(("JSON_CONTAINS(executor_person, '"+ cpUserDO.getId()+"')")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
queryWrapperX.eqIfPresent(TaskDO::getProjectId, pageReqVO.getProjectId()) |
|
|
|
|
.eqIfPresent(TaskDO::getCropId, pageReqVO.getCropId()) |
|
|
|
|
.eqIfPresent(TaskDO::getCropNum, pageReqVO.getCropNum()) |
|
|
|
|
.eqIfPresent(TaskDO::getTaskCateId, pageReqVO.getTaskCateId()) |
|
|
|
|
.eqIfPresent(TaskDO::getTaskCateName, pageReqVO.getTaskCateName()) |
|
|
|
|
.eqIfPresent(TaskDO::getResources, pageReqVO.getResources()) |
|
|
|
|
.eqIfPresent(TaskDO::getImages, pageReqVO.getImages()) |
|
|
|
|
.eqIfPresent(TaskDO::getDraft, pageReqVO.getDraft()) |
|
|
|
|
.betweenIfPresent(TaskDO::getPlanStartTime, pageReqVO.getBeginPlanStartTime(), pageReqVO.getEndPlanStartTime()) |
|
|
|
|
.betweenIfPresent(TaskDO::getPlanEndTime, pageReqVO.getBeginPlanEndTime(), pageReqVO.getEndPlanEndTime()) |
|
|
|
|
.eqIfPresent(TaskDO::getWeight, pageReqVO.getWeight()) |
|
|
|
|
.betweenIfPresent(TaskDO::getCreateTime, pageReqVO.getBeginCreateTime(), pageReqVO.getEndCreateTime()) |
|
|
|
|
.eqIfPresent(TaskDO::getPretendDelete, pageReqVO.getPretendDelete()) |
|
|
|
|
.eqIfPresent(TaskDO::getStatus, pageReqVO.getTaskStatus()) |
|
|
|
|
.orderByDesc(TaskDO::getId); |
|
|
|
|
|
|
|
|
|
PageResult<TaskDO> pageResult = taskMapper.selectPage(pageReqVO, queryWrapperX); |
|
|
|
|
|
|
|
|
|
Map<Long, TaskAssemblyDTO> map = this.taskAssemble(pageResult.getList()); |
|
|
|
|
List<TaskAssemblyDTO> list = new ArrayList<>(); |
|
|
|
|
pageResult.getList().forEach(item ->{ |
|
|
|
|
if (map.containsKey(item.getId())){ |
|
|
|
|
TaskAssemblyDTO taskAssemblyDTO = map.get(item.getId()); |
|
|
|
|
TaskAssemblyDTO dto = BeanUtil.copyProperties(item, TaskAssemblyDTO.class); |
|
|
|
|
dto.setProjectName(taskAssemblyDTO.getProjectName()); |
|
|
|
|
dto.setTaskMsg(taskAssemblyDTO.getTaskMsg()); |
|
|
|
|
list.add(dto); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
PageResult<TaskAssemblyDTO> assemble = new PageResult<>(); |
|
|
|
|
assemble.setTotal(pageResult.getTotal()); |
|
|
|
|
assemble.setList(list); |
|
|
|
|
return assemble; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -189,6 +246,11 @@ public class TaskServiceImpl implements TaskService {
|
|
|
|
|
//负责人
|
|
|
|
|
taskMsg.setApiMainPerson(cpUserService.getById(String.valueOf(taskMsg.getMainPerson()))); |
|
|
|
|
} |
|
|
|
|
AdminUserDO adminUser = adminUserMapper.selectOne(AdminUserDO::getId, taskDO.getCreator()); |
|
|
|
|
if (ObjectUtil.isNotEmpty(adminUser)){ |
|
|
|
|
//创建人
|
|
|
|
|
taskMsg.setApiCreateUser(cpUserMapper.selectOne(CpUserDO::getUserId, adminUser.getCpUserId())); |
|
|
|
|
} |
|
|
|
|
//任务活动的累计数量
|
|
|
|
|
List<DiscussDO> discussDOList = discussMapper.selectList(DiscussDO::getTaskId, id); |
|
|
|
|
taskMsg.setCumulativeQuantity(ObjectUtil.isEmpty(discussDOList) ? 0 : discussDOList.stream().mapToInt(DiscussDO::getCropNum).sum()); |
|
|
|
@ -396,5 +458,30 @@ public class TaskServiceImpl implements TaskService {
|
|
|
|
|
return map; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//活动汇总
|
|
|
|
|
public TaskSummaryDTO taskSummary(){ |
|
|
|
|
Long userId = getLoginUserId(); |
|
|
|
|
TaskSummaryDTO taskSummaryDTO = new TaskSummaryDTO(); |
|
|
|
|
if (ObjectUtil.isNotEmpty(userId)){ |
|
|
|
|
//我创建
|
|
|
|
|
taskSummaryDTO.setCreateCount(taskMapper.selectCount( |
|
|
|
|
new LambdaQueryWrapper<TaskDO>().eq(TaskDO::getCreator, userId).eq(TaskDO::getDraft, false).eq(TaskDO::getPretendDelete, false)).intValue()); |
|
|
|
|
AdminUserDO adminUser = adminUserMapper.selectOne(AdminUserDO::getId, userId); |
|
|
|
|
CpUserDO cpUser = cpUserMapper.selectOne(CpUserDO::getUserId, adminUser.getCpUserId()); |
|
|
|
|
//我负责的
|
|
|
|
|
taskSummaryDTO.setResponsibleCount(taskMapper.selectCount( |
|
|
|
|
new LambdaQueryWrapper<TaskDO>().eq(TaskDO::getMainPerson, cpUser.getId()).eq(TaskDO::getDraft, false).eq(TaskDO::getPretendDelete, false)).intValue()); |
|
|
|
|
//我参与的
|
|
|
|
|
//queryWrapperX.apply(" ((JSON_CONTAINS(members, '"+ user.getId()+"') or creator = " + getLoginUserId() +"))");
|
|
|
|
|
taskSummaryDTO.setJoinCount(taskMapper.selectCount( |
|
|
|
|
new LambdaQueryWrapper<TaskDO>().eq(TaskDO::getDraft, false).eq(TaskDO::getPretendDelete, false).apply(("JSON_CONTAINS(executor_person, '"+ cpUser.getId()+"')"))).intValue()); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return taskSummaryDTO; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|