优化项目逻辑
This commit is contained in:
@ -73,12 +73,12 @@ public class BusProject extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 项目类型
|
* 项目类型
|
||||||
*/
|
*/
|
||||||
private String type;
|
private String projectType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 项目类型(1光伏 2风电)
|
* 项目类别
|
||||||
*/
|
*/
|
||||||
private String isType;
|
private String projectCategory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除时间
|
* 删除时间
|
||||||
|
@ -53,12 +53,12 @@ public class ProjectCreateReq implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 项目类型
|
* 项目类型
|
||||||
*/
|
*/
|
||||||
private String type;
|
private String projectType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 项目类型(1光伏 2风电)
|
* 项目类别
|
||||||
*/
|
*/
|
||||||
private String isType;
|
private String projectCategory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 项目地址
|
* 项目地址
|
||||||
@ -91,9 +91,14 @@ public class ProjectCreateReq implements Serializable {
|
|||||||
private String onStreamTime;
|
private String onStreamTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打卡范围(09:00,18:00)
|
* 打卡时间开始
|
||||||
*/
|
*/
|
||||||
private String punchRange;
|
private String playCardStart;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打卡时间结束
|
||||||
|
*/
|
||||||
|
private String playCardEnd;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设计总量
|
* 设计总量
|
||||||
|
@ -58,12 +58,12 @@ public class ProjectQueryReq implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 项目类型
|
* 项目类型
|
||||||
*/
|
*/
|
||||||
private String type;
|
private String projectType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 项目类型(1光伏 2风电)
|
* 项目类别
|
||||||
*/
|
*/
|
||||||
private String isType;
|
private String projectCategory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 项目地址
|
* 项目地址
|
||||||
|
@ -63,12 +63,12 @@ public class ProjectUpdateReq implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 项目类型
|
* 项目类型
|
||||||
*/
|
*/
|
||||||
private String type;
|
private String projectType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 项目类型(1光伏 2风电)
|
* 项目类别
|
||||||
*/
|
*/
|
||||||
private String isType;
|
private String projectCategory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 项目地址
|
* 项目地址
|
||||||
@ -101,9 +101,14 @@ public class ProjectUpdateReq implements Serializable {
|
|||||||
private String onStreamTime;
|
private String onStreamTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打卡范围(09:00,18:00)
|
* 打卡时间开始
|
||||||
*/
|
*/
|
||||||
private String punchRange;
|
private String playCardStart;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打卡时间结束
|
||||||
|
*/
|
||||||
|
private String playCardEnd;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设计总量
|
* 设计总量
|
||||||
@ -119,4 +124,9 @@ public class ProjectUpdateReq implements Serializable {
|
|||||||
* 显示隐藏(0显示 1隐藏)
|
* 显示隐藏(0显示 1隐藏)
|
||||||
*/
|
*/
|
||||||
private String showHidden;
|
private String showHidden;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序字段
|
||||||
|
*/
|
||||||
|
private Long sort;
|
||||||
}
|
}
|
||||||
|
@ -85,15 +85,16 @@ public class BusProjectVo implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 项目类型
|
* 项目类型
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "项目类型")
|
@ExcelProperty(value = "项目类型", converter = ExcelDictConvert.class)
|
||||||
private String type;
|
@ExcelDictFormat(dictType = "project_type")
|
||||||
|
private String projectType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 项目类型(1光伏 2风电)
|
* 项目类别
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "项目类型", converter = ExcelDictConvert.class)
|
@ExcelProperty(value = "项目类型", converter = ExcelDictConvert.class)
|
||||||
@ExcelDictFormat(readConverterExp = "1=光伏,2=风电")
|
@ExcelDictFormat(dictType = "project_category_type")
|
||||||
private String isType;
|
private String projectCategory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 项目地址
|
* 项目地址
|
||||||
@ -156,6 +157,11 @@ public class BusProjectVo implements Serializable {
|
|||||||
@ExcelDictFormat(readConverterExp = "1=显示,2=隐藏")
|
@ExcelDictFormat(readConverterExp = "1=显示,2=隐藏")
|
||||||
private String showHidden;
|
private String showHidden;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序字段
|
||||||
|
*/
|
||||||
|
private Long sort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
*/
|
*/
|
||||||
|
@ -91,15 +91,19 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj
|
|||||||
/**
|
/**
|
||||||
* 新增项目
|
* 新增项目
|
||||||
*
|
*
|
||||||
* @param dto 项目
|
* @param req 项目
|
||||||
* @return 新项目 id
|
* @return 新项目 id
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long insertByBo(ProjectCreateReq dto) {
|
public Long insertByBo(ProjectCreateReq req) {
|
||||||
// 将实体类和 DTO 进行转换
|
// 将实体类和 DTO 进行转换
|
||||||
BusProject project = new BusProject();
|
BusProject project = new BusProject();
|
||||||
BeanUtils.copyProperties(dto, project);
|
BeanUtils.copyProperties(req, project);
|
||||||
|
String playCardStart = req.getPlayCardStart();
|
||||||
|
String playCardEnd = req.getPlayCardEnd();
|
||||||
|
String punchRange = playCardStart + "," + playCardEnd;
|
||||||
|
project.setPunchRange(punchRange);
|
||||||
// 数据校验
|
// 数据校验
|
||||||
validEntityBeforeSave(project, true);
|
validEntityBeforeSave(project, true);
|
||||||
// 写入数据库
|
// 写入数据库
|
||||||
@ -136,10 +140,17 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj
|
|||||||
// 将实体类和 DTO 进行转换
|
// 将实体类和 DTO 进行转换
|
||||||
BusProject project = new BusProject();
|
BusProject project = new BusProject();
|
||||||
BeanUtils.copyProperties(req, project);
|
BeanUtils.copyProperties(req, project);
|
||||||
|
String playCardStart = req.getPlayCardStart();
|
||||||
|
String playCardEnd = req.getPlayCardEnd();
|
||||||
|
if (StringUtils.isNotBlank(playCardStart) && StringUtils.isNotBlank(playCardEnd)){
|
||||||
|
String punchRange = playCardStart + "," + playCardEnd;
|
||||||
|
project.setPunchRange(punchRange);
|
||||||
|
}
|
||||||
// 数据校验
|
// 数据校验
|
||||||
validEntityBeforeSave(project, false);
|
validEntityBeforeSave(project, false);
|
||||||
// 权限校验
|
// 权限校验
|
||||||
validPermission(project);
|
Long userId = LoginHelper.getUserId();
|
||||||
|
validAuth(project.getId(), userId);
|
||||||
// 判断是否存在
|
// 判断是否存在
|
||||||
BusProject oldProject = this.getById(project.getId());
|
BusProject oldProject = this.getById(project.getId());
|
||||||
if (oldProject == null) {
|
if (oldProject == null) {
|
||||||
@ -163,22 +174,6 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限判断
|
|
||||||
*/
|
|
||||||
private void validPermission(BusProject entity) {
|
|
||||||
Long entityId = entity.getId();
|
|
||||||
// 获取当前登录用户
|
|
||||||
Long userId = LoginHelper.getUserId();
|
|
||||||
// 判断是否存在项目与登录用户关联
|
|
||||||
QueryWrapper<BusUserProjectRelevancy> queryWrapper = new QueryWrapper<>();
|
|
||||||
queryWrapper.eq("project_id", entityId);
|
|
||||||
queryWrapper.eq("user_id", userId);
|
|
||||||
if (userProjectRelevancyService.count(queryWrapper) <= 0) {
|
|
||||||
throw new ServiceException("当前用户无权限操作", HttpStatus.FORBIDDEN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验并批量删除项目信息
|
* 校验并批量删除项目信息
|
||||||
*
|
*
|
||||||
@ -245,8 +240,8 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj
|
|||||||
Long pId = req.getPId();
|
Long pId = req.getPId();
|
||||||
String status = req.getStatus();
|
String status = req.getStatus();
|
||||||
String remark = req.getRemark();
|
String remark = req.getRemark();
|
||||||
String type = req.getType();
|
String projectType = req.getProjectType();
|
||||||
String isType = req.getIsType();
|
String projectCategory = req.getProjectCategory();
|
||||||
String projectSite = req.getProjectSite();
|
String projectSite = req.getProjectSite();
|
||||||
String principal = req.getPrincipal();
|
String principal = req.getPrincipal();
|
||||||
String principalPhone = req.getPrincipalPhone();
|
String principalPhone = req.getPrincipalPhone();
|
||||||
@ -260,7 +255,6 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj
|
|||||||
lqw.like(StringUtils.isNotBlank(projectName), BusProject::getProjectName, projectName);
|
lqw.like(StringUtils.isNotBlank(projectName), BusProject::getProjectName, projectName);
|
||||||
lqw.like(StringUtils.isNotBlank(shortName), BusProject::getShortName, shortName);
|
lqw.like(StringUtils.isNotBlank(shortName), BusProject::getShortName, shortName);
|
||||||
lqw.like(StringUtils.isNotBlank(remark), BusProject::getRemark, remark);
|
lqw.like(StringUtils.isNotBlank(remark), BusProject::getRemark, remark);
|
||||||
lqw.like(StringUtils.isNotBlank(type), BusProject::getType, type);
|
|
||||||
lqw.like(StringUtils.isNotBlank(projectSite), BusProject::getProjectSite, projectSite);
|
lqw.like(StringUtils.isNotBlank(projectSite), BusProject::getProjectSite, projectSite);
|
||||||
lqw.like(StringUtils.isNotBlank(principal), BusProject::getPrincipal, principal);
|
lqw.like(StringUtils.isNotBlank(principal), BusProject::getPrincipal, principal);
|
||||||
lqw.like(StringUtils.isNotBlank(principalPhone), BusProject::getPrincipalPhone, principalPhone);
|
lqw.like(StringUtils.isNotBlank(principalPhone), BusProject::getPrincipalPhone, principalPhone);
|
||||||
@ -272,9 +266,11 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj
|
|||||||
lqw.eq(ObjectUtils.isNotEmpty(pId), BusProject::getPId, pId);
|
lqw.eq(ObjectUtils.isNotEmpty(pId), BusProject::getPId, pId);
|
||||||
lqw.eq(ObjectUtils.isNotEmpty(status), BusProject::getStatus, status);
|
lqw.eq(ObjectUtils.isNotEmpty(status), BusProject::getStatus, status);
|
||||||
lqw.eq(ObjectUtils.isNotEmpty(id), BusProject::getId, id);
|
lqw.eq(ObjectUtils.isNotEmpty(id), BusProject::getId, id);
|
||||||
lqw.eq(ObjectUtils.isNotEmpty(isType), BusProject::getIsType, isType);
|
lqw.eq(ObjectUtils.isNotEmpty(projectType), BusProject::getProjectType, projectType);
|
||||||
|
lqw.eq(ObjectUtils.isNotEmpty(projectCategory), BusProject::getProjectCategory, projectCategory);
|
||||||
lqw.eq(ObjectUtils.isNotEmpty(designTotal), BusProject::getDesignTotal, designTotal);
|
lqw.eq(ObjectUtils.isNotEmpty(designTotal), BusProject::getDesignTotal, designTotal);
|
||||||
lqw.eq(ObjectUtils.isNotEmpty(showHidden), BusProject::getShowHidden, showHidden);
|
lqw.eq(ObjectUtils.isNotEmpty(showHidden), BusProject::getShowHidden, showHidden);
|
||||||
|
lqw.orderByAsc(BusProject::getSort);
|
||||||
return lqw;
|
return lqw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +300,7 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj
|
|||||||
queryWrapper.eq("project_id", projectId);
|
queryWrapper.eq("project_id", projectId);
|
||||||
queryWrapper.eq("user_id", userId);
|
queryWrapper.eq("user_id", userId);
|
||||||
if (userProjectRelevancyService.count(queryWrapper) <= 0) {
|
if (userProjectRelevancyService.count(queryWrapper) <= 0) {
|
||||||
throw new ServiceException("无该项目的权限操作", HttpStatus.FORBIDDEN);
|
throw new ServiceException("当前用户无该项目权限操作", HttpStatus.FORBIDDEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
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.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
@ -123,11 +124,12 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
|
|||||||
throw new ServiceException("新增项目班组下的成员失败,数据库异常", HttpStatus.ERROR);
|
throw new ServiceException("新增项目班组下的成员失败,数据库异常", HttpStatus.ERROR);
|
||||||
}
|
}
|
||||||
// 同步修改用户表的team_id字段并添加入场时间
|
// 同步修改用户表的team_id字段并添加入场时间
|
||||||
BusConstructionUser constructionUser = new BusConstructionUser();
|
LambdaUpdateWrapper<BusConstructionUser> constructionUserLuw = Wrappers.lambdaUpdate(BusConstructionUser.class)
|
||||||
constructionUser.setId(projectTeamMember.getMemberId());
|
.eq(BusConstructionUser::getId, projectTeamMember.getMemberId())
|
||||||
constructionUser.setTeamId(projectTeamMember.getTeamId());
|
.set(BusConstructionUser::getTeamId, projectTeamMember.getTeamId())
|
||||||
constructionUser.setEntryDate(new Date());
|
.set(BusConstructionUser::getEntryDate, new Date())
|
||||||
constructionUserService.updateById(constructionUser);
|
.set(BusConstructionUser::getLeaveDate, null);
|
||||||
|
constructionUserService.update(constructionUserLuw);
|
||||||
return projectTeamMember.getId();
|
return projectTeamMember.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,10 +153,10 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
|
|||||||
throw new ServiceException("修改项目班组下的成员,数据不存在", HttpStatus.NOT_FOUND);
|
throw new ServiceException("修改项目班组下的成员,数据不存在", HttpStatus.NOT_FOUND);
|
||||||
}
|
}
|
||||||
// 同步修改用户表的team_id字段
|
// 同步修改用户表的team_id字段
|
||||||
BusConstructionUser constructionUser = new BusConstructionUser();
|
LambdaUpdateWrapper<BusConstructionUser> constructionUserLuw = Wrappers.lambdaUpdate(BusConstructionUser.class)
|
||||||
constructionUser.setId(projectTeamMember.getMemberId());
|
.eq(BusConstructionUser::getId, projectTeamMember.getMemberId())
|
||||||
constructionUser.setTeamId(projectTeamMember.getTeamId());
|
.set(BusConstructionUser::getTeamId, projectTeamMember.getTeamId());
|
||||||
constructionUserService.updateById(constructionUser);
|
constructionUserService.update(constructionUserLuw);
|
||||||
// 操作数据库
|
// 操作数据库
|
||||||
return this.updateById(projectTeamMember);
|
return this.updateById(projectTeamMember);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user