Forráskód Böngészése

处理钉钉离职人员的消息同步

seyason 2 éve
szülő
commit
f6fec4cd01

+ 25 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/DingDingController.java

@@ -242,6 +242,31 @@ public class DingDingController {
                                 }
                             }
                         }
+                    } else if ("SYNC_HTTP_PUSH_MEDIUM".equals(eventType)) {
+                        JSONArray bizData = eventJson.getJSONArray("bizData");
+                        if (bizData.size() > 0) {
+                            //优先处理suite_ticket推送
+                            for (int i = 0; i < bizData.size(); i++) {
+                                JSONObject bizItem = bizData.getJSONObject(i);
+                                int bizType = bizItem.getInteger("biz_type");
+                                if (13 == bizType) {
+                                    JSONObject actionBizData = bizItem.getJSONObject("biz_data");
+                                    String syncAction = actionBizData.getString("syncAction");
+                                    if ("user_leave_org".equals(syncAction)) {
+                                        //员工离职
+                                        String corpId = bizItem.getString("corp_id");
+                                        String unionId = actionBizData.getString("unionid");
+                                        Integer companyId = companyDingdingMapper.selectById(corpId).getCompanyId();
+                                        User user = userMapper.selectOne(new QueryWrapper<User>().eq("company_id", companyId).eq("dingding_unionid", unionId));
+                                        if (user != null && user.getIsActive() == 1) {
+                                            user.setIsActive(0);
+                                            user.setInactiveDate(LocalDate.now());
+                                            userMapper.updateById(user);
+                                        }
+                                    }
+                                }
+                            }
+                        }
                     }
                 }
             }