|
@@ -9,6 +9,7 @@ import com.usky.dxtop.common.utils.StringUtils;
|
|
|
import com.usky.dxtop.common.utils.http.HttpUtils;
|
|
|
import com.usky.dxtop.model.Dept;
|
|
|
import com.usky.dxtop.model.Staff;
|
|
|
+import com.usky.dxtop.model.SysDept;
|
|
|
import com.usky.dxtop.service.DeptService;
|
|
|
import com.usky.dxtop.service.StaffService;
|
|
|
import com.usky.dxtop.service.api.SmApi;
|
|
@@ -18,10 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.TreeMap;
|
|
|
+import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
|
|
|
/**
|
|
@@ -63,33 +61,17 @@ public class SmJob {
|
|
|
treeMap = SmApi.generatePersonParam(null,
|
|
|
null, null, null);
|
|
|
}
|
|
|
+ List<Dept> depts = deptService.list();
|
|
|
+ List<Staff> checkStaffList = new ArrayList<>();
|
|
|
common(SmApi.PERSON_URL,treeMap,staffList -> {
|
|
|
List<Staff> list = staffList.toJavaList(Staff.class);
|
|
|
list.forEach(date -> {
|
|
|
try {
|
|
|
- date.setCardId(new BigDecimal(date.getCardId()).toString());
|
|
|
- LambdaQueryWrapper<Staff> queryWrapper = Wrappers.lambdaQuery();
|
|
|
- queryWrapper.eq(Staff::getId,date.getId());
|
|
|
- Staff staff = staffService.getOne(queryWrapper);
|
|
|
- //获取部门信息
|
|
|
- Map deptMap = JSON.parseObject(date.getDept(), Map.class);
|
|
|
- LambdaQueryWrapper<Dept> deptLambdaQueryWrapper = Wrappers.lambdaQuery();
|
|
|
- deptLambdaQueryWrapper.eq(Dept::getId,deptMap.get("id").toString());
|
|
|
- Dept dept = deptService.getOne(deptLambdaQueryWrapper);
|
|
|
- if (null != dept){
|
|
|
- date.setDeptId(dept.getDId());
|
|
|
- int type;
|
|
|
- if (null == staff){
|
|
|
- type = 1;
|
|
|
- staffService.save(date);
|
|
|
- }else {
|
|
|
- type = 2;
|
|
|
- date.setSId(staff.getSId());
|
|
|
- staffService.updateById(date);
|
|
|
- }
|
|
|
+ if (enhanceStaff(date,depts)){
|
|
|
+ checkStaffList.add(date);
|
|
|
//发送人员信息
|
|
|
if (StringUtils.isNotBlank(date.getCardId()) && Double.parseDouble(date.getCardId()) > 60000){
|
|
|
- staffService.personSendMessage(date,type);
|
|
|
+ staffService.personSendMessage(date,date.getAddOrUp());
|
|
|
//发送人脸信息
|
|
|
if (StringUtils.isNotBlank(date.getFaceId())){
|
|
|
staffService.faceSendMessage(date);
|
|
@@ -100,10 +82,36 @@ public class SmJob {
|
|
|
log.error("smJob-person:"+e.getMessage());
|
|
|
}
|
|
|
});
|
|
|
+ staffService.saveOrUpdateBatch(checkStaffList);
|
|
|
+ checkStaffList.clear();
|
|
|
return list.isEmpty();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 增强人员信息
|
|
|
+ * @param data
|
|
|
+ */
|
|
|
+ public boolean enhanceStaff(Staff data,List<Dept> depts){
|
|
|
+ data.setCardId(new BigDecimal(data.getCardId()).toString());
|
|
|
+ LambdaQueryWrapper<Staff> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(Staff::getId,data.getId());
|
|
|
+ Staff staff = staffService.getOne(queryWrapper);
|
|
|
+ Map deptMap = JSON.parseObject(data.getDept(), Map.class);
|
|
|
+ return depts.stream().filter(dept -> dept.getId().equals(deptMap.get("id").toString())).findAny()
|
|
|
+ .map(s -> {
|
|
|
+ data.setDeptId(s.getDId());
|
|
|
+ if (null == staff){
|
|
|
+ data.setAddOrUp(1);
|
|
|
+ }else {
|
|
|
+ data.setAddOrUp(2);
|
|
|
+ data.setSId(staff.getSId());
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }).orElse(false);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
public void groupApi(GroupParam groupParam){
|
|
|
TreeMap<String, Object> treeMap;
|
|
|
if (null != groupParam){
|
|
@@ -113,6 +121,7 @@ public class SmJob {
|
|
|
treeMap = SmApi.generateDeptParam(null,
|
|
|
null,null,null);
|
|
|
}
|
|
|
+ List<Dept> checkDeptList = new ArrayList<>();
|
|
|
common(SmApi.DEPT_URL,treeMap,deptList -> {
|
|
|
List<Dept> list = deptList.toJavaList(Dept.class);
|
|
|
list.forEach(date -> {
|
|
@@ -123,11 +132,17 @@ public class SmJob {
|
|
|
if (StringUtils.isBlank(date.getPid())){
|
|
|
date.setPid("0");
|
|
|
}
|
|
|
- deptService.saveOrUpdate(date,queryWrapper);
|
|
|
+ Dept dept = deptService.getOne(queryWrapper);
|
|
|
+ if (null != dept){
|
|
|
+ date.setDId(dept.getDId());
|
|
|
+ }
|
|
|
+ checkDeptList.add(date);
|
|
|
}catch (Exception e){
|
|
|
log.error("smJob-group:"+e.getMessage());
|
|
|
}
|
|
|
});
|
|
|
+ deptService.saveOrUpdateBatch(checkDeptList);
|
|
|
+ checkDeptList.clear();
|
|
|
return list.isEmpty();
|
|
|
});
|
|
|
//拼接父子结构发送数据
|