分包
This commit is contained in:
@ -187,6 +187,7 @@ public class SubConstructionUserServiceImpl extends ServiceImpl<SubConstructionU
|
||||
lqw.like(StringUtils.isNotBlank(userName), SubConstructionUser::getUserName, userName);
|
||||
lqw.isNull(SubConstructionUser::getProjectId);
|
||||
lqw.isNull(SubConstructionUser::getTeamId);
|
||||
lqw.eq(SubConstructionUser::getUserRole, "0");
|
||||
// 添加关联查询条件:sys_user的dept_id为null
|
||||
// 另一种写法,使用表别名
|
||||
lqw.apply("exists (select 1 from sys_user where user_id = sys_user_id and dept_id is null)");
|
||||
@ -235,6 +236,7 @@ public class SubConstructionUserServiceImpl extends ServiceImpl<SubConstructionU
|
||||
SysUserBo sysUserBo = new SysUserBo();
|
||||
sysUserBo.setUserId(sysUserId);
|
||||
sysUserBo.setDeptId(dto.getDeptId());
|
||||
sysUserBo.setContractorId(dto.getContractorId());
|
||||
userService.updateUser(sysUserBo);
|
||||
|
||||
//人员与班组关联表
|
||||
|
||||
@ -5,6 +5,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.docx4j.org.apache.xpath.operations.Bool;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
@ -18,10 +19,13 @@ import org.dromara.project.domain.dto.projectteam.BusProjectTeamCreateReq;
|
||||
import org.dromara.project.domain.dto.projectteam.BusProjectTeamQueryReq;
|
||||
import org.dromara.project.domain.dto.projectteam.BusProjectTeamUpdateReq;
|
||||
import org.dromara.project.domain.vo.BusProjectPunchrangeVo;
|
||||
import org.dromara.project.domain.vo.projectteam.BusProjectTeamAppVo;
|
||||
import org.dromara.project.domain.vo.projectteam.BusProjectTeamForemanVo;
|
||||
import org.dromara.project.domain.vo.projectteam.BusProjectTeamVo;
|
||||
import org.dromara.project.service.IBusProjectPunchrangeService;
|
||||
import org.dromara.project.service.IBusProjectTeamService;
|
||||
import org.dromara.system.domain.vo.SysUserVo;
|
||||
import org.dromara.system.service.ISysUserService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@ -42,6 +46,8 @@ public class BusProjectTeamController extends BaseController {
|
||||
private final IBusProjectTeamService busProjectTeamService;
|
||||
|
||||
private final IBusProjectPunchrangeService busProjectPunchrangeService;
|
||||
|
||||
private final ISysUserService userService;
|
||||
/**
|
||||
* 查询项目班组列表
|
||||
*/
|
||||
@ -127,4 +133,31 @@ public class BusProjectTeamController extends BaseController {
|
||||
public TableDataInfo<BusProjectPunchrangeVo> list(BusProjectPunchrangeBo bo, PageQuery pageQuery) {
|
||||
return busProjectPunchrangeService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有分包管理人员
|
||||
*/
|
||||
@GetMapping("/listSubContractor")
|
||||
public R<List<SysUserVo>> listSubContractor(Long projectId) {
|
||||
return R.ok(userService.selectUserListByAppUserType("2",projectId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取与用户关联的班组
|
||||
*/
|
||||
@SaCheckPermission("project:projectTeam:getByUserId")
|
||||
@GetMapping("/getByUserId/{userId}/{projectId}")
|
||||
public R<List<BusProjectTeamAppVo>> getByUserId(@PathVariable("userId") Long userId,
|
||||
@PathVariable("projectId") Long projectId){
|
||||
return R.ok(busProjectTeamService.getByUserId(userId,projectId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除班组的管理
|
||||
*/
|
||||
@PutMapping("/deleteUserId/{id}")
|
||||
public R<Boolean> deleteUserId(@PathVariable("id") Long id){
|
||||
return R.ok(busProjectTeamService.deleteUserId(id));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import jakarta.validation.constraints.NotNull;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.project.domain.dto.projectteam.BusProjectTeamQueryReq;
|
||||
import org.dromara.project.domain.vo.projectteam.BusProjectTeamAppVo;
|
||||
import org.dromara.project.domain.vo.projectteam.BusProjectTeamForemanVo;
|
||||
import org.dromara.project.domain.vo.projectteam.BusProjectTeamVo;
|
||||
import org.dromara.project.service.IBusProjectTeamService;
|
||||
@ -49,4 +50,13 @@ public class BusProjectTeamAppController extends BaseController {
|
||||
busProjectTeamQueryReq.setProjectId(projectid);
|
||||
return R.ok(projectTeamService.queryList(busProjectTeamQueryReq));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取与用户关联的班组
|
||||
*/
|
||||
@GetMapping("/getByUserId/{userId}/{projectId}")
|
||||
public R<List<BusProjectTeamAppVo>> getByUserId(@PathVariable("userId") Long userId,@PathVariable("projectId") Long projectId){
|
||||
return R.ok(projectTeamService.getByUserId(userId,projectId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -53,4 +53,8 @@ public class BusProjectTeam extends BaseEntity {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 管理员Id
|
||||
*/
|
||||
private Long userId;
|
||||
}
|
||||
|
||||
@ -46,4 +46,9 @@ public class BusProjectTeamCreateReq implements Serializable {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
/**
|
||||
* 管理员Id
|
||||
*/
|
||||
private Long userId;
|
||||
}
|
||||
|
||||
@ -48,4 +48,8 @@ public class BusProjectTeamUpdateReq implements Serializable {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 管理员Id
|
||||
*/
|
||||
private Long userId;
|
||||
}
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
package org.dromara.project.domain.vo.projectteam;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||
import org.dromara.common.translation.annotation.Translation;
|
||||
import org.dromara.common.translation.constant.TransConstant;
|
||||
import org.dromara.project.domain.BusProjectTeam;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 项目班组视图对象 bus_project_team
|
||||
*
|
||||
* @author lilemy
|
||||
* @date 2025-03-07
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = BusProjectTeam.class)
|
||||
public class BusProjectTeamAppVo implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String teamName;
|
||||
}
|
||||
@ -6,6 +6,8 @@ import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||
import org.dromara.common.translation.annotation.Translation;
|
||||
import org.dromara.common.translation.constant.TransConstant;
|
||||
import org.dromara.project.domain.BusProjectPunchrange;
|
||||
import org.dromara.project.domain.BusProjectTeam;
|
||||
|
||||
@ -71,6 +73,18 @@ public class BusProjectTeamVo implements Serializable {
|
||||
@ExcelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 管理员Id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
|
||||
/**
|
||||
* 管理员Id
|
||||
*/
|
||||
@Translation(type = TransConstant.USER_ID_TO_NICKNAME, mapper = "userId")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 打卡范围
|
||||
*/
|
||||
|
||||
@ -50,4 +50,9 @@ public class BusLoginUserProjectRelevancyVo implements Serializable {
|
||||
*/
|
||||
private Long teamId;
|
||||
|
||||
/**
|
||||
* 班组名
|
||||
*/
|
||||
private String teamName;
|
||||
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ import org.dromara.project.domain.BusProjectTeam;
|
||||
import org.dromara.project.domain.dto.projectteam.BusProjectTeamCreateReq;
|
||||
import org.dromara.project.domain.dto.projectteam.BusProjectTeamQueryReq;
|
||||
import org.dromara.project.domain.dto.projectteam.BusProjectTeamUpdateReq;
|
||||
import org.dromara.project.domain.vo.projectteam.BusProjectTeamAppVo;
|
||||
import org.dromara.project.domain.vo.projectteam.BusProjectTeamForemanVo;
|
||||
import org.dromara.project.domain.vo.projectteam.BusProjectTeamVo;
|
||||
import org.dromara.quality.domain.vo.qualityinspection.QltQualityInspectionVo;
|
||||
@ -115,4 +116,10 @@ public interface IBusProjectTeamService extends IService<BusProjectTeam> {
|
||||
* @return 项目班组分页对象视图
|
||||
*/
|
||||
Page<BusProjectTeamVo> getVoPage(Page<BusProjectTeam> projectTeamPage);
|
||||
|
||||
|
||||
List<BusProjectTeamAppVo> getByUserId(Long userId,Long projectId);
|
||||
|
||||
|
||||
Boolean deleteUserId(Long id);
|
||||
}
|
||||
|
||||
@ -25,6 +25,7 @@ import org.dromara.project.domain.dto.projectteam.BusProjectTeamQueryReq;
|
||||
import org.dromara.project.domain.dto.projectteam.BusProjectTeamUpdateReq;
|
||||
import org.dromara.project.domain.enums.BusProjectTeamMemberPostEnum;
|
||||
import org.dromara.project.domain.vo.projectteam.BusForemanVo;
|
||||
import org.dromara.project.domain.vo.projectteam.BusProjectTeamAppVo;
|
||||
import org.dromara.project.domain.vo.projectteam.BusProjectTeamForemanVo;
|
||||
import org.dromara.project.domain.vo.projectteam.BusProjectTeamVo;
|
||||
import org.dromara.project.mapper.BusProjectTeamMapper;
|
||||
@ -429,4 +430,30 @@ public class BusProjectTeamServiceImpl extends ServiceImpl<BusProjectTeamMapper,
|
||||
projectTeamVoPage.setRecords(projectTeamVoList);
|
||||
return projectTeamVoPage;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<BusProjectTeamAppVo> getByUserId(Long userId,Long projectId) {
|
||||
LambdaQueryWrapper<BusProjectTeam> lqw = new LambdaQueryWrapper<>();
|
||||
|
||||
lqw.eq(BusProjectTeam::getUserId, userId);
|
||||
lqw.eq(BusProjectTeam::getProjectId, projectId);
|
||||
List<BusProjectTeam> projectTeamList = list(lqw);
|
||||
if (CollUtil.isNotEmpty(projectTeamList)) {
|
||||
return projectTeamList.stream().map(projectTeam -> {
|
||||
BusProjectTeamAppVo projectTeamAppVo = new BusProjectTeamAppVo();
|
||||
BeanUtils.copyProperties(projectTeam, projectTeamAppVo);
|
||||
return projectTeamAppVo;
|
||||
}).toList();
|
||||
}
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteUserId(Long id) {
|
||||
int update = baseMapper.update(Wrappers.<BusProjectTeam>lambdaUpdate()
|
||||
.eq(BusProjectTeam::getId, id)
|
||||
.set(BusProjectTeam::getUserId, null));
|
||||
return update>0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.project.constant.BusProjectConstant;
|
||||
import org.dromara.project.domain.BusProject;
|
||||
import org.dromara.project.domain.BusProjectTeam;
|
||||
import org.dromara.project.domain.BusProjectTeamMember;
|
||||
import org.dromara.project.domain.BusUserProjectRelevancy;
|
||||
import org.dromara.project.domain.dto.project.BusProjectBatchByProjectListReq;
|
||||
@ -27,6 +28,7 @@ import org.dromara.project.domain.vo.userprojectrelevancy.BusUserProjectRelevanc
|
||||
import org.dromara.project.mapper.BusUserProjectRelevancyMapper;
|
||||
import org.dromara.project.service.IBusProjectService;
|
||||
import org.dromara.project.service.IBusProjectTeamMemberService;
|
||||
import org.dromara.project.service.IBusProjectTeamService;
|
||||
import org.dromara.project.service.IBusUserProjectRelevancyService;
|
||||
import org.dromara.system.service.ISysUserService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@ -58,6 +60,10 @@ public class BusUserProjectRelevancyServiceImpl extends ServiceImpl<BusUserProje
|
||||
@Resource
|
||||
private IBusProjectTeamMemberService projectMemberService;
|
||||
|
||||
@Lazy
|
||||
@Resource
|
||||
private IBusProjectTeamService teamService;
|
||||
|
||||
/**
|
||||
* 查询系统用户与项目关联
|
||||
*
|
||||
@ -355,7 +361,17 @@ public class BusUserProjectRelevancyServiceImpl extends ServiceImpl<BusUserProje
|
||||
|
||||
Map<Long, Long> teamMap = projectMemberService.lambdaQuery().eq(BusProjectTeamMember::getMemberId, userId).list()
|
||||
.stream().collect(Collectors.toMap(BusProjectTeamMember::getProjectId, BusProjectTeamMember::getTeamId));
|
||||
|
||||
Collection<Long> values = teamMap.values();
|
||||
Map<Long, String> teamList;
|
||||
if(CollUtil.isEmpty(values)){
|
||||
teamList = new HashMap<>();
|
||||
}else {
|
||||
teamList = teamService.lambdaQuery()
|
||||
.select(BusProjectTeam::getId, BusProjectTeam::getTeamName)
|
||||
.in(BusProjectTeam::getId, values)
|
||||
.list()
|
||||
.stream().collect(Collectors.toMap(BusProjectTeam::getId, BusProjectTeam::getTeamName));
|
||||
}
|
||||
|
||||
// 获取封装
|
||||
return list.stream()
|
||||
@ -373,10 +389,10 @@ public class BusUserProjectRelevancyServiceImpl extends ServiceImpl<BusUserProje
|
||||
loginUserProjectRelevancy.setProjectName(project.getProjectName());
|
||||
loginUserProjectRelevancy.setShortName(project.getShortName());
|
||||
loginUserProjectRelevancy.setTeamId(teamMap.get(projectId));
|
||||
loginUserProjectRelevancy.setTeamName(teamList.get(teamMap.get(projectId)));
|
||||
return loginUserProjectRelevancy;
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
|
||||
@ -6,6 +6,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -24,10 +25,15 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.common.tenant.helper.TenantHelper;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.contractor.domain.SubContractor;
|
||||
import org.dromara.contractor.service.ISubContractorService;
|
||||
import org.dromara.project.domain.BusProject;
|
||||
import org.dromara.project.service.IBusProjectService;
|
||||
import org.dromara.system.domain.bo.SysDeptBo;
|
||||
import org.dromara.system.domain.bo.SysPostBo;
|
||||
import org.dromara.system.domain.bo.SysRoleBo;
|
||||
import org.dromara.system.domain.bo.SysUserBo;
|
||||
import org.dromara.system.domain.dto.FbUserListDto;
|
||||
import org.dromara.system.domain.dto.role.SysRoleProjectDto;
|
||||
import org.dromara.system.domain.vo.*;
|
||||
import org.dromara.system.listener.SysUserImportListener;
|
||||
@ -56,6 +62,8 @@ public class SysUserController extends BaseController {
|
||||
private final ISysPostService postService;
|
||||
private final ISysDeptService deptService;
|
||||
private final ISysTenantService tenantService;
|
||||
private final IBusProjectService projectService;
|
||||
private final ISubContractorService contractorService;
|
||||
|
||||
/**
|
||||
* 获取用户列表
|
||||
@ -333,12 +341,72 @@ public class SysUserController extends BaseController {
|
||||
return R.ok(userService.selectUserListByDept(deptId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户类型
|
||||
*/
|
||||
@SaCheckPermission("system:user:edit")
|
||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/appUserType/{userId}/{appUserType}")
|
||||
public R<Boolean> updateUserAppType(@PathVariable("userId") Long userId,
|
||||
@PathVariable("appUserType") String appUserType) {
|
||||
return R.ok(userService.updateAppUserType(userId, appUserType));
|
||||
@PathVariable("appUserType") String appUserType,
|
||||
@RequestBody List<Long> projectIds) {
|
||||
return R.ok(userService.updateAppUserType(userId, appUserType,projectIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户是否有项目
|
||||
*/
|
||||
@SaCheckPermission("system:user:edit")
|
||||
@GetMapping("/queryProjectRelevancy/{userId}")
|
||||
public R<Boolean> queryProjectRelevancy(@PathVariable("userId") Long userId) {
|
||||
return R.ok(userService.queryProjectRelevancy(userId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有父项目
|
||||
*/
|
||||
@SaCheckPermission("system:user:edit")
|
||||
@GetMapping("/projectList")
|
||||
public R<List<BusProject>> projectList() {
|
||||
List<BusProject> list = projectService.list(Wrappers.lambdaQuery(BusProject.class)
|
||||
.select(BusProject::getId, BusProject::getProjectName)
|
||||
.eq(BusProject::getPId, 0));
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取分包用户列表
|
||||
*/
|
||||
@SaCheckPermission("system:user:fbList")
|
||||
@GetMapping("/fbList")
|
||||
public TableDataInfo<SysUserVo> fbList(FbUserListDto dto, PageQuery pageQuery) {
|
||||
return userService.selectPageFbUserList(dto, pageQuery);
|
||||
}
|
||||
/**
|
||||
* 获取分包单位列表
|
||||
*/
|
||||
@SaCheckPermission("system:user:updateFb")
|
||||
@PutMapping("/{projectId}")
|
||||
public R<List<SubContractor>> getFbList(@PathVariable("projectId") Long projectId) {
|
||||
List<SubContractor> list = contractorService.list(Wrappers.<SubContractor>lambdaQuery()
|
||||
.select(SubContractor::getId, SubContractor::getName)
|
||||
.eq(SubContractor::getProjectId, projectId)
|
||||
);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改分包单位
|
||||
*/
|
||||
@SaCheckPermission("system:user:updateFb")
|
||||
@PutMapping("/{userId}/{contractorId}")
|
||||
public R<Boolean> updateFb(@PathVariable("userId") Long userId,
|
||||
@PathVariable("contractorId") Long contractorId) {
|
||||
return R.ok(userService.updateFb(userId, contractorId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -110,6 +110,12 @@ public class SysUser extends TenantEntity {
|
||||
private String appUserType;
|
||||
|
||||
|
||||
/**
|
||||
* 分包公司Id
|
||||
*/
|
||||
private Long contractorId;
|
||||
|
||||
|
||||
public SysUser(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
@ -113,6 +113,9 @@ public class SysUserBo extends BaseEntity {
|
||||
*/
|
||||
private Long roleId;
|
||||
|
||||
|
||||
private Long contractorId;
|
||||
|
||||
/**
|
||||
* 排除不查询的用户(工作流用)
|
||||
*/
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
package org.dromara.system.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FbUserListDto {
|
||||
|
||||
private String userName;
|
||||
|
||||
private String nickName;
|
||||
|
||||
private String phonenumber;
|
||||
|
||||
private Long projectId;
|
||||
}
|
||||
@ -152,4 +152,14 @@ public class SysUserVo implements Serializable {
|
||||
|
||||
private String appUserType;
|
||||
|
||||
/**
|
||||
* 分包
|
||||
*/
|
||||
private Long contractorId;
|
||||
|
||||
/**
|
||||
* 分包单位名称
|
||||
*/
|
||||
private String contractorName;
|
||||
|
||||
}
|
||||
|
||||
@ -133,4 +133,8 @@ public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo> {
|
||||
@DataColumn(key = "userName", value = "u.user_id")
|
||||
})
|
||||
List<SysUserVo> selectVoListByDept(@Param(Constants.WRAPPER) Wrapper<SysUser> sysUserWrapper);
|
||||
|
||||
|
||||
|
||||
List<SysUserVo> selectUserListByAppUserType(@Param("appUserType") String appUserType, @Param("projectId")Long projectId);
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package org.dromara.system.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.system.domain.SysUserRole;
|
||||
|
||||
@ -20,4 +22,9 @@ public interface SysUserRoleMapper extends BaseMapperPlus<SysUserRole, SysUserRo
|
||||
*/
|
||||
List<Long> selectUserIdsByRoleId(Long roleId);
|
||||
|
||||
@Delete("DELETE sur FROM sys_user_role sur \n" +
|
||||
"INNER JOIN sys_role sr ON sur.role_id = sr.role_id \n" +
|
||||
"WHERE sur.user_id = #{userId} " +
|
||||
" AND sr.role_source = '2' ")
|
||||
void deleteAppRoleByUserId(@Param("userId") Long userId);
|
||||
}
|
||||
|
||||
@ -4,9 +4,11 @@ import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.system.domain.SysUser;
|
||||
import org.dromara.system.domain.bo.SysUserBo;
|
||||
import org.dromara.system.domain.dto.FbUserListDto;
|
||||
import org.dromara.system.domain.dto.role.SysRoleProjectDto;
|
||||
import org.dromara.system.domain.vo.SysUserExportVo;
|
||||
import org.dromara.system.domain.vo.SysUserVo;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -21,6 +23,8 @@ public interface ISysUserService {
|
||||
|
||||
TableDataInfo<SysUserVo> selectPageUserList(SysUserBo user, PageQuery pageQuery);
|
||||
|
||||
TableDataInfo<SysUserVo> selectPageFbUserList(FbUserListDto user, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
@ -263,7 +267,13 @@ public interface ISysUserService {
|
||||
|
||||
Long save(SysUser sysUser);
|
||||
|
||||
Boolean updateAppUserType(Long userId,String appUserType);
|
||||
Boolean updateAppUserType(Long userId,String appUserType,List<Long> projectIds);
|
||||
|
||||
List<SysUserVo> selectUserListByDeptByType(SysUserBo sysUserBo);
|
||||
|
||||
Boolean queryProjectRelevancy(Long userId);
|
||||
|
||||
List<SysUserVo> selectUserListByAppUserType(String appUserType,Long projectId);
|
||||
|
||||
Boolean updateFb(Long userId,Long contractorId);
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
QueryWrapper<SysRole> wrapper = Wrappers.query();
|
||||
wrapper.eq("r.del_flag", SystemConstants.NORMAL)
|
||||
.eq(StringUtils.isNotBlank(bo.getRoleSource()), "r.role_source", bo.getRoleSource())
|
||||
.notIn("2".equals(bo.getRoleSource()), "r.role_id", Arrays.asList( 2L,3L,4L))
|
||||
.notIn("2".equals(bo.getRoleSource()), "r.role_id", Arrays.asList( 2L,3L,4L,5L))
|
||||
//.eq(ObjectUtil.isNotNull(bo.getDeptId()), "r.dept_id", bo.getDeptId())
|
||||
.eq(ObjectUtil.isNotNull(bo.getIsSpecial()), "r.is_special", bo.getIsSpecial())
|
||||
.eq(ObjectUtil.isNotNull(bo.getRoleId()), "r.role_id", bo.getRoleId())
|
||||
|
||||
@ -2,6 +2,7 @@ package org.dromara.system.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
@ -24,11 +25,15 @@ import org.dromara.common.core.utils.*;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
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.project.domain.BusUserProjectRelevancy;
|
||||
import org.dromara.project.service.IBusUserProjectRelevancyService;
|
||||
import org.dromara.system.domain.*;
|
||||
import org.dromara.system.domain.bo.SysUserBo;
|
||||
import org.dromara.system.domain.dto.FbUserListDto;
|
||||
import org.dromara.system.domain.dto.role.SysRoleProjectDto;
|
||||
import org.dromara.system.domain.vo.SysPostVo;
|
||||
import org.dromara.system.domain.vo.SysRoleVo;
|
||||
@ -70,6 +75,8 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
|
||||
private final ISubConstructionUserService constructionUserService;
|
||||
|
||||
private final ISubContractorService contractorService;
|
||||
|
||||
@Lazy
|
||||
@Resource
|
||||
private ISysUserFileService userFileService;
|
||||
@ -99,6 +106,34 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo<SysUserVo> selectPageFbUserList(FbUserListDto dto, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<SysUser> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
wrapper.eq(SysUser::getAppUserType, "2");
|
||||
wrapper.like(StringUtils.isNotBlank(dto.getUserName()),SysUser::getUserName, dto.getUserName());
|
||||
wrapper.like(StringUtils.isNotBlank(dto.getPhonenumber()),SysUser::getPhonenumber, dto.getPhonenumber());
|
||||
wrapper.like(StringUtils.isNotBlank(dto.getNickName()),SysUser::getNickName, dto.getNickName());
|
||||
wrapper.exists("SELECT 1 FROM bus_user_project_relevancy " +
|
||||
"WHERE bus_user_project_relevancy.user_id = u.user_id " +
|
||||
"AND project_id = {0}", dto.getProjectId());
|
||||
Page<SysUserVo> page = baseMapper.selectPageUserList(pageQuery.build(), wrapper);
|
||||
List<SysUserVo> userVoList = page.getRecords();
|
||||
|
||||
if (CollUtil.isNotEmpty(userVoList)) {
|
||||
|
||||
List<Long> list1 = userVoList.stream().map(SysUserVo::getContractorId).toList();
|
||||
List<SubContractor> subContractors = contractorService.listByIds(list1);
|
||||
Map<Long, String> collect = subContractors.stream().collect(Collectors.toMap(SubContractor::getId, SubContractor::getName));
|
||||
userVoList.forEach(userVo -> {
|
||||
Long contractorId = userVo.getContractorId();
|
||||
userVo.setContractorName(collect.get(contractorId));
|
||||
});
|
||||
page.setRecords(userVoList);
|
||||
}
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
@ -115,6 +150,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
QueryWrapper<SysUser> wrapper = Wrappers.query();
|
||||
wrapper.isNotNull("u.dept_id");
|
||||
wrapper.eq("u.del_flag", SystemConstants.NORMAL)
|
||||
.eq(StringUtils.isNotBlank(user.getAppUserType()), "u.app_user_type", user.getAppUserType())
|
||||
.eq(StringUtils.isNotBlank(user.getUserType()), "u.user_type", user.getUserType())
|
||||
.eq(ObjectUtil.isNotNull(user.getUserId()), "u.user_id", user.getUserId())
|
||||
.like(StringUtils.isNotBlank(user.getNickName()), "u.nick_name", user.getNickName())
|
||||
@ -762,6 +798,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
|
||||
/**
|
||||
* 根据部门 ID 获取用户 ID -> 名称 映射
|
||||
*
|
||||
* @param deptId
|
||||
* @return
|
||||
*/
|
||||
@ -783,6 +820,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
|
||||
/**
|
||||
* 获取指定部门的用户名称列表(用于 Excel 下拉框)
|
||||
*
|
||||
* @param deptId
|
||||
* @return
|
||||
*/
|
||||
@ -828,18 +866,61 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean updateAppUserType(Long userId, String appUserType) {
|
||||
//直接添加权限 app用户类型 0-施工人员 1-管理人员 2-分包人员
|
||||
// if("1".equals(appUserType)){
|
||||
// //清空app角色
|
||||
// userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>()
|
||||
// .eq(SysUserRole::getUserId, userId));
|
||||
// //添加管理人员角色
|
||||
//
|
||||
// }
|
||||
public Boolean updateAppUserType(Long userId, String appUserType,List<Long> projectIds) {
|
||||
//app用户类型 0-施工人员 1-管理人员 2-分包人员
|
||||
SysUser sysUser = baseMapper.selectById(userId);
|
||||
if (sysUser == null) {
|
||||
throw new ServiceException("用户不存在!");
|
||||
}
|
||||
Long contractorId = null;
|
||||
SubConstructionUser constructionUser = constructionUserService.lambdaQuery()
|
||||
.eq(SubConstructionUser::getSysUserId, userId)
|
||||
.one();
|
||||
if (constructionUser != null) {
|
||||
if (constructionUser.getTeamId() != null) {
|
||||
throw new ServiceException("请先退出班组!");
|
||||
}
|
||||
constructionUserService.update(Wrappers.<SubConstructionUser>lambdaUpdate()
|
||||
.eq(SubConstructionUser::getId, constructionUser.getId())
|
||||
.set(SubConstructionUser::getUserRole, appUserType)
|
||||
);
|
||||
contractorId = constructionUser.getContractorId();
|
||||
}
|
||||
String oldType = sysUser.getAppUserType();
|
||||
if ("0".equals(oldType)) { //施工人员->管理人员/分包人员
|
||||
//清除app所有角色
|
||||
userRoleMapper.deleteAppRoleByUserId(userId);
|
||||
}else { //管理人员 <-> 施工人员
|
||||
//清除所有角色
|
||||
userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>()
|
||||
.eq(SysUserRole::getUserId, userId));
|
||||
}
|
||||
//查询所有关联项目
|
||||
List<BusUserProjectRelevancy> list = userProjectRelevancyService.list(Wrappers.<BusUserProjectRelevancy>lambdaQuery()
|
||||
.eq(BusUserProjectRelevancy::getUserId, userId));
|
||||
List<Long> projects = list.stream().map(BusUserProjectRelevancy::getProjectId).collect(Collectors.toList());
|
||||
if(CollectionUtil.isEmpty(projects)){
|
||||
if(CollectionUtil.isEmpty(projectIds)){
|
||||
throw new ServiceException("请选择项目!");
|
||||
}
|
||||
projects = projectIds;
|
||||
}
|
||||
|
||||
Long roleId = "1".equals(appUserType)?4L:5L;
|
||||
ArrayList<SysUserRole> sysUserRoles = new ArrayList<>();
|
||||
for (Long project : projects) {
|
||||
SysUserRole sysUserRole = new SysUserRole();
|
||||
sysUserRole.setProjectId(project);
|
||||
sysUserRole.setUserId(userId);
|
||||
sysUserRole.setRoleId(roleId);
|
||||
sysUserRoles.add(sysUserRole);
|
||||
}
|
||||
userRoleMapper.insertBatch(sysUserRoles);
|
||||
|
||||
return baseMapper.update(null,
|
||||
new LambdaUpdateWrapper<SysUser>()
|
||||
.set(SysUser::getAppUserType, appUserType)
|
||||
.set(contractorId!=null,SysUser::getContractorId, contractorId)
|
||||
.eq(SysUser::getUserId, userId)) > 0;
|
||||
}
|
||||
|
||||
@ -848,6 +929,20 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
return baseMapper.selectVoListByDept(this.buildQueryWrapper(sysUserBo));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean queryProjectRelevancy(Long userId) {
|
||||
List<BusUserProjectRelevancy> list = userProjectRelevancyService.list(Wrappers.<BusUserProjectRelevancy>lambdaQuery()
|
||||
.eq(BusUserProjectRelevancy::getUserId, userId));
|
||||
return CollectionUtil.isNotEmpty(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUserVo> selectUserListByAppUserType(String appUserType,Long projectId) {
|
||||
return baseMapper.selectUserListByAppUserType(appUserType,projectId);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户账户
|
||||
*
|
||||
@ -1092,4 +1187,19 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
}
|
||||
return sysOss.getUrl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateFb(Long userId,Long contractorId) {
|
||||
SysUser sysUser = baseMapper.selectById(userId);
|
||||
sysUser.setContractorId(contractorId);
|
||||
|
||||
SubConstructionUser constructionUser = constructionUserService.lambdaQuery()
|
||||
.eq(SubConstructionUser::getSysUserId, userId)
|
||||
.one();
|
||||
if(constructionUser != null){
|
||||
constructionUser.setContractorId(contractorId);
|
||||
constructionUserService.updateById(constructionUser);
|
||||
}
|
||||
return baseMapper.updateById(sysUser)>0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
</if>
|
||||
<if test="ew.getSqlSelect == null">
|
||||
u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex,
|
||||
u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.app_user_type
|
||||
u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.app_user_type,u.contractor_id
|
||||
</if>
|
||||
from sys_user u
|
||||
${ew.getCustomSqlSegment}
|
||||
@ -122,5 +122,22 @@
|
||||
${ew.getCustomSqlSegment}
|
||||
</select>
|
||||
|
||||
<select id="selectUserListByAppUserType" resultType="org.dromara.system.domain.vo.SysUserVo">
|
||||
SELECT
|
||||
su.user_id,
|
||||
su.nick_name,
|
||||
su.phonenumber
|
||||
FROM
|
||||
sys_user su
|
||||
INNER JOIN
|
||||
bus_user_project_relevancy bur
|
||||
ON su.user_id = bur.user_id
|
||||
WHERE
|
||||
bur.project_id = #{projectId}
|
||||
AND su.app_user_type = #{appUserType}
|
||||
AND su.del_flag = '0'
|
||||
AND su.status = '0'
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user