|
|
@ -24,6 +24,8 @@ import com.ccsens.util.exception.BaseException; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.poi.ss.usermodel.Workbook; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
|
|
import org.springframework.core.io.DefaultResourceLoader; |
|
|
|
import org.springframework.core.io.ResourceLoader; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
@ -613,6 +615,7 @@ public class CompeteService implements ICompeteService{ |
|
|
|
//查询报名信息
|
|
|
|
int typeId = competeType.getType(); |
|
|
|
ArrayList<CompeteVo.EnrollPlayInfo> arrayList = new ArrayList(); |
|
|
|
List<String> string = null; |
|
|
|
//1:查询该类型下所有项目的id,name,team信息,排除level为1的
|
|
|
|
List<CompeteVo.ProjectInfo> projectInfoList = competeEnrollDao.getProject(typeId); |
|
|
|
//2:根据team字段判断是否为团队项目
|
|
|
@ -681,7 +684,6 @@ public class CompeteService implements ICompeteService{ |
|
|
|
//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()) { |
|
|
@ -715,7 +717,88 @@ public class CompeteService implements ICompeteService{ |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
return filePath.get(0); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public String enrollPlayCount(QueryDto<CompeteDto.CompeteType> params) 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); |
|
|
|
} |
|
|
|
//7:将数据放入excel表格
|
|
|
|
ResourceLoader resourceLoader = new DefaultResourceLoader(); |
|
|
|
InputStream is = resourceLoader.getResource("classpath:template/competeCount.xlsx").getInputStream(); |
|
|
|
Workbook workbook = new XSSFWorkbook(is); |
|
|
|
//生成excel表格对象,并将数据放入
|
|
|
|
//生成表对象
|
|
|
|
List<List<PoiUtil.PoiUtilCell>> list = new ArrayList<>(); |
|
|
|
//生成行对象
|
|
|
|
List<PoiUtil.PoiUtilCell> poiUtilCellList1 = new ArrayList<>(); |
|
|
|
List<PoiUtil.PoiUtilCell> poiUtilCellList2 = new ArrayList<>(); |
|
|
|
List<PoiUtil.PoiUtilCell> poiUtilCellList3 = new ArrayList<>(); |
|
|
|
list.add(poiUtilCellList1); |
|
|
|
list.add(poiUtilCellList2); |
|
|
|
list.add(poiUtilCellList3); |
|
|
|
|
|
|
|
list1.forEach(excelist ->{ |
|
|
|
List<PoiUtil.PoiUtilCell> title = new ArrayList<>(); |
|
|
|
title.add(new PoiUtil.PoiUtilCell()); |
|
|
|
title.add(new PoiUtil.PoiUtilCell()); |
|
|
|
title.add(new PoiUtil.PoiUtilCell()); |
|
|
|
excelist.getCountList().forEach(count -> { |
|
|
|
title.add(new PoiUtil.PoiUtilCell(String.valueOf(count.getCount()))); |
|
|
|
}); |
|
|
|
list.add(title); |
|
|
|
}); |
|
|
|
Workbook wbs = PoiUtil.exportWB("统计表", list, workbook); |
|
|
|
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(); |
|
|
|
} |
|
|
|
File file = new File(path); |
|
|
|
try { |
|
|
|
OutputStream outputStream = new FileOutputStream(file); |
|
|
|
wbs.write(outputStream); |
|
|
|
outputStream.close(); |
|
|
|
}catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
return PropUtil.imgDomain + filepath; |
|
|
|
} |
|
|
|
} |
|
|
|