Commit 40ab518f authored by 钱坤's avatar 钱坤

Merge remote-tracking branch 'origin/master' into v0.0.1-day-subject

# Conflicts:
#	src/main/java/com/tanpu/feo/feojob/jobs/DaySubJob.java
parents 28e8826e 3ce5a327
package com.tanpu.feo.feojob.controller; package com.tanpu.feo.feojob.controller;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.tanpu.common.api.CommonResp; import com.tanpu.common.api.CommonResp;
import com.tanpu.feo.feojob.dao.user.entity.DaySubjectEntity;
import com.tanpu.feo.feojob.dto.OrgSyncDto; import com.tanpu.feo.feojob.dto.OrgSyncDto;
import com.tanpu.feo.feojob.jobs.DaySubJob; import com.tanpu.feo.feojob.jobs.DaySubJob;
import com.tanpu.feo.feojob.jobs.OrgSyncByWxcpJob; import com.tanpu.feo.feojob.jobs.OrgSyncByWxcpJob;
...@@ -9,13 +11,13 @@ import com.tanpu.feo.feojob.service.OrgSyncByJyzyService; ...@@ -9,13 +11,13 @@ import com.tanpu.feo.feojob.service.OrgSyncByJyzyService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
@RestController @RestController
@Api(tags = "手动执行 早报推送") @Api(tags = "手动执行 早报推送")
...@@ -33,4 +35,15 @@ public class DaySubjectController { ...@@ -33,4 +35,15 @@ public class DaySubjectController {
return CommonResp.success("执行完成"); return CommonResp.success("执行完成");
} }
@RequestMapping(value = "/sendOneOrgDaySubject", method = RequestMethod.GET)
@ApiOperation(value = "单机构早报推送")
public CommonResp<String> sendOneOrgDaySubject(@RequestParam String orgId, @RequestParam String date) {
List<DaySubjectEntity> daySubjectList = daySubJob.getDaySubject(date, orgId);
List<DaySubjectEntity> list = daySubjectList.stream().filter(p -> StringUtils.equals(p.getDsPt(), orgId))
.collect(Collectors.toList());
String oneMorningTitle = daySubJob.getOneMorningTitle();
daySubJob.sendDaySubject(orgId, list, oneMorningTitle);
return CommonResp.success("执行完成");
}
} }
...@@ -13,6 +13,8 @@ public class OrgInfoDto { ...@@ -13,6 +13,8 @@ public class OrgInfoDto {
private String orgId; private String orgId;
private String orgQrCodeUrl;
private List<UserInfoEntity> userInfoList; private List<UserInfoEntity> userInfoList;
private List<EmployeeEntity> employeeList; 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("/api/org/get-qrcode-url")
CommonResp<String> getQrCodeUrl(@RequestParam("orgId") String orgId);
}
...@@ -12,6 +12,8 @@ import com.tanpu.feo.feojob.dto.WorkDataDto; ...@@ -12,6 +12,8 @@ import com.tanpu.feo.feojob.dto.WorkDataDto;
import com.tanpu.feo.feojob.dto.WxCpDepartDto; import com.tanpu.feo.feojob.dto.WxCpDepartDto;
import com.tanpu.feo.feojob.enums.EmployeeDutyEnum; import com.tanpu.feo.feojob.enums.EmployeeDutyEnum;
import com.tanpu.feo.feojob.enums.RoleTypeEnum; 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 com.tanpu.feo.feojob.service.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxErrorException;
...@@ -64,8 +66,10 @@ public class OrgSyncByWxcpJob { ...@@ -64,8 +66,10 @@ public class OrgSyncByWxcpJob {
private OrgSyncService orgSyncService; private OrgSyncService orgSyncService;
@Value("${tanpu.sync.job.skipped:true}") @Value("${tanpu.sync.job.skipped:true}")
private boolean jobSkipped; private boolean jobSkipped;
@Resource
private FeignClientForFatools feignClientForFatools;
@Scheduled(cron = "0 30 6,10,15 * * ?") //每日凌晨6点30执行 @Scheduled(cron = "0 30 6-19/1 * * ?") //每日凌晨6点30开始执行
public void execute() { public void execute() {
log.info("====== 开始执行OrgSyncByWxcpJob ======"); log.info("====== 开始执行OrgSyncByWxcpJob ======");
try { try {
...@@ -115,10 +119,12 @@ public class OrgSyncByWxcpJob { ...@@ -115,10 +119,12 @@ public class OrgSyncByWxcpJob {
continue; continue;
} }
String qrCodeUrl = getQrCodeUrl(orgEntity.getId());
//5 开始比对 5张表 数据 user_info employee department department_employee employee_role //5 开始比对 5张表 数据 user_info employee department department_employee employee_role
log.info("======开始比对 5张表 数据 ======"); log.info("======开始比对 5张表 数据 ======");
String corpId = wxCpDefaultConfig.getCorpId(); 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<EmployeeEntity> workEmployee = employeeWork(orgEntity.getId(), wxCpDepartDtoList, corpId);
WorkDataDto<DepartmentEntity> workDepartment = departmentWork(orgEntity.getId(), wxCpDepartDtoList); WorkDataDto<DepartmentEntity> workDepartment = departmentWork(orgEntity.getId(), wxCpDepartDtoList);
WorkDataDto<DepartmentEmployeeEntity> workDepartmentEmployee = departmentEmployeeWork(orgEntity.getId(), wxCpDepartDtoList, corpId); WorkDataDto<DepartmentEmployeeEntity> workDepartmentEmployee = departmentEmployeeWork(orgEntity.getId(), wxCpDepartDtoList, corpId);
...@@ -135,6 +141,14 @@ public class OrgSyncByWxcpJob { ...@@ -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: 整理 员工与角色关联关系 数据 * @description: 整理 员工与角色关联关系 数据
* @Author: zejia zj wu * @Author: zejia zj wu
...@@ -401,7 +415,7 @@ public class OrgSyncByWxcpJob { ...@@ -401,7 +415,7 @@ public class OrgSyncByWxcpJob {
* @Author: zejia zj wu * @Author: zejia zj wu
* @date: 2021/5/27 3:10 下午 * @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<>(); WorkDataDto<UserInfoEntity> workDataDto = new WorkDataDto<>();
List<UserInfoEntity> insertList = new ArrayList<>(); List<UserInfoEntity> insertList = new ArrayList<>();
List<UserInfoEntity> deleteList = new ArrayList<>(); List<UserInfoEntity> deleteList = new ArrayList<>();
...@@ -429,14 +443,16 @@ public class OrgSyncByWxcpJob { ...@@ -429,14 +443,16 @@ public class OrgSyncByWxcpJob {
continue; continue;
} }
// 更新 // 更新
if (!userInfo.getUiUsername().equals(wxCpUser.getName()) || StrUtil.isBlankIfStr(userInfo.getUiHeadimgMp()) if (!StringUtils.equals(userInfo.getUiNickname(), wxCpUser.getName()) ||
!userInfo.getUiUsername().equals(wxCpUser.getName()) || StrUtil.isBlankIfStr(userInfo.getUiHeadimgMp())
|| !wxCpUser.getUserId().equals(userInfo.getWxcpUid()) || StrUtil.isBlankIfStr(userInfo.getUiWechatXcxQrcode()) || !wxCpUser.getUserId().equals(userInfo.getWxcpUid()) || StrUtil.isBlankIfStr(userInfo.getUiWechatXcxQrcode())
|| !userInfo.getUiShenfen().equals(String.valueOf(wxCpUser.getIsLeader()))) { || !userInfo.getUiShenfen().equals(String.valueOf(wxCpUser.getIsLeader()))) {
userInfo.setUiNickname(wxCpUser.getName());
userInfo.setUiUsername(wxCpUser.getName()); userInfo.setUiUsername(wxCpUser.getName());
userInfo.setUiHeadimgMp(wxCpUser.getThumbAvatar()); userInfo.setUiHeadimgMp(wxCpUser.getThumbAvatar());
userInfo.setWxcpUid(wxCpUser.getUserId()); userInfo.setWxcpUid(wxCpUser.getUserId());
userInfo.setUiShenfen(String.valueOf(wxCpUser.getIsLeader())); 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); updateList.add(userInfo);
} }
hashMap.remove(id); hashMap.remove(id);
...@@ -449,6 +465,7 @@ public class OrgSyncByWxcpJob { ...@@ -449,6 +465,7 @@ public class OrgSyncByWxcpJob {
Gender gender = wxCpUser.getGender(); Gender gender = wxCpUser.getGender();
String sex = gender.getCode().equals("1") ? BaseConstant.Gender.MAN : BaseConstant.Gender.WOMEN; String sex = gender.getCode().equals("1") ? BaseConstant.Gender.MAN : BaseConstant.Gender.WOMEN;
userInfo.setUiSex(sex); userInfo.setUiSex(sex);
userInfo.setUiNickname(wxCpUser.getName());
userInfo.setUiHeadimg(wxCpUser.getThumbAvatar()); userInfo.setUiHeadimg(wxCpUser.getThumbAvatar());
userInfo.setUiHeadimgMp(wxCpUser.getThumbAvatar()); userInfo.setUiHeadimgMp(wxCpUser.getThumbAvatar());
userInfo.setOrgId(orgId); userInfo.setOrgId(orgId);
...@@ -470,7 +487,7 @@ public class OrgSyncByWxcpJob { ...@@ -470,7 +487,7 @@ public class OrgSyncByWxcpJob {
userInfo.setUiRegisterTime(userInfo.getCreatetime()); userInfo.setUiRegisterTime(userInfo.getCreatetime());
userInfo.setUiChannel(null); userInfo.setUiChannel(null);
userInfo.setWxcpUid(wxCpUser.getUserId()); userInfo.setWxcpUid(wxCpUser.getUserId());
userInfo.setUiWechatXcxQrcode(orgSyncService.createWechatXcxQrcode(userInfo.getId(), userInfo.getUiHeadimgMp())); userInfo.setUiWechatXcxQrcode(orgSyncService.createWechatXcxQrcode(userInfo.getId(), userInfo.getUiHeadimgMp(), qrCodeUrl));
insertList.add(userInfo); insertList.add(userInfo);
} }
workDataDto.setDeleteList(deleteList); workDataDto.setDeleteList(deleteList);
......
...@@ -15,6 +15,7 @@ import com.tanpu.feo.feojob.dao.jyzyuser.entity.JyzyTeamEntity; ...@@ -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.dao.jyzyuser.entity.JyzyUserInfoEntity;
import com.tanpu.feo.feojob.enums.EmployeeDutyEnum; import com.tanpu.feo.feojob.enums.EmployeeDutyEnum;
import com.tanpu.feo.feojob.enums.RoleTypeEnum; 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.JyzyOrgService;
import com.tanpu.feo.feojob.service.jyzy.JyzyTeamService; import com.tanpu.feo.feojob.service.jyzy.JyzyTeamService;
import com.tanpu.feo.feojob.service.jyzy.JyzyUserInfoService; import com.tanpu.feo.feojob.service.jyzy.JyzyUserInfoService;
...@@ -50,6 +51,8 @@ public class OrgSyncByJyzyService { ...@@ -50,6 +51,8 @@ public class OrgSyncByJyzyService {
private JyzyUserInfoService jyzyUserInfoService; private JyzyUserInfoService jyzyUserInfoService;
@Resource @Resource
private OrgSyncService orgSyncService; private OrgSyncService orgSyncService;
@Resource
private FeignClientForFatools feignClientForFatools;
public CommonResp<String> orgSyncByJyzy(OrgSyncDto orgSyncDto) { public CommonResp<String> orgSyncByJyzy(OrgSyncDto orgSyncDto) {
try { try {
...@@ -104,7 +107,7 @@ public class OrgSyncByJyzyService { ...@@ -104,7 +107,7 @@ public class OrgSyncByJyzyService {
if (!jyzyUserInfo.getMD5().equals(userInfo.getMD5()) || StrUtil.isBlank(userInfo.getUiWechatXcxQrcode())) { if (!jyzyUserInfo.getMD5().equals(userInfo.getMD5()) || StrUtil.isBlank(userInfo.getUiWechatXcxQrcode())) {
userInfo.update(jyzyUserInfo); userInfo.update(jyzyUserInfo);
if (StrUtil.isBlank(userInfo.getUiWechatXcxQrcode())) { //重新生成 小程序 球形码 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); updateUserInfoList.add(userInfo);
} }
...@@ -117,7 +120,7 @@ public class OrgSyncByJyzyService { ...@@ -117,7 +120,7 @@ public class OrgSyncByJyzyService {
userInfo.setLevel(2); userInfo.setLevel(2);
userInfo.setUiGrade("0"); userInfo.setUiGrade("0");
userInfo.setUiRegisterTime(DateTime.now()); 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); insertUserInfoList.add(userInfo);
}); });
...@@ -316,7 +319,7 @@ public class OrgSyncByJyzyService { ...@@ -316,7 +319,7 @@ public class OrgSyncByJyzyService {
throw new Exception("feoOrgCode 不存在"); throw new Exception("feoOrgCode 不存在");
} }
String orgId = org.getId(); String orgId = org.getId();
orgInfoDtoBuilder.orgId(orgId); orgInfoDtoBuilder.orgId(orgId).orgQrCodeUrl(getQrCodeUrl(org.getId()));
// 2 根据 orgId 获取 userInfoList信息 // 2 根据 orgId 获取 userInfoList信息
List<UserInfoEntity> userInfoList = userInfoService.getUserInfoListByOrgId(orgId); List<UserInfoEntity> userInfoList = userInfoService.getUserInfoListByOrgId(orgId);
orgInfoDtoBuilder.userInfoList(userInfoList); orgInfoDtoBuilder.userInfoList(userInfoList);
...@@ -367,4 +370,12 @@ public class OrgSyncByJyzyService { ...@@ -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,28 +67,34 @@ public class OrgSyncService { ...@@ -67,28 +67,34 @@ public class OrgSyncService {
} }
} }
public String createWechatXcxQrcode(String userId, String headImg) { public String createWechatXcxQrcode(String userId, String headImg, String qrCodeUrl) {
String url = null; String url = null;
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
try { try {
if (StrUtil.isBlank(headImg)) { if (StrUtil.isBlank(headImg)) {
headImg = wxDefaultImg; 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); JSONObject jsonObject = JSONUtil.parseObj(res);
String statusCode = (String) jsonObject.get("statusCode"); String statusCode = (String) jsonObject.get("statusCode");
if ("0000".equals(statusCode)) { if ("0000".equals(statusCode)) {
url = (String) jsonObject.get("attributes"); url = (String) jsonObject.get("attributes");
} else {
log.error("小程序球码生成失败, userId:{}, qrCodeUrl: {}, resp: {}", userId, qrCodeUrl, jsonObject);
} }
} catch (Exception e) { } catch (Exception e) {
log.error("======用户:{} 生成小程序球形码失败: {}======", userId, e.getMessage()); log.error("======用户:{} 生成小程序球形码失败: {}======", userId, e.getMessage());
} }
log.info("======用户:{} 生成小程序球形码成功 耗时: {}======", userId, System.currentTimeMillis() - startTime); log.info("======用户:{} 生成小程序球形码结束 耗时: {}======", userId, System.currentTimeMillis() - startTime);
return url; return url;
} }
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) { private void deleteAdmin(String orgId, WorkDataDto<UserInfoEntity> workUserInfo, WorkDataDto<EmployeeEntity> workEmployee, WorkDataDto<EmployeeRoleEntity> workEmployeeRole) {
// 获取 role // 获取 role
Map<String, String> roleMap = roleService.findInfoNoAdmin(); Map<String, String> roleMap = roleService.findInfoNoAdmin();
......
package com.tanpu.feo.feojob.service;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
@Service
public class RedirectService {
@Value("${tanpu.redirect.url:}")
private String redirectUrl;
public String getRedirectLink(String url) {
if (StringUtils.isBlank(url)) {
return "";
}
String u = Base64.getEncoder().encodeToString(url.getBytes(StandardCharsets.UTF_8));
return redirectUrl + u;
}
}
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