[add] 查询分包管理人员,用户项目关联添加类型,班组打卡范围
This commit is contained in:
@ -66,7 +66,7 @@ public class SubContractorController extends BaseController {
|
||||
@GetMapping("/listManager/{projectId}")
|
||||
public R<List<SubContractorManagerVo>> listManager(@NotNull(message = "项目id不能为空")
|
||||
@PathVariable Long projectId) {
|
||||
return R.ok(contractorService.queryManagerList(projectId));
|
||||
return R.ok(contractorService.queryManagerListByProjectId(projectId));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,66 +55,11 @@ public class SubConstructionUserCreateReq implements Serializable {
|
||||
*/
|
||||
private String nation;
|
||||
|
||||
/**
|
||||
* 身份证正面图片
|
||||
*/
|
||||
private String sfzFrontPic;
|
||||
|
||||
/**
|
||||
* 身份证反面图片
|
||||
*/
|
||||
private String sfzBackPic;
|
||||
|
||||
/**
|
||||
* 身份证号码
|
||||
*/
|
||||
private String sfzNumber;
|
||||
|
||||
/**
|
||||
* 身份证有效开始期
|
||||
*/
|
||||
private String sfzStart;
|
||||
|
||||
/**
|
||||
* 身份证有效结束期
|
||||
*/
|
||||
private String sfzEnd;
|
||||
|
||||
/**
|
||||
* 身份证地址
|
||||
*/
|
||||
private String sfzSite;
|
||||
|
||||
/**
|
||||
* 身份证出生日期
|
||||
*/
|
||||
private String sfzBirth;
|
||||
|
||||
/**
|
||||
* 籍贯
|
||||
*/
|
||||
private String nativePlace;
|
||||
|
||||
/**
|
||||
* 银行卡图片
|
||||
*/
|
||||
private String yhkPic;
|
||||
|
||||
/**
|
||||
* 银行卡号
|
||||
*/
|
||||
private String yhkNumber;
|
||||
|
||||
/**
|
||||
* 开户行
|
||||
*/
|
||||
private String yhkOpeningBank;
|
||||
|
||||
/**
|
||||
* 持卡人
|
||||
*/
|
||||
private String yhkCardholder;
|
||||
|
||||
/**
|
||||
* 工种(字典type_of_work)
|
||||
*/
|
||||
|
@ -62,56 +62,11 @@ public class SubConstructionUserUpdateReq implements Serializable {
|
||||
*/
|
||||
private String nation;
|
||||
|
||||
/**
|
||||
* 身份证正面图片
|
||||
*/
|
||||
private String sfzFrontPic;
|
||||
|
||||
/**
|
||||
* 身份证反面图片
|
||||
*/
|
||||
private String sfzBackPic;
|
||||
|
||||
/**
|
||||
* 身份证有效开始期
|
||||
*/
|
||||
private String sfzStart;
|
||||
|
||||
/**
|
||||
* 身份证有效结束期
|
||||
*/
|
||||
private String sfzEnd;
|
||||
|
||||
/**
|
||||
* 身份证地址
|
||||
*/
|
||||
private String sfzSite;
|
||||
|
||||
/**
|
||||
* 身份证出生日期
|
||||
*/
|
||||
private String sfzBirth;
|
||||
|
||||
/**
|
||||
* 籍贯
|
||||
*/
|
||||
private String nativePlace;
|
||||
|
||||
/**
|
||||
* 银行卡图片
|
||||
*/
|
||||
private String yhkPic;
|
||||
|
||||
/**
|
||||
* 开户行
|
||||
*/
|
||||
private String yhkOpeningBank;
|
||||
|
||||
/**
|
||||
* 持卡人
|
||||
*/
|
||||
private String yhkCardholder;
|
||||
|
||||
/**
|
||||
* 工种(字典type_of_work)
|
||||
*/
|
||||
|
@ -21,11 +21,6 @@ public class SubContractorManagerVo implements Serializable {
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 公司名称
|
||||
*/
|
||||
|
@ -106,10 +106,10 @@ public interface ISubContractorService extends IService<SubContractor> {
|
||||
Page<SubContractorVo> getVoPage(Page<SubContractor> contractorPage);
|
||||
|
||||
/**
|
||||
* 获取分包公司管理员列表
|
||||
* 获取项目下分包公司管理员列表
|
||||
*
|
||||
* @param projectId 项目id
|
||||
* @return 分包公司经理列表
|
||||
*/
|
||||
List<SubContractorManagerVo> queryManagerList(Long projectId);
|
||||
List<SubContractorManagerVo> queryManagerListByProjectId(Long projectId);
|
||||
}
|
||||
|
@ -331,9 +331,6 @@ public class SubConstructionUserServiceImpl extends ServiceImpl<SubConstructionU
|
||||
validEntityBeforeSave(constructionUser, true);
|
||||
Long userId = LoginHelper.getUserId();
|
||||
projectService.validAuth(req.getProjectId(), userId);
|
||||
// 对身份证号码进行加密
|
||||
String encrypt = idCardEncryptorUtil.encrypt(req.getSfzNumber());
|
||||
constructionUser.setSfzNumber(encrypt);
|
||||
// 操作数据库
|
||||
boolean save = this.save(constructionUser);
|
||||
if (!save) {
|
||||
@ -552,7 +549,6 @@ public class SubConstructionUserServiceImpl extends ServiceImpl<SubConstructionU
|
||||
String typeOfWork = entity.getTypeOfWork();
|
||||
String wageMeasureUnit = entity.getWageMeasureUnit();
|
||||
String phone = entity.getPhone();
|
||||
String sfzNumber = entity.getSfzNumber();
|
||||
if (projectId == null) {
|
||||
throw new ServiceException("项目 id 不能为空", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
@ -566,9 +562,6 @@ public class SubConstructionUserServiceImpl extends ServiceImpl<SubConstructionU
|
||||
if (StringUtils.isEmpty(wageMeasureUnit)) {
|
||||
throw new ServiceException("工资计量单位不能为空", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
if (StringUtils.isEmpty(sfzNumber)) {
|
||||
throw new ServiceException("身份证不能为空", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
if (projectService.getById(projectId) == null) {
|
||||
throw new ServiceException("对应项目不存在", HttpStatus.NOT_FOUND);
|
||||
@ -596,9 +589,6 @@ public class SubConstructionUserServiceImpl extends ServiceImpl<SubConstructionU
|
||||
if (StringUtils.isNotEmpty(phone) && !PhoneUtil.isPhone(phone)) {
|
||||
throw new ServiceException("手机号码格式不正确", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(sfzNumber) && !IdcardUtil.isValidCard(sfzNumber)) {
|
||||
throw new ServiceException("身份证号码格式不正确", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,10 +22,12 @@ import org.dromara.contractor.domain.dto.contractor.SubContractorQueryReq;
|
||||
import org.dromara.contractor.domain.dto.contractor.SubContractorUpdateReq;
|
||||
import org.dromara.contractor.domain.vo.contractor.SubContractorManagerVo;
|
||||
import org.dromara.contractor.domain.vo.contractor.SubContractorVo;
|
||||
import org.dromara.contractor.domain.vo.contractor.SubManagerVo;
|
||||
import org.dromara.contractor.mapper.SubContractorMapper;
|
||||
import org.dromara.contractor.service.ISubConstructionUserService;
|
||||
import org.dromara.contractor.service.ISubContractorService;
|
||||
import org.dromara.project.domain.BusProject;
|
||||
import org.dromara.project.domain.enums.SubConstructionUserRoleEnum;
|
||||
import org.dromara.project.service.IBusProjectService;
|
||||
import org.dromara.system.domain.SysDept;
|
||||
import org.dromara.system.domain.enums.SysDeptTypeEnum;
|
||||
@ -366,13 +368,13 @@ public class SubContractorServiceImpl extends ServiceImpl<SubContractorMapper, S
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分包公司管理员列表
|
||||
* 获取项目下分包公司管理员列表
|
||||
*
|
||||
* @param projectId 项目id
|
||||
* @return 分包公司经理列表
|
||||
*/
|
||||
@Override
|
||||
public List<SubContractorManagerVo> queryManagerList(Long projectId) {
|
||||
public List<SubContractorManagerVo> queryManagerListByProjectId(Long projectId) {
|
||||
List<SubContractor> contractorList = this.lambdaQuery()
|
||||
.eq(SubContractor::getProjectId, projectId)
|
||||
.list();
|
||||
@ -380,6 +382,29 @@ public class SubContractorServiceImpl extends ServiceImpl<SubContractorMapper, S
|
||||
return List.of();
|
||||
}
|
||||
Set<Long> contractorIds = contractorList.stream().map(SubContractor::getId).collect(Collectors.toSet());
|
||||
return List.of();
|
||||
List<SubConstructionUser> adminUserList = constructionUserService.lambdaQuery()
|
||||
.in(SubConstructionUser::getContractorId, contractorIds)
|
||||
.eq(SubConstructionUser::getUserRole, SubConstructionUserRoleEnum.ADMIN.getValue())
|
||||
.list();
|
||||
Map<Long, List<SubConstructionUser>> adminUserMap = adminUserList.stream()
|
||||
.collect(Collectors.groupingBy(SubConstructionUser::getContractorId));
|
||||
return contractorList.stream().map(contractor -> {
|
||||
SubContractorManagerVo vo = new SubContractorManagerVo();
|
||||
Long id = contractor.getId();
|
||||
if (adminUserMap.containsKey(id)) {
|
||||
List<SubConstructionUser> users = adminUserMap.get(id);
|
||||
if (users != null) {
|
||||
vo.setManagerList(users.stream().map(user -> {
|
||||
SubManagerVo managerVo = new SubManagerVo();
|
||||
managerVo.setManagerId(user.getSysUserId());
|
||||
managerVo.setManagerName(user.getUserName());
|
||||
return managerVo;
|
||||
}).toList());
|
||||
}
|
||||
}
|
||||
vo.setId(id);
|
||||
vo.setName(contractor.getName());
|
||||
return vo;
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
|
@ -6,8 +6,6 @@ import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
@ -55,8 +53,8 @@ public class BusProjectTeamController extends BaseController {
|
||||
@SaCheckPermission("project:projectTeam:list")
|
||||
@GetMapping("/listForeman/{projectId}")
|
||||
public R<List<BusProjectTeamForemanVo>> listForeman(@NotNull(message = "项目id不能为空")
|
||||
@PathVariable Long projectId) {
|
||||
return R.ok(busProjectTeamService.queryForemanList(projectId));
|
||||
@PathVariable Long projectId) {
|
||||
return R.ok(busProjectTeamService.queryForemanListByProjectId(projectId));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -89,7 +87,7 @@ public class BusProjectTeamController extends BaseController {
|
||||
@Log(title = "项目班组", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Long> add(@Validated(AddGroup.class) @RequestBody BusProjectTeamCreateReq req) {
|
||||
public R<Long> add(@Validated @RequestBody BusProjectTeamCreateReq req) {
|
||||
return R.ok(busProjectTeamService.insertByBo(req));
|
||||
}
|
||||
|
||||
@ -100,7 +98,7 @@ public class BusProjectTeamController extends BaseController {
|
||||
@Log(title = "项目班组", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody BusProjectTeamUpdateReq req) {
|
||||
public R<Void> edit(@Validated @RequestBody BusProjectTeamUpdateReq req) {
|
||||
return toAjax(busProjectTeamService.updateByBo(req));
|
||||
}
|
||||
|
||||
|
@ -7,8 +7,6 @@ import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
@ -102,7 +100,7 @@ public class BusUserProjectRelevancyController extends BaseController {
|
||||
@Log(title = "系统用户与项目关联", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Long> add(@Validated(AddGroup.class) @RequestBody BusUserProjectRelevancyCreateReq req) {
|
||||
public R<Long> add(@Validated @RequestBody BusUserProjectRelevancyCreateReq req) {
|
||||
return R.ok(userProjectRelevancyService.insertByBo(req));
|
||||
}
|
||||
|
||||
@ -127,9 +125,9 @@ public class BusUserProjectRelevancyController extends BaseController {
|
||||
@DeleteMapping("/remove/project/list")
|
||||
public R<Boolean> removeBatchByProjectList(@RequestBody BusProjectBatchByProjectListReq req) {
|
||||
Long userId = req.getUserId();
|
||||
Long[] projectIdList = req.getProjectIdList();
|
||||
List<Long> projectIdList = req.getProjectIdList();
|
||||
QueryWrapper<BusUserProjectRelevancy> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("user_id", userId).in("project_id", (Object[]) projectIdList);
|
||||
wrapper.eq("user_id", userId).in("project_id", projectIdList);
|
||||
boolean result = userProjectRelevancyService.remove(wrapper);
|
||||
/* List<UserProjectRelevancy> userProjectRelevancyList = Arrays.stream(projectIdList).map(projectId -> {
|
||||
UserProjectRelevancy userProjectRelevancy = new UserProjectRelevancy();
|
||||
@ -149,7 +147,7 @@ public class BusUserProjectRelevancyController extends BaseController {
|
||||
@Log(title = "系统用户与项目关联", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody BusUserProjectRelevancyUpdateReq req) {
|
||||
public R<Void> edit(@Validated @RequestBody BusUserProjectRelevancyUpdateReq req) {
|
||||
return toAjax(userProjectRelevancyService.updateByBo(req));
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,11 @@ public class BusProjectTeam extends BaseEntity {
|
||||
*/
|
||||
private String isClockIn;
|
||||
|
||||
/**
|
||||
* 打卡范围
|
||||
*/
|
||||
private String punchRange;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
@ -36,4 +36,9 @@ public class BusUserProjectRelevancy implements Serializable {
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 用户类型(0系统管理员 1普通人员 2项目管理员)
|
||||
*/
|
||||
private String userType;
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lilemy
|
||||
@ -23,6 +24,6 @@ public class BusProjectBatchByProjectListReq implements Serializable {
|
||||
/**
|
||||
* 项目ID列表
|
||||
*/
|
||||
private Long[] projectIdList;
|
||||
private List<Long> projectIdList;
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
package org.dromara.project.domain.dto.projectteam;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lilemy
|
||||
@ -18,18 +21,26 @@ public class BusProjectTeamCreateReq implements Serializable {
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
@NotNull(message = "项目id不能为空")
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 班组名称
|
||||
*/
|
||||
@NotBlank(message = "班组名称不能为空")
|
||||
private String teamName;
|
||||
|
||||
/**
|
||||
* 范围内打卡(0范围内打卡 1任何地点打卡)默认为1
|
||||
*/
|
||||
@NotBlank(message = "范围内打卡")
|
||||
private String isClockIn;
|
||||
|
||||
/**
|
||||
* 打卡范围
|
||||
*/
|
||||
private List<String> punchRangeList;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
@ -15,11 +15,6 @@ public class BusProjectTeamQueryReq implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 3252651952758479341L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
|
@ -1,9 +1,11 @@
|
||||
package org.dromara.project.domain.dto.projectteam;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lilemy
|
||||
@ -18,6 +20,7 @@ public class BusProjectTeamUpdateReq implements Serializable {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@NotNull(message = "id不能为空")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
@ -35,6 +38,11 @@ public class BusProjectTeamUpdateReq implements Serializable {
|
||||
*/
|
||||
private String isClockIn;
|
||||
|
||||
/**
|
||||
* 打卡范围
|
||||
*/
|
||||
private List<String> punchRangeList;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
@ -1,5 +1,7 @@
|
||||
package org.dromara.project.domain.dto.userprojectrelevancy;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
@ -18,11 +20,19 @@ public class BusUserProjectRelevancyCreateReq implements Serializable {
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@NotNull(message = "用户ID不能为空")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 项目ID
|
||||
*/
|
||||
@NotNull(message = "项目ID不能为空")
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 用户类型(0系统管理员 1普通人员 2项目管理员)
|
||||
*/
|
||||
@NotBlank(message = "用户类型不能为空")
|
||||
private String userType;
|
||||
|
||||
}
|
||||
|
@ -15,11 +15,6 @@ public class BusUserProjectRelevancyQueryReq implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 3252651952758479341L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@ -29,4 +24,9 @@ public class BusUserProjectRelevancyQueryReq implements Serializable {
|
||||
* 项目ID
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 用户类型(0系统管理员 1普通人员 2项目管理员)
|
||||
*/
|
||||
private String userType;
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package org.dromara.project.domain.dto.userprojectrelevancy;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
@ -18,6 +20,7 @@ public class BusUserProjectRelevancyUpdateReq implements Serializable {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@NotNull(message = "主键ID不能为空")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
@ -30,4 +33,10 @@ public class BusUserProjectRelevancyUpdateReq implements Serializable {
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 用户类型(0系统管理员 1普通人员 2项目管理员)
|
||||
*/
|
||||
@NotBlank(message = "用户类型不能为空")
|
||||
private String userType;
|
||||
|
||||
}
|
||||
|
@ -40,6 +40,11 @@ public class BusLoginUserProjectRelevancyVo implements Serializable {
|
||||
*/
|
||||
private String shortName;
|
||||
|
||||
/**
|
||||
* 用户类型(0系统管理员 1普通人员 2项目管理员)
|
||||
*/
|
||||
private String userType;
|
||||
|
||||
/**
|
||||
* go项目id
|
||||
*/
|
||||
|
@ -44,6 +44,12 @@ public class BusUserProjectRelevancyVo implements Serializable {
|
||||
@ExcelProperty(value = "项目ID")
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 用户类型(0系统管理员 1普通人员 2项目管理员)
|
||||
*/
|
||||
@ExcelProperty(value = "用户类型(0系统管理员 1普通人员 2项目管理员)")
|
||||
private String userType;
|
||||
|
||||
/**
|
||||
* 项目详情
|
||||
*/
|
||||
|
@ -79,7 +79,7 @@ public interface IBusProjectTeamService extends IService<BusProjectTeam> {
|
||||
* @param projectId 项目id
|
||||
* @return 项目班组和班组长分页列表
|
||||
*/
|
||||
List<BusProjectTeamForemanVo> queryForemanList(Long projectId);
|
||||
List<BusProjectTeamForemanVo> queryForemanListByProjectId(Long projectId);
|
||||
|
||||
/**
|
||||
* 获取项目班组视图对象
|
||||
|
@ -62,16 +62,18 @@ public interface IBusUserProjectRelevancyService extends IService<BusUserProject
|
||||
*
|
||||
* @param projectId 项目ID
|
||||
* @param userIdList 用户ID列表
|
||||
* @param userType 用户类型
|
||||
*/
|
||||
void saveBatchByUserList(Long projectId, List<Long> userIdList);
|
||||
void saveBatchByUserList(Long projectId, List<Long> userIdList, String userType);
|
||||
|
||||
/**
|
||||
* 批量新增用户和项目关联
|
||||
*
|
||||
* @param projectIdList 项目ID列表
|
||||
* @param userId 用户ID
|
||||
* @param userType 用户类型
|
||||
*/
|
||||
void saveBatchByProjectList(List<Long> projectIdList, Long userId);
|
||||
void saveBatchByProjectList(List<Long> projectIdList, Long userId, String userType);
|
||||
|
||||
/**
|
||||
* 修改系统用户与项目关联
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.dromara.project.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
@ -16,6 +17,7 @@ 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.service.ISubConstructionUserService;
|
||||
import org.dromara.project.domain.BusProjectPunchrange;
|
||||
import org.dromara.project.domain.BusProjectTeam;
|
||||
import org.dromara.project.domain.BusProjectTeamMember;
|
||||
import org.dromara.project.domain.dto.projectteam.BusProjectTeamCreateReq;
|
||||
@ -26,17 +28,19 @@ import org.dromara.project.domain.vo.projectteam.BusForemanVo;
|
||||
import org.dromara.project.domain.vo.projectteam.BusProjectTeamForemanVo;
|
||||
import org.dromara.project.domain.vo.projectteam.BusProjectTeamVo;
|
||||
import org.dromara.project.mapper.BusProjectTeamMapper;
|
||||
import org.dromara.project.service.IBusProjectPunchrangeService;
|
||||
import org.dromara.project.service.IBusProjectService;
|
||||
import org.dromara.project.service.IBusProjectTeamMemberService;
|
||||
import org.dromara.project.service.IBusProjectTeamService;
|
||||
import org.dromara.system.domain.vo.SysUserVo;
|
||||
import org.dromara.system.service.ISysUserService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -49,9 +53,6 @@ import java.util.stream.Collectors;
|
||||
public class BusProjectTeamServiceImpl extends ServiceImpl<BusProjectTeamMapper, BusProjectTeam>
|
||||
implements IBusProjectTeamService {
|
||||
|
||||
@Resource
|
||||
private ISysUserService userService;
|
||||
|
||||
@Resource
|
||||
private IBusProjectService projectService;
|
||||
|
||||
@ -63,6 +64,9 @@ public class BusProjectTeamServiceImpl extends ServiceImpl<BusProjectTeamMapper,
|
||||
@Resource
|
||||
private ISubConstructionUserService constructionUserService;
|
||||
|
||||
@Resource
|
||||
private IBusProjectPunchrangeService projectPunchrangeService;
|
||||
|
||||
/**
|
||||
* 查询项目班组
|
||||
*
|
||||
@ -116,8 +120,22 @@ public class BusProjectTeamServiceImpl extends ServiceImpl<BusProjectTeamMapper,
|
||||
// 将实体类和 DTO 进行转换
|
||||
BusProjectTeam projectTeam = new BusProjectTeam();
|
||||
BeanUtils.copyProperties(req, projectTeam);
|
||||
List<String> punchRangeList = req.getPunchRangeList();
|
||||
if (CollUtil.isNotEmpty(punchRangeList)) {
|
||||
projectTeam.setPunchRange(JSONUtil.toJsonStr(punchRangeList));
|
||||
}
|
||||
// 数据校验
|
||||
validEntityBeforeSave(projectTeam);
|
||||
// 判断打卡范围是否存在
|
||||
if (CollUtil.isNotEmpty(punchRangeList)) {
|
||||
Long count = projectPunchrangeService.lambdaQuery()
|
||||
.in(BusProjectPunchrange::getId, punchRangeList)
|
||||
.eq(BusProjectPunchrange::getProjectId, projectTeam.getProjectId())
|
||||
.count();
|
||||
if (count != punchRangeList.size()) {
|
||||
throw new ServiceException("项目未配置考勤范围", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
// 操作数据库
|
||||
boolean save = this.save(projectTeam);
|
||||
if (!save) {
|
||||
@ -137,8 +155,22 @@ public class BusProjectTeamServiceImpl extends ServiceImpl<BusProjectTeamMapper,
|
||||
// 将实体类和 DTO 进行转换
|
||||
BusProjectTeam projectTeam = new BusProjectTeam();
|
||||
BeanUtils.copyProperties(req, projectTeam);
|
||||
List<String> punchRangeList = req.getPunchRangeList();
|
||||
if (CollUtil.isNotEmpty(punchRangeList)) {
|
||||
projectTeam.setPunchRange(JSONUtil.toJsonStr(punchRangeList));
|
||||
}
|
||||
// 数据校验
|
||||
validEntityBeforeSave(projectTeam);
|
||||
// 判断打卡范围是否存在
|
||||
if (CollUtil.isNotEmpty(punchRangeList)) {
|
||||
Long count = projectPunchrangeService.lambdaQuery()
|
||||
.in(BusProjectPunchrange::getId, punchRangeList)
|
||||
.eq(BusProjectPunchrange::getProjectId, projectTeam.getProjectId())
|
||||
.count();
|
||||
if (count != punchRangeList.size()) {
|
||||
throw new ServiceException("项目未配置考勤范围", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
// 判断是否存在
|
||||
BusProjectTeam oldProjectTeam = this.getById(projectTeam.getId());
|
||||
if (oldProjectTeam == null) {
|
||||
@ -154,6 +186,7 @@ public class BusProjectTeamServiceImpl extends ServiceImpl<BusProjectTeamMapper,
|
||||
private void validEntityBeforeSave(BusProjectTeam entity) {
|
||||
// TODO 做一些数据校验,如唯一约束
|
||||
Long projectId = entity.getProjectId();
|
||||
String isClockIn = entity.getIsClockIn();
|
||||
// 判断是否重名
|
||||
String teamName = entity.getTeamName();
|
||||
LambdaQueryWrapper<BusProjectTeam> queryWrapper = new LambdaQueryWrapper<>();
|
||||
@ -172,6 +205,13 @@ public class BusProjectTeamServiceImpl extends ServiceImpl<BusProjectTeamMapper,
|
||||
// 判断用户是否对项目下的内容有操作权限
|
||||
Long userId = LoginHelper.getUserId();
|
||||
projectService.validAuth(projectId, userId);
|
||||
// 校验范围内打卡是否选择了打卡范围
|
||||
if (StringUtils.isNotBlank(isClockIn) && isClockIn.equals("0")) {
|
||||
String punchRange = entity.getPunchRange();
|
||||
if (StringUtils.isBlank(punchRange)) {
|
||||
throw new ServiceException("请选择打卡范围", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -209,7 +249,7 @@ public class BusProjectTeamServiceImpl extends ServiceImpl<BusProjectTeamMapper,
|
||||
* @return 项目班组和班组长分页列表
|
||||
*/
|
||||
@Override
|
||||
public List<BusProjectTeamForemanVo> queryForemanList(Long projectId) {
|
||||
public List<BusProjectTeamForemanVo> queryForemanListByProjectId(Long projectId) {
|
||||
List<BusProjectTeam> projectTeamList = this.list(Wrappers.lambdaQuery(BusProjectTeam.class).eq(BusProjectTeam::getProjectId, projectId));
|
||||
if (CollUtil.isEmpty(projectTeamList)) {
|
||||
return List.of();
|
||||
@ -231,11 +271,6 @@ public class BusProjectTeamServiceImpl extends ServiceImpl<BusProjectTeamMapper,
|
||||
List<SubConstructionUser> foremanList = constructionUserService.listByIds(foremanIdList);
|
||||
Map<Long, List<SubConstructionUser>> foremanMap = foremanList.stream()
|
||||
.collect(Collectors.groupingBy(SubConstructionUser::getTeamId));
|
||||
// 获取系统用户信息
|
||||
List<Long> sysUserIds = foremanList.stream().map(SubConstructionUser::getSysUserId).filter(Objects::nonNull).distinct().toList();
|
||||
List<SysUserVo> sysUserList = userService.selectUserByIds(sysUserIds, null);
|
||||
Map<Long, String> sysUserMap = sysUserList.stream()
|
||||
.collect(Collectors.toMap(SysUserVo::getUserId, SysUserVo::getNickName));
|
||||
// 封装数据
|
||||
return projectTeamList.stream().map(projectTeam -> {
|
||||
BusProjectTeamForemanVo projectTeamForemanResp = new BusProjectTeamForemanVo();
|
||||
@ -249,13 +284,11 @@ public class BusProjectTeamServiceImpl extends ServiceImpl<BusProjectTeamMapper,
|
||||
BusForemanVo foremanVo = new BusForemanVo();
|
||||
Long sysUserId = constructionUser.getSysUserId();
|
||||
if (sysUserId != null) {
|
||||
String userName = sysUserMap.get(sysUserId);
|
||||
foremanVo.setForemanId(sysUserId);
|
||||
foremanVo.setForemanName(userName);
|
||||
foremanVo.setForemanName(constructionUser.getUserName());
|
||||
}
|
||||
return foremanVo;
|
||||
})
|
||||
.toList();
|
||||
}).toList();
|
||||
projectTeamForemanResp.setForemanList(foremanVoList);
|
||||
}
|
||||
return projectTeamForemanResp;
|
||||
@ -297,7 +330,6 @@ public class BusProjectTeamServiceImpl extends ServiceImpl<BusProjectTeamMapper,
|
||||
return lqw;
|
||||
}
|
||||
// 从对象中取值
|
||||
Long id = req.getId();
|
||||
Long projectId = req.getProjectId();
|
||||
String teamName = req.getTeamName();
|
||||
String isClockIn = req.getIsClockIn();
|
||||
@ -306,7 +338,6 @@ public class BusProjectTeamServiceImpl extends ServiceImpl<BusProjectTeamMapper,
|
||||
lqw.like(StringUtils.isNotBlank(teamName), BusProjectTeam::getTeamName, teamName);
|
||||
lqw.like(StringUtils.isNotBlank(remark), BusProjectTeam::getRemark, remark);
|
||||
// 精确查询
|
||||
lqw.eq(ObjectUtils.isNotEmpty(id), BusProjectTeam::getId, id);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(projectId), BusProjectTeam::getProjectId, projectId);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(isClockIn), BusProjectTeam::getIsClockIn, isClockIn);
|
||||
return lqw;
|
||||
|
@ -10,6 +10,7 @@ import jakarta.annotation.Resource;
|
||||
import org.dromara.common.core.constant.HttpStatus;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.ObjectUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
@ -127,10 +128,11 @@ public class BusUserProjectRelevancyServiceImpl extends ServiceImpl<BusUserProje
|
||||
*
|
||||
* @param projectId 项目ID
|
||||
* @param userIdList 用户ID列表
|
||||
* @param userType 用户类型
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveBatchByUserList(Long projectId, List<Long> userIdList) {
|
||||
public void saveBatchByUserList(Long projectId, List<Long> userIdList, String userType) {
|
||||
if (ObjectUtils.isEmpty(projectId) || ObjectUtils.isEmpty(userIdList)) {
|
||||
return;
|
||||
}
|
||||
@ -138,6 +140,7 @@ public class BusUserProjectRelevancyServiceImpl extends ServiceImpl<BusUserProje
|
||||
BusUserProjectRelevancy userProjectRelevancy = new BusUserProjectRelevancy();
|
||||
userProjectRelevancy.setUserId(userId);
|
||||
userProjectRelevancy.setProjectId(projectId);
|
||||
userProjectRelevancy.setUserType(userType);
|
||||
return userProjectRelevancy;
|
||||
}).toList();
|
||||
boolean saveRelevancy = this.saveBatch(userProjectRelevancyList);
|
||||
@ -151,17 +154,19 @@ public class BusUserProjectRelevancyServiceImpl extends ServiceImpl<BusUserProje
|
||||
*
|
||||
* @param projectIdList 项目ID列表
|
||||
* @param userId 用户ID
|
||||
* @param userType 用户类型
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveBatchByProjectList(List<Long> projectIdList, Long userId) {
|
||||
if (ObjectUtils.isEmpty(projectIdList) || ObjectUtils.isEmpty(userId)) {
|
||||
public void saveBatchByProjectList(List<Long> projectIdList, Long userId, String userType) {
|
||||
if (ObjectUtils.isEmpty(projectIdList) || ObjectUtils.isEmpty(userId) || StringUtils.isBlank(userType)) {
|
||||
return;
|
||||
}
|
||||
List<BusUserProjectRelevancy> userProjectRelevancyList = projectIdList.stream().map(projectId -> {
|
||||
BusUserProjectRelevancy userProjectRelevancy = new BusUserProjectRelevancy();
|
||||
userProjectRelevancy.setUserId(userId);
|
||||
userProjectRelevancy.setProjectId(projectId);
|
||||
userProjectRelevancy.setUserType(userType);
|
||||
return userProjectRelevancy;
|
||||
}).toList();
|
||||
boolean saveRelevancy = this.saveBatch(userProjectRelevancyList);
|
||||
@ -361,12 +366,12 @@ public class BusUserProjectRelevancyServiceImpl extends ServiceImpl<BusUserProje
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insertBatchByProjectList(BusProjectBatchByProjectListReq req) {
|
||||
Long userId = req.getUserId();
|
||||
Long[] projectIdList = req.getProjectIdList();
|
||||
long count = projectService.count(new QueryWrapper<BusProject>().in("id", (Object[]) projectIdList));
|
||||
if (count < projectIdList.length) {
|
||||
List<Long> projectIdList = req.getProjectIdList();
|
||||
long count = projectService.count(new QueryWrapper<BusProject>().in("id", projectIdList));
|
||||
if (count < projectIdList.size()) {
|
||||
throw new ServiceException("项目ID列表错误,一个或多个项目不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
List<BusUserProjectRelevancy> userProjectRelevancyList = Arrays.stream(projectIdList).map(projectId -> {
|
||||
List<BusUserProjectRelevancy> userProjectRelevancyList = projectIdList.stream().map(projectId -> {
|
||||
BusUserProjectRelevancy userProjectRelevancy = new BusUserProjectRelevancy();
|
||||
userProjectRelevancy.setUserId(userId);
|
||||
userProjectRelevancy.setProjectId(projectId);
|
||||
@ -423,13 +428,13 @@ public class BusUserProjectRelevancyServiceImpl extends ServiceImpl<BusUserProje
|
||||
return queryWrapper;
|
||||
}
|
||||
// 从对象中取值
|
||||
Long id = req.getId();
|
||||
Long userId = req.getUserId();
|
||||
Long projectId = req.getProjectId();
|
||||
String userType = req.getUserType();
|
||||
// 精确查询
|
||||
queryWrapper.eq(ObjectUtils.isNotEmpty(id), BusUserProjectRelevancy::getId, id);
|
||||
queryWrapper.eq(ObjectUtils.isNotEmpty(userId), BusUserProjectRelevancy::getUserId, userId);
|
||||
queryWrapper.eq(ObjectUtils.isNotEmpty(projectId), BusUserProjectRelevancy::getProjectId, projectId);
|
||||
queryWrapper.eq(StringUtils.isNotBlank(userType), BusUserProjectRelevancy::getUserType, userType);
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,28 @@
|
||||
package org.dromara.system.domain.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author lilemy
|
||||
* @date 2025-08-06 14:47
|
||||
*/
|
||||
@Getter
|
||||
public enum SysContractorRoleEnum {
|
||||
|
||||
MANAGER("manager", "管理人员",1),
|
||||
FOREMAN("foreman", "班组长",2),
|
||||
WORKER("worker", "工人",3);
|
||||
|
||||
private final String code;
|
||||
|
||||
private final String name;
|
||||
|
||||
private final int sort;
|
||||
|
||||
SysContractorRoleEnum(String code, String name,int sort) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
}
|
@ -9,10 +9,11 @@ import lombok.Getter;
|
||||
@Getter
|
||||
public enum SysDeptTypeEnum {
|
||||
|
||||
NORMAL("1", "正常"),
|
||||
SPECIAL("2", "特殊"),
|
||||
PROJECT("3", "项目"),
|
||||
CONTRACT("4", "分包");
|
||||
COMPANY("1", "总公司"),
|
||||
SUB_COMPANY("2", "子公司"),
|
||||
SPECIAL("3", "特殊"),
|
||||
PROJECT("4", "项目"),
|
||||
CONTRACT("5", "分包");
|
||||
|
||||
private final String code;
|
||||
|
||||
|
@ -32,6 +32,7 @@ import org.dromara.system.domain.SysPost;
|
||||
import org.dromara.system.domain.SysRole;
|
||||
import org.dromara.system.domain.SysUser;
|
||||
import org.dromara.system.domain.bo.SysDeptBo;
|
||||
import org.dromara.system.domain.enums.SysContractorRoleEnum;
|
||||
import org.dromara.system.domain.enums.SysDeptTypeEnum;
|
||||
import org.dromara.system.domain.vo.SysDeptVo;
|
||||
import org.dromara.system.domain.vo.SysPostVo;
|
||||
@ -489,6 +490,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
dept.setProjectId(projectId);
|
||||
// 判断是否有需要新增项目关联的用户
|
||||
List<Long> deptIds = this.getParentAndSiblingDeptIds(dept);
|
||||
deptIds.remove(dept.getDeptId());
|
||||
LambdaQueryWrapper<SysUser> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.select(SysUser::getUserId);
|
||||
lqw.in(SysUser::getDeptId, deptIds);
|
||||
@ -497,7 +499,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
.filter(userId -> !LoginHelper.isSuperAdmin(userId))
|
||||
.toList();
|
||||
if (CollUtil.isNotEmpty(userIds)) {
|
||||
userProjectRelevancyService.saveBatchByUserList(projectId, userIds);
|
||||
userProjectRelevancyService.saveBatchByUserList(projectId, userIds, "2");
|
||||
}
|
||||
} else if (SysDeptTypeEnum.CONTRACT.getCode().equals(deptType)) {
|
||||
// 分包部门
|
||||
@ -533,7 +535,29 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
dept.setProjectId(projectId);
|
||||
dept.setContractorId(contractorId);
|
||||
}
|
||||
return baseMapper.insert(dept);
|
||||
int insert = baseMapper.insert(dept);
|
||||
if (insert < 1) {
|
||||
throw new ServiceException("添加部门失败", HttpStatus.ERROR);
|
||||
}
|
||||
if (SysDeptTypeEnum.CONTRACT.getCode().equals(deptType)) {
|
||||
// 分包部门,自动创建下面的角色
|
||||
Long deptId = dept.getDeptId();
|
||||
List<SysContractorRoleEnum> roleNameList = List.of(SysContractorRoleEnum.values());
|
||||
List<SysRole> roles = roleNameList.stream().map(item -> {
|
||||
SysRole role = new SysRole();
|
||||
role.setDeptId(deptId);
|
||||
role.setRoleName(item.getName());
|
||||
role.setRoleKey(dept.getContractorId() + "_" + item.getCode());
|
||||
role.setStatus("0");
|
||||
role.setRoleSort(item.getSort());
|
||||
return role;
|
||||
}).toList();
|
||||
boolean b = roleMapper.insertBatch(roles);
|
||||
if (!b) {
|
||||
throw new ServiceException("添加部门角色失败");
|
||||
}
|
||||
}
|
||||
return insert;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -587,6 +611,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
}
|
||||
// 获取当前部门及其上级部门 ID 列表
|
||||
List<Long> deptIds = this.getParentAndSiblingDeptIds(dept);
|
||||
deptIds.remove(dept.getDeptId());
|
||||
// 获取部门用户 ID
|
||||
LambdaQueryWrapper<SysUser> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.select(SysUser::getUserId);
|
||||
@ -599,10 +624,10 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
// 情况 1:原本有项目,且项目 ID 改变 → 删除旧的,添加新的
|
||||
if (oldProjectId != null) {
|
||||
userProjectRelevancyService.deleteByProjectAndUserIds(oldProjectId, userIds);
|
||||
userProjectRelevancyService.saveBatchByUserList(newProjectId, userIds);
|
||||
userProjectRelevancyService.saveBatchByUserList(newProjectId, userIds, "2");
|
||||
} else {
|
||||
// 情况 2:原本没有项目,现在新增了 → 直接添加
|
||||
userProjectRelevancyService.saveBatchByUserList(newProjectId, userIds);
|
||||
userProjectRelevancyService.saveBatchByUserList(newProjectId, userIds, "2");
|
||||
}
|
||||
}
|
||||
dept.setProjectId(newProjectId);
|
||||
|
@ -15,6 +15,7 @@ import jakarta.annotation.Resource;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.constant.CacheNames;
|
||||
import org.dromara.common.core.constant.HttpStatus;
|
||||
import org.dromara.common.core.constant.SystemConstants;
|
||||
import org.dromara.common.core.domain.dto.UserDTO;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
@ -23,10 +24,13 @@ 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.service.ISubConstructionUserService;
|
||||
import org.dromara.project.domain.dto.userprojectrelevancy.BusUserProjectRelevancyCreateReq;
|
||||
import org.dromara.project.service.IBusUserProjectRelevancyService;
|
||||
import org.dromara.system.domain.*;
|
||||
import org.dromara.system.domain.bo.SysUserBo;
|
||||
import org.dromara.system.domain.enums.SysContractorRoleEnum;
|
||||
import org.dromara.system.domain.enums.SysDeptTypeEnum;
|
||||
import org.dromara.system.domain.vo.*;
|
||||
import org.dromara.system.mapper.*;
|
||||
@ -60,6 +64,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
private final SysUserPostMapper userPostMapper;
|
||||
private final ISysDeptService deptService;
|
||||
private final IBusUserProjectRelevancyService userProjectRelevancyService;
|
||||
private final ISubConstructionUserService constructionUserService;
|
||||
|
||||
@Lazy
|
||||
@Resource
|
||||
@ -335,16 +340,40 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
insertUserRole(user, false);
|
||||
Long deptId = user.getDeptId();
|
||||
SysDeptVo deptVo = deptService.selectDeptById(deptId);
|
||||
if (deptVo.getDeptType().equals(SysDeptTypeEnum.CONTRACT.getCode())) {
|
||||
String deptType = deptVo.getDeptType();
|
||||
if (deptType.equals(SysDeptTypeEnum.CONTRACT.getCode())) {
|
||||
// 关联分包部门所属项目
|
||||
BusUserProjectRelevancyCreateReq req = new BusUserProjectRelevancyCreateReq();
|
||||
req.setUserId(user.getUserId());
|
||||
req.setProjectId(deptVo.getProjectId());
|
||||
req.setUserType("1");
|
||||
userProjectRelevancyService.insertByBo(req);
|
||||
Long[] roleIds = user.getRoleIds();
|
||||
if (roleIds.length > 1) {
|
||||
throw new ServiceException("分包部门只能关联一个角色", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
Long roleId = roleIds[0];
|
||||
SysRole sysRole = roleMapper.selectById(roleId);
|
||||
if (sysRole.getRoleName().equals(SysContractorRoleEnum.MANAGER.getName())) {
|
||||
SubConstructionUser constructionUser = constructionUserService.getBySysUserId(user.getUserId());
|
||||
constructionUser.setUserRole(SysContractorRoleEnum.MANAGER.getName());
|
||||
constructionUserService.updateById(constructionUser);
|
||||
}
|
||||
} else {
|
||||
// 关联部门所属项目
|
||||
List<Long> projectIds = deptService.selectProjectIdById(deptId);
|
||||
userProjectRelevancyService.saveBatchByProjectList(projectIds, user.getUserId());
|
||||
String userType = "1";
|
||||
if (deptType.equals(SysDeptTypeEnum.COMPANY.getCode()) || deptType.equals(SysDeptTypeEnum.SUB_COMPANY.getCode())) {
|
||||
userType = "2";
|
||||
}
|
||||
if (deptType.equals(SysDeptTypeEnum.SPECIAL.getCode())) {
|
||||
// 判断父部门是否为总部门或子部门
|
||||
SysDeptVo parentDept = deptService.selectDeptById(deptVo.getParentId());
|
||||
if (parentDept.getDeptType().equals(SysDeptTypeEnum.COMPANY.getCode()) || parentDept.getDeptType().equals(SysDeptTypeEnum.SUB_COMPANY.getCode())) {
|
||||
userType = "2";
|
||||
}
|
||||
}
|
||||
userProjectRelevancyService.saveBatchByProjectList(projectIds, user.getUserId(), userType);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
@ -392,20 +421,33 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
}
|
||||
Long deptId = user.getDeptId();
|
||||
SysDeptVo deptVo = deptService.selectDeptById(deptId);
|
||||
if (deptVo.getDeptType().equals(SysDeptTypeEnum.CONTRACT.getCode())) {
|
||||
String deptType = deptVo.getDeptType();
|
||||
if (deptType.equals(SysDeptTypeEnum.CONTRACT.getCode())) {
|
||||
// 先删除旧关联
|
||||
userProjectRelevancyService.deleteByUserId(user.getUserId());
|
||||
// 添加新关联
|
||||
BusUserProjectRelevancyCreateReq req = new BusUserProjectRelevancyCreateReq();
|
||||
req.setUserId(user.getUserId());
|
||||
req.setProjectId(deptVo.getProjectId());
|
||||
req.setUserType("1");
|
||||
userProjectRelevancyService.insertByBo(req);
|
||||
} else {
|
||||
// 先删除旧关联
|
||||
userProjectRelevancyService.deleteByUserId(user.getUserId());
|
||||
// 添加新关联
|
||||
List<Long> projectIds = deptService.selectProjectIdById(user.getDeptId());
|
||||
userProjectRelevancyService.saveBatchByProjectList(projectIds, user.getUserId());
|
||||
String userType = "1";
|
||||
if (deptType.equals(SysDeptTypeEnum.COMPANY.getCode()) || deptType.equals(SysDeptTypeEnum.SUB_COMPANY.getCode())) {
|
||||
userType = "2";
|
||||
}
|
||||
if (deptType.equals(SysDeptTypeEnum.SPECIAL.getCode())) {
|
||||
// 判断父部门是否为总部门或子部门
|
||||
SysDeptVo parentDept = deptService.selectDeptById(deptVo.getParentId());
|
||||
if (parentDept.getDeptType().equals(SysDeptTypeEnum.COMPANY.getCode()) || parentDept.getDeptType().equals(SysDeptTypeEnum.SUB_COMPANY.getCode())) {
|
||||
userType = "2";
|
||||
}
|
||||
}
|
||||
userProjectRelevancyService.saveBatchByProjectList(projectIds, user.getUserId(), userType);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
@ -625,7 +667,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
LambdaQueryWrapper<SysUserPost> lqw = Wrappers.lambdaQuery();
|
||||
lqw.in(SysUserPost::getPostId, postIds);
|
||||
List<SysUserPost> userPostList = userPostMapper.selectList(lqw);
|
||||
if (CollUtil.isNotEmpty(userPostList)){
|
||||
if (CollUtil.isNotEmpty(userPostList)) {
|
||||
List<Long> userIds = userPostList.stream().map(SysUserPost::getUserId).distinct().toList();
|
||||
return baseMapper.selectVoByIds(userIds);
|
||||
}
|
||||
|
Reference in New Issue
Block a user