项目管理添加与机构关联逻辑,bug修复等
This commit is contained in:
@ -23,6 +23,10 @@
|
||||
<groupId>com.fastbee</groupId>
|
||||
<artifactId>fastbee-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fastbee</groupId>
|
||||
<artifactId>fastbee-system-service</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
@ -11,7 +11,7 @@ import com.fastbee.common.core.domain.BaseEntity;
|
||||
* 项目对象 project
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-10-17
|
||||
* @date 2024-10-18
|
||||
*/
|
||||
@ApiModel(value = "Project",description = "项目 project")
|
||||
@Data
|
||||
@ -106,4 +106,19 @@ public class Project extends BaseEntity
|
||||
@ApiModelProperty("父项目id")
|
||||
private Long parentId;
|
||||
|
||||
/** 所属机构id */
|
||||
@Excel(name = "所属机构id")
|
||||
@ApiModelProperty("所属机构id")
|
||||
private Long deptId;
|
||||
|
||||
/** 行政区域代码 */
|
||||
@Excel(name = "行政区域代码")
|
||||
@ApiModelProperty("行政区域代码")
|
||||
private String administrativeAreaCode;
|
||||
|
||||
/** 项目所属机构名称 */
|
||||
@Excel(name = "项目所属机构名称")
|
||||
@ApiModelProperty("项目所属机构名称")
|
||||
private String deptName;
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
package com.fastbee.project.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import com.fastbee.project.domain.Project;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -12,7 +13,7 @@ import java.util.List;
|
||||
* @author kerwincui
|
||||
* @date 2024-10-17
|
||||
*/
|
||||
public interface ProjectMapper extends BaseMapper<Project>
|
||||
public interface ProjectMapper extends MPJBaseMapper<Project>
|
||||
{
|
||||
/**
|
||||
* 查询项目
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.fastbee.project.service;
|
||||
|
||||
import com.fastbee.common.core.domain.entity.SysDept;
|
||||
import com.fastbee.project.domain.Project;
|
||||
|
||||
import java.util.List;
|
||||
@ -63,4 +64,10 @@ public interface IProjectService
|
||||
|
||||
Map<String,Object> selectProjectByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 获取未绑定项目的部门列表
|
||||
* @return 部门列表
|
||||
*/
|
||||
List<SysDept> getUnbindDeptList();
|
||||
|
||||
}
|
||||
|
@ -2,12 +2,14 @@ package com.fastbee.project.service.impl;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.fastbee.common.core.domain.entity.SysDept;
|
||||
import com.fastbee.common.exception.ServiceException;
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
import com.fastbee.project.domain.Project;
|
||||
import com.fastbee.project.mapper.ProjectMapper;
|
||||
import com.fastbee.project.service.IProjectService;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import com.fastbee.system.mapper.SysDeptMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -17,7 +19,7 @@ import java.util.*;
|
||||
* 项目Service业务层处理
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-09-26
|
||||
* @date 2024-09-26
|
||||
*/
|
||||
@Service
|
||||
public class ProjectServiceImpl implements IProjectService
|
||||
@ -25,6 +27,9 @@ public class ProjectServiceImpl implements IProjectService
|
||||
@Autowired
|
||||
private ProjectMapper projectMapper;
|
||||
|
||||
@Autowired
|
||||
private SysDeptMapper sysDeptMapper;
|
||||
|
||||
/**
|
||||
* 查询项目
|
||||
*
|
||||
@ -57,7 +62,12 @@ public class ProjectServiceImpl implements IProjectService
|
||||
*/
|
||||
@Override
|
||||
public int insertProject(Project project)
|
||||
{
|
||||
{ //判断选择的机构下是否已经绑定项目
|
||||
Project one = new LambdaQueryChainWrapper<>(projectMapper).select(Project::getProjectId, Project::getProjectName)
|
||||
.eq(Project::getDeptId, project.getDeptId()).one();
|
||||
if(Objects.nonNull(one)){
|
||||
throw new ServiceException("该机构下已经存在项目");
|
||||
}
|
||||
project.setCreateTime(DateUtils.getNowDate());
|
||||
return projectMapper.insertProject(project);
|
||||
}
|
||||
@ -71,6 +81,15 @@ public class ProjectServiceImpl implements IProjectService
|
||||
@Override
|
||||
public int updateProject(Project project)
|
||||
{
|
||||
//判断选择的机构下是否已经绑定项目
|
||||
Project one = new LambdaQueryChainWrapper<>(projectMapper).select(Project::getProjectId, Project::getProjectName,Project::getDeptId)
|
||||
.eq(Project::getDeptId, project.getDeptId()).one();
|
||||
if(Objects.isNull(one)){
|
||||
throw new ServiceException("项目不存在!");
|
||||
}
|
||||
if(!one.getDeptId().equals(project.getDeptId())){
|
||||
throw new ServiceException("非法修改项目机构!");
|
||||
}
|
||||
project.setUpdateTime(DateUtils.getNowDate());
|
||||
return projectMapper.updateProject(project);
|
||||
}
|
||||
@ -126,6 +145,29 @@ public class ProjectServiceImpl implements IProjectService
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询未绑定项目的部门列表
|
||||
* @return 部门列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysDept> getUnbindDeptList() {
|
||||
//查询所有机构
|
||||
List<SysDept> sysDeptList = new LambdaQueryChainWrapper<>(sysDeptMapper)
|
||||
.select(SysDept::getDeptId, SysDept::getDeptName)
|
||||
.list();
|
||||
//查询所有项目
|
||||
List<Project> projectList = new LambdaQueryChainWrapper<>(projectMapper)
|
||||
.select(Project::getProjectId, Project::getDeptId)
|
||||
.list();
|
||||
//遍历项目,把已绑定项目的机构从机构列表中移除
|
||||
for (Project project : projectList) {
|
||||
if (Objects.nonNull(project.getDeptId()))
|
||||
sysDeptList.removeIf(sysDept -> sysDept.getDeptId().equals(project.getDeptId()));
|
||||
}
|
||||
|
||||
return sysDeptList;
|
||||
}
|
||||
|
||||
public List<Long> getAllProjects(Long projectId) {
|
||||
List<Long> allProjects = new ArrayList<>();
|
||||
|
||||
|
@ -27,10 +27,13 @@
|
||||
<result property="tenantName" column="tenant_name" />
|
||||
<result property="ownerId" column="owner_id" />
|
||||
<result property="parentId" column="parent_id" />
|
||||
<result property="deptId" column="dept_id" />
|
||||
<result property="administrativeAreaCode" column="administrative_area_code" />
|
||||
<result property="deptName" column="dept_name" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectProjectVo">
|
||||
select project_id, project_name, sys_show_name, central_coordinates, scope, administrative_area, owner, logo, image, video_introduction, remark, p_params, introduce, del_flag, create_time, create_by, update_time, remarks, tenant_id, tenant_name, owner_id, parent_id from project
|
||||
select project_id, project_name, sys_show_name, central_coordinates, scope, administrative_area, owner, logo, image, video_introduction, remark, p_params, introduce, del_flag, create_time, create_by, update_time, remarks, tenant_id, tenant_name, owner_id, parent_id, dept_id, administrative_area_code, dept_name from project
|
||||
</sql>
|
||||
|
||||
<select id="selectProjectList" parameterType="Project" resultMap="ProjectResult">
|
||||
@ -52,6 +55,9 @@
|
||||
<if test="tenantName != null and tenantName != ''"> and tenant_name like concat('%', #{tenantName}, '%')</if>
|
||||
<if test="ownerId != null "> and owner_id = #{ownerId}</if>
|
||||
<if test="parentId != null "> and parent_id = #{parentId}</if>
|
||||
<if test="deptId != null "> and dept_id = #{deptId}</if>
|
||||
<if test="administrativeAreaCode != null and administrativeAreaCode != ''"> and administrative_area_code = #{administrativeAreaCode}</if>
|
||||
<if test="deptName != null and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
@ -85,6 +91,9 @@
|
||||
<if test="tenantName != null">tenant_name,</if>
|
||||
<if test="ownerId != null">owner_id,</if>
|
||||
<if test="parentId != null">parent_id,</if>
|
||||
<if test="deptId != null">dept_id,</if>
|
||||
<if test="administrativeAreaCode != null">administrative_area_code,</if>
|
||||
<if test="deptName != null">dept_name,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="projectId != null">#{projectId},</if>
|
||||
@ -109,6 +118,9 @@
|
||||
<if test="tenantName != null">#{tenantName},</if>
|
||||
<if test="ownerId != null">#{ownerId},</if>
|
||||
<if test="parentId != null">#{parentId},</if>
|
||||
<if test="deptId != null">#{deptId},</if>
|
||||
<if test="administrativeAreaCode != null">#{administrativeAreaCode},</if>
|
||||
<if test="deptName != null">#{deptName},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@ -136,6 +148,9 @@
|
||||
<if test="tenantName != null">tenant_name = #{tenantName},</if>
|
||||
<if test="ownerId != null">owner_id = #{ownerId},</if>
|
||||
<if test="parentId != null">parent_id = #{parentId},</if>
|
||||
<if test="deptId != null">dept_id = #{deptId},</if>
|
||||
<if test="administrativeAreaCode != null">administrative_area_code = #{administrativeAreaCode},</if>
|
||||
<if test="deptName != null">dept_name = #{deptName},</if>
|
||||
</trim>
|
||||
where project_id = #{projectId}
|
||||
</update>
|
||||
|
Reference in New Issue
Block a user