Blizzard 1 жил өмнө
parent
commit
95d06546e7
25 өөрчлөгдсөн 593 нэмэгдсэн , 36 устгасан
  1. 47 0
      blade-service-api/wt-okr-api/src/main/java/com/wtkj/dto/ProjectPageDTO.java
  2. 40 0
      blade-service-api/wt-okr-api/src/main/java/com/wtkj/entity/Project.java
  3. 32 0
      blade-service-api/wt-okr-api/src/main/java/com/wtkj/entity/ProjectAuth.java
  4. 39 0
      blade-service-api/wt-okr-api/src/main/java/com/wtkj/entity/ProjectStage.java
  5. 2 2
      blade-service-api/wt-okr-api/src/main/java/com/wtkj/entity/TemplateTypeAndStage.java
  6. 10 0
      blade-service/wt-okr/pom.xml
  7. 19 0
      blade-service/wt-okr/src/main/java/com/wtkj/MagicValue.java
  8. 39 5
      blade-service/wt-okr/src/main/java/com/wtkj/controller/ProjectController.java
  9. 12 12
      blade-service/wt-okr/src/main/java/com/wtkj/controller/TypeAndStageController.java
  10. 15 0
      blade-service/wt-okr/src/main/java/com/wtkj/mapper/ProjectAuthMapper.java
  11. 15 0
      blade-service/wt-okr/src/main/java/com/wtkj/mapper/ProjectAuthMapper.xml
  12. 12 0
      blade-service/wt-okr/src/main/java/com/wtkj/mapper/ProjectStageMapper.java
  13. 6 0
      blade-service/wt-okr/src/main/java/com/wtkj/mapper/ProjectStageMapper.xml
  14. 3 4
      blade-service/wt-okr/src/main/java/com/wtkj/mapper/TypeStageMapper.java
  15. 2 2
      blade-service/wt-okr/src/main/java/com/wtkj/mapper/TypeStageMapper.xml
  16. 24 0
      blade-service/wt-okr/src/main/java/com/wtkj/service/IAsyncService.java
  17. 15 0
      blade-service/wt-okr/src/main/java/com/wtkj/service/IProjectAuthService.java
  18. 6 0
      blade-service/wt-okr/src/main/java/com/wtkj/service/IProjectService.java
  19. 12 0
      blade-service/wt-okr/src/main/java/com/wtkj/service/IProjectStageService.java
  20. 6 3
      blade-service/wt-okr/src/main/java/com/wtkj/service/ITypeAndStageService.java
  21. 84 0
      blade-service/wt-okr/src/main/java/com/wtkj/service/impl/AsyncServiceImpl.java
  22. 24 0
      blade-service/wt-okr/src/main/java/com/wtkj/service/impl/ProjectAuthServiceImpl.java
  23. 96 0
      blade-service/wt-okr/src/main/java/com/wtkj/service/impl/ProjectServiceImpl.java
  24. 18 0
      blade-service/wt-okr/src/main/java/com/wtkj/service/impl/ProjectStageServiceImplService.java
  25. 15 8
      blade-service/wt-okr/src/main/java/com/wtkj/service/impl/TypeAndStageServiceImpl.java

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

@@ -0,0 +1,47 @@
+package com.wtkj.dto;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-13 17:11
+ * @describe
+ */
+@Data
+public class ProjectPageDTO implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	private String year;
+
+	private String name;
+
+	private String areaCode;
+
+	@ApiModelProperty(value = "主管单位")
+	@JsonSerialize(using = ToStringSerializer.class)
+	private Long competentUnit;
+
+	@ApiModelProperty(value = "协作单位")
+	private String cooperationUint;
+
+	@ApiModelProperty(value = "是否按照待完成任务数降序 0:否 1:是 默认否")
+	private Integer todoAsc = 0;
+
+	@ApiModelProperty(value = "是否按照截至时间降序 0:否 1:是 默认否")
+	private Integer endTimeAsc = 0;
+
+	@NotNull(message = "current不可为空")
+	private int current;
+
+	@NotNull(message = "size不可为空")
+	private int size;
+
+
+}

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

@@ -2,13 +2,18 @@ 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.math.BigDecimal;
+import java.util.Date;
 
 /**
  * @author Blizzard
@@ -25,18 +30,53 @@ public class Project extends BaseEntity {
 	@TableField("project_type")
 	@NotNull(message = "projectType不可为空")
 	@JsonSerialize(using = ToStringSerializer.class)
+	@ApiModelProperty(value = "项目类型id")
 	private Long projectType;
 
+	@TableField("current_stage")
+	@JsonSerialize(using = ToStringSerializer.class)
+	@ApiModelProperty(value = "当前阶段id")
+	private Long currentStage;
+
 	@TableField("name")
 	private String name;
 
+	@TableField("total_amount")
+	private BigDecimal totalAmount;
+
 	@TableField("area_code")
 	@NotNull(message = "areaCode不可为空")
+	@ApiModelProperty(value = "地区编码")
 	private String areaCode;
 
 	@TableField("competent_unit")
 	@NotNull(message = "competentUnit不可为空")
 	@JsonSerialize(using = ToStringSerializer.class)
+	@ApiModelProperty(value = "主管单位")
 	private Long competentUnit;
 
+	@TableField("cooperation_unit")
+	@ApiModelProperty(value = "协作单位")
+	private String cooperationUint;
+
+	@TableField("industry_id")
+	@NotNull(message = "industryId不可为空")
+	@JsonSerialize(using = ToStringSerializer.class)
+	@ApiModelProperty(value = "行业分类")
+	private Long industryId;
+
+	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
+	@ApiModelProperty(value = "截止时间")
+	private Date endTime;
+
+	@TableField("year")
+	@ApiModelProperty(value = "年份")
+	private String year;
+
+	@TableField("todo_task")
+	@ApiModelProperty(value = "待完成任务数量")
+	private Integer todoTask;
+
+
 }

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

@@ -0,0 +1,32 @@
+package com.wtkj.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-13 17:21
+ * @describe 第三方机构项目权限
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@TableName("blade_project_auth")
+public class ProjectAuth extends BaseEntity {
+
+	@TableField("user_id")
+	@JsonSerialize(using = ToStringSerializer.class)
+	private Long userId;
+
+	@TableField("user_dept")
+	@JsonSerialize(using = ToStringSerializer.class)
+	private Long userDept;
+
+	@TableField("project_id")
+	@JsonSerialize(using = ToStringSerializer.class)
+	private Long projectId;
+}

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

@@ -0,0 +1,39 @@
+package com.wtkj.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+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 javax.validation.constraints.NotNull;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-13 16:15
+ * @describe
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@TableName("blade_project_stage")
+public class ProjectStage extends BaseEntity {
+
+	private static final long serialVersionUID = 1L;
+
+	@TableField("project_id")
+	@JsonSerialize(using = ToStringSerializer.class)
+	private Long projectId;
+
+	@TableField("name")
+	@ApiModelProperty("名称")
+	private String name;
+
+	@TableField("sort")
+	@ApiModelProperty("排序")
+	@NotNull(message = "sort不可为空")
+	private Integer sort;
+
+}

+ 2 - 2
blade-service-api/wt-okr-api/src/main/java/com/wtkj/entity/TypeAndStage.java → blade-service-api/wt-okr-api/src/main/java/com/wtkj/entity/TemplateTypeAndStage.java

@@ -17,9 +17,9 @@ import javax.validation.constraints.NotNull;
  * @describe 项目类型和阶段表
  */
 @Data
-@TableName("blade_type_and_stage")
+@TableName("blade_template_type_and_stage")
 @EqualsAndHashCode(callSuper = true)
-public class TypeAndStage extends BaseEntity {
+public class TemplateTypeAndStage extends BaseEntity {
 
 	private static final long serialVersionUID = 1L;
 

+ 10 - 0
blade-service/wt-okr/pom.xml

@@ -26,6 +26,16 @@
             <artifactId>wt-okr-api</artifactId>
             <version>1.0.RELEASE</version>
         </dependency>
+        <dependency>
+            <groupId>org.springblade</groupId>
+            <artifactId>blade-system-api</artifactId>
+            <version>2.9.1.RELEASE</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springblade</groupId>
+            <artifactId>blade-user-api</artifactId>
+            <version>2.9.1.RELEASE</version>
+        </dependency>
     </dependencies>
 
 

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

@@ -0,0 +1,19 @@
+package com.wtkj;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-14 09:17
+ * @describe
+ */
+public interface MagicValue {
+
+	/**
+	 * 业主机构管理员
+	 */
+	String DEPT_ADMIN = "deptAdmin";
+
+	/**
+	 * 服务机构管理员
+	 */
+	String STAFF_ADMIN = "admin";
+}

+ 39 - 5
blade-service/wt-okr/src/main/java/com/wtkj/controller/ProjectController.java

@@ -1,16 +1,19 @@
 package com.wtkj.controller;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import com.wtkj.dto.ProjectPageDTO;
 import com.wtkj.entity.Project;
+import com.wtkj.service.IAsyncService;
 import com.wtkj.service.IProjectService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 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.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springblade.core.tool.utils.Func;
+import org.springframework.web.bind.annotation.*;
 
 /**
  * @author Blizzard
@@ -25,6 +28,8 @@ public class ProjectController {
 
 	private final IProjectService projectService;
 
+	private final IAsyncService asyncService;
+
 	/**
 	 * 创建/修改项目
 	 */
@@ -32,7 +37,36 @@ public class ProjectController {
 	@ApiOperation(value = "新建或者修改项目", notes = "传入project")
 	@ApiOperationSupport(order = 1)
 	public R<Boolean> create(@RequestBody Project project) {
-		return R.status(projectService.saveOrUpdate(project));
+		return R.status(projectService.submit(project));
+	}
+
+	/**
+	 * 分页
+	 */
+	@PostMapping("/page")
+	@ApiOperation(value = "分页", notes = "")
+	@ApiOperationSupport(order = 2)
+	public R page(@RequestBody ProjectPageDTO dto) {
+		Query query = new Query();
+		query.setCurrent(dto.getCurrent());
+		query.setSize(dto.getSize());
+		IPage<Project> page = projectService.getPage(dto, Condition.getPage(query));
+		return R.data(page);
+	}
+
+	/**
+	 * 删除
+	 */
+	@GetMapping("/delete")
+	@ApiOperation(value = "删除", notes = "传入ids")
+	@ApiOperationSupport(order = 3)
+	public R<Boolean> delete(String ids) {
+		boolean b = projectService.removeBatchByIds(Func.toLongList(ids));
+		if (b) {
+			//todo 项目相关的信息删除
+			asyncService.removeProject(Func.toLongList(ids));
+		}
+		return R.status(b);
 	}
 
 }

+ 12 - 12
blade-service/wt-okr/src/main/java/com/wtkj/controller/TypeAndStageController.java

@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
-import com.wtkj.entity.TypeAndStage;
+import com.wtkj.entity.TemplateTypeAndStage;
 import com.wtkj.service.ITypeAndStageService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -35,11 +35,11 @@ public class TypeAndStageController {
 	@GetMapping("/page")
 	@ApiOperationSupport(order = 1)
 	@ApiOperation(value = "项目类型分页", notes = " ")
-	public R<IPage<TypeAndStage>> page(Query query) {
-		LambdaQueryWrapper<TypeAndStage> lqw = Wrappers.lambdaQuery();
-		lqw.eq(TypeAndStage::getParentId, 0);
-		lqw.orderByDesc(TypeAndStage::getCreateTime);
-		IPage<TypeAndStage> page = typeAndStageService.page(Condition.getPage(query), lqw);
+	public R<IPage<TemplateTypeAndStage>> page(Query query) {
+		LambdaQueryWrapper<TemplateTypeAndStage> lqw = Wrappers.lambdaQuery();
+		lqw.eq(TemplateTypeAndStage::getParentId, 0);
+		lqw.orderByDesc(TemplateTypeAndStage::getCreateTime);
+		IPage<TemplateTypeAndStage> page = typeAndStageService.page(Condition.getPage(query), lqw);
 		return R.data(page);
 	}
 
@@ -49,9 +49,9 @@ public class TypeAndStageController {
 	@GetMapping("/v2/stage-list")
 	@ApiOperationSupport(order = 2)
 	@ApiOperation(value = "阶段列表", notes = "传入parentId")
-	public R<List<TypeAndStage>> list(@RequestParam(value = "parentId") Long parentId) {
-		List<TypeAndStage> list = typeAndStageService.list(new LambdaQueryWrapper<TypeAndStage>().eq(TypeAndStage::getParentId, parentId)
-			.orderByAsc(TypeAndStage::getSort));
+	public R<List<TemplateTypeAndStage>> list(@RequestParam(value = "parentId") Long parentId) {
+		List<TemplateTypeAndStage> list = typeAndStageService.list(new LambdaQueryWrapper<TemplateTypeAndStage>().eq(TemplateTypeAndStage::getParentId, parentId)
+			.orderByAsc(TemplateTypeAndStage::getSort));
 		return R.data(list);
 	}
 
@@ -61,8 +61,8 @@ public class TypeAndStageController {
 	@GetMapping("/submit")
 	@ApiOperationSupport(order = 3)
 	@ApiOperation(value = "新增或者修改", notes = "传入typeAndStage")
-	public R submit(@RequestBody TypeAndStage typeAndStage) {
-		return R.status(typeAndStageService.submit(typeAndStage));
+	public R submit(@RequestBody TemplateTypeAndStage templateTypeAndStage) {
+		return R.status(typeAndStageService.submit(templateTypeAndStage));
 	}
 
 
@@ -73,7 +73,7 @@ public class TypeAndStageController {
 	@ApiOperation(value = "查看类型或阶段详情", notes = "传入id")
 	@GetMapping("/v2/detail")
 	public R detail(Long id) {
-		TypeAndStage detail = typeAndStageService.getById(id);
+		TemplateTypeAndStage detail = typeAndStageService.getById(id);
 		return R.data(detail);
 	}
 

+ 15 - 0
blade-service/wt-okr/src/main/java/com/wtkj/mapper/ProjectAuthMapper.java

@@ -0,0 +1,15 @@
+package com.wtkj.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.wtkj.entity.ProjectAuth;
+
+import java.util.List;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-13 17:35
+ * @describe
+ */
+public interface ProjectAuthMapper extends BaseMapper<ProjectAuth> {
+	List<ProjectAuth> selectByDeptAndUser(Long deptId, Long userId);
+}

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

@@ -0,0 +1,15 @@
+<?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.ProjectAuthMapper">
+
+
+    <select id="selectByDeptAndUser" resultType="com.wtkj.entity.ProjectAuth">
+        select * from blade_project_auth where is_deleted = 0
+        <if test="param1 != null">
+            and user_dept = #{param1}
+        </if>
+        <if test="param2 != null">
+            and user_id = #{param2}
+        </if>
+    </select>
+</mapper>

+ 12 - 0
blade-service/wt-okr/src/main/java/com/wtkj/mapper/ProjectStageMapper.java

@@ -0,0 +1,12 @@
+package com.wtkj.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.wtkj.entity.ProjectStage;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-13 16:46
+ * @describe
+ */
+public interface ProjectStageMapper extends BaseMapper<ProjectStage> {
+}

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

@@ -0,0 +1,6 @@
+<?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.ProjectStageMapper">
+
+
+</mapper>

+ 3 - 4
blade-service/wt-okr/src/main/java/com/wtkj/mapper/TypeStageMapper.java

@@ -1,7 +1,7 @@
 package com.wtkj.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.wtkj.entity.TypeAndStage;
+import com.wtkj.entity.TemplateTypeAndStage;
 
 import java.util.List;
 
@@ -10,8 +10,7 @@ import java.util.List;
  * @create at 2022-12-12 12:00
  * @describe
  */
-public interface TypeStageMapper extends BaseMapper<TypeAndStage> {
-	List<TypeAndStage> getListByParentId(Long parentId);
-
+public interface TypeStageMapper extends BaseMapper<TemplateTypeAndStage> {
 
+	List<TemplateTypeAndStage> selectStages(Long projectType);
 }

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

@@ -2,8 +2,8 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.wtkj.mapper.TypeStageMapper">
 
-    <select id="getListByParentId" resultType="com.wtkj.entity.TypeAndStage">
-        select * from blade_type_stage where is_deleted = 0
+    <select id="selectStages" resultType="com.wtkj.entity.TemplateTypeAndStage">
+        select * from blade_template_type_and_stage where is_deleted = 0
         <if test="param1 != null">
             and parent_id = #{param1}
         </if>

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

@@ -0,0 +1,24 @@
+package com.wtkj.service;
+
+import com.wtkj.entity.Project;
+import org.springblade.core.secure.BladeUser;
+
+import java.util.List;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-13 16:32
+ * @describe
+ */
+public interface IAsyncService {
+
+	/**
+	 * 异步创建项目 阶段 项目权限等处理
+	 */
+	void createProject(Project project, BladeUser user);
+
+	/**
+	 * 异步删除项目  项目阶段 文件夹/文件等
+	 */
+	void removeProject(List<Long> projectIds);
+}

+ 15 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/IProjectAuthService.java

@@ -0,0 +1,15 @@
+package com.wtkj.service;
+
+import com.wtkj.entity.ProjectAuth;
+import org.springblade.core.mp.base.BaseService;
+
+import java.util.List;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-13 17:37
+ * @describe
+ */
+public interface IProjectAuthService extends BaseService<ProjectAuth> {
+	List<ProjectAuth> getByDeptAndUser(Long deptId, Long userId);
+}

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

@@ -1,5 +1,7 @@
 package com.wtkj.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.wtkj.dto.ProjectPageDTO;
 import com.wtkj.entity.Project;
 import org.springblade.core.mp.base.BaseService;
 
@@ -9,4 +11,8 @@ import org.springblade.core.mp.base.BaseService;
  * @describe
  */
 public interface IProjectService extends BaseService<Project> {
+	boolean submit(Project project);
+
+	IPage<Project> getPage(ProjectPageDTO dto, IPage<Project> page);
+
 }

+ 12 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/IProjectStageService.java

@@ -0,0 +1,12 @@
+package com.wtkj.service;
+
+import com.wtkj.entity.ProjectStage;
+import org.springblade.core.mp.base.BaseService;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-13 16:49
+ * @describe
+ */
+public interface IProjectStageService extends BaseService<ProjectStage> {
+}

+ 6 - 3
blade-service/wt-okr/src/main/java/com/wtkj/service/ITypeAndStageService.java

@@ -1,16 +1,19 @@
 package com.wtkj.service;
 
-import com.wtkj.entity.TypeAndStage;
+import com.wtkj.entity.TemplateTypeAndStage;
 import org.springblade.core.mp.base.BaseService;
 
+import java.util.List;
+
 /**
  * @author Jimi Zhang
  * @create at 2022-12-12 14:05
  * @describe
  */
-public interface ITypeAndStageService extends BaseService<TypeAndStage> {
+public interface ITypeAndStageService extends BaseService<TemplateTypeAndStage> {
 
 
-	boolean submit(TypeAndStage typeAndStage);
+	boolean submit(TemplateTypeAndStage templateTypeAndStage);
 
+	List<TemplateTypeAndStage> getStages(Long projectType);
 }

+ 84 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/AsyncServiceImpl.java

@@ -0,0 +1,84 @@
+package com.wtkj.service.impl;
+
+import com.wtkj.entity.Project;
+import com.wtkj.entity.ProjectAuth;
+import com.wtkj.entity.ProjectStage;
+import com.wtkj.entity.TemplateTypeAndStage;
+import com.wtkj.service.IAsyncService;
+import com.wtkj.service.IProjectAuthService;
+import com.wtkj.service.IProjectStageService;
+import com.wtkj.service.ITypeAndStageService;
+import lombok.AllArgsConstructor;
+import org.springblade.core.secure.BladeUser;
+import org.springblade.core.tool.utils.DateUtil;
+import org.springblade.core.tool.utils.Func;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-13 16:32
+ * @describe
+ */
+@Service
+@AllArgsConstructor
+public class AsyncServiceImpl implements IAsyncService {
+
+	private final ITypeAndStageService typeAndStageService;
+	private final IProjectStageService stageService;
+	private final IProjectAuthService projectAuthService;
+
+
+	@Override
+	@Async("asyncPoolTaskExecutor")
+	public void createProject(Project project, BladeUser user) {
+		//1.项目类型  --> 使用类型对应的模版阶段创建项目阶段
+		Long projectType = project.getProjectType();
+		List<TemplateTypeAndStage> templateStage = typeAndStageService.getStages(projectType);
+		//2.创建项目阶段
+		if (!CollectionUtils.isEmpty(templateStage)) {
+			List<ProjectStage> stagesList = new ArrayList<>();
+			templateStage.forEach(template -> {
+				//项目的阶段记录表
+				ProjectStage stage = new ProjectStage();
+				stage.setProjectId(project.getId());
+				stage.setName(template.getName());
+				stage.setSort(template.getSort());
+				stage.setCreateUser(project.getCreateUser());
+				stage.setCreateDept(project.getCreateDept());
+				stage.setCreateTime(DateUtil.now());
+				stage.setUpdateTime(DateUtil.now());
+				stage.setUpdateUser(project.getUpdateUser());
+				stagesList.add(stage);
+			});
+			if (!CollectionUtils.isEmpty(stagesList)) {
+				stageService.saveBatch(stagesList);
+			}
+		}
+
+		//3.如果主管单位和当前登录用户不是同一机构
+		String deptIdStr = user.getDeptId();
+		if (deptIdStr != null) {
+			Long deptId = Func.firstLong(deptIdStr);
+			if (!deptId.equals(project.getCompetentUnit())) {
+				ProjectAuth auth = new ProjectAuth();
+				auth.setUserId(user.getUserId());
+				auth.setUserDept(deptId);
+				auth.setProjectId(project.getId());
+				projectAuthService.save(auth);
+			}
+		}
+
+	}
+
+	@Async("asyncPoolTaskExecutor")
+	@Override
+	public void removeProject(List<Long> longList) {
+
+	}
+
+}

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

@@ -0,0 +1,24 @@
+package com.wtkj.service.impl;
+
+import com.wtkj.entity.ProjectAuth;
+import com.wtkj.mapper.ProjectAuthMapper;
+import com.wtkj.service.IProjectAuthService;
+import lombok.AllArgsConstructor;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-13 17:37
+ * @describe
+ */
+@Service
+@AllArgsConstructor
+public class ProjectAuthServiceImpl extends BaseServiceImpl<ProjectAuthMapper, ProjectAuth> implements IProjectAuthService {
+	@Override
+	public List<ProjectAuth> getByDeptAndUser(Long deptId, Long userId) {
+		return baseMapper.selectByDeptAndUser(deptId, userId);
+	}
+}

+ 96 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/ProjectServiceImpl.java

@@ -1,11 +1,30 @@
 package com.wtkj.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+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.mapper.ProjectMapper;
+import com.wtkj.service.IAsyncService;
+import com.wtkj.service.IProjectAuthService;
 import com.wtkj.service.IProjectService;
 import lombok.AllArgsConstructor;
 import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.core.secure.BladeUser;
+import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.StringUtil;
+import org.springblade.system.entity.Dept;
+import org.springblade.system.feign.ISysClient;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static com.wtkj.MagicValue.STAFF_ADMIN;
 
 /**
  * @author Blizzard
@@ -15,4 +34,81 @@ import org.springframework.stereotype.Service;
 @Service
 @AllArgsConstructor
 public class ProjectServiceImpl extends BaseServiceImpl<ProjectMapper, Project> implements IProjectService {
+
+	private final IAsyncService asyncService;
+	private final ISysClient sysClient;
+	private final IProjectAuthService projectAuthService;
+
+	@Override
+	public boolean submit(Project project) {
+		boolean flag = false;
+		BladeUser user = AuthUtil.getUser();
+		if (project.getId() == null) {
+			flag = this.save(project);
+			asyncService.createProject(project, user);
+		} else {
+			flag = this.updateById(project);
+		}
+		return flag;
+	}
+
+	@Override
+	public IPage<Project> getPage(ProjectPageDTO dto, IPage<Project> page) {
+		LambdaQueryWrapper<Project> lqw = new LambdaQueryWrapper<>();
+		//判断当前登录用户的身份 是业主还是服务机构
+		String deptIdStr = AuthUtil.getDeptId();
+		Long deptId = Long.valueOf(deptIdStr);
+		R<Dept> rpc = sysClient.getDept(deptId);
+		if (rpc.isSuccess()) {
+			//项目名称
+			if (dto.getName() != null) {
+				lqw.eq(Project::getName, dto.getName());
+			}
+			//区域
+			if (dto.getAreaCode() != null) {
+				lqw.eq(Project::getAreaCode, dto.getAreaCode());
+			}
+			Integer deptCategory = rpc.getData().getDeptCategory();
+			//如果是业主 即查询主管单位是该deptId的项目
+			if (deptCategory != null && deptCategory.equals(3)) {
+				//主管单位 业主自己
+				lqw.eq(Project::getCompetentUnit, deptId);
+				//协作单位
+				lqw.like(StringUtil.isNotBlank(dto.getCooperationUint()), Project::getCooperationUint, dto.getCooperationUint());
+			} else {
+				//主管单位
+				lqw.eq(Project::getCompetentUnit, dto.getCompetentUnit());
+				//如果不是业主 ---> 判断是否是服务商的管理员  服务商管理员可以查看所有的项目
+				String userRole = AuthUtil.getUserRole();
+				if (userRole != null && userRole.equals(STAFF_ADMIN)) {
+					List<ProjectAuth> auths = projectAuthService.getByDeptAndUser(deptId, null);
+					if (!CollectionUtils.isEmpty(auths)) {
+						Set<Long> projectIds = auths.stream().map(ProjectAuth::getProjectId).collect(Collectors.toSet());
+						lqw.in(Project::getId, projectIds);
+					}
+				} else {
+					//不是服务机构管理员 则会是项目经理或者任务执行人  从项目权限表里取
+					List<ProjectAuth> auths = projectAuthService.getByDeptAndUser(deptId, AuthUtil.getUserId());
+					if (!CollectionUtils.isEmpty(auths)) {
+						Set<Long> projectIds = auths.stream().map(ProjectAuth::getProjectId).collect(Collectors.toSet());
+						lqw.in(Project::getId, projectIds);
+					}
+				}
+			}
+			//待完成任务数排序
+			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);
+	}
+
 }

+ 18 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/ProjectStageServiceImplService.java

@@ -0,0 +1,18 @@
+package com.wtkj.service.impl;
+
+import com.wtkj.entity.ProjectStage;
+import com.wtkj.mapper.ProjectStageMapper;
+import com.wtkj.service.IProjectStageService;
+import lombok.AllArgsConstructor;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-13 16:50
+ * @describe
+ */
+@Service
+@AllArgsConstructor
+public class ProjectStageServiceImplService extends BaseServiceImpl<ProjectStageMapper, ProjectStage> implements IProjectStageService {
+}

+ 15 - 8
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/TypeAndStageServiceImpl.java

@@ -2,7 +2,7 @@ package com.wtkj.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.wtkj.entity.TypeAndStage;
+import com.wtkj.entity.TemplateTypeAndStage;
 import com.wtkj.mapper.TypeStageMapper;
 import com.wtkj.service.ITypeAndStageService;
 import lombok.AllArgsConstructor;
@@ -10,6 +10,8 @@ import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * @author Jimi Zhang
  * @create at 2022-12-12 14:06
@@ -17,23 +19,28 @@ import org.springframework.stereotype.Service;
  */
 @Service
 @AllArgsConstructor
-public class TypeAndStageServiceImpl extends BaseServiceImpl<TypeStageMapper, TypeAndStage> implements ITypeAndStageService {
+public class TypeAndStageServiceImpl extends BaseServiceImpl<TypeStageMapper, TemplateTypeAndStage> implements ITypeAndStageService {
 
 
 	@Override
-	public boolean submit(TypeAndStage typeAndStage) {
-		if (typeAndStage.getId() == null) {
-			LambdaQueryWrapper<TypeAndStage> lqw = Wrappers.lambdaQuery();
-			lqw.eq(TypeAndStage::getName, typeAndStage.getName());
+	public boolean submit(TemplateTypeAndStage templateTypeAndStage) {
+		if (templateTypeAndStage.getId() == null) {
+			LambdaQueryWrapper<TemplateTypeAndStage> lqw = Wrappers.lambdaQuery();
+			lqw.eq(TemplateTypeAndStage::getName, templateTypeAndStage.getName());
 			Long cnt = baseMapper.selectCount(lqw);
 			if (cnt > 0L) {
 				throw new ServiceException("项目类型或者阶段名称重名,已经存在!");
 			}
-			return save(typeAndStage);
+			return save(templateTypeAndStage);
 		} else {
-			return updateById(typeAndStage);
+			return updateById(templateTypeAndStage);
 		}
 	}
 
+	@Override
+	public List<TemplateTypeAndStage> getStages(Long projectType) {
+		return baseMapper.selectStages(projectType);
+	}
+
 
 }