|
|
@ -3,21 +3,24 @@ package com.ccsens.mt.service; |
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import cn.hutool.core.lang.Snowflake; |
|
|
|
import cn.hutool.core.util.IdcardUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.ccsens.cloudutil.feign.TallFeignClient; |
|
|
|
import com.ccsens.mt.bean.dto.CompeteDto; |
|
|
|
import com.ccsens.mt.bean.po.*; |
|
|
|
import com.ccsens.mt.bean.vo.ProvinceCompeteVo; |
|
|
|
import com.ccsens.mt.bean.vo.TableVo; |
|
|
|
import com.ccsens.mt.persist.dao.CompeteEnrollDao; |
|
|
|
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.dao.*; |
|
|
|
import com.ccsens.mt.persist.mapper.*; |
|
|
|
import com.ccsens.util.PoiUtil; |
|
|
|
import com.ccsens.util.PropUtil; |
|
|
|
import com.ccsens.util.RedisUtil; |
|
|
|
import com.ccsens.util.bean.dto.QueryDto; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.poi.ss.usermodel.Workbook; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.io.File; |
|
|
@ -27,7 +30,13 @@ import java.io.OutputStream; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
public class ExcelService implements IExcelService { |
|
|
|
/** |
|
|
|
* @author 逗 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
|
|
|
public class ExcelService implements IExcelService { |
|
|
|
@Resource |
|
|
|
private CompeteTimeDao competeTimeDao; |
|
|
|
@Resource |
|
|
@ -60,17 +69,23 @@ public class ExcelService implements IExcelService { |
|
|
|
private TallFeignClient tallFeignClient; |
|
|
|
@Resource |
|
|
|
private CommonFileMapper commonFileMapper; |
|
|
|
@Resource |
|
|
|
private IProvinceService provinceService; |
|
|
|
@Resource |
|
|
|
private CompeteCompanyDao competeCompanyDao; |
|
|
|
@Resource |
|
|
|
CompeteCoachMapper competeCoachMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public String competeJoin(QueryDto<CompeteDto.CompeteTime> params) throws IOException { |
|
|
|
CompeteDto.CompeteTime competeTime =params.getParam(); |
|
|
|
CompeteDto.CompeteTime competeTime = params.getParam(); |
|
|
|
List<TableVo.CompeteJoin> competeJoinList = getCompeteJoin(competeTime); |
|
|
|
String path = getExcelFilePathForCompeteJoin(competeJoinList); |
|
|
|
return null; |
|
|
|
return path; |
|
|
|
} |
|
|
|
|
|
|
|
private List<TableVo.CompeteJoin> getCompeteJoin(CompeteDto.CompeteTime params){ |
|
|
|
private List<TableVo.CompeteJoin> getCompeteJoin(CompeteDto.CompeteTime params) { |
|
|
|
List<TableVo.CompeteJoin> competeJoinList = new ArrayList<>(); |
|
|
|
Long competeTimeId = params.getCompeteTimeId(); |
|
|
|
CompeteTime competeTime = competeTimeDao.selectByPrimaryKey(competeTimeId); |
|
|
@ -80,14 +95,14 @@ public class ExcelService implements IExcelService { |
|
|
|
competeProjectExample.createCriteria().andTypeEqualTo((byte) type).andLevelEqualTo(level); |
|
|
|
//获取参赛项目集合
|
|
|
|
List<CompeteProject> competeProjectList = competeProjectMapper.selectByExample(competeProjectExample); |
|
|
|
for (CompeteProject competeProject : competeProjectList){ |
|
|
|
for (CompeteProject competeProject : competeProjectList) { |
|
|
|
String projectName = competeProject.getName(); |
|
|
|
if (competeProject.getTeam() == 0){ |
|
|
|
if (competeProject.getTeam() == 0) { |
|
|
|
//如果不是团队项目,查询该项目下报名人数集合
|
|
|
|
CompeteProjectPlayerExample competeProjectPlayerExample = new CompeteProjectPlayerExample(); |
|
|
|
competeProjectPlayerExample.createCriteria().andProjectIdEqualTo(competeProject.getId()); |
|
|
|
List<CompeteProjectPlayer> competeProjectPlayerList = competeProjectPlayerMapper.selectByExample(competeProjectPlayerExample); |
|
|
|
for (CompeteProjectPlayer competeProjectPlayer : competeProjectPlayerList){ |
|
|
|
for (CompeteProjectPlayer competeProjectPlayer : competeProjectPlayerList) { |
|
|
|
//查询每个报名人的详细信息下
|
|
|
|
CompetePlayer competePlayer = competePlayerDao.selectByPrimaryKey(competeProjectPlayer.getPlayerId()); |
|
|
|
TableVo.CompeteJoin competeJoin = new TableVo.CompeteJoin(); |
|
|
@ -99,45 +114,63 @@ public class ExcelService implements IExcelService { |
|
|
|
String idCard = competeJoin.getIdCard(); |
|
|
|
int ageByIdCard = IdcardUtil.getAgeByIdCard(idCard); |
|
|
|
competeJoin.setAge(ageByIdCard); |
|
|
|
//性别
|
|
|
|
competeJoin.setGender(competePlayer.getGender()); |
|
|
|
Byte gender = competePlayer.getGender(); |
|
|
|
if (gender == 0) { |
|
|
|
competeJoin.setGender("女"); |
|
|
|
} else { |
|
|
|
competeJoin.setGender("男"); |
|
|
|
} |
|
|
|
//查询单位,并赋值
|
|
|
|
CompeteCompany competeCompany = competeCompanyMapper.selectByPrimaryKey(competePlayer.getCompanyId()); |
|
|
|
competeJoin.setJoinTeam(competeCompany.getName()); |
|
|
|
if (ObjectUtil.isNotNull(competeCompany)) { |
|
|
|
competeJoin.setJoinTeam(competeCompany.getName()); |
|
|
|
} |
|
|
|
//查询组别,并赋值
|
|
|
|
CompeteGroup competeGroup = competeGroupMapper.selectByPrimaryKey(competePlayer.getCompeteGroupId()); |
|
|
|
competeJoin.setCompeteGroup(competePlayer.getName()); |
|
|
|
//身份证明查询,并赋值
|
|
|
|
CommonFile commonFile = commonFileMapper.selectByPrimaryKey(competePlayer.getIdCardFrontFile()); |
|
|
|
competeJoin.setIdCardPromise(commonFile.getVisitLocation()); |
|
|
|
//一寸证件照查询赋值
|
|
|
|
CommonFile commonFile1 = commonFileMapper.selectByPrimaryKey(competePlayer.getIdPhotoFile()); |
|
|
|
competeJoin.setPicture(commonFile1.getVisitLocation()); |
|
|
|
//学籍证明/俱乐部证明
|
|
|
|
CommonFile commonFile2 = commonFileMapper.selectByPrimaryKey(competePlayer.getStudentRecordFile()); |
|
|
|
competeJoin.setStudentPromise(commonFile2.getVisitLocation()); |
|
|
|
//体检证明
|
|
|
|
CommonFile commonFile3 = commonFileMapper.selectByPrimaryKey(competePlayer.getHealthRecordFile()); |
|
|
|
competeJoin.setBodyTest(commonFile3.getVisitLocation()); |
|
|
|
//人身意外伤害保险证明
|
|
|
|
CommonFile commonFile4 = commonFileMapper.selectByPrimaryKey(competePlayer.getInsuranceRecordFile()); |
|
|
|
competeJoin.setBodyProtect(commonFile4.getVisitLocation()); |
|
|
|
if (ObjectUtil.isNotNull(competeGroup)) { |
|
|
|
competeJoin.setCompeteGroup(competePlayer.getName()); |
|
|
|
} |
|
|
|
// //身份证明查询,并赋值
|
|
|
|
// CommonFile commonFile = commonFileMapper.selectByPrimaryKey(competePlayer.getIdCardFrontFile());
|
|
|
|
// if (ObjectUtil.isNotNull(commonFile)) {
|
|
|
|
// competeJoin.setIdCardPromise(commonFile.getVisitLocation());
|
|
|
|
// }
|
|
|
|
// //一寸证件照查询赋值
|
|
|
|
// CommonFile commonFile1 = commonFileMapper.selectByPrimaryKey(competePlayer.getIdPhotoFile());
|
|
|
|
// if (ObjectUtil.isNotNull(commonFile1)) {
|
|
|
|
// competeJoin.setPicture(commonFile1.getVisitLocation());
|
|
|
|
// }
|
|
|
|
// //学籍证明/俱乐部证明
|
|
|
|
// CommonFile commonFile2 = commonFileMapper.selectByPrimaryKey(competePlayer.getStudentRecordFile());
|
|
|
|
// if (ObjectUtil.isNotNull(commonFile2)) {
|
|
|
|
// competeJoin.setStudentPromise(commonFile2.getVisitLocation());
|
|
|
|
// }
|
|
|
|
// //体检证明
|
|
|
|
// CommonFile commonFile3 = commonFileMapper.selectByPrimaryKey(competePlayer.getHealthRecordFile());
|
|
|
|
// if (ObjectUtil.isNotNull(commonFile3)) {
|
|
|
|
// competeJoin.setBodyTest(commonFile3.getVisitLocation());
|
|
|
|
// }
|
|
|
|
// //人身意外伤害保险证明
|
|
|
|
// CommonFile commonFile4 = commonFileMapper.selectByPrimaryKey(competePlayer.getInsuranceRecordFile());
|
|
|
|
// if (ObjectUtil.isNotNull(commonFile4)) {
|
|
|
|
// competeJoin.setBodyProtect(commonFile4.getVisitLocation());
|
|
|
|
// }
|
|
|
|
//参赛项目名赋值
|
|
|
|
competeJoin.setCompeteProject(projectName); |
|
|
|
competeJoinList.add(competeJoin); |
|
|
|
} |
|
|
|
|
|
|
|
}else { //团队项目
|
|
|
|
} else { //团队项目
|
|
|
|
//获取参赛队伍集合
|
|
|
|
CompeteTeamExample competeTeamExample = new CompeteTeamExample(); |
|
|
|
competeTeamExample.createCriteria().andProjectIdEqualTo(competeProject.getId()); |
|
|
|
List<CompeteTeam> competeTeamList = competeTeamDao.selectByExample(competeTeamExample); |
|
|
|
for (CompeteTeam competeTeam : competeTeamList){ |
|
|
|
for (CompeteTeam competeTeam : competeTeamList) { |
|
|
|
//获取队伍下的成员集合
|
|
|
|
CompeteTeamMemberExample competeTeamMemberExample = new CompeteTeamMemberExample(); |
|
|
|
competeTeamMemberExample.createCriteria().andCompeteTeamIdEqualTo(competeTeam.getId()); |
|
|
|
List<CompeteTeamMember> competeTeamMemberList = competeTeamMemberMapper.selectByExample(competeTeamMemberExample); |
|
|
|
for (CompeteTeamMember competeTeamMember : competeTeamMemberList){ |
|
|
|
for (CompeteTeamMember competeTeamMember : competeTeamMemberList) { |
|
|
|
//查询成员详细信息
|
|
|
|
CompetePlayer competePlayer = competePlayerDao.selectByPrimaryKey(competeTeamMember.getPlayerId()); |
|
|
|
TableVo.CompeteJoin competeJoin = new TableVo.CompeteJoin(); |
|
|
@ -150,28 +183,48 @@ public class ExcelService implements IExcelService { |
|
|
|
int ageByIdCard = IdcardUtil.getAgeByIdCard(idCard); |
|
|
|
competeJoin.setAge(ageByIdCard); |
|
|
|
//性别
|
|
|
|
competeJoin.setGender(competePlayer.getGender()); |
|
|
|
Byte gender = competePlayer.getGender(); |
|
|
|
if (gender == 0) { |
|
|
|
competeJoin.setGender("女"); |
|
|
|
} else { |
|
|
|
competeJoin.setGender("男"); |
|
|
|
} |
|
|
|
|
|
|
|
//查询单位,并赋值
|
|
|
|
CompeteCompany competeCompany = competeCompanyMapper.selectByPrimaryKey(competePlayer.getCompanyId()); |
|
|
|
competeJoin.setJoinTeam(competeCompany.getName()); |
|
|
|
if (ObjectUtil.isNotNull(competeCompany)) { |
|
|
|
competeJoin.setJoinTeam(competeCompany.getName()); |
|
|
|
} |
|
|
|
//查询组别,并赋值
|
|
|
|
CompeteGroup competeGroup = competeGroupMapper.selectByPrimaryKey(competePlayer.getCompeteGroupId()); |
|
|
|
competeJoin.setCompeteGroup(competePlayer.getName()); |
|
|
|
//身份证明查询,并赋值
|
|
|
|
CommonFile commonFile = commonFileMapper.selectByPrimaryKey(competePlayer.getIdCardFrontFile()); |
|
|
|
competeJoin.setIdCardPromise(commonFile.getVisitLocation()); |
|
|
|
//一寸证件照查询赋值
|
|
|
|
CommonFile commonFile1 = commonFileMapper.selectByPrimaryKey(competePlayer.getIdPhotoFile()); |
|
|
|
competeJoin.setPicture(commonFile1.getVisitLocation()); |
|
|
|
//学籍证明/俱乐部证明
|
|
|
|
CommonFile commonFile2 = commonFileMapper.selectByPrimaryKey(competePlayer.getStudentRecordFile()); |
|
|
|
competeJoin.setStudentPromise(commonFile2.getVisitLocation()); |
|
|
|
//体检证明
|
|
|
|
CommonFile commonFile3 = commonFileMapper.selectByPrimaryKey(competePlayer.getHealthRecordFile()); |
|
|
|
competeJoin.setBodyTest(commonFile3.getVisitLocation()); |
|
|
|
//人身意外伤害保险证明
|
|
|
|
CommonFile commonFile4 = commonFileMapper.selectByPrimaryKey(competePlayer.getInsuranceRecordFile()); |
|
|
|
competeJoin.setBodyProtect(commonFile4.getVisitLocation()); |
|
|
|
if (ObjectUtil.isNotNull(competeGroup)) { |
|
|
|
competeJoin.setCompeteGroup(competePlayer.getName()); |
|
|
|
} |
|
|
|
// //身份证明查询,并赋值
|
|
|
|
// CommonFile commonFile = commonFileMapper.selectByPrimaryKey(competePlayer.getIdCardFrontFile());
|
|
|
|
// if (ObjectUtil.isNotNull(commonFile)){
|
|
|
|
// competeJoin.setIdCardPromise(commonFile.getVisitLocation());
|
|
|
|
// }
|
|
|
|
// //一寸证件照查询赋值
|
|
|
|
// CommonFile commonFile1 = commonFileMapper.selectByPrimaryKey(competePlayer.getIdPhotoFile());
|
|
|
|
// if (ObjectUtil.isNotNull(commonFile1)){
|
|
|
|
// competeJoin.setPicture(commonFile1.getVisitLocation());
|
|
|
|
// }
|
|
|
|
// //学籍证明/俱乐部证明
|
|
|
|
// CommonFile commonFile2 = commonFileMapper.selectByPrimaryKey(competePlayer.getStudentRecordFile());
|
|
|
|
// if (ObjectUtil.isNotNull(commonFile2)){
|
|
|
|
// competeJoin.setStudentPromise(commonFile2.getVisitLocation());
|
|
|
|
// }
|
|
|
|
// //体检证明
|
|
|
|
// CommonFile commonFile3 = commonFileMapper.selectByPrimaryKey(competePlayer.getHealthRecordFile());
|
|
|
|
// if (ObjectUtil.isNotNull(commonFile3)){
|
|
|
|
// competeJoin.setBodyTest(commonFile3.getVisitLocation());
|
|
|
|
// }
|
|
|
|
// //人身意外伤害保险证明
|
|
|
|
// CommonFile commonFile4 = commonFileMapper.selectByPrimaryKey(competePlayer.getInsuranceRecordFile());
|
|
|
|
// if (ObjectUtil.isNotNull(commonFile4)){
|
|
|
|
// competeJoin.setBodyProtect(commonFile4.getVisitLocation());
|
|
|
|
// }
|
|
|
|
//参赛项目名赋值
|
|
|
|
competeJoin.setCompeteProject(projectName); |
|
|
|
competeJoinList.add(competeJoin); |
|
|
@ -179,7 +232,7 @@ public class ExcelService implements IExcelService { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return competeJoinList; |
|
|
|
return competeJoinList; |
|
|
|
} |
|
|
|
|
|
|
|
private String getExcelFilePathForCompeteJoin(List<TableVo.CompeteJoin> arrayList) throws IOException { |
|
|
@ -188,6 +241,7 @@ public class ExcelService implements IExcelService { |
|
|
|
//创建行对象
|
|
|
|
List<PoiUtil.PoiUtilCell> title = new ArrayList<>(); |
|
|
|
//给首行单元格赋值
|
|
|
|
title.add(new PoiUtil.PoiUtilCell("序号")); |
|
|
|
title.add(new PoiUtil.PoiUtilCell("参赛项目")); |
|
|
|
title.add(new PoiUtil.PoiUtilCell("组别")); |
|
|
|
title.add(new PoiUtil.PoiUtilCell("参赛队伍")); |
|
|
@ -195,11 +249,12 @@ public class ExcelService implements IExcelService { |
|
|
|
title.add(new PoiUtil.PoiUtilCell("性别")); |
|
|
|
title.add(new PoiUtil.PoiUtilCell("年龄")); |
|
|
|
title.add(new PoiUtil.PoiUtilCell("身份证号")); |
|
|
|
title.add(new PoiUtil.PoiUtilCell("身份证明")); |
|
|
|
title.add(new PoiUtil.PoiUtilCell("一寸证件照")); |
|
|
|
title.add(new PoiUtil.PoiUtilCell("学籍证明/俱乐部证明")); |
|
|
|
title.add(new PoiUtil.PoiUtilCell("体检证明")); |
|
|
|
title.add(new PoiUtil.PoiUtilCell("人身意外伤害保险证明")); |
|
|
|
// title.add(new PoiUtil.PoiUtilCell("身份证明"));
|
|
|
|
// title.add(new PoiUtil.PoiUtilCell("一寸证件照"));
|
|
|
|
// title.add(new PoiUtil.PoiUtilCell("学籍证明/俱乐部证明"));
|
|
|
|
// title.add(new PoiUtil.PoiUtilCell("体检证明"));
|
|
|
|
// title.add(new PoiUtil.PoiUtilCell("人身意外伤害保险证明"));
|
|
|
|
title.add(new PoiUtil.PoiUtilCell("备注")); |
|
|
|
list.add(title); |
|
|
|
//创建整个excel表格对象
|
|
|
|
Workbook workbook = new XSSFWorkbook(); |
|
|
@ -220,19 +275,19 @@ public class ExcelService implements IExcelService { |
|
|
|
PoiUtil.PoiUtilCell poiUtilCel4 = new PoiUtil.PoiUtilCell(String.valueOf(competeJoin.getGender())); |
|
|
|
cells.add(poiUtilCel4); |
|
|
|
PoiUtil.PoiUtilCell poiUtilCel5 = new PoiUtil.PoiUtilCell(String.valueOf(competeJoin.getAge())); |
|
|
|
cells.add(poiUtilCel4); |
|
|
|
cells.add(poiUtilCel5); |
|
|
|
PoiUtil.PoiUtilCell poiUtilCel6 = new PoiUtil.PoiUtilCell(competeJoin.getIdCard()); |
|
|
|
cells.add(poiUtilCel4); |
|
|
|
PoiUtil.PoiUtilCell poiUtilCel7 = new PoiUtil.PoiUtilCell(competeJoin.getIdCardPromise()); |
|
|
|
cells.add(poiUtilCel4); |
|
|
|
PoiUtil.PoiUtilCell poiUtilCel8 = new PoiUtil.PoiUtilCell(competeJoin.getPicture()); |
|
|
|
cells.add(poiUtilCel4); |
|
|
|
PoiUtil.PoiUtilCell poiUtilCel9 = new PoiUtil.PoiUtilCell(competeJoin.getStudentPromise()); |
|
|
|
cells.add(poiUtilCel4); |
|
|
|
PoiUtil.PoiUtilCell poiUtilCel10 = new PoiUtil.PoiUtilCell(competeJoin.getBodyTest()); |
|
|
|
cells.add(poiUtilCel4); |
|
|
|
PoiUtil.PoiUtilCell poiUtilCel11= new PoiUtil.PoiUtilCell(competeJoin.getBodyProtect()); |
|
|
|
cells.add(poiUtilCel4); |
|
|
|
cells.add(poiUtilCel6); |
|
|
|
// PoiUtil.PoiUtilCell poiUtilCel7 = new PoiUtil.PoiUtilCell(competeJoin.getIdCardPromise());
|
|
|
|
// cells.add(poiUtilCel7);
|
|
|
|
// PoiUtil.PoiUtilCell poiUtilCel8 = new PoiUtil.PoiUtilCell(competeJoin.getPicture());
|
|
|
|
// cells.add(poiUtilCel8);
|
|
|
|
// PoiUtil.PoiUtilCell poiUtilCel9 = new PoiUtil.PoiUtilCell(competeJoin.getStudentPromise());
|
|
|
|
// cells.add(poiUtilCel9);
|
|
|
|
// PoiUtil.PoiUtilCell poiUtilCel10 = new PoiUtil.PoiUtilCell(competeJoin.getBodyTest());
|
|
|
|
// cells.add(poiUtilCel10);
|
|
|
|
// PoiUtil.PoiUtilCell poiUtilCel11 = new PoiUtil.PoiUtilCell(competeJoin.getBodyProtect());
|
|
|
|
// cells.add(poiUtilCel11);
|
|
|
|
list.add(cells); |
|
|
|
i++; |
|
|
|
} |
|
|
@ -242,6 +297,104 @@ public class ExcelService implements IExcelService { |
|
|
|
String name = "XXXX大赛报名表" + ".xlsx"; |
|
|
|
String filepath = "mt/" + DateUtil.today() + "/" + System.currentTimeMillis() + ".xlsx"; |
|
|
|
String path = PropUtil.path + filepath; |
|
|
|
// String path = filepath;
|
|
|
|
File tmpFile = new File(path); |
|
|
|
if (!tmpFile.getParentFile().exists()) { |
|
|
|
tmpFile.getParentFile().mkdirs(); |
|
|
|
} |
|
|
|
//PropUtil.path获取配置文件中的path属性,拼接生成写入信息的文件名,
|
|
|
|
File file = new File(path); |
|
|
|
OutputStream stream = new FileOutputStream(file); |
|
|
|
wbs.write(stream); |
|
|
|
stream.close(); |
|
|
|
return path; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public String competeJoinCount(CompeteDto.CompeteTime params) throws IOException { |
|
|
|
List<TableVo.CompeteOverview> competeOverviewList = competeJoinCountList(params); |
|
|
|
String path = getExcelFilePathForCompeteJoinCount(competeOverviewList); |
|
|
|
return path; |
|
|
|
} |
|
|
|
|
|
|
|
private List<TableVo.CompeteOverview> competeJoinCountList(CompeteDto.CompeteTime params) { |
|
|
|
CompeteCompanyExample competeCompanyExample = new CompeteCompanyExample(); |
|
|
|
competeCompanyExample.createCriteria().andCompeteTimeIdEqualTo(params.getCompeteTimeId()); |
|
|
|
//根据大赛id查公司集合
|
|
|
|
List<CompeteCompany> competeCompanyList = competeCompanyMapper.selectByExample(competeCompanyExample); |
|
|
|
List<TableVo.CompeteOverview> competeOverview2List = new ArrayList<>(); |
|
|
|
for (CompeteCompany competeCompany : competeCompanyList) { |
|
|
|
//每个公司的教练数量
|
|
|
|
int leader = 1; |
|
|
|
int coach = 0; |
|
|
|
CompeteCoachExample competeCoachExample = new CompeteCoachExample(); |
|
|
|
competeCoachExample.createCriteria().andCompanyIdEqualTo(competeCompany.getId()).andIdentityEqualTo((byte) coach); |
|
|
|
long count = competeCoachMapper.countByExample(competeCoachExample); |
|
|
|
//每个公司的领队数量
|
|
|
|
CompeteCoachExample competeCoachExample1 = new CompeteCoachExample(); |
|
|
|
competeCoachExample1.createCriteria().andCompanyIdEqualTo(competeCompany.getId()).andIdentityEqualTo((byte) leader); |
|
|
|
long count1 = competeCoachMapper.countByExample(competeCoachExample1); |
|
|
|
//每个公司运动员人数
|
|
|
|
CompetePlayerExample competePlayerExample2 = new CompetePlayerExample(); |
|
|
|
competePlayerExample2.createCriteria().andCompanyIdEqualTo(competeCompany.getId()); |
|
|
|
long count2 = competePlayerDao.countByExample(competePlayerExample2); |
|
|
|
//总人数
|
|
|
|
long sum = count + count1 + count2; |
|
|
|
TableVo.CompeteOverview CompeteOverview2 = new TableVo.CompeteOverview(); |
|
|
|
CompeteOverview2.setCompanyName(competeCompany.getName()); |
|
|
|
CompeteOverview2.setCoachNum((int) count); |
|
|
|
CompeteOverview2.setGuideNum((int) count1); |
|
|
|
CompeteOverview2.setPlayerNum((int) count2); |
|
|
|
CompeteOverview2.setSum((int) sum); |
|
|
|
competeOverview2List.add(CompeteOverview2); |
|
|
|
} |
|
|
|
return competeOverview2List; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getExcelFilePathForCompeteJoinCount(List<TableVo.CompeteOverview> arrayList) throws IOException { |
|
|
|
//创建excle表格对象
|
|
|
|
List<List<PoiUtil.PoiUtilCell>> list = new ArrayList<>(); |
|
|
|
//创建行对象
|
|
|
|
List<PoiUtil.PoiUtilCell> title = new ArrayList<>(); |
|
|
|
//给首行单元格赋值
|
|
|
|
title.add(new PoiUtil.PoiUtilCell("序号")); |
|
|
|
title.add(new PoiUtil.PoiUtilCell("单位")); |
|
|
|
title.add(new PoiUtil.PoiUtilCell("领队")); |
|
|
|
title.add(new PoiUtil.PoiUtilCell("教练")); |
|
|
|
title.add(new PoiUtil.PoiUtilCell("运动员")); |
|
|
|
title.add(new PoiUtil.PoiUtilCell("总人数")); |
|
|
|
list.add(title); |
|
|
|
//创建整个excel表格对象
|
|
|
|
Workbook workbook = new XSSFWorkbook(); |
|
|
|
int i = 1; |
|
|
|
for (TableVo.CompeteOverview competeOverview : arrayList) { |
|
|
|
//行对象
|
|
|
|
List<PoiUtil.PoiUtilCell> cells = new ArrayList<>(); |
|
|
|
cells.add(new PoiUtil.PoiUtilCell(i + "", 1, 1, 300, 18)); |
|
|
|
//单元格对象
|
|
|
|
PoiUtil.PoiUtilCell poiUtilCel = new PoiUtil.PoiUtilCell(competeOverview.getCompanyName()); |
|
|
|
cells.add(poiUtilCel); |
|
|
|
PoiUtil.PoiUtilCell poiUtilCell = new PoiUtil.PoiUtilCell(String.valueOf(competeOverview.getGuideNum())); |
|
|
|
cells.add(poiUtilCell); |
|
|
|
PoiUtil.PoiUtilCell poiUtilCel2 = new PoiUtil.PoiUtilCell(String.valueOf(competeOverview.getCoachNum())); |
|
|
|
cells.add(poiUtilCel2); |
|
|
|
PoiUtil.PoiUtilCell poiUtilCel3 = new PoiUtil.PoiUtilCell(String.valueOf(competeOverview.getPlayerNum())); |
|
|
|
cells.add(poiUtilCel3); |
|
|
|
PoiUtil.PoiUtilCell poiUtilCel4 = new PoiUtil.PoiUtilCell(String.valueOf(competeOverview.getSum())); |
|
|
|
cells.add(poiUtilCel4); |
|
|
|
list.add(cells); |
|
|
|
i++; |
|
|
|
} |
|
|
|
//生成excel表格对象,并将数据放入
|
|
|
|
Workbook wbs = PoiUtil.exportWB("参赛人数统计表", list, workbook); |
|
|
|
//8:关联金山在线文档
|
|
|
|
String name = "参赛人数统计表" + ".xlsx"; |
|
|
|
String filepath = "mt/" + DateUtil.today() + "/" + System.currentTimeMillis() + ".xlsx"; |
|
|
|
String path = PropUtil.path + filepath; |
|
|
|
// String path = filepath;
|
|
|
|
File tmpFile = new File(path); |
|
|
|
if (!tmpFile.getParentFile().exists()) { |
|
|
|
tmpFile.getParentFile().mkdirs(); |
|
|
@ -254,4 +407,66 @@ public class ExcelService implements IExcelService { |
|
|
|
return path; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public String competeAllCount(CompeteDto.CompeteTime params) throws IOException { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
private List<TableVo.CompeteAllCount> competeAllCountList(CompeteDto.CompeteTime params){ |
|
|
|
//根据大赛查类型
|
|
|
|
Long competeTimeId = params.getCompeteTimeId(); |
|
|
|
CompeteTime competeTime = competeTimeDao.selectByPrimaryKey(competeTimeId); |
|
|
|
int type = competeTime.getType(); |
|
|
|
Byte level = 2; |
|
|
|
CompeteProjectExample competeProjectExample = new CompeteProjectExample(); |
|
|
|
competeProjectExample.createCriteria().andTypeEqualTo((byte) type).andLevelEqualTo(level); |
|
|
|
//获取参赛项目集合
|
|
|
|
List<CompeteProject> competeProjectList = competeProjectMapper.selectByExample(competeProjectExample); |
|
|
|
CompeteGroupExample competeGroupExample = new CompeteGroupExample(); |
|
|
|
competeGroupExample.createCriteria().andTypeEqualTo((byte) type); |
|
|
|
//获取组别集合
|
|
|
|
List<CompeteGroup> competeGroupList = competeGroupMapper.selectByExample(competeGroupExample); |
|
|
|
for (CompeteProject competeProject : competeProjectList){ |
|
|
|
//若不是团队项目
|
|
|
|
if (competeProject.getTeam() == 0){ |
|
|
|
TableVo.CompeteAllCount competeAllCount = new TableVo.CompeteAllCount(); |
|
|
|
//项目名赋值
|
|
|
|
competeAllCount.setProjectName(competeProject.getName()); |
|
|
|
//遍历组别集合
|
|
|
|
int i = 0; |
|
|
|
for(CompeteGroup competeGroup : competeGroupList){ |
|
|
|
CompetePlayerExample competePlayerExample = new CompetePlayerExample(); |
|
|
|
competePlayerExample.createCriteria().andCompeteGroupIdEqualTo(competeGroup.getId()); |
|
|
|
//计算每个组别人数
|
|
|
|
long count = competePlayerDao.countByExample(competePlayerExample); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|