完善项目模块页面和对应接口

This commit is contained in:
lcj
2025-03-12 15:55:32 +08:00
parent b8426798e7
commit dfc66e85c9
17 changed files with 502 additions and 463 deletions

View File

@ -3,10 +3,9 @@ package org.dromara.project.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
/**
@ -16,9 +15,8 @@ import java.util.Date;
* @date 2025-03-07
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("bus_project_team_member")
public class BusProjectTeamMember extends BaseEntity {
public class BusProjectTeamMember implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@ -59,5 +57,14 @@ public class BusProjectTeamMember extends BaseEntity {
*/
private Date deletedAt;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
}

View File

@ -53,6 +53,11 @@ public class ConstructionUserQueryReq extends PageRequest implements Serializabl
*/
private Long teamId;
/**
* 不在班组id
*/
private Long notTeamId;
/**
* 状态0在职 1离职
*/

View File

@ -51,10 +51,10 @@ public class BusProjectTeamMemberVo implements Serializable {
private Long memberId;
/**
* 施工人员信息
* 施工人员名称
*/
@ExcelProperty(value = "施工人员信息")
private BusConstructionUserVo constructionUserVo;
@ExcelProperty(value = "施工人员名称")
private String memberName;
/**
* 岗位默认为0普通员工1组长

View File

@ -216,6 +216,7 @@ public class BusConstructionUserServiceImpl extends ServiceImpl<BusConstructionU
Long projectId = req.getProjectId();
Long contractorId = req.getContractorId();
Long teamId = req.getTeamId();
Long notTeamId = req.getNotTeamId();
Long status = req.getStatus();
Long isPinch = req.getIsPinch();
String phone = req.getPhone();
@ -264,6 +265,12 @@ public class BusConstructionUserServiceImpl extends ServiceImpl<BusConstructionU
queryWrapper.eq(ObjectUtils.isNotEmpty(typeOfWork), "type_of_work", typeOfWork);
queryWrapper.eq(ObjectUtils.isNotEmpty(clock), "clock", clock);
queryWrapper.eq(ObjectUtils.isNotEmpty(salary), "salary", salary);
// 精准查询,不等于
if (ObjectUtils.isNotEmpty(notTeamId)) {
queryWrapper.and(wrapper -> wrapper
.ne("team_id", notTeamId)
.or().isNull("team_id"));
}
// 排序规则
queryWrapper.orderBy(SqlUtil.validSortField(sortField),
sortOrder.equals(CommonConstant.SORT_ORDER_ASC),

View File

@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
@ -18,13 +19,12 @@ import org.dromara.project.domain.BusProjectTeamMember;
import org.dromara.project.domain.req.projectteammember.ProjectTeamMemberCreateReq;
import org.dromara.project.domain.req.projectteammember.ProjectTeamMemberQueryReq;
import org.dromara.project.domain.req.projectteammember.ProjectTeamMemberUpdateReq;
import org.dromara.project.domain.vo.BusConstructionUserVo;
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.IBusProjectService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -104,6 +104,7 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
* @return 是否新增成功
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Long insertByBo(ProjectTeamMemberCreateReq req) {
// 将实体类和 DTO 进行转换
BusProjectTeamMember projectTeamMember = new BusProjectTeamMember();
@ -111,16 +112,21 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
// 数据校验
validEntityBeforeSave(projectTeamMember);
// 判断对应的用户与项目关联是否存在
if (this.getOne(new LambdaQueryWrapper<BusProjectTeamMember>()
.eq(BusProjectTeamMember::getMemberId, projectTeamMember.getMemberId())
.eq(BusProjectTeamMember::getTeamId, projectTeamMember.getTeamId())) != null) {
throw new ServiceException("用户和项目班组关联已存在", HttpStatus.CONFLICT);
BusProjectTeamMember teamMember = this.getOne(new LambdaQueryWrapper<BusProjectTeamMember>()
.eq(BusProjectTeamMember::getMemberId, projectTeamMember.getMemberId()));
if (teamMember != null) {
throw new ServiceException("当前用户以关联编号为:" + teamMember.getTeamId() + "的班组", HttpStatus.CONFLICT);
}
// 操作数据库
boolean save = this.save(projectTeamMember);
if (!save) {
throw new ServiceException("新增项目班组下的成员失败,数据库异常", HttpStatus.ERROR);
}
// 同步修改用户表的team_id字段
BusConstructionUser constructionUser = new BusConstructionUser();
constructionUser.setId(projectTeamMember.getMemberId());
constructionUser.setTeamId(projectTeamMember.getTeamId());
constructionUserService.updateById(constructionUser);
return projectTeamMember.getId();
}
@ -131,6 +137,7 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
* @return 是否修改成功
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean updateByBo(ProjectTeamMemberUpdateReq req) {
// 将实体类和 DTO 进行转换
BusProjectTeamMember projectTeamMember = new BusProjectTeamMember();
@ -142,6 +149,11 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
if (oldProjectTeamMember == null) {
throw new ServiceException("修改项目班组下的成员,数据不存在", HttpStatus.NOT_FOUND);
}
// 同步修改用户表的team_id字段
BusConstructionUser constructionUser = new BusConstructionUser();
constructionUser.setId(projectTeamMember.getMemberId());
constructionUser.setTeamId(projectTeamMember.getTeamId());
constructionUserService.updateById(constructionUser);
// 操作数据库
return this.updateById(projectTeamMember);
}
@ -190,6 +202,15 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
if (isValid) {
//TODO 做一些业务上的校验,判断是否需要校验
}
List<BusProjectTeamMember> projectTeamMemberList = this.listByIds(ids);
if (projectTeamMemberList.size() != ids.size()) {
throw new ServiceException("删除项目班组下的成员失败,数据缺失", HttpStatus.NOT_FOUND);
}
List<Long> memberIds = projectTeamMemberList.stream().map(BusProjectTeamMember::getMemberId).toList();
LambdaUpdateWrapper<BusConstructionUser> queryWrapper = new LambdaUpdateWrapper<>();
queryWrapper.in(BusConstructionUser::getId, memberIds);
queryWrapper.set(BusConstructionUser::getTeamId, null);
constructionUserService.update(null, queryWrapper);
return this.removeBatchByIds(ids);
}
@ -209,7 +230,8 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
BeanUtils.copyProperties(projectTeamMember, projectTeamMemberVo);
// 关联获取施工人员信息
Long memberId = projectTeamMember.getMemberId();
projectTeamMemberVo.setConstructionUserVo(constructionUserService.queryById(memberId));
BusConstructionUser constructionUser = constructionUserService.getById(memberId);
projectTeamMemberVo.setMemberName(constructionUser.getUserName());
return projectTeamMemberVo;
}
@ -276,11 +298,11 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
BusProjectTeamMemberVo projectTeamMemberVo = new BusProjectTeamMemberVo();
BeanUtils.copyProperties(projectTeamMember, projectTeamMemberVo);
Long memberId = projectTeamMember.getMemberId();
BusConstructionUserVo constructionUserVo = null;
String memberName = null;
if (contractorIdContractorList.containsKey(memberId)) {
constructionUserVo = constructionUserService.getVo(contractorIdContractorList.get(memberId).get(0));
memberName = contractorIdContractorList.get(memberId).get(0).getUserName();
}
projectTeamMemberVo.setConstructionUserVo(constructionUserVo);
projectTeamMemberVo.setMemberName(memberName);
return projectTeamMemberVo;
}).toList();
projectTeamMemberVoPage.setRecords(projectTeamMemberVoList);

View File

@ -177,7 +177,7 @@ CREATE TABLE `bus_construction_user`
`status` tinyint null comment '状态0在职 1离职',
`is_pinch` tinyint null comment '是否代打',
`phone` varchar(24) null comment '联系电话',
`sex` tinyint default 0 not null comment '0:保密 1:男 2女',
`sex` tinyint default 0 not null comment '性别(0:保密 1:男 2女)',
`nation` varchar(20) null comment '民族',
`sfz_number` varchar(50) null comment '身份证号码',
`sfz_start` varchar(20) null comment '身份证有效开始期',