项目管理接口相关逻辑补充,部门添加型行政区划树状层级业务等
This commit is contained in:
@ -73,6 +73,41 @@ public class SysDept extends BaseEntity
|
|||||||
@ApiModelProperty("删除标志(0代表存在 2代表删除)")
|
@ApiModelProperty("删除标志(0代表存在 2代表删除)")
|
||||||
private String delFlag;
|
private String delFlag;
|
||||||
|
|
||||||
|
/** 行政区域 */
|
||||||
|
@ApiModelProperty("行政区域")
|
||||||
|
private String administrativeArea;
|
||||||
|
|
||||||
|
/** 行政区域代码 */
|
||||||
|
@ApiModelProperty("行政区域代码")
|
||||||
|
private String administrativeAreaCode;
|
||||||
|
|
||||||
|
/** 行政区域省代码 */
|
||||||
|
@ApiModelProperty("行政区域省代码")
|
||||||
|
private String provinceCode;
|
||||||
|
|
||||||
|
/** 行政区域市代码 */
|
||||||
|
@ApiModelProperty("行政区域市代码")
|
||||||
|
private String cityCode;
|
||||||
|
|
||||||
|
/** 行政区域县代码 */
|
||||||
|
@ApiModelProperty("行政区域县代码")
|
||||||
|
private String countyCode;
|
||||||
|
|
||||||
|
/** 行政区域镇代码 */
|
||||||
|
@ApiModelProperty("行政区域镇代码")
|
||||||
|
private String townCode;
|
||||||
|
|
||||||
|
/** 行政区域村代码 */
|
||||||
|
@ApiModelProperty("行政区域村代码")
|
||||||
|
private String villageCode;
|
||||||
|
|
||||||
|
/** 部门管理的项目id */
|
||||||
|
@ApiModelProperty("部门管理的项目id")
|
||||||
|
private Long projectId;
|
||||||
|
|
||||||
|
|
||||||
|
//业务字段-----------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
/** 父部门名称 */
|
/** 父部门名称 */
|
||||||
@ApiModelProperty("父部门名称")
|
@ApiModelProperty("父部门名称")
|
||||||
private String parentName;
|
private String parentName;
|
||||||
|
@ -146,7 +146,7 @@ public class ProjectController extends BaseController
|
|||||||
*/
|
*/
|
||||||
@GetMapping("/areaTree")
|
@GetMapping("/areaTree")
|
||||||
@ApiOperation("查询项目的行政区划树状列表")
|
@ApiOperation("查询项目的行政区划树状列表")
|
||||||
public AjaxResult getProjectAreaTree(@Param("projectId") Long projectId,@Param("startLevel") Integer startLevel){
|
public AjaxResult getProjectAreaTree(@Param("projectId") Long deptId,@Param("startLevel") Integer startLevel){
|
||||||
return success(projectService.getProjectAreaTree(projectId, startLevel));
|
return success(projectService.getProjectAreaTree(deptId, startLevel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
<groupId>com.fastbee</groupId>
|
<groupId>com.fastbee</groupId>
|
||||||
<artifactId>fastbee-system-service</artifactId>
|
<artifactId>fastbee-system-service</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fastbee</groupId>
|
||||||
|
<artifactId>fastbee-iot-service</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -153,4 +153,20 @@ public class Project extends BaseEntity
|
|||||||
@ApiModelProperty("行政区域村代码")
|
@ApiModelProperty("行政区域村代码")
|
||||||
private String villageCode;
|
private String villageCode;
|
||||||
|
|
||||||
|
//业务字段---------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* 系统账号名称
|
||||||
|
*/
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统账号密码
|
||||||
|
*/
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 确认密码
|
||||||
|
*/
|
||||||
|
private String confirmPassword;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -78,5 +78,5 @@ public interface IProjectService
|
|||||||
* 获取项目行政区域列表
|
* 获取项目行政区域列表
|
||||||
* @return 行政区域列表
|
* @return 行政区域列表
|
||||||
*/
|
*/
|
||||||
List<SysDistrict> getProjectAreaTree(Long projectId,Integer startLevel);
|
List<SysDistrict> getProjectAreaTree(Long deptId,Integer startLevel);
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,18 @@ import cn.hutool.json.JSONArray;
|
|||||||
import cn.hutool.json.JSONException;
|
import cn.hutool.json.JSONException;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
|
||||||
import com.fastbee.common.constant.ProjectLevelConstant;
|
import com.fastbee.common.constant.ProjectLevelConstant;
|
||||||
import com.fastbee.common.core.domain.entity.SysDept;
|
import com.fastbee.common.core.domain.entity.SysDept;
|
||||||
|
import com.fastbee.common.core.domain.entity.SysMenu;
|
||||||
|
import com.fastbee.common.core.domain.entity.SysRole;
|
||||||
import com.fastbee.common.core.domain.entity.SysUser;
|
import com.fastbee.common.core.domain.entity.SysUser;
|
||||||
import com.fastbee.common.exception.ServiceException;
|
import com.fastbee.common.exception.ServiceException;
|
||||||
import com.fastbee.common.holder.ProjectHolder;
|
import com.fastbee.common.holder.ProjectHolder;
|
||||||
import com.fastbee.common.utils.DateUtils;
|
import com.fastbee.common.utils.DateUtils;
|
||||||
|
import com.fastbee.iot.model.RegisterUserInput;
|
||||||
|
import com.fastbee.iot.model.RegisterUserOutput;
|
||||||
|
import com.fastbee.iot.service.IToolService;
|
||||||
import com.fastbee.project.domain.Project;
|
import com.fastbee.project.domain.Project;
|
||||||
import com.fastbee.project.mapper.ProjectMapper;
|
import com.fastbee.project.mapper.ProjectMapper;
|
||||||
import com.fastbee.project.service.IProjectService;
|
import com.fastbee.project.service.IProjectService;
|
||||||
@ -19,8 +25,12 @@ import com.fastbee.system.domain.SysDistrict;
|
|||||||
import com.fastbee.system.mapper.SysDeptMapper;
|
import com.fastbee.system.mapper.SysDeptMapper;
|
||||||
import com.fastbee.system.mapper.SysDistrictMapper;
|
import com.fastbee.system.mapper.SysDistrictMapper;
|
||||||
import com.fastbee.system.mapper.SysUserMapper;
|
import com.fastbee.system.mapper.SysUserMapper;
|
||||||
|
import com.fastbee.system.service.ISysDeptService;
|
||||||
|
import com.fastbee.system.service.ISysMenuService;
|
||||||
|
import com.fastbee.system.service.ISysRoleService;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -40,13 +50,25 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
|
|
||||||
private final SysDistrictMapper sysDistrictMapper;
|
private final SysDistrictMapper sysDistrictMapper;
|
||||||
|
|
||||||
public ProjectServiceImpl(ProjectMapper projectMapper, SysDeptMapper sysDeptMapper, SysUserMapper sysUserMapper, SysDistrictMapper sysDistrictMapper) {
|
private final ISysMenuService sysMenuService;
|
||||||
|
|
||||||
|
private final ISysRoleService sysRoleService;
|
||||||
|
|
||||||
|
private final ISysDeptService deptService;
|
||||||
|
private final IToolService toolService;
|
||||||
|
|
||||||
|
public ProjectServiceImpl(ProjectMapper projectMapper, SysDeptMapper sysDeptMapper, SysUserMapper sysUserMapper, SysDistrictMapper sysDistrictMapper, ISysMenuService sysMenuService, ISysRoleService sysRoleService, ISysDeptService deptService, IToolService toolService) {
|
||||||
this.projectMapper = projectMapper;
|
this.projectMapper = projectMapper;
|
||||||
this.sysDeptMapper = sysDeptMapper;
|
this.sysDeptMapper = sysDeptMapper;
|
||||||
this.sysUserMapper = sysUserMapper;
|
this.sysUserMapper = sysUserMapper;
|
||||||
this.sysDistrictMapper = sysDistrictMapper;
|
this.sysDistrictMapper = sysDistrictMapper;
|
||||||
|
this.sysMenuService = sysMenuService;
|
||||||
|
this.sysRoleService = sysRoleService;
|
||||||
|
this.deptService = deptService;
|
||||||
|
this.toolService = toolService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据主键查询项目
|
* 根据主键查询项目
|
||||||
*
|
*
|
||||||
@ -88,21 +110,99 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
* 新增项目
|
* 新增项目
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public int insertProject(Project project)
|
public int insertProject(Project project)
|
||||||
{
|
{
|
||||||
//判断选择的机构下是否已经绑定项目
|
//判断选择的机构下是否已经绑定项目
|
||||||
List<Project> projectList = new LambdaQueryChainWrapper<>(projectMapper)
|
// List<Project> projectList = new LambdaQueryChainWrapper<>(projectMapper)
|
||||||
.select(Project::getId, Project::getProjectName)
|
// .select(Project::getId, Project::getProjectName)
|
||||||
.eq(Project::getDeptId, project.getDeptId()).list();
|
// .eq(Project::getDeptId, project.getDeptId()).list();
|
||||||
if(!projectList.isEmpty()){
|
// if(!projectList.isEmpty()){
|
||||||
throw new ServiceException("该机构下已经存在项目");
|
// throw new ServiceException("该机构下已经存在项目");
|
||||||
}
|
// }
|
||||||
|
//TODO 参数校验
|
||||||
|
//获取当前时间
|
||||||
|
Date nowDate = DateUtils.getNowDate();
|
||||||
//处理项目行政区划
|
//处理项目行政区划
|
||||||
parseAdministrativeDivisionInfo(project);
|
parseAdministrativeDivisionInfo(project);
|
||||||
|
//给项目分配一个机构--------------------------------------------------------
|
||||||
|
SysDept newSysDept = new SysDept();
|
||||||
|
//设置上级机构id
|
||||||
|
newSysDept.setParentId(100L);
|
||||||
|
//设置祖级列表
|
||||||
|
newSysDept.setAncestors("0,100");
|
||||||
|
//设置创建时间
|
||||||
|
newSysDept.setCreateTime(nowDate);
|
||||||
|
//设置默认机构名称
|
||||||
|
newSysDept.setDeptName(project.getProjectName());
|
||||||
|
newSysDept.setLeader("admin");
|
||||||
|
|
||||||
|
//设置机构型行政区域信息
|
||||||
|
newSysDept.setAdministrativeAreaCode(Objects.nonNull(project.getAdministrativeAreaCode())?project.getAdministrativeAreaCode():null);
|
||||||
|
newSysDept.setAdministrativeArea(Objects.nonNull(project.getAdministrativeArea())?project.getAdministrativeArea():null);
|
||||||
|
newSysDept.setProvinceCode(Objects.nonNull(project.getProvinceCode())?project.getProvinceCode():null);
|
||||||
|
newSysDept.setCityCode(Objects.nonNull(project.getCityCode())?project.getCityCode():null);
|
||||||
|
newSysDept.setCountyCode(Objects.nonNull(project.getCountyCode())?project.getCountyCode():null);
|
||||||
|
newSysDept.setTownCode(Objects.nonNull(project.getTownCode())?project.getTownCode():null);
|
||||||
|
newSysDept.setVillageCode(Objects.nonNull(project.getVillageCode())?project.getVillageCode():null);
|
||||||
|
|
||||||
|
if(sysDeptMapper.insertDept(newSysDept)<1){
|
||||||
|
throw new ServiceException("创建默认机构失败!");
|
||||||
|
}
|
||||||
|
// 新增机构关联系统账号
|
||||||
|
|
||||||
|
// 添加管理员角色,给所有权限
|
||||||
|
SysDept sysDept = deptService.selectDeptById(100L);
|
||||||
|
List<SysMenu> sysMenuList = sysMenuService.selectMenuList(new SysMenu(), sysDept.getDeptUserId());
|
||||||
|
Long[] menuIdList = sysMenuList.stream().map(SysMenu::getMenuId).toArray(Long[]::new);
|
||||||
|
SysRole sysRole = new SysRole();
|
||||||
|
sysRole.setRoleName("管理员");
|
||||||
|
sysRole.setRoleKey("manager");
|
||||||
|
sysRole.setRoleSort(1);
|
||||||
|
sysRole.setStatus("0");
|
||||||
|
sysRole.setDeptId(newSysDept.getDeptId());
|
||||||
|
sysRole.setMenuIds(menuIdList);
|
||||||
|
sysRoleService.insertRole(sysRole);
|
||||||
|
|
||||||
|
// 注册机构管理员用户
|
||||||
|
RegisterUserInput registerUserInput = new RegisterUserInput();
|
||||||
|
registerUserInput.setUsername(project.getUserName());
|
||||||
|
registerUserInput.setPassword(project.getPassword());
|
||||||
|
registerUserInput.setPhonenumber("15666617898");
|
||||||
|
registerUserInput.setDeptId(newSysDept.getDeptId());
|
||||||
|
registerUserInput.setRoleIds(new Long[]{sysRole.getRoleId()});
|
||||||
|
RegisterUserOutput registerUserOutput = toolService.registerNoCaptcha(registerUserInput);
|
||||||
|
if (com.fastbee.common.utils.StringUtils.isNotEmpty(registerUserOutput.getMsg())) {
|
||||||
|
deptService.deleteDeptById(newSysDept.getDeptId());
|
||||||
|
sysRoleService.deleteRoleById(sysRole.getRoleId());
|
||||||
|
throw new ServiceException(registerUserOutput.getMsg());
|
||||||
|
}
|
||||||
|
// 更新机构管理员角色绑定信息
|
||||||
|
deptService.updateDeptUserId(newSysDept.getDeptId(), registerUserOutput.getSysUserId());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// //创建该机构的登录账号数据
|
||||||
|
// SysUser newSysUser = new SysUser();
|
||||||
|
// newSysUser.setUserName(project.getUserName());
|
||||||
|
// newSysUser.setPassword(project.getPassword());
|
||||||
|
// newSysUser.setNickName(project.getProjectName()+"管理员");
|
||||||
|
// newSysUser.setDeptId(newSysDept.getDeptId());
|
||||||
|
// newSysUser.setCreateTime(nowDate);
|
||||||
|
// newSysUser.setCreateBy(project.getCreateBy());
|
||||||
|
//
|
||||||
|
// if(sysUserMapper.insertUser(newSysUser)<1){
|
||||||
|
// throw new ServiceException("创建默认机构管理员账号失败!");
|
||||||
|
// }
|
||||||
|
project.setDeptId(newSysDept.getDeptId());
|
||||||
project.setCreateTime(DateUtils.getNowDate());
|
project.setCreateTime(DateUtils.getNowDate());
|
||||||
return projectMapper.insertProject(project);
|
return projectMapper.insertProject(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析项目行政区划信息
|
||||||
|
* @param project 项目
|
||||||
|
*/
|
||||||
private void parseAdministrativeDivisionInfo(Project project) {
|
private void parseAdministrativeDivisionInfo(Project project) {
|
||||||
//项目行政区域处理
|
//项目行政区域处理
|
||||||
//拆解项目行政区域代码信息
|
//拆解项目行政区域代码信息
|
||||||
@ -131,19 +231,25 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
//单个行政区划代码列表
|
//单个行政区划代码列表
|
||||||
JSONArray administrativeArea = JSONUtil.parseArray(item);
|
JSONArray administrativeArea = JSONUtil.parseArray(item);
|
||||||
//拆解出每个行政区划代码里面的镇或村
|
//拆解出每个行政区划代码里面的镇或村
|
||||||
if(administrativeArea.size()!=5){
|
// if(administrativeArea.size()!=5){
|
||||||
throw new ServiceException("项目行政区域代码多选列表的元素长度必须为5,到达村级别!");
|
// throw new ServiceException("项目行政区域代码多选列表的元素长度必须为5,到达村级别!");
|
||||||
}
|
// }
|
||||||
//保存项目省代码列表
|
//保存项目省代码列表
|
||||||
provincialCodeList.add(administrativeArea.get(0).toString());
|
provincialCodeList.add(administrativeArea.get(0).toString());
|
||||||
//保存项目市代码列表
|
//保存项目市代码列表
|
||||||
cityCodeList.add(administrativeArea.get(1).toString());
|
cityCodeList.add(administrativeArea.get(1).toString());
|
||||||
//保存项目县代码列表
|
//保存项目县代码列表
|
||||||
countyCodeList.add(administrativeArea.get(2).toString());
|
countyCodeList.add(administrativeArea.get(2).toString());
|
||||||
|
|
||||||
|
if(administrativeArea.size()>=4){
|
||||||
//保存项目镇代码列表
|
//保存项目镇代码列表
|
||||||
townCodeList.add(administrativeArea.get(3).toString());
|
townCodeList.add(administrativeArea.get(3).toString());
|
||||||
|
}
|
||||||
|
if(administrativeArea.size()>=5){
|
||||||
//保存项目村代码列表
|
//保存项目村代码列表
|
||||||
villageCodeList.add(administrativeArea.get(4).toString());
|
villageCodeList.add(administrativeArea.get(4).toString());
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//设置项目省、市、县、镇、村行政区划代码列表
|
//设置项目省、市、县、镇、村行政区划代码列表
|
||||||
@ -170,6 +276,7 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
* 修改项目
|
* 修改项目
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public int updateProject(Project project)
|
public int updateProject(Project project)
|
||||||
{
|
{
|
||||||
//判断选择的机构下是否已经绑定项目
|
//判断选择的机构下是否已经绑定项目
|
||||||
@ -187,7 +294,24 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
project.setUpdateTime(DateUtils.getNowDate());
|
project.setUpdateTime(DateUtils.getNowDate());
|
||||||
//处理项目行政区划
|
//处理项目行政区划
|
||||||
parseAdministrativeDivisionInfo(project);
|
parseAdministrativeDivisionInfo(project);
|
||||||
return projectMapper.updateProject(project);
|
//同步更新项目所属最顶级部门行政区划数据
|
||||||
|
boolean updateDept = new LambdaUpdateChainWrapper<>(sysDeptMapper)
|
||||||
|
.set(SysDept::getAdministrativeAreaCode, project.getAdministrativeAreaCode())
|
||||||
|
.set(SysDept::getProvinceCode, project.getProvinceCode())
|
||||||
|
.set(SysDept::getCityCode, project.getCityCode())
|
||||||
|
.set(SysDept::getCountyCode, project.getCountyCode())
|
||||||
|
.set(SysDept::getTownCode, project.getTownCode())
|
||||||
|
.set(SysDept::getVillageCode, project.getVillageCode())
|
||||||
|
.eq(SysDept::getDeptId, project.getDeptId())
|
||||||
|
.update();
|
||||||
|
if(!updateDept){
|
||||||
|
throw new ServiceException("同步更新项目所属最顶级部门行政区划数据失败!");
|
||||||
|
}
|
||||||
|
int updateProject = projectMapper.updateProject(project);
|
||||||
|
if(updateProject <1 ){
|
||||||
|
throw new ServiceException("修改项目失败!");
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -211,7 +335,6 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
.select(SysUser::getUserId, SysUser::getDeptId)
|
.select(SysUser::getUserId, SysUser::getDeptId)
|
||||||
.eq(SysUser::getUserId, userId)
|
.eq(SysUser::getUserId, userId)
|
||||||
.one();
|
.one();
|
||||||
|
|
||||||
//查询该管理员所管理的项目id以及子项目id列表
|
//查询该管理员所管理的项目id以及子项目id列表
|
||||||
Project project = new LambdaQueryChainWrapper<>(projectMapper)
|
Project project = new LambdaQueryChainWrapper<>(projectMapper)
|
||||||
.select(Project::getId, Project::getProjectName,Project::getLevel,Project::getDeptId
|
.select(Project::getId, Project::getProjectName,Project::getLevel,Project::getDeptId
|
||||||
@ -311,24 +434,30 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
* 查询项目的行政区划树状列表
|
* 查询项目的行政区划树状列表
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<SysDistrict> getProjectAreaTree(Long projectId,Integer startLevel) {
|
public List<SysDistrict> getProjectAreaTree(Long deptId,Integer startLevel) {
|
||||||
//参数校验
|
//参数校验
|
||||||
if(startLevel>5||startLevel<1){
|
if(startLevel>5||startLevel<1){
|
||||||
throw new ServiceException("超出行政级别查询范围(1~5级)!");
|
throw new ServiceException("超出行政级别查询范围(1~5级)!");
|
||||||
}
|
}
|
||||||
//查询项目的行政区划信息
|
//查询项目的行政区划信息
|
||||||
Project project = new LambdaQueryChainWrapper<>(projectMapper)
|
// Project project = new LambdaQueryChainWrapper<>(projectMapper)
|
||||||
.select(Project::getProvinceCode, Project::getCityCode, Project::getCountyCode,
|
// .select(Project::getProvinceCode, Project::getCityCode, Project::getCountyCode,
|
||||||
Project::getTownCode, Project::getVillageCode)
|
// Project::getTownCode, Project::getVillageCode)
|
||||||
.eq(Project::getId, projectId)
|
// .eq(Project::getId, projectId)
|
||||||
|
// .one();
|
||||||
|
SysDept sysDept = new LambdaQueryChainWrapper<>(sysDeptMapper)
|
||||||
|
.select(SysDept::getDeptId,SysDept::getProvinceCode, SysDept::getCityCode, SysDept::getCountyCode,
|
||||||
|
SysDept::getTownCode, SysDept::getVillageCode)
|
||||||
|
.eq(SysDept::getDeptId, deptId)
|
||||||
.one();
|
.one();
|
||||||
if (Objects.isNull(project)) {
|
if (Objects.isNull(sysDept)) {
|
||||||
throw new ServiceException("项目不存在");
|
// throw new ServiceException("项目不存在");
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
//判断项目的省、市、县、镇、村行政区划列表数据不为null
|
//判断项目的省、市、县、镇、村行政区划列表数据不为null
|
||||||
isProvinceCodeBlank(project);
|
isProvinceCodeBlank(sysDept);
|
||||||
|
|
||||||
List<Object> administrativeCodeList = getTownAndvillageCodeList(project,startLevel);
|
List<Object> administrativeCodeList = getTownAndvillageCodeList(sysDept,startLevel);
|
||||||
|
|
||||||
//查询项目所属县下面的所有镇、村行政区划列表
|
//查询项目所属县下面的所有镇、村行政区划列表
|
||||||
List<SysDistrict> projectDistrictList;
|
List<SysDistrict> projectDistrictList;
|
||||||
@ -339,7 +468,7 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
|
|
||||||
//限制行政区划级别
|
//限制行政区划级别
|
||||||
projectDistrictList = sysDistrictLambdaQueryChainWrapper
|
projectDistrictList = sysDistrictLambdaQueryChainWrapper
|
||||||
.in(SysDistrict::getAdcode,administrativeCodeList)
|
.in(!administrativeCodeList.isEmpty(),SysDistrict::getAdcode,administrativeCodeList)
|
||||||
.list();
|
.list();
|
||||||
|
|
||||||
// System.err.println("项目所属县下面的所有镇、村行政区划列表");
|
// System.err.println("项目所属县下面的所有镇、村行政区划列表");
|
||||||
@ -348,12 +477,15 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
return buildTree(projectDistrictList);
|
return buildTree(projectDistrictList);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Object> getTownAndvillageCodeList(Project project,Integer startLevel) {
|
private static List<Object> getTownAndvillageCodeList(SysDept sysDept,Integer startLevel) {
|
||||||
|
// if(sysDept.getDeptId().toString().equals("100")){
|
||||||
|
// return new ArrayList<>();
|
||||||
|
// }
|
||||||
//查询项目的省、市、县、镇、村行政区划列表数据
|
//查询项目的省、市、县、镇、村行政区划列表数据
|
||||||
//目前项目下面的镇或者村都可以多选划分成一个项目
|
//目前项目下面的镇或者村都可以多选划分成一个项目
|
||||||
//找到项目行政区划开始多选的级别
|
//找到项目行政区划开始多选的级别
|
||||||
//判断省是否多选
|
//判断省是否多选
|
||||||
JSONArray provinceCodeList = JSONUtil.parseArray(project.getProvinceCode());
|
JSONArray provinceCodeList = JSONUtil.parseArray(sysDept.getProvinceCode());
|
||||||
//判断集合中的元素值都相等则说明省未多选
|
//判断集合中的元素值都相等则说明省未多选
|
||||||
if (!provinceCodeList.stream().allMatch(provinceCode -> provinceCode.equals(provinceCodeList.get(0)))) {
|
if (!provinceCodeList.stream().allMatch(provinceCode -> provinceCode.equals(provinceCodeList.get(0)))) {
|
||||||
throw new ServiceException("项目省级行政区划只能包含一个省!");
|
throw new ServiceException("项目省级行政区划只能包含一个省!");
|
||||||
@ -362,7 +494,7 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
List<Object> distinctProvinceCodeList = provinceCodeList.stream().distinct().collect(Collectors.toList());
|
List<Object> distinctProvinceCodeList = provinceCodeList.stream().distinct().collect(Collectors.toList());
|
||||||
|
|
||||||
//判断市是否多选
|
//判断市是否多选
|
||||||
JSONArray cityCodeList = JSONUtil.parseArray(project.getCityCode());
|
JSONArray cityCodeList = JSONUtil.parseArray(sysDept.getCityCode());
|
||||||
//判断集合中的元素值都相等则说明市未多选
|
//判断集合中的元素值都相等则说明市未多选
|
||||||
if (!cityCodeList.stream().allMatch(cityCode -> cityCode.equals(cityCodeList.get(0)))) {
|
if (!cityCodeList.stream().allMatch(cityCode -> cityCode.equals(cityCodeList.get(0)))) {
|
||||||
throw new ServiceException("项目市级行政区划只能包含一个市!");
|
throw new ServiceException("项目市级行政区划只能包含一个市!");
|
||||||
@ -371,7 +503,7 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
List<Object> distinctCityCodeList = cityCodeList.stream().distinct().collect(Collectors.toList());
|
List<Object> distinctCityCodeList = cityCodeList.stream().distinct().collect(Collectors.toList());
|
||||||
|
|
||||||
//判断县是否多选
|
//判断县是否多选
|
||||||
JSONArray countyCodeList = JSONUtil.parseArray(project.getCountyCode());
|
JSONArray countyCodeList = JSONUtil.parseArray(sysDept.getCountyCode());
|
||||||
//判断集合中的元素值都相等则说明县未多选
|
//判断集合中的元素值都相等则说明县未多选
|
||||||
if (!countyCodeList.stream().allMatch(countyCode -> countyCode.equals(countyCodeList.get(0)))) {
|
if (!countyCodeList.stream().allMatch(countyCode -> countyCode.equals(countyCodeList.get(0)))) {
|
||||||
throw new ServiceException("项目县级行政区划只能包含一个县!");
|
throw new ServiceException("项目县级行政区划只能包含一个县!");
|
||||||
@ -380,12 +512,12 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
List<Object> distinctcCountyCodeList= countyCodeList.stream().distinct().collect(Collectors.toList());
|
List<Object> distinctcCountyCodeList= countyCodeList.stream().distinct().collect(Collectors.toList());
|
||||||
|
|
||||||
//判断镇是否多选
|
//判断镇是否多选
|
||||||
JSONArray townCodeList = JSONUtil.parseArray(project.getTownCode());
|
JSONArray townCodeList = JSONUtil.parseArray(sysDept.getTownCode());
|
||||||
//判断集合中的元素值都相等则说明镇未多选
|
//判断集合中的元素值都相等则说明镇未多选
|
||||||
List<Object> distinctTownCodeList;
|
List<Object> distinctTownCodeList;
|
||||||
|
|
||||||
distinctTownCodeList = townCodeList.stream().distinct().collect(Collectors.toList());
|
distinctTownCodeList = townCodeList.stream().distinct().collect(Collectors.toList());
|
||||||
JSONArray villageCodeList = JSONUtil.parseArray(project.getVillageCode());
|
JSONArray villageCodeList = JSONUtil.parseArray(sysDept.getVillageCode());
|
||||||
|
|
||||||
// System.err.println("镇行政区划代码");
|
// System.err.println("镇行政区划代码");
|
||||||
// System.err.println(distinctTownCodeList);
|
// System.err.println(distinctTownCodeList);
|
||||||
@ -409,20 +541,23 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
return administrativeCodeList;
|
return administrativeCodeList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void isProvinceCodeBlank(Project project) {
|
private void isProvinceCodeBlank(SysDept sysDept) {
|
||||||
if (StringUtils.isBlank(project.getProvinceCode())){
|
// if(sysDept.getDeptId().toString().equals("100")){
|
||||||
|
// return ;
|
||||||
|
// }
|
||||||
|
if (StringUtils.isBlank(sysDept.getProvinceCode())){
|
||||||
throw new ServiceException("项目省级行政区划信息缺失!");
|
throw new ServiceException("项目省级行政区划信息缺失!");
|
||||||
}
|
}
|
||||||
if (StringUtils.isBlank(project.getCityCode())){
|
if (StringUtils.isBlank(sysDept.getCityCode())){
|
||||||
throw new ServiceException("项目市级行政区划信息缺失!");
|
throw new ServiceException("项目市级行政区划信息缺失!");
|
||||||
}
|
}
|
||||||
if (StringUtils.isBlank(project.getCountyCode())){
|
if (StringUtils.isBlank(sysDept.getCountyCode())){
|
||||||
throw new ServiceException("项目县级行政区划信息缺失!");
|
throw new ServiceException("项目县级行政区划信息缺失!");
|
||||||
}
|
}
|
||||||
if (StringUtils.isBlank(project.getTownCode())){
|
if (StringUtils.isBlank(sysDept.getTownCode())){
|
||||||
throw new ServiceException("项目镇级行政区划信息缺失!");
|
throw new ServiceException("项目镇级行政区划信息缺失!");
|
||||||
}
|
}
|
||||||
if (StringUtils.isBlank(project.getVillageCode())){
|
if (StringUtils.isBlank(sysDept.getVillageCode())){
|
||||||
throw new ServiceException("项目村级行政区划信息缺失!");
|
throw new ServiceException("项目村级行政区划信息缺失!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package com.fastbee.system.service.impl;
|
package com.fastbee.system.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONArray;
|
||||||
|
import cn.hutool.json.JSONException;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.fastbee.common.annotation.DataScope;
|
import com.fastbee.common.annotation.DataScope;
|
||||||
import com.fastbee.common.constant.UserConstants;
|
import com.fastbee.common.constant.UserConstants;
|
||||||
import com.fastbee.common.core.domain.TreeSelect;
|
import com.fastbee.common.core.domain.TreeSelect;
|
||||||
@ -9,6 +12,7 @@ import com.fastbee.common.core.domain.entity.SysUser;
|
|||||||
import com.fastbee.common.core.domain.model.LoginUser;
|
import com.fastbee.common.core.domain.model.LoginUser;
|
||||||
import com.fastbee.common.core.text.Convert;
|
import com.fastbee.common.core.text.Convert;
|
||||||
import com.fastbee.common.exception.ServiceException;
|
import com.fastbee.common.exception.ServiceException;
|
||||||
|
import com.fastbee.common.utils.DateUtils;
|
||||||
import com.fastbee.common.utils.SecurityUtils;
|
import com.fastbee.common.utils.SecurityUtils;
|
||||||
import com.fastbee.common.utils.StringUtils;
|
import com.fastbee.common.utils.StringUtils;
|
||||||
import com.fastbee.common.utils.spring.SpringUtils;
|
import com.fastbee.common.utils.spring.SpringUtils;
|
||||||
@ -245,10 +249,87 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||||||
{
|
{
|
||||||
throw new ServiceException("部门停用,不允许新增");
|
throw new ServiceException("部门停用,不允许新增");
|
||||||
}
|
}
|
||||||
|
//设置祖级别列表
|
||||||
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
|
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
|
||||||
|
//处理机构所管理行政区划信息
|
||||||
|
parseAdministrativeDivisionInfo(dept);
|
||||||
|
dept.setCreateTime(DateUtils.getNowDate());
|
||||||
return deptMapper.insertDept(dept);
|
return deptMapper.insertDept(dept);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析项目行政区划信息
|
||||||
|
* @param sysDept 部门
|
||||||
|
*/
|
||||||
|
private void parseAdministrativeDivisionInfo(SysDept sysDept) {
|
||||||
|
//项目行政区域处理
|
||||||
|
//拆解项目行政区域代码信息
|
||||||
|
if(org.apache.commons.lang3.StringUtils.isBlank(sysDept.getAdministrativeAreaCode())){
|
||||||
|
throw new ServiceException("项目行政区域代码不能为空!");
|
||||||
|
}
|
||||||
|
//判断行政区域代码json格式
|
||||||
|
if(isNotValidJsonArray(sysDept.getAdministrativeAreaCode())){
|
||||||
|
throw new ServiceException("项目行政区域代码多选列表非json数组!");
|
||||||
|
}
|
||||||
|
//项目省代码列表
|
||||||
|
List<String> provincialCodeList =new ArrayList<>();
|
||||||
|
//项目市代码列表
|
||||||
|
List<String> cityCodeList =new ArrayList<>();
|
||||||
|
//项目县代码列表
|
||||||
|
List<String> countyCodeList =new ArrayList<>();
|
||||||
|
//项目镇代码列表
|
||||||
|
List<String> townCodeList =new ArrayList<>();
|
||||||
|
//项目村代码列表
|
||||||
|
List<String> villageCodeList =new ArrayList<>();
|
||||||
|
JSONArray administrativeAreaList = JSONUtil.parseArray(sysDept.getAdministrativeAreaCode());
|
||||||
|
administrativeAreaList.forEach(item->{
|
||||||
|
if(isNotValidJsonArray(item.toString())){
|
||||||
|
throw new ServiceException("项目行政区域代码多选列表的元素非json数组!");
|
||||||
|
}
|
||||||
|
//单个行政区划代码列表
|
||||||
|
JSONArray administrativeArea = JSONUtil.parseArray(item);
|
||||||
|
//拆解出每个行政区划代码里面的镇或村
|
||||||
|
// if(administrativeArea.size()!=5){
|
||||||
|
// throw new ServiceException("项目行政区域代码多选列表的元素长度必须为5,到达村级别!");
|
||||||
|
// }
|
||||||
|
//保存项目省代码列表
|
||||||
|
provincialCodeList.add(administrativeArea.get(0).toString());
|
||||||
|
//保存项目市代码列表
|
||||||
|
cityCodeList.add(administrativeArea.get(1).toString());
|
||||||
|
//保存项目县代码列表
|
||||||
|
countyCodeList.add(administrativeArea.get(2).toString());
|
||||||
|
//保存项目镇代码列表
|
||||||
|
|
||||||
|
if(administrativeArea.size()>=4){
|
||||||
|
//保存项目镇代码列表
|
||||||
|
townCodeList.add(administrativeArea.get(3).toString());
|
||||||
|
}
|
||||||
|
if(administrativeArea.size()>=5){
|
||||||
|
//保存项目村代码列表
|
||||||
|
villageCodeList.add(administrativeArea.get(4).toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//设置项目省、市、县、镇、村行政区划代码列表
|
||||||
|
sysDept.setProvinceCode(JSONUtil.toJsonStr(provincialCodeList));
|
||||||
|
sysDept.setCityCode(JSONUtil.toJsonStr(cityCodeList));
|
||||||
|
sysDept.setCountyCode(JSONUtil.toJsonStr(countyCodeList));
|
||||||
|
sysDept.setTownCode(JSONUtil.toJsonStr(townCodeList));
|
||||||
|
sysDept.setVillageCode(JSONUtil.toJsonStr(villageCodeList));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证json对象是否是数组
|
||||||
|
*/
|
||||||
|
public boolean isNotValidJsonArray(String jsonStr) {
|
||||||
|
try {
|
||||||
|
JSONUtil.parseArray(jsonStr);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改保存部门信息
|
* 修改保存部门信息
|
||||||
*
|
*
|
||||||
@ -261,17 +342,26 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||||||
})
|
})
|
||||||
@Override
|
@Override
|
||||||
public int updateDept(SysDept dept)
|
public int updateDept(SysDept dept)
|
||||||
{
|
{ //查询当前修改部门的父部门
|
||||||
SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
|
SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
|
||||||
|
//查询当前修改部门修改前的旧数据
|
||||||
SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
|
SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
|
||||||
if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept))
|
if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept))
|
||||||
{
|
{
|
||||||
|
//更新部门的祖级列表
|
||||||
String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
|
String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
|
||||||
String oldAncestors = oldDept.getAncestors();
|
String oldAncestors = oldDept.getAncestors();
|
||||||
dept.setAncestors(newAncestors);
|
dept.setAncestors(newAncestors);
|
||||||
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
|
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//处理机构所管理行政区划信息
|
||||||
|
parseAdministrativeDivisionInfo(dept);
|
||||||
|
//更新部门信息
|
||||||
|
dept.setUpdateTime(DateUtils.getNowDate());
|
||||||
int result = deptMapper.updateDept(dept);
|
int result = deptMapper.updateDept(dept);
|
||||||
|
|
||||||
|
|
||||||
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
|
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
|
||||||
&& !StringUtils.equals("0", dept.getAncestors()))
|
&& !StringUtils.equals("0", dept.getAncestors()))
|
||||||
{
|
{
|
||||||
@ -283,7 +373,6 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改该部门的父级部门状态
|
* 修改该部门的父级部门状态
|
||||||
*
|
|
||||||
* @param dept 当前部门
|
* @param dept 当前部门
|
||||||
*/
|
*/
|
||||||
private void updateParentDeptStatusNormal(SysDept dept)
|
private void updateParentDeptStatusNormal(SysDept dept)
|
||||||
|
@ -102,9 +102,9 @@ public class SysDistrictServiceImpl implements ISysDistrictService
|
|||||||
* @param mapOutlineUrl 地图轮廓json文件访问uel
|
* @param mapOutlineUrl 地图轮廓json文件访问uel
|
||||||
*/
|
*/
|
||||||
private void verifySaveJsonData(SysDistrict sysDistrict, String mapOutlineUrl) {
|
private void verifySaveJsonData(SysDistrict sysDistrict, String mapOutlineUrl) {
|
||||||
//行政区划轮廓json文件url必须是绝对完整
|
//行政区划轮廓json文件url是绝对url代表新上传过
|
||||||
if(!(mapOutlineUrl.contains("http://") || mapOutlineUrl.contains("https://"))){
|
if(!(mapOutlineUrl.contains("http://") || mapOutlineUrl.contains("https://"))){
|
||||||
throw new ServiceException("行政区划轮廓json文件url不正确!");
|
return ;
|
||||||
}
|
}
|
||||||
//上传行政区划轮廓进行数据处理
|
//上传行政区划轮廓进行数据处理
|
||||||
String jsonData = HttpUtil.get(mapOutlineUrl);
|
String jsonData = HttpUtil.get(mapOutlineUrl);
|
||||||
@ -135,7 +135,7 @@ public class SysDistrictServiceImpl implements ISysDistrictService
|
|||||||
if(StringUtils.isBlank(mapOutlineUrl)){
|
if(StringUtils.isBlank(mapOutlineUrl)){
|
||||||
return sysDistrictMapper.updateSysDistrict(sysDistrict);
|
return sysDistrictMapper.updateSysDistrict(sysDistrict);
|
||||||
}
|
}
|
||||||
//判断行政区划轮廓json文件路url是否是完整url还是相对url
|
//判断行政区划轮廓json文件路url是否是完整url还是相对url,如果是相对url则代表并未修改,绝对url代表修改过
|
||||||
verifySaveJsonData(sysDistrict, mapOutlineUrl);
|
verifySaveJsonData(sysDistrict, mapOutlineUrl);
|
||||||
|
|
||||||
return sysDistrictMapper.updateSysDistrict(sysDistrict);
|
return sysDistrictMapper.updateSysDistrict(sysDistrict);
|
||||||
|
@ -61,7 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
|
<select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
|
||||||
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.dept_type, d.dept_user_id,
|
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.dept_type, d.dept_user_id,d.administrative_area_code,
|
||||||
(select dept_name from sys_dept where dept_id = d.parent_id) parent_name
|
(select dept_name from sys_dept where dept_id = d.parent_id) parent_name
|
||||||
from sys_dept d
|
from sys_dept d
|
||||||
where d.dept_id = #{deptId}
|
where d.dept_id = #{deptId}
|
||||||
@ -121,53 +121,136 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- <insert id="insertDept" parameterType="SysDept" useGeneratedKeys="true" keyProperty="deptId">-->
|
||||||
|
<!-- insert into sys_dept(-->
|
||||||
|
<!-- <if test="deptId != null and deptId != 0">dept_id,</if>-->
|
||||||
|
<!-- <if test="deptUserId != null and deptUserId != 0">dept_user_id,</if>-->
|
||||||
|
<!-- <if test="parentId != null and parentId != 0">parent_id,</if>-->
|
||||||
|
<!-- <if test="deptName != null and deptName != ''">dept_name,</if>-->
|
||||||
|
<!-- <if test="ancestors != null and ancestors != ''">ancestors,</if>-->
|
||||||
|
<!-- <if test="orderNum != null">order_num,</if>-->
|
||||||
|
<!-- <if test="leader != null and leader != ''">leader,</if>-->
|
||||||
|
<!-- <if test="phone != null and phone != ''">phone,</if>-->
|
||||||
|
<!-- <if test="email != null and email != ''">email,</if>-->
|
||||||
|
<!-- <if test="status != null">status,</if>-->
|
||||||
|
<!-- <if test="createBy != null and createBy != ''">create_by,</if>-->
|
||||||
|
<!-- <if test="deptType != null and deptType != ''">dept_type,</if>-->
|
||||||
|
<!-- create_time-->
|
||||||
|
<!-- )values(-->
|
||||||
|
<!-- <if test="deptId != null and deptId != 0">#{deptId},</if>-->
|
||||||
|
<!-- <if test="deptUserId != null and deptUserId != 0">#{deptUserId},</if>-->
|
||||||
|
<!-- <if test="parentId != null and parentId != 0">#{parentId},</if>-->
|
||||||
|
<!-- <if test="deptName != null and deptName != ''">#{deptName},</if>-->
|
||||||
|
<!-- <if test="ancestors != null and ancestors != ''">#{ancestors},</if>-->
|
||||||
|
<!-- <if test="orderNum != null">#{orderNum},</if>-->
|
||||||
|
<!-- <if test="leader != null and leader != ''">#{leader},</if>-->
|
||||||
|
<!-- <if test="phone != null and phone != ''">#{phone},</if>-->
|
||||||
|
<!-- <if test="email != null and email != ''">#{email},</if>-->
|
||||||
|
<!-- <if test="status != null">#{status},</if>-->
|
||||||
|
<!-- <if test="createBy != null and createBy != ''">#{createBy},</if>-->
|
||||||
|
<!-- <if test="deptType != null and deptType != ''">#{deptType},</if>-->
|
||||||
|
<!-- sysdate()-->
|
||||||
|
<!-- )-->
|
||||||
|
<!-- </insert>-->
|
||||||
<insert id="insertDept" parameterType="SysDept" useGeneratedKeys="true" keyProperty="deptId">
|
<insert id="insertDept" parameterType="SysDept" useGeneratedKeys="true" keyProperty="deptId">
|
||||||
insert into sys_dept(
|
insert into sys_dept
|
||||||
<if test="deptId != null and deptId != 0">dept_id,</if>
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="deptUserId != null and deptUserId != 0">dept_user_id,</if>
|
<if test="deptUserId != null">dept_user_id,</if>
|
||||||
<if test="parentId != null and parentId != 0">parent_id,</if>
|
<if test="parentId != null">parent_id,</if>
|
||||||
<if test="deptName != null and deptName != ''">dept_name,</if>
|
|
||||||
<if test="ancestors != null and ancestors != ''">ancestors,</if>
|
<if test="ancestors != null and ancestors != ''">ancestors,</if>
|
||||||
|
<if test="deptName != null">dept_name,</if>
|
||||||
<if test="orderNum != null">order_num,</if>
|
<if test="orderNum != null">order_num,</if>
|
||||||
<if test="leader != null and leader != ''">leader,</if>
|
<if test="leader != null and leader != ''">leader,</if>
|
||||||
<if test="phone != null and phone != ''">phone,</if>
|
<if test="phone != null">phone,</if>
|
||||||
<if test="email != null and email != ''">email,</if>
|
|
||||||
<if test="status != null">status,</if>
|
<if test="status != null">status,</if>
|
||||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
<if test="delFlag != null">del_flag,</if>
|
||||||
<if test="deptType != null and deptType != ''">dept_type,</if>
|
<if test="createBy != null">create_by,</if>
|
||||||
create_time
|
<if test="createTime != null">create_time,</if>
|
||||||
)values(
|
<if test="updateBy != null">update_by,</if>
|
||||||
<if test="deptId != null and deptId != 0">#{deptId},</if>
|
<if test="updateTime != null">update_time,</if>
|
||||||
<if test="deptUserId != null and deptUserId != 0">#{deptUserId},</if>
|
<if test="email != null">email,</if>
|
||||||
<if test="parentId != null and parentId != 0">#{parentId},</if>
|
<if test="deptType != null">dept_type,</if>
|
||||||
<if test="deptName != null and deptName != ''">#{deptName},</if>
|
<if test="administrativeArea != null">administrative_area,</if>
|
||||||
|
<if test="administrativeAreaCode != null">administrative_area_code,</if>
|
||||||
|
<if test="provinceCode != null">province_code,</if>
|
||||||
|
<if test="cityCode != null">city_code,</if>
|
||||||
|
<if test="countyCode != null">county_code,</if>
|
||||||
|
<if test="townCode != null">town_code,</if>
|
||||||
|
<if test="villageCode != null">village_code,</if>
|
||||||
|
<if test="projectId != null">project_id,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="deptUserId != null">#{deptUserId},</if>
|
||||||
|
<if test="parentId != null">#{parentId},</if>
|
||||||
<if test="ancestors != null and ancestors != ''">#{ancestors},</if>
|
<if test="ancestors != null and ancestors != ''">#{ancestors},</if>
|
||||||
|
<if test="deptName != null">#{deptName},</if>
|
||||||
<if test="orderNum != null">#{orderNum},</if>
|
<if test="orderNum != null">#{orderNum},</if>
|
||||||
<if test="leader != null and leader != ''">#{leader},</if>
|
<if test="leader != null and leader != ''">#{leader},</if>
|
||||||
<if test="phone != null and phone != ''">#{phone},</if>
|
<if test="phone != null">#{phone},</if>
|
||||||
<if test="email != null and email != ''">#{email},</if>
|
|
||||||
<if test="status != null">#{status},</if>
|
<if test="status != null">#{status},</if>
|
||||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
<if test="delFlag != null">#{delFlag},</if>
|
||||||
<if test="deptType != null and deptType != ''">#{deptType},</if>
|
<if test="createBy != null">#{createBy},</if>
|
||||||
sysdate()
|
<if test="createTime != null">#{createTime},</if>
|
||||||
)
|
<if test="updateBy != null">#{updateBy},</if>
|
||||||
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
|
<if test="email != null">#{email},</if>
|
||||||
|
<if test="deptType != null">#{deptType},</if>
|
||||||
|
<if test="administrativeArea != null">#{administrativeArea},</if>
|
||||||
|
<if test="administrativeAreaCode != null">#{administrativeAreaCode},</if>
|
||||||
|
<if test="provinceCode != null">#{provinceCode},</if>
|
||||||
|
<if test="cityCode != null">#{cityCode},</if>
|
||||||
|
<if test="countyCode != null">#{countyCode},</if>
|
||||||
|
<if test="townCode != null">#{townCode},</if>
|
||||||
|
<if test="villageCode != null">#{villageCode},</if>
|
||||||
|
<if test="projectId != null">#{projectId},</if>
|
||||||
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<!-- <update id="updateDept" parameterType="SysDept">-->
|
||||||
|
<!-- update sys_dept-->
|
||||||
|
<!-- <set>-->
|
||||||
|
<!-- <if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>-->
|
||||||
|
<!-- <if test="deptUserId != null and deptUserId != 0">dept_user_id = #{deptUserId},</if>-->
|
||||||
|
<!-- <if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>-->
|
||||||
|
<!-- <if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>-->
|
||||||
|
<!-- <if test="orderNum != null">order_num = #{orderNum},</if>-->
|
||||||
|
<!-- <if test="leader != null">leader = #{leader},</if>-->
|
||||||
|
<!-- <if test="phone != null">phone = #{phone},</if>-->
|
||||||
|
<!-- <if test="email != null">email = #{email},</if>-->
|
||||||
|
<!-- <if test="status != null and status != ''">status = #{status},</if>-->
|
||||||
|
<!-- <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>-->
|
||||||
|
<!-- update_time = sysdate()-->
|
||||||
|
<!-- </set>-->
|
||||||
|
<!-- where dept_id = #{deptId}-->
|
||||||
|
<!-- </update>-->
|
||||||
|
|
||||||
<update id="updateDept" parameterType="SysDept">
|
<update id="updateDept" parameterType="SysDept">
|
||||||
update sys_dept
|
update sys_dept
|
||||||
<set>
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
<if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
|
<if test="deptUserId != null">dept_user_id = #{deptUserId},</if>
|
||||||
<if test="deptUserId != null and deptUserId != 0">dept_user_id = #{deptUserId},</if>
|
<if test="parentId != null">parent_id = #{parentId},</if>
|
||||||
<if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
|
|
||||||
<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
|
<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
|
||||||
|
<if test="deptName != null">dept_name = #{deptName},</if>
|
||||||
<if test="orderNum != null">order_num = #{orderNum},</if>
|
<if test="orderNum != null">order_num = #{orderNum},</if>
|
||||||
<if test="leader != null">leader = #{leader},</if>
|
<if test="leader != null and leader != ''">leader = #{leader},</if>
|
||||||
<if test="phone != null">phone = #{phone},</if>
|
<if test="phone != null">phone = #{phone},</if>
|
||||||
|
<if test="status != null">status = #{status},</if>
|
||||||
|
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||||
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
<if test="email != null">email = #{email},</if>
|
<if test="email != null">email = #{email},</if>
|
||||||
<if test="status != null and status != ''">status = #{status},</if>
|
<if test="deptType != null">dept_type = #{deptType},</if>
|
||||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
<if test="administrativeArea != null">administrative_area = #{administrativeArea},</if>
|
||||||
update_time = sysdate()
|
<if test="administrativeAreaCode != null">administrative_area_code = #{administrativeAreaCode},</if>
|
||||||
</set>
|
<if test="provinceCode != null">province_code = #{provinceCode},</if>
|
||||||
|
<if test="cityCode != null">city_code = #{cityCode},</if>
|
||||||
|
<if test="countyCode != null">county_code = #{countyCode},</if>
|
||||||
|
<if test="townCode != null">town_code = #{townCode},</if>
|
||||||
|
<if test="villageCode != null">village_code = #{villageCode},</if>
|
||||||
|
<if test="projectId != null">project_id = #{projectId},</if>
|
||||||
|
</trim>
|
||||||
where dept_id = #{deptId}
|
where dept_id = #{deptId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user