Commit dd42110a authored by 赵啸非's avatar 赵啸非

添加删除本地多余的部门部门

parent 91a4f1bb
...@@ -29,6 +29,7 @@ import org.springframework.util.ObjectUtils; ...@@ -29,6 +29,7 @@ import org.springframework.util.ObjectUtils;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
* DeptService * DeptService
...@@ -172,17 +173,19 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity ...@@ -172,17 +173,19 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity
StaffQuery query = new StaffQuery(); StaffQuery query = new StaffQuery();
query.setStatusNotList(Arrays.asList(StaffSatusEnum.离职.getValue())); query.setStatusNotList(Arrays.asList(StaffSatusEnum.离职.getValue()));
query.setDeptIdList(getChildrenId(m, list)); query.setDeptIdList(getChildrenId(m, list));
int count = staffService.count(query,null); int count = staffService.count(query, null);
m.setPersonNum(count); m.setPersonNum(count);
return m; return m;
} }
).collect(Collectors.toList()); ).collect(Collectors.toList());
return returnList.stream().map(DeptTreeSelect::new).collect(Collectors.toList()); return returnList.stream().map(DeptTreeSelect::new).collect(Collectors.toList());
} }
/** /**
* 递归查询子节点 * 递归查询子节点
* @param root 根节点 *
* @param all 所有节点 * @param root 根节点
* @param all 所有节点
* @return 根节点信息 * @return 根节点信息
*/ */
private List<DeptEntity> getChildren(DeptEntity root, List<DeptEntity> all) { private List<DeptEntity> getChildren(DeptEntity root, List<DeptEntity> all) {
...@@ -194,7 +197,7 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity ...@@ -194,7 +197,7 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity
StaffQuery query = new StaffQuery(); StaffQuery query = new StaffQuery();
query.setDeptIdList(getChildrenId(m, all)); query.setDeptIdList(getChildrenId(m, all));
query.setStatusNotList(Arrays.asList(StaffSatusEnum.离职.getValue())); query.setStatusNotList(Arrays.asList(StaffSatusEnum.离职.getValue()));
int count = staffService.count(query,null); int count = staffService.count(query, null);
m.setPersonNum(count); m.setPersonNum(count);
return m; return m;
} }
...@@ -202,12 +205,12 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity ...@@ -202,12 +205,12 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity
return children; return children;
} }
private List<Long> getChildrenId(DeptEntity root, List<DeptEntity> all){ private List<Long> getChildrenId(DeptEntity root, List<DeptEntity> all) {
List<Long> idList = new ArrayList<>(); List<Long> idList = new ArrayList<>();
idList.add(root.getId()); idList.add(root.getId());
all.forEach(item ->{ all.forEach(item -> {
if(Objects.equals(item.getParentId(), root.getId())){ if (Objects.equals(item.getParentId(), root.getId())) {
idList.addAll(getChildrenId(item,all)); idList.addAll(getChildrenId(item, all));
} }
}); });
return idList; return idList;
...@@ -266,8 +269,8 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity ...@@ -266,8 +269,8 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity
parentDept.setPersonNum(sum); parentDept.setPersonNum(sum);
this.update(parentDept); this.update(parentDept);
} }
}else { } else {
log.info("deptEntity is null.deptId:{}",item.getKey()); log.info("deptEntity is null.deptId:{}", item.getKey());
} }
} }
...@@ -287,14 +290,14 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity ...@@ -287,14 +290,14 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity
@Override @Override
public List<DeptEntity> getDeptBySalaId(Long salaId) throws AppException { public List<DeptEntity> getDeptBySalaId(Long salaId) throws AppException {
DeptQuery query = new DeptQuery(); DeptQuery query = new DeptQuery();
if(salaId == null || salaId == -1l){ if (salaId == null || salaId == -1l) {
List<DeptEntity> allSala = dao.getList(new DeptQuery().parentId(71l)); List<DeptEntity> allSala = dao.getList(new DeptQuery().parentId(71l));
List<Long> salaList = new ArrayList<>(); List<Long> salaList = new ArrayList<>();
for(DeptEntity item:allSala){ for (DeptEntity item : allSala) {
salaList.add(item.getId()); salaList.add(item.getId());
} }
query.setParentIdList(salaList); query.setParentIdList(salaList);
}else { } else {
query.setParentId(salaId); query.setParentId(salaId);
} }
return dao.getList(query); return dao.getList(query);
...@@ -338,6 +341,27 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity ...@@ -338,6 +341,27 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity
this.update(deptEntity); this.update(deptEntity);
} }
} }
//差额删除部门
List<DeptEntity> localDeptList = this.find(new DeptQuery());
// Map<String, DeptEntity> localDeptMap = localDeptList.stream().collect(Collectors.toMap(x -> x.getDeptCode(), y -> y, (o, n) -> n));
//差额对
Map<String, OrgInfo> remoteDeptMap = orgInfoList.stream().collect(Collectors.toMap(x -> x.getOrgIndexCode(), y -> y, (o, n) -> n));
List<DeptEntity> deleteLocalDeptList = localDeptList.stream().map(item -> {
String deptCode = item.getDeptCode();
OrgInfo orgInfo = remoteDeptMap.get(deptCode);
if (ObjectUtils.isEmpty(orgInfo)) {
//需要删除的本地部门
return item;
} else {
return null;
}
}).filter(f -> f != null).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(deleteLocalDeptList)) {
log.info("delete dept lsit size :{}", deleteLocalDeptList.size());
}
} }
return Rest.ok(); return Rest.ok();
......
...@@ -49,8 +49,8 @@ POST {{baseUrl}}/attendance/record/hik/addAttendanceRecord ...@@ -49,8 +49,8 @@ POST {{baseUrl}}/attendance/record/hik/addAttendanceRecord
Content-Type: application/json Content-Type: application/json
{ {
"attendanceDateStart": "2024-10-19", "attendanceDateStart": "2025-01-01",
"attendanceDateEnd": "2024-10-31" "attendanceDateEnd": "2025-01-02"
} }
###海康考勤打卡记录计算1 ###海康考勤打卡记录计算1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment