|
@@ -8,24 +8,19 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
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.MsgLog;
|
|
|
import com.usky.dxtop.model.Staff;
|
|
|
import com.usky.dxtop.service.DeptService;
|
|
|
-import com.usky.dxtop.service.MsgLogService;
|
|
|
import com.usky.dxtop.service.StaffService;
|
|
|
import com.usky.dxtop.service.api.SmApi;
|
|
|
-import com.usky.dxtop.service.config.rabbitmq.face.FaceConsumeConfig;
|
|
|
-import com.usky.dxtop.service.config.rabbitmq.group.GroupConsumeConfig;
|
|
|
-import com.usky.dxtop.service.config.rabbitmq.profile.ProfileConsumeConfig;
|
|
|
import lombok.Data;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.amqp.rabbit.connection.CorrelationData;
|
|
|
-import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import java.util.*;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.TreeMap;
|
|
|
import java.util.function.Function;
|
|
|
|
|
|
/**
|
|
@@ -44,23 +39,6 @@ public class SmJob {
|
|
|
@Autowired
|
|
|
private DeptService deptService;
|
|
|
|
|
|
- @Autowired
|
|
|
- @Qualifier(ProfileConsumeConfig.TEMPLATE)
|
|
|
- private RabbitTemplate profileRabbitTemplate;
|
|
|
-
|
|
|
-
|
|
|
- @Autowired
|
|
|
- @Qualifier(FaceConsumeConfig.TEMPLATE)
|
|
|
- private RabbitTemplate faceRabbitTemplate;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- @Qualifier(GroupConsumeConfig.TEMPLATE)
|
|
|
- private RabbitTemplate groupRabbitTemplate;
|
|
|
-
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private MsgLogService msgLogService;
|
|
|
-
|
|
|
// @Scheduled(cron = "0 0 0 */1 * ?")
|
|
|
public void personExecute(String param) {
|
|
|
PersonParam personParam = JSON.parseObject(param, PersonParam.class);
|
|
@@ -90,8 +68,11 @@ public class SmJob {
|
|
|
LambdaQueryWrapper<Staff> queryWrapper = Wrappers.lambdaQuery();
|
|
|
queryWrapper.eq(Staff::getId,date.getId());
|
|
|
Staff staff = staffService.getOne(queryWrapper);
|
|
|
- Map dept = JSON.parseObject(date.getDept(), Map.class);
|
|
|
- date.setDeptId(dept.get("id").toString());
|
|
|
+ //获取部门信息
|
|
|
+ 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);
|
|
|
int type;
|
|
|
if (null == staff){
|
|
|
type = 1;
|
|
@@ -102,12 +83,13 @@ public class SmJob {
|
|
|
staffService.updateById(date);
|
|
|
}
|
|
|
//发送人员信息
|
|
|
- if (StringUtils.isNotBlank(date.getCardId())){
|
|
|
- personSendMessage(date,type);
|
|
|
+ if (StringUtils.isNotBlank(date.getCardId()) && null != dept){
|
|
|
+ date.setDeptId(dept.getId());
|
|
|
+ staffService.personSendMessage(date,type);
|
|
|
}
|
|
|
//发送人脸信息
|
|
|
if (StringUtils.isNotBlank(date.getFaceId())){
|
|
|
- faceSendMessage(date);
|
|
|
+ staffService.faceSendMessage(date);
|
|
|
}
|
|
|
});
|
|
|
return list.isEmpty();
|
|
@@ -123,19 +105,19 @@ public class SmJob {
|
|
|
treeMap = SmApi.generateDeptParam(null,
|
|
|
null,null,null);
|
|
|
}
|
|
|
- common(SmApi.DEPT_URL,treeMap,staffList -> {
|
|
|
- List<Dept> list = staffList.toJavaList(Dept.class);
|
|
|
+ common(SmApi.DEPT_URL,treeMap,deptList -> {
|
|
|
+ List<Dept> list = deptList.toJavaList(Dept.class);
|
|
|
list.forEach(date -> {
|
|
|
+ //只负责同步
|
|
|
LambdaQueryWrapper<Dept> queryWrapper = Wrappers.lambdaQuery();
|
|
|
queryWrapper.eq(Dept::getId,date.getId());
|
|
|
- Dept dept = deptService.getOne(queryWrapper);
|
|
|
- if (null == dept){
|
|
|
- deptService.save(date);
|
|
|
- }
|
|
|
- deptSendMessage(date);
|
|
|
+ deptService.saveOrUpdate(date,queryWrapper);
|
|
|
});
|
|
|
return list.isEmpty();
|
|
|
});
|
|
|
+ //拼接父子结构发送数据
|
|
|
+ List<Dept> list = deptService.list();
|
|
|
+ deptService.buildDeptTree(list);
|
|
|
}
|
|
|
|
|
|
public void common(String url, TreeMap<String,Object> param, Function<JSONArray,Boolean> function){
|
|
@@ -169,74 +151,7 @@ public class SmJob {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 人员消息
|
|
|
- * @param staff
|
|
|
- */
|
|
|
- public void personSendMessage(Staff staff,Integer type){
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
- map.put("type",type);
|
|
|
- map.put("card_type",1);
|
|
|
- map.put("card",staff.getCardId());
|
|
|
- map.put("name",staff.getName());
|
|
|
- map.put("mob",staff.getId());
|
|
|
- Map dept = JSON.parseObject(staff.getDept(), Map.class);
|
|
|
- map.put("groupid",dept.get("id"));
|
|
|
- map.put("tel",staff.getContacts());
|
|
|
- map.put("level_name","");
|
|
|
- MsgLog msgLog = new MsgLog();
|
|
|
- msgLog.setBusinessId(staff.getSId());
|
|
|
- msgLog.setExchange(ProfileConsumeConfig.NAME);
|
|
|
- msgLog.setRoutingKey(ProfileConsumeConfig.NAME);
|
|
|
- msgLogService.save(msgLog);
|
|
|
- map.put("seq",msgLog.getId());
|
|
|
- msgLog.setMsg(JSON.toJSONString(map));
|
|
|
- msgLogService.updateById(msgLog);
|
|
|
- CorrelationData correlationData = new CorrelationData(msgLog.getId().toString());
|
|
|
- profileRabbitTemplate.convertAndSend(msgLog.getExchange(), msgLog.getRoutingKey(), map,correlationData);
|
|
|
- }
|
|
|
|
|
|
- /**
|
|
|
- * 部门消息
|
|
|
- * @param dept
|
|
|
- */
|
|
|
- public void deptSendMessage(Dept dept){
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
- map.put("parentid",dept.getPid());
|
|
|
- map.put("id",dept.getId());
|
|
|
- map.put("name",dept.getName());
|
|
|
- MsgLog msgLog = new MsgLog();
|
|
|
- msgLog.setBusinessId(dept.getDId());
|
|
|
- msgLog.setExchange(GroupConsumeConfig.NAME);
|
|
|
- msgLog.setRoutingKey(GroupConsumeConfig.NAME);
|
|
|
- msgLogService.save(msgLog);
|
|
|
- map.put("seq",msgLog.getId());
|
|
|
- msgLog.setMsg(JSON.toJSONString(map));
|
|
|
- msgLogService.updateById(msgLog);
|
|
|
- CorrelationData correlationData = new CorrelationData(msgLog.getId().toString());
|
|
|
- groupRabbitTemplate.convertAndSend(msgLog.getExchange(), msgLog.getRoutingKey(), map,correlationData);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 人脸
|
|
|
- * @param staff
|
|
|
- */
|
|
|
- public void faceSendMessage(Staff staff){
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
- map.put("mob",staff.getId());
|
|
|
- map.put("image",staff.getFaceId());
|
|
|
- faceRabbitTemplate.convertAndSend(FaceConsumeConfig.NAME, FaceConsumeConfig.NAME, map);
|
|
|
- MsgLog msgLog = new MsgLog();
|
|
|
- msgLog.setBusinessId(staff.getSId());
|
|
|
- msgLog.setExchange(FaceConsumeConfig.NAME);
|
|
|
- msgLog.setRoutingKey(FaceConsumeConfig.NAME);
|
|
|
- msgLogService.save(msgLog);
|
|
|
- map.put("seq",msgLog.getId());
|
|
|
- msgLog.setMsg(JSON.toJSONString(map));
|
|
|
- msgLogService.updateById(msgLog);
|
|
|
- CorrelationData correlationData = new CorrelationData(msgLog.getId().toString());
|
|
|
- faceRabbitTemplate.convertAndSend(msgLog.getExchange(), msgLog.getRoutingKey(), map,correlationData);
|
|
|
- }
|
|
|
|
|
|
@Data
|
|
|
public static class PersonParam {
|