Blizzard 1 жил өмнө
parent
commit
8411bbeeba

+ 11 - 1
blade-service-api/wt-okr-api/src/main/java/com/wtkj/entity/Task.java

@@ -39,7 +39,7 @@ public class Task extends BaseEntity {
 	private Long orgDeptId;
 
 	@TableField("task_status")
-	@ApiModelProperty("任务状态:最大数值代表完成 默认为1进行中")
+	@ApiModelProperty("任务状态:1.待确认 2.进行中 3.已提交 4.已完成 5.已取消")
 	private Integer taskStatus = 1;
 
 	@TableField("level")
@@ -66,12 +66,21 @@ public class Task extends BaseEntity {
 	@JsonFormat(pattern = "yyyy-MM-dd")
 	private Date endTime;
 
+	@TableField("is_confirmed")
+	@ApiModelProperty("是否已经确认完成")
+	private Integer isConfirmed;
+
 	@TableField("confirm_time")
 	@ApiModelProperty("任务完成确认时间")
 	@DateTimeFormat(pattern = "yyyy-MM-dd")
 	@JsonFormat(pattern = "yyyy-MM-dd")
 	private Date confirmTime;
 
+	@JsonSerialize(using = ToStringSerializer.class)
+	@ApiModelProperty(value = "确认任务完成的用户")
+	@TableField("confirm_user")
+	private Long confirmUser;
+
 	@TableField("remark")
 	@ApiModelProperty("备注")
 	private String remark;
@@ -105,4 +114,5 @@ public class Task extends BaseEntity {
 
 	@TableField("month")
 	private Integer month;
+
 }

+ 0 - 13
blade-service-api/wt-okr-api/src/main/java/com/wtkj/vo/MyTask.java

@@ -1,13 +0,0 @@
-package com.wtkj.vo;
-
-import java.io.Serializable;
-
-/**
- * @author Blizzard
- * @create at 2023-09-18 15:52
- * @describe
- */
-public class MyTask implements Serializable {
-	private static final long serialVersionUID = 1L;
-
-}

+ 31 - 0
blade-service-api/wt-okr-api/src/main/java/com/wtkj/vo/MyTaskStatistics.java

@@ -0,0 +1,31 @@
+package com.wtkj.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-18 15:52
+ * @describe
+ */
+@Data
+public class MyTaskStatistics implements Serializable {
+	private static final long serialVersionUID = 1L;
+
+	private Integer all = 0;
+
+	private Integer completed = 0;
+
+	private Integer notCompleted = 0;
+
+	private Integer overdue = 0;
+
+	private Integer toConfirmed = 0;
+
+	private Integer todayToExpire = 0;
+
+	private Integer overdueComplete = 0;
+
+
+}

+ 36 - 18
blade-service/wt-okr/src/main/java/com/wtkj/controller/TaskController.java

@@ -41,6 +41,9 @@ public class TaskController {
 
 	private final ITaskCostService taskCostService;
 
+	/**
+	 * 我的任务分页
+	 */
 
 	@GetMapping("/my-task-page")
 	@ApiOperationSupport(order = 1)
@@ -51,14 +54,19 @@ public class TaskController {
 		return R.data(TaskWrapper.build().pageVO(page));
 	}
 
+	/**
+	 * 我的任务统计
+	 */
 	@GetMapping("/my-task-statistics")
-	@ApiOperationSupport(order = 1)
+	@ApiOperationSupport(order = 2)
 	@ApiOperation(value = "我的任务统计", notes = "")
-	public R myTask() {
-		//todo 我的任务统计
-		return R.data(null);
+	public R myTask(@RequestParam Integer year, @RequestParam Integer month) {
+		return R.data(taskService.myTaskStatistics(year, month));
 	}
 
+	/**
+	 * 创建、修改任务
+	 */
 	@PostMapping("/submit")
 	@ApiOperation(value = "创建、修改任务", notes = "")
 	@ApiOperationSupport(order = 3)
@@ -77,11 +85,21 @@ public class TaskController {
 		return R.data(TaskWrapper.build().pageVO(page));
 	}
 
+	/**
+	 * 删除任务
+	 */
+	@GetMapping("/delete-project-task")
+	@ApiOperationSupport(order = 5)
+	@ApiOperation(value = "删除项目任务", notes = "传入ids")
+	public R<Boolean> deleteTask(String ids) {
+		return R.status(taskService.removeByIds(Func.toLongList(ids)));
+	}
+
 	/**
 	 * 任务详情
 	 */
 	@GetMapping("/detail")
-	@ApiOperationSupport(order = 5)
+	@ApiOperationSupport(order = 6)
 	@ApiOperation(value = "任务详情", notes = "传入任务主键id")
 	public R<TaskVO> detail(@RequestParam Long id) {
 		Task detail = taskService.getById(id);
@@ -92,7 +110,7 @@ public class TaskController {
 	 * 任务成果文件
 	 */
 	@GetMapping("/result-file")
-	@ApiOperationSupport(order = 6)
+	@ApiOperationSupport(order = 7)
 	@ApiOperation(value = "任务成果文件", notes = "传入任务主键id")
 	public R<List<TaskFileVO>> files(@RequestParam Long id) {
 		List<TaskFile> files = taskFileService.fileList(id);
@@ -103,7 +121,7 @@ public class TaskController {
 	 * 上传成果文件
 	 */
 	@GetMapping("/upload-file")
-	@ApiOperationSupport(order = 7)
+	@ApiOperationSupport(order = 8)
 	@ApiOperation(value = "上传成果文件", notes = "传入任务主键id,文件ids")
 	public R saveFile(@RequestParam Long taskId, @RequestParam String ids) {
 		return R.status(taskService.uploadFile(taskId, ids));
@@ -113,7 +131,7 @@ public class TaskController {
 	 * 删除附件
 	 */
 	@GetMapping("/delete-file")
-	@ApiOperationSupport(order = 8)
+	@ApiOperationSupport(order = 9)
 	@ApiOperation(value = "删除附件", notes = "传入主键ids")
 	public R deleteFile(@RequestParam String ids) {
 		return R.status(taskService.deleteFile(ids));
@@ -123,7 +141,7 @@ public class TaskController {
 	 * 移动文件
 	 */
 	@GetMapping("/move-file")
-	@ApiOperationSupport(order = 9)
+	@ApiOperationSupport(order = 10)
 	@ApiOperation(value = "移动文件", notes = "")
 	public R moveFile(@RequestParam Long stageId, @RequestParam Long folderId, @RequestParam String fileIds) {
 		return R.status(taskService.moveFile(stageId, folderId, fileIds));
@@ -133,7 +151,7 @@ public class TaskController {
 	 * 任务相关动态
 	 */
 	@GetMapping("/task-log")
-	@ApiOperationSupport(order = 10)
+	@ApiOperationSupport(order = 11)
 	@ApiOperation(value = "任务相关动态", notes = "传入任务主键id")
 	public R<IPage<TaskLogVO>> taskLog(Long id, Query query) {
 		LambdaQueryWrapper<TaskLog> lqw = new LambdaQueryWrapper<>();
@@ -147,7 +165,7 @@ public class TaskController {
 	 * 添加任务相关合同
 	 */
 	@PostMapping("/submit-task-contract")
-	@ApiOperationSupport(order = 11)
+	@ApiOperationSupport(order = 12)
 	@ApiOperation(value = "新增或者修改任务合同", notes = "")
 	public R<Boolean> submitContracts(@RequestBody @Valid TaskContract contract) {
 		return R.status(taskContractService.saveOrUpdate(contract));
@@ -158,7 +176,7 @@ public class TaskController {
 	 * 删除任务合同
 	 */
 	@GetMapping("/delete-task-contract")
-	@ApiOperationSupport(order = 12)
+	@ApiOperationSupport(order = 13)
 	@ApiOperation(value = "删除任务合同", notes = "传入主键ids")
 	public R<Boolean> deleteContracts(@RequestParam String ids) {
 		return R.status(taskContractService.removeByIds(Func.toLongList(ids)));
@@ -168,7 +186,7 @@ public class TaskController {
 	 * 任务合同分页
 	 */
 	@GetMapping("/task-contract-page")
-	@ApiOperationSupport(order = 13)
+	@ApiOperationSupport(order = 14)
 	@ApiOperation(value = "任务合同分页", notes = "传入主键taskId,分页参数")
 	public R<IPage<TaskContractVO>> contractPage(@RequestParam Long taskId, Query query) {
 		IPage<TaskContract> page = taskContractService.pageByTaskId(taskId, Condition.getPage(query));
@@ -180,7 +198,7 @@ public class TaskController {
 	 * 任务成本核算
 	 */
 	@PostMapping("/submit-task-cost")
-	@ApiOperationSupport(order = 14)
+	@ApiOperationSupport(order = 15)
 	@ApiOperation(value = "新增或修改任务成本", notes = "")
 	public R<Boolean> submitCost(@RequestBody TaskCost cost) {
 		return R.data(taskCostService.saveOrUpdate(cost));
@@ -190,7 +208,7 @@ public class TaskController {
 	 * 任务成本详情
 	 */
 	@GetMapping("/task-cost-detail")
-	@ApiOperationSupport(order = 15)
+	@ApiOperationSupport(order = 16)
 	@ApiOperation(value = "成本详情", notes = "")
 	public R<TaskCostVO> costDetail(@RequestParam Long id) {
 		TaskCost detail = taskCostService.getById(id);
@@ -201,7 +219,7 @@ public class TaskController {
 	 * 删除成本记录
 	 */
 	@GetMapping("/delete-task-cost")
-	@ApiOperationSupport(order = 16)
+	@ApiOperationSupport(order = 17)
 	@ApiOperation(value = "删除成本记录", notes = "传入主键ids")
 	public R<Boolean> deleteCost(@RequestParam String ids) {
 		return R.status(taskCostService.removeByIds(Func.toLongList(ids)));
@@ -211,7 +229,7 @@ public class TaskController {
 	 * 成本分页
 	 */
 	@GetMapping("/task-cost-page")
-	@ApiOperationSupport(order = 17)
+	@ApiOperationSupport(order = 18)
 	@ApiOperation(value = "成本分页", notes = "传入taskId,分页参数")
 	public R<IPage<TaskCostVO>> costPage(@RequestParam Long taskId, Query query) {
 		IPage<TaskCost> page = taskCostService.pageByTaskId(taskId, Condition.getPage(query));
@@ -222,7 +240,7 @@ public class TaskController {
 	 * 成本统计
 	 */
 	@GetMapping("/task-cost-statistics")
-	@ApiOperationSupport(order = 18)
+	@ApiOperationSupport(order = 19)
 	@ApiOperation(value = "任务成本统计", notes = "传入taskId数")
 	public R<JSONObject> costStatistics(@RequestParam Long taskId) {
 		return R.data(taskCostService.costStatistics(taskId));

+ 9 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/ITaskService.java

@@ -2,8 +2,11 @@ package com.wtkj.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.wtkj.entity.Task;
+import com.wtkj.vo.MyTaskStatistics;
 import org.springblade.core.mp.base.BaseService;
 
+import java.util.List;
+
 /**
  * @author Blizzard
  * @create at 2023-09-15 15:18
@@ -21,4 +24,10 @@ public interface ITaskService extends BaseService<Task> {
 	boolean deleteFile(String ids);
 
 	IPage<Task> myTaskPage(Integer type, Integer isGroup, Integer year, Integer month, IPage<Task> page);
+
+	MyTaskStatistics myTaskStatistics(Integer year, Integer month);
+
+	List<Task> listByUser(Long userId, Integer year, Integer month);
+
+	boolean deleteTask(List<Long> taskIds);
 }

+ 75 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/TaskServiceImpl.java

@@ -10,18 +10,21 @@ import com.wtkj.service.IAsyncService;
 import com.wtkj.service.IFileAndFolderService;
 import com.wtkj.service.ITaskFileService;
 import com.wtkj.service.ITaskService;
+import com.wtkj.vo.MyTaskStatistics;
 import com.wutong.file.feign.IFileClient;
 import com.wutong.file.vo.FileVO;
 import lombok.AllArgsConstructor;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.DateUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
 import java.time.LocalDate;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -169,4 +172,76 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
 		}
 		return baseMapper.selectPage(page, lqw);
 	}
+
+	@Override
+	public MyTaskStatistics myTaskStatistics(Integer year, Integer month) {
+		MyTaskStatistics statistics = new MyTaskStatistics();
+		Long userId = AuthUtil.getUserId();
+		List<Task> tasks = this.listByUser(userId, year, month);
+		if (!CollectionUtils.isEmpty(tasks)) {
+			//全部任务数
+			statistics.setAll(tasks.size());
+			tasks.forEach(task -> {
+				//任务确认状态
+				Integer isConfirmed = task.getIsConfirmed();
+				//任务状态 1.待确认 2.进行中 3.已提交 4.已完成 5.已取消
+				Integer taskStatus = task.getTaskStatus();
+				if (isConfirmed.equals(1)) {
+					//已完成
+					statistics.setCompleted(statistics.getCompleted() + 1);
+				}
+				Date now = DateUtil.now();
+				Date endTime = task.getEndTime();
+				if (endTime != null) {
+					//过了截至时间且未确认的任务为已逾期
+					if (endTime.before(now) && isConfirmed.equals(0)) {
+						statistics.setOverdue(statistics.getOverdue() + 1);
+					}
+
+					//待确认 已经提交但未确认且未逾期的任务为待确认
+					if (endTime.after(now) && taskStatus.equals(3) && isConfirmed.equals(0)) {
+						statistics.setToConfirmed(statistics.getToConfirmed() + 1);
+					}
+
+					//今日到期
+					String endStr = DateUtil.format(endTime, "yyyy-MM-dd");
+					String nowStr = DateUtil.format(now, "yyyy-MM-dd");
+					if (endStr.equals(nowStr)) {
+						statistics.setTodayToExpire(statistics.getTodayToExpire() + 1);
+					}
+
+					//逾期完成
+					if (endTime.before(now) && isConfirmed.equals(1)) {
+						statistics.setOverdueComplete(statistics.getOverdueComplete() + 1);
+					}
+				}
+			});
+			//未完成
+			statistics.setNotCompleted(statistics.getAll() - statistics.getCompleted());
+		}
+		return statistics;
+	}
+
+	@Override
+	public List<Task> listByUser(Long userId, Integer year, Integer month) {
+		LambdaQueryWrapper<Task> lqw = new LambdaQueryWrapper<>();
+		//当前年 当前月
+		LocalDate currentDate = LocalDate.now();
+		int currentYear = currentDate.getYear();
+		int currentMonth = currentDate.getMonthValue();
+		lqw.eq(Task::getYear, year == null ? currentYear : year);
+		lqw.eq(Task::getMonth, month == null ? currentMonth : month);
+		lqw.and(wq -> {
+			wq.eq(Task::getCreateUser, userId);
+			wq.or().like(Task::getExecuteUser, String.valueOf(userId));
+		});
+		lqw.orderByDesc(Task::getCreateTime);
+		return this.list(lqw);
+	}
+
+	//todo 删除任务是否需要事务删除任务相关?
+	@Override
+	public boolean deleteTask(List<Long> taskIds) {
+		return false;
+	}
 }