|
|
@ -3,6 +3,7 @@ import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import cn.hutool.core.util.IdcardUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.ccsens.mt.bean.dto.CompeteDto; |
|
|
|
import com.ccsens.mt.bean.dto.ProvinceCompeteDto; |
|
|
|
import com.ccsens.mt.bean.dto.ScoreDto; |
|
|
@ -13,6 +14,7 @@ import com.ccsens.mt.bean.vo.ScoreVo; |
|
|
|
import com.ccsens.mt.bean.vo.TableVo; |
|
|
|
import com.ccsens.mt.persist.dao.*; |
|
|
|
import com.ccsens.mt.persist.mapper.*; |
|
|
|
import com.ccsens.mt.util.Constant; |
|
|
|
import com.ccsens.util.CodeEnum; |
|
|
|
import com.ccsens.util.PoiUtil; |
|
|
|
import com.ccsens.util.PropUtil; |
|
|
@ -41,6 +43,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.unit.DataUnit; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.validation.constraints.NotNull; |
|
|
|
import java.io.File; |
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.io.IOException; |
|
|
@ -52,6 +55,9 @@ import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.GregorianCalendar; |
|
|
|
import java.util.List; |
|
|
|
import java.util.concurrent.ExecutorService; |
|
|
|
import java.util.concurrent.Executors; |
|
|
|
import java.util.concurrent.Future; |
|
|
|
|
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
@ -94,6 +100,8 @@ public class ExcelService implements IExcelService { |
|
|
|
private CompeteScoreDao competeScoreDao; |
|
|
|
@Resource |
|
|
|
private ICompeteService competeService; |
|
|
|
@Resource |
|
|
|
private CompeteScoreDao competeScoreDao; |
|
|
|
|
|
|
|
@Override |
|
|
|
public String dasaiduiwuxinxiWPS(QueryDto<CompeteDto.CompeteTime> params) { |
|
|
@ -1587,5 +1595,81 @@ public class ExcelService implements IExcelService { |
|
|
|
return PropUtil.domain + "file/download/know?path="+path; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public String beforeEight(QueryDto<CompeteDto.CompeteTime> params) { |
|
|
|
log.info("到处{}大赛各项的前八名", params); |
|
|
|
// 查询项目
|
|
|
|
Long competeTimeId = params.getParam().getCompeteTimeId(); |
|
|
|
List<CompeteProject> list = competeProjectDao.queryProject(competeTimeId); |
|
|
|
Workbook workbook = new XSSFWorkbook(); |
|
|
|
|
|
|
|
list.forEach(project -> { |
|
|
|
List<CompeteExcelVo.BeforeEight> eights; |
|
|
|
// 个人赛
|
|
|
|
if (project.getTeam().byteValue() == Constant.Compete.TEAM_NO) { |
|
|
|
eights = competeScoreDao.queryEight(project.getId(), competeTimeId); |
|
|
|
} else { |
|
|
|
// 团体赛
|
|
|
|
eights = competeScoreDao.queryEightFancyRope(project.getId(), competeTimeId); |
|
|
|
} |
|
|
|
List<List<PoiUtil.PoiUtilCell>> raws = new ArrayList<>(); |
|
|
|
initTitle(project, raws); |
|
|
|
eights.forEach(eight -> { |
|
|
|
|
|
|
|
if (StrUtil.isEmpty(eight.getEightNames())) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
List<PoiUtil.PoiUtilCell> cells = new ArrayList<>(); |
|
|
|
cells.add(new PoiUtil.PoiUtilCell(eight.getGroupName())); |
|
|
|
String[] split = eight.getEightNames().split(","); |
|
|
|
for (String name: split) { |
|
|
|
cells.add(new PoiUtil.PoiUtilCell(name)); |
|
|
|
} |
|
|
|
raws.add(cells); |
|
|
|
}); |
|
|
|
PoiUtil.exportWB(project.getName(), raws, workbook); |
|
|
|
}); |
|
|
|
String filepath = "mt/" + DateUtil.today() + "/" + System.currentTimeMillis() + ".xlsx"; |
|
|
|
String path = PropUtil.path + filepath; |
|
|
|
File file = new File(path); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
if (!file.getParentFile().exists()) { |
|
|
|
file.getParentFile().mkdirs(); |
|
|
|
} |
|
|
|
// if (!file.exists()) {
|
|
|
|
// file.createNewFile();
|
|
|
|
// }
|
|
|
|
OutputStream outputStream = new FileOutputStream(file); |
|
|
|
workbook.write(outputStream); |
|
|
|
outputStream.close(); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
return PropUtil.domain + "file/download/know?path="+path; |
|
|
|
} |
|
|
|
|
|
|
|
private void initTitle(CompeteProject project, List<List<PoiUtil.PoiUtilCell>> raws) { |
|
|
|
List<PoiUtil.PoiUtilCell> title = new ArrayList<>(); |
|
|
|
title.add(new PoiUtil.PoiUtilCell( "2020年山西省学生跳绳比赛", 9 , 1)); |
|
|
|
raws.add(title); |
|
|
|
List<PoiUtil.PoiUtilCell> title2 = new ArrayList<>(); |
|
|
|
title2.add(new PoiUtil.PoiUtilCell(project.getName() , 9 , 1)); |
|
|
|
raws.add(title2); |
|
|
|
List<PoiUtil.PoiUtilCell> head = new ArrayList<>(); |
|
|
|
head.add(new PoiUtil.PoiUtilCell("")); |
|
|
|
head.add(new PoiUtil.PoiUtilCell("第一名")); |
|
|
|
head.add(new PoiUtil.PoiUtilCell("第二名")); |
|
|
|
head.add(new PoiUtil.PoiUtilCell("第三名")); |
|
|
|
head.add(new PoiUtil.PoiUtilCell("第四名")); |
|
|
|
head.add(new PoiUtil.PoiUtilCell("第五名")); |
|
|
|
head.add(new PoiUtil.PoiUtilCell("第六名")); |
|
|
|
head.add(new PoiUtil.PoiUtilCell("第七名")); |
|
|
|
head.add(new PoiUtil.PoiUtilCell("第八名")); |
|
|
|
raws.add(head); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|