|
@@ -6,7 +6,6 @@ import java.util.List;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.fouram.constants.WebConstants;
|
|
import org.fouram.constants.WebConstants;
|
|
-import org.fouram.constants.WebConstants.DelFlagEnum;
|
|
|
|
import org.fouram.core.base.model.PageData;
|
|
import org.fouram.core.base.model.PageData;
|
|
import org.fouram.core.base.service.BaseService;
|
|
import org.fouram.core.base.service.BaseService;
|
|
import org.fouram.core.base.service.RequestService;
|
|
import org.fouram.core.base.service.RequestService;
|
|
@@ -17,6 +16,8 @@ import org.fouram.core.util.JsonNodeUtil;
|
|
import org.fouram.core.util.Tools;
|
|
import org.fouram.core.util.Tools;
|
|
import org.fouram.entity.SapOrg;
|
|
import org.fouram.entity.SapOrg;
|
|
import org.fouram.entity.SapUser;
|
|
import org.fouram.entity.SapUser;
|
|
|
|
+import org.fouram.enums.DelFlagEnum;
|
|
|
|
+import org.fouram.enums.SapUserResultEnum;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -88,27 +89,23 @@ public class SapUserService extends BaseService {
|
|
return sapUsers;
|
|
return sapUsers;
|
|
}
|
|
}
|
|
|
|
|
|
- public void saveOneAndSyncWX(SapUser entity) throws Exception {
|
|
|
|
|
|
+ public void saveSapUser(SapUser entity) throws Exception {
|
|
entity.setCreateDate(new Date());
|
|
entity.setCreateDate(new Date());
|
|
- entity.setDelFlag(DelFlagEnum.ENABLE);
|
|
|
|
|
|
+ entity.setDelFlag(DelFlagEnum.ENABLE.getCode());
|
|
save("SapUserMapper.saveOne", entity);
|
|
save("SapUserMapper.saveOne", entity);
|
|
- // 更新同步企业微信备注
|
|
|
|
- updateWXResult(entity.getPersonId());
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- public void updateEnable(String userId) throws Exception {
|
|
|
|
- SapUser entity = SapUser.builder().userId(userId).delFlag(DelFlagEnum.ENABLE).build();
|
|
|
|
|
|
+ public void updateDelFlag(String userId, DelFlagEnum delFlagEnum) throws Exception {
|
|
|
|
+ SapUser entity = SapUser.builder().userId(userId).delFlag(delFlagEnum.getCode()).build();
|
|
update("SapUserMapper.updateDelFlag", entity);
|
|
update("SapUserMapper.updateDelFlag", entity);
|
|
}
|
|
}
|
|
|
|
|
|
- public void updateOneAndSyncWX(SapUser entity) throws Exception {
|
|
|
|
- entity.setDelFlag(DelFlagEnum.ENABLE);
|
|
|
|
|
|
+ public void updateSapUser(SapUser entity) throws Exception {
|
|
|
|
+ entity.setDelFlag(DelFlagEnum.ENABLE.getCode());
|
|
update("SapUserMapper.updateOne", entity);
|
|
update("SapUserMapper.updateOne", entity);
|
|
- // 更新同步企业微信备注
|
|
|
|
- updateWXResult(entity.getPersonId());
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- public void updateWXResult(String personId) throws Exception {
|
|
|
|
|
|
+ public void updateSyncWxResult(String personId) throws Exception {
|
|
String result = createOrUpdateWXUser(personId);
|
|
String result = createOrUpdateWXUser(personId);
|
|
SapUser entity = SapUser.builder().personId(personId).result(result).build();
|
|
SapUser entity = SapUser.builder().personId(personId).result(result).build();
|
|
update("SapUserMapper.updateResult", entity);
|
|
update("SapUserMapper.updateResult", entity);
|
|
@@ -117,7 +114,7 @@ public class SapUserService extends BaseService {
|
|
private String createOrUpdateWXUser(String personId) throws Exception {
|
|
private String createOrUpdateWXUser(String personId) throws Exception {
|
|
// 测试
|
|
// 测试
|
|
if (isTestWXSync) {
|
|
if (isTestWXSync) {
|
|
- return "TEST-" + WebConstants.SUCCESS;
|
|
|
|
|
|
+ return "TEST-" + SapUserResultEnum.SUCCESS.getCode();
|
|
}
|
|
}
|
|
List<SapUser> sapUsers = selectListByPersonId(personId);
|
|
List<SapUser> sapUsers = selectListByPersonId(personId);
|
|
SapUser wxSapUser = sapUsers.get(0);
|
|
SapUser wxSapUser = sapUsers.get(0);
|
|
@@ -142,14 +139,16 @@ public class SapUserService extends BaseService {
|
|
wxSapUser.getFormatBusinessPhone(), wxSapUser.getFirstOrgName());
|
|
wxSapUser.getFormatBusinessPhone(), wxSapUser.getFirstOrgName());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 判断是不是垃圾数据
|
|
|
|
+ *
|
|
|
|
+ * @param sapUser
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
public String checkSapUser(SapUser sapUser) {
|
|
public String checkSapUser(SapUser sapUser) {
|
|
- if (Tools.isEmpty(sapUser.getPersonId())) {
|
|
|
|
- return "员工ID为空";
|
|
|
|
- } else if (Tools.isEmpty(sapUser.getFirstOrgName())) {
|
|
|
|
- return "一级组织为空";
|
|
|
|
- }
|
|
|
|
- if (WebConstants.INGORE_PERSONIDS.contains("," + sapUser.getPersonId() + ",")) {
|
|
|
|
- return "忽略数据(兼职用户)";
|
|
|
|
|
|
+ if (Tools.isEmpty(sapUser.getPersonId()) || Tools.isEmpty(sapUser.getFirstOrgName())
|
|
|
|
+ || WebConstants.INGORE_PERSONIDS.contains("," + sapUser.getPersonId() + ",")) {
|
|
|
|
+ return SapUserResultEnum.GARBAGE.getCode();
|
|
}
|
|
}
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
@@ -173,8 +172,8 @@ public class SapUserService extends BaseService {
|
|
return (List<SapUser>) findList("SapUserMapper.selectDeleteList", null);
|
|
return (List<SapUser>) findList("SapUserMapper.selectDeleteList", null);
|
|
}
|
|
}
|
|
|
|
|
|
- public void updateAllDelete() throws Exception {
|
|
|
|
- update("SapUserMapper.updateAllDelete", null);
|
|
|
|
|
|
+ public void updateAllDelFlag(String delFlag) throws Exception {
|
|
|
|
+ update("SapUserMapper.updateAllDelFlag", delFlag);
|
|
}
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
@@ -250,31 +249,24 @@ public class SapUserService extends BaseService {
|
|
update("SapUserMapper.updateAvatar", sapUser);
|
|
update("SapUserMapper.updateAvatar", sapUser);
|
|
}
|
|
}
|
|
|
|
|
|
- public void updatDelFlagByUserId(String userId, Integer delFlag) throws Exception {
|
|
|
|
- PageData pd = new PageData();
|
|
|
|
- pd.put("userId", userId);
|
|
|
|
- pd.put("delFlag", delFlag);
|
|
|
|
- update("SapUserMapper.updatDelFlagByUserId", pd);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
public void deleteQuitUserByUserId(String userId, String oprUserId) throws Exception {
|
|
public void deleteQuitUserByUserId(String userId, String oprUserId) throws Exception {
|
|
SapUser sapUser = selectByUserId(userId);
|
|
SapUser sapUser = selectByUserId(userId);
|
|
String personId = sapUser.getPersonId();
|
|
String personId = sapUser.getPersonId();
|
|
List<SapUser> sapUsers = selectListByPersonId(personId);
|
|
List<SapUser> sapUsers = selectListByPersonId(personId);
|
|
- for(SapUser user : sapUsers) {
|
|
|
|
- updatDelFlagByUserId(user.getUserId(), DelFlagEnum.DELETED);
|
|
|
|
|
|
+ for (SapUser user : sapUsers) {
|
|
|
|
+ updateDelFlag(user.getUserId(), DelFlagEnum.DELETED);
|
|
}
|
|
}
|
|
WXCpUserUtil.delete(personId);
|
|
WXCpUserUtil.delete(personId);
|
|
sapOprLogService.saveOne(JSONUtil.toString(sapUsers), WebConstants.OPRTYPE_DELETE, oprUserId);
|
|
sapOprLogService.saveOne(JSONUtil.toString(sapUsers), WebConstants.OPRTYPE_DELETE, oprUserId);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void updateUnableData() throws Exception {
|
|
public void updateUnableData() throws Exception {
|
|
List<SapUser> users = selectSuccessList();
|
|
List<SapUser> users = selectSuccessList();
|
|
- for(SapUser user : users) {
|
|
|
|
|
|
+ for (SapUser user : users) {
|
|
WxCpUser wxUser = WXCpUserUtil.getByIdOrEmail(user.getUserId(), null);
|
|
WxCpUser wxUser = WXCpUserUtil.getByIdOrEmail(user.getUserId(), null);
|
|
- if(wxUser == null) {
|
|
|
|
|
|
+ if (wxUser == null) {
|
|
System.out.println(user.getUserId());
|
|
System.out.println(user.getUserId());
|
|
- updatDelFlagByUserId(user.getUserId(), DelFlagEnum.UNABLE);
|
|
|
|
|
|
+ updateDelFlag(user.getUserId(), DelFlagEnum.UNABLE);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|