Browse Source

FORMAT

feature/yujt_vim
zhangyuan 5 years ago
parent
commit
8413a7dd84
  1. 30
      epdc-cloud-admin/src/main/java/com/elink/esua/epdc/service/impl/SysDeptServiceImpl.java

30
epdc-cloud-admin/src/main/java/com/elink/esua/epdc/service/impl/SysDeptServiceImpl.java

@ -128,14 +128,12 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptDao, SysDeptEntit
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void save(SysDeptDTO dto) { public void save(SysDeptDTO dto) {
String partyCode = dto.getPartyCode(); String partyCode = dto.getPartyCode();
if (StringUtils.isNotBlank(partyCode)) { if (StringUtils.isNotBlank(partyCode) && getCodeCount(dto) > 0) {
if (getCodeCount(dto) > 0) { throw new RenException("您输入的编码已存在");
throw new RenException("您输入的编码已存在");
}
} }
SysDeptEntity entity = ConvertUtils.sourceToTarget(dto, SysDeptEntity.class); SysDeptEntity entity = ConvertUtils.sourceToTarget(dto, SysDeptEntity.class);
if (!entity.getAllAreaCode().isEmpty()) { if (!entity.getAllAreaCode().isEmpty()) {
String[] areaCodeArray = entity.getAllAreaCode().split(","); String[] areaCodeArray = entity.getAllAreaCode().split(StrConstant.COMMA);
entity.setParentAreaCode(areaCodeArray[areaCodeArray.length - 2]); entity.setParentAreaCode(areaCodeArray[areaCodeArray.length - 2]);
} }
entity.setPids(getPidList(entity.getPid())); entity.setPids(getPidList(entity.getPid()));
@ -153,10 +151,8 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptDao, SysDeptEntit
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void update(SysDeptDTO dto) { public void update(SysDeptDTO dto) {
String partyCode = dto.getPartyCode(); String partyCode = dto.getPartyCode();
if (StringUtils.isNotBlank(partyCode)) { if (StringUtils.isNotBlank(partyCode) && getCodeCount(dto) > 0) {
if (getCodeCount(dto) > 0) { throw new RenException("您输入的编码已存在");
throw new RenException("您输入的编码已存在");
}
} }
SysDeptEntity entity = ConvertUtils.sourceToTarget(dto, SysDeptEntity.class); SysDeptEntity entity = ConvertUtils.sourceToTarget(dto, SysDeptEntity.class);
@ -165,7 +161,7 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptDao, SysDeptEntit
throw new RenException(ErrorCode.SUPERIOR_DEPT_ERROR); throw new RenException(ErrorCode.SUPERIOR_DEPT_ERROR);
} }
if (!entity.getAllAreaCode().isEmpty()) { if (!entity.getAllAreaCode().isEmpty()) {
String[] areaCodeArray = entity.getAllAreaCode().split(","); String[] areaCodeArray = entity.getAllAreaCode().split(StrConstant.COMMA);
entity.setParentAreaCode(areaCodeArray[areaCodeArray.length - 2]); entity.setParentAreaCode(areaCodeArray[areaCodeArray.length - 2]);
} }
entity.setPids(getPidList(entity.getPid())); entity.setPids(getPidList(entity.getPid()));
@ -521,13 +517,13 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptDao, SysDeptEntit
// 用于存储 一个父节点的所有下级节点 // 用于存储 一个父节点的所有下级节点
childrenNodeList = new JSONArray(); childrenNodeList = new JSONArray();
for (int j = 0; j < childDepts.size(); j++) { for (SysDeptEntity childDept : childDepts) {
deptId = childDepts.get(j).getId(); deptId = childDept.getId();
if (nodeParent.get("value").equals(String.valueOf(childDepts.get(j).getPid()))) { if (nodeParent.get("value").equals(String.valueOf(childDept.getPid()))) {
nodeChild = new JSONObject(); nodeChild = new JSONObject();
nodeChild.put("label", childDepts.get(j).getName()); nodeChild.put("label", childDept.getName());
nodeChild.put("typeKey", childDepts.get(j).getTypeKey()); nodeChild.put("typeKey", childDept.getTypeKey());
nodeChild.put("value", String.valueOf(deptId)); nodeChild.put("value", String.valueOf(deptId));
childrenNodeList.add(nodeChild); childrenNodeList.add(nodeChild);
@ -541,8 +537,8 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptDao, SysDeptEntit
} }
List<Long> newDataScopeList = Lists.newArrayList(); List<Long> newDataScopeList = Lists.newArrayList();
for (int i = 0; i < dataScopeDeptList.size(); i++) { for (Long aLong : dataScopeDeptList) {
deptId = dataScopeDeptList.get(i); deptId = aLong;
if (!parentDeptIdList.contains(deptId)) { if (!parentDeptIdList.contains(deptId)) {
newDataScopeList.add(deptId); newDataScopeList.add(deptId);
} }

Loading…
Cancel
Save