|
|
@ -20,12 +20,15 @@ package com.elink.esua.epdc.service.impl; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|
|
|
import com.elink.esua.epdc.dao.PartyOrgDao; |
|
|
|
import com.elink.esua.epdc.dto.DeptLevelAndLeaderDTO; |
|
|
|
import com.elink.esua.epdc.dto.PartyOrgDTO; |
|
|
|
import com.elink.esua.epdc.entity.PartyOrgEntity; |
|
|
|
import com.elink.esua.epdc.optimize.modules.deptlevel.service.OptSysDeptService; |
|
|
|
import com.elink.esua.epdc.redis.PartyOrgRedis; |
|
|
|
import com.elink.esua.epdc.service.PartyOrgService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
@ -48,6 +51,8 @@ public class PartyOrgServiceImpl extends BaseServiceImpl<PartyOrgDao, PartyOrgEn |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private PartyOrgRedis partyOrgRedis; |
|
|
|
@Autowired |
|
|
|
private OptSysDeptService optSysDeptService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<PartyOrgDTO> page(Map<String, Object> params) { |
|
|
@ -77,13 +82,22 @@ public class PartyOrgServiceImpl extends BaseServiceImpl<PartyOrgDao, PartyOrgEn |
|
|
|
@Override |
|
|
|
public PartyOrgDTO get(String id) { |
|
|
|
PartyOrgEntity entity = baseDao.selectById(id); |
|
|
|
return ConvertUtils.sourceToTarget(entity, PartyOrgDTO.class); |
|
|
|
PartyOrgDTO dto = ConvertUtils.sourceToTarget(entity, PartyOrgDTO.class); |
|
|
|
if (null != dto && null != dto.getAllDeptIds()) { |
|
|
|
String[] split = dto.getAllDeptIds().split(","); |
|
|
|
// 去除,顶级组织
|
|
|
|
String[] allDeptIdArr = new String[split.length - NumConstant.ONE]; |
|
|
|
System.arraycopy(split, NumConstant.ONE, allDeptIdArr, NumConstant.ZERO,split.length - NumConstant.ONE); |
|
|
|
dto.setAllDeptIdArr(allDeptIdArr); |
|
|
|
} |
|
|
|
return dto; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void save(PartyOrgDTO dto) { |
|
|
|
PartyOrgEntity entity = ConvertUtils.sourceToTarget(dto, PartyOrgEntity.class); |
|
|
|
this.packageOrgLevel(entity, Long.valueOf(dto.getDeptId())); |
|
|
|
insert(entity); |
|
|
|
} |
|
|
|
|
|
|
@ -91,9 +105,27 @@ public class PartyOrgServiceImpl extends BaseServiceImpl<PartyOrgDao, PartyOrgEn |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(PartyOrgDTO dto) { |
|
|
|
PartyOrgEntity entity = ConvertUtils.sourceToTarget(dto, PartyOrgEntity.class); |
|
|
|
this.packageOrgLevel(entity, Long.valueOf(dto.getDeptId())); |
|
|
|
updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 组装部门层级 |
|
|
|
* |
|
|
|
* @param entity |
|
|
|
* @param deptId |
|
|
|
* @return void |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 16:25 2021-08-06 |
|
|
|
**/ |
|
|
|
private void packageOrgLevel(PartyOrgEntity entity, Long deptId) { |
|
|
|
DeptLevelAndLeaderDTO deptLevel = optSysDeptService.getDeptLevelById(deptId); |
|
|
|
entity.setAllDeptIds(deptLevel.getAllDeptIds()); |
|
|
|
entity.setAllDeptNames(deptLevel.getAllDeptNames()); |
|
|
|
entity.setParentDeptIds(deptLevel.getParentDeptIds()); |
|
|
|
entity.setParentDeptNames(deptLevel.getParentDeptNames()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void delete(String[] ids) { |
|
|
|