|
@@ -5,17 +5,16 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.management.platform.controller.WeiXinCorpController;
|
|
|
-import com.management.platform.entity.SysConfig;
|
|
|
-import com.management.platform.entity.User;
|
|
|
-import com.management.platform.entity.UserCorpwxTime;
|
|
|
-import com.management.platform.entity.WxCorpInfo;
|
|
|
+import com.management.platform.entity.*;
|
|
|
import com.management.platform.mapper.SysConfigMapper;
|
|
|
import com.management.platform.mapper.UserCorpwxTimeMapper;
|
|
|
import com.management.platform.mapper.UserMapper;
|
|
|
import com.management.platform.mapper.WxCorpInfoMapper;
|
|
|
import com.management.platform.service.WxCorpInfoService;
|
|
|
+import com.management.platform.util.ColorUtil;
|
|
|
import com.management.platform.util.DateTimeUtil;
|
|
|
import com.management.platform.util.HttpRespMsg;
|
|
|
+import com.management.platform.util.SnowFlake;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -311,7 +310,6 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
|
Object[] objects = corpwxUserIds.subList(fromIndex, toIndex).toArray(new String[0]);
|
|
|
reqOnceCardTime(corpInfo, startTime, endTime, objects, showLog);
|
|
|
}
|
|
|
-
|
|
|
} catch (Exception exception) {
|
|
|
exception.printStackTrace();
|
|
|
}
|
|
@@ -319,6 +317,71 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg syncMembByCardTime(WxCorpInfo wxCorpInfo) {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", wxCorpInfo.getCompanyId()).likeRight("name", "woy9Tk"));
|
|
|
+ List<String> corpwxUserIds = userList.stream().map(User::getCorpwxUserid).collect(Collectors.toList());
|
|
|
+ System.out.println("新拉取到的无姓名用户WXCorp_userid size="+corpwxUserIds.size());
|
|
|
+ if (corpwxUserIds.size() == 0) {
|
|
|
+ msg.data = "无新成员更新";
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ String url = null;
|
|
|
+ try {
|
|
|
+ LocalDateTime startDateTime = LocalDateTime.now();
|
|
|
+ LocalDateTime endDateTime = LocalDateTime.now();
|
|
|
+ startDateTime = startDateTime.minusDays(5);
|
|
|
+ endDateTime = endDateTime.minusDays(1);
|
|
|
+
|
|
|
+ startDateTime = startDateTime.withHour(0).withMinute(0).withSecond(0).withNano(0);
|
|
|
+ long startTime = startDateTime.toEpochSecond(ZoneOffset.of("+8"));
|
|
|
+ endDateTime = endDateTime.withHour(0).withMinute(0).withSecond(0).withNano(0);
|
|
|
+ long endTime = endDateTime.toEpochSecond(ZoneOffset.of("+8"));
|
|
|
+ System.out.println("startTime="+startTime+",endTime="+endTime);
|
|
|
+
|
|
|
+ int batchCount = 1;
|
|
|
+ int batchSize = 100;
|
|
|
+ int totalLength = 1;
|
|
|
+ //按批调用
|
|
|
+ for (int i=0;i<batchCount; i++) {
|
|
|
+ int fromIndex = i*batchSize;
|
|
|
+ int toIndex = (i+1) * batchSize;
|
|
|
+ if (toIndex > totalLength) toIndex = totalLength;
|
|
|
+ Object[] objects = corpwxUserIds.subList(fromIndex, toIndex).toArray(new String[0]);
|
|
|
+ reqOnceCardTime(wxCorpInfo, startTime, endTime, objects, false);
|
|
|
+ }
|
|
|
+ //查询日报中的人员姓名,更新用户表
|
|
|
+ List<UserCorpwxTime> cardTimeList = userCorpwxTimeMapper.selectList(
|
|
|
+ new QueryWrapper<UserCorpwxTime>().select("corpwx_userid, name").eq("company_id", wxCorpInfo.getCompanyId()).in("corpwx_userid", corpwxUserIds));
|
|
|
+ List<User> updateUserList = new ArrayList<>();
|
|
|
+ for (UserCorpwxTime userCorpwxTime : cardTimeList) {
|
|
|
+ User user = userMapper.selectOne(new QueryWrapper<User>().eq("name", userCorpwxTime.getName()).eq("company_id", wxCorpInfo.getCompanyId()));
|
|
|
+ if (user != null && user.getCorpwxUserid() == null) {
|
|
|
+ user.setCorpwxUserid(userCorpwxTime.getCorpwxUserid());
|
|
|
+ updateUserList.add(user);
|
|
|
+ userMapper.updateById(user);
|
|
|
+ System.out.println("更新用户:"+user.getName());
|
|
|
+ } else {
|
|
|
+ System.out.println("查询日报无更新:"+userCorpwxTime.getCorpwxUserid()+", "+userCorpwxTime.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> collect = userList.stream().map(User::getId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ userMapper.delete(new QueryWrapper<User>().in("id", collect));
|
|
|
+ if (updateUserList.size() == 0) {
|
|
|
+ msg.data = "处理完毕。当前无新人员需要关联企业微信身份";
|
|
|
+ } else {
|
|
|
+ msg.data = "处理完毕。本次自动关联了:"+updateUserList.size()+"位人员:"+updateUserList.stream().map(User::getName).collect(Collectors.joining(","));
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception exception) {
|
|
|
+ exception.printStackTrace();
|
|
|
+ }
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private void reqOnceCardTime(WxCorpInfo corpInfo, long startTime, long endTime, Object[] objects, boolean showLog) throws Exception {
|
|
|
DateTimeFormatter mdFormat = DateTimeFormatter.ofPattern("yyyy/M/d");
|