施工人员黑名单后端逻辑优化,增加前端页面
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
package org.dromara.project.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
@ -61,7 +63,7 @@ public class BusConstructionUser extends BaseEntity {
|
||||
/**
|
||||
* 是否代打
|
||||
*/
|
||||
private Long isPinch;
|
||||
private String isPinch;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
@ -71,7 +73,7 @@ public class BusConstructionUser extends BaseEntity {
|
||||
/**
|
||||
* 0:保密 1:男 2女
|
||||
*/
|
||||
private Long sex;
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 民族
|
||||
@ -156,12 +158,12 @@ public class BusConstructionUser extends BaseEntity {
|
||||
/**
|
||||
* 入场时间
|
||||
*/
|
||||
private String entryDate;
|
||||
private Date entryDate;
|
||||
|
||||
/**
|
||||
* 离场时间
|
||||
*/
|
||||
private String leaveDate;
|
||||
private Date leaveDate;
|
||||
|
||||
/**
|
||||
* 薪水
|
||||
|
||||
@ -1,45 +0,0 @@
|
||||
package org.dromara.project.domain.bo;
|
||||
|
||||
import org.dromara.project.domain.BusConstructionBlacklist;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 黑名单业务对象 bus_construction_blacklist
|
||||
*
|
||||
* @author lcj
|
||||
* @date 2025-03-27
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = BusConstructionBlacklist.class, reverseConvertGenerate = false)
|
||||
public class BusConstructionBlacklistBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@NotNull(message = "用户id不能为空", groups = { AddGroup.class })
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 名字
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 身份证号码
|
||||
*/
|
||||
private String sfzNumber;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@ -35,11 +35,6 @@ public class ConstructionUserCreateReq implements Serializable {
|
||||
*/
|
||||
private Long contractorId;
|
||||
|
||||
/**
|
||||
* 班组id
|
||||
*/
|
||||
private Long teamId;
|
||||
|
||||
/**
|
||||
* 状态(0在职 1离职)
|
||||
*/
|
||||
@ -48,7 +43,7 @@ public class ConstructionUserCreateReq implements Serializable {
|
||||
/**
|
||||
* 是否代打
|
||||
*/
|
||||
private Long isPinch;
|
||||
private String isPinch;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
@ -58,7 +53,7 @@ public class ConstructionUserCreateReq implements Serializable {
|
||||
/**
|
||||
* 0:保密 1:男 2女
|
||||
*/
|
||||
private Long sex;
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 民族
|
||||
@ -140,16 +135,6 @@ public class ConstructionUserCreateReq implements Serializable {
|
||||
*/
|
||||
private String clock;
|
||||
|
||||
/**
|
||||
* 入场时间
|
||||
*/
|
||||
private String entryDate;
|
||||
|
||||
/**
|
||||
* 离场时间
|
||||
*/
|
||||
private String leaveDate;
|
||||
|
||||
/**
|
||||
* 薪水
|
||||
*/
|
||||
|
||||
@ -53,7 +53,7 @@ public class ConstructionUserQueryReq implements Serializable {
|
||||
/**
|
||||
* 是否代打
|
||||
*/
|
||||
private Long isPinch;
|
||||
private String isPinch;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
@ -63,7 +63,7 @@ public class ConstructionUserQueryReq implements Serializable {
|
||||
/**
|
||||
* 0:保密 1:男 2女
|
||||
*/
|
||||
private Long sex;
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 民族
|
||||
@ -75,26 +75,6 @@ public class ConstructionUserQueryReq implements Serializable {
|
||||
*/
|
||||
private String sfzNumber;
|
||||
|
||||
/**
|
||||
* 身份证有效开始期
|
||||
*/
|
||||
private String sfzStart;
|
||||
|
||||
/**
|
||||
* 身份证有效结束期
|
||||
*/
|
||||
private String sfzEnd;
|
||||
|
||||
/**
|
||||
* 身份证地址
|
||||
*/
|
||||
private String sfzSite;
|
||||
|
||||
/**
|
||||
* 身份证出生日期
|
||||
*/
|
||||
private String sfzBirth;
|
||||
|
||||
/**
|
||||
* 籍贯
|
||||
*/
|
||||
|
||||
@ -40,11 +40,6 @@ public class ConstructionUserUpdateReq implements Serializable {
|
||||
*/
|
||||
private Long contractorId;
|
||||
|
||||
/**
|
||||
* 班组id
|
||||
*/
|
||||
private Long teamId;
|
||||
|
||||
/**
|
||||
* 状态(0在职 1离职)
|
||||
*/
|
||||
@ -53,7 +48,7 @@ public class ConstructionUserUpdateReq implements Serializable {
|
||||
/**
|
||||
* 是否代打
|
||||
*/
|
||||
private Long isPinch;
|
||||
private String isPinch;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
@ -63,7 +58,7 @@ public class ConstructionUserUpdateReq implements Serializable {
|
||||
/**
|
||||
* 0:保密 1:男 2女
|
||||
*/
|
||||
private Long sex;
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 民族
|
||||
@ -145,16 +140,6 @@ public class ConstructionUserUpdateReq implements Serializable {
|
||||
*/
|
||||
private String clock;
|
||||
|
||||
/**
|
||||
* 入场时间
|
||||
*/
|
||||
private String entryDate;
|
||||
|
||||
/**
|
||||
* 离场时间
|
||||
*/
|
||||
private String leaveDate;
|
||||
|
||||
/**
|
||||
* 薪水
|
||||
*/
|
||||
|
||||
@ -66,7 +66,6 @@ public class BusConstructionUserVo implements Serializable {
|
||||
/**
|
||||
* 分包公司
|
||||
*/
|
||||
@ExcelProperty(value = "分包公司")
|
||||
private BusContractorVo contractorVo;
|
||||
|
||||
/**
|
||||
@ -78,7 +77,6 @@ public class BusConstructionUserVo implements Serializable {
|
||||
/**
|
||||
* 班组
|
||||
*/
|
||||
@ExcelProperty(value = "班组")
|
||||
private BusProjectTeamVo teamVo;
|
||||
|
||||
/**
|
||||
@ -92,7 +90,7 @@ public class BusConstructionUserVo implements Serializable {
|
||||
* 是否代打
|
||||
*/
|
||||
@ExcelProperty(value = "是否代打")
|
||||
private Long isPinch;
|
||||
private String isPinch;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
@ -103,8 +101,9 @@ public class BusConstructionUserVo implements Serializable {
|
||||
/**
|
||||
* 0:保密 1:男 2女
|
||||
*/
|
||||
@ExcelProperty(value = "0:保密 1:男 2女")
|
||||
private Long sex;
|
||||
@ExcelProperty(value = "性别", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(dictType = "user_sex_type")
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 民族
|
||||
@ -207,13 +206,13 @@ public class BusConstructionUserVo implements Serializable {
|
||||
* 入场时间
|
||||
*/
|
||||
@ExcelProperty(value = "入场时间")
|
||||
private String entryDate;
|
||||
private Date entryDate;
|
||||
|
||||
/**
|
||||
* 离场时间
|
||||
*/
|
||||
@ExcelProperty(value = "离场时间")
|
||||
private String leaveDate;
|
||||
private Date leaveDate;
|
||||
|
||||
/**
|
||||
* 薪水
|
||||
|
||||
@ -62,6 +62,14 @@ public interface IBusConstructionBlacklistService extends IService<BusConstructi
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
/**
|
||||
* 校验用户是否在黑名单中
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param projectId 项目id
|
||||
*/
|
||||
void validUserInBlacklist(Long userId, Long projectId);
|
||||
|
||||
/**
|
||||
* 获取黑名单查询条件封装
|
||||
*
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package org.dromara.project.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@ -14,6 +15,7 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.project.domain.BusConstructionBlacklist;
|
||||
import org.dromara.project.domain.BusConstructionUser;
|
||||
import org.dromara.project.domain.BusProjectTeamMember;
|
||||
import org.dromara.project.domain.req.constructionblacklist.ConstructionBlacklistCreateReq;
|
||||
import org.dromara.project.domain.req.constructionblacklist.ConstructionBlacklistQueryReq;
|
||||
import org.dromara.project.domain.vo.BusConstructionBlacklistVo;
|
||||
@ -21,11 +23,14 @@ import org.dromara.project.mapper.BusConstructionBlacklistMapper;
|
||||
import org.dromara.project.service.IBusConstructionBlacklistService;
|
||||
import org.dromara.project.service.IBusConstructionUserService;
|
||||
import org.dromara.project.service.IBusProjectService;
|
||||
import org.dromara.project.service.IBusProjectTeamMemberService;
|
||||
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.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -44,6 +49,10 @@ public class BusConstructionBlacklistServiceImpl extends ServiceImpl<BusConstruc
|
||||
@Resource
|
||||
private IBusConstructionUserService constructionUserService;
|
||||
|
||||
@Lazy
|
||||
@Resource
|
||||
private IBusProjectTeamMemberService projectTeamMemberService;
|
||||
|
||||
/**
|
||||
* 查询黑名单
|
||||
*
|
||||
@ -88,6 +97,7 @@ public class BusConstructionBlacklistServiceImpl extends ServiceImpl<BusConstruc
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long insertByBo(ConstructionBlacklistCreateReq req) {
|
||||
// 将实体类和 DTO 进行转换
|
||||
BusConstructionBlacklist constructionBlacklist = new BusConstructionBlacklist();
|
||||
@ -110,6 +120,28 @@ public class BusConstructionBlacklistServiceImpl extends ServiceImpl<BusConstruc
|
||||
if (!result) {
|
||||
throw new ServiceException("新增黑名单失败,数据库异常", HttpStatus.ERROR);
|
||||
}
|
||||
// 如果加入黑名单用户已在班组,则移除
|
||||
Long teamId = constructionUser.getTeamId();
|
||||
if (teamId != null) {
|
||||
// 修改用户team_id字段
|
||||
LambdaUpdateWrapper<BusConstructionUser> constructionUserLqw = Wrappers.lambdaUpdate(BusConstructionUser.class)
|
||||
.eq(BusConstructionUser::getId, userId)
|
||||
.set(BusConstructionUser::getTeamId, null)
|
||||
.set(BusConstructionUser::getLeaveDate, new Date());
|
||||
boolean update = constructionUserService.update(constructionUserLqw);
|
||||
if (!update) {
|
||||
throw new ServiceException("用户退场失败,数据库异常", HttpStatus.ERROR);
|
||||
}
|
||||
// 移除用户与班组关联
|
||||
LambdaQueryWrapper<BusProjectTeamMember> projectTeamMemberLqw = Wrappers.lambdaQuery(BusProjectTeamMember.class)
|
||||
.eq(BusProjectTeamMember::getProjectId, req.getProjectId())
|
||||
.eq(BusProjectTeamMember::getTeamId, teamId)
|
||||
.eq(BusProjectTeamMember::getMemberId, userId);
|
||||
boolean remove = projectTeamMemberService.remove(projectTeamMemberLqw);
|
||||
if (!remove) {
|
||||
throw new ServiceException("用户退场失败,数据库异常", HttpStatus.ERROR);
|
||||
}
|
||||
}
|
||||
return constructionBlacklist.getId();
|
||||
}
|
||||
|
||||
@ -155,6 +187,22 @@ public class BusConstructionBlacklistServiceImpl extends ServiceImpl<BusConstruc
|
||||
return this.removeBatchByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验用户是否在黑名单中
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param projectId 项目id
|
||||
*/
|
||||
@Override
|
||||
public void validUserInBlacklist(Long userId, Long projectId) {
|
||||
LambdaQueryWrapper<BusConstructionBlacklist> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(BusConstructionBlacklist::getUserId, userId)
|
||||
.eq(BusConstructionBlacklist::getProjectId, projectId);
|
||||
if (this.count(lqw) > 0) {
|
||||
throw new ServiceException("用户已存在黑名单中", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取黑名单查询条件封装
|
||||
*
|
||||
|
||||
@ -14,14 +14,13 @@ 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;
|
||||
import org.dromara.project.domain.BusConstructionUser;
|
||||
import org.dromara.project.domain.BusContractor;
|
||||
import org.dromara.project.domain.BusProjectTeamMember;
|
||||
import org.dromara.project.domain.*;
|
||||
import org.dromara.project.domain.req.constructionuser.ConstructionUserCreateReq;
|
||||
import org.dromara.project.domain.req.constructionuser.ConstructionUserQueryReq;
|
||||
import org.dromara.project.domain.req.constructionuser.ConstructionUserUpdateReq;
|
||||
import org.dromara.project.domain.vo.BusConstructionUserVo;
|
||||
import org.dromara.project.domain.vo.BusContractorVo;
|
||||
import org.dromara.project.domain.vo.BusProjectTeamVo;
|
||||
import org.dromara.project.mapper.BusConstructionUserMapper;
|
||||
import org.dromara.project.service.*;
|
||||
import org.dromara.system.service.ISysOssService;
|
||||
@ -63,6 +62,10 @@ public class BusConstructionUserServiceImpl extends ServiceImpl<BusConstructionU
|
||||
@Resource
|
||||
private ISysOssService ossService;
|
||||
|
||||
@Lazy
|
||||
@Resource
|
||||
private IBusConstructionBlacklistService constructionBlacklistService;
|
||||
|
||||
/**
|
||||
* 查询施工人员
|
||||
*
|
||||
@ -257,15 +260,11 @@ public class BusConstructionUserServiceImpl extends ServiceImpl<BusConstructionU
|
||||
Long teamId = req.getTeamId();
|
||||
Long notTeamId = req.getNotTeamId();
|
||||
String status = req.getStatus();
|
||||
Long isPinch = req.getIsPinch();
|
||||
String isPinch = req.getIsPinch();
|
||||
String phone = req.getPhone();
|
||||
Long sex = req.getSex();
|
||||
String sex = req.getSex();
|
||||
String nation = req.getNation();
|
||||
String sfzNumber = req.getSfzNumber();
|
||||
String sfzStart = req.getSfzStart();
|
||||
String sfzEnd = req.getSfzEnd();
|
||||
String sfzSite = req.getSfzSite();
|
||||
String sfzBirth = req.getSfzBirth();
|
||||
String nativePlace = req.getNativePlace();
|
||||
String yhkNumber = req.getYhkNumber();
|
||||
String yhkOpeningBank = req.getYhkOpeningBank();
|
||||
@ -280,22 +279,18 @@ public class BusConstructionUserServiceImpl extends ServiceImpl<BusConstructionU
|
||||
lqw.like(StringUtils.isNotBlank(phone), BusConstructionUser::getPhone, phone);
|
||||
lqw.like(StringUtils.isNotBlank(nation), BusConstructionUser::getNation, nation);
|
||||
lqw.like(StringUtils.isNotBlank(sfzNumber), BusConstructionUser::getSfzNumber, sfzNumber);
|
||||
lqw.like(StringUtils.isNotBlank(sfzStart), BusConstructionUser::getSfzStart, sfzStart);
|
||||
lqw.like(StringUtils.isNotBlank(sfzEnd), BusConstructionUser::getSfzEnd, sfzEnd);
|
||||
lqw.like(StringUtils.isNotBlank(sfzSite), BusConstructionUser::getSfzSite, sfzSite);
|
||||
lqw.like(StringUtils.isNotBlank(sfzBirth), BusConstructionUser::getSfzBirth, sfzBirth);
|
||||
lqw.like(StringUtils.isNotBlank(nativePlace), BusConstructionUser::getNativePlace, nativePlace);
|
||||
lqw.like(StringUtils.isNotBlank(yhkNumber), BusConstructionUser::getYhkNumber, yhkNumber);
|
||||
lqw.like(StringUtils.isNotBlank(yhkOpeningBank), BusConstructionUser::getYhkOpeningBank, yhkOpeningBank);
|
||||
lqw.like(StringUtils.isNotBlank(yhkCardholder), BusConstructionUser::getYhkCardholder, yhkCardholder);
|
||||
// 精确查询
|
||||
lqw.eq(ObjectUtils.isNotEmpty(status), BusConstructionUser::getStatus, status);
|
||||
lqw.eq(StringUtils.isNotBlank(status), BusConstructionUser::getStatus, status);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(id), BusConstructionUser::getId, id);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(projectId), BusConstructionUser::getProjectId, projectId);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(contractorId), BusConstructionUser::getContractorId, contractorId);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(teamId), BusConstructionUser::getTeamId, teamId);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(isPinch), BusConstructionUser::getIsPinch, isPinch);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(sex), BusConstructionUser::getSex, sex);
|
||||
lqw.eq(StringUtils.isNotBlank(isPinch), BusConstructionUser::getIsPinch, isPinch);
|
||||
lqw.eq(StringUtils.isNotBlank(sex), BusConstructionUser::getSex, sex);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(typeOfWork), BusConstructionUser::getTypeOfWork, typeOfWork);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(clock), BusConstructionUser::getClock, clock);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(salary), BusConstructionUser::getSalary, salary);
|
||||
@ -305,6 +300,17 @@ public class BusConstructionUserServiceImpl extends ServiceImpl<BusConstructionU
|
||||
.ne(BusConstructionUser::getTeamId, notTeamId)
|
||||
.or().isNull(BusConstructionUser::getTeamId));
|
||||
}
|
||||
// 查询当前项目下的黑名单人员
|
||||
LambdaQueryWrapper<BusConstructionBlacklist> blacklistLqw = Wrappers.lambdaQuery(BusConstructionBlacklist.class)
|
||||
.select(BusConstructionBlacklist::getUserId);
|
||||
if (projectId != null) {
|
||||
blacklistLqw.eq(BusConstructionBlacklist::getProjectId, projectId);
|
||||
}
|
||||
List<Long> blackUserIdList = constructionBlacklistService.listObjs(blacklistLqw, obj -> (Long) obj);
|
||||
// 查询结果移除黑名单人员
|
||||
if (CollUtil.isNotEmpty(blackUserIdList)) {
|
||||
lqw.notIn(BusConstructionUser::getId, blackUserIdList);
|
||||
}
|
||||
return lqw;
|
||||
}
|
||||
|
||||
@ -327,18 +333,31 @@ public class BusConstructionUserServiceImpl extends ServiceImpl<BusConstructionU
|
||||
// 关联查询分包公司信息
|
||||
Set<Long> contractorIdSet = constructionUserList.stream().map(BusConstructionUser::getContractorId)
|
||||
.collect(Collectors.toSet());
|
||||
Map<Long, List<BusContractor>> contractorIdContractorList = contractorService.listByIds(contractorIdSet).stream()
|
||||
Map<Long, List<BusContractor>> contractorIdContractorMap = contractorService.listByIds(contractorIdSet).stream()
|
||||
.collect(Collectors.groupingBy(BusContractor::getId));
|
||||
// 关联查询班组信息
|
||||
Set<Long> teamIdSet = constructionUserList.stream().map(BusConstructionUser::getTeamId)
|
||||
.collect(Collectors.toSet());
|
||||
Map<Long, List<BusProjectTeam>> teamIdTeamMap = projectTeamService.listByIds(teamIdSet).stream()
|
||||
.collect(Collectors.groupingBy(BusProjectTeam::getId));
|
||||
// 填充信息
|
||||
List<BusConstructionUserVo> constructionUserVoList = constructionUserList.stream().map(constructionUser -> {
|
||||
BusConstructionUserVo constructionUserVo = new BusConstructionUserVo();
|
||||
BeanUtils.copyProperties(constructionUser, constructionUserVo);
|
||||
// 关联分包公司信息
|
||||
Long contractorId = constructionUser.getContractorId();
|
||||
BusContractorVo contractor = null;
|
||||
if (contractorIdContractorList.containsKey(contractorId)) {
|
||||
contractor = contractorService.getVo(contractorIdContractorList.get(contractorId).get(0));
|
||||
if (contractorIdContractorMap.containsKey(contractorId)) {
|
||||
contractor = contractorService.getVo(contractorIdContractorMap.get(contractorId).get(0));
|
||||
}
|
||||
constructionUserVo.setContractorVo(contractor);
|
||||
// 关联班组信息
|
||||
Long teamId = constructionUser.getTeamId();
|
||||
BusProjectTeamVo team = null;
|
||||
if (teamIdTeamMap.containsKey(teamId)) {
|
||||
team = projectTeamService.getVo(teamIdTeamMap.get(teamId).get(0));
|
||||
}
|
||||
constructionUserVo.setTeamVo(team);
|
||||
return constructionUserVo;
|
||||
}).toList();
|
||||
constructionUserVoPage.setRecords(constructionUserVoList);
|
||||
|
||||
@ -22,18 +22,12 @@ import org.dromara.project.domain.req.projectteammember.ProjectTeamMemberQueryRe
|
||||
import org.dromara.project.domain.req.projectteammember.ProjectTeamMemberUpdateReq;
|
||||
import org.dromara.project.domain.vo.BusProjectTeamMemberVo;
|
||||
import org.dromara.project.mapper.BusProjectTeamMemberMapper;
|
||||
import org.dromara.project.service.IBusConstructionUserService;
|
||||
import org.dromara.project.service.IBusProjectService;
|
||||
import org.dromara.project.service.IBusProjectTeamMemberService;
|
||||
import org.dromara.project.service.IBusProjectTeamService;
|
||||
import org.dromara.project.service.*;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -55,6 +49,9 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
|
||||
@Resource
|
||||
private IBusProjectService projectService;
|
||||
|
||||
@Resource
|
||||
private IBusConstructionBlacklistService constructionBlacklistService;
|
||||
|
||||
/**
|
||||
* 查询项目班组下的成员
|
||||
*
|
||||
@ -111,21 +108,25 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
|
||||
BeanUtils.copyProperties(req, projectTeamMember);
|
||||
// 数据校验
|
||||
validEntityBeforeSave(projectTeamMember, true);
|
||||
// 判断用户是否已经被拉黑
|
||||
constructionBlacklistService.validUserInBlacklist(projectTeamMember.getMemberId(), projectTeamMember.getProjectId());
|
||||
// 判断对应的用户与项目关联是否存在
|
||||
BusProjectTeamMember teamMember = this.getOne(new LambdaQueryWrapper<BusProjectTeamMember>()
|
||||
.eq(BusProjectTeamMember::getMemberId, projectTeamMember.getMemberId()));
|
||||
.eq(BusProjectTeamMember::getMemberId, projectTeamMember.getMemberId())
|
||||
.eq(BusProjectTeamMember::getProjectId, projectTeamMember.getProjectId()));
|
||||
if (teamMember != null) {
|
||||
throw new ServiceException("当前用户已关联编号为:" + teamMember.getTeamId() + "的班组", HttpStatus.CONFLICT);
|
||||
throw new ServiceException("当前用户已入场", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
// 操作数据库
|
||||
boolean save = this.save(projectTeamMember);
|
||||
if (!save) {
|
||||
throw new ServiceException("新增项目班组下的成员失败,数据库异常", HttpStatus.ERROR);
|
||||
}
|
||||
// 同步修改用户表的team_id字段
|
||||
// 同步修改用户表的team_id字段并添加入场时间
|
||||
BusConstructionUser constructionUser = new BusConstructionUser();
|
||||
constructionUser.setId(projectTeamMember.getMemberId());
|
||||
constructionUser.setTeamId(projectTeamMember.getTeamId());
|
||||
constructionUser.setEntryDate(new Date());
|
||||
constructionUserService.updateById(constructionUser);
|
||||
return projectTeamMember.getId();
|
||||
}
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
package org.dromara.safety.domain;
|
||||
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 题库对象 bus_question_bank
|
||||
@ -29,6 +29,11 @@ public class BusQuestionBank extends BaseEntity {
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 题目类别
|
||||
*/
|
||||
|
||||
@ -26,6 +26,11 @@ public class BusQuestionsConfig implements Serializable {
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 单选题(单位/道)
|
||||
*/
|
||||
|
||||
@ -16,6 +16,11 @@ public class QuestionBankCreateReq implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 9014952417764490638L;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 题目类别
|
||||
*/
|
||||
|
||||
@ -21,6 +21,11 @@ public class QuestionBankQueryReq implements Serializable {
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 题目类别
|
||||
*/
|
||||
|
||||
@ -15,6 +15,11 @@ public class QuestionsConfigCreateReq implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = -6430325731025840429L;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 单选题(单位/道)
|
||||
*/
|
||||
|
||||
@ -20,6 +20,11 @@ public class QuestionsConfigQueryReq implements Serializable {
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 单选题(单位/道)
|
||||
*/
|
||||
|
||||
@ -33,6 +33,12 @@ public class BusQuestionBankVo implements Serializable {
|
||||
@ExcelProperty(value = "主键id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
@ExcelProperty(value = "项目id")
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 题目类别
|
||||
*/
|
||||
@ -56,8 +62,7 @@ public class BusQuestionBankVo implements Serializable {
|
||||
/**
|
||||
* 选项(以JSON数组形式存储)
|
||||
*/
|
||||
@ExcelProperty(value = "选项", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "以=JSON数组形式存储")
|
||||
@ExcelProperty(value = "选项")
|
||||
private List<String> optionList;
|
||||
|
||||
/**
|
||||
|
||||
@ -4,8 +4,6 @@ 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.safety.domain.BusQuestionsConfig;
|
||||
|
||||
import java.io.Serial;
|
||||
@ -32,11 +30,16 @@ public class BusQuestionsConfigVo implements Serializable {
|
||||
@ExcelProperty(value = "主键id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
@ExcelProperty(value = "项目id")
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 单选题(单位/道)
|
||||
*/
|
||||
@ExcelProperty(value = "单选题", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "单=位/道")
|
||||
@ExcelProperty(value = "单选题")
|
||||
private Long singleChoice;
|
||||
|
||||
/**
|
||||
@ -48,8 +51,7 @@ public class BusQuestionsConfigVo implements Serializable {
|
||||
/**
|
||||
* 多选题(单位/道)
|
||||
*/
|
||||
@ExcelProperty(value = "多选题", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "单=位/道")
|
||||
@ExcelProperty(value = "多选题")
|
||||
private Long multipleChoice;
|
||||
|
||||
/**
|
||||
@ -61,8 +63,7 @@ public class BusQuestionsConfigVo implements Serializable {
|
||||
/**
|
||||
* 判断题(单位/道)
|
||||
*/
|
||||
@ExcelProperty(value = "判断题", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "单=位/道")
|
||||
@ExcelProperty(value = "判断题")
|
||||
private Long estimate;
|
||||
|
||||
/**
|
||||
@ -86,8 +87,7 @@ public class BusQuestionsConfigVo implements Serializable {
|
||||
/**
|
||||
* 答题最大时间(单位/分钟)
|
||||
*/
|
||||
@ExcelProperty(value = "答题最大时间", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "单=位/分钟")
|
||||
@ExcelProperty(value = "答题最大时间")
|
||||
private Long answerTime;
|
||||
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.dromara.common.core.constant.CacheConstants;
|
||||
import org.dromara.common.core.constant.HttpStatus;
|
||||
@ -14,6 +15,8 @@ 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.redis.utils.RedisUtils;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.project.service.IBusProjectService;
|
||||
import org.dromara.safety.domain.BusQuestionBank;
|
||||
import org.dromara.safety.domain.req.questionbank.QuestionBankCreateReq;
|
||||
import org.dromara.safety.domain.req.questionbank.QuestionBankQueryReq;
|
||||
@ -38,6 +41,9 @@ import java.util.List;
|
||||
public class BusQuestionBankServiceImpl extends ServiceImpl<BusQuestionBankMapper, BusQuestionBank>
|
||||
implements IBusQuestionBankService {
|
||||
|
||||
@Resource
|
||||
private IBusProjectService projectService;
|
||||
|
||||
/**
|
||||
* 查询题库
|
||||
*
|
||||
@ -134,6 +140,7 @@ public class BusQuestionBankServiceImpl extends ServiceImpl<BusQuestionBankMappe
|
||||
String categoryType = entity.getCategoryType();
|
||||
String questionType = entity.getQuestionType();
|
||||
String questionContent = entity.getQuestionContent();
|
||||
Long projectId = entity.getProjectId();
|
||||
if (create) {
|
||||
if (StringUtils.isEmpty(categoryType)) {
|
||||
throw new ServiceException("分类类型不能为空", HttpStatus.BAD_REQUEST);
|
||||
@ -144,6 +151,12 @@ public class BusQuestionBankServiceImpl extends ServiceImpl<BusQuestionBankMappe
|
||||
if (StringUtils.isEmpty(questionContent)) {
|
||||
throw new ServiceException("题目内容不能为空", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
if (projectId == null) {
|
||||
throw new ServiceException("项目id不能为空", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
if (projectId != null && projectService.getById(projectId) == null) {
|
||||
throw new ServiceException("对应项目不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,8 +170,12 @@ public class BusQuestionBankServiceImpl extends ServiceImpl<BusQuestionBankMappe
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
List<BusQuestionBank> questionBankList = this.listByIds(ids);
|
||||
if (isValid) {
|
||||
// TODO 做一些业务上的校验,判断是否需要校验
|
||||
List<Long> projectId = questionBankList.stream().map(BusQuestionBank::getProjectId).toList();
|
||||
projectService.validAuth(projectId, userId);
|
||||
}
|
||||
return this.removeBatchByIds(ids);
|
||||
}
|
||||
@ -193,6 +210,7 @@ public class BusQuestionBankServiceImpl extends ServiceImpl<BusQuestionBankMappe
|
||||
return lqw;
|
||||
}
|
||||
Long id = req.getId();
|
||||
Long projectId = req.getProjectId();
|
||||
String categoryType = req.getCategoryType();
|
||||
String questionType = req.getQuestionType();
|
||||
String questionContent = req.getQuestionContent();
|
||||
@ -209,6 +227,7 @@ public class BusQuestionBankServiceImpl extends ServiceImpl<BusQuestionBankMappe
|
||||
lqw.like(StringUtils.isNotBlank(correctAnswer), BusQuestionBank::getCorrectAnswer, correctAnswer);
|
||||
// 精准查询
|
||||
lqw.eq(ObjectUtils.isNotEmpty(id), BusQuestionBank::getId, id);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(projectId), BusQuestionBank::getProjectId, projectId);
|
||||
lqw.eq(StringUtils.isNotBlank(categoryType), BusQuestionBank::getCategoryType, categoryType);
|
||||
lqw.eq(StringUtils.isNotBlank(questionType), BusQuestionBank::getQuestionType, questionType);
|
||||
return lqw;
|
||||
|
||||
@ -4,11 +4,14 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
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.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.project.service.IBusProjectService;
|
||||
import org.dromara.safety.domain.BusQuestionsConfig;
|
||||
import org.dromara.safety.domain.req.questionsconfig.QuestionsConfigCreateReq;
|
||||
import org.dromara.safety.domain.req.questionsconfig.QuestionsConfigQueryReq;
|
||||
@ -33,6 +36,9 @@ import java.util.List;
|
||||
public class BusQuestionsConfigServiceImpl extends ServiceImpl<BusQuestionsConfigMapper, BusQuestionsConfig>
|
||||
implements IBusQuestionsConfigService {
|
||||
|
||||
@Resource
|
||||
private IBusProjectService projectService;
|
||||
|
||||
/**
|
||||
* 查询题库配置
|
||||
*
|
||||
@ -122,8 +128,14 @@ public class BusQuestionsConfigServiceImpl extends ServiceImpl<BusQuestionsConfi
|
||||
*/
|
||||
private void validEntityBeforeSave(BusQuestionsConfig entity, Boolean create) {
|
||||
// TODO 做一些数据校验,如唯一约束
|
||||
Long projectId = entity.getProjectId();
|
||||
if (create) {
|
||||
|
||||
if (projectId == null) {
|
||||
throw new ServiceException("项目id不能为空", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
if (projectId != null && projectService.getById(projectId) == null) {
|
||||
throw new ServiceException("对应项目不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,8 +149,12 @@ public class BusQuestionsConfigServiceImpl extends ServiceImpl<BusQuestionsConfi
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
List<BusQuestionsConfig> questionsConfigList = this.listByIds(ids);
|
||||
if (isValid) {
|
||||
// TODO 做一些业务上的校验,判断是否需要校验
|
||||
List<Long> projectId = questionsConfigList.stream().map(BusQuestionsConfig::getProjectId).toList();
|
||||
projectService.validAuth(projectId, userId);
|
||||
}
|
||||
return this.removeBatchByIds(ids);
|
||||
}
|
||||
@ -173,6 +189,7 @@ public class BusQuestionsConfigServiceImpl extends ServiceImpl<BusQuestionsConfi
|
||||
return lqw;
|
||||
}
|
||||
Long id = req.getId();
|
||||
Long projectId = req.getProjectId();
|
||||
Long singleChoice = req.getSingleChoice();
|
||||
Long singleScore = req.getSingleScore();
|
||||
Long multipleChoice = req.getMultipleChoice();
|
||||
@ -184,6 +201,7 @@ public class BusQuestionsConfigServiceImpl extends ServiceImpl<BusQuestionsConfi
|
||||
Long answerTime = req.getAnswerTime();
|
||||
// 精准查询
|
||||
lqw.eq(ObjectUtils.isNotEmpty(id), BusQuestionsConfig::getId, id);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(projectId), BusQuestionsConfig::getProjectId, projectId);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(singleChoice), BusQuestionsConfig::getSingleChoice, singleChoice);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(singleScore), BusQuestionsConfig::getSingleScore, singleScore);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(multipleChoice), BusQuestionsConfig::getMultipleChoice, multipleChoice);
|
||||
|
||||
Reference in New Issue
Block a user