Browse Source

日期有任务的显示

zyh
小久哥 3 years ago
parent
commit
59c86e3aca
  1. 3
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/ProjectController.java
  2. 9
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/vo/ProjectBaseVO.java
  3. 4
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/vo/ProjectRespVO.java
  4. 8
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/TaskController.java
  5. 2
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectService.java
  6. 9
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java
  7. 6
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskService.java
  8. 21
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImpl.java

3
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/ProjectController.java

@ -73,8 +73,7 @@ public class ProjectController {
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('farm:project:query')")
public CommonResult<ProjectRespVO> getProject(@RequestParam("id") Long id) {
ProjectDO project = projectService.getProject(id);
return success(ProjectConvert.INSTANCE.convert(project));
return success(projectService.getProject(id));
}
@GetMapping("/list")

9
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/vo/ProjectBaseVO.java

@ -25,7 +25,8 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*/
@Data
public class ProjectBaseVO extends ProjectDO {
public class
ProjectBaseVO extends ProjectDO {
@ApiModelProperty(value = "")
@ -78,11 +79,11 @@ public class ProjectBaseVO extends ProjectDO {
List<RoleDO> roles = roleService.getRolesFromCache(loginUser.getRoleIds());
Optional<RoleDO> admin = roles.stream().filter(roleDO -> roleDO.getName().contains("管理员") || roleDO.getCode().contains("admin")).findAny();
// 是创建者 或者 是 租户的管理员,可以更改项目
actions.put("edit",getCreator().equals(loginUser.getId().toString()) || admin.isPresent());
// // 是创建者 或者 是 租户的管理员,可以更改项目
actions.put("edit",this.getCreator().equals(loginUser.getId().toString()) || admin.isPresent());
// 应该加上,项目下面没有运行中的任务才可以删除 ,或者是在删除部分再做判断 ,此处只做权限显示
actions.put("delete",getCreator().equals(loginUser.getId().toString()) || admin.isPresent());
actions.put("delete",this.getCreator().equals(loginUser.getId().toString()) || admin.isPresent());
return actions;
}

4
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/vo/ProjectRespVO.java

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.farm.controller.admin.project.vo;
import cn.iocoder.yudao.module.system.dal.dataobject.CpUser.CpUserDO;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
@ -16,4 +17,7 @@ public class ProjectRespVO extends ProjectBaseVO {
@ApiModelProperty(value = "")
private Date createTime;
@ApiModelProperty("项目的成员")
private List<CpUserDO> userList;
}

8
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/TaskController.java

@ -141,4 +141,12 @@ public class TaskController {
public R<TaskSummaryDTO> taskSummary(){
return R.success(taskService.taskSummary());
}
@GetMapping("/whatDayHaveTask")
@ApiOperation("有任务的日期")
public R<List<Map<String, String>>> whatDayHaveTask(){
return R.success(taskService.whatDayHaveTask());
}
}

2
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectService.java

@ -46,7 +46,7 @@ public interface ProjectService {
* @param id 编号
* @return 农场项目
*/
ProjectDO getProject(Long id);
ProjectRespVO getProject(Long id);
/**
* 获得农场项目列表

9
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java

@ -113,8 +113,13 @@ public class ProjectServiceImpl implements ProjectService {
}
@Override
public ProjectDO getProject(Long id) {
return projectMapper.selectById(id);
public ProjectRespVO getProject(Long id) {
ProjectDO projectDO = projectMapper.selectById(id);
ProjectRespVO respVO = BeanUtil.copyProperties(projectDO, ProjectRespVO.class);
List<CpUserDO> userList = ObjectUtil.isEmpty(projectDO.getMembers()) ? new ArrayList<>() : cpUserMapper.selectList(CpUserDO::getId, projectDO.getMembers());
respVO.setUserList(userList);
return respVO;
}
@Override

6
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskService.java

@ -93,4 +93,10 @@ public interface TaskService {
* 任务汇总
**/
TaskSummaryDTO taskSummary();
/**
* 小程序任务 有日期的任务显示
**/
List<Map<String, String>> whatDayHaveTask();
}

21
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImpl.java

@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.farm.service.task;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.StrBuilder;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
@ -8,6 +10,7 @@ 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.mybatis.core.query.QueryWrapperX;
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;
@ -34,6 +37,7 @@ 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.excel.annotation.format.DateTimeFormat;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -44,6 +48,8 @@ import javax.annotation.Resource;
import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated;
import java.text.DateFormat;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
@ -472,6 +478,21 @@ public class TaskServiceImpl implements TaskService {
}
public List<Map<String, String>> whatDayHaveTask(){
LambdaQueryWrapperX<TaskDO> queryWrapperX = new LambdaQueryWrapperX<>();
queryWrapperX.ne(TaskDO::getDraft, true);
queryWrapperX.ne(TaskDO::getPretendDelete, true);
List<TaskDO> taskList = taskMapper.selectList(queryWrapperX);
Map<Object, List<TaskDO>> dateMap = taskList.stream().collect(Collectors.groupingBy(item -> DateUtil.format(item.getPlanStartTime(), DatePattern.NORM_DATE_FORMAT)));
List<Map<String, String>> list = new ArrayList<>();
dateMap.entrySet().stream().forEach(item ->{
Map map = new HashMap<String,String>() ;
map.put("date", item.getKey().toString());
list.add(map);
});
return list;
}
}

Loading…
Cancel
Save