| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestHeader; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.Serializable; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | * @since 2025/04/02 17:49 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class MemberServiceImpl implements MemberService { |
| | | |
| | | @Resource(name="sessionRedisTemplate") |
| | | private RedisTemplate<Object, Serializable> redisTemplate; |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | @Autowired |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void syncQwAll(){ |
| | | if(Constants.DEALING_MEMBER_SYNC){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,同步任务正在进行,请稍后刷新页面重试!"); |
| | |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | Date date = new Date(); |
| | | List<QywxUserListResponse> list = new ArrayList<>(); |
| | | int index =0; |
| | | for(Company c : companyList){ |
| | | List<QywxUserListResponse> tList = QywxUtil.getUserList(systemDictDataBiz.queryByCode(Constants.QYWX,Constants.QYWX_TOKEN).getCode(),c.getQwId()); |
| | | if(tList!=null){ |
| | | log.error((index++)+"==============="+c.getName()+"============人员数量:"+tList.size()); |
| | | list.addAll(tList); |
| | | }else{ |
| | | log.error((index++)+"==============="+c.getName()+"============人员数量:0"); |
| | | } |
| | | } |
| | | if(list == null || list.size() ==0){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未同步到任何组织信息!"); |
| | | } |
| | | log.error( "###################=================人员总数量:"+list.size()); |
| | | List<Member> memberList = memberMapper.selectList(new LambdaQueryWrapper<Member>().eq(Member::getIsdeleted,Constants.ZERO)); |
| | | List<Member> newList = new ArrayList<>(); |
| | | List<Member> updateList = new ArrayList<>(); |
| | |
| | | if(StringUtils.isNotBlank(comNames)){ |
| | | comNames += ","; |
| | | } |
| | | comNames += c.getNamePath(); |
| | | comNames += StringUtils.defaultString(c.getNamePath(),c.getName()); |
| | | } |
| | | } |
| | | cm.setCompanyList(qycom); |
| | |
| | | } |
| | | String token = systemDictDataBiz.queryByCode(Constants.QYWX,Constants.QYWX_TOKEN).getCode(); |
| | | //根据code换区企业微信ID |
| | | QywxBaseResponse<String> qwIdBaseResponse= null;// QywxUtil.getUserInfoByCode(token,dto.getCode()); |
| | | // if(Objects.isNull(qwIdBaseResponse)||Objects.isNull(qwIdBaseResponse.getErrcode())){ |
| | | // throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"企业微信登录码解析失败,请联系管理员"); |
| | | // } |
| | | // if(!Constants.equalsInteger(qwIdBaseResponse.getErrcode(),Constants.ZERO)){ |
| | | // throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"企业微信登录失败:"+qwIdBaseResponse.getErrmsg()); |
| | | // } |
| | | // if(Objects.isNull(qwIdBaseResponse.getData())){ |
| | | // throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"企业微信用户信息解析失败,请联系管理员"); |
| | | // } |
| | | // String qwId = qwIdBaseResponse.getData(); |
| | | String qwId = dto.getCode(); |
| | | QywxBaseResponse<String> qwIdBaseResponse = QywxUtil.getUserInfoByCode(token,dto.getCode()); |
| | | if(Objects.isNull(qwIdBaseResponse)||Objects.isNull(qwIdBaseResponse.getErrcode())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"企业微信登录码解析失败,请联系管理员"); |
| | | } |
| | | if(!Constants.equalsInteger(qwIdBaseResponse.getErrcode(),Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"企业微信登录失败:"+qwIdBaseResponse.getErrmsg()); |
| | | } |
| | | if(Objects.isNull(qwIdBaseResponse.getData())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"企业微信用户信息解析失败,请联系管理员"); |
| | | } |
| | | String qwId = qwIdBaseResponse.getData(); |
| | | // String qwId = dto.getCode(); |
| | | Member member = memberMapper.selectOne(new QueryWrapper<Member>().lambda().eq(Member::getQwId,qwId).eq(Member::getIsdeleted,Constants.ZERO).last(" limit 1 ")); |
| | | if(Objects.isNull(member)){ |
| | | //根据企业微信ID 查询用户信息 |