企业修改
This commit is contained in:
parent
4da9fa295b
commit
bca18576bf
@ -1,17 +1,18 @@
|
||||
package com.zhgd.xmgl.modules.project.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.modules.project.entity.ProjectEnterprise;
|
||||
import com.zhgd.xmgl.modules.worker.entity.EnterpriseInfo;
|
||||
import com.zhgd.xmgl.modules.xz.entity.XzProjectOrg;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.modules.worker.entity.EnterpriseInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.zhgd.xmgl.modules.project.entity.ProjectEnterprise;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @Description: 项目劳务公司关联
|
||||
* @author: pds
|
||||
@ -36,4 +37,5 @@ public interface ProjectEnterpriseMapper extends BaseMapper<ProjectEnterprise> {
|
||||
|
||||
void updateAncestors(@Param("oldAncestor") String oldAncestor, @Param("newAncestor") String newAncestor, @Param("projectSn") String projectSn, @Param("id") Long id);
|
||||
|
||||
List<XzProjectOrg> getChildren(Long id);
|
||||
}
|
||||
|
||||
@ -223,4 +223,9 @@
|
||||
SET ancestors=REPLACE(ancestors, #{oldAncestor}, #{newAncestor})
|
||||
WHERE ancestors LIKE N'${oldAncestor},${id}%' and project_sn = #{projectSn}
|
||||
</update>
|
||||
|
||||
<select id="getChildren" resultType="com.zhgd.xmgl.modules.xz.entity.XzProjectOrg">
|
||||
select * from project_enterprise
|
||||
where find_in_set(#{id}, ancestors)
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@ -16,6 +16,7 @@ import com.zhgd.xmgl.modules.worker.entity.EnterpriseInfo;
|
||||
import com.zhgd.xmgl.modules.worker.entity.UserEnterprise;
|
||||
import com.zhgd.xmgl.modules.worker.mapper.EnterpriseInfoMapper;
|
||||
import com.zhgd.xmgl.modules.worker.mapper.UserEnterpriseMapper;
|
||||
import com.zhgd.xmgl.modules.xz.entity.XzProjectOrg;
|
||||
import com.zhgd.xmgl.security.entity.UserInfo;
|
||||
import com.zhgd.xmgl.security.util.SecurityUtils;
|
||||
import com.zhgd.xmgl.util.MessageUtil;
|
||||
@ -96,30 +97,39 @@ public class ProjectEnterpriseServiceImpl extends ServiceImpl<ProjectEnterpriseM
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editProjectEnterprise(ProjectEnterprise projectEnterprise) {
|
||||
ProjectEnterprise oldPo = projectEnterpriseMapper.selectById(projectEnterprise.getId());
|
||||
if (oldPo == null) {
|
||||
public void editProjectEnterprise(ProjectEnterprise pe) {
|
||||
ProjectEnterprise old = projectEnterpriseMapper.selectById(pe.getId());
|
||||
if (old == null) {
|
||||
throw new OpenAlertException(MessageUtil.get("notFindErr"));
|
||||
}
|
||||
|
||||
if (!Objects.equals(oldPo.getParentProjectEnterpriseId(), projectEnterprise.getParentProjectEnterpriseId())) {
|
||||
ProjectEnterprise pOrg = projectEnterpriseMapper.selectById(projectEnterprise.getParentProjectEnterpriseId());
|
||||
if (!Objects.equals(old.getParentProjectEnterpriseId(), pe.getParentProjectEnterpriseId())) {
|
||||
if (Objects.equals(pe.getId(), pe.getParentProjectEnterpriseId())) {
|
||||
throw new OpenAlertException("不能将其移动到其自身");
|
||||
}
|
||||
List<XzProjectOrg> children = baseMapper.getChildren(pe.getId());
|
||||
for (XzProjectOrg child : children) {
|
||||
if (child.getId().equals(pe.getParentProjectEnterpriseId())) {
|
||||
throw new OpenAlertException("不能将其移动到其自身下级");
|
||||
}
|
||||
}
|
||||
ProjectEnterprise pOrg = projectEnterpriseMapper.selectById(pe.getParentProjectEnterpriseId());
|
||||
// 修改子部门
|
||||
boolean top = projectEnterprise.getParentProjectEnterpriseId() == null || projectEnterprise.getParentProjectEnterpriseId() == 0;
|
||||
boolean top = pe.getParentProjectEnterpriseId() == null || pe.getParentProjectEnterpriseId() == 0;
|
||||
if (top) {
|
||||
projectEnterprise.setParentProjectEnterpriseId(0L);
|
||||
projectEnterprise.setAncestors("0");
|
||||
pe.setParentProjectEnterpriseId(0L);
|
||||
pe.setAncestors("0");
|
||||
} else {
|
||||
if (pOrg == null) {
|
||||
throw new OpenAlertException("上级部门不存在");
|
||||
}
|
||||
projectEnterprise.setAncestors(pOrg.getAncestors() + "," + pOrg.getId());
|
||||
pe.setAncestors(pOrg.getAncestors() + "," + pOrg.getId());
|
||||
}
|
||||
baseMapper.updateAncestors(oldPo.getAncestors(), projectEnterprise.getAncestors(), projectEnterprise.getProjectSn(), projectEnterprise.getId());
|
||||
baseMapper.updateById(projectEnterprise);
|
||||
baseMapper.updateAncestors(old.getAncestors(), pe.getAncestors(), pe.getProjectSn(), pe.getId());
|
||||
baseMapper.updateById(pe);
|
||||
} else {
|
||||
projectEnterprise.setAncestors(null);
|
||||
baseMapper.updateById(projectEnterprise);
|
||||
pe.setAncestors(null);
|
||||
baseMapper.updateById(pe);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user