Blizzard 1 рік тому
батько
коміт
5c024a16ee
18 змінених файлів з 360 додано та 162 видалено
  1. 0 5
      blade-service-api/pom.xml
  2. 25 0
      blade-service-api/wt-okr-api/src/main/java/com/wtkj/feign/IOkrClient.java
  3. 0 2
      blade-service-api/wt-okr-api/src/main/java/com/wtkj/vo/WorkStatusVO.java
  4. 14 0
      blade-service/wt-okr/src/main/java/com/wtkj/controller/ContactController.java
  5. 2 1
      blade-service/wt-okr/src/main/java/com/wtkj/controller/IndexController.java
  6. 20 7
      blade-service/wt-okr/src/main/java/com/wtkj/controller/QrCodeController.java
  7. 28 0
      blade-service/wt-okr/src/main/java/com/wtkj/feign/OkrClient.java
  8. 1 2
      blade-service/wt-okr/src/main/java/com/wtkj/mapper/ProjectAuthMapper.java
  9. 4 11
      blade-service/wt-okr/src/main/java/com/wtkj/mapper/ProjectAuthMapper.xml
  10. 1 2
      blade-service/wt-okr/src/main/java/com/wtkj/service/IProjectAuthService.java
  11. 4 1
      blade-service/wt-okr/src/main/java/com/wtkj/service/IQrcodeService.java
  12. 1 1
      blade-service/wt-okr/src/main/java/com/wtkj/service/IWorkStatusService.java
  13. 143 24
      blade-service/wt-okr/src/main/java/com/wtkj/service/impl/AsyncServiceImpl.java
  14. 2 6
      blade-service/wt-okr/src/main/java/com/wtkj/service/impl/ProjectAuthServiceImpl.java
  15. 72 74
      blade-service/wt-okr/src/main/java/com/wtkj/service/impl/ProjectServiceImpl.java
  16. 29 12
      blade-service/wt-okr/src/main/java/com/wtkj/service/impl/QrcodeServiceImpl.java
  17. 13 5
      blade-service/wt-okr/src/main/java/com/wtkj/service/impl/TaskServiceImpl.java
  18. 1 9
      blade-service/wt-okr/src/main/java/com/wtkj/service/impl/WorkStatusServiceImpl.java

+ 0 - 5
blade-service-api/pom.xml

@@ -47,11 +47,6 @@
             <artifactId>blade-core-auto</artifactId>
             <scope>provided</scope>
         </dependency>
-        <dependency>
-            <groupId>com.wtkj</groupId>
-            <artifactId>blade-common</artifactId>
-            <version>1.0.RELEASE</version>
-        </dependency>
     </dependencies>
 
     <build>

+ 25 - 0
blade-service-api/wt-okr-api/src/main/java/com/wtkj/feign/IOkrClient.java

@@ -0,0 +1,25 @@
+package com.wtkj.feign;
+
+
+import com.wtkj.entity.WorkStatus;
+import org.springblade.core.tool.api.R;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-25 16:11
+ * @describe
+ */
+@FeignClient(value = "wutong-okr")
+public interface IOkrClient {
+
+	String API_PReFIX = "/client";
+
+	String WORK_STATUS = API_PReFIX + "/work-status";
+
+
+	@GetMapping(WORK_STATUS)
+	R<WorkStatus> workStatus(@RequestParam Long userId);
+}

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

@@ -3,7 +3,6 @@ package com.wtkj.vo;
 import com.wtkj.entity.WorkStatus;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
-import org.springblade.system.user.entity.User;
 
 /**
  * @author Blizzard
@@ -16,5 +15,4 @@ public class WorkStatusVO extends WorkStatus {
 
 	private static final long serialVersionUID = 1L;
 
-	private User user;
 }

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

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import com.wtkj.entity.ContactOuter;
 import com.wtkj.service.IContactOuterService;
+import com.wtkj.service.IWorkStatusService;
+import com.wtkj.vo.WorkStatusVO;
 import com.wtkj.wrapper.ContactOuterUserWrapper;
 import com.wtkj.wrapper.ContactOuterWrapper;
 import io.swagger.annotations.Api;
@@ -30,6 +32,7 @@ import org.springframework.web.bind.annotation.RestController;
 public class ContactController {
 
 	private final IContactOuterService contactOuterService;
+	private final IWorkStatusService workStatusService;
 
 
 	/**
@@ -55,4 +58,15 @@ public class ContactController {
 	}
 
 
+	/**
+	 * 用户工作状态
+	 */
+	@GetMapping("/user-workStatus")
+	@ApiOperation(value = "用户工作状态", notes = "传入userId")
+	@ApiOperationSupport(order = 3)
+	public R workStatus(@RequestParam Long userId) {
+		WorkStatusVO workStatusVO = workStatusService.workStatus(userId);
+		return R.data(workStatusVO);
+	}
+
 }

+ 2 - 1
blade-service/wt-okr/src/main/java/com/wtkj/controller/IndexController.java

@@ -42,7 +42,8 @@ public class IndexController {
 	@ApiOperationSupport(order = 1)
 	@ApiOperation(value = "我的状态", notes = "")
 	public R wordStatus() {
-		return R.data(workStatus.workStatus());
+		Long userId = AuthUtil.getUserId();
+		return R.data(workStatus.workStatus(userId));
 	}
 
 

+ 20 - 7
blade-service/wt-okr/src/main/java/com/wtkj/controller/QrCodeController.java

@@ -10,6 +10,8 @@ import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
 import org.springframework.web.bind.annotation.*;
 
+import javax.validation.Valid;
+
 /**
  * @author Blizzard
  * @create at 2023-09-19 17:25
@@ -27,7 +29,7 @@ public class QrCodeController {
 	 * 生成二维码
 	 */
 	@GetMapping("/create-qrcode")
-	@ApiOperation(value = "生成二维码", notes = "")
+	@ApiOperation(value = "生成邀请用户为联系人二维码", notes = "")
 	@ApiOperationSupport(order = 1)
 	public R createQrcode() {
 		return R.data(qrcodeService.createQrcode());
@@ -36,21 +38,32 @@ public class QrCodeController {
 	/**
 	 * 邀请至机构下
 	 */
-	@GetMapping("/invite-to-dept")
+	@PostMapping("/invite-to-dept")
 	@ApiOperation(value = "接受邀请至机构下", notes = "type:1 邀请内部联系人 2:外部联系人")
 	@ApiOperationSupport(order = 2)
-	public R inviteToDept(@RequestBody InviteToDeptDTO dto) {
+	public R inviteToDept(@RequestBody @Valid InviteToDeptDTO dto) {
 		return R.status(qrcodeService.inviteToDept(dto.getCreateUser(), dto.getType(), dto.getQrcodeId(), AuthUtil.getUserId(), dto.getDeptId()));
 	}
 
+	/**
+	 * 生成邀请至项目组二维码
+	 */
+	@GetMapping("/create-group-qrcode")
+	@ApiOperation(value = "生成邀请至项目组二维码", notes = "")
+	@ApiOperationSupport(order = 3)
+	public R createGroupQrcode(@RequestParam Long projectId) {
+		return R.data(qrcodeService.createGroupQrcode(projectId));
+	}
+
+
 	/**
 	 * 邀请至项目组
 	 */
 	@GetMapping("/invite-to-project")
-	@ApiOperation(value = "接受邀请至项目组", notes = "ownerDept:主管单位,deptId:服务商的顶级机构id")
-	@ApiOperationSupport(order = 3)
-	public R inviteToProject(@RequestParam String qrcodeId, @RequestParam Long ownerDept, @RequestParam Long deptId, @RequestParam Long projectId) {
-		return R.status(qrcodeService.inviteToProject(qrcodeId, ownerDept, deptId, projectId));
+	@ApiOperation(value = "接受邀请至项目组", notes = "deptId:服务商的顶级机构id")
+	@ApiOperationSupport(order = 4)
+	public R inviteToProject(@RequestParam String qrcodeId, @RequestParam Long topDept, @RequestParam Long projectId) {
+		return R.status(qrcodeService.inviteToProject(qrcodeId, topDept, projectId));
 	}
 
 }

+ 28 - 0
blade-service/wt-okr/src/main/java/com/wtkj/feign/OkrClient.java

@@ -0,0 +1,28 @@
+package com.wtkj.feign;
+
+import com.wtkj.entity.WorkStatus;
+import com.wtkj.service.IWorkStatusService;
+import lombok.AllArgsConstructor;
+import org.springblade.core.tenant.annotation.NonDS;
+import org.springblade.core.tool.api.R;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-25 16:21
+ * @describe
+ */
+@NonDS
+@RestController
+@AllArgsConstructor
+public class OkrClient implements IOkrClient {
+
+	private final IWorkStatusService workStatusService;
+
+	@Override
+	@GetMapping(WORK_STATUS)
+	public R<WorkStatus> workStatus(Long userId) {
+		return R.data(workStatusService.workStatus(userId));
+	}
+}

+ 1 - 2
blade-service/wt-okr/src/main/java/com/wtkj/mapper/ProjectAuthMapper.java

@@ -11,7 +11,6 @@ import java.util.List;
  * @describe
  */
 public interface ProjectAuthMapper extends BaseMapper<ProjectAuth> {
-	List<ProjectAuth> selectByDeptAndUser(Long deptId, Long userId);
+	List<ProjectAuth> selectByDeptAndUser(Long topDept, Long deptId, Long userId);
 
-	List<ProjectAuth> selectByTopDeptAndUser(Long topDept, Long userId);
 }

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

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

+ 1 - 2
blade-service/wt-okr/src/main/java/com/wtkj/service/IProjectAuthService.java

@@ -11,7 +11,6 @@ import java.util.List;
  * @describe
  */
 public interface IProjectAuthService extends BaseService<ProjectAuth> {
-	List<ProjectAuth> getByDeptAndUser(Long deptId, Long userId);
+	List<ProjectAuth> getByDeptAndUser(Long topDept, Long deptId, Long userId);
 
-	List<ProjectAuth> getByTopDept(Long topDept, Long userId);
 }

+ 4 - 1
blade-service/wt-okr/src/main/java/com/wtkj/service/IQrcodeService.java

@@ -14,5 +14,8 @@ public interface IQrcodeService {
 
 	boolean inviteToDept(Long createUser, Integer type, String qrcodeId, Long userId, Long deptId);
 
-	boolean inviteToProject(String qrcodeId, Long ownerDept, Long deptId, Long projectId);
+	boolean inviteToProject(String qrcodeId, Long deptId, Long projectId);
+
+	JSONObject createGroupQrcode(Long projectId);
+
 }

+ 1 - 1
blade-service/wt-okr/src/main/java/com/wtkj/service/IWorkStatusService.java

@@ -10,5 +10,5 @@ import org.springblade.core.mp.base.BaseService;
  * @describe
  */
 public interface IWorkStatusService extends BaseService<WorkStatus> {
-	WorkStatusVO workStatus();
+	WorkStatusVO workStatus(Long userId);
 }

+ 143 - 24
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/AsyncServiceImpl.java

@@ -7,6 +7,7 @@ import org.springblade.core.secure.BladeUser;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.DateUtil;
 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;
@@ -68,27 +69,25 @@ public class AsyncServiceImpl implements IAsyncService {
 		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());
-				R<Dept> rpc = sysClient.getDept(deptId);
-				if (rpc.isSuccess()) {
-					String ancestors = rpc.getData().getAncestors();
-					if (ancestors != null && ancestors.contains(String.valueOf(ZERO))) {
-						List<Long> longList = Func.toLongList(ancestors);
-						if (!CollectionUtils.isEmpty(longList)) {
-							if (longList.size() > 2) {
-								auth.setTopDept(longList.get(1));
-							} else {
-								auth.setTopDept(Long.valueOf(deptIdStr));
-							}
+			ProjectAuth auth = new ProjectAuth();
+			auth.setUserId(user.getUserId());
+			R<Dept> rpc = sysClient.getDept(deptId);
+			if (rpc.isSuccess()) {
+				String ancestors = rpc.getData().getAncestors();
+				if (ancestors != null && ancestors.contains(String.valueOf(ZERO))) {
+					List<Long> parentIds = Func.toLongList(ancestors);
+					if (!CollectionUtils.isEmpty(parentIds)) {
+						if (parentIds.size() > 2) {
+							auth.setTopDept(parentIds.get(1));
+						} else {
+							auth.setTopDept(Long.valueOf(deptIdStr));
 						}
 					}
 				}
-				auth.setUserDept(deptId);
-				auth.setProjectId(project.getId());
-				projectAuthService.save(auth);
 			}
+			auth.setUserDept(deptId);
+			auth.setProjectId(project.getId());
+			projectAuthService.save(auth);
 		}
 
 	}
@@ -108,6 +107,7 @@ public class AsyncServiceImpl implements IAsyncService {
 			R<User> userR = userClient.userInfoById(createUser);
 			if (userR.isSuccess()) {
 				List<TaskLog> logs = new ArrayList<>();
+				List<ProjectAuth> auths = new ArrayList<>();
 				TaskLog log = new TaskLog();
 				log.setTaskId(task.getId());
 				log.setContent(userR.getData().getName() + " 创建了任务");
@@ -117,8 +117,9 @@ public class AsyncServiceImpl implements IAsyncService {
 				log.setCreateTime(DateUtil.now());
 				log.setUpdateTime(DateUtil.now());
 				logs.add(log);
-				if (task.getOrgDeptId() != null) {
-					Long orgDeptId = task.getOrgDeptId();
+				Long orgDeptId = null;
+				if (task.getOrgDeptId() != null && task.getOrgDeptId() > 0L) {
+					orgDeptId = task.getOrgDeptId();
 					R<Dept> dept = sysClient.getDept(orgDeptId);
 					if (dept.isSuccess()) {
 						TaskLog taskLog = new TaskLog();
@@ -132,7 +133,7 @@ public class AsyncServiceImpl implements IAsyncService {
 						logs.add(taskLog);
 					}
 				}
-				if (task.getExecuteDept() != null) {
+				if (task.getExecuteDept() != null && task.getExecuteDept() > 0L) {
 					Long executeDept = task.getExecuteDept();
 					R<Dept> dept = sysClient.getDept(executeDept);
 					if (dept.isSuccess()) {
@@ -147,8 +148,9 @@ public class AsyncServiceImpl implements IAsyncService {
 						logs.add(taskLog);
 					}
 				}
-				if (task.getProjectManager() != null) {
+				if (task.getProjectManager() != null && task.getProjectManager() > 0L) {
 					Long projectManager = task.getProjectManager();
+					//1.任务动态
 					R<User> userR1 = userClient.userInfoById(projectManager);
 					if (userR1.isSuccess()) {
 						TaskLog taskLog = new TaskLog();
@@ -160,15 +162,39 @@ public class AsyncServiceImpl implements IAsyncService {
 						taskLog.setCreateTime(DateUtil.now());
 						taskLog.setUpdateTime(DateUtil.now());
 						logs.add(taskLog);
+
+						//2.项目权限
+						String deptStr = userR1.getData().getDeptId();
+						if (StringUtil.isNotBlank(deptStr) && orgDeptId != null) {
+							Long deptId = Func.firstLong(deptStr);
+							ProjectAuth auth = new ProjectAuth();
+							auth.setTopDept(orgDeptId);
+							auth.setUserDept(deptId);
+							auth.setProjectId(task.getProjectId());
+							auth.setUserId(projectManager);
+							auths.add(auth);
+						}
 					}
 				}
-				if (task.getExecuteUser() != null) {
+				if (StringUtil.isNotBlank(task.getExecuteUser())) {
 					List<Long> userIds = Func.toLongList(task.getExecuteUser());
 					List<String> str = new ArrayList<>();
+					Long finalOrgDeptId = orgDeptId;
 					userIds.forEach(userId -> {
 						R<User> rpc = userClient.userInfoById(userId);
 						if (rpc.isSuccess()) {
 							str.add(rpc.getData().getName());
+
+							String deptStr = rpc.getData().getDeptId();
+							if (StringUtil.isNotBlank(deptStr) && finalOrgDeptId != null) {
+								Long deptId = Func.firstLong(deptStr);
+								ProjectAuth auth = new ProjectAuth();
+								auth.setTopDept(finalOrgDeptId);
+								auth.setUserDept(deptId);
+								auth.setProjectId(task.getProjectId());
+								auth.setUserId(userId);
+								auths.add(auth);
+							}
 						}
 					});
 					if (!CollectionUtils.isEmpty(str)) {
@@ -183,7 +209,44 @@ public class AsyncServiceImpl implements IAsyncService {
 						logs.add(taskLog);
 					}
 				}
+
+				if (StringUtil.isNotBlank(task.getCheckUser())) {
+					List<Long> userIds = Func.toLongList(task.getCheckUser());
+					List<String> str = new ArrayList<>();
+					Long finalOrgDeptId1 = orgDeptId;
+					userIds.forEach(userId -> {
+						R<User> rpc = userClient.userInfoById(userId);
+						if (rpc.isSuccess()) {
+							str.add(rpc.getData().getName());
+
+							String deptStr = rpc.getData().getDeptId();
+							if (StringUtil.isNotBlank(deptStr) && finalOrgDeptId1 != null) {
+								Long deptId = Func.firstLong(deptStr);
+								ProjectAuth auth = new ProjectAuth();
+								auth.setTopDept(finalOrgDeptId1);
+								auth.setUserDept(deptId);
+								auth.setProjectId(task.getProjectId());
+								auth.setUserId(userId);
+								auths.add(auth);
+							}
+						}
+					});
+					if (!CollectionUtils.isEmpty(str)) {
+						TaskLog taskLog = new TaskLog();
+						taskLog.setTaskId(task.getId());
+						taskLog.setContent(userR.getData().getName() + " 指定了任务审查者 " + Func.join(str));
+						taskLog.setCreateDept(task.getCreateDept());
+						taskLog.setCreateUser(task.getCreateUser());
+						taskLog.setUpdateUser(task.getUpdateUser());
+						taskLog.setCreateTime(DateUtil.now());
+						taskLog.setUpdateTime(DateUtil.now());
+						logs.add(taskLog);
+					}
+				}
 				taskLogService.saveBatch(logs);
+				if (!CollectionUtils.isEmpty(auths)) {
+					projectAuthService.saveBatch(auths);
+				}
 			}
 		}
 		// todo 2.任务下发通知
@@ -195,9 +258,10 @@ public class AsyncServiceImpl implements IAsyncService {
 		R<User> userR = userClient.userInfoById(userId);
 		if (userR.isSuccess()) {
 			List<TaskLog> logs = new ArrayList<>();
+			List<ProjectAuth> auths = new ArrayList<>();
+			Long orgDeptId = task.getOrgDeptId();
 			switch (type) {
 				case 1:
-					Long orgDeptId = task.getOrgDeptId();
 					R<Dept> dept = sysClient.getDept(orgDeptId);
 					if (dept.isSuccess()) {
 						TaskLog log = new TaskLog();
@@ -239,6 +303,17 @@ public class AsyncServiceImpl implements IAsyncService {
 						log2.setCreateTime(DateUtil.now());
 						log2.setUpdateTime(DateUtil.now());
 						logs.add(log2);
+
+						String deptStr = userR1.getData().getDeptId();
+						if (StringUtil.isNotBlank(deptStr) && orgDeptId != null) {
+							Long deptId = Func.firstLong(deptStr);
+							ProjectAuth auth = new ProjectAuth();
+							auth.setTopDept(orgDeptId);
+							auth.setUserDept(deptId);
+							auth.setProjectId(task.getProjectId());
+							auth.setUserId(projectManager);
+							auths.add(auth);
+						}
 					}
 					break;
 				case 4:
@@ -248,6 +323,17 @@ public class AsyncServiceImpl implements IAsyncService {
 						R<User> rpc = userClient.userInfoById(id);
 						if (rpc.isSuccess()) {
 							str.add(rpc.getData().getName());
+
+							String deptStr = rpc.getData().getDeptId();
+							if (StringUtil.isNotBlank(deptStr) && orgDeptId != null) {
+								Long deptId = Func.firstLong(deptStr);
+								ProjectAuth auth = new ProjectAuth();
+								auth.setTopDept(orgDeptId);
+								auth.setUserDept(deptId);
+								auth.setProjectId(task.getProjectId());
+								auth.setUserId(id);
+								auths.add(auth);
+							}
 						}
 					});
 					if (!CollectionUtils.isEmpty(str)) {
@@ -262,9 +348,42 @@ public class AsyncServiceImpl implements IAsyncService {
 						logs.add(log3);
 					}
 					break;
-			}
+				case 5:
+					List<Long> checkUsers = Func.toLongList(task.getCheckUser());
+					List<String> checks = new ArrayList<>();
+					checkUsers.forEach(id -> {
+						R<User> rpc = userClient.userInfoById(id);
+						if (rpc.isSuccess()) {
+							checks.add(rpc.getData().getName());
 
+							String deptStr = rpc.getData().getDeptId();
+							if (StringUtil.isNotBlank(deptStr) && orgDeptId != null) {
+								Long deptId = Func.firstLong(deptStr);
+								ProjectAuth auth = new ProjectAuth();
+								auth.setTopDept(orgDeptId);
+								auth.setUserDept(deptId);
+								auth.setProjectId(task.getProjectId());
+								auth.setUserId(id);
+								auths.add(auth);
+							}
+						}
+					});
+					if (!CollectionUtils.isEmpty(checks)) {
+						TaskLog log4 = new TaskLog();
+						log4.setTaskId(task.getId());
+						log4.setContent(userR.getData().getName() + " 指定了任务审查者 " + Func.join(checks));
+						log4.setCreateDept(task.getCreateDept());
+						log4.setCreateUser(task.getCreateUser());
+						log4.setUpdateUser(task.getUpdateUser());
+						log4.setCreateTime(DateUtil.now());
+						log4.setUpdateTime(DateUtil.now());
+						logs.add(log4);
+					}
+			}
 			taskLogService.saveBatch(logs);
+			if (!CollectionUtils.isEmpty(auths)) {
+				projectAuthService.saveBatch(auths);
+			}
 		}
 	}
 

+ 2 - 6
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/ProjectAuthServiceImpl.java

@@ -18,12 +18,8 @@ import java.util.List;
 @AllArgsConstructor
 public class ProjectAuthServiceImpl extends BaseServiceImpl<ProjectAuthMapper, ProjectAuth> implements IProjectAuthService {
 	@Override
-	public List<ProjectAuth> getByDeptAndUser(Long deptId, Long userId) {
-		return baseMapper.selectByDeptAndUser(deptId, userId);
+	public List<ProjectAuth> getByDeptAndUser(Long topDept, Long deptId, Long userId) {
+		return baseMapper.selectByDeptAndUser(topDept, deptId, userId);
 	}
 
-	@Override
-	public List<ProjectAuth> getByTopDept(Long topDept, Long userId) {
-		return baseMapper.selectByTopDeptAndUser(topDept, userId);
-	}
 }

+ 72 - 74
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/ProjectServiceImpl.java

@@ -2,6 +2,7 @@ package com.wtkj.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.wtkj.dto.ProjectPageDTO;
 import com.wtkj.entity.Project;
 import com.wtkj.entity.ProjectAuth;
@@ -14,21 +15,20 @@ 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.Func;
 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.math.BigDecimal;
 import java.time.LocalDate;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Objects;
 import java.util.Set;
 import java.util.stream.Collectors;
 
-import static com.wtkj.config.MagicValue.STAFF_ADMIN;
+import static com.wtkj.config.MagicValue.*;
 
 /**
  * @author Blizzard
@@ -40,7 +40,6 @@ import static com.wtkj.config.MagicValue.STAFF_ADMIN;
 public class ProjectServiceImpl extends BaseServiceImpl<ProjectMapper, Project> implements IProjectService {
 
 	private final IAsyncService asyncService;
-	private final ISysClient sysClient;
 	private final IProjectAuthService projectAuthService;
 	private final ITaskService taskService;
 	private final ITaskContractService taskContractService;
@@ -62,7 +61,8 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectMapper, Project>
 
 	@Override
 	public IPage<Project> getPage(ProjectPageDTO dto, IPage<Project> page) {
-		LambdaQueryWrapper<Project> lqw = new LambdaQueryWrapper<>();
+		IPage<Project> projectIPage = new Page<>();
+		/*LambdaQueryWrapper<Project> lqw = new LambdaQueryWrapper<>();
 		//判断当前登录用户的身份 是业主还是服务机构
 		String deptIdStr = AuthUtil.getDeptId();
 		Long deptId = Long.valueOf(deptIdStr);
@@ -106,83 +106,81 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectMapper, Project>
 				}
 			}
 		}
-		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 {
-				//2.非业主
-				//主管单位
-				if (dto.getCompetentUnit() != null) {
-					lqw.eq(Project::getCompetentUnit, dto.getCompetentUnit());
+		return this.page(page, lqw);*/
+		//1.机构类型
+		Integer category = dto.getDeptCategory();
+		Long topDept = dto.getTopDept();
+		Set<Long> projectIds = new HashSet<>();
+		if (category != null) {
+			if (category.equals(3)) {
+				//1.1 是业主 ---> 项目权限表里 topDept 字段是自己的集合
+				List<ProjectAuth> auths = projectAuthService.getByDeptAndUser(topDept, null, null);
+				if (!CollectionUtils.isEmpty(auths)) {
+					Set<Long> ids = auths.stream().map(ProjectAuth::getProjectId).filter(Objects::nonNull).collect(Collectors.toSet());
+					projectIds.addAll(ids);
 				}
-				//如果不是业主 ---> 判断是否是服务商
-				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 if (category.equals(4)) {
+				String role = AuthUtil.getUserRole();
+				Long deptId = Func.firstLong(AuthUtil.getDeptId());
+				Long userId = AuthUtil.getUserId();
+				//1.2 是服务机构
+				if (role != null) {
+					if (role.contains(STAFF_ADMIN)) {
+						// 1.2.1 机构管理员 ---> 项目权限表里 topDept 字段是自己的集合
+						List<ProjectAuth> auths = projectAuthService.getByDeptAndUser(topDept, null, null);
+						if (!CollectionUtils.isEmpty(auths)) {
+							Set<Long> ids = auths.stream().map(ProjectAuth::getProjectId).filter(Objects::nonNull).collect(Collectors.toSet());
+							projectIds.addAll(ids);
 						}
-					} 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)) {
-							//是普通员工
+					} else if (role.contains(STAFF_SECOND_ADMIN)) {
+						// 1.2.2 次级机构主管  ---> 项目权限表里 userDept 字段是自己的集合
+						List<ProjectAuth> auths = projectAuthService.getByDeptAndUser(topDept, deptId, null);
+						if (!CollectionUtils.isEmpty(auths)) {
+							Set<Long> ids = auths.stream().map(ProjectAuth::getProjectId).filter(Objects::nonNull).collect(Collectors.toSet());
+							projectIds.addAll(ids);
+						}
+					} else if (role.contains(STAFF_USER) || role.contains(STAFF_PROJECT_MANAGER)) {
+						//1.2.3 普通员工和项目经理   --->项目权限表里 userId 是自己的
+						List<ProjectAuth> auths = projectAuthService.getByDeptAndUser(topDept, deptId, userId);
+						if (!CollectionUtils.isEmpty(auths)) {
+							Set<Long> ids = auths.stream().map(ProjectAuth::getProjectId).filter(Objects::nonNull).collect(Collectors.toSet());
+							projectIds.addAll(ids);
 						}
 					}
 				}
 			}
 		}
-		//待完成任务数排序
-		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);
+		if (!CollectionUtils.isEmpty(projectIds)) {
+			LambdaQueryWrapper<Project> lqw = new LambdaQueryWrapper<>();
+			//年份
+			lqw.eq(dto.getYear() != null, 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());
+			}
+			//协作单位
+			lqw.like(StringUtil.isNotBlank(dto.getCooperationUint()), Project::getCooperationUint, dto.getCooperationUint());
+			//主管单位
+			lqw.eq(dto.getCompetentUnit() != null, Project::getCompetentUnit, dto.getCompetentUnit());
+
+			lqw.in(Project::getId, projectIds);
+
+			//任务数量降序
+			if (dto.getTodoAsc().equals(1)) {
+				lqw.orderByDesc(Project::getTodoTask);
+			} else {
+				lqw.orderByAsc(Project::getTodoTask);
+			}
+			// todo 截至时间降序
+			projectIPage = this.page(page, lqw);
 		}
 
-		return this.page(page, lqw);*/
+		return projectIPage;
+
 	}
 
 	@Override

+ 29 - 12
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/QrcodeServiceImpl.java

@@ -3,18 +3,17 @@ package com.wtkj.service.impl;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.wtkj.entity.ContactOuter;
+import com.wtkj.entity.Project;
 import com.wtkj.entity.ProjectAuth;
 import com.wtkj.entity.ProjectGroup;
-import com.wtkj.service.IContactOuterService;
-import com.wtkj.service.IProjectAuthService;
-import com.wtkj.service.IProjectGroupService;
-import com.wtkj.service.IQrcodeService;
+import com.wtkj.service.*;
 import io.seata.spring.annotation.GlobalTransactional;
 import lombok.AllArgsConstructor;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.redis.cache.BladeRedis;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
 import org.springblade.system.user.feign.IUserClient;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -38,6 +37,7 @@ public class QrcodeServiceImpl implements IQrcodeService {
 	private final IProjectAuthService projectAuthService;
 	private final IProjectGroupService projectGroupService;
 	private final IContactOuterService contactOuterService;
+	private final IProjectService projectService;
 
 	@Override
 	public JSONObject createQrcode() {
@@ -70,32 +70,49 @@ public class QrcodeServiceImpl implements IQrcodeService {
 				contact.setUserId(createUser);
 				contactOuterService.save(contact);
 			}
-
 		}
 		return flag;
 	}
 
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public boolean inviteToProject(String qrcodeId, Long ownerDept, Long deptId, Long projectId) {
+	public boolean inviteToProject(String qrcodeId, Long deptId, Long projectId) {
 		boolean flag = false;
 		boolean exist = isExist(qrcodeId);
 		if (exist) {
-			//1.权限 2.项目组
+			//1.权限 2.联系人 3.项目组
 			ProjectAuth auth = new ProjectAuth();
 			auth.setProjectId(projectId);
 			auth.setTopDept(deptId);
+			auth.setUserDept(Func.firstLong(AuthUtil.getDeptId()));
+			auth.setUserId(auth.getUserId());
 			projectAuthService.save(auth);
 
-			ProjectGroup group = new ProjectGroup();
-			group.setProjectId(projectId);
-			group.setInviteDept(ownerDept);
-			group.setBeInvitedDept(deptId);
-			flag = projectGroupService.save(group);
+			// todo  联系人
+
+			Project project = projectService.getById(projectId);
+			if (project != null) {
+				ProjectGroup group = new ProjectGroup();
+				group.setProjectId(projectId);
+				group.setInviteDept(project.getCompetentUnit());
+				group.setBeInvitedDept(deptId);
+				flag = projectGroupService.save(group);
+			}
 		}
 		return flag;
 	}
 
+	@Override
+	public JSONObject createGroupQrcode(Long projectId) {
+		JSONObject res = new JSONObject();
+		String kv = IdWorker.getIdStr();
+		redis.setEx(kv, 0, Duration.ofSeconds(expireIn));
+		res.put("createUser", AuthUtil.getUser());
+		res.put("projectId", projectId);
+		res.put("qrcodeId", kv);
+		return res;
+	}
+
 	/**
 	 * 判断二维码是否有效和是否达到扫描上限
 	 */

+ 13 - 5
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/TaskServiceImpl.java

@@ -49,30 +49,38 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
 		boolean flag = false;
 		Long taskId = task.getId();
 		if (taskId == null) {
+			LocalDate now = LocalDate.now();
+			Integer year = now.getYear();
+			Integer month = now.getMonthValue();
+			task.setYear(year);
+			task.setMonth(month);
 			flag = this.save(task);
 			asyncService.createTaskLog(task);
 		} else {
-			//todo 任务状态处理
 			//执行的顶级单位
 			Long userId = AuthUtil.getUserId();
 			Task byId = this.getById(taskId);
 			if (byId != null) {
 				//1.指定了执行单位
-				if (byId.getOrgDeptId() == null && task.getOrgDeptId() != null) {
+				if ((byId.getOrgDeptId() == null || byId.getOrgDeptId() < 0L) && task.getOrgDeptId() != null && task.getOrgDeptId() > 0L) {
 					asyncService.updateTask(1, userId, task);
 				}
 				//2.指定任务执行部门
-				if (byId.getExecuteDept() == null && task.getExecuteDept() != null) {
+				if ((byId.getExecuteDept() == null || byId.getExecuteDept() < 0L) && task.getExecuteDept() != null && task.getExecuteDept() > 0L) {
 					asyncService.updateTask(2, userId, task);
 				}
 				//3.指定项目经理
-				if (byId.getProjectManager() == null && task.getProjectManager() != null) {
+				if ((byId.getProjectManager() == null || byId.getProjectManager() < 0L) && task.getProjectManager() != null && task.getProjectManager() > 0L) {
 					asyncService.updateTask(3, userId, task);
 				}
 				//4.指定任务执行者
-				if (byId.getExecuteUser() == null && task.getExecuteUser() != null) {
+				if (StringUtil.isBlank(byId.getExecuteUser()) && StringUtil.isNotBlank(task.getExecuteUser())) {
 					asyncService.updateTask(4, userId, task);
 				}
+				//5.指定任务审查者
+				if (StringUtil.isBlank(byId.getCheckUser()) && StringUtil.isNotBlank(task.getCheckUser())) {
+					asyncService.updateTask(5, userId, task);
+				}
 			}
 			flag = this.updateById(task);
 		}

+ 1 - 9
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/WorkStatusServiceImpl.java

@@ -7,10 +7,7 @@ import com.wtkj.service.IWorkStatusService;
 import com.wtkj.vo.WorkStatusVO;
 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.BeanUtil;
-import org.springblade.system.user.entity.User;
 import org.springblade.system.user.feign.IUserClient;
 import org.springframework.stereotype.Service;
 
@@ -28,9 +25,8 @@ public class WorkStatusServiceImpl extends BaseServiceImpl<WorkStatusMapper, Wor
 	private final IUserClient userClient;
 
 	@Override
-	public WorkStatusVO workStatus() {
+	public WorkStatusVO workStatus(Long userId) {
 		WorkStatusVO vo = new WorkStatusVO();
-		Long userId = AuthUtil.getUserId();
 		LambdaQueryWrapper<WorkStatus> lqw = new LambdaQueryWrapper<>();
 		lqw.eq(WorkStatus::getUserId, userId);
 		lqw.orderByDesc(WorkStatus::getCreateTime);
@@ -39,10 +35,6 @@ public class WorkStatusServiceImpl extends BaseServiceImpl<WorkStatusMapper, Wor
 		if (one != null) {
 			vo = Objects.requireNonNull(BeanUtil.copy(one, WorkStatusVO.class));
 		}
-		R<User> userR = userClient.userInfoById(userId);
-		if (userR.isSuccess()) {
-			vo.setUser(userR.getData());
-		}
 		return vo;
 	}
 }