|
|
@ -9,31 +9,24 @@ import cn.hutool.core.util.StrUtil; |
|
|
|
import com.ccsens.mt.bean.dto.CompeteDto; |
|
|
|
import com.ccsens.mt.bean.dto.ProvinceCompeteDto; |
|
|
|
import com.ccsens.mt.bean.po.*; |
|
|
|
import com.ccsens.mt.bean.vo.CompeteVo; |
|
|
|
import com.ccsens.mt.bean.vo.ProvinceCompeteVo; |
|
|
|
import com.ccsens.mt.persist.dao.CompeteCompanyDao; |
|
|
|
import com.ccsens.mt.persist.dao.CompetePlayerDao; |
|
|
|
import com.ccsens.mt.persist.dao.CompeteTeamDao; |
|
|
|
import com.ccsens.mt.persist.dao.CompeteTimeDao; |
|
|
|
import com.ccsens.mt.persist.mapper.*; |
|
|
|
import com.ccsens.mt.persist.mapper.CommonFileMapper; |
|
|
|
import com.ccsens.mt.persist.mapper.CompeteCoachMapper; |
|
|
|
import com.ccsens.mt.persist.mapper.CompetePlayerMapper; |
|
|
|
import com.ccsens.mt.util.Constant; |
|
|
|
import com.ccsens.util.CodeEnum; |
|
|
|
import com.ccsens.util.PropUtil; |
|
|
|
import com.ccsens.util.UploadFileUtil_Servlet3; |
|
|
|
import com.ccsens.util.WebConstant; |
|
|
|
import com.ccsens.util.exception.BaseException; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.aspectj.apache.bcel.classfile.Code; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.servlet.http.Part; |
|
|
|
import java.io.File; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
@ -51,8 +44,6 @@ public class ProvinceService implements IProvinceService { |
|
|
|
@Resource |
|
|
|
private CompeteTimeDao competeTimeDao; |
|
|
|
@Resource |
|
|
|
private CommonFileMapper commonFileMapper; |
|
|
|
@Resource |
|
|
|
private CompetePlayerDao competePlayerDao; |
|
|
|
@Resource |
|
|
|
private CompeteCoachMapper competeCoachMapper; |
|
|
@ -128,8 +119,9 @@ public class ProvinceService implements IProvinceService { |
|
|
|
CompetePlayer player = new CompetePlayer(); |
|
|
|
player.setId(snowflake.nextId()); |
|
|
|
player.setName(param.getPlayerName()); |
|
|
|
player.setGender((byte) param.getGender()); |
|
|
|
|
|
|
|
|
|
|
|
if(ObjectUtil.isNull(param.getCompeteId())){ throw new BaseException(CodeEnum.NOT_COMPANY); } |
|
|
|
//身份证不能为空,且正确
|
|
|
|
if(StrUtil.isEmpty(param.getIdCard()) || !IdcardUtil.isValidCard(param.getIdCard())){throw new BaseException(CodeEnum.ID_CARD_ERROR);} |
|
|
|
//是否已注册
|
|
|
@ -138,14 +130,26 @@ public class ProvinceService implements IProvinceService { |
|
|
|
if(competePlayerDao.countByExample(competePlayerExample) != 0){ |
|
|
|
throw new BaseException(CodeEnum.ID_CARD_ALREADY); |
|
|
|
} |
|
|
|
|
|
|
|
if(ObjectUtil.isNull(param.getCompeteId())){ throw new BaseException(CodeEnum.NOT_COMPANY); } |
|
|
|
if(ObjectUtil.isNull(param.getGroupId())){ throw new BaseException(CodeEnum.MT_NOT_GROUP); } |
|
|
|
//检查性别与组别是否匹配
|
|
|
|
CompeteGroup competeGroup = competeGroupMapper.selectByPrimaryKey(param.getGroupId()); |
|
|
|
if(ObjectUtil.isNull(competeGroup) || param.getGender() != competeGroup.getSex()){ |
|
|
|
throw new BaseException(CodeEnum.MT_NOT_GROUP); |
|
|
|
} |
|
|
|
//验证性别是否正确
|
|
|
|
int gender = IdcardUtil.getGenderByIdCard(param.getIdCard()); |
|
|
|
if(gender != param.getGender()){ |
|
|
|
throw new BaseException(CodeEnum.GENDER_ERROR); |
|
|
|
} |
|
|
|
//通过groupRemark和性别查找选手组别信息
|
|
|
|
CompeteGroup competeGroup = new CompeteGroup(); |
|
|
|
CompeteGroupExample competeGroupExample = new CompeteGroupExample(); |
|
|
|
competeGroupExample.createCriteria().andSexEqualTo((byte) param.getGender()).andGroupRemarkEqualTo((byte) param.getGroupRemark()); |
|
|
|
List<CompeteGroup> groupList = competeGroupMapper.selectByExample(competeGroupExample); |
|
|
|
if(CollectionUtil.isNotEmpty(groupList)){ |
|
|
|
competeGroup = groupList.get(0); |
|
|
|
} |
|
|
|
// if(ObjectUtil.isNull(param.getGroupId())){ throw new BaseException(CodeEnum.MT_NOT_GROUP); }
|
|
|
|
|
|
|
|
// //检查性别与组别是否匹配
|
|
|
|
// CompeteGroup competeGroup = competeGroupMapper.selectByPrimaryKey(param.getGroupId());
|
|
|
|
// if(ObjectUtil.isNull(competeGroup) || param.getGender() != competeGroup.getSex()){
|
|
|
|
// throw new BaseException(CodeEnum.MT_NOT_GROUP);
|
|
|
|
// }
|
|
|
|
//获取选手年龄
|
|
|
|
int ageByIdCard = IdcardUtil.getAgeByIdCard(param.getIdCard()); |
|
|
|
//判断年龄和分组是否匹配
|
|
|
@ -162,28 +166,17 @@ public class ProvinceService implements IProvinceService { |
|
|
|
if(ObjectUtil.isNull(param.getStudentRecord())){ throw new BaseException(CodeEnum.PHOTO_IS_EMPTY.mtMsgPhoto("学籍证明")); } |
|
|
|
if(ObjectUtil.isNull(param.getHealthRecord())){ throw new BaseException(CodeEnum.PHOTO_IS_EMPTY.mtMsgPhoto("健康证明")); } |
|
|
|
if(ObjectUtil.isNull(param.getInsuranceRecord())){ throw new BaseException(CodeEnum.PHOTO_IS_EMPTY.mtMsgPhoto("保险证明")); } |
|
|
|
player.setGender((byte) param.getGender()); |
|
|
|
player.setIdCard(param.getIdCard()); |
|
|
|
player.setCompanyId(param.getCompeteId()); |
|
|
|
player.setCompeteGroupId(param.getGroupId()); |
|
|
|
player.setCompeteGroupId(competeGroup.getId()); |
|
|
|
player.setGroupRemark((byte) param.getGroupRemark()); |
|
|
|
player.setIdCardFrontFile(param.getIdCardFront()); |
|
|
|
player.setIdCardBackFile(param.getIdCardBack()); |
|
|
|
player.setIdPhotoFile(param.getIdPhone()); |
|
|
|
player.setStudentRecordFile(param.getStudentRecord()); |
|
|
|
player.setHealthRecordFile(param.getHealthRecord()); |
|
|
|
player.setInsuranceRecordFile(param.getInsuranceRecord()); |
|
|
|
|
|
|
|
// //添加身份证正面照片
|
|
|
|
// player.setIdCardFrontFile(uploadPhotoFile(param.getIdCardFront(),userId));
|
|
|
|
// //身份证反面
|
|
|
|
// player.setIdCardBackFile(uploadPhotoFile(param.getIdCardFront(),userId));
|
|
|
|
// //一寸证件照
|
|
|
|
// player.setIdPhotoFile(uploadPhotoFile(param.getIdCardFront(),userId));
|
|
|
|
// //学籍证明
|
|
|
|
// player.setStudentRecordFile(uploadPhotoFile(param.getIdCardFront(),userId));
|
|
|
|
// //健康证明
|
|
|
|
// player.setHealthRecordFile(uploadPhotoFile(param.getIdCardFront(),userId));
|
|
|
|
// //保险证明
|
|
|
|
// player.setInsuranceRecordFile(uploadPhotoFile(param.getIdCardFront(),userId));
|
|
|
|
competePlayerDao.insertSelective(player); |
|
|
|
log.info("新加参赛选手:{}",player); |
|
|
|
}else { |
|
|
@ -191,11 +184,37 @@ public class ProvinceService implements IProvinceService { |
|
|
|
CompetePlayer player = competePlayerDao.selectByPrimaryKey(param.getPlayerId()); |
|
|
|
log.info("查找需要修改的选手信息:{}",player); |
|
|
|
if(ObjectUtil.isNull(player)){ throw new BaseException(CodeEnum.PARAM_ERROR); } |
|
|
|
//身份证不能为空,且正确
|
|
|
|
if(!IdcardUtil.isValidCard(param.getIdCard())){throw new BaseException(CodeEnum.ID_CARD_ERROR);} |
|
|
|
//是否已注册
|
|
|
|
CompetePlayerExample competePlayerExample = new CompetePlayerExample(); |
|
|
|
competePlayerExample.createCriteria().andIdCardEqualTo(param.getIdCard()).andIdNotEqualTo(param.getPlayerId()); |
|
|
|
if(competePlayerDao.countByExample(competePlayerExample) != 0){throw new BaseException(CodeEnum.ID_CARD_ALREADY);} |
|
|
|
//验证性别是否正确
|
|
|
|
int gender = IdcardUtil.getGenderByIdCard(param.getIdCard()); |
|
|
|
if(gender != param.getGender()){ |
|
|
|
throw new BaseException(CodeEnum.GENDER_ERROR); |
|
|
|
} |
|
|
|
//通过groupRemark和性别查找选手组别信息
|
|
|
|
CompeteGroup competeGroup = new CompeteGroup(); |
|
|
|
CompeteGroupExample competeGroupExample = new CompeteGroupExample(); |
|
|
|
competeGroupExample.createCriteria().andSexEqualTo((byte) param.getGender()).andGroupRemarkEqualTo((byte) param.getGroupRemark()); |
|
|
|
List<CompeteGroup> groupList = competeGroupMapper.selectByExample(competeGroupExample); |
|
|
|
if(CollectionUtil.isNotEmpty(groupList)){ |
|
|
|
competeGroup = groupList.get(0); |
|
|
|
} |
|
|
|
//获取选手年龄
|
|
|
|
int ageByIdCard = IdcardUtil.getAgeByIdCard(param.getIdCard()); |
|
|
|
//判断年龄和分组是否匹配
|
|
|
|
if(ageByIdCard < competeGroup.getMinAge() || ageByIdCard > competeGroup.getMaxAge()){ |
|
|
|
throw new BaseException(CodeEnum.MT_NOT_GROUP); |
|
|
|
} |
|
|
|
//字段不为空则修改
|
|
|
|
if(StrUtil.isNotEmpty(param.getPlayerName())){player.setName(param.getPlayerName());} |
|
|
|
if(StrUtil.isNotEmpty(param.getIdCard())){player.setIdCard(param.getIdCard());} |
|
|
|
if(ObjectUtil.isNotNull(param.getGender())){player.setGender((byte) param.getGender());} |
|
|
|
if(ObjectUtil.isNotNull(param.getGroupId())){player.setCompeteGroupId(param.getGroupId());} |
|
|
|
if(ObjectUtil.isNotNull(competeGroup)){player.setCompeteGroupId(competeGroup.getId());} |
|
|
|
if(ObjectUtil.isNotNull(param.getGroupRemark())){player.setGroupRemark((byte) param.getGroupRemark());} |
|
|
|
if(ObjectUtil.isNotNull(param.getCompeteId())){player.setCompanyId(param.getCompeteId());} |
|
|
|
|
|
|
|
if(ObjectUtil.isNotNull(param.getIdCardFront())){player.setIdCardFrontFile(param.getIdCardFront());} |
|
|
@ -204,13 +223,6 @@ public class ProvinceService implements IProvinceService { |
|
|
|
if(ObjectUtil.isNotNull(param.getStudentRecord())){player.setStudentRecordFile(param.getStudentRecord());} |
|
|
|
if(ObjectUtil.isNotNull(param.getHealthRecord())){player.setHealthRecordFile(param.getHealthRecord());} |
|
|
|
if(ObjectUtil.isNotNull(param.getInsuranceRecord())){player.setInsuranceRecordFile(param.getInsuranceRecord());} |
|
|
|
|
|
|
|
// if(ObjectUtil.isNotNull(param.getIdCardFront())){player.setIdCardFrontFile(uploadPhotoFile(param.getIdCardFront(),userId));}
|
|
|
|
// if(ObjectUtil.isNotNull(param.getIdCardBack())){player.setIdCardBackFile(uploadPhotoFile(param.getIdCardFront(),userId));}
|
|
|
|
// if(ObjectUtil.isNotNull(param.getIdPhone())){player.setIdPhotoFile(uploadPhotoFile(param.getIdCardFront(),userId));}
|
|
|
|
// if(ObjectUtil.isNotNull(param.getStudentRecord())){ player.setStudentRecordFile(uploadPhotoFile(param.getIdCardFront(),userId));}
|
|
|
|
// if(ObjectUtil.isNotNull(param.getHealthRecord())){ player.setHealthRecordFile(uploadPhotoFile(param.getIdCardFront(),userId));}
|
|
|
|
// if(ObjectUtil.isNotNull(param.getInsuranceRecord())){ player.setInsuranceRecordFile(uploadPhotoFile(param.getIdCardFront(),userId));}
|
|
|
|
competePlayerDao.updateByPrimaryKeySelective(player); |
|
|
|
} |
|
|
|
} |
|
|
@ -226,27 +238,6 @@ public class ProvinceService implements IProvinceService { |
|
|
|
return competePlayerDao.queryPlayerByCompanyId(param.getCompanyId()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 将上传的图片信息保存,并在数据库添加记录 |
|
|
|
*/ |
|
|
|
private Long uploadPhotoFile(Part file,Long userId) throws Exception { |
|
|
|
log.info("上传文件:{}", file.getSubmittedFileName()); |
|
|
|
String allowedExt = "jpg,jpeg,png"; |
|
|
|
String dir = PropUtil.path; |
|
|
|
String path = UploadFileUtil_Servlet3.uploadFile(file, allowedExt, dir); |
|
|
|
log.info(dir+""+path); |
|
|
|
|
|
|
|
CommonFile fileDo = new CommonFile(); |
|
|
|
String name = file.getSubmittedFileName(); |
|
|
|
fileDo.setId(snowflake.nextId()); |
|
|
|
fileDo.setFileName(name); |
|
|
|
fileDo.setLocation(dir + File.separator + path); |
|
|
|
fileDo.setUserId(userId); |
|
|
|
fileDo.setVisitLocation(PropUtil.imgDomain + Constant.File.UPLOAD_URL + File.separator + path); |
|
|
|
commonFileMapper.insertSelective(fileDo); |
|
|
|
log.info("保存文件:{}", fileDo); |
|
|
|
return fileDo.getId(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@ -385,29 +376,6 @@ public class ProvinceService implements IProvinceService { |
|
|
|
return competeCompanyHeadList; |
|
|
|
} |
|
|
|
|
|
|
|
// @Override
|
|
|
|
// public void saveCoach(CompeteDto.AddCoach param) {
|
|
|
|
// CompeteCoach competeCoach = new CompeteCoach();
|
|
|
|
// Long companyId = param.getCompanyId();
|
|
|
|
// competeCoach.setCompanyId(companyId);
|
|
|
|
// Long cpachId = param.getCoachId();
|
|
|
|
// competeCoach.setId(cpachId);
|
|
|
|
// int identity = param.getIdentity();
|
|
|
|
// competeCoach.setIdentity((byte) identity);
|
|
|
|
// String name = param.getName();
|
|
|
|
// competeCoach.setName(name);
|
|
|
|
// int gender = param.getGender();
|
|
|
|
// competeCoach.setGender((byte) gender);
|
|
|
|
// String phone = param.getPhone();
|
|
|
|
// competeCoach.setPhone(phone);
|
|
|
|
// String idCard = param.getIdCard();
|
|
|
|
// competeCoach.setIdCard(idCard);
|
|
|
|
// Long idPhoto = param.getIdPhoto();
|
|
|
|
// competeCoach.setIdPhoto(idPhoto);
|
|
|
|
// Long coachCertificate = param.getCoachCertificate();
|
|
|
|
// competeCoach.setCoachCertificate(coachCertificate);
|
|
|
|
// competeCoachMapper.insertSelective(competeCoach);
|
|
|
|
// }
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void deleteCoach(CompeteDto.LeaderId param) { |
|
|
@ -424,11 +392,6 @@ public class ProvinceService implements IProvinceService { |
|
|
|
}else { |
|
|
|
throw new BaseException(CodeEnum.PARAM_ERROR); |
|
|
|
} |
|
|
|
// else {
|
|
|
|
// throw new BaseException(CodeEnum.PARAM_ERROR);
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -590,12 +553,11 @@ public class ProvinceService implements IProvinceService { |
|
|
|
CompeteTeamMemberExample example = new CompeteTeamMemberExample(); |
|
|
|
example.createCriteria().andCompeteTeamIdEqualTo(competeTeam.getId()); |
|
|
|
long memberNum = teamMemberMapper.countByExample(example); |
|
|
|
|
|
|
|
if(joinCount + memberNum > competeProject.getMemberMax() ){ |
|
|
|
if(joinCount + memberNum > 0) { |
|
|
|
if (joinCount + memberNum > competeProject.getMemberMax() || joinCount + memberNum < competeProject.getMemberMin()) { |
|
|
|
throw new BaseException(CodeEnum.MEMBER_NUM_ERROR); |
|
|
|
//TODO 参赛人数不满足比赛人数要求
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
for (int i = 0; i < param.getPlayers().size(); i++) { |
|
|
|
ProvinceCompeteDto.JoinProjectPlayer joinProjectPlayer = param.getPlayers().get(i); |
|
|
|
CompetePlayer player = competePlayerDao.selectByPrimaryKey(joinProjectPlayer.getPlayerId()); |
|
|
@ -635,6 +597,10 @@ public class ProvinceService implements IProvinceService { |
|
|
|
competeTeam.setRecStatus((byte) 2); |
|
|
|
competeTeamDao.updateByPrimaryKeySelective(competeTeam); |
|
|
|
}else { |
|
|
|
//当前参赛人数不符提示错误信息
|
|
|
|
if(teamMemberMapper.countByExample(memberExample) > competeProject.getMemberMax() || teamMemberMapper.countByExample(memberExample) < competeProject.getMemberMin()){ |
|
|
|
throw new BaseException(CodeEnum.MEMBER_NUM_ERROR); |
|
|
|
} |
|
|
|
//修改团队的性别组和组别备注信息
|
|
|
|
ProvinceCompeteVo.TeamGroupRemark teamGroupRemark = competePlayerDao.getTeamGroupRemark(competeTeam.getId()); |
|
|
|
if (StrUtil.isNotEmpty(teamGroupRemark.getGroupRemark())) { |
|
|
@ -661,5 +627,45 @@ public class ProvinceService implements IProvinceService { |
|
|
|
public ProvinceCompeteVo.GetCoach getCoachInfo(CompeteDto.LeaderId param) { |
|
|
|
return competeCompanyDao.getCoachInfo(param.getCoachId()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查找团体项目下的参赛选手信息 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<ProvinceCompeteVo.GroupAndPlayer> getPlayerByTeamProject(ProvinceCompeteDto.GetPlayerByTeamProject param) { |
|
|
|
List<ProvinceCompeteVo.GroupAndPlayer> groupAndPlayerList = null; |
|
|
|
//查找项目
|
|
|
|
CompeteProject competeProject = competeProjectMapper.selectByPrimaryKey(param.getProjectId()); |
|
|
|
if(ObjectUtil.isNotNull(competeProject)){ |
|
|
|
groupAndPlayerList = competeCompanyDao.getPlayerByTeamProject(param.getProjectId(),competeProject.getType()); |
|
|
|
} |
|
|
|
return groupAndPlayerList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查找符合参赛规则的选手信息 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<ProvinceCompeteVo.GroupAndPlayer> getPlayerByTeamProjectWithRule(ProvinceCompeteDto.GetPlayerByTeamProjectWithRule param) { |
|
|
|
List<ProvinceCompeteVo.GroupAndPlayer> groupAndPlayerList = new ArrayList<>(); |
|
|
|
//查找项目
|
|
|
|
CompeteProject competeProject = competeProjectMapper.selectByPrimaryKey(param.getProjectId()); |
|
|
|
if(ObjectUtil.isNotNull(competeProject) && competeProject.getTeam() == 1){ |
|
|
|
//如果同单位不限组别
|
|
|
|
if(competeProject.getJoinRule() == 1){ |
|
|
|
groupAndPlayerList = competeCompanyDao.queryPlayerByGroupId(competeProject.getType(),param.getCompanyId(),null,param.getProjectId()); |
|
|
|
} |
|
|
|
//如果同单位限制组别
|
|
|
|
if(competeProject.getJoinRule() == 0){ |
|
|
|
/*每个单位每个组别可以报名,报名过其他组的选手不能再次报名, |
|
|
|
例:1单位a同学报名了q比赛的小学男子组,a同学就无法再报名q比赛小学混合组 |
|
|
|
b同学报名了r比赛的小学混合组,b同学就无法再报名r比赛的女子组和男子组,无论b同学是男还是女*/ |
|
|
|
//查找此单位下所有该组的选手,如果选择混合组,则男女都查找
|
|
|
|
//排除已经报名别的组的选手
|
|
|
|
groupAndPlayerList = competeCompanyDao.getPlayerByTeamProjectWithRule(param.getCompanyId(),competeProject.getId(),competeProject.getType(),param.getGroupRemark(),param.getGender()); |
|
|
|
} |
|
|
|
} |
|
|
|
return groupAndPlayerList; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|