|
|
@ -35,7 +35,9 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.io.*; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
/** |
|
|
|
* @author 逗 |
|
|
@ -606,20 +608,69 @@ public class CompeteService implements ICompeteService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public String enrollPlayInfo(QueryDto<CompeteDto.CompeteType> params) { |
|
|
|
public String enrollPlayInfo(QueryDto<CompeteDto.CompeteType> params) throws Exception { |
|
|
|
CompeteDto.CompeteType competeType = params.getParam(); |
|
|
|
List<String> filePath = new ArrayList<>(); |
|
|
|
//查询大赛id
|
|
|
|
CompeteVo.CompeteTime competeTimeByType = competeTimeDao.getCompeteTimeByType(competeType.getType(), System.currentTimeMillis()); |
|
|
|
// //查询此大赛是否关联wps
|
|
|
|
// WpsDto.VisitWpsUrl visitWpsUrl = new WpsDto.VisitWpsUrl();
|
|
|
|
// visitWpsUrl.setBusinessId(competeTimeByType.getId());
|
|
|
|
// visitWpsUrl.setBusinessType((byte) 11);
|
|
|
|
// visitWpsUrl.setUserId(params.getUserId());
|
|
|
|
// filePath = tallFeignClient.queryVisitUrls(visitWpsUrl);
|
|
|
|
// if(CollectionUtil.isNotEmpty(filePath)){
|
|
|
|
// //TODO 删除以前的关联信息
|
|
|
|
// }
|
|
|
|
List<CompeteVo.EnrollPlayInfo> arrayList = getEnrollPlayInfos(competeType); |
|
|
|
String path = getExcelFilePath(arrayList); |
|
|
|
|
|
|
|
return PropUtil.domain + "file/download/know?path="+path; |
|
|
|
} |
|
|
|
|
|
|
|
private String getExcelFilePath(List<CompeteVo.EnrollPlayInfo> arrayList) throws IOException { |
|
|
|
//7:将数据放入excel表格
|
|
|
|
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("手机号")); |
|
|
|
title.add(new PoiUtil.PoiUtilCell("其他参赛人员")); |
|
|
|
list.add(title); |
|
|
|
Workbook workbook = new XSSFWorkbook(); |
|
|
|
int i = 1; |
|
|
|
for (CompeteVo.EnrollPlayInfo enrollPlayInfo : arrayList) { |
|
|
|
//行对象
|
|
|
|
List<PoiUtil.PoiUtilCell> cells = new ArrayList<>(); |
|
|
|
cells.add(new PoiUtil.PoiUtilCell(i + "", 1, 1, 300, 18)); |
|
|
|
//单元格对象
|
|
|
|
PoiUtil.PoiUtilCell poiUtilCel = new PoiUtil.PoiUtilCell(enrollPlayInfo.getName()); |
|
|
|
cells.add(poiUtilCel); |
|
|
|
PoiUtil.PoiUtilCell poiUtilCell = new PoiUtil.PoiUtilCell(enrollPlayInfo.getGroupName()); |
|
|
|
cells.add(poiUtilCell); |
|
|
|
PoiUtil.PoiUtilCell poiUtilCel2 = new PoiUtil.PoiUtilCell(enrollPlayInfo.getUsername()); |
|
|
|
cells.add(poiUtilCel2); |
|
|
|
PoiUtil.PoiUtilCell poiUtilCel3 = new PoiUtil.PoiUtilCell(enrollPlayInfo.getIdCard()); |
|
|
|
cells.add(poiUtilCel3); |
|
|
|
PoiUtil.PoiUtilCell poiUtilCel4 = new PoiUtil.PoiUtilCell(enrollPlayInfo.getPhone()); |
|
|
|
cells.add(poiUtilCel4); |
|
|
|
if (StrUtil.isNotEmpty(enrollPlayInfo.getOthersName())) { |
|
|
|
PoiUtil.PoiUtilCell poiUtilCel5 = new PoiUtil.PoiUtilCell(enrollPlayInfo.getOthersName()); |
|
|
|
cells.add(poiUtilCel5); |
|
|
|
} |
|
|
|
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; |
|
|
|
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; |
|
|
|
} |
|
|
|
|
|
|
|
private ArrayList<CompeteVo.EnrollPlayInfo> getEnrollPlayInfos(CompeteDto.CompeteType competeType) { |
|
|
|
//查询报名信息
|
|
|
|
int typeId = competeType.getType(); |
|
|
|
ArrayList<CompeteVo.EnrollPlayInfo> arrayList = new ArrayList(); |
|
|
@ -627,6 +678,7 @@ public class CompeteService implements ICompeteService { |
|
|
|
//1:查询该类型下所有项目的id,name,team信息,排除level为1的
|
|
|
|
List<CompeteVo.ProjectInfo> projectInfoList = competeEnrollDao.getProject(typeId); |
|
|
|
//2:根据team字段判断是否为团队项目
|
|
|
|
Map<Long, CompeteVo.EnrollPlayInfo> map = new HashMap<>(); |
|
|
|
for (CompeteVo.ProjectInfo projectInfo : projectInfoList) { |
|
|
|
long team = projectInfo.getTeam(); |
|
|
|
//3:若是单人项目,在t_compete_project_player表中根据传进来的项目名的项目id查询该项目下所有play_id-参赛选手id和该选手的所在组别id
|
|
|
@ -634,10 +686,18 @@ public class CompeteService implements ICompeteService { |
|
|
|
List<CompeteVo.ProjectPlayer> projectPlayerList = competeEnrollDao.getProjectPlayer(projectInfo.getId()); |
|
|
|
for (CompeteVo.ProjectPlayer projectPlayer : projectPlayerList) { |
|
|
|
//4:然后根据查出来的play_id查询t_compete_player中play_id=id的所有信息,包括姓名,身份证,手机号;通过组别id,在t_compete_group中查找组别名称;单人项目不涉及同组参赛者
|
|
|
|
CompeteVo.EnrollPlayInfo enrollPlayInfo = competeEnrollDao.getPlayerAndProject(projectPlayer.getPlayer_id()); |
|
|
|
CompeteVo.EnrollPlayInfo enrollPlayInfo = map.get(projectPlayer.getPlayer_id()); |
|
|
|
|
|
|
|
if (ObjectUtil.isNull(enrollPlayInfo)) { |
|
|
|
enrollPlayInfo = competeEnrollDao.getPlayerAndProject(projectPlayer.getPlayer_id()); |
|
|
|
map.put(projectPlayer.getPlayer_id(), enrollPlayInfo); |
|
|
|
} |
|
|
|
|
|
|
|
if (enrollPlayInfo != null) { |
|
|
|
enrollPlayInfo.setName(projectInfo.getName()); |
|
|
|
arrayList.add(enrollPlayInfo); |
|
|
|
CompeteVo.EnrollPlayInfo enrollPlayInfo1 = new CompeteVo.EnrollPlayInfo(); |
|
|
|
BeanUtil.copyProperties(enrollPlayInfo, enrollPlayInfo1); |
|
|
|
enrollPlayInfo1.setName(projectInfo.getName()); |
|
|
|
arrayList.add(enrollPlayInfo1); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
@ -653,118 +713,41 @@ public class CompeteService implements ICompeteService { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//7:将数据放入excel表格
|
|
|
|
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("手机号")); |
|
|
|
title.add(new PoiUtil.PoiUtilCell("其他参赛人员")); |
|
|
|
list.add(title); |
|
|
|
try { |
|
|
|
Workbook workbook = new XSSFWorkbook(); |
|
|
|
int i = 1; |
|
|
|
for (CompeteVo.EnrollPlayInfo enrollPlayInfo : arrayList) { |
|
|
|
//行对象
|
|
|
|
List<PoiUtil.PoiUtilCell> cells = new ArrayList<>(); |
|
|
|
cells.add(new PoiUtil.PoiUtilCell(i + "", 1, 1, 300, 18)); |
|
|
|
//单元格对象
|
|
|
|
PoiUtil.PoiUtilCell poiUtilCel = new PoiUtil.PoiUtilCell(enrollPlayInfo.getName()); |
|
|
|
cells.add(poiUtilCel); |
|
|
|
PoiUtil.PoiUtilCell poiUtilCell = new PoiUtil.PoiUtilCell(enrollPlayInfo.getGroupName()); |
|
|
|
cells.add(poiUtilCell); |
|
|
|
PoiUtil.PoiUtilCell poiUtilCel2 = new PoiUtil.PoiUtilCell(enrollPlayInfo.getUsername()); |
|
|
|
cells.add(poiUtilCel2); |
|
|
|
PoiUtil.PoiUtilCell poiUtilCel3 = new PoiUtil.PoiUtilCell(enrollPlayInfo.getIdCard()); |
|
|
|
cells.add(poiUtilCel3); |
|
|
|
PoiUtil.PoiUtilCell poiUtilCel4 = new PoiUtil.PoiUtilCell(enrollPlayInfo.getPhone()); |
|
|
|
cells.add(poiUtilCel4); |
|
|
|
PoiUtil.PoiUtilCell poiUtilCel5 = new PoiUtil.PoiUtilCell(enrollPlayInfo.getOthersName()); |
|
|
|
cells.add(poiUtilCel5); |
|
|
|
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; |
|
|
|
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(); |
|
|
|
//关联wps
|
|
|
|
WpsDto.Business business = new WpsDto.Business(); |
|
|
|
business.setBusinessId(competeTimeByType.getId()); |
|
|
|
business.setBusinessType((byte) 11); |
|
|
|
business.setFileName(name); |
|
|
|
business.setFilePath(path); |
|
|
|
business.setRealFilePath(path); |
|
|
|
business.setFileSize(file.length()); |
|
|
|
business.setUserId(params.getUserId()); |
|
|
|
business.setOperation(WebConstant.Wps.USER_OPERATION_NEW); |
|
|
|
business.setPrivilege(WebConstant.Wps.PROJECT_PRIVILEGE_READ); |
|
|
|
log.info("跳绳比赛报名表关联wps:{}", business); |
|
|
|
tallFeignClient.saveWpsFile(business); |
|
|
|
//查询wps
|
|
|
|
WpsDto.VisitWpsUrl visitWpsUrl = new WpsDto.VisitWpsUrl(); |
|
|
|
visitWpsUrl.setBusinessId(competeTimeByType.getId()); |
|
|
|
visitWpsUrl.setBusinessType((byte) 11); |
|
|
|
visitWpsUrl.setUserId(params.getUserId()); |
|
|
|
filePath = tallFeignClient.queryVisitUrls(visitWpsUrl); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
return filePath.get(0); |
|
|
|
return arrayList; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public String enrollPlayInfoWps(QueryDto<CompeteDto.CompeteType> params) throws IOException { |
|
|
|
CompeteDto.CompeteType competeType = params.getParam(); |
|
|
|
List<CompeteVo.EnrollPlayInfo> arrayList = getEnrollPlayInfos(competeType); |
|
|
|
String path = getExcelFilePath(arrayList); |
|
|
|
File file = new File(path); |
|
|
|
|
|
|
|
CompeteVo.CompeteTime competeTimeByType = competeTimeDao.getCompeteTimeByType(competeType.getType(), System.currentTimeMillis()); |
|
|
|
//关联wps
|
|
|
|
WpsDto.Business business = new WpsDto.Business(); |
|
|
|
business.setBusinessId(competeTimeByType.getId()); |
|
|
|
business.setBusinessType((byte) 11); |
|
|
|
business.setFileName(file.getName()); |
|
|
|
business.setFilePath(path); |
|
|
|
business.setRealFilePath(path); |
|
|
|
business.setFileSize(file.length()); |
|
|
|
business.setUserId(params.getUserId()); |
|
|
|
business.setOperation(WebConstant.Wps.USER_OPERATION_NEW); |
|
|
|
business.setPrivilege(WebConstant.Wps.PROJECT_PRIVILEGE_READ); |
|
|
|
log.info("跳绳比赛报名表关联wps:{}", business); |
|
|
|
tallFeignClient.saveWpsFile(business); |
|
|
|
//查询wps
|
|
|
|
WpsDto.VisitWpsUrl visitWpsUrl = new WpsDto.VisitWpsUrl(); |
|
|
|
visitWpsUrl.setBusinessId(competeTimeByType.getId()); |
|
|
|
visitWpsUrl.setBusinessType((byte) 11); |
|
|
|
visitWpsUrl.setUserId(params.getUserId()); |
|
|
|
return tallFeignClient.queryVisitUrls(visitWpsUrl).get(0); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public String enrollPlayCountDownLoad() throws IOException { |
|
|
|
//查询该类型下所有项目的id,name,team信息,排除level为1的的集合
|
|
|
|
int typeId = 2; |
|
|
|
//放总数据集合
|
|
|
|
List<CompeteVo.GroupNum> list1 = new ArrayList<>(); |
|
|
|
//根据type 查项目
|
|
|
|
List<CompeteVo.ProjectInfo> projectInfoList = competeEnrollDao.getProject(typeId); |
|
|
|
//根据type 查组别id,组别名
|
|
|
|
List<CompeteVo.Count> groupIdAndNameList = competeEnrollDao.getGroupIdNameFromGroup(typeId); |
|
|
|
for (CompeteVo.ProjectInfo projectInfo : projectInfoList) { |
|
|
|
CompeteVo.GroupNum groupNum = new CompeteVo.GroupNum(); |
|
|
|
groupNum.setName(projectInfo.getName()); |
|
|
|
List<CompeteVo.Count> countList = new ArrayList<>(); |
|
|
|
if (CollectionUtil.isNotEmpty(groupIdAndNameList)) { |
|
|
|
for (CompeteVo.Count groupIdAndName : groupIdAndNameList) { |
|
|
|
CompeteVo.Count count1 = new CompeteVo.Count(); |
|
|
|
count1.setGroup_name(groupIdAndName.getGroup_name()); |
|
|
|
// groupIdAndNameList.forEach(groupIdAndName -> {
|
|
|
|
if (projectInfo.getTeam() == 0) { |
|
|
|
CompeteProjectPlayerExample projectPlayerExample = new CompeteProjectPlayerExample(); |
|
|
|
projectPlayerExample.createCriteria().andProjectIdEqualTo(projectInfo.getId()).andCompeteGroupIdEqualTo(groupIdAndName.getCompete_group_id()); |
|
|
|
long count = competeProjectPlayerMapper.countByExample(projectPlayerExample); |
|
|
|
count1.setCount((int) count); |
|
|
|
} else { |
|
|
|
CompeteTeamExample teamExample = new CompeteTeamExample(); |
|
|
|
teamExample.createCriteria().andProjectIdEqualTo(projectInfo.getId()).andCompeteGroupIdEqualTo(groupIdAndName.getCompete_group_id()); |
|
|
|
long count = competeTeamDao.countByExample(teamExample); |
|
|
|
count1.setCount((int) count); |
|
|
|
} |
|
|
|
// });
|
|
|
|
countList.add(count1); |
|
|
|
} |
|
|
|
} |
|
|
|
groupNum.setCountList(countList); |
|
|
|
list1.add(groupNum); |
|
|
|
} |
|
|
|
List<CompeteVo.GroupNum> list1 = enrollPlayCount(); |
|
|
|
//7:将数据放入excel表格
|
|
|
|
ResourceLoader resourceLoader = new DefaultResourceLoader(); |
|
|
|
InputStream is = resourceLoader.getResource("classpath:template/competeCount.xlsx").getInputStream(); |
|
|
@ -810,7 +793,7 @@ public class CompeteService implements ICompeteService { |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
return PropUtil.imgDomain + filepath; |
|
|
|
return PropUtil.domain + "file/download/know?path="+path; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -831,7 +814,6 @@ public class CompeteService implements ICompeteService { |
|
|
|
for (CompeteVo.Count groupIdAndName : groupIdAndNameList) { |
|
|
|
CompeteVo.Count count1 = new CompeteVo.Count(); |
|
|
|
count1.setGroup_name(groupIdAndName.getGroup_name()); |
|
|
|
// groupIdAndNameList.forEach(groupIdAndName -> {
|
|
|
|
if (projectInfo.getTeam() == 0) { |
|
|
|
CompeteProjectPlayerExample projectPlayerExample = new CompeteProjectPlayerExample(); |
|
|
|
projectPlayerExample.createCriteria().andProjectIdEqualTo(projectInfo.getId()).andCompeteGroupIdEqualTo(groupIdAndName.getCompete_group_id()); |
|
|
@ -843,7 +825,6 @@ public class CompeteService implements ICompeteService { |
|
|
|
long count = competeTeamDao.countByExample(teamExample); |
|
|
|
count1.setCount((int) count); |
|
|
|
} |
|
|
|
// });
|
|
|
|
countList.add(count1); |
|
|
|
} |
|
|
|
} |
|
|
|