فهرست منبع

feat: task's related contract

Blizzard 1 سال پیش
والد
کامیت
a12a4338f4

+ 3 - 0
blade-service-api/wt-okr-api/src/main/java/com/wtkj/entity/AuthUserInfo.java

@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import org.springblade.core.secure.BladeUser;
+import org.springblade.system.user.entity.User;
 
 /**
  * @author Blizzard
@@ -23,5 +24,7 @@ public class AuthUserInfo extends BladeUser {
 
 	private String deptName;
 
+	private User user;
+
 
 }

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

@@ -91,4 +91,10 @@ public class Task extends BaseEntity {
 	@ApiModelProperty(value = "执行人")
 	@TableField("execute_user")
 	private String executeUser;
+
+	@TableField("year")
+	private Integer year;
+
+	@TableField("month")
+	private Integer month;
 }

+ 45 - 0
blade-service-api/wt-okr-api/src/main/java/com/wtkj/entity/TaskContract.java

@@ -0,0 +1,45 @@
+package com.wtkj.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+
+import javax.validation.constraints.NotNull;
+import java.math.BigDecimal;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-18 09:20
+ * @describe 任务相关合同
+ */
+@EqualsAndHashCode(callSuper = true)
+@TableName("blade_task_contract")
+@Data
+public class TaskContract extends BaseEntity {
+
+	@TableField("task_id")
+	@NotNull(message = "taskId can't be null")
+	private Long taskId;
+
+	@TableField("org_dept_id")
+	@ApiModelProperty(value = "任务执行机构的顶级id,即乙方")
+	@NotNull(message = "orgDeptId can't be null")
+	private Long orgDeptId;
+
+	@TableField("blade_file_id")
+	@ApiModelProperty(value = "文件上传完返回的主键id")
+	@NotNull(message = "bladeFileId can't be null")
+	private Long bladeFileId;
+
+	@TableField("amount")
+	@ApiModelProperty(value = "合同金额")
+	private BigDecimal amount;
+
+	@TableField("unpaid_amount")
+	@ApiModelProperty(value = "未付金额")
+	private BigDecimal unpaidAmount;
+
+}

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

@@ -31,6 +31,6 @@ public class TaskFile extends BaseEntity {
 	private Long bladeFileId;
 
 	@TableField("is_checked")
-	@ApiModelProperty("项目经理是否确认")
+	@ApiModelProperty("是否确认")
 	private Integer isChecked;
 }

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

@@ -0,0 +1,18 @@
+package com.wtkj.vo;
+
+import com.wtkj.entity.TaskContract;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-18 10:33
+ * @describe
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class TaskContractVO extends TaskContract {
+
+	private String partyB;
+
+}

+ 62 - 9
blade-service/wt-okr/src/main/java/com/wtkj/controller/TaskController.java

@@ -4,14 +4,17 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import com.wtkj.entity.Task;
+import com.wtkj.entity.TaskContract;
 import com.wtkj.entity.TaskFile;
 import com.wtkj.entity.TaskLog;
+import com.wtkj.service.ITaskContractService;
 import com.wtkj.service.ITaskFileService;
 import com.wtkj.service.ITaskLogService;
 import com.wtkj.service.ITaskService;
 import com.wtkj.vo.TaskFileVO;
 import com.wtkj.vo.TaskLogVO;
 import com.wtkj.vo.TaskVO;
+import com.wtkj.wrapper.TaskContractWrapper;
 import com.wtkj.wrapper.TaskFileWrapper;
 import com.wtkj.wrapper.TaskLogWrapper;
 import com.wtkj.wrapper.TaskWrapper;
@@ -21,6 +24,7 @@ import lombok.AllArgsConstructor;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
 import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
@@ -43,9 +47,29 @@ public class TaskController {
 
 	private final ITaskFileService taskFileService;
 
+	private final ITaskContractService taskContractService;
+
+
+	@GetMapping("/my-task-page")
+	@ApiOperationSupport(order = 1)
+	@ApiOperation(value = "我的任务列表", notes = "type:1:全部 2:我创建的 3:我执行的")
+	public R<IPage<TaskVO>> myTaskPage(@RequestParam(defaultValue = "1") Integer type, @RequestParam(defaultValue = "0") Integer isGroup,
+									   Integer year, Integer month, Query query) {
+		IPage<Task> page = taskService.myTaskPage(type, isGroup, year, month, Condition.getPage(query));
+		return R.data(TaskWrapper.build().pageVO(page));
+	}
+
+	@GetMapping("/my-task-statistics")
+	@ApiOperationSupport(order = 1)
+	@ApiOperation(value = "我的任务统计", notes = "")
+	public R myTask() {
+		//todo 我的任务统计
+		return R.data(null);
+	}
+
 	@PostMapping("/submit")
 	@ApiOperation(value = "创建、修改任务", notes = "")
-	@ApiOperationSupport(order = 1)
+	@ApiOperationSupport(order = 3)
 	public R<Boolean> submitTask(@RequestBody @Valid Task task) {
 		return R.status(taskService.submit(task));
 	}
@@ -54,7 +78,7 @@ public class TaskController {
 	 * 项目任务列表
 	 */
 	@GetMapping("/project-task-page")
-	@ApiOperationSupport(order = 2)
+	@ApiOperationSupport(order = 4)
 	@ApiOperation(value = "项目任务列表", notes = "传入projectId,分页参数")
 	public R<IPage<TaskVO>> projectTask(@RequestParam Long projectId, Query query) {
 		IPage<Task> page = taskService.projectTaskPage(projectId, Condition.getPage(query));
@@ -65,7 +89,7 @@ public class TaskController {
 	 * 任务详情
 	 */
 	@GetMapping("/detail")
-	@ApiOperationSupport(order = 3)
+	@ApiOperationSupport(order = 5)
 	@ApiOperation(value = "任务详情", notes = "传入任务主键id")
 	public R<TaskVO> detail(@RequestParam Long id) {
 		Task detail = taskService.getById(id);
@@ -76,7 +100,7 @@ public class TaskController {
 	 * 任务成果文件
 	 */
 	@GetMapping("/result-file")
-	@ApiOperationSupport(order = 3)
+	@ApiOperationSupport(order = 6)
 	@ApiOperation(value = "任务成果文件", notes = "传入任务主键id")
 	public R<List<TaskFileVO>> files(@RequestParam Long id) {
 		List<TaskFile> files = taskFileService.fileList(id);
@@ -87,7 +111,7 @@ public class TaskController {
 	 * 上传成果文件
 	 */
 	@GetMapping("/upload-file")
-	@ApiOperationSupport(order = 4)
+	@ApiOperationSupport(order = 7)
 	@ApiOperation(value = "上传成果文件", notes = "传入任务主键id,文件ids")
 	public R saveFile(@RequestParam Long taskId, @RequestParam String ids) {
 		return R.status(taskService.uploadFile(taskId, ids));
@@ -97,7 +121,7 @@ public class TaskController {
 	 * 删除附件
 	 */
 	@GetMapping("/delete-file")
-	@ApiOperationSupport(order = 5)
+	@ApiOperationSupport(order = 8)
 	@ApiOperation(value = "删除附件", notes = "传入主键ids")
 	public R deleteFile(@RequestParam String ids) {
 		return R.status(taskService.deleteFile(ids));
@@ -107,7 +131,7 @@ public class TaskController {
 	 * 移动文件
 	 */
 	@GetMapping("/move-file")
-	@ApiOperationSupport(order = 6)
+	@ApiOperationSupport(order = 9)
 	@ApiOperation(value = "移动文件", notes = "")
 	public R moveFile(@RequestParam Long stageId, @RequestParam Long folderId, @RequestParam String fileIds) {
 		return R.status(taskService.moveFile(stageId, folderId, fileIds));
@@ -117,7 +141,7 @@ public class TaskController {
 	 * 任务相关动态
 	 */
 	@GetMapping("/task-log")
-	@ApiOperationSupport(order = 8)
+	@ApiOperationSupport(order = 10)
 	@ApiOperation(value = "任务相关动态", notes = "传入任务主键id")
 	public R<IPage<TaskLogVO>> taskLog(Long id, Query query) {
 		LambdaQueryWrapper<TaskLog> lqw = new LambdaQueryWrapper<>();
@@ -128,8 +152,37 @@ public class TaskController {
 	}
 
 	/**
-	 *
+	 * 添加任务相关合同
+	 */
+	@PostMapping("/submit-task-contract")
+	@ApiOperationSupport(order = 11)
+	@ApiOperation(value = "新增或者修改任务合同", notes = "")
+	public R<Boolean> savaContracts(@RequestBody @Valid TaskContract contract) {
+		return R.status(taskContractService.saveOrUpdate(contract));
+
+	}
+
+	/**
+	 * 删除任务合同
+	 */
+	@GetMapping("/delete-task-contract")
+	@ApiOperationSupport(order = 12)
+	@ApiOperation(value = "删除任务合同", notes = "传入主键ids")
+	public R<Boolean> deleteContracts(@RequestParam String ids) {
+		return R.status(taskContractService.removeByIds(Func.toLongList(ids)));
+	}
+
+	/**
+	 * 任务合同分页
 	 */
+	@GetMapping("/task-contract-page")
+	@ApiOperationSupport(order = 13)
+	@ApiOperation(value = "任务合同分页", notes = "传入主键taskId,分页参数")
+	public R contractPage(@RequestParam Long taskId, Query query) {
+		IPage<TaskContract> page = taskContractService.pageByTaskId(taskId, Condition.getPage(query));
+		return R.data(TaskContractWrapper.build().pageVO(page));
+	}
+
 
 
 }

+ 16 - 0
blade-service/wt-okr/src/main/java/com/wtkj/mapper/TaskContractMapper.java

@@ -0,0 +1,16 @@
+package com.wtkj.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.wtkj.entity.TaskContract;
+
+import java.util.List;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-18 09:50
+ * @describe
+ */
+public interface TaskContractMapper extends BaseMapper<TaskContract> {
+	List<TaskContract> selectByTaskId(Long taskId, IPage<TaskContract> page);
+}

+ 8 - 0
blade-service/wt-okr/src/main/java/com/wtkj/mapper/TaskContractMapper.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.wtkj.mapper.TaskContractMapper">
+
+    <select id="selectByTaskId" resultType="com.wtkj.entity.TaskContract">
+        select * from blade_task_contract where is_deleted = 0 and task_id = #{param1} order by create_time desc;
+    </select>
+</mapper>

+ 14 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/ITaskContractService.java

@@ -0,0 +1,14 @@
+package com.wtkj.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.wtkj.entity.TaskContract;
+import org.springblade.core.mp.base.BaseService;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-18 09:52
+ * @describe
+ */
+public interface ITaskContractService extends BaseService<TaskContract> {
+	IPage<TaskContract> pageByTaskId(Long taskId, IPage<TaskContract> page);
+}

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

@@ -19,4 +19,6 @@ public interface ITaskService extends BaseService<Task> {
 	boolean moveFile(Long stageId, Long folderId, String fileIds);
 
 	boolean deleteFile(String ids);
+
+	IPage<Task> myTaskPage(Integer type, Integer isGroup, Integer year, Integer month, IPage<Task> page);
 }

+ 3 - 5
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/AsyncServiceImpl.java

@@ -35,7 +35,6 @@ public class AsyncServiceImpl implements IAsyncService {
 	private final ISysClient sysClient;
 	private final IUserClient userClient;
 	private final ITaskLogService taskLogService;
-	private final IProjectService projectService;
 	private final IIndexMessageService indexMessageService;
 
 	@Override
@@ -273,13 +272,12 @@ public class AsyncServiceImpl implements IAsyncService {
 		Long projectId = task.getProjectId();
 		String title = task.getTitle();
 		R<User> userR = userClient.userInfoById(userId);
-		Project project = projectService.getById(projectId);
-		if (userR.isSuccess() && project != null) {
+		if (userR.isSuccess()) {
 			IndexMessage message = new IndexMessage();
 			message.setCategory(1);
-			//发送给任务创建者
+			//发送给审查人和项目经理
 			message.setToUser(createUser);
-			message.setContent(userR.getData().getName() + "上传了" + project.getName() + title + "任务的文件,请查阅");
+			message.setContent(userR.getData().getName() + "上传了" + title + "任务的文件,请查阅");
 			message.setOpenUrl("/task");
 			message.setCreateDept(task.getCreateDept());
 			message.setCreateUser(userId);

+ 8 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/DeptToDeptServiceImpl.java

@@ -14,6 +14,8 @@ import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.StringUtil;
 import org.springblade.system.entity.Dept;
 import org.springblade.system.feign.ISysClient;
+import org.springblade.system.user.entity.User;
+import org.springblade.system.user.feign.IUserClient;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
@@ -33,6 +35,7 @@ import static com.wtkj.config.MagicValue.ZERO;
 public class DeptToDeptServiceImpl extends BaseServiceImpl<DeptToDeptMapper, DeptToDept> implements IDeptToDeptService {
 
 	private final ISysClient sysClient;
+	private final IUserClient userClient;
 
 	@Override
 	public AuthUserInfo userInfo() {
@@ -59,6 +62,11 @@ public class DeptToDeptServiceImpl extends BaseServiceImpl<DeptToDeptMapper, Dep
 					}
 				}
 			}
+			Long userId = user.getUserId();
+			R<User> userR = userClient.userInfoById(userId);
+			if (userR.isSuccess()) {
+				userInfo.setUser(userR.getData());
+			}
 			return userInfo;
 		}
 		return null;

+ 24 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/ITaskContractServiceImpl.java

@@ -0,0 +1,24 @@
+package com.wtkj.service.impl;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.wtkj.entity.TaskContract;
+import com.wtkj.mapper.TaskContractMapper;
+import com.wtkj.service.ITaskContractService;
+import lombok.AllArgsConstructor;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-18 09:53
+ * @describe
+ */
+@Service
+@AllArgsConstructor
+public class ITaskContractServiceImpl extends BaseServiceImpl<TaskContractMapper, TaskContract> implements ITaskContractService {
+
+	@Override
+	public IPage<TaskContract> pageByTaskId(Long taskId, IPage<TaskContract> page) {
+		return page.setRecords(baseMapper.selectByTaskId(taskId, page));
+	}
+}

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

@@ -20,6 +20,7 @@ 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.List;
 
@@ -136,4 +137,36 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
 	public boolean deleteFile(String ids) {
 		return taskFileService.removeBatchByIds(Func.toLongList(ids));
 	}
+
+	@Override
+	public IPage<Task> myTaskPage(Integer type, Integer isGroup, Integer year, Integer month, IPage<Task> page) {
+
+		Long userId = AuthUtil.getUserId();
+		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);
+
+		//1.全部 2.我创建的 3.我执行的
+		if (type == 1) {
+			lqw.and(wq -> {
+				wq.eq(Task::getCreateUser, userId);
+				wq.or().like(Task::getExecuteUser, String.valueOf(userId));
+			});
+		} else if (type == 2) {
+			lqw.eq(Task::getCreateUser, userId);
+		} else {
+			lqw.like(Task::getExecuteUser, String.valueOf(userId));
+		}
+		if (isGroup == 1) {
+			lqw.groupBy(Task::getProjectId, Task::getCreateTime);
+			lqw.orderByDesc(Task::getProjectId, Task::getCreateTime);
+		} else {
+			lqw.orderByDesc(Task::getCreateTime);
+		}
+		return baseMapper.selectPage(page, lqw);
+	}
 }

+ 38 - 0
blade-service/wt-okr/src/main/java/com/wtkj/wrapper/TaskContractWrapper.java

@@ -0,0 +1,38 @@
+package com.wtkj.wrapper;
+
+import com.wtkj.entity.TaskContract;
+import com.wtkj.vo.TaskContractVO;
+import org.springblade.core.mp.support.BaseEntityWrapper;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.core.tool.utils.SpringUtil;
+import org.springblade.system.entity.Dept;
+import org.springblade.system.feign.ISysClient;
+
+import java.util.Objects;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-18 10:36
+ * @describe
+ */
+public class TaskContractWrapper extends BaseEntityWrapper<TaskContract, TaskContractVO> {
+
+	private static ISysClient sysClient;
+
+	public static TaskContractWrapper build() {
+		sysClient = SpringUtil.getBean(ISysClient.class);
+		return new TaskContractWrapper();
+	}
+
+	@Override
+	public TaskContractVO entityVO(TaskContract entity) {
+		TaskContractVO vo = Objects.requireNonNull(BeanUtil.copy(entity, TaskContractVO.class));
+		Long deptId = entity.getOrgDeptId();
+		R<Dept> rpc = sysClient.getDept(deptId);
+		if (rpc.isSuccess()) {
+			vo.setPartyB(rpc.getData().getDeptName());
+		}
+		return vo;
+	}
+}