|
|
@ -43,6 +43,8 @@ import com.google.common.collect.Lists; |
|
|
|
import com.google.common.collect.Maps; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
@ -73,6 +75,7 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptDao, SysDeptEntit |
|
|
|
@Autowired |
|
|
|
private RedisUtils redisUtils; |
|
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(SysDeptServiceImpl.class); |
|
|
|
@Override |
|
|
|
public List<SysDeptDTO> list(Map<String, Object> params) { |
|
|
|
//普通管理员,只能查询所属部门及子部门的数据
|
|
|
@ -636,6 +639,98 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptDao, SysDeptEntit |
|
|
|
return new Result<DeptOption>().ok((DeptOption) obj); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param |
|
|
|
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.DeptOption> |
|
|
|
* @Author yinzuomei |
|
|
|
* @Description 获取所有部门树:二级只要街道 |
|
|
|
* @Date 2020/1/31 10:31 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public Result<DeptOption> getDeptTreeForEpiDemic() { |
|
|
|
String deptKey = RedisKeys.getAllDeptOptionKeyForEpiDemic(); |
|
|
|
Object obj = redisUtils.get(deptKey); |
|
|
|
if (null == obj) { |
|
|
|
this.packgeAllDeptOptionForEpiDemic(); |
|
|
|
obj = redisUtils.get(deptKey); |
|
|
|
} |
|
|
|
return new Result<DeptOption>().ok((DeptOption) obj); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param |
|
|
|
* @return void |
|
|
|
* @Author yinzuomei |
|
|
|
* @Description |
|
|
|
* @Date 2020/1/31 11:39 |
|
|
|
**/ |
|
|
|
private void packgeAllDeptOptionForEpiDemic() { |
|
|
|
List<DeptTreeDTO> deptList = baseDao.selectListDeptTree(); |
|
|
|
JSONObject node; |
|
|
|
JSONArray headNodes = new JSONArray(); |
|
|
|
for (DeptTreeDTO deptItemDto : deptList) { |
|
|
|
if (deptItemDto.getPid().longValue() == NumConstant.ZERO_L) { |
|
|
|
node = new JSONObject(); |
|
|
|
node.put("value", deptItemDto.getId()); |
|
|
|
node.put("label", deptItemDto.getName()); |
|
|
|
headNodes.add(node); |
|
|
|
} |
|
|
|
} |
|
|
|
// 用于存放所有父级节点
|
|
|
|
JSONArray parent; |
|
|
|
parent = headNodes; |
|
|
|
// 用于存放所有子级节点
|
|
|
|
JSONArray allChildren = new JSONArray(); |
|
|
|
JSONArray children; |
|
|
|
// 用于存放单个子级节点
|
|
|
|
JSONObject childNode; |
|
|
|
// 存放其余未处理的类别(节点)
|
|
|
|
List<DeptTreeDTO> others = this.getOtherDept(deptList, parent); |
|
|
|
|
|
|
|
while (!others.isEmpty()) { |
|
|
|
for (int i = 0; i < parent.size(); i++) { |
|
|
|
node = parent.getJSONObject(i); |
|
|
|
children = new JSONArray(); |
|
|
|
for (DeptTreeDTO categoryTreeDto : others) { |
|
|
|
if (categoryTreeDto.getPid().equals(node.get("value"))) { |
|
|
|
SysDeptEntity parentDeptInfo = baseDao.getById(categoryTreeDto.getPid()); |
|
|
|
//二级只要街道党工委
|
|
|
|
if (parentDeptInfo.getPid().longValue() == NumConstant.ZERO_L) { |
|
|
|
logger.info("二级目录:" + categoryTreeDto.getName()); |
|
|
|
SysDeptEntity currentDeptInfo = baseDao.getById(categoryTreeDto.getId()); |
|
|
|
if (OrganizationTypeConstant.ORG_TYPE_STREET_PARTY.equals(currentDeptInfo.getTypeKey())) { |
|
|
|
childNode = new JSONObject(); |
|
|
|
childNode.put("value", categoryTreeDto.getId()); |
|
|
|
childNode.put("label", categoryTreeDto.getName()); |
|
|
|
children.add(childNode); |
|
|
|
allChildren.add(childNode); |
|
|
|
} |
|
|
|
} else { |
|
|
|
childNode = new JSONObject(); |
|
|
|
childNode.put("value", categoryTreeDto.getId()); |
|
|
|
childNode.put("label", categoryTreeDto.getName()); |
|
|
|
children.add(childNode); |
|
|
|
allChildren.add(childNode); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (!children.isEmpty()) { |
|
|
|
node.put("children", children); |
|
|
|
} |
|
|
|
} |
|
|
|
parent = allChildren; |
|
|
|
|
|
|
|
others = this.getOtherDept(others, parent); |
|
|
|
|
|
|
|
} |
|
|
|
//存放到redis中
|
|
|
|
List<JSONArray> cache = Lists.newArrayList(); |
|
|
|
cache.add(headNodes); |
|
|
|
DeptOption option = new DeptOption(); |
|
|
|
option.setOptions(cache.get(0)); |
|
|
|
redisUtils.set(RedisKeys.getAllDeptOptionKeyForEpiDemic(), option); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param params |
|
|
|
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.CompleteDeptDTO> |
|
|
|