|
|
|
@ -14,11 +14,7 @@ import com.huoran.common.exception.ExceptionEnum; |
|
|
|
|
import com.huoran.common.response.R; |
|
|
|
|
import com.huoran.competition.entity.Competition; |
|
|
|
|
import com.huoran.competition.entity.CompetitionRegistration; |
|
|
|
|
import com.huoran.competition.entity.CompetitionTeam; |
|
|
|
|
import com.huoran.competition.entity.CompleteCompetitionSetup; |
|
|
|
|
import com.huoran.competition.entity.req.PageRegistrationStaffReq; |
|
|
|
|
import com.huoran.competition.entity.vo.ExcelData; |
|
|
|
|
import com.huoran.competition.entity.vo.PersonalExcelData; |
|
|
|
|
import com.huoran.competition.entity.vo.RegistrationVO; |
|
|
|
|
import com.huoran.competition.mapper.*; |
|
|
|
|
import com.huoran.competition.service.CompetitionRangeService; |
|
|
|
@ -29,7 +25,6 @@ import com.huoran.competition.utils.ExcelStyleUtil; |
|
|
|
|
import com.huoran.competition.utils.HandleNameAsteriskReplacementUtil; |
|
|
|
|
import org.apache.poi.ss.usermodel.Workbook; |
|
|
|
|
import org.jetbrains.annotations.NotNull; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
@ -38,7 +33,6 @@ import org.springframework.util.ObjectUtils; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.net.URLEncoder; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -89,14 +83,13 @@ public class CompetitionRegistrationServiceImpl extends ServiceImpl<CompetitionR |
|
|
|
|
|
|
|
|
|
//默认设置后台
|
|
|
|
|
|
|
|
|
|
if (ObjectUtils.isEmpty(req.getQuerySource())){ |
|
|
|
|
req.setQuerySource(2); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtils.isEmpty(req.getQuerySource())) { |
|
|
|
|
req.setQuerySource(2); |
|
|
|
|
} |
|
|
|
|
if (req.getQuerySource() == 1) { |
|
|
|
|
pageList |
|
|
|
|
.getRecords().forEach(registrationVO -> { |
|
|
|
|
registrationVO.setUsername(HandleNameAsteriskReplacementUtil.desensitizedName(registrationVO.getUsername())); |
|
|
|
|
}); |
|
|
|
|
pageList.getRecords().forEach(registrationVO -> { |
|
|
|
|
registrationVO.setUsername(HandleNameAsteriskReplacementUtil.desensitizedName(registrationVO.getUsername())); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return R.ok().put("data", pageList); |
|
|
|
@ -142,39 +135,37 @@ public class CompetitionRegistrationServiceImpl extends ServiceImpl<CompetitionR |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void export(HttpServletResponse response, PageRegistrationStaffReq req) throws IOException { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Page<RegistrationVO> page = new Page<RegistrationVO>(req.getPageNum(), req.getPageSize()); |
|
|
|
|
IPage<RegistrationVO> applicantVOList = baseMapper.selectApplicantByCondition(page, req); |
|
|
|
|
QueryWrapper<CompleteCompetitionSetup> setupQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
setupQueryWrapper.eq("competition_id", req.getCompetitionId()); |
|
|
|
|
CompleteCompetitionSetup setup = completeCompetitionSetupMapper.selectOne(setupQueryWrapper); |
|
|
|
|
List<ExcelData> excelDataList = new ArrayList<>(); |
|
|
|
|
List<PersonalExcelData> personalExcelData = new ArrayList<>(); |
|
|
|
|
//导出团队名称
|
|
|
|
|
if (setup.getCompetitionType() == 1) { |
|
|
|
|
applicantVOList.getRecords().forEach(registrationVO -> { |
|
|
|
|
QueryWrapper<CompetitionTeam> teamQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
teamQueryWrapper.eq("competition_id", req.getCompetitionId()); |
|
|
|
|
teamQueryWrapper.eq("account_id", registrationVO.getAccountId()); |
|
|
|
|
CompetitionTeam team = competitionTeamMapper.selectOne(teamQueryWrapper); |
|
|
|
|
if (team != null && team.getCaptain() == 0) { |
|
|
|
|
registrationVO.setTeamName(team.getTeamName()); |
|
|
|
|
} else if (team != null) { |
|
|
|
|
CompetitionTeam team1 = competitionTeamMapper.selectById(team.getPid()); |
|
|
|
|
registrationVO.setTeamName(team1.getTeamName()); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
applicantVOList.getRecords().forEach(applicantVO -> { |
|
|
|
|
ExcelData excelData = new ExcelData(); |
|
|
|
|
BeanUtils.copyProperties(applicantVO, excelData); |
|
|
|
|
excelDataList.add(excelData); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
//个人导出列
|
|
|
|
|
applicantVOList.getRecords().forEach(applicantVO -> { |
|
|
|
|
PersonalExcelData personalExcelData1 = new PersonalExcelData(); |
|
|
|
|
BeanUtils.copyProperties(applicantVO, personalExcelData1); |
|
|
|
|
personalExcelData.add(personalExcelData1); |
|
|
|
|
}); |
|
|
|
|
IPage<RegistrationVO> pageList = baseMapper.selectRegistrationByCondition(page, req); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (RegistrationVO vo : pageList.getRecords()) { |
|
|
|
|
//组织类型/平台来源(5:幼儿园,6:供应商)
|
|
|
|
|
switch (vo.getPlatformId()) { |
|
|
|
|
case "5": |
|
|
|
|
vo.setPlatformId("幼儿园"); |
|
|
|
|
break; |
|
|
|
|
case "6": |
|
|
|
|
vo.setPlatformId("供应商"); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//签到状态(0.待签到 1.已签到 2.未签到:活动结束后没签到的)
|
|
|
|
|
switch (vo.getSignInStatus()) { |
|
|
|
|
case "0": |
|
|
|
|
vo.setSignInStatus("待签到"); |
|
|
|
|
break; |
|
|
|
|
case "1": |
|
|
|
|
vo.setSignInStatus("已签到"); |
|
|
|
|
break; |
|
|
|
|
case "2": |
|
|
|
|
vo.setSignInStatus("未签到"); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 告诉浏览器用什么软件可以打开此文件
|
|
|
|
@ -184,12 +175,8 @@ public class CompetitionRegistrationServiceImpl extends ServiceImpl<CompetitionR |
|
|
|
|
//编码
|
|
|
|
|
response.setCharacterEncoding("UTF-8"); |
|
|
|
|
|
|
|
|
|
Workbook workbook; |
|
|
|
|
if (setup.getCompetitionType() == 1) { |
|
|
|
|
workbook = ExcelExportUtil.exportExcel(new ExportParams(), ExcelData.class, excelDataList); |
|
|
|
|
} else { |
|
|
|
|
workbook = ExcelExportUtil.exportExcel(new ExportParams(), PersonalExcelData.class, personalExcelData); |
|
|
|
|
} |
|
|
|
|
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), RegistrationVO.class, pageList.getRecords()); |
|
|
|
|
|
|
|
|
|
ExportParams exportParams = new ExportParams(null, "delivery", ExcelType.XSSF); |
|
|
|
|
exportParams.setStyle(ExcelStyleUtil.class); |
|
|
|
|
workbook.write(response.getOutputStream()); |
|
|
|
@ -197,6 +184,35 @@ public class CompetitionRegistrationServiceImpl extends ServiceImpl<CompetitionR |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void exportDataInBatches(List<RegistrationVO> listOfExportSub, HttpServletResponse response) throws IOException { |
|
|
|
|
|
|
|
|
|
if (!listOfExportSub.isEmpty()) { |
|
|
|
|
for (RegistrationVO vo : listOfExportSub) { |
|
|
|
|
//组织类型/平台来源(5:幼儿园,6:供应商)
|
|
|
|
|
switch (vo.getPlatformId()) { |
|
|
|
|
case "5": |
|
|
|
|
vo.setPlatformId("幼儿园"); |
|
|
|
|
break; |
|
|
|
|
case "6": |
|
|
|
|
vo.setPlatformId("供应商"); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//签到状态(0.待签到 1.已签到 2.未签到:活动结束后没签到的)
|
|
|
|
|
switch (vo.getSignInStatus()) { |
|
|
|
|
case "0": |
|
|
|
|
vo.setSignInStatus("待签到"); |
|
|
|
|
break; |
|
|
|
|
case "1": |
|
|
|
|
vo.setSignInStatus("已签到"); |
|
|
|
|
break; |
|
|
|
|
case "2": |
|
|
|
|
vo.setSignInStatus("未签到"); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 告诉浏览器用什么软件可以打开此文件
|
|
|
|
|
response.setHeader("content-Type", "application/vnd.ms-excel"); |
|
|
|
|
// 下载文件的默认名称
|
|
|
|
|