Commit 8dbc47e7 authored by 钱坤's avatar 钱坤

qrcodeurl统一从fatools获取

parent 43cbf4b6
......@@ -13,6 +13,8 @@ public class OrgInfoDto {
private String orgId;
private String orgQrCodeUrl;
private List<UserInfoEntity> userInfoList;
private List<EmployeeEntity> employeeList;
......
package com.tanpu.feo.feojob.feign;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 接口返回对象基类
*
* @description:
* @author: wanglei
* @created: 2020/04/08 23:52
*/
@Data
@ApiModel("BaseRep")
public class BaseRep<T> {
@ApiModelProperty(value = "返回码")
public String statusCode;
@ApiModelProperty(value = "返回码对应描述")
public String message;
@ApiModelProperty(value = "业务数据")
public T attributes;
}
This diff is collapsed.
package com.tanpu.feo.feojob.feign.fatools;
import com.tanpu.feo.feojob.feign.CommonResp;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Map;
//@FeignClient(value = "fatools", contextId = "fatoolsUser", fallbackFactory = FeignbackForFatools.class, url = "http://localhost:8189/fatools")
@FeignClient(value = "fatools", url = "${tanpu.feo-fatools.svc:}", path = "/fatools")
public interface FeignClientForFatools {
@GetMapping("/get-wx-config")
CommonResp<Map<String, Object>> getWxConfigInfo(@RequestParam("orgCode") String orgCode);
@GetMapping("/get-qrcode-url")
CommonResp<String> getQrCodeUrl(@RequestParam("orgId") String orgId);
}
......@@ -12,6 +12,8 @@ import com.tanpu.feo.feojob.dto.WorkDataDto;
import com.tanpu.feo.feojob.dto.WxCpDepartDto;
import com.tanpu.feo.feojob.enums.EmployeeDutyEnum;
import com.tanpu.feo.feojob.enums.RoleTypeEnum;
import com.tanpu.feo.feojob.feign.CommonResp;
import com.tanpu.feo.feojob.feign.fatools.FeignClientForFatools;
import com.tanpu.feo.feojob.service.*;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
......@@ -64,6 +66,8 @@ public class OrgSyncByWxcpJob {
private OrgSyncService orgSyncService;
@Value("${tanpu.sync.job.skipped:true}")
private boolean jobSkipped;
@Resource
private FeignClientForFatools feignClientForFatools;
@Scheduled(cron = "0 30 6-19/1 * * ?") //每日凌晨6点30开始执行
public void execute() {
......@@ -115,10 +119,12 @@ public class OrgSyncByWxcpJob {
continue;
}
String qrCodeUrl = getQrCodeUrl(orgEntity.getId());
//5 开始比对 5张表 数据 user_info employee department department_employee employee_role
log.info("======开始比对 5张表 数据 ======");
String corpId = wxCpDefaultConfig.getCorpId();
WorkDataDto<UserInfoEntity> workUserInfo = userInfoWork(orgEntity.getId(), wxCpDepartDtoList, corpId);
WorkDataDto<UserInfoEntity> workUserInfo = userInfoWork(orgEntity.getId(), wxCpDepartDtoList, corpId, qrCodeUrl);
WorkDataDto<EmployeeEntity> workEmployee = employeeWork(orgEntity.getId(), wxCpDepartDtoList, corpId);
WorkDataDto<DepartmentEntity> workDepartment = departmentWork(orgEntity.getId(), wxCpDepartDtoList);
WorkDataDto<DepartmentEmployeeEntity> workDepartmentEmployee = departmentEmployeeWork(orgEntity.getId(), wxCpDepartDtoList, corpId);
......@@ -135,6 +141,14 @@ public class OrgSyncByWxcpJob {
}
private String getQrCodeUrl(String orgId) {
CommonResp<String> commonResp = feignClientForFatools.getQrCodeUrl(orgId);
if (commonResp.isNotSuccess()) {
throw new RuntimeException(commonResp.statusCode + ", " + commonResp.getMessage());
}
return commonResp.getAttributes();
}
/**
* @description: 整理 员工与角色关联关系 数据
* @Author: zejia zj wu
......@@ -401,7 +415,7 @@ public class OrgSyncByWxcpJob {
* @Author: zejia zj wu
* @date: 2021/5/27 3:10 下午
*/
private WorkDataDto<UserInfoEntity> userInfoWork(String orgId, List<WxCpDepartDto> wxCpDepartDtoList, String corpId) {
private WorkDataDto<UserInfoEntity> userInfoWork(String orgId, List<WxCpDepartDto> wxCpDepartDtoList, String corpId, String qrCodeUrl) {
WorkDataDto<UserInfoEntity> workDataDto = new WorkDataDto<>();
List<UserInfoEntity> insertList = new ArrayList<>();
List<UserInfoEntity> deleteList = new ArrayList<>();
......@@ -438,7 +452,7 @@ public class OrgSyncByWxcpJob {
userInfo.setUiHeadimgMp(wxCpUser.getThumbAvatar());
userInfo.setWxcpUid(wxCpUser.getUserId());
userInfo.setUiShenfen(String.valueOf(wxCpUser.getIsLeader()));
userInfo.setUiWechatXcxQrcode(orgSyncService.createWechatXcxQrcode(userInfo.getId(), wxCpUser.getThumbAvatar()));
userInfo.setUiWechatXcxQrcode(orgSyncService.createWechatXcxQrcode(userInfo.getId(), wxCpUser.getThumbAvatar(), qrCodeUrl));
updateList.add(userInfo);
}
hashMap.remove(id);
......@@ -473,7 +487,7 @@ public class OrgSyncByWxcpJob {
userInfo.setUiRegisterTime(userInfo.getCreatetime());
userInfo.setUiChannel(null);
userInfo.setWxcpUid(wxCpUser.getUserId());
userInfo.setUiWechatXcxQrcode(orgSyncService.createWechatXcxQrcode(userInfo.getId(), userInfo.getUiHeadimgMp()));
userInfo.setUiWechatXcxQrcode(orgSyncService.createWechatXcxQrcode(userInfo.getId(), userInfo.getUiHeadimgMp(), qrCodeUrl));
insertList.add(userInfo);
}
workDataDto.setDeleteList(deleteList);
......
......@@ -15,6 +15,7 @@ import com.tanpu.feo.feojob.dao.jyzyuser.entity.JyzyTeamEntity;
import com.tanpu.feo.feojob.dao.jyzyuser.entity.JyzyUserInfoEntity;
import com.tanpu.feo.feojob.enums.EmployeeDutyEnum;
import com.tanpu.feo.feojob.enums.RoleTypeEnum;
import com.tanpu.feo.feojob.feign.fatools.FeignClientForFatools;
import com.tanpu.feo.feojob.service.jyzy.JyzyOrgService;
import com.tanpu.feo.feojob.service.jyzy.JyzyTeamService;
import com.tanpu.feo.feojob.service.jyzy.JyzyUserInfoService;
......@@ -50,6 +51,8 @@ public class OrgSyncByJyzyService {
private JyzyUserInfoService jyzyUserInfoService;
@Resource
private OrgSyncService orgSyncService;
@Resource
private FeignClientForFatools feignClientForFatools;
public CommonResp<String> orgSyncByJyzy(OrgSyncDto orgSyncDto) {
try {
......@@ -104,7 +107,7 @@ public class OrgSyncByJyzyService {
if (!jyzyUserInfo.getMD5().equals(userInfo.getMD5()) || StrUtil.isBlank(userInfo.getUiWechatXcxQrcode())) {
userInfo.update(jyzyUserInfo);
if (StrUtil.isBlank(userInfo.getUiWechatXcxQrcode())) { //重新生成 小程序 球形码
userInfo.setUiWechatXcxQrcode(orgSyncService.createWechatXcxQrcode(userInfo.getId(), userInfo.getUiHeadimg()));
userInfo.setUiWechatXcxQrcode(orgSyncService.createWechatXcxQrcode(userInfo.getId(), userInfo.getUiHeadimg(), orgInfoDto.getOrgQrCodeUrl()));
}
updateUserInfoList.add(userInfo);
}
......@@ -117,7 +120,7 @@ public class OrgSyncByJyzyService {
userInfo.setLevel(2);
userInfo.setUiGrade("0");
userInfo.setUiRegisterTime(DateTime.now());
userInfo.setUiWechatXcxQrcode(orgSyncService.createWechatXcxQrcode(userInfo.getId(), userInfo.getUiHeadimg()));
userInfo.setUiWechatXcxQrcode(orgSyncService.createWechatXcxQrcode(userInfo.getId(), userInfo.getUiHeadimg(), orgInfoDto.getOrgQrCodeUrl()));
insertUserInfoList.add(userInfo);
});
......@@ -316,7 +319,7 @@ public class OrgSyncByJyzyService {
throw new Exception("feoOrgCode 不存在");
}
String orgId = org.getId();
orgInfoDtoBuilder.orgId(orgId);
orgInfoDtoBuilder.orgId(orgId).orgQrCodeUrl(getQrCodeUrl(org.getId()));
// 2 根据 orgId 获取 userInfoList信息
List<UserInfoEntity> userInfoList = userInfoService.getUserInfoListByOrgId(orgId);
orgInfoDtoBuilder.userInfoList(userInfoList);
......@@ -367,4 +370,12 @@ public class OrgSyncByJyzyService {
}
}
private String getQrCodeUrl(String orgCode) {
com.tanpu.feo.feojob.feign.CommonResp<String> commonResp = feignClientForFatools.getQrCodeUrl(orgCode);
if (commonResp.isNotSuccess()) {
throw new RuntimeException(commonResp.statusCode + ", " + commonResp.getMessage());
}
return commonResp.getAttributes();
}
}
......@@ -67,14 +67,14 @@ public class OrgSyncService {
}
}
public String createWechatXcxQrcode(String userId, String headImg) {
public String createWechatXcxQrcode(String userId, String headImg, String qrCodeUrl) {
String url = null;
long startTime = System.currentTimeMillis();
try {
if (StrUtil.isBlank(headImg)) {
headImg = wxDefaultImg;
}
String res = restTemplate.getForObject(qrcodeurl + "?userId=" + userId + "&headimage=" + headImg + "&params=" + userId, String.class);
String res = restTemplate.getForObject(qrCodeUrl + "?userId=" + userId + "&headimage=" + headImg + "&params=" + userId, String.class);
JSONObject jsonObject = JSONUtil.parseObj(res);
String statusCode = (String) jsonObject.get("statusCode");
if ("0000".equals(statusCode)) {
......@@ -89,6 +89,10 @@ public class OrgSyncService {
}
private String getQrCodeUrl(String urlTemplate, String miniAppId){
return String.format(urlTemplate,miniAppId);
}
private void deleteAdmin(String orgId, WorkDataDto<UserInfoEntity> workUserInfo, WorkDataDto<EmployeeEntity> workEmployee, WorkDataDto<EmployeeRoleEntity> workEmployeeRole) {
// 获取 role
Map<String, String> roleMap = roleService.findInfoNoAdmin();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment