فهرست منبع

feat: project statistics

Blizzard 1 سال پیش
والد
کامیت
c4eb240de3
21فایلهای تغییر یافته به همراه323 افزوده شده و 18 حذف شده
  1. 3 0
      blade-service-api/wt-okr-api/src/main/java/com/wtkj/dto/ProjectPageDTO.java
  2. 7 0
      blade-service-api/wt-okr-api/src/main/java/com/wtkj/dto/ProjectTaskPageDTO.java
  3. 5 0
      blade-service-api/wt-okr-api/src/main/java/com/wtkj/entity/Project.java
  4. 6 0
      blade-service-api/wt-okr-api/src/main/java/com/wtkj/entity/ProjectStage.java
  5. 4 0
      blade-service-api/wt-okr-api/src/main/java/com/wtkj/entity/TaskContract.java
  6. 7 0
      blade-service-api/wt-okr-api/src/main/java/com/wtkj/entity/TaskCost.java
  7. 27 0
      blade-service-api/wt-okr-api/src/main/java/com/wtkj/vo/ProjectStatisticsVO.java
  8. 4 0
      blade-service-api/wt-okr-api/src/main/java/com/wtkj/vo/ProjectVO.java
  9. 5 0
      blade-service/wt-okr/src/main/java/com/wtkj/config/MagicValue.java
  10. 19 2
      blade-service/wt-okr/src/main/java/com/wtkj/controller/ProjectController.java
  11. 5 0
      blade-service/wt-okr/src/main/java/com/wtkj/mapper/TaskContractMapper.java
  12. 11 0
      blade-service/wt-okr/src/main/java/com/wtkj/mapper/TaskContractMapper.xml
  13. 2 0
      blade-service/wt-okr/src/main/java/com/wtkj/mapper/TaskMapper.java
  14. 12 2
      blade-service/wt-okr/src/main/java/com/wtkj/mapper/TaskMapper.xml
  15. 3 0
      blade-service/wt-okr/src/main/java/com/wtkj/service/IProjectService.java
  16. 8 0
      blade-service/wt-okr/src/main/java/com/wtkj/service/ITaskContractService.java
  17. 3 0
      blade-service/wt-okr/src/main/java/com/wtkj/service/ITaskService.java
  18. 13 0
      blade-service/wt-okr/src/main/java/com/wtkj/service/impl/ITaskContractServiceImpl.java
  19. 146 14
      blade-service/wt-okr/src/main/java/com/wtkj/service/impl/ProjectServiceImpl.java
  20. 9 0
      blade-service/wt-okr/src/main/java/com/wtkj/service/impl/TaskServiceImpl.java
  21. 24 0
      blade-service/wt-okr/src/main/java/com/wtkj/wrapper/ProjectWrapper.java

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

@@ -47,5 +47,8 @@ public class ProjectPageDTO implements Serializable {
 	@NotNull(message = "topDept不可为空")
 	private Long topDept;
 
+	@ApiModelProperty(value = "当前登录用户的机构类型")
+	@NotNull(message = "deptCategory不可为空")
+	private Integer deptCategory;
 
 }

+ 7 - 0
blade-service-api/wt-okr-api/src/main/java/com/wtkj/dto/ProjectTaskPageDTO.java

@@ -1,5 +1,6 @@
 package com.wtkj.dto;
 
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import javax.validation.constraints.NotNull;
@@ -20,6 +21,12 @@ public class ProjectTaskPageDTO implements Serializable {
 
 	private String name;
 
+	@ApiModelProperty(value = "当前登录用户的机构类型")
+	@NotNull(message = "deptCategory can't be null")
+	private Integer deptCategory;
+
+	@ApiModelProperty(value = "当前登录用户的顶级机构id")
+	@NotNull(message = "orgDeptId can't be null")
 	private Long orgDeptId;
 
 	private Integer taskStatus;

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

@@ -86,5 +86,10 @@ public class Project extends BaseEntity {
 	@ApiModelProperty(value = "待完成任务数量")
 	private Integer todoTask;
 
+	@TableField("img_id")
+	@ApiModelProperty(value = "项目图片文件ID")
+	private Integer imgId;
+
+
 
 }

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

@@ -2,12 +2,14 @@ package com.wtkj.entity;
 
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import org.springblade.core.mp.base.BaseEntity;
+import org.springframework.format.annotation.DateTimeFormat;
 
 import javax.validation.constraints.NotNull;
 import java.util.Date;
@@ -39,9 +41,13 @@ public class ProjectStage extends BaseEntity {
 
 	@TableField("start_time")
 	@ApiModelProperty("阶段周期开始时间")
+	@DateTimeFormat(pattern = "yyyy-MM-dd")
+	@JsonFormat(pattern = "yyyy-MM-dd")
 	private Date startTime;
 
 	@TableField("end_time")
 	@ApiModelProperty("阶段周期结束时间")
+	@DateTimeFormat(pattern = "yyyy-MM-dd")
+	@JsonFormat(pattern = "yyyy-MM-dd")
 	private Date endTime;
 }

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

@@ -24,6 +24,10 @@ public class TaskContract extends BaseEntity {
 
 	private static final long serialVersionUID = 1L;
 
+	@TableField("project_id")
+	@NotNull(message = "projectId can't be null")
+	@JsonSerialize(using = ToStringSerializer.class)
+	private Long projectId;
 
 	@TableField("task_id")
 	@NotNull(message = "taskId can't be null")

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

@@ -11,6 +11,7 @@ import lombok.EqualsAndHashCode;
 import org.springblade.core.mp.base.BaseEntity;
 import org.springframework.format.annotation.DateTimeFormat;
 
+import javax.validation.constraints.NotNull;
 import java.math.BigDecimal;
 import java.util.Date;
 
@@ -27,8 +28,14 @@ public class TaskCost extends BaseEntity {
 	private static final long serialVersionUID = 1L;
 
 
+	@TableField("project_id")
+	@NotNull(message = "projectId can't be null")
+	@JsonSerialize(using = ToStringSerializer.class)
+	private Long projectId;
+
 	@TableField("task_id")
 	@JsonSerialize(using = ToStringSerializer.class)
+	@NotNull(message = "taskId can't be null")
 	private Long taskId;
 
 	@ApiModelProperty(value = "成本类型 字典值")

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

@@ -0,0 +1,27 @@
+package com.wtkj.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-21 10:47
+ * @describe
+ */
+@Data
+public class ProjectStatisticsVO implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	private Integer projectCount;
+
+	private BigDecimal totalAmount;
+
+	private BigDecimal contractAmount;
+
+	private Integer todoTask;
+
+	private Integer warns;
+}

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

@@ -16,4 +16,8 @@ public class ProjectVO extends Project {
 	private static final long serialVersionUID = 1L;
 
 	private String currentStageName;
+
+	private String imgUrl;
+
+	private String competentUnitName;
 }

+ 5 - 0
blade-service/wt-okr/src/main/java/com/wtkj/config/MagicValue.java

@@ -22,6 +22,11 @@ public interface MagicValue {
 	 */
 	String STAFF_SECOND_ADMIN = "staff_second_admin";
 
+	/**
+	 * 服务机构
+	 */
+	String STAFF_PROJECT_MANAGER = "staff_project_manager";
+
 	String STAFF_USER = "staff_user";
 
 	Integer ZERO = 0;

+ 19 - 2
blade-service/wt-okr/src/main/java/com/wtkj/controller/ProjectController.java

@@ -101,13 +101,22 @@ public class ProjectController {
 		return R.status(stageService.saveOrUpdate(stage));
 	}
 
+	/**
+	 * 项目列表统计
+	 */
+	@GetMapping("/project-statistics")
+	@ApiOperation(value = "项目统计", notes = "")
+	@ApiOperationSupport(order = 6)
+	public R projectStatistics(@RequestParam Long topDept, @RequestParam Integer deptCategory, @RequestParam String year) {
+		return R.data(projectService.projectStatistics(topDept, deptCategory, year));
+	}
 
 	/**
 	 * 工作台任务统计
 	 */
 	@GetMapping("/task-summary")
 	@ApiOperation(value = "项目任务统计", notes = "传入projectId")
-	@ApiOperationSupport(order = 6)
+	@ApiOperationSupport(order = 7)
 	public R<MyTaskStatistics> taskStatistics(@RequestParam Long projectId) {
 		return R.data(taskService.TaskStatistics(projectId, null, null));
 	}
@@ -118,11 +127,19 @@ public class ProjectController {
 	 */
 	@GetMapping("/project-group-mem")
 	@ApiOperation(value = "项目组成员", notes = "传入projectId,competentUnit:主管单位")
-	@ApiOperationSupport(order = 7)
+	@ApiOperationSupport(order = 8)
 	public R groupMem(@RequestParam Long projectId, @RequestParam Long competentUnit) {
 		List<ProjectGroup> list = projectGroupService.getGroupByProjectId(projectId, competentUnit);
 		return R.data(ProjectGroupWrapper.build().listVO(list));
 	}
 
+	@GetMapping("/project-detail")
+	@ApiOperation(value = "项目详情", notes = "")
+	@ApiOperationSupport(order = 9)
+	public R detail(@RequestParam Long projectId) {
+		Project byId = projectService.getById(projectId);
+		return R.data(ProjectWrapper.build().entityVO(byId));
+	}
+
 
 }

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

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.wtkj.entity.TaskContract;
 
 import java.util.List;
+import java.util.Set;
 
 /**
  * @author Blizzard
@@ -13,4 +14,8 @@ import java.util.List;
  */
 public interface TaskContractMapper extends BaseMapper<TaskContract> {
 	List<TaskContract> selectByTaskId(Long taskId, IPage<TaskContract> page);
+
+	List<TaskContract> getByProjectIds(Set<Long> projectIds);
+
+	List<TaskContract> getByOrgDeptId(Long topDept);
 }

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

@@ -5,4 +5,15 @@
     <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>
+
+    <select id="getByProjectIds" resultType="com.wtkj.entity.TaskContract">
+        select * from blade_task_contract where is_deleted = 0 and project_id in
+        <foreach collection="param" index="index" item="item" open="(" separator="," close=")">
+            #{item}
+        </foreach>
+    </select>
+
+    <select id="getByOrgDeptId" resultType="com.wtkj.entity.TaskContract">
+        select * from blade_task_contract where is_deleted = 0 and org_dept_id = #{param} order by create_time desc;
+    </select>
 </mapper>

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

@@ -27,4 +27,6 @@ public interface TaskMapper extends BaseMapper<Task> {
 	List<Task> getByOrgDeptId(Long topDept, String date);
 
 	List<Task> getTodayTodoByOrgDeptId(Long topDept, String date);
+
+	List<Task> getTodoByYear(Set<Long> projectIds, Integer year);
 }

+ 12 - 2
blade-service/wt-okr/src/main/java/com/wtkj/mapper/TaskMapper.xml

@@ -36,8 +36,11 @@
     </select>
 
     <select id="getByOrgDeptId" resultType="com.wtkj.entity.Task">
-        select * from blade_task where is_deleted = 0 and org_dept_id = #{param1} and
-        DATE_FORMAT(#{param2},'%Y-%m-%d') >= DATE_FORMAT(end_time,'%Y-%m-%d') and is_confirmed = 0 order by create_time
+        select * from blade_task where is_deleted = 0 and org_dept_id = #{param1}
+        <if test="param2 != null">
+            and DATE_FORMAT(#{param2},'%Y-%m-%d') >= DATE_FORMAT(end_time,'%Y-%m-%d') and is_confirmed = 0
+        </if>
+        order by create_time
     </select>
 
     <select id="getTodoAndExpireByUserId" resultType="com.wtkj.entity.Task">
@@ -50,4 +53,11 @@
         select * from blade_task where is_deleted = 0 and org_dept_id = #{param1} and
         DATE_FORMAT(#{param2},'%Y-%m-%d') = DATE_FORMAT(end_time,'%Y-%m-%d') and is_confirmed = 0 order by create_time
     </select>
+
+    <select id="getTodoByYear" resultType="com.wtkj.entity.Task">
+        select * from blade_task where is_deleted = 0 and year = #{param2} and is_confirmed = 0 and project_id in
+        <foreach collection="param1" index="index" item="item" open="(" separator="," close=")">
+            #{item}
+        </foreach>
+    </select>
 </mapper>

+ 3 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/IProjectService.java

@@ -3,6 +3,7 @@ package com.wtkj.service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.wtkj.dto.ProjectPageDTO;
 import com.wtkj.entity.Project;
+import com.wtkj.vo.ProjectStatisticsVO;
 import org.springblade.core.mp.base.BaseService;
 
 import java.util.Set;
@@ -18,4 +19,6 @@ public interface IProjectService extends BaseService<Project> {
 	IPage<Project> getPage(ProjectPageDTO dto, IPage<Project> page);
 
 	Set<Long> getByCreate(Long createDept, Long createUser);
+
+	ProjectStatisticsVO projectStatistics(Long topDept, Integer deptCategory, String year);
 }

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

@@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.wtkj.entity.TaskContract;
 import org.springblade.core.mp.base.BaseService;
 
+import java.util.List;
+import java.util.Set;
+
 /**
  * @author Blizzard
  * @create at 2023-09-18 09:52
@@ -11,4 +14,9 @@ import org.springblade.core.mp.base.BaseService;
  */
 public interface ITaskContractService extends BaseService<TaskContract> {
 	IPage<TaskContract> pageByTaskId(Long taskId, IPage<TaskContract> page);
+
+	List<TaskContract> getByProjectIds(Set<Long> projectIds);
+
+	List<TaskContract> getByOrgDeptId(Long topDept);
+
 }

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

@@ -69,4 +69,7 @@ public interface ITaskService extends BaseService<Task> {
 	 * 机构下当日待完成的任务
 	 */
 	List<Task> getTodayTodoByOrgDeptId(Long topDept, String date);
+
+	List<Task> getTodoByYear(Set<Long> projectIds, String year);
+
 }

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

@@ -8,6 +8,9 @@ import lombok.AllArgsConstructor;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+import java.util.Set;
+
 /**
  * @author Blizzard
  * @create at 2023-09-18 09:53
@@ -21,4 +24,14 @@ public class ITaskContractServiceImpl extends BaseServiceImpl<TaskContractMapper
 	public IPage<TaskContract> pageByTaskId(Long taskId, IPage<TaskContract> page) {
 		return page.setRecords(baseMapper.selectByTaskId(taskId, page));
 	}
+
+	@Override
+	public List<TaskContract> getByProjectIds(Set<Long> projectIds) {
+		return baseMapper.getByProjectIds(projectIds);
+	}
+
+	@Override
+	public List<TaskContract> getByOrgDeptId(Long topDept) {
+		return baseMapper.getByOrgDeptId(topDept);
+	}
 }

+ 146 - 14
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/ProjectServiceImpl.java

@@ -5,10 +5,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.wtkj.dto.ProjectPageDTO;
 import com.wtkj.entity.Project;
 import com.wtkj.entity.ProjectAuth;
+import com.wtkj.entity.Task;
+import com.wtkj.entity.TaskContract;
 import com.wtkj.mapper.ProjectMapper;
-import com.wtkj.service.IAsyncService;
-import com.wtkj.service.IProjectAuthService;
-import com.wtkj.service.IProjectService;
+import com.wtkj.service.*;
+import com.wtkj.vo.ProjectStatisticsVO;
 import lombok.AllArgsConstructor;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.core.secure.BladeUser;
@@ -20,7 +21,10 @@ import org.springblade.system.feign.ISysClient;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
+import java.math.BigDecimal;
+import java.time.LocalDate;
 import java.util.List;
+import java.util.Objects;
 import java.util.Set;
 import java.util.stream.Collectors;
 
@@ -38,12 +42,16 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectMapper, Project>
 	private final IAsyncService asyncService;
 	private final ISysClient sysClient;
 	private final IProjectAuthService projectAuthService;
+	private final ITaskService taskService;
+	private final ITaskContractService taskContractService;
 
 	@Override
 	public boolean submit(Project project) {
 		boolean flag = false;
 		BladeUser user = AuthUtil.getUser();
 		if (project.getId() == null) {
+			LocalDate date = LocalDate.now();
+			project.setYear(String.valueOf(date.getYear()));
 			flag = this.save(project);
 			asyncService.createProject(project, user);
 		} else {
@@ -97,20 +105,84 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectMapper, Project>
 					}
 				}
 			}
-			//待完成任务数排序
-			if (dto.getTodoAsc().equals(1)) {
-				lqw.orderByAsc(Project::getTodoTask);
-			} else {
-				lqw.orderByDesc(Project::getTodoTask);
-			}
-			//截止时间排序
-			if (dto.getEndTimeAsc().equals(1)) {
-				lqw.orderByAsc(Project::getEndTime);
+		}
+		return this.page(page, lqw);
+
+		/*Long deptId = Func.firstLong(AuthUtil.getDeptId());
+		LambdaQueryWrapper<Project> lqw = new LambdaQueryWrapper<>();
+		//判断当前登录用户的身份 是业主还是服务机构
+		//年份
+		if (StringUtil.isNotBlank(dto.getYear())) {
+			lqw.like(Project::getYear, dto.getYear());
+		}
+		//项目名称
+		if (StringUtil.isNotBlank(dto.getName())) {
+			lqw.eq(Project::getName, dto.getName());
+		}
+		//区域
+		if (StringUtil.isNotBlank(dto.getAreaCode())) {
+			lqw.eq(Project::getAreaCode, dto.getAreaCode());
+		}
+		Integer deptCategory = dto.getDeptCategory();
+		if (deptCategory != null) {
+			//1.如果是业主 即查询主管单位是该deptId的项目
+			if (deptCategory.equals(3)) {
+				//主管单位 业主自己
+				lqw.eq(Project::getCompetentUnit, dto.getTopDept());
+				//协作单位
+				lqw.like(StringUtil.isNotBlank(dto.getCooperationUint()), Project::getCooperationUint, dto.getCooperationUint());
+
+
 			} else {
-				lqw.orderByDesc(Project::getEndTime);
+				//2.非业主
+				//主管单位
+				if (dto.getCompetentUnit() != null) {
+					lqw.eq(Project::getCompetentUnit, dto.getCompetentUnit());
+				}
+				//如果不是业主 ---> 判断是否是服务商
+				String userRole = AuthUtil.getUserRole();
+				if (userRole != null) {
+					//2.1 机构管理员  ---> 项目来源 机构自建的,做任务
+					if (userRole.contains(STAFF_ADMIN)) {
+						//服务商自己建的项目主管单位就是自己
+						lqw.eq(Project::getCreateTopDept,dto.getTopDept());
+						List<Task> tasks = taskService.getByOrgDeptId(dto.getTopDept(), null);
+						if (!CollectionUtils.isEmpty(tasks)){
+							Set<Long> projectIds = tasks.stream().map(Task::getProjectId).filter(Objects::nonNull).collect(Collectors.toSet());
+							lqw.in(Project::getId,projectIds);
+						}
+					} else {
+						//2.2非机构管理员 是主管  执行机构是自己 和任务执行机构是自己
+						if (userRole.contains(STAFF_SECOND_ADMIN)) {
+							lqw.eq(Project::getCreateDept, deptId);
+							List<Task> tasks = taskService.getByExecuteDept(deptId);
+							if (!CollectionUtils.isEmpty(tasks)){
+
+							}
+
+						} else if (userRole.contains(STAFF_PROJECT_MANAGER)) {
+							//是项目经理
+						} else if (userRole.contains(STAFF_USER)) {
+							//是普通员工
+						}
+					}
+				}
 			}
 		}
-		return this.page(page, lqw);
+		//待完成任务数排序
+		if (dto.getTodoAsc().equals(1)) {
+			lqw.orderByAsc(Project::getTodoTask);
+		} else {
+			lqw.orderByDesc(Project::getTodoTask);
+		}
+		//截止时间排序
+		if (dto.getEndTimeAsc().equals(1)) {
+			lqw.orderByAsc(Project::getEndTime);
+		} else {
+			lqw.orderByDesc(Project::getEndTime);
+		}
+
+		return this.page(page, lqw);*/
 	}
 
 	@Override
@@ -118,4 +190,64 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectMapper, Project>
 		return baseMapper.selectByCreate(createDept, createUser);
 	}
 
+	@Override
+	public ProjectStatisticsVO projectStatistics(Long topDept, Integer deptCategory, String year) {
+		ProjectStatisticsVO vo = new ProjectStatisticsVO();
+		if (deptCategory != null) {
+			LambdaQueryWrapper<Project> lqw = new LambdaQueryWrapper<>();
+			if (deptCategory.equals(3)) {
+				//是业主 --> 主管单位是topDept
+				lqw.eq(Project::getCompetentUnit, topDept);
+				List<Project> list = this.list(lqw);
+				if (!CollectionUtils.isEmpty(list)) {
+					Set<Long> projectIds = list.stream().map(Project::getId).collect(Collectors.toSet());
+					//项目总数
+					vo.setProjectCount(list.size());
+					//项目总投
+					BigDecimal amount = list.stream().map(Project::getTotalAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
+					vo.setTotalAmount(amount);
+					//服务合同金额 -->所有业主的项目的任务下的所有合同
+					List<TaskContract> contracts = taskContractService.getByProjectIds(projectIds);
+					if (!CollectionUtils.isEmpty(contracts)) {
+						BigDecimal reduce = contracts.stream().map(TaskContract::getAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
+						vo.setContractAmount(reduce);
+					}
+					//待完成任务总数
+					List<Task> tasks = taskService.getTodoByYear(projectIds, year);
+					if (!CollectionUtils.isEmpty(tasks)) {
+						vo.setTodoTask(tasks.size());
+					}
+				}
+			} else {
+				//是服务机构 -->执行机构是topDept
+				List<Task> tasks = taskService.getByOrgDeptId(topDept, null);
+				if (!CollectionUtils.isEmpty(tasks)) {
+					Set<Long> projectIds = tasks.stream().map(Task::getProjectId).filter(Objects::nonNull).collect(Collectors.toSet());
+					lqw.in(Project::getId, projectIds);
+					List<Project> projects = this.list(lqw);
+					if (!CollectionUtils.isEmpty(projects)) {
+						//项目总数
+						vo.setProjectCount(projects.size());
+						//项目总投
+						BigDecimal amount = projects.stream().map(Project::getTotalAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
+						vo.setTotalAmount(amount);
+						//服务合同金额  --> 任务合同乙方是当前机构的
+						List<TaskContract> contracts = taskContractService.getByOrgDeptId(topDept);
+						if (!CollectionUtils.isEmpty(contracts)) {
+							BigDecimal reduce = contracts.stream().map(TaskContract::getAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
+							vo.setContractAmount(reduce);
+						}
+						//待完成任务数量
+						Set<Task> collect = tasks.stream().filter(f -> f.getYear().equals(Integer.valueOf(year)) && f.getIsConfirmed() == 0).collect(Collectors.toSet());
+						if (!CollectionUtils.isEmpty(collect)) {
+							vo.setTodoTask(collect.size());
+						}
+					}
+				}
+			}
+		}
+
+		return vo;
+	}
+
 }

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

@@ -82,6 +82,10 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
 	public IPage<Task> projectTaskPage(ProjectTaskPageDTO dto, IPage<Task> page) {
 		LambdaQueryWrapper<Task> lqw = new LambdaQueryWrapper<>();
 		lqw.eq(Task::getProjectId, dto.getProjectId());
+		if (dto.getDeptCategory().equals(3)) {
+			//是业主
+			dto.setOrgDeptId(null);
+		}
 		if (dto.getName() != null) {
 			lqw.like(Task::getTitle, dto.getName());
 		}
@@ -312,4 +316,9 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
 	public List<Task> getTodayTodoByOrgDeptId(Long topDept, String date) {
 		return baseMapper.getTodayTodoByOrgDeptId(topDept, date);
 	}
+
+	@Override
+	public List<Task> getTodoByYear(Set<Long> projectIds, String year) {
+		return baseMapper.getTodoByYear(projectIds, Integer.valueOf(year));
+	}
 }

+ 24 - 0
blade-service/wt-okr/src/main/java/com/wtkj/wrapper/ProjectWrapper.java

@@ -4,9 +4,14 @@ import com.wtkj.entity.Project;
 import com.wtkj.entity.ProjectStage;
 import com.wtkj.service.IProjectStageService;
 import com.wtkj.vo.ProjectVO;
+import com.wutong.file.feign.IFileClient;
+import com.wutong.file.vo.FileVO;
 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;
 
@@ -18,10 +23,15 @@ import java.util.Objects;
 public class ProjectWrapper extends BaseEntityWrapper<Project, ProjectVO> {
 
 	private static IProjectStageService stageService;
+	private static IFileClient fileClient;
+
+	private static ISysClient sysClient;
 
 
 	public static ProjectWrapper build() {
 		stageService = SpringUtil.getBean(IProjectStageService.class);
+		fileClient = SpringUtil.getBean(IFileClient.class);
+		sysClient = SpringUtil.getBean(ISysClient.class);
 		return new ProjectWrapper();
 	}
 
@@ -35,6 +45,20 @@ public class ProjectWrapper extends BaseEntityWrapper<Project, ProjectVO> {
 				vo.setCurrentStageName(byId.getName());
 			}
 		}
+		Integer imgId = entity.getImgId();
+		if (imgId != null) {
+			R<FileVO> byId = fileClient.findById(imgId);
+			if (byId.isSuccess()) {
+				vo.setImgUrl(byId.getData().getFilePath());
+			}
+		}
+		Long competentUnit = entity.getCompetentUnit();
+		if (competentUnit != null) {
+			R<Dept> dept = sysClient.getDept(competentUnit);
+			if (dept.isSuccess()) {
+				vo.setCompetentUnitName(dept.getData().getDeptName());
+			}
+		}
 		return vo;
 	}
 }