Commit 27f80c26 by guojuxing

审核员调整:关联管理员不可编辑手机号和名称,取管理员的数据

parent 965b435a
......@@ -60,8 +60,18 @@ public class AuditorDTO implements Serializable {
private Integer projectItemCount;
private Integer auditedGroupCount;
/**
* 微信用户头像
*/
private String headUrl;
/**
* 微信用户昵称
*/
private String weChatNickName;
/**
* 二维码链接
*/
private String qrcodeUrl;
public Integer getAuditorId() {
return auditorId;
......@@ -167,6 +177,15 @@ public class AuditorDTO implements Serializable {
return weChatNickName;
}
public String getQrcodeUrl() {
return qrcodeUrl;
}
public AuditorDTO setQrcodeUrl(String qrcodeUrl) {
this.qrcodeUrl = qrcodeUrl;
return this;
}
@Override
public String toString() {
return "AuditorDTO{" +
......@@ -183,6 +202,7 @@ public class AuditorDTO implements Serializable {
", auditedGroupCount=" + auditedGroupCount +
", headUrl='" + headUrl + '\'' +
", weChatNickName='" + weChatNickName + '\'' +
", qrcodeUrl='" + qrcodeUrl + '\'' +
'}';
}
}
......@@ -4,6 +4,7 @@ import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.config.Config;
import com.gic.auth.dto.AuditorDTO;
import com.gic.auth.dto.wechat.WechatUserDTO;
import com.gic.auth.entity.TabAuditor;
import com.gic.auth.entity.TabAuditorAuditedGroupRel;
import com.gic.auth.entity.TabAuditorProjectItemRel;
......@@ -31,6 +32,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
......@@ -72,6 +74,17 @@ public class AuditorApiServiceImpl implements AuditorApiService {
@Override
@Transactional(rollbackFor = Exception.class)
public ServiceResponse<String> saveOrUpdateAuditor(AuditorDTO auditorDTO) {
//是否是关联管理员,如果是,则姓名和手机号取自管理员信息
Integer userId = auditorDTO.getUserId();
boolean isRelationUser = userId != null;
if (isRelationUser) {
TabSysUser tabSysUser = userService.getUserById(userId);
if (tabSysUser != null) {
auditorDTO.setPhone(tabSysUser.getPhoneNumber());
auditorDTO.setAuditorName(tabSysUser.getUserName());
}
}
boolean nameIsRepeat = auditorService.validAuditorNameIsRepeat(auditorDTO.getEnterpriseId(), auditorDTO.getAuditorName(), auditorDTO.getAuditorId());
if (nameIsRepeat) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "审核员姓名重复");
......@@ -155,6 +168,10 @@ public class AuditorApiServiceImpl implements AuditorApiService {
return EnterpriseServiceResponse.failure(ErrorCode.NOTEXISTS);
}
AuditorDTO auditorDTO = EntityUtil.changeEntityByJSON(AuditorDTO.class, auditor);
//是否是关联管理员,如果是,则姓名和手机号取自管理员信息
Integer userId = auditorDTO.getUserId();
boolean isRelationUser = userId != null;
List<TabAuditorProjectItemRel> projectList = auditorProjectItemRelService.listRelByAuditorId(auditorId);
if (CollectionUtils.isNotEmpty(projectList)) {
List<Integer> projectIds = projectList.stream().map(TabAuditorProjectItemRel::getProjectItemId).collect(Collectors.toList());
......@@ -166,8 +183,27 @@ public class AuditorApiServiceImpl implements AuditorApiService {
auditorDTO.setAuditedGroupIdList(groupIds);
}
String codeUrl = QrcodeUtils.getTempQrCodeUrl(QrcodeTypeEnum.AUDITOR.getCode(), auditorId, auditor.getEnterpriseId());
auditorDTO.setHeadUrl(codeUrl);
//二维码链接
String codeUrl;
if (isRelationUser) {
codeUrl = QrcodeUtils.getTempQrCodeUrl(QrcodeTypeEnum.USER.getCode(), userId, auditor.getEnterpriseId());
} else {
codeUrl = QrcodeUtils.getTempQrCodeUrl(QrcodeTypeEnum.AUDITOR.getCode(), auditorId, auditor.getEnterpriseId());
}
auditorDTO.setQrcodeUrl(codeUrl);
//微信用户数据
String openId = auditor.getOpenid();
if (isRelationUser) {
TabSysUser tabSysUser = userService.getUserById(userId);
if (tabSysUser != null) {
openId = tabSysUser.getOpenId();
}
}
WechatUserDTO wechatUserDTO = QrcodeUtils.getMemberInfoByOpenId(openId);
if (wechatUserDTO != null) {
auditorDTO.setWeChatNickName(wechatUserDTO.getNickname());
auditorDTO.setHeadUrl(wechatUserDTO.getHeadimgurl());
}
return ServiceResponse.success(auditorDTO);
}
......@@ -178,11 +214,24 @@ public class AuditorApiServiceImpl implements AuditorApiService {
Page<AuditorDTO> resultPage = PageHelperUtils.changePageHelperToCurrentPage(page, AuditorDTO.class);
if (CollectionUtils.isNotEmpty(resultPage.getResult())) {
List<Integer> auditorIdList = resultPage.getResult().stream().map(AuditorDTO::getAuditorId).collect(Collectors.toList());
//查询关联的管理员手机号和名称
List<Integer> userIdList = resultPage.getResult().stream().filter(e -> e.getUserId() != null).map(AuditorDTO::getUserId).collect(Collectors.toList());
List<TabSysUser> userList = userService.listUserByIdList(userIdList);
Map<Integer, TabSysUser> userMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(userList)) {
userMap = userList.stream().collect(Collectors.toMap(e -> e.getUserId(), e -> e));
}
Map<Integer, Integer> projectItemMap = auditorProjectItemRelService.getCountByAuditorIds(auditorIdList);
Map<Integer, Integer> userCountMap = auditorAuditedGroupRelService.getUserCountByAuditorIds(auditorIdList);
for (AuditorDTO auditorDTO : resultPage.getResult()) {
auditorDTO.setProjectItemCount(projectItemMap.get(auditorDTO.getAuditorId()));
auditorDTO.setAuditedGroupCount(userCountMap.get(auditorDTO.getAuditorId()));
TabSysUser user = userMap.get(auditorDTO.getAuditorId());
if (user != null) {
auditorDTO.setPhone(user.getPhoneNumber());
auditorDTO.setAuditorName(user.getUserName());
}
}
}
return ServiceResponse.success(resultPage);
......@@ -211,15 +260,9 @@ public class AuditorApiServiceImpl implements AuditorApiService {
List<Integer> auditedGroupIds = auditedGroupUserRelService.listAuditedGroupByUserId(enterpriseId, userId);
if (CollectionUtils.isNotEmpty(auditedGroupIds)) {
List<Integer> auditorIds = auditorAuditedGroupRelService.listRelByAuditedGroupIdAndAuditId(enterpriseId, auditedGroupIds, projectAuditorIds);
if (CollectionUtils.isNotEmpty(auditorIds)) {
AuditorListQO listQO = new AuditorListQO();
listQO.setEnterpriseId(enterpriseId);
listQO.setIsUse(GlobalInfo.DATA_STATUS_NORMAL);
listQO.setAuditorIdList(auditorIds);
List<TabAuditor> auditorList = this.auditorService.listAuditor(listQO);
if (CollectionUtils.isNotEmpty(auditorList)) {
return ServiceResponse.success(EntityUtil.changeEntityListByJSON(AuditorDTO.class, auditorList));
}
List<AuditorDTO> list = listAuditor(auditorIds, enterpriseId);
if (list != null) {
return ServiceResponse.success(list);
}
}
}
......@@ -249,15 +292,9 @@ public class AuditorApiServiceImpl implements AuditorApiService {
Integer projectItemId = projectItemResponse.getResult().getProjectItemId();
// 找到审批项对应的审核员
List<Integer> projectAuditorIds = auditorProjectItemRelService.listAuditorIdByProjectItemId(enterpriseId, projectItemId);
if (CollectionUtils.isNotEmpty(projectAuditorIds)) {
AuditorListQO listQO = new AuditorListQO();
listQO.setEnterpriseId(enterpriseId);
listQO.setIsUse(GlobalInfo.DATA_STATUS_NORMAL);
listQO.setAuditorIdList(projectAuditorIds);
List<TabAuditor> auditorList = this.auditorService.listAuditor(listQO);
if (CollectionUtils.isNotEmpty(auditorList)) {
return ServiceResponse.success(EntityUtil.changeEntityListByJSON(AuditorDTO.class, auditorList));
}
List<AuditorDTO> list = listAuditor(projectAuditorIds, enterpriseId);
if (list != null) {
return ServiceResponse.success(list);
}
AuditorDTO adminAuditor = this.getAdminAuditor(enterpriseId);
return ServiceResponse.success(Collections.singletonList(adminAuditor));
......@@ -300,4 +337,18 @@ public class AuditorApiServiceImpl implements AuditorApiService {
return EntityUtil.changeEntityByJSON(AuditorDTO.class, auditor);
}
}
private List<AuditorDTO> listAuditor(List<Integer> auditorIds, Integer enterpriseId) {
if (CollectionUtils.isNotEmpty(auditorIds)) {
AuditorListQO listQO = new AuditorListQO();
listQO.setEnterpriseId(enterpriseId);
listQO.setIsUse(GlobalInfo.DATA_STATUS_NORMAL);
listQO.setAuditorIdList(auditorIds);
List<TabAuditor> auditorList = this.auditorService.listAuditor(listQO);
if (CollectionUtils.isNotEmpty(auditorList)) {
return EntityUtil.changeEntityListByJSON(AuditorDTO.class, auditorList);
}
}
return null;
}
}
......@@ -58,6 +58,9 @@ public class QrcodeUtils {
* @return
*/
public static WechatUserDTO getMemberInfoByOpenId(String openId) {
if (StringUtils.isBlank(openId)) {
return null;
}
WeixinUserFunService weixinUserFunService = ApplicationContextUtils.getBean("weixinUserFunService");
Config config = ApplicationContextUtils.getBean("config");
ServiceResponse<WeixinUserAuthDTO> response = weixinUserFunService.getMemberInfo(config.getAppkey(), openId);
......
......@@ -191,8 +191,8 @@ public class UserController {
* @return
*/
@RequestMapping("/change-bind")
public RestResponse changeBind() {
return ResultControllerUtils.commonResult(userApiService.getUserQrcode(UserDetailUtils.getUserDetail().getUserId(),
public RestResponse changeBind(Integer userId) {
return ResultControllerUtils.commonResult(userApiService.getUserQrcode(userId == null ? UserDetailUtils.getUserDetail().getUserId() : userId,
UserDetailUtils.getUserDetail().getEnterpriseId()));
}
......
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