|
|
|
@ -1,13 +1,5 @@
|
|
|
|
|
package com.ruoyi.system.service.impl;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.text.DateFormat;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
@ -41,6 +33,13 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.text.DateFormat;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 比赛信息Service业务层处理
|
|
|
|
@ -50,8 +49,7 @@ import javax.annotation.Resource;
|
|
|
|
|
*/
|
|
|
|
|
@Log4j2
|
|
|
|
|
@Service
|
|
|
|
|
public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Competition> implements ICompetitionService
|
|
|
|
|
{
|
|
|
|
|
public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Competition> implements ICompetitionService {
|
|
|
|
|
@Resource
|
|
|
|
|
private CompetitionMapper competitionMapper;
|
|
|
|
|
@Resource
|
|
|
|
@ -87,6 +85,7 @@ public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Compe
|
|
|
|
|
private String winLocation;
|
|
|
|
|
@Value("${image.domainName}")
|
|
|
|
|
private String domainName;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询比赛信息
|
|
|
|
|
*
|
|
|
|
@ -94,8 +93,7 @@ public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Compe
|
|
|
|
|
* @return 比赛信息
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Competition selectCompetitionById(Long id)
|
|
|
|
|
{
|
|
|
|
|
public Competition selectCompetitionById(Long id) {
|
|
|
|
|
return competitionMapper.selectCompetitionById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -106,8 +104,7 @@ public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Compe
|
|
|
|
|
* @return 比赛信息
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<Competition> selectCompetitionList(Competition competition)
|
|
|
|
|
{
|
|
|
|
|
public List<Competition> selectCompetitionList(Competition competition) {
|
|
|
|
|
return competitionMapper.selectCompetitionList(competition);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -118,8 +115,7 @@ public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Compe
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public int insertCompetition(Competition competition)
|
|
|
|
|
{
|
|
|
|
|
public int insertCompetition(Competition competition) {
|
|
|
|
|
return competitionMapper.insertCompetition(competition);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -130,8 +126,7 @@ public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Compe
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public int updateCompetition(Competition competition)
|
|
|
|
|
{
|
|
|
|
|
public int updateCompetition(Competition competition) {
|
|
|
|
|
return competitionMapper.updateCompetition(competition);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -142,8 +137,7 @@ public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Compe
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public int deleteCompetitionByIds(Long[] ids)
|
|
|
|
|
{
|
|
|
|
|
public int deleteCompetitionByIds(Long[] ids) {
|
|
|
|
|
return competitionMapper.deleteCompetitionByIds(ids);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -154,18 +148,17 @@ public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Compe
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public int deleteCompetitionById(Long id)
|
|
|
|
|
{
|
|
|
|
|
public int deleteCompetitionById(Long id) {
|
|
|
|
|
return competitionMapper.deleteCompetitionById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public WxAppletsCodeVo genCompetitionCommonAqrSpread(WxAppletsCodeVo wxAppletsCodeVo) {
|
|
|
|
|
Object key = redisService.getCacheObject(CacheConstants.COMPETITION_SPREAD_AQR_CODE + wxAppletsCodeVo.getScene());
|
|
|
|
|
if(ObjectUtils.isEmpty(key)){
|
|
|
|
|
if (ObjectUtils.isEmpty(key)) {
|
|
|
|
|
wxAppletsCodeVo = wxApplesCodeService.genWxApplesAqrCode(wxAppletsCodeVo);
|
|
|
|
|
redisService.setCacheObject(CacheConstants.COMPETITION_SPREAD_AQR_CODE + wxAppletsCodeVo.getScene(),wxAppletsCodeVo.getCodeImgUrl(),30L, TimeUnit.DAYS);
|
|
|
|
|
}else {
|
|
|
|
|
redisService.setCacheObject(CacheConstants.COMPETITION_SPREAD_AQR_CODE + wxAppletsCodeVo.getScene(), wxAppletsCodeVo.getCodeImgUrl(), 30L, TimeUnit.DAYS);
|
|
|
|
|
} else {
|
|
|
|
|
wxAppletsCodeVo.setCodeImgUrl((String) key);
|
|
|
|
|
}
|
|
|
|
|
return wxAppletsCodeVo;
|
|
|
|
@ -173,22 +166,37 @@ public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Compe
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<Competition> getCompetitionByCondition(CompetitionVo competition) {
|
|
|
|
|
return competitionMapper.getCompetitionByCondition(competition);
|
|
|
|
|
List<Competition> competitionList = competitionMapper.getCompetitionByCondition(competition);
|
|
|
|
|
for (Competition comp : competitionList) {
|
|
|
|
|
if (comp.getCompetitionNature() == 0) {
|
|
|
|
|
WxBasketballTeam mainTeam = wxBasketballTeamMapper.selectWxBasketballTeamById(comp.getMainTeamId());
|
|
|
|
|
if (ObjectUtil.isNotEmpty(mainTeam)) {
|
|
|
|
|
comp.setMainTeamLogo(mainTeam.getTeamLogo());
|
|
|
|
|
}
|
|
|
|
|
if (comp.getGuestTeamId() != null) {
|
|
|
|
|
WxBasketballTeam guestTeam = wxBasketballTeamMapper.selectWxBasketballTeamById(comp.getGuestTeamId());
|
|
|
|
|
if (ObjectUtil.isNotEmpty(guestTeam)) {
|
|
|
|
|
comp.setGuestTeamLogo(guestTeam.getTeamLogo());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return competitionList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public CompetitionExcleVo getTeamEnrollExcleImpData(Long competitionId, Long userId) {
|
|
|
|
|
CompetitionExcleVo excleVo = new CompetitionExcleVo();
|
|
|
|
|
Competition competition = competitionMapper.selectCompetitionById(competitionId);
|
|
|
|
|
if(ObjectUtil.isNull(competition)){
|
|
|
|
|
if (ObjectUtil.isNull(competition)) {
|
|
|
|
|
return excleVo;
|
|
|
|
|
}
|
|
|
|
|
//todo 获取球队数据
|
|
|
|
|
CompetitionOfTeam team = competitionOfTeamMapper.selectOneByUserId(competitionId,String.valueOf(userId));
|
|
|
|
|
if(ObjectUtil.isNull(team)){
|
|
|
|
|
CompetitionOfTeam team = competitionOfTeamMapper.selectOneByUserId(competitionId, String.valueOf(userId));
|
|
|
|
|
if (ObjectUtil.isNull(team)) {
|
|
|
|
|
return excleVo;
|
|
|
|
|
}
|
|
|
|
|
BeanUtil.copyProperties(competition,excleVo);
|
|
|
|
|
BeanUtil.copyProperties(competition, excleVo);
|
|
|
|
|
excleVo.setOfTeam(team);
|
|
|
|
|
//todo 查询球队队员数据
|
|
|
|
|
CompetitionMembers condtion = new CompetitionMembers();
|
|
|
|
@ -202,15 +210,15 @@ public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Compe
|
|
|
|
|
@Override
|
|
|
|
|
public CompetitionResponse getCompetitionById(Long id) {
|
|
|
|
|
//查询比赛信息
|
|
|
|
|
CompetitionResponse competitionResponse=new CompetitionResponse();
|
|
|
|
|
CompetitionResponse competitionResponse = new CompetitionResponse();
|
|
|
|
|
Competition competition = competitionMapper.selectCompetitionById(id);
|
|
|
|
|
if(UtilTool.isNull(competition)){
|
|
|
|
|
if (UtilTool.isNull(competition)) {
|
|
|
|
|
throw new ServiceException("根据id未查询到约战信息");
|
|
|
|
|
}
|
|
|
|
|
BeanUtils.copyProperties(competition,competitionResponse);
|
|
|
|
|
BeanUtils.copyProperties(competition, competitionResponse);
|
|
|
|
|
//查询比赛参与人员列表数据
|
|
|
|
|
List<CompetitionMembersVo> membersList = competitionMembersMapper.getCompetitionMembersByCompetitionId(competition.getId());
|
|
|
|
|
if(competition.getCompetitionNature().intValue()==0) {
|
|
|
|
|
if (competition.getCompetitionNature().intValue() == 0) {
|
|
|
|
|
Map<Long, List<CompetitionMembersVo>> groupByTeamIdMap = membersList.stream().collect(Collectors.groupingBy(CompetitionMembers::getCompetitionTeamId)); //查询主队下的队员信息
|
|
|
|
|
for (Map.Entry<Long, List<CompetitionMembersVo>> entry : groupByTeamIdMap.entrySet()) {
|
|
|
|
|
if (!StringUtils.isEmpty(competition.getMainTeamId()) && entry.getKey().equals(competition.getMainTeamId())) {
|
|
|
|
@ -221,14 +229,14 @@ public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Compe
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//查询球队的合照
|
|
|
|
|
List<Long> teamIds =new ArrayList<>();
|
|
|
|
|
if(!StringUtils.isEmpty(competition.getMainTeamId())) {
|
|
|
|
|
List<Long> teamIds = new ArrayList<>();
|
|
|
|
|
if (!StringUtils.isEmpty(competition.getMainTeamId())) {
|
|
|
|
|
teamIds.add(competition.getMainTeamId());
|
|
|
|
|
}
|
|
|
|
|
if(!StringUtils.isEmpty(competition.getGuestTeamId())) {
|
|
|
|
|
if (!StringUtils.isEmpty(competition.getGuestTeamId())) {
|
|
|
|
|
teamIds.add(competition.getGuestTeamId());
|
|
|
|
|
}
|
|
|
|
|
if(teamIds.size()>0) {
|
|
|
|
|
if (teamIds.size() > 0) {
|
|
|
|
|
List<WxBasketballTeam> basketballTeamList = wxBasketballTeamMapper.selectBatchIds(teamIds);
|
|
|
|
|
CompetitionTeamVsTeam competitionTeamVsTeam = new CompetitionTeamVsTeam();
|
|
|
|
|
for (WxBasketballTeam team : basketballTeamList) {
|
|
|
|
@ -256,26 +264,26 @@ public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Compe
|
|
|
|
|
public Boolean establishCompetition(CompetitionVo entity) {
|
|
|
|
|
//使用赛会名称加密缓存防止重复提交
|
|
|
|
|
Object key = redisService.getCacheObject(Constants.COMPETITION_CREATE_KEY + DigestUtil.md5(entity.getCompetitionName().trim()));
|
|
|
|
|
if(ObjectUtil.isNotNull(key)){
|
|
|
|
|
if (ObjectUtil.isNotNull(key)) {
|
|
|
|
|
throw new ServiceException("当前创建赛会数据已提交到系统,毋须重复提交!");
|
|
|
|
|
}
|
|
|
|
|
LoginUser user = SecurityUtils.getLoginUser();
|
|
|
|
|
entity.setCreatedBy(String.valueOf(user.getUserid()));
|
|
|
|
|
entity.setCreatedTime(new Date());
|
|
|
|
|
DateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
|
entity.setCompetitionCode(sdf.format(new Date())+ RandomStringUtils.randomNumeric(6));
|
|
|
|
|
entity.setCompetitionCode(sdf.format(new Date()) + RandomStringUtils.randomNumeric(6));
|
|
|
|
|
//判断是否已经存在
|
|
|
|
|
List<Competition> existList = competitionMapper.selectCompetitionList( Competition.builder().competitionName(entity.getCompetitionName()).competitionNature(entity.getCompetitionNature()).build());
|
|
|
|
|
if(existList.size()>0) {
|
|
|
|
|
List<Competition> existList = competitionMapper.selectCompetitionList(Competition.builder().competitionName(entity.getCompetitionName()).competitionNature(entity.getCompetitionNature()).build());
|
|
|
|
|
if (existList.size() > 0) {
|
|
|
|
|
throw new ServiceException("当前赛会已存在,毋须重复提交!");
|
|
|
|
|
}
|
|
|
|
|
//小程序-推送赛会通知给系统管理员。管理员好及时去审核赛会
|
|
|
|
|
List<UserRole> userRoles = userRoleMapper.selectUserRoleList(UserRole.builder().roleCode(UserRoles.ADMIN.code()).build());
|
|
|
|
|
List<Long> userIds = userRoles.stream().map(UserRole::getUserId).collect(Collectors.toList());
|
|
|
|
|
List<WxUser> managerUsers = wxUserMapper.listByIds(userIds);
|
|
|
|
|
if(!StringUtils.isEmpty(managerUsers)&&!StringUtils.isEmpty(managerUsers.size()>0)){
|
|
|
|
|
for (WxUser managerUser:managerUsers){
|
|
|
|
|
if(!StringUtils.isEmpty(managerUser.getOpenid())) {
|
|
|
|
|
if (!StringUtils.isEmpty(managerUsers) && !StringUtils.isEmpty(managerUsers.size() > 0)) {
|
|
|
|
|
for (WxUser managerUser : managerUsers) {
|
|
|
|
|
if (!StringUtils.isEmpty(managerUser.getOpenid())) {
|
|
|
|
|
WxMssVo wxMssVo = new WxMssVo();
|
|
|
|
|
wxMssVo.setTemplate_id(WxAppletsTemplateIdsEnum.COMPETITION_SIGN_UP.getCode());
|
|
|
|
|
wxMssVo.setTouser(managerUser.getOpenid());
|
|
|
|
@ -289,8 +297,8 @@ public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Compe
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(competitionMapper.insertCompetition(entity)>0){
|
|
|
|
|
redisService.setCacheObject(Constants.COMPETITION_CREATE_KEY + DigestUtil.md5(entity.getCompetitionName().trim()),entity.getCompetitionName(),20L,TimeUnit.SECONDS);
|
|
|
|
|
if (competitionMapper.insertCompetition(entity) > 0) {
|
|
|
|
|
redisService.setCacheObject(Constants.COMPETITION_CREATE_KEY + DigestUtil.md5(entity.getCompetitionName().trim()), entity.getCompetitionName(), 20L, TimeUnit.SECONDS);
|
|
|
|
|
}
|
|
|
|
|
return Boolean.TRUE;
|
|
|
|
|
}
|
|
|
|
@ -299,27 +307,27 @@ public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Compe
|
|
|
|
|
public Boolean challengeConfirm(Competition entity) {
|
|
|
|
|
//使用赛会名称加密缓存防止重复提交
|
|
|
|
|
Object key = redisService.getCacheObject(Constants.COMPETITION_CREATE_KEY + DigestUtil.md5(entity.getCompetitionName().trim()));
|
|
|
|
|
if(UtilTool.isNotNull(key)){
|
|
|
|
|
if (UtilTool.isNotNull(key)) {
|
|
|
|
|
throw new ServiceException("当前创建赛会数据已提交到系统,毋须重复提交!");
|
|
|
|
|
}
|
|
|
|
|
LoginUser user = SecurityUtils.getLoginUser();
|
|
|
|
|
entity.setCreatedBy(String.valueOf(user.getUserid()));
|
|
|
|
|
entity.setCreatedTime(new Date());
|
|
|
|
|
DateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
|
entity.setCompetitionCode(sdf.format(new Date())+ RandomStringUtils.randomNumeric(6));
|
|
|
|
|
entity.setCompetitionCode(sdf.format(new Date()) + RandomStringUtils.randomNumeric(6));
|
|
|
|
|
//判断是否已经存在
|
|
|
|
|
List<Competition> dbList = competitionMapper.selectCompetitionList(Competition.builder().competitionNature(entity.getCompetitionNature())
|
|
|
|
|
.competitionName(entity.getCompetitionName()).build());
|
|
|
|
|
if(dbList.size()>0) {
|
|
|
|
|
if (dbList.size() > 0) {
|
|
|
|
|
throw new ServiceException("当前赛会已存在,毋须重复提交!");
|
|
|
|
|
}
|
|
|
|
|
//小程序-推送赛会通知给系统管理员。管理员好及时去审核赛会
|
|
|
|
|
List<UserRole> userRoles = userRoleMapper.selectUserRoleList(UserRole.builder().roleCode(UserRoles.ADMIN.code()).build());
|
|
|
|
|
List<Long> userIds = userRoles.stream().map(UserRole::getUserId).collect(Collectors.toList());
|
|
|
|
|
List<WxUser> managerUsers = wxUserMapper.listByIds(userIds);
|
|
|
|
|
if(!StringUtils.isEmpty(managerUsers)&&!StringUtils.isEmpty(managerUsers.size()>0)){
|
|
|
|
|
for (WxUser managerUser:managerUsers){
|
|
|
|
|
if(!StringUtils.isEmpty(managerUser.getOpenid())) {
|
|
|
|
|
if (!StringUtils.isEmpty(managerUsers) && !StringUtils.isEmpty(managerUsers.size() > 0)) {
|
|
|
|
|
for (WxUser managerUser : managerUsers) {
|
|
|
|
|
if (!StringUtils.isEmpty(managerUser.getOpenid())) {
|
|
|
|
|
WxMssVo wxMssVo = new WxMssVo();
|
|
|
|
|
wxMssVo.setTemplate_id(WxAppletsTemplateIdsEnum.COMPETITION_SIGN_UP.getCode());
|
|
|
|
|
wxMssVo.setTouser(managerUser.getOpenid());
|
|
|
|
@ -333,11 +341,11 @@ public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Compe
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(ObjectUtil.isNull(entity.getId())) {
|
|
|
|
|
if (ObjectUtil.isNull(entity.getId())) {
|
|
|
|
|
if (competitionMapper.insertCompetition(entity) > 0) {
|
|
|
|
|
redisService.setCacheObject(Constants.COMPETITION_CREATE_KEY + DigestUtil.md5(entity.getCompetitionName().trim()), entity.getCompetitionName(), 20L, TimeUnit.SECONDS);
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
competitionMapper.updateCompetition(entity);
|
|
|
|
|
}
|
|
|
|
|
return Boolean.TRUE;
|
|
|
|
@ -345,16 +353,16 @@ public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Compe
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<Competition> getMyJoinCompetition(CompetitionVo competition) {
|
|
|
|
|
List<Competition> list=competitionMapper.getMyJoinCompetition(competition);
|
|
|
|
|
for (Competition comp:list){
|
|
|
|
|
if(competition.getCompetitionNature()==0){
|
|
|
|
|
List<Competition> list = competitionMapper.getMyJoinCompetition(competition);
|
|
|
|
|
for (Competition comp : list) {
|
|
|
|
|
if (competition.getCompetitionNature() == 0) {
|
|
|
|
|
WxBasketballTeam mainTeam = wxBasketballTeamMapper.selectWxBasketballTeamById(comp.getMainTeamId());
|
|
|
|
|
if(!org.springframework.util.ObjectUtils.isEmpty(mainTeam)) {
|
|
|
|
|
if (!org.springframework.util.ObjectUtils.isEmpty(mainTeam)) {
|
|
|
|
|
comp.setMainTeamLogo(mainTeam.getTeamLogo());
|
|
|
|
|
}
|
|
|
|
|
if(comp.getGuestTeamId()!=null) {
|
|
|
|
|
if (comp.getGuestTeamId() != null) {
|
|
|
|
|
WxBasketballTeam guestTeam = wxBasketballTeamMapper.selectWxBasketballTeamById(comp.getGuestTeamId());
|
|
|
|
|
if(!org.springframework.util.ObjectUtils.isEmpty(guestTeam)) {
|
|
|
|
|
if (!org.springframework.util.ObjectUtils.isEmpty(guestTeam)) {
|
|
|
|
|
comp.setGuestTeamLogo(guestTeam.getTeamLogo());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -362,11 +370,12 @@ public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Compe
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean add(Competition entity) {
|
|
|
|
|
entity.setCompetitionNature(0);
|
|
|
|
|
Long id=entity.getId();
|
|
|
|
|
Long id = entity.getId();
|
|
|
|
|
LoginUser user = SecurityUtils.getLoginUser();
|
|
|
|
|
//判断是否存在
|
|
|
|
|
List<Competition> competitions = competitionMapper.selectCompetitionList(Competition.builder()
|
|
|
|
@ -374,11 +383,11 @@ public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Compe
|
|
|
|
|
.mainTeamId(entity.getMainTeamId())
|
|
|
|
|
.buildingId(entity.getBuildingId())
|
|
|
|
|
.cityCode(entity.getCityCode()).build());
|
|
|
|
|
if(competitions.size()>0){
|
|
|
|
|
if (competitions.size() > 0) {
|
|
|
|
|
throw new ServiceException("当前约战数据已存在,毋须重复提交!");
|
|
|
|
|
}
|
|
|
|
|
//获取场馆数据
|
|
|
|
|
if(!StringUtils.isEmpty(entity.getBuildingId())){
|
|
|
|
|
if (!StringUtils.isEmpty(entity.getBuildingId())) {
|
|
|
|
|
WxBuildingInfo buildingInfo = wxBuildingInfoService.selectWxBuildingInfoById(entity.getBuildingId());
|
|
|
|
|
entity.setBuildingName(buildingInfo.getBuildingName());
|
|
|
|
|
entity.setCityCode(buildingInfo.getCityCode());
|
|
|
|
@ -391,12 +400,12 @@ public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Compe
|
|
|
|
|
entity.setCreatedTime(new Date());
|
|
|
|
|
entity.setFounder(user.getUserid());
|
|
|
|
|
entity.setStatus(CompetitionStatusEnum.TREATY_WAR.getValue());
|
|
|
|
|
if(ObjectUtil.isNull(entity.getId())){
|
|
|
|
|
if (ObjectUtil.isNull(entity.getId())) {
|
|
|
|
|
competitionMapper.insertCompetition(entity);
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
competitionMapper.updateCompetition(entity);
|
|
|
|
|
}
|
|
|
|
|
if(!StringUtils.isEmpty(entity.getGuestTeamId())) {
|
|
|
|
|
if (!StringUtils.isEmpty(entity.getGuestTeamId())) {
|
|
|
|
|
TeamMembers teamMembers = teamMembersService.getOneByTeamIdAndRoleCode(entity.getGuestTeamId(), RoleEnum.TEAM_MANAGER.getCode());
|
|
|
|
|
//如果指定了约战的对象就需要给约战的球队的队长发一个消息
|
|
|
|
|
Message message = new Message();
|
|
|
|
@ -408,23 +417,23 @@ public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Compe
|
|
|
|
|
message.setSourceId(entity.getId());
|
|
|
|
|
message.setFlowEntity(JSON.toJSONString(entity));
|
|
|
|
|
message.setCreatedTime(new Date());
|
|
|
|
|
message.setMessageTitle("您收到一条【"+entity.getMainTeamName()+"】"+FowTypeEnum.MAKE_AN_APPOINTMENT.getDesc()+",请及时处理");
|
|
|
|
|
message.setMessageTitle("您收到一条【" + entity.getMainTeamName() + "】" + FowTypeEnum.MAKE_AN_APPOINTMENT.getDesc() + ",请及时处理");
|
|
|
|
|
messageService.insertMessage(message);
|
|
|
|
|
//小程序-查询用户数据看看是否可以推送服务消息根据unionId是否存在
|
|
|
|
|
WxUser guestUser = wxUserMapper.selectWxUserById(teamMembers.getUserId());
|
|
|
|
|
if(!StringUtils.isEmpty(guestUser)&&!StringUtils.isEmpty(guestUser.getOpenid())){
|
|
|
|
|
WxMssVo wxMssVo=new WxMssVo();
|
|
|
|
|
if (!StringUtils.isEmpty(guestUser) && !StringUtils.isEmpty(guestUser.getOpenid())) {
|
|
|
|
|
WxMssVo wxMssVo = new WxMssVo();
|
|
|
|
|
wxMssVo.setTemplate_id(WxAppletsTemplateIdsEnum.TREATY_WAR.getCode());
|
|
|
|
|
wxMssVo.setTouser(guestUser.getOpenid());
|
|
|
|
|
Map<String, TemplateDataVo> map = new HashMap<>();
|
|
|
|
|
map.put("thing1",new TemplateDataVo(entity.getMainTeamName()));
|
|
|
|
|
map.put("thing2",new TemplateDataVo(entity.getGuestTeamName()));
|
|
|
|
|
map.put("thing3",new TemplateDataVo("您有新的约战信息,请在小程序中进行处理"));
|
|
|
|
|
map.put("thing1", new TemplateDataVo(entity.getMainTeamName()));
|
|
|
|
|
map.put("thing2", new TemplateDataVo(entity.getGuestTeamName()));
|
|
|
|
|
map.put("thing3", new TemplateDataVo("您有新的约战信息,请在小程序中进行处理"));
|
|
|
|
|
wxMssVo.setData(map);
|
|
|
|
|
wxAppletsService.pushOneUser(wxMssVo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(StringUtils.isEmpty(id)) {
|
|
|
|
|
if (StringUtils.isEmpty(id)) {
|
|
|
|
|
//保存创建人到比赛参与人员表
|
|
|
|
|
CompetitionMembers competitionMembers = new CompetitionMembers();
|
|
|
|
|
competitionMembers.setCompetitionId(entity.getId());
|
|
|
|
@ -439,6 +448,7 @@ public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Compe
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean edit(Competition entity) {
|
|
|
|
|
LoginUser user = SecurityUtils.getLoginUser();
|
|
|
|
@ -450,7 +460,7 @@ public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Compe
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
@Override
|
|
|
|
|
public CompetitionExcleVo importExcleData(Long competitionId,Map<String, PictureData> maplist, Sheet sheet) {
|
|
|
|
|
public CompetitionExcleVo importExcleData(Long competitionId, Map<String, PictureData> maplist, Sheet sheet) {
|
|
|
|
|
CompetitionExcleVo excleVo = new CompetitionExcleVo();
|
|
|
|
|
String time = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
|
|
|
|
//System.out.println("获取到精确到日的时间格式为"+time);
|
|
|
|
@ -531,13 +541,13 @@ public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Compe
|
|
|
|
|
throw new CheckedException("球队人数不能为空");
|
|
|
|
|
}
|
|
|
|
|
//todo 校验是否是整数
|
|
|
|
|
if(!NumberUtil.isInteger(teamUserNum)){
|
|
|
|
|
if (!NumberUtil.isInteger(teamUserNum)) {
|
|
|
|
|
throw new CheckedException("球队人数必须是正整数");
|
|
|
|
|
}
|
|
|
|
|
//todo 获取到数据后,开始保存数据
|
|
|
|
|
LoginUser user = SecurityUtils.getLoginUser();
|
|
|
|
|
String userId = null;
|
|
|
|
|
if(ObjectUtil.isNotNull(user)&&ObjectUtil.isNotNull(user.getUserid())){
|
|
|
|
|
if (ObjectUtil.isNotNull(user) && ObjectUtil.isNotNull(user.getUserid())) {
|
|
|
|
|
userId = String.valueOf(user.getUserid());
|
|
|
|
|
}
|
|
|
|
|
CompetitionOfTeamVo team = new CompetitionOfTeamVo();
|
|
|
|
@ -574,7 +584,7 @@ public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Compe
|
|
|
|
|
if (UtilTool.isNotNull(competitionOfTeam)) {
|
|
|
|
|
team.setId(competitionOfTeam.getId());
|
|
|
|
|
competitionOfTeamMapper.updateCompetitionOfTeam(team);
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
competitionOfTeamMapper.insertCompetitionOfTeam(team);
|
|
|
|
|
}
|
|
|
|
|
excleVo.setOfTeam(team);
|
|
|
|
@ -618,8 +628,8 @@ public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Compe
|
|
|
|
|
if (cell != null) {
|
|
|
|
|
cell.setCellType(CellType.STRING);
|
|
|
|
|
//todo 校验是否是整数
|
|
|
|
|
if(!NumberUtil.isInteger(cell.getStringCellValue())){
|
|
|
|
|
throw new CheckedException(membersVo.getRealName()+" 的身高必须是正整数");
|
|
|
|
|
if (!NumberUtil.isInteger(cell.getStringCellValue())) {
|
|
|
|
|
throw new CheckedException(membersVo.getRealName() + " 的身高必须是正整数");
|
|
|
|
|
}
|
|
|
|
|
membersVo.setHeight(new BigDecimal(cell.getStringCellValue()));
|
|
|
|
|
}
|
|
|
|
@ -628,8 +638,8 @@ public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Compe
|
|
|
|
|
if (cell != null) {
|
|
|
|
|
cell.setCellType(CellType.STRING);
|
|
|
|
|
//todo 校验是否是整数
|
|
|
|
|
if(!NumberUtil.isInteger(cell.getStringCellValue())){
|
|
|
|
|
throw new CheckedException(membersVo.getRealName()+" 的体重必须是正整数");
|
|
|
|
|
if (!NumberUtil.isInteger(cell.getStringCellValue())) {
|
|
|
|
|
throw new CheckedException(membersVo.getRealName() + " 的体重必须是正整数");
|
|
|
|
|
}
|
|
|
|
|
membersVo.setWeight(new BigDecimal(cell.getStringCellValue()));
|
|
|
|
|
}
|
|
|
|
@ -653,9 +663,9 @@ public class CompetitionServiceImpl extends ServiceImpl<CompetitionMapper, Compe
|
|
|
|
|
//membersVo.setAvatar(domainName+datePath+newFileName);
|
|
|
|
|
//保存图片
|
|
|
|
|
PictureData pictureData2 = maplist.get(i + "_0");
|
|
|
|
|
log.info(membersVo.getRealName()+" 开始导入,图片位置"+i + "_0");
|
|
|
|
|
log.info(membersVo.getRealName() + " 开始导入,图片位置" + i + "_0");
|
|
|
|
|
if (pictureData2 == null) {
|
|
|
|
|
throw new CheckedException(membersVo.getRealName()+" 的头像插入方式错误,请先选中单元格然后插入图片");
|
|
|
|
|
throw new CheckedException(membersVo.getRealName() + " 的头像插入方式错误,请先选中单元格然后插入图片");
|
|
|
|
|
}
|
|
|
|
|
byte[] data2 = pictureData2.getData();
|
|
|
|
|
String newFileName2 = UUID.randomUUID() + "_0.jpg";
|
|
|
|
|