diff --git a/mt/src/main/java/com/ccsens/mt/bean/vo/CompeteExcelVo.java b/mt/src/main/java/com/ccsens/mt/bean/vo/CompeteExcelVo.java index afc375ca..f1fd1a83 100644 --- a/mt/src/main/java/com/ccsens/mt/bean/vo/CompeteExcelVo.java +++ b/mt/src/main/java/com/ccsens/mt/bean/vo/CompeteExcelVo.java @@ -32,7 +32,7 @@ public class CompeteExcelVo { @ApiModelProperty("单位名称") private String companyName; @ApiModelProperty("团队选手名字") - private String playerNames; + private String playerName; } @Data diff --git a/mt/src/main/java/com/ccsens/mt/persist/dao/CompeteScoreDao.java b/mt/src/main/java/com/ccsens/mt/persist/dao/CompeteScoreDao.java index 98dbefd7..cbdba9a9 100644 --- a/mt/src/main/java/com/ccsens/mt/persist/dao/CompeteScoreDao.java +++ b/mt/src/main/java/com/ccsens/mt/persist/dao/CompeteScoreDao.java @@ -104,4 +104,10 @@ public interface CompeteScoreDao { * @return */ List selCanSaiDuiWuMes(); + + /** + * 查询出场顺序表(导出表格用) + * @return + */ + List selAllOrder(@Param("type") byte type); } diff --git a/mt/src/main/java/com/ccsens/mt/service/ExcelService.java b/mt/src/main/java/com/ccsens/mt/service/ExcelService.java index ab453062..edcb533a 100644 --- a/mt/src/main/java/com/ccsens/mt/service/ExcelService.java +++ b/mt/src/main/java/com/ccsens/mt/service/ExcelService.java @@ -696,212 +696,97 @@ public class ExcelService implements IExcelService { */ @Override public String iCompetitionOrderService(QueryDto params) { - List competeProjectList= competeCompanyDao.selectProjectByType(params.getParam().getCompeteTimeId()); - for (int i=0;i singleOrderPlayerList=competePlayerDao.selectSinglePlayerByProjectId(competeProject.getId()); - size = singleOrderPlayerList.stream().mapToInt(singleOrderPlayer -> singleOrderPlayer.getCompanyNameList().size()).sum(); - competeProject.setProjectList(singleOrderPlayerList); - }else { - List 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> biao = new ArrayList<>(); - List 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 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 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 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 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 allProjectList = competeScoreDao.selAllOrder(competeTime.getType()); + List> biao = new ArrayList<>(); + List 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 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 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 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 competeProjectList = competeProjectMapper.selectByExample(competeProjectExample); -// CompeteGroupExample competeGroupExample = new CompeteGroupExample(); -// competeGroupExample.createCriteria().andTypeEqualTo((byte) type); -// //获取组别集合 -// List 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 competeAllCountList(CompeteDto.CompeteTime params){ //查询个人赛的数量统计 diff --git a/mt/src/main/resources/mapper_dao/CompeteScoreDao.xml b/mt/src/main/resources/mapper_dao/CompeteScoreDao.xml index c060d25d..5bde88b5 100644 --- a/mt/src/main/resources/mapper_dao/CompeteScoreDao.xml +++ b/mt/src/main/resources/mapper_dao/CompeteScoreDao.xml @@ -862,6 +862,116 @@ ORDER BY tt.id + + + + + + + + + + + + + + + +