Browse Source

Merge remote-tracking branch 'origin/master'

master
PoffyZhang 1 year ago
parent
commit
1a54d94c85
6 changed files with 123 additions and 54 deletions
  1. +66
    -15
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java
  2. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java
  3. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/req/ToBeProcessedReq.java
  4. +38
    -26
      pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java
  5. +0
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/user/model/po/ReqUserDisableOrEnablePO.java
  6. +15
    -11
      pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java

+ 66
- 15
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java View File

@@ -64,6 +64,7 @@ import com.wflow.workflow.bean.vo.ProcessDetailVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

@@ -213,11 +214,7 @@ public class ProjectLibManage {
String employeeCode, Project oldProject) {

Project project = saveConstructProjectNewVersion(projectDto,instanceId,employeeCode,oldProject);

// 将旧的项目状态、阶段置为null,版本置为不是最新
oldProject.setNewest(Boolean.FALSE);
projectService.updateById(oldProject);

// 将旧的项目状态、阶段置为null,防止项目还会出现在待申报列表
LambdaUpdateWrapper<Project> updateWrapper = Wrappers.lambdaUpdate(Project.class);
updateWrapper.set(Project::getStage,null)
.set(Project::getStatus,null)
@@ -314,6 +311,8 @@ public class ProjectLibManage {
//为空 代表是新申报的
if(Objects.isNull(projectDto.getId())){
BeanUtils.copyProperties(projectDto, project);
// 被撤回重新申报的项目,项目ID要置空
project.setId(null);
project.setCreateOn(LocalDateTime.now());
project.setUpdateOn(LocalDateTime.now());
project.setStage(ProjectStatusEnum.NOT_APPROVED.getCode());
@@ -326,10 +325,21 @@ public class ProjectLibManage {
// 标记为建设方案申报
project.setIsConstruct(Boolean.TRUE);
// 保存初步方案项目ID
project.setPrePlanProjectId(oldProject.getId());
if (Boolean.TRUE.equals(oldProject.getIsConstruct())){
// 重新提交
project.setPrePlanProjectId(oldProject.getPrePlanProjectId());
}else {
project.setPrePlanProjectId(oldProject.getId());
}
projectService.save(project);

// 将旧的项目版本置为不是最新
projectService.update(Wrappers.lambdaUpdate(Project.class)
.set(Project::getNewest,Boolean.FALSE)
.ne(Project::getId,project.getId())
.eq(Project::getProjectCode,project.getProjectCode()));
}else{
//否则是重新提交的 新生成一个新版本的项目
//否则是被驳回,重新提交的 新生成一个新版本的项目
project = newProjectWithVersion(projectDto);
if(Objects.nonNull(project)){
project.setInstCode(instanceId);
@@ -341,6 +351,15 @@ public class ProjectLibManage {
//保存项目应用
Boolean isApp = Objects.nonNull(projectDto.getIncludeApplication()) && CommonEnum.YES.getCode().equals(projectDto.getIncludeApplication())
? Boolean.TRUE : Boolean.FALSE;
//采取批量删除 批量添加的方式 批量删除建设方案申报后的应用信息
List<Long> projectIdList = projectService.list(Wrappers.lambdaQuery(Project.class)
.eq(Project::getProjectCode, oldProject.getProjectCode())
.eq(Project::getIsConstruct, Boolean.TRUE)).stream()
.map(Project::getId).collect(Collectors.toList());
projectApplicationService.remove(Wrappers.lambdaQuery(ProjectApplication.class)
.eq(ProjectApplication::getProjectCode,oldProject.getProjectCode())
.in(ProjectApplication::getProjectId,projectIdList));

if (isApp && CollUtil.isNotEmpty(projectDto.getApplicationList())) {
Project finalProject = project;
List<ProjectApplication> applications = projectDto.getApplicationList().stream().map(application -> {
@@ -353,7 +372,7 @@ public class ProjectLibManage {
projectApplication.setBuildOrgName(finalProject.getBuildOrgName());
return projectApplication;
}).collect(Collectors.toList());
projectApplicationService.saveOrUpdateBatch(applications);
projectApplicationService.saveBatch(applications);
}
return project;
} catch (Exception e) {
@@ -454,11 +473,14 @@ public class ProjectLibManage {
.ne(Project::getId,project.getId())
.eq(Project::getProjectCode,project.getProjectCode()));

//采取批量删除 批量添加的方式
//采取批量删除 批量添加的方式 批量删除建设方案申报后的应用信息
List<Long> projectIdList = projectService.list(Wrappers.lambdaQuery(Project.class)
.eq(Project::getProjectCode, project.getProjectCode())
.eq(Project::getIsConstruct, Boolean.TRUE)).stream()
.map(Project::getId).collect(Collectors.toList());
projectApplicationService.remove(Wrappers.lambdaQuery(ProjectApplication.class)
.eq(ProjectApplication::getProjectId,project.getId()));
projectApplicationService.remove(Wrappers.lambdaQuery(ProjectApplication.class)
.eq(ProjectApplication::getProjectCode,project.getProjectCode()));
.eq(ProjectApplication::getProjectCode,project.getProjectCode())
.in(ProjectApplication::getProjectId,projectIdList));

//app
List<ProjectApplicationDTO> applicationList = projecDto.getApplicationList();
@@ -652,7 +674,27 @@ public class ProjectLibManage {
// 查询应用
List<ProjectApplication> applications = applicationService.list(Wrappers.lambdaQuery(ProjectApplication.class)
.eq(ProjectApplication::getProjectCode, vo.getProjectCode()));
Optional.ofNullable(applications).ifPresent(apps ->

// 查出同一项目编号,建设方案申报前的项目ID
List<Long> projectIdList = projectService.list(Wrappers.lambdaQuery(Project.class)
.eq(Project::getProjectCode, projectInfo.getProjectCode())
.eq(Project::getIsConstruct, Boolean.FALSE)).stream()
.map(Project::getId).collect(Collectors.toList());
List<ProjectApplication> applicationList;
// 如果是建设方案申报后的项目,过滤掉初步方案的应用信息
if (Boolean.TRUE.equals(projectInfo.getIsConstruct())){
applicationList = applications.stream()
.filter(a -> !projectIdList.contains(a.getProjectId()))
.collect(Collectors.toList());
}
// 如果不是,展示初步方案的应用信息
else {
applicationList = applications.stream()
.filter(a -> projectIdList.contains(a.getProjectId()))
.collect(Collectors.toList());
}

Optional.ofNullable(applicationList).ifPresent(apps ->
vo.setProjectApplications(CollUtils.convert(apps,
ProjectHelper::convertVO)
));
@@ -739,8 +781,17 @@ public class ProjectLibManage {
vo.buildDynamicForm(projectInfo.getDynamicForm());
// 查询应用
List<ProjectApplication> applications = applicationService.list(Wrappers.lambdaQuery(ProjectApplication.class)
.eq(ProjectApplication::getProjectId, vo.getId()));
Optional.ofNullable(applications).ifPresent(apps ->
.eq(ProjectApplication::getProjectCode, vo.getProjectCode()));
// 查出同一项目编号,建设方案申报前的项目ID
List<Long> projectIdList = projectService.list(Wrappers.lambdaQuery(Project.class)
.eq(Project::getProjectCode, projectInfo.getProjectCode())
.eq(Project::getIsConstruct, Boolean.FALSE)).stream()
.map(Project::getId).collect(Collectors.toList());
List<ProjectApplication> applicationList = applications.stream()
.filter(a -> projectIdList.contains(a.getProjectId()))
.collect(Collectors.toList());

Optional.ofNullable(applicationList).ifPresent(apps ->
vo.setProjectApplications(CollUtils.convert(apps,
ProjectHelper::convertVO)
));


+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java View File

@@ -148,7 +148,7 @@ public class TodoCenterManage {
String employeeCode = param.getEmployeeCode();
if(StringUtils.isBlank(employeeCode)){
// 获取登录用户ID
Long userId = LoginUserUtil.getUserId();
Long userId = Optional.ofNullable(param.getLoginUserId()).orElseGet(LoginUserUtil::getUserId);
// 获取登录用户全量信息
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId);
// 获取员工浙政钉code


+ 3
- 0
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/req/ToBeProcessedReq.java View File

@@ -48,4 +48,7 @@ public class ToBeProcessedReq extends PagePo implements Serializable {

@ApiModelProperty("登录人员工号")
private String employeeCode;

private Long loginUserId;

}

+ 38
- 26
pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java View File

@@ -12,6 +12,7 @@ import com.ningdatech.pmapi.common.constant.RegionConst;
import com.ningdatech.pmapi.common.helper.RegionCacheHelper;
import com.ningdatech.pmapi.common.helper.UserInfoHelper;
import com.ningdatech.pmapi.common.util.BizUtils;
import com.ningdatech.pmapi.common.util.StrUtils;
import com.ningdatech.pmapi.ding.constants.DingOrganizationContant;
import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo;
import com.ningdatech.pmapi.organization.model.entity.DingOrganization;
@@ -37,6 +38,7 @@ import com.ningdatech.zwdd.ZwddIntegrationProperties;
import com.ningdatech.zwdd.client.ZwddClient;
import com.wflow.workflow.bean.dto.ProcessInstanceUserDto;
import lombok.RequiredArgsConstructor;
import org.springframework.aop.framework.AopContext;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@@ -85,7 +87,7 @@ public class UserInfoManage {
.like(StringUtils.isNotBlank(phoneNo), UserInfo::getMobile, phoneNo)
.like(StringUtils.isNotBlank(name), UserInfo::getRealName, name)
.in(Objects.nonNull(userIdList), UserInfo::getId, userIdList)
.eq(Objects.nonNull(regionId), UserInfo::getRegionCode,regionId)
.eq(Objects.nonNull(regionId), UserInfo::getRegionCode, regionId)
.like(StringUtils.isNotBlank(orgName), UserInfo::getEmpPosUnitName, orgName)
.eq(StringUtils.isNotBlank(orgCode), UserInfo::getEmpPosUnitCode, orgCode)
.orderByDesc(UserInfo::getUpdateOn);
@@ -188,7 +190,7 @@ public class UserInfoManage {
* @param userRoleList
*/
private List<Long> getRoleCompliantUserIdList(List<UserRoleVO> userRoleList) {
if(CollUtil.isNotEmpty(userRoleList)){
if (CollUtil.isNotEmpty(userRoleList)) {
userRoleList = userRoleList.stream().filter(r -> Objects.nonNull(r.getId())).collect(Collectors.toList());
}
if (CollUtil.isEmpty(userRoleList)) {
@@ -250,12 +252,21 @@ public class UserInfoManage {
return userRoleInfoList;
}

public void disableOrEnable(ReqUserDisableOrEnablePO reqUserDisableOrEnablePO) {
Long userId = generateUserId(reqUserDisableOrEnablePO.getEmployeeCode());
@Transactional(rollbackFor = Exception.class)
public void disableOrEnable(ReqUserDisableOrEnablePO req) {
Long userId;
if (req.getUserId() != null) {
userId = req.getUserId();
} else if (StrUtils.isNotBlank(req.getEmployeeCode())) {
UserInfoManage proxy = (UserInfoManage) AopContext.currentProxy();
userId = proxy.generateUserId(req.getEmployeeCode());
} else {
throw BizException.wrap("用户参数缺失");
}
UserInfo userInfo = iUserInfoService.getById(userId);
userInfo.setAvailable(reqUserDisableOrEnablePO.getOperation());
userInfo.setAvailable(req.getOperation());
iUserInfoService.updateById(userInfo);
if (userInfo.getAvailable().equals("DISABLE")) {
if ("DISABLE".equals(userInfo.getAvailable())) {
userAuthManage.kickOff(userId);
}

@@ -353,24 +364,24 @@ public class UserInfoManage {
String mobile = userInfo.getMobile();
Long userId = userInfo.getId();
// if (StringUtils.isBlank(mobile)) {
// 校验手机号是否重复
UserInfo repeatMobileUserInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class)
.eq(UserInfo::getMobile, reqUserDetailEditPO.getPhoneNo()).ne(UserInfo::getId, userId));
if (Objects.nonNull(repeatMobileUserInfo)) {
throw new BizException("该手机号码已被绑定,请问重复绑定");
}
String phoneNo = reqUserDetailEditPO.getPhoneNo();
userInfo.setMobile(phoneNo);
// 更新浙政钉相关数据
if (StringUtils.isNotBlank(phoneNo)) {
iDingEmployeeInfoService
.update(Wrappers.lambdaUpdate(DingEmployeeInfo.class)
.eq(DingEmployeeInfo::getMainJob, "true")
.eq(DingEmployeeInfo::getEmployeeCode, employeeCode)
.set(DingEmployeeInfo::getBindUserMobile, phoneNo));
iUserInfoService.updateById(userInfo);
}
// 校验手机号是否重复
UserInfo repeatMobileUserInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class)
.eq(UserInfo::getMobile, reqUserDetailEditPO.getPhoneNo()).ne(UserInfo::getId, userId));
if (Objects.nonNull(repeatMobileUserInfo)) {
throw new BizException("该手机号码已被绑定,请问重复绑定");
}
String phoneNo = reqUserDetailEditPO.getPhoneNo();
userInfo.setMobile(phoneNo);
// 更新浙政钉相关数据
if (StringUtils.isNotBlank(phoneNo)) {
iDingEmployeeInfoService
.update(Wrappers.lambdaUpdate(DingEmployeeInfo.class)
.eq(DingEmployeeInfo::getMainJob, "true")
.eq(DingEmployeeInfo::getEmployeeCode, employeeCode)
.set(DingEmployeeInfo::getBindUserMobile, phoneNo));
iUserInfoService.updateById(userInfo);
}
// }

}
@@ -450,13 +461,14 @@ public class UserInfoManage {

//生成头像 链接
private String makeAvatar(String avatar) {
try{
try {
GenericResult<String> accessToken = zwddClient.getAccessToken();
String token = accessToken.getData();
String res = "https://" + zwddIntegrationProperties.getDomain() + "/media/download?" +
"access_token=" + token + "&media_id=" + avatar;
return res;
}catch (Exception e){}
} catch (Exception e) {
}
return org.apache.commons.lang3.StringUtils.EMPTY;
}



+ 0
- 1
pmapi/src/main/java/com/ningdatech/pmapi/user/model/po/ReqUserDisableOrEnablePO.java View File

@@ -18,7 +18,6 @@ public class ReqUserDisableOrEnablePO {
@ApiModelProperty("用户id")
private Long userId;

@NotBlank(message = "浙政钉 用户编码 不能为空")
@ApiModelProperty("浙政钉 用户编码")
private String employeeCode;



+ 15
- 11
pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java View File

@@ -5,6 +5,7 @@ import com.ningdatech.pmapi.projectdeclared.manage.DeclaredProjectManage;
import com.ningdatech.pmapi.projectdeclared.manage.DefaultDeclaredProjectManage;
import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage;
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq;
import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO;
import com.ningdatech.pmapi.sys.manage.NoticeManage;
import com.ningdatech.pmapi.sys.model.req.NoticeListReq;
import com.ningdatech.pmapi.todocenter.manage.TodoCenterManage;
@@ -17,6 +18,8 @@ import com.ningdatech.pmapi.workbench.converter.WorkbenchConverter;
import com.ningdatech.pmapi.workbench.model.vo.WorkbenchVO;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ForkJoinPool;
import java.util.stream.Collectors;
@@ -43,30 +46,32 @@ public class WorkbenchManage {

private final ProjectLibManage projectLibManage;

public WorkbenchVO getWorkbenchData(Integer year){
public WorkbenchVO getWorkbenchData(Integer year) {
WorkbenchVO res = new WorkbenchVO();
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId());
Long userId = LoginUserUtil.getUserId();
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(userId);

CompletableFuture.allOf(
CompletableFuture.runAsync(()-> {
CompletableFuture.runAsync(() -> {
//1.待办中心数据
TodoCenterStatisticsVO statisticsVO = todoCenterManage.todoCenterStatistics(user.getEmployeeCode());
ToBeProcessedReq toBeProcessedReq = new ToBeProcessedReq();
toBeProcessedReq.setPageNumber(1);
toBeProcessedReq.setPageSize(5);
toBeProcessedReq.setLoginUserId(userId);
toBeProcessedReq.setEmployeeCode(user.getEmployeeCode());
statisticsVO.setTodoList(todoCenterManage.todoProjectList(toBeProcessedReq).getRecords()
.stream().map(v -> WorkbenchConverter.convert(v)).collect(Collectors.toList()));
.stream().map(WorkbenchConverter::convert).collect(Collectors.toList()));
res.setTodoCerter(statisticsVO);
}, ForkJoinPool.commonPool()),
CompletableFuture.runAsync(()-> {
CompletableFuture.runAsync(() -> {
//2.项目统计数据
res.setOrgDeclared(WorkbenchConverter.convert(defaultDeclaredProjectManage.declaredProjectOrgStatistics(year,user)));
if(userInfoHelper.isSuperOrRegionAdmin(user.getUserId())){
res.setRegionDeclared(WorkbenchConverter.convert(defaultDeclaredProjectManage.declaredProjectRegionStatistics(year,user)));
res.setOrgDeclared(WorkbenchConverter.convert(defaultDeclaredProjectManage.declaredProjectOrgStatistics(year, user)));
if (userInfoHelper.isSuperOrRegionAdmin(user.getUserId())) {
res.setRegionDeclared(WorkbenchConverter.convert(defaultDeclaredProjectManage.declaredProjectRegionStatistics(year, user)));
}
}, ForkJoinPool.commonPool()),
CompletableFuture.runAsync(()-> {
CompletableFuture.runAsync(() -> {
//3.所有公告按类型分
NoticeListReq noticeListReq = new NoticeListReq();
noticeListReq.setPageNumber(1);
@@ -81,8 +86,7 @@ public class WorkbenchManage {
projectListReq.setPageSize(5);
projectListReq.setProjectYear(year);
projectListReq.setBuildOrgCode(user.getEmpPosUnitCode());
res.setProjects(projectLibManage.projectLibListWithPermission(projectListReq,user).getRecords().stream().collect(Collectors.toList()));

res.setProjects(new ArrayList<>(projectLibManage.projectLibListWithPermission(projectListReq, user).getRecords()));
return res;
}
}

Loading…
Cancel
Save