10 files added
2 files modified
| | |
| | | public static final String SETTLEMENT_STATUS_SETTLED = "settlement_status_settled"; |
| | | //结算状态:未结算 |
| | | public static final String SETTLEMENT_STATUS_UNSETTLED = "settlement_status_unsettled"; |
| | | |
| | | // 优先度 |
| | | public static final String PRIORITY = "priority"; |
| | | // 优先度:低 |
| | | public static final String PRIORITY_LOW = "priority_low"; |
| | | // 优先度:中 |
| | | public static final String PRIORITY_MIDDLE = "priority_middle"; |
| | | // 优先度:高 |
| | | public static final String PRIORITY_HIGH = "priority_high"; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.task.domain; |
| | | |
| | | import lombok.Data; |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import cn.hutool.core.bean.copier.CopyOptions; |
| | | import me.zhengjie.base.BaseEntity; |
| | | |
| | | import javax.persistence.*; |
| | | import javax.validation.constraints.*; |
| | | import java.sql.Timestamp; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description / |
| | | * @author 赵士淞 |
| | | * @date 2022-12-27 |
| | | **/ |
| | | @Entity |
| | | @Data |
| | | @Table(name="task") |
| | | public class Task extends BaseEntity implements Serializable { |
| | | |
| | | @Id |
| | | @GeneratedValue(strategy = GenerationType.IDENTITY) |
| | | @Column(name = "`id`") |
| | | @ApiModelProperty(value = "ID") |
| | | private Long id; |
| | | |
| | | @Column(name = "`project_id`",nullable = false) |
| | | @NotNull |
| | | @ApiModelProperty(value = "项目ID") |
| | | private Long projectId; |
| | | |
| | | @Column(name = "`pid`") |
| | | @ApiModelProperty(value = "父任务ID") |
| | | private Long pid; |
| | | |
| | | @Column(name = "`name`",nullable = false) |
| | | @NotBlank |
| | | @ApiModelProperty(value = "名称") |
| | | private String name; |
| | | |
| | | @Column(name = "`priority`",nullable = false) |
| | | @NotBlank |
| | | @ApiModelProperty(value = "优先度") |
| | | private String priority; |
| | | |
| | | @Column(name = "`task_classification`",nullable = false) |
| | | @NotBlank |
| | | @ApiModelProperty(value = "任务分类") |
| | | private String taskClassification; |
| | | |
| | | @Column(name = "`description`") |
| | | @ApiModelProperty(value = "描述") |
| | | private String description; |
| | | |
| | | @Column(name = "`plan_start_time`") |
| | | @ApiModelProperty(value = "计划开始时间") |
| | | private Timestamp planStartTime; |
| | | |
| | | @Column(name = "`plan_end_time`") |
| | | @ApiModelProperty(value = "计划结束时间") |
| | | private Timestamp planEndTime; |
| | | |
| | | @Column(name = "`plan_hours`",nullable = false) |
| | | @NotNull |
| | | @ApiModelProperty(value = "计划工时") |
| | | private Double planHours; |
| | | |
| | | @Column(name = "`plan_workload`") |
| | | @ApiModelProperty(value = "计划工作量") |
| | | private Double planWorkload; |
| | | |
| | | @Column(name = "`plan_workload_unit`") |
| | | @ApiModelProperty(value = "计划工作量单位") |
| | | private String planWorkloadUnit; |
| | | |
| | | @Column(name = "`remarks`") |
| | | @ApiModelProperty(value = "备注") |
| | | private String remarks; |
| | | |
| | | public void copy(Task source){ |
| | | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.task.repository; |
| | | |
| | | import me.zhengjie.modules.task.domain.Task; |
| | | import org.springframework.data.jpa.repository.JpaRepository; |
| | | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author 赵士淞 |
| | | * @date 2022-12-27 |
| | | **/ |
| | | public interface TaskRepository extends JpaRepository<Task, Long>, JpaSpecificationExecutor<Task> { |
| | | |
| | | /** |
| | | * 根据父级任务ID查询 |
| | | * @param pid |
| | | * @return |
| | | */ |
| | | List<Task> findByPid(Long pid); |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.task.rest; |
| | | |
| | | import me.zhengjie.annotation.Log; |
| | | import me.zhengjie.modules.task.domain.Task; |
| | | import me.zhengjie.modules.task.service.TaskService; |
| | | import me.zhengjie.modules.task.service.dto.TaskQueryCriteria; |
| | | import org.springframework.data.domain.Pageable; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import io.swagger.annotations.*; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author 赵士淞 |
| | | * @date 2022-12-27 |
| | | **/ |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @Api(tags = "任务管理") |
| | | @RequestMapping("/api/task") |
| | | public class TaskController { |
| | | |
| | | private final TaskService taskService; |
| | | |
| | | @Log("导出数据") |
| | | @ApiOperation("导出数据") |
| | | @GetMapping(value = "/download") |
| | | @PreAuthorize("@el.check('task:download')") |
| | | public void exportTask(HttpServletResponse response, TaskQueryCriteria criteria) throws IOException { |
| | | taskService.download(taskService.queryAll(criteria), response); |
| | | } |
| | | |
| | | @GetMapping |
| | | @Log("查询任务") |
| | | @ApiOperation("查询任务") |
| | | @PreAuthorize("@el.check('task:list')") |
| | | public ResponseEntity<Object> queryTask(TaskQueryCriteria criteria, Pageable pageable){ |
| | | return new ResponseEntity<>(taskService.queryAll(criteria,pageable),HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping(value = "/all") |
| | | @Log("查询任务") |
| | | @ApiOperation("查询任务") |
| | | @PreAuthorize("@el.check('task:list')") |
| | | public ResponseEntity<Object> queryTask(TaskQueryCriteria criteria){ |
| | | return new ResponseEntity<>(taskService.queryAll(criteria),HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping(value = "/children") |
| | | @Log("查询子级任务") |
| | | @ApiOperation("查询子级任务") |
| | | @PreAuthorize("@el.check('task:list')") |
| | | public ResponseEntity<Object> queryChildrenTask(TaskQueryCriteria criteria){ |
| | | return new ResponseEntity<>(taskService.queryChildren(criteria),HttpStatus.OK); |
| | | } |
| | | |
| | | @PostMapping |
| | | @Log("新增任务") |
| | | @ApiOperation("新增任务") |
| | | @PreAuthorize("@el.check('task:add')") |
| | | public ResponseEntity<Object> createTask(@Validated @RequestBody Task resources){ |
| | | return new ResponseEntity<>(taskService.create(resources),HttpStatus.CREATED); |
| | | } |
| | | |
| | | @PutMapping |
| | | @Log("修改任务") |
| | | @ApiOperation("修改任务") |
| | | @PreAuthorize("@el.check('task:edit')") |
| | | public ResponseEntity<Object> updateTask(@Validated @RequestBody Task resources){ |
| | | taskService.update(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @Log("删除任务") |
| | | @ApiOperation("删除任务") |
| | | @PreAuthorize("@el.check('task:del')") |
| | | public ResponseEntity<Object> deleteTask(@RequestBody Long[] ids) { |
| | | taskService.deleteAll(ids); |
| | | return new ResponseEntity<>(HttpStatus.OK); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.task.service; |
| | | |
| | | import me.zhengjie.modules.task.domain.Task; |
| | | import me.zhengjie.modules.task.service.dto.TaskDto; |
| | | import me.zhengjie.modules.task.service.dto.TaskQueryCriteria; |
| | | import org.springframework.data.domain.Pageable; |
| | | import java.util.Map; |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description 服务接口 |
| | | * @author 赵士淞 |
| | | * @date 2022-12-27 |
| | | **/ |
| | | public interface TaskService { |
| | | |
| | | /** |
| | | * 查询数据分页 |
| | | * @param criteria 条件 |
| | | * @param pageable 分页参数 |
| | | * @return Map<String,Object> |
| | | */ |
| | | Map<String,Object> queryAll(TaskQueryCriteria criteria, Pageable pageable); |
| | | |
| | | /** |
| | | * 查询所有数据不分页 |
| | | * @param criteria 条件参数 |
| | | * @return List<TaskDto> |
| | | */ |
| | | List<TaskDto> queryAll(TaskQueryCriteria criteria); |
| | | |
| | | /** |
| | | * 查询子级数据不分页 |
| | | * @param criteria 条件参数 |
| | | * @return List<TaskDto> |
| | | */ |
| | | List<TaskDto> queryChildren(TaskQueryCriteria criteria); |
| | | |
| | | /** |
| | | * 根据ID查询 |
| | | * @param id ID |
| | | * @return TaskDto |
| | | */ |
| | | TaskDto findById(Long id); |
| | | |
| | | /** |
| | | * 创建 |
| | | * @param resources / |
| | | * @return TaskDto |
| | | */ |
| | | TaskDto create(Task resources); |
| | | |
| | | /** |
| | | * 编辑 |
| | | * @param resources / |
| | | */ |
| | | void update(Task resources); |
| | | |
| | | /** |
| | | * 多选删除 |
| | | * @param ids / |
| | | */ |
| | | void deleteAll(Long[] ids); |
| | | |
| | | /** |
| | | * 导出数据 |
| | | * @param all 待导出的数据 |
| | | * @param response / |
| | | * @throws IOException / |
| | | */ |
| | | void download(List<TaskDto> all, HttpServletResponse response) throws IOException; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.task.service.dto; |
| | | |
| | | import lombok.Data; |
| | | import me.zhengjie.base.BaseDTO; |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description / |
| | | * @author 赵士淞 |
| | | * @date 2022-12-27 |
| | | **/ |
| | | @Data |
| | | public class TaskDto extends BaseDTO implements Serializable { |
| | | |
| | | /** ID */ |
| | | private Long id; |
| | | |
| | | /** 项目ID */ |
| | | private Long projectId; |
| | | |
| | | /** 父任务ID */ |
| | | private Long pid; |
| | | |
| | | /** 名称 */ |
| | | private String name; |
| | | |
| | | /** 优先度 */ |
| | | private String priority; |
| | | |
| | | /** 任务分类 */ |
| | | private String taskClassification; |
| | | |
| | | /** 描述 */ |
| | | private String description; |
| | | |
| | | /** 计划开始时间 */ |
| | | private Timestamp planStartTime; |
| | | |
| | | /** 计划结束时间 */ |
| | | private Timestamp planEndTime; |
| | | |
| | | /** 计划工时 */ |
| | | private Double planHours; |
| | | |
| | | /** 计划工作量 */ |
| | | private Double planWorkload; |
| | | |
| | | /** 计划工作量单位 */ |
| | | private String planWorkloadUnit; |
| | | |
| | | /** 备注 */ |
| | | private String remarks; |
| | | |
| | | /** 项目名称 */ |
| | | private String projectName; |
| | | |
| | | /** 父任务名称 */ |
| | | private String pidName; |
| | | |
| | | /** 是否有子级 */ |
| | | private Boolean hasChildren; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.task.service.dto; |
| | | |
| | | import lombok.Data; |
| | | import java.util.List; |
| | | import me.zhengjie.annotation.Query; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author 赵士淞 |
| | | * @date 2022-12-27 |
| | | **/ |
| | | @Data |
| | | public class TaskQueryCriteria{ |
| | | |
| | | /** 精确 */ |
| | | @Query |
| | | private Long id; |
| | | |
| | | /** 精确 */ |
| | | @Query |
| | | private Long projectId; |
| | | |
| | | /** 模糊 */ |
| | | @Query(type = Query.Type.INNER_LIKE) |
| | | private String name; |
| | | |
| | | /** 精确 */ |
| | | @Query |
| | | private String priority; |
| | | |
| | | /** 精确 */ |
| | | @Query |
| | | private String taskClassification; |
| | | |
| | | @Query(type = Query.Type.IS_NULL, propName = "pid") |
| | | private Boolean pidIsNull; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.task.service.impl; |
| | | |
| | | import me.zhengjie.modules.constant.Constant; |
| | | import me.zhengjie.modules.project.domain.Project; |
| | | import me.zhengjie.modules.project.repository.ProjectRepository; |
| | | import me.zhengjie.modules.system.repository.DictDetailRepository; |
| | | import me.zhengjie.modules.task.domain.Task; |
| | | import me.zhengjie.utils.ValidationUtil; |
| | | import me.zhengjie.utils.FileUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import me.zhengjie.modules.task.repository.TaskRepository; |
| | | import me.zhengjie.modules.task.service.TaskService; |
| | | import me.zhengjie.modules.task.service.dto.TaskDto; |
| | | import me.zhengjie.modules.task.service.dto.TaskQueryCriteria; |
| | | import me.zhengjie.modules.task.service.mapstruct.TaskMapper; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.data.domain.Page; |
| | | import org.springframework.data.domain.Pageable; |
| | | import me.zhengjie.utils.PageUtil; |
| | | import me.zhengjie.utils.QueryHelp; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.function.Function; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description 服务实现 |
| | | * @author 赵士淞 |
| | | * @date 2022-12-27 |
| | | **/ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class TaskServiceImpl implements TaskService { |
| | | |
| | | private final TaskRepository taskRepository; |
| | | private final TaskMapper taskMapper; |
| | | private final ProjectRepository projectRepository; |
| | | private final DictDetailRepository dictDetailRepository; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(TaskQueryCriteria criteria, Pageable pageable){ |
| | | // 判断检索条件 |
| | | if (criteria.getProjectId() == null && criteria.getName() == null && criteria.getPriority() == null && criteria.getTaskClassification() == null) { |
| | | // 检索条件 |
| | | criteria.setPidIsNull(true); |
| | | } |
| | | Page<Task> page = taskRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); |
| | | // 将实体类转换为DTO(重写) |
| | | Function<Task, TaskDto> func = new Function<Task, TaskDto>(){ |
| | | @Override |
| | | public TaskDto apply(Task t) { |
| | | // 将实体类转换成DTO |
| | | TaskDto taskDto = taskMapper.toDto(t); |
| | | // 根据项目ID查询项目信息 |
| | | Project project = projectRepository.findById(taskDto.getProjectId()).orElseGet(Project::new); |
| | | ValidationUtil.isNull(project.getId(),"Project","id",taskDto.getProjectId()); |
| | | // 项目名称 |
| | | taskDto.setProjectName(project.getName()); |
| | | // 判断父级任务ID是否为空 |
| | | if (taskDto.getPid() != null) { |
| | | // 根据父级任务ID查询任务信息 |
| | | Task task = taskRepository.findById(taskDto.getPid()).orElseGet(Task::new); |
| | | ValidationUtil.isNull(task.getId(),"Task","id",taskDto.getPid()); |
| | | // 项目名称 |
| | | taskDto.setPidName(task.getName()); |
| | | } |
| | | // 根据父级任务ID查询 |
| | | List<Task> childrenTaskList = taskRepository.findByPid(taskDto.getId()); |
| | | // 判断子级数量 |
| | | if (childrenTaskList.size() > 0) { |
| | | // 是否有子级 |
| | | taskDto.setHasChildren(true); |
| | | } else { |
| | | // 是否有子级 |
| | | taskDto.setHasChildren(false); |
| | | } |
| | | // 返回处理好的DTO |
| | | return taskDto; |
| | | } |
| | | }; |
| | | return PageUtil.toPage(page.map(func)); |
| | | } |
| | | |
| | | @Override |
| | | public List<TaskDto> queryAll(TaskQueryCriteria criteria){ |
| | | return taskMapper.toDto(taskRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); |
| | | } |
| | | |
| | | @Override |
| | | public List<TaskDto> queryChildren(TaskQueryCriteria criteria){ |
| | | // 根据父级任务ID查询 |
| | | List<TaskDto> childrenTaskDtoList = taskMapper.toDto(taskRepository.findByPid(criteria.getId())); |
| | | // 循环子级任务列表 |
| | | for (int i = 0; i < childrenTaskDtoList.size(); i ++) { |
| | | // 根据项目ID查询项目信息 |
| | | Project project = projectRepository.findById(childrenTaskDtoList.get(i).getProjectId()).orElseGet(Project::new); |
| | | ValidationUtil.isNull(project.getId(),"Project","id",childrenTaskDtoList.get(i).getProjectId()); |
| | | // 项目名称 |
| | | childrenTaskDtoList.get(i).setProjectName(project.getName()); |
| | | // 判断父级任务ID是否为空 |
| | | if (childrenTaskDtoList.get(i).getPid() != null) { |
| | | // 根据父级任务ID查询任务信息 |
| | | Task task = taskRepository.findById(childrenTaskDtoList.get(i).getPid()).orElseGet(Task::new); |
| | | ValidationUtil.isNull(task.getId(),"Task","id",childrenTaskDtoList.get(i).getPid()); |
| | | // 项目名称 |
| | | childrenTaskDtoList.get(i).setPidName(task.getName()); |
| | | } |
| | | // 根据父级任务ID查询 |
| | | List<Task> childrenTaskList = taskRepository.findByPid(childrenTaskDtoList.get(i).getId()); |
| | | // 判断子级数量 |
| | | if (childrenTaskList.size() > 0) { |
| | | // 是否有子级 |
| | | childrenTaskDtoList.get(i).setHasChildren(true); |
| | | } else { |
| | | // 是否有子级 |
| | | childrenTaskDtoList.get(i).setHasChildren(false); |
| | | } |
| | | } |
| | | return childrenTaskDtoList; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public TaskDto findById(Long id) { |
| | | Task task = taskRepository.findById(id).orElseGet(Task::new); |
| | | ValidationUtil.isNull(task.getId(),"Task","id",id); |
| | | return taskMapper.toDto(task); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public TaskDto create(Task resources) { |
| | | return taskMapper.toDto(taskRepository.save(resources)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void update(Task resources) { |
| | | Task task = taskRepository.findById(resources.getId()).orElseGet(Task::new); |
| | | ValidationUtil.isNull( task.getId(),"Task","id",resources.getId()); |
| | | task.copy(resources); |
| | | taskRepository.save(task); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteAll(Long[] ids) { |
| | | for (Long id : ids) { |
| | | taskRepository.deleteById(id); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void download(List<TaskDto> all, HttpServletResponse response) throws IOException { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | for (TaskDto task : all) { |
| | | String projectName = task.getProjectId() != null ? projectRepository.findById(task.getProjectId()).orElseGet(Project::new).getName() : ""; |
| | | String pidName = task.getPid() != null ? taskRepository.findById(task.getPid()).orElseGet(Task::new).getName() : ""; |
| | | String priority = task.getPriority() != null ? dictDetailRepository.findByDictNameAndValue(Constant.PRIORITY, task.getPriority()).getLabel() : ""; |
| | | String taskClassification = task.getTaskClassification() != null ? dictDetailRepository.findByDictNameAndValue(Constant.TASK_CLASSIFICATION, task.getTaskClassification()).getLabel() : ""; |
| | | String planWorkloadUnit = task.getPlanWorkloadUnit() != null ? dictDetailRepository.findByDictNameAndValue(Constant.STANDARD_WORKLOAD_UNIT, task.getPlanWorkloadUnit()).getLabel() : ""; |
| | | Map<String,Object> map = new LinkedHashMap<>(); |
| | | map.put("项目名称", projectName); |
| | | map.put("父任务名称", pidName); |
| | | map.put("名称", task.getName()); |
| | | map.put("优先度", priority); |
| | | map.put("任务分类", taskClassification); |
| | | map.put("描述", task.getDescription()); |
| | | map.put("计划开始时间", task.getPlanStartTime()); |
| | | map.put("计划结束时间", task.getPlanEndTime()); |
| | | map.put("计划工时", task.getPlanHours()); |
| | | map.put("计划工作量", task.getPlanWorkload()); |
| | | map.put("计划工作量单位", planWorkloadUnit); |
| | | map.put("备注", task.getRemarks()); |
| | | map.put("创建者", task.getCreateBy()); |
| | | map.put("创建时间", task.getCreateTime()); |
| | | map.put("更新者", task.getUpdateBy()); |
| | | map.put("更新时间", task.getUpdateTime()); |
| | | list.add(map); |
| | | } |
| | | FileUtil.downloadExcel(list, response); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.task.service.mapstruct; |
| | | |
| | | import me.zhengjie.base.BaseMapper; |
| | | import me.zhengjie.modules.task.domain.Task; |
| | | import me.zhengjie.modules.task.service.dto.TaskDto; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.ReportingPolicy; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author 赵士淞 |
| | | * @date 2022-12-27 |
| | | **/ |
| | | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) |
| | | public interface TaskMapper extends BaseMapper<TaskDto, Task> { |
| | | |
| | | } |
| New file |
| | |
| | | import request from '@/utils/request' |
| | | |
| | | export function getAll(params) { |
| | | return request({ |
| | | url: 'api/task/all', |
| | | method: 'get', |
| | | params |
| | | }) |
| | | } |
| | | |
| | | export function getChildren(params) { |
| | | return request({ |
| | | url: 'api/task/children', |
| | | method: 'get', |
| | | params |
| | | }) |
| | | } |
| | | |
| | | export function add(data) { |
| | | return request({ |
| | | url: 'api/task', |
| | | method: 'post', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export function del(ids) { |
| | | return request({ |
| | | url: 'api/task/', |
| | | method: 'delete', |
| | | data: ids |
| | | }) |
| | | } |
| | | |
| | | export function edit(data) { |
| | | return request({ |
| | | url: 'api/task', |
| | | method: 'put', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export default { getAll, getChildren, add, edit, del } |
| | |
| | | // 结算状态:未结算 |
| | | export const SETTLEMENT_STATUS_UNSETTLED = 'settlement_status_unsettled' |
| | | |
| | | // 优先度 |
| | | export const PRIORITY = 'priority' |
| | | // 优先度:低 |
| | | export const PRIORITY_LOW = 'priority_low' |
| | | // 优先度:中 |
| | | export const PRIORITY_MIDDLE = 'priority_middle' |
| | | // 优先度:高 |
| | | export const PRIORITY_HIGH = 'priority_high' |
| | | |
| | | export default { |
| | | CONFIG_PROPORTION_BASIC_WAGE, |
| | | CONFIG_PROPORTION_MERIT_WAGE, |
| | |
| | | PROJECT_DISTINGUISH_B, |
| | | SETTLEMENT_STATUS, |
| | | SETTLEMENT_STATUS_SETTLED, |
| | | SETTLEMENT_STATUS_UNSETTLED |
| | | SETTLEMENT_STATUS_UNSETTLED, |
| | | PRIORITY, |
| | | PRIORITY_LOW, |
| | | PRIORITY_MIDDLE, |
| | | PRIORITY_HIGH |
| | | } |
| New file |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <!--工具栏--> |
| | | <div class="head-container"> |
| | | <div v-if="crud.props.searchToggle"> |
| | | <!-- 搜索 --> |
| | | <el-select v-model="query.projectId" filterable clearable placeholder="所属项目" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in projects" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | <el-input v-model="query.name" clearable placeholder="名称" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" /> |
| | | <el-select v-model="query.priority" filterable clearable placeholder="优先度" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in dict[priority]" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | <el-select v-model="query.taskClassification" filterable clearable placeholder="任务分类" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in dict[taskClassification]" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | <rrOperation :crud="crud" /> |
| | | </div> |
| | | <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'--> |
| | | <crudOperation :permission="permission" /> |
| | | <!--表单组件--> |
| | | <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px"> |
| | | <el-form ref="form" :model="form" :rules="rules" size="small" label-width="110px"> |
| | | <el-form-item label="所属项目" prop="projectId"> |
| | | <el-select v-model="form.projectId" filterable clearable placeholder="请选择" style="width: 340px;" @change="projectChange"> |
| | | <el-option |
| | | v-for="item in projects" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="名称" prop="name"> |
| | | <el-input v-model="form.name" style="width: 340px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="父级任务"> |
| | | <el-select v-model="form.pid" filterable clearable placeholder="请选择" style="width: 340px;"> |
| | | <el-option |
| | | v-for="item in pidTasks" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | :disabled="item.id == form.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="优先度" prop="priority"> |
| | | <el-select v-model="form.priority" filterable clearable placeholder="请选择" style="width: 340px;"> |
| | | <el-option |
| | | v-for="item in dict[priority]" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="任务分类" prop="taskClassification"> |
| | | <el-select v-model="form.taskClassification" filterable clearable placeholder="请选择" style="width: 340px;"> |
| | | <el-option |
| | | v-for="item in dict[taskClassification]" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="描述"> |
| | | <el-input v-model="form.description" :rows="3" type="textarea" style="width: 340px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="计划开始时间"> |
| | | <el-date-picker v-model="form.planStartTime" type="datetime" :picker-options="planStartTimePickerOptions" style="width: 340px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="计划结束时间"> |
| | | <el-date-picker v-model="form.planEndTime" type="datetime" :picker-options="planEndTimePickerOptions" style="width: 340px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="计划工时" prop="planHours"> |
| | | <el-input v-model="form.planHours" style="width: 340px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="计划工作量" prop="planWorkload"> |
| | | <el-input v-model="form.planWorkload" style="width: 340px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="计划工作量单位"> |
| | | <el-select v-model="form.planWorkloadUnit" filterable clearable placeholder="请选择" style="width: 340px;"> |
| | | <el-option |
| | | v-for="item in dict[standardWorkloadUnit]" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="备注"> |
| | | <el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 340px;" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div slot="footer" class="dialog-footer"> |
| | | <el-button type="text" @click="crud.cancelCU">取消</el-button> |
| | | <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | <!--表格渲染--> |
| | | <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" row-key="id" lazy :load="load" :tree-props="{children: 'children', hasChildren: 'hasChildren'}" @selection-change="crud.selectionChangeHandler"> |
| | | <el-table-column type="selection" width="55" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="projectName" label="所属项目" fixed="left" width="180"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ scope.row.projectName }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="name" label="名称" fixed="left" width="180" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="priority" label="优先度" width="80"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ dict.label[priority][scope.row.priority] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskClassification" label="任务分类" width="80"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ dict.label[taskClassification][scope.row.taskClassification] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="description" label="描述" width="140" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="planStartTime" label="计划开始时间" width="140" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="planEndTime" label="计划结束时间" width="140" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="planHours" label="计划工时" width="80" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="planWorkload" label="计划工作量" width="80" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="planWorkloadUnit" label="计划工作量单位" width="110"> |
| | | <template slot-scope="scope"> |
| | | <el-tag v-if="scope.row.planWorkloadUnit != null && scope.row.planWorkloadUnit != ''">{{ dict.label[standardWorkloadUnit][scope.row.planWorkloadUnit] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="remarks" label="备注" width="140" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="createTime" label="创建时间" width="140" /> |
| | | <el-table-column v-if="checkPer(['admin','task:edit','task:del'])" label="操作" width="150px" align="center" fixed="right"> |
| | | <template slot-scope="scope"> |
| | | <udOperation |
| | | :data="scope.row" |
| | | :permission="permission" |
| | | /> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <!--分页组件--> |
| | | <pagination /> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import crudTask from '@/api/task/task' |
| | | import CRUD, { presenter, header, form, crud } from '@crud/crud' |
| | | import rrOperation from '@crud/RR.operation' |
| | | import crudOperation from '@crud/CRUD.operation' |
| | | import udOperation from '@crud/UD.operation' |
| | | import pagination from '@crud/Pagination' |
| | | import constant from '../../../utils/constant' |
| | | import crudProject from '@/api/project/project' |
| | | |
| | | const defaultForm = { id: null, projectId: null, pid: null, name: null, priority: null, taskClassification: null, description: null, planStartTime: null, planEndTime: null, planHours: null, planWorkload: null, planWorkloadUnit: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null } |
| | | export default { |
| | | name: 'Task', |
| | | components: { pagination, crudOperation, rrOperation, udOperation }, |
| | | mixins: [presenter(), header(), form(defaultForm), crud()], |
| | | dicts: [constant.PRIORITY, constant.TAST_CLASSIFICATION, constant.STANDARD_WORKLOAD_UNIT], |
| | | cruds() { |
| | | return CRUD({ title: '任务', url: 'api/task', idField: 'id', sort: 'id,desc', crudMethod: { ...crudTask }}) |
| | | }, |
| | | data() { |
| | | // 指针重指向 |
| | | const _this = this |
| | | // 时长(千内)验证 |
| | | var durationValidate = (rule, value, callback) => { |
| | | const reg = /^([0-9]|[1-9]\d{1,2})(\.\d{1,2})?$|1000$/ |
| | | if (value != null && value !== '' && !reg.test(value)) { |
| | | callback(new Error('请输入 一千 以内的正整数或两位小数')) |
| | | } else { |
| | | callback() |
| | | } |
| | | } |
| | | return { |
| | | permission: { |
| | | add: ['admin', 'task:add'], |
| | | edit: ['admin', 'task:edit'], |
| | | del: ['admin', 'task:del'], |
| | | download: ['admin', 'task:download'] |
| | | }, |
| | | rules: { |
| | | projectId: [ |
| | | { required: true, message: '所属项目不能为空', trigger: 'change' } |
| | | ], |
| | | name: [ |
| | | { required: true, message: '名称不能为空', trigger: 'blur' }, |
| | | { max: 100, message: '最大长度 100 个字符', trigger: 'blur' } |
| | | ], |
| | | priority: [ |
| | | { required: true, message: '优先度不能为空', trigger: 'change' } |
| | | ], |
| | | taskClassification: [ |
| | | { required: true, message: '任务分类不能为空', trigger: 'change' } |
| | | ], |
| | | planHours: [ |
| | | { required: true, message: '计划工时不能为空', trigger: 'blur' }, |
| | | { validator: durationValidate, trigger: 'blur' } |
| | | ], |
| | | planWorkload: [ |
| | | { validator: durationValidate, trigger: 'blur' } |
| | | ] |
| | | }, |
| | | queryTypeOptions: [ |
| | | { key: 'projectId', display_name: '所属项目' }, |
| | | { key: 'name', display_name: '名称' }, |
| | | { key: 'priority', display_name: '优先度' }, |
| | | { key: 'taskClassification', display_name: '任务分类' } |
| | | ], |
| | | // 计划开始时间选项 |
| | | planStartTimePickerOptions: { |
| | | // 禁用日期 |
| | | disabledDate(time) { |
| | | return _this.form.planEndTime != null && _this.form.planEndTime !== '' ? time.getTime() > _this.form.planEndTime.getTime() : false |
| | | } |
| | | }, |
| | | // 计划结束时间选项 |
| | | planEndTimePickerOptions: { |
| | | // 禁用日期 |
| | | disabledDate(time) { |
| | | return _this.form.planStartTime != null && _this.form.planStartTime !== '' ? time.getTime() < _this.form.planStartTime.getTime() - (86400000 - 1) : false |
| | | } |
| | | }, |
| | | // 字典:优先度 |
| | | priority: constant.PRIORITY, |
| | | // 字典:任务分类 |
| | | taskClassification: constant.TAST_CLASSIFICATION, |
| | | // 字典:标准工作量单位 |
| | | standardWorkloadUnit: constant.STANDARD_WORKLOAD_UNIT, |
| | | // 项目列表 |
| | | projects: [], |
| | | // 父级任务列表 |
| | | pidTasks: [] |
| | | } |
| | | }, |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | // 获取项目 |
| | | this.getProject() |
| | | return true |
| | | }, |
| | | // 获取项目 |
| | | getProject() { |
| | | // 获取项目 |
| | | crudProject.getAll({ approveStatus: constant.APPROVE_STATUS_ACKNOWLEDGED }).then(res => { |
| | | // 项目列表 |
| | | this.projects = res |
| | | }) |
| | | }, |
| | | // 钩子:新建 - 之前 |
| | | [CRUD.HOOK.beforeToAdd]() { |
| | | // 父级任务列表 |
| | | this.pidTasks = [] |
| | | }, |
| | | // 钩子:编辑 - 之前 |
| | | [CRUD.HOOK.beforeToEdit]() { |
| | | // 获取父级任务 |
| | | crudTask.getAll({ projectId: this.form.projectId }).then(res => { |
| | | // 父级任务列表 |
| | | this.pidTasks = res |
| | | }) |
| | | }, |
| | | // 项目变更 |
| | | projectChange() { |
| | | // 表单赋值 |
| | | this.form.pid = null |
| | | // 父级任务列表 |
| | | this.pidTasks = [] |
| | | // 获取父级任务 |
| | | crudTask.getAll({ projectId: this.form.projectId }).then(res => { |
| | | // 父级任务列表 |
| | | this.pidTasks = res |
| | | }) |
| | | }, |
| | | // 树形表数据加载 |
| | | load(tree, treeNode, resolve) { |
| | | // 获取子级任务 |
| | | crudTask.getChildren({ id: tree.id }).then(res => { |
| | | // 添加 |
| | | resolve(res) |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | </style> |