|
@@ -24,15 +24,18 @@ public class WxUserService extends BaseService {
|
|
|
|
|
|
public void saveUsers() throws Exception {
|
|
public void saveUsers() throws Exception {
|
|
update("WxUserMapper.updateAllDelete", null);
|
|
update("WxUserMapper.updateAllDelete", null);
|
|
-
|
|
|
|
|
|
+
|
|
List<WxCpUser> users = WXCpUserUtil.listAllUser();
|
|
List<WxCpUser> users = WXCpUserUtil.listAllUser();
|
|
List<WxDepart> departs = null;
|
|
List<WxDepart> departs = null;
|
|
WxUser wxUser = null;
|
|
WxUser wxUser = null;
|
|
WxUser dbUser = null;
|
|
WxUser dbUser = null;
|
|
String userId = null;
|
|
String userId = null;
|
|
|
|
+ StringBuffer sb = null;
|
|
for (WxCpUser user : users) {
|
|
for (WxCpUser user : users) {
|
|
|
|
+ sb = new StringBuffer();
|
|
userId = user.getUserId();
|
|
userId = user.getUserId();
|
|
- wxUser = WxUser.builder().userId(userId).name(user.getName()).departId(user.getDepartIds()[0]).build();
|
|
|
|
|
|
+ wxUser = WxUser.builder().userId(userId).email(user.getEmail()).name(user.getName())
|
|
|
|
+ .departId(user.getDepartIds()[0]).build();
|
|
departs = getUserDepart(wxUser.getDepartId());
|
|
departs = getUserDepart(wxUser.getDepartId());
|
|
if (departs.size() > 0) {
|
|
if (departs.size() > 0) {
|
|
wxUser.setFirstDepartName(departs.get(0).getName());
|
|
wxUser.setFirstDepartName(departs.get(0).getName());
|
|
@@ -43,7 +46,11 @@ public class WxUserService extends BaseService {
|
|
wxUser.setSecondDepartId(departs.get(1).getId());
|
|
wxUser.setSecondDepartId(departs.get(1).getId());
|
|
}
|
|
}
|
|
wxUser.setPosition(user.getPosition());
|
|
wxUser.setPosition(user.getPosition());
|
|
- wxUser.setDepartIds(user.getDepartIds().toString().replace("[", ",").replace("]", ",").replace(" ", ""));
|
|
|
|
|
|
+ sb.append(",");
|
|
|
|
+ for(Long departId : user.getDepartIds()) {
|
|
|
|
+ sb.append(departId).append(",");
|
|
|
|
+ }
|
|
|
|
+ wxUser.setDepartIds(sb.toString());
|
|
dbUser = selectById(userId);
|
|
dbUser = selectById(userId);
|
|
if (dbUser == null) {
|
|
if (dbUser == null) {
|
|
save("WxUserMapper.save", wxUser);
|
|
save("WxUserMapper.save", wxUser);
|
|
@@ -53,7 +60,7 @@ public class WxUserService extends BaseService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public WxUser selectById(String userId) throws Exception {
|
|
public WxUser selectById(String userId) throws Exception {
|
|
return (WxUser) findObject("WxUserMapper.selectById", userId);
|
|
return (WxUser) findObject("WxUserMapper.selectById", userId);
|
|
}
|
|
}
|
|
@@ -64,7 +71,7 @@ public class WxUserService extends BaseService {
|
|
}
|
|
}
|
|
return userDepartMap.get(departId);
|
|
return userDepartMap.get(departId);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@SuppressWarnings("unchecked")
|
|
@SuppressWarnings("unchecked")
|
|
public List<String> selectAllUserIds() throws Exception {
|
|
public List<String> selectAllUserIds() throws Exception {
|
|
return (List<String>) findList("WxUserMapper.selectAllUserIds", null);
|
|
return (List<String>) findList("WxUserMapper.selectAllUserIds", null);
|