|
|
@@ -9,9 +9,7 @@ import com.tzld.piaoquan.growth.common.dao.mapper.*;
|
|
|
import com.tzld.piaoquan.growth.common.model.bo.XxlJobParam;
|
|
|
import com.tzld.piaoquan.growth.common.model.po.*;
|
|
|
import com.tzld.piaoquan.growth.common.service.WeComAccessTokenService;
|
|
|
-import com.tzld.piaoquan.growth.common.service.WeComSendService;
|
|
|
import com.tzld.piaoquan.growth.common.utils.DateUtil;
|
|
|
-import com.tzld.piaoquan.growth.common.utils.DateUtils;
|
|
|
import com.tzld.piaoquan.growth.common.utils.LarkRobotUtil;
|
|
|
import com.xxl.job.core.biz.model.ReturnT;
|
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
@@ -25,6 +23,7 @@ import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.tzld.piaoquan.growth.common.common.constant.WeComConstant.*;
|
|
|
@@ -57,8 +56,8 @@ public class WeComStaffDataJob {
|
|
|
@Autowired
|
|
|
private CorpStatisticsTotalMapper corpStatisticsTotalMapper;
|
|
|
|
|
|
- @XxlJob("insertStaffJob")
|
|
|
- public ReturnT<String> insertStaff(String param) {
|
|
|
+ @XxlJob("syncStaffJob")
|
|
|
+ public ReturnT<String> syncStaff(String param) {
|
|
|
try {
|
|
|
XxlJobParam xxlJobParam = new XxlJobParam();
|
|
|
if (StringUtils.isNotEmpty(param)) {
|
|
|
@@ -78,6 +77,7 @@ public class WeComStaffDataJob {
|
|
|
continue;
|
|
|
}
|
|
|
for (String carrierId : carrierIdList) {
|
|
|
+ JSONObject carrierInfo = getCarrierInfo(corp.getId(), carrierId);
|
|
|
StaffExample example = new StaffExample();
|
|
|
example.createCriteria().andCarrierIdEqualTo(carrierId).andCorpIdEqualTo(corp.getId());
|
|
|
List<Staff> staffList = staffMapper.selectByExample(example);
|
|
|
@@ -85,8 +85,18 @@ public class WeComStaffDataJob {
|
|
|
Staff staff = new Staff();
|
|
|
staff.setCorpId(corp.getId());
|
|
|
staff.setCarrierId(carrierId);
|
|
|
- staff.setRemark("");
|
|
|
+ if (Objects.nonNull(carrierInfo) && carrierInfo.containsKey("name")) {
|
|
|
+ staff.setRemark(carrierInfo.getString("name"));
|
|
|
+ } else {
|
|
|
+ staff.setRemark("");
|
|
|
+ }
|
|
|
staffMapper.insert(staff);
|
|
|
+ } else {
|
|
|
+ Staff staff = staffList.get(0);
|
|
|
+ if (Objects.nonNull(carrierInfo) && carrierInfo.containsKey("name")) {
|
|
|
+ staff.setRemark(carrierInfo.getString("name"));
|
|
|
+ staffMapper.updateByPrimaryKeySelective(staff);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -115,6 +125,25 @@ public class WeComStaffDataJob {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ private JSONObject getCarrierInfo(Long corpId, String userId) throws IOException {
|
|
|
+ String weComAccessToken = weComAccessTokenService.getWeComAccessToken(corpId);
|
|
|
+ String url = String.format(GET_WE_COM_FOLLOW_USER_DETAIL + "?access_token=%s", weComAccessToken);
|
|
|
+ url = String.format(url + "&userid=%s", userId);
|
|
|
+ String res;
|
|
|
+ if (corpId == 1L) {
|
|
|
+ res = httpPoolClient.get(url);
|
|
|
+ } else {
|
|
|
+ res = proxyHttpPoolClient.get(url);
|
|
|
+ }
|
|
|
+ log.info("getCarrierInfo corp = {} , userId = {}, res={}", corpId, userId, res);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
+ Integer errcode = jsonObject.getInteger("errcode");
|
|
|
+ if (errcode == 0) {
|
|
|
+ return jsonObject;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
@XxlJob("statisticsTotalJob")
|
|
|
public ReturnT<String> statisticsTotal(String param) throws IOException {
|
|
|
String date;
|