|
|
@ -696,212 +696,97 @@ public class ExcelService implements IExcelService { |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public String iCompetitionOrderService(QueryDto<CompeteDto.CompeteTime> params) { |
|
|
|
List<CompeteExcelVo.AllProject> competeProjectList= competeCompanyDao.selectProjectByType(params.getParam().getCompeteTimeId()); |
|
|
|
for (int i=0;i<competeProjectList.size();i++){ |
|
|
|
CompeteExcelVo.AllProject competeProject=competeProjectList.get(i); |
|
|
|
SimpleDateFormat start=new SimpleDateFormat("HH:mm"); |
|
|
|
SimpleDateFormat end=new SimpleDateFormat("HH:mm"); |
|
|
|
SimpleDateFormat date=new SimpleDateFormat("MM-dd a"); |
|
|
|
String startStr=start.format(new Date(competeProject.getStartTime())); |
|
|
|
competeProject.setStartTimeStr(startStr); |
|
|
|
|
|
|
|
String endStr=end.format(new Date(competeProject.getEndTime())); |
|
|
|
competeProject.setEndTimeStr(endStr); |
|
|
|
String year=date.format(new Date(competeProject.getStartTime())); |
|
|
|
competeProject.setYear(year); |
|
|
|
int siteNum=competeProject.getSiteNum(); |
|
|
|
competeProject.setSiteNum(siteNum); |
|
|
|
int size; |
|
|
|
if(competeProject.getTeam().equals((byte) 0)){ |
|
|
|
List<CompeteExcelVo.TeamOrderPlayer> singleOrderPlayerList=competePlayerDao.selectSinglePlayerByProjectId(competeProject.getId()); |
|
|
|
size = singleOrderPlayerList.stream().mapToInt(singleOrderPlayer -> singleOrderPlayer.getCompanyNameList().size()).sum(); |
|
|
|
competeProject.setProjectList(singleOrderPlayerList); |
|
|
|
}else { |
|
|
|
List<CompeteExcelVo.TeamOrderPlayer> teamOrderPlayerList= competeTeamDao.selectTeamMemberByProjectId(competeProject.getId()); |
|
|
|
size = teamOrderPlayerList.stream().mapToInt(teamOrderPlayer -> teamOrderPlayer.getCompanyNameList().size()).sum(); |
|
|
|
competeProject.setProjectList(teamOrderPlayerList); |
|
|
|
} |
|
|
|
competeProject.setSize(size); |
|
|
|
} |
|
|
|
String dasia=competeTimeDao.selectByPrimaryKey(params.getParam().getCompeteTimeId()).getName(); |
|
|
|
//创建excle表格对象
|
|
|
|
List<List<PoiUtil.PoiUtilCell>> biao = new ArrayList<>(); |
|
|
|
List<PoiUtil.PoiUtilCell> one = new ArrayList<>(); |
|
|
|
PoiUtil.PoiUtilCell yuandongyuan=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 6, 1); |
|
|
|
yuandongyuan.setValue(dasia+"出场顺序表"); |
|
|
|
one.add(yuandongyuan); |
|
|
|
biao.add(one); |
|
|
|
|
|
|
|
|
|
|
|
for (int j=0 ;j<competeProjectList.size();j++){ |
|
|
|
List<PoiUtil.PoiUtilCell> three = new ArrayList<>(); |
|
|
|
PoiUtil.PoiUtilCell threeDate=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 6, 1); |
|
|
|
if(j==0){ |
|
|
|
threeDate.setValue(competeProjectList.get(j).getYear()); |
|
|
|
three.add(threeDate); |
|
|
|
biao.add(three); |
|
|
|
List<PoiUtil.PoiUtilCell> two = new ArrayList<>(); |
|
|
|
PoiUtil.PoiUtilCell two1=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|
|
|
two1.setValue("时间"); |
|
|
|
PoiUtil.PoiUtilCell two2=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|
|
|
two2.setValue("项目"); |
|
|
|
PoiUtil.PoiUtilCell two3=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|
|
|
two3.setValue("组别"); |
|
|
|
PoiUtil.PoiUtilCell two4=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|
|
|
two4.setValue("场次/场地"); |
|
|
|
PoiUtil.PoiUtilCell two5=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|
|
|
two5.setValue("参赛单位"); |
|
|
|
PoiUtil.PoiUtilCell two6=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|
|
|
two6.setValue("参赛人员"); |
|
|
|
two.add(two1); |
|
|
|
two.add(two2); |
|
|
|
two.add(two3); |
|
|
|
two.add(two4); |
|
|
|
two.add(two5); |
|
|
|
two.add(two6); |
|
|
|
biao.add(two); |
|
|
|
}else{ |
|
|
|
if (!competeProjectList.get(j).getYear().equals(competeProjectList.get(j-1).getYear())){ |
|
|
|
threeDate.setValue(competeProjectList.get(j).getYear()); |
|
|
|
three.add(threeDate); |
|
|
|
biao.add(three); |
|
|
|
List<PoiUtil.PoiUtilCell> two = new ArrayList<>(); |
|
|
|
PoiUtil.PoiUtilCell two1=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|
|
|
two1.setValue("时间"); |
|
|
|
PoiUtil.PoiUtilCell two2=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|
|
|
two2.setValue("项目"); |
|
|
|
PoiUtil.PoiUtilCell two3=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|
|
|
two3.setValue("组别"); |
|
|
|
PoiUtil.PoiUtilCell two4=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|
|
|
two4.setValue("场次/场地"); |
|
|
|
PoiUtil.PoiUtilCell two5=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|
|
|
two5.setValue("参赛单位"); |
|
|
|
PoiUtil.PoiUtilCell two6=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|
|
|
two6.setValue("参赛人员"); |
|
|
|
two.add(two1); |
|
|
|
two.add(two2); |
|
|
|
two.add(two3); |
|
|
|
two.add(two4); |
|
|
|
two.add(two5); |
|
|
|
two.add(two6); |
|
|
|
biao.add(two); |
|
|
|
} |
|
|
|
} |
|
|
|
//m行循环 是16次 k 是组次数得循环 4 次 n是组里面得循环
|
|
|
|
for(int k=0,m=0,n=0;m<competeProjectList.get(j).getSize();m++){ |
|
|
|
//代表一行
|
|
|
|
List<PoiUtil.PoiUtilCell> four = new ArrayList<>(); |
|
|
|
if(m==0){ |
|
|
|
PoiUtil.PoiUtilCell fourOne=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, competeProjectList.get(j).getSize()); |
|
|
|
fourOne.setValue(competeProjectList.get(j).getStartTimeStr()+"-"+competeProjectList.get(j).getEndTimeStr()); |
|
|
|
four.add(fourOne); |
|
|
|
PoiUtil.PoiUtilCell fourTwo=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, competeProjectList.get(j).getSize()); |
|
|
|
fourTwo.setValue(competeProjectList.get(j).getProjectName()); |
|
|
|
four.add(fourTwo); |
|
|
|
}else { |
|
|
|
four.add(new PoiUtil.PoiUtilCell()); |
|
|
|
four.add(new PoiUtil.PoiUtilCell()); |
|
|
|
} |
|
|
|
|
|
|
|
PoiUtil.PoiUtilCell fourThree=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, competeProjectList.get(j).getProjectList().get(k).getCompanyNameList().size()); |
|
|
|
if(n>0){ |
|
|
|
fourThree=new PoiUtil.PoiUtilCell(); |
|
|
|
}else { |
|
|
|
fourThree.setValue(competeProjectList.get(j).getProjectList().get(k++).getGroupName()); |
|
|
|
n++; |
|
|
|
} |
|
|
|
if(n==competeProjectList.get(j).getProjectList().get(k-1).getCompanyNameList().size()){ |
|
|
|
n=0; |
|
|
|
//k++
|
|
|
|
CompeteTime competeTime = competeTimeDao.selectByPrimaryKey(params.getParam().getCompeteTimeId()); |
|
|
|
|
|
|
|
if(competeTime!=null){ |
|
|
|
List<CompeteExcelVo.Project> allProjectList = competeScoreDao.selAllOrder(competeTime.getType()); |
|
|
|
List<List<PoiUtil.PoiUtilCell>> biao = new ArrayList<>(); |
|
|
|
List<PoiUtil.PoiUtilCell> one = new ArrayList<>(); |
|
|
|
PoiUtil.PoiUtilCell yuandongyuan=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 6, 1); |
|
|
|
yuandongyuan.setValue(competeTime.getName()+"出场顺序表"); |
|
|
|
one.add(yuandongyuan); |
|
|
|
biao.add(one); |
|
|
|
List<PoiUtil.PoiUtilCell> two = new ArrayList<>(); |
|
|
|
PoiUtil.PoiUtilCell two1=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|
|
|
two1.setValue("时间"); |
|
|
|
PoiUtil.PoiUtilCell two2=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|
|
|
two2.setValue("项目"); |
|
|
|
PoiUtil.PoiUtilCell two3=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|
|
|
two3.setValue("组别"); |
|
|
|
PoiUtil.PoiUtilCell two4=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|
|
|
two4.setValue("场次/场地"); |
|
|
|
PoiUtil.PoiUtilCell two5=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|
|
|
two5.setValue("参赛单位"); |
|
|
|
PoiUtil.PoiUtilCell two6=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|
|
|
two6.setValue("参赛人员"); |
|
|
|
two.add(two1); |
|
|
|
two.add(two2); |
|
|
|
two.add(two3); |
|
|
|
two.add(two4); |
|
|
|
two.add(two5); |
|
|
|
two.add(two6); |
|
|
|
biao.add(two); |
|
|
|
for (CompeteExcelVo.Project project : allProjectList) { |
|
|
|
int j = 0, q = 0;//一个项目得长度 项目循环
|
|
|
|
for (CompeteExcelVo.TeamOrderPlayer teamOrderPlayer : project.getProjectList()) { |
|
|
|
j += teamOrderPlayer.getCompanyNameList().size(); |
|
|
|
} |
|
|
|
four.add(fourThree); |
|
|
|
|
|
|
|
PoiUtil.PoiUtilCell fourFour=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|
|
|
int x=competeProjectList.get(j).getTeam(); |
|
|
|
if(x<=0){ |
|
|
|
x=2; |
|
|
|
} |
|
|
|
if((m+1)%x==0){ |
|
|
|
fourFour.setValue(""+((m+1)/x)+"--"+x); |
|
|
|
}else { |
|
|
|
fourFour.setValue(""+((m+1)/x+1)+"--"+((m+1)%x)); |
|
|
|
} |
|
|
|
four.add(fourFour); |
|
|
|
PoiUtil.PoiUtilCell fourFive=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|
|
|
if(n==0){ |
|
|
|
log.info("j:{}, k:{}, n:{}", j,k,n); |
|
|
|
fourFive.setValue(competeProjectList.get(j).getProjectList().get(k-1).getCompanyNameList().get(n).getCompanyName()); |
|
|
|
}else { |
|
|
|
fourFive.setValue(competeProjectList.get(j).getProjectList().get(k-1).getCompanyNameList().get(n-1).getCompanyName()); |
|
|
|
} |
|
|
|
four.add(fourFive); |
|
|
|
PoiUtil.PoiUtilCell fourSix=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|
|
|
if(n==0){ |
|
|
|
fourSix.setValue(competeProjectList.get(j).getProjectList().get(k-1).getCompanyNameList().get(n).getPlayerNames()); |
|
|
|
}else { |
|
|
|
fourSix.setValue(competeProjectList.get(j).getProjectList().get(k-1).getCompanyNameList().get(n-1).getPlayerNames()); |
|
|
|
for (int k = 0; k < project.getProjectList().size(); k++) { |
|
|
|
int t = 0;//组别得长度 组别循环
|
|
|
|
for (int m = 0; m < project.getProjectList().get(k).getCompanyNameList().size(); m++) { |
|
|
|
List<PoiUtil.PoiUtilCell> three = new ArrayList<>(); |
|
|
|
PoiUtil.PoiUtilCell three1; |
|
|
|
PoiUtil.PoiUtilCell three2; |
|
|
|
if (q == 0) { |
|
|
|
three1 = new PoiUtil.PoiUtilCell(project.getStartTime(), 1, j); |
|
|
|
three2 = new PoiUtil.PoiUtilCell(project.getProjectName(), 1, j); |
|
|
|
q++; |
|
|
|
} else { |
|
|
|
three1 = new PoiUtil.PoiUtilCell(); |
|
|
|
three2 = new PoiUtil.PoiUtilCell(); |
|
|
|
} |
|
|
|
PoiUtil.PoiUtilCell three3; |
|
|
|
if (t == 0) { |
|
|
|
three3 = new PoiUtil.PoiUtilCell(project.getProjectList().get(k).getGroupName(), 1, project.getProjectList().get(k).getCompanyNameList().size()); |
|
|
|
++t; |
|
|
|
} else { |
|
|
|
three3 = new PoiUtil.PoiUtilCell(); |
|
|
|
} |
|
|
|
PoiUtil.PoiUtilCell three4 = new PoiUtil.PoiUtilCell(project.getProjectList().get(k).getCompanyNameList().get(m).getStartOrder(), 1, 1); |
|
|
|
PoiUtil.PoiUtilCell three5 = new PoiUtil.PoiUtilCell(project.getProjectList().get(k).getCompanyNameList().get(m).getCompanyName(), 1, 1); |
|
|
|
PoiUtil.PoiUtilCell three6 = new PoiUtil.PoiUtilCell(project.getProjectList().get(k).getCompanyNameList().get(m).getPlayerName(), 1, 1); |
|
|
|
three.add(three1); |
|
|
|
three.add(three2); |
|
|
|
three.add(three3); |
|
|
|
three.add(three4); |
|
|
|
three.add(three5); |
|
|
|
three.add(three6); |
|
|
|
biao.add(three); |
|
|
|
} |
|
|
|
} |
|
|
|
four.add(fourSix); |
|
|
|
biao.add(four); |
|
|
|
} |
|
|
|
Workbook workbook = new XSSFWorkbook(); |
|
|
|
PoiUtil.exportWB("出场顺序表",biao,workbook); |
|
|
|
String filepath = "mt/" + DateUtil.today() + "/" + System.currentTimeMillis() + ".xlsx"; |
|
|
|
String path = PropUtil.path + filepath; |
|
|
|
String path1="C:/d/"+filepath;//本地的路径
|
|
|
|
File tmpFile = new File(path); |
|
|
|
if (!tmpFile.getParentFile().exists()) { |
|
|
|
tmpFile.getParentFile().mkdirs(); |
|
|
|
} |
|
|
|
File file = new File(path); |
|
|
|
try { |
|
|
|
OutputStream outputStream = new FileOutputStream(file); |
|
|
|
workbook.write(outputStream); |
|
|
|
outputStream.close(); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
return PropUtil.domain + "file/download/know?path="+path; |
|
|
|
} |
|
|
|
|
|
|
|
Workbook workbook = new XSSFWorkbook(); |
|
|
|
PoiUtil.exportWB("出场顺序",biao,workbook); |
|
|
|
String filepath = "mt/" + DateUtil.today() + "/" + System.currentTimeMillis() + ".xlsx"; |
|
|
|
String path = PropUtil.path + filepath; |
|
|
|
String path1="C:/d/"+filepath;//本地的路径
|
|
|
|
File tmpFile = new File(path); |
|
|
|
if (!tmpFile.getParentFile().exists()) { |
|
|
|
tmpFile.getParentFile().mkdirs(); |
|
|
|
} |
|
|
|
File file = new File(path); |
|
|
|
try { |
|
|
|
OutputStream outputStream = new FileOutputStream(file); |
|
|
|
workbook.write(outputStream); |
|
|
|
outputStream.close(); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
return PropUtil.domain + "file/download/know?path="+path; |
|
|
|
return ""; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
private List<TableVo.CompeteAllCount> competeAllCountList(CompeteDto.CompeteTime params){ |
|
|
|
//查询个人赛的数量统计
|
|
|
|
|
|
|
|