This commit is contained in:
zt
2025-09-28 16:25:42 +08:00
parent eb6a7f2373
commit d644df94dc
6 changed files with 153 additions and 4 deletions

View File

@ -131,8 +131,13 @@ public interface UserService {
String selectAvatarById(Long userId);
/**
* 通过用户id查询头像
* 通过用户id查询用户信息
*/
UserDTO selectUser(Long userId);
/**
* 查询对应专业的用户Id
*/
List<String> selectUserByProfession(String code,String businessId,String type,Long projectId);
}

View File

@ -99,4 +99,6 @@ public interface IDesUserService extends IService<DesUser>{
Long getCount(String principal, String specialty, Long projectId);
void exportExcelByProjectId(Long deptId, HttpServletResponse response);
List<Long> selectbySpecialtyAndType(String specialty, String type, Long projectId);
}

View File

@ -1,5 +1,6 @@
package org.dromara.design.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.poi.ss.usermodel.*;
@ -15,6 +16,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.dromara.design.domain.dto.desUser.DesUserBatchDto;
import org.dromara.project.domain.BusUserProjectRelevancy;
import org.dromara.project.service.IBusUserProjectRelevancyService;
import org.dromara.system.domain.SysUserRole;
import org.dromara.system.domain.bo.SysUserBo;
import org.dromara.system.domain.vo.SysDictDataVo;
@ -54,6 +57,8 @@ public class DesUserServiceImpl extends ServiceImpl<DesUserMapper, DesUser> impl
private final ISysRoleService roleService;
private final IBusUserProjectRelevancyService userProjectRelevancyService;
/**
* 查询设计人员
*
@ -171,6 +176,9 @@ public class DesUserServiceImpl extends ServiceImpl<DesUserMapper, DesUser> impl
ArrayList<String> userIds = new ArrayList<>();
List<SysUserRole> sysUserRoles = new ArrayList<>();
for (DesUserBo bo : dto.getList()) {
if(bo.getUserId()==null){
continue;
@ -194,6 +202,25 @@ public class DesUserServiceImpl extends ServiceImpl<DesUserMapper, DesUser> impl
userIds.add(sysUserRole.getUserId()+"-"+sysUserRole.getRoleId());
}
roleService.insertUserRoleBatch(sysUserRoles);
//项目关联
// 删除用户与项目的关联
Set<Long> list1 = sysUserRoles.stream().map(SysUserRole::getUserId).collect(Collectors.toSet());
if(CollectionUtil.isNotEmpty(list1)){
userProjectRelevancyService.remove(new LambdaQueryWrapper<>(BusUserProjectRelevancy.class)
.in(BusUserProjectRelevancy::getUserId, list1)
.eq(BusUserProjectRelevancy::getProjectId, dto.getProjectId())
);
ArrayList<BusUserProjectRelevancy> busUserProjectRelevancies = new ArrayList<>();
for (Long userId : list1) {
BusUserProjectRelevancy relevancy = new BusUserProjectRelevancy();
relevancy.setUserId(userId);
relevancy.setProjectId(dto.getProjectId());
relevancy.setUserType("2");
busUserProjectRelevancies.add(relevancy);
}
userProjectRelevancyService.saveBatch(busUserProjectRelevancies);
}
//todo:发消息
return saveBatch(desUsers);
}
@ -473,4 +500,16 @@ public class DesUserServiceImpl extends ServiceImpl<DesUserMapper, DesUser> impl
validation.setShowErrorBox(true);
mainSheet.addValidationData(validation);
}
@Override
public List<Long> selectbySpecialtyAndType(String specialty, String type, Long projectId) {
List<DesUser> desUsers = baseMapper.selectList(Wrappers.<DesUser>lambdaQuery()
.eq(DesUser::getUserMajor, specialty)
.eq(DesUser::getUserType, type)
.eq(DesUser::getProjectId, projectId)
);
return desUsers.stream().map(DesUser::getUserId).collect(Collectors.toList());
}
}

View File

@ -493,6 +493,12 @@ public class DesVolumeFileServiceImpl extends ServiceImpl<DesVolumeFileMapper, D
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean deleteByIds(Collection<Long> ids) {
try {
ossService.deleteWithValidByIds(ids,false);
}catch (Exception e){
log.error("删除卷册文件存储失败",e);
}
return this.removeBatchByIds(ids);
}

View File

@ -29,6 +29,13 @@ import org.dromara.contractor.domain.SubConstructionUser;
import org.dromara.contractor.domain.SubContractor;
import org.dromara.contractor.service.ISubConstructionUserService;
import org.dromara.contractor.service.ISubContractorService;
import org.dromara.design.domain.DesDesignChange;
import org.dromara.design.domain.DesVolumeCatalog;
import org.dromara.design.domain.DesVolumeFile;
import org.dromara.design.service.IDesDesignChangeService;
import org.dromara.design.service.IDesUserService;
import org.dromara.design.service.IDesVolumeCatalogService;
import org.dromara.design.service.IDesVolumeFileService;
import org.dromara.project.domain.BusUserProjectRelevancy;
import org.dromara.project.service.IBusUserProjectRelevancyService;
import org.dromara.system.domain.*;
@ -77,6 +84,22 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
private final ISubContractorService contractorService;
@Lazy
@Resource
private IDesVolumeCatalogService volumeCatalogService;
@Lazy
@Resource
private IDesVolumeFileService volumeFileService;
@Lazy
@Resource
private IDesDesignChangeService desDesignChangeService;
@Lazy
@Resource
private IDesUserService desUserService;
@Lazy
@Resource
private ISysUserFileService userFileService;
@ -1220,4 +1243,27 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
}
return userDTO;
}
@Override
public List<String> selectUserByProfession(String code, String businessId,String type,Long projectId) {
//procDesignFile 过程图纸
//bpDesignFile 蓝图审核
//moneydesignchanged 资金设计变更管理
//designchanged 设计变更审批
String specialty = null;
if("procDesignFile".equals(code) || "bpDesignFile".equals(code)){
DesVolumeFile volumeFile = volumeFileService.getById(businessId);
DesVolumeCatalog volumeCatalog = volumeCatalogService.getById(volumeFile.getVolumeCatalogId());
specialty = volumeCatalog.getSpecialty();
} else if ("moneydesignchanged".equals(code) || "designchanged".equals(code)) {
DesDesignChange desDesignChange = desDesignChangeService.getById(businessId);
specialty = desDesignChange.getSpecialty();
}
if(specialty == null){
return null;
}
List<Long> longs = desUserService.selectbySpecialtyAndType(specialty, type,projectId);
return longs.stream().map(String::valueOf).toList();
}
}

View File

@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.domain.dto.UserDTO;
import org.dromara.common.core.domain.model.LoginUser;
import org.dromara.common.core.enums.BusinessStatusEnum;
import org.dromara.common.core.service.UserService;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.warm.flow.core.FlowEngine;
import org.dromara.warm.flow.core.dto.FlowParams;
@ -54,6 +55,19 @@ public class WorkflowGlobalListener implements GlobalListener {
private final IFlwCommonService flwCommonService;
private final InsService insService;
private final IFlwTaskAssigneeService flwTaskAssigneeService;
private final UserService userService;
// 需要分专业的角色
// 1961314792461586433 校审员(系统)
// 1961315028017893378 审核员(系统)
// 1961315147199041537 审定员(系统)
private static final List<String> roleList = Arrays.asList("role:1961314792461586433", "role:1961315028017893378", "role:1961315147199041537");
/**
* 创建监听器,任务创建时执行
@ -149,12 +163,22 @@ public class WorkflowGlobalListener implements GlobalListener {
permissionFlag = permissionFlag.replace("@@", ",");
String flowCode = definition.getFlowCode();
String projectId = flowCode.split("_")[0];
String[] split = flowCode.split("_");
String projectId = split[0];
List<UserDTO> userDTOS = flwTaskAssigneeService.fetchUsersByStorageIds(permissionFlag, Long.valueOf(projectId));
flowTask.setPermissionList(userDTOS.stream().map(UserDTO::getUserId).map(String::valueOf).collect(Collectors.toList()));
String type = getType(permissionFlag);
if(type != null){
try {
List<String> longs = userService.selectUserByProfession(split[1], instance.getBusinessId(), type,Long.valueOf(projectId));
flowTask.setPermissionList(longs);
}catch (Exception e) {
flowTask.setPermissionList(userDTOS.stream().map(UserDTO::getUserId).map(String::valueOf).collect(Collectors.toList()));
}
}else {
flowTask.setPermissionList(userDTOS.stream().map(UserDTO::getUserId).map(String::valueOf).collect(Collectors.toList()));
}
}
} catch (Exception e) {
log.error("设置失败: {}", e.getMessage());
@ -162,6 +186,33 @@ public class WorkflowGlobalListener implements GlobalListener {
}
}
public String getType(String permissionFlag){
// 1961314792461586433 校审员(系统)
// 1961315028017893378 审核员(系统)
// 1961315147199041537 审定员(系统)
String[] split = permissionFlag.split(",");
String roleId = null;
for (String s : split) {
if(roleList.contains(s)){
roleId = s.replace("role:", "");
}
}
if(roleId == null){
return null;
}
String type = null;
if("1961314792461586433".equals(roleId)){
type = "3";
}else if("1961315028017893378".equals(roleId)){
type = "5";
}else if("1961315147199041537".equals(roleId)){
type = "4";
}
return type;
}
/**
* 完成监听器,当前任务完成后执行
*