Commit 8e4c5a7b authored by yangshuxing's avatar yangshuxing

Merge remote-tracking branch 'remotes/origin/master' into v2.0

parents a881ed79 f646b50b
...@@ -9,10 +9,9 @@ import com.neusoft.www.utils.web.Result; ...@@ -9,10 +9,9 @@ import com.neusoft.www.utils.web.Result;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
...@@ -260,6 +259,13 @@ public class ScoreController { ...@@ -260,6 +259,13 @@ public class ScoreController {
@RequestMapping("export/{cmptId}") @RequestMapping("export/{cmptId}")
public void export(@PathVariable("cmptId") Integer cmptId,HttpServletResponse response) throws IOException { public void export(@PathVariable("cmptId") Integer cmptId,HttpServletResponse response) throws IOException {
Workbook book = new HSSFWorkbook();
HSSFCellStyle cellStyle = (HSSFCellStyle) book.createCellStyle();
//垂直居中
cellStyle.setVerticalAlignment(cellStyle.getVerticalAlignmentEnum().CENTER);
//水平居中
cellStyle.setAlignment(HorizontalAlignment.CENTER);
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
response.setContentType("application/octet-stream; charset=utf-8"); response.setContentType("application/octet-stream; charset=utf-8");
response.setHeader("Content-Disposition", "attachment; filename="+URLEncoder.encode("名单.xls","UTF-8")); response.setHeader("Content-Disposition", "attachment; filename="+URLEncoder.encode("名单.xls","UTF-8"));
...@@ -271,7 +277,7 @@ public class ScoreController { ...@@ -271,7 +277,7 @@ public class ScoreController {
List<CmptScoreRule> rules = cmptScoreRuleService.getCmptScoreRulesByCmptId(cmptId); List<CmptScoreRule> rules = cmptScoreRuleService.getCmptScoreRulesByCmptId(cmptId);
Workbook book = new HSSFWorkbook();
roadsStatistic.forEach(road -> { roadsStatistic.forEach(road -> {
...@@ -341,13 +347,14 @@ public class ScoreController { ...@@ -341,13 +347,14 @@ public class ScoreController {
row.createCell(3).setCellValue("参赛号码"); row.createCell(3).setCellValue("参赛号码");
row.createCell(4).setCellValue("合计用时"); row.createCell(4).setCellValue("合计用时");
row.createCell(5).setCellValue("合计排名"); row.createCell(5).setCellValue("合计排名");
row.createCell(6).setCellValue("分段成绩"); row.createCell(6).setCellValue("合计打卡次数");
row.createCell(7).setCellValue("完成时间"); row.createCell(7).setCellValue("分段成绩");
row.createCell(8).setCellValue("提交时间"); row.createCell(8).setCellValue("完成时间");
row.createCell(9).setCellValue("用时"); row.createCell(9).setCellValue("提交时间");
row.createCell(10).setCellValue("里程");//用户填写的里程数 row.createCell(10).setCellValue("用时");
row.createCell(11).setCellValue("里程");//用户填写的里程数
for(int m=0;m < fields.size();m++){ for(int m=0;m < fields.size();m++){
row.createCell(11+m).setCellValue(fields.get(m).getFieldName()); row.createCell(12+m).setCellValue(fields.get(m).getFieldName());
} }
int startNum = 1; int startNum = 1;
...@@ -373,31 +380,48 @@ public class ScoreController { ...@@ -373,31 +380,48 @@ public class ScoreController {
int finalJ = j; int finalJ = j;
int sq = seq.getAndIncrement(); int sq = seq.getAndIncrement();
first.ifPresent(scoreExcelBean -> { first.ifPresent(scoreExcelBean -> {
sub.createCell(6).setCellValue("第"+sq+"次成绩"); sub.createCell(7).setCellValue("第"+sq+"次成绩");
sub.createCell(7).setCellValue(scoreExcelBean.getDate()); sub.createCell(8).setCellValue(scoreExcelBean.getDate());
sub.createCell(8).setCellValue(scoreExcelBean.getInsertTime()); sub.createCell(9).setCellValue(scoreExcelBean.getInsertTime());
sub.createCell(9).setCellValue(DateUtil.formatDate(scoreExcelBean.getDuration())); sub.createCell(10).setCellValue(DateUtil.formatDate(scoreExcelBean.getDuration()));
sub.createCell(10).setCellValue(String.format("%.3f",scoreExcelBean.getSubsectionMileage()/1000.0)+"KM"); sub.createCell(11).setCellValue(String.format("%.3f",scoreExcelBean.getSubsectionMileage()/1000.0)+"KM");
List<CmptScoreFieldValue> fieldValues = scoreExcelBean.getFieldValues(); List<CmptScoreFieldValue> fieldValues = scoreExcelBean.getFieldValues();
for(int m=0;m < fieldValues.size();m++){ for(int m=0;m < fieldValues.size();m++){
sub.createCell(11+m).setCellValue(fieldValues.get(m).getScoreFieldValue()); sub.createCell(12+m).setCellValue(fieldValues.get(m).getScoreFieldValue());
} }
}); });
} }
Row workRow = sheet.getRow(startNum); Row workRow = sheet.getRow(startNum);
workRow.createCell(0).setCellValue(user.getMember_name());
workRow.createCell(1).setCellValue("0".equals(user.getSex()) ? "男":"女"); Cell cell = workRow.createCell(0);
cell.setCellValue(user.getMember_name());
cell.setCellStyle(cellStyle);
Cell cell1 = workRow.createCell(1);
cell1.setCellValue("0".equals(user.getSex()) ? "男":"女");
cell1.setCellStyle(cellStyle);
Cell cell2 = workRow.createCell(2);
cell2.setCellValue(user.getItem_name());
cell2.setCellStyle(cellStyle);
workRow.createCell(2).setCellValue(user.getItem_name()); Cell cell3 = workRow.createCell(3);
cell3.setCellValue(user.getMarkNo());
cell3.setCellStyle(cellStyle);
workRow.createCell(3).setCellValue(user.getMarkNo()); Cell cell4 = workRow.createCell(4);
cell4.setCellValue(doneScoreList.get(i).getDurationStr());
cell4.setCellStyle(cellStyle);
workRow.createCell(4).setCellValue(doneScoreList.get(i).getDurationStr()); Cell cell5 = workRow.createCell(5);
cell5.setCellValue(doneScoreList.get(i).getRankNo());
cell5.setCellStyle(cellStyle);
workRow.createCell(5).setCellValue(doneScoreList.get(i).getRankNo()); Cell cell6 = workRow.createCell(6);
cell6.setCellValue(userScoreExcelBean.getScores().size());
cell6.setCellStyle(cellStyle);
if(rules.size() > 1){ if(rules.size() > 1){
sheet.addMergedRegion(new CellRangeAddress(startNum,rollNum,0,0)); sheet.addMergedRegion(new CellRangeAddress(startNum,rollNum,0,0));
...@@ -406,6 +430,7 @@ public class ScoreController { ...@@ -406,6 +430,7 @@ public class ScoreController {
sheet.addMergedRegion(new CellRangeAddress(startNum,rollNum,3,3)); sheet.addMergedRegion(new CellRangeAddress(startNum,rollNum,3,3));
sheet.addMergedRegion(new CellRangeAddress(startNum,rollNum,4,4)); sheet.addMergedRegion(new CellRangeAddress(startNum,rollNum,4,4));
sheet.addMergedRegion(new CellRangeAddress(startNum,rollNum,5,5)); sheet.addMergedRegion(new CellRangeAddress(startNum,rollNum,5,5));
sheet.addMergedRegion(new CellRangeAddress(startNum,rollNum,6,6));
} }
...@@ -416,12 +441,28 @@ public class ScoreController { ...@@ -416,12 +441,28 @@ public class ScoreController {
for(int i=0; i < noneScoreList.size();i++){ for(int i=0; i < noneScoreList.size();i++){
EnrollUser user = noneScoreList.get(i).getUser(); EnrollUser user = noneScoreList.get(i).getUser();
Row workRow = sheet.createRow(sheet.getLastRowNum()+1); Row workRow = sheet.createRow(sheet.getLastRowNum()+1);
workRow.createCell(0).setCellValue(user.getMember_name()); Cell cell = workRow.createCell(0);
workRow.createCell(1).setCellValue("0".equals(user.getSex()) ? "男":"女"); cell.setCellValue(user.getMember_name());
workRow.createCell(2).setCellValue(user.getItem_name()); cell.setCellStyle(cellStyle);
workRow.createCell(3).setCellValue(user.getMarkNo());
workRow.createCell(4).setCellValue(noneScoreList.get(i).getDurationStr()); Cell cell1 = workRow.createCell(1);
workRow.createCell(5).setCellValue(noneScoreList.get(i).getRankNo()); cell1.setCellValue("0".equals(user.getSex()) ? "男":"女");
cell1.setCellStyle(cellStyle);
Cell cell2 = workRow.createCell(2);
cell2.setCellValue(user.getItem_name());
cell2.setCellStyle(cellStyle);
Cell cell3 = workRow.createCell(3);
cell3.setCellValue(user.getMarkNo());
cell3.setCellStyle(cellStyle);
Cell cell4 = workRow.createCell(4);
cell4.setCellValue(noneScoreList.get(i).getDurationStr());
cell4.setCellStyle(cellStyle);
Cell cell5 = workRow.createCell(5);
cell5.setCellValue(noneScoreList.get(i).getRankNo());
cell5.setCellStyle(cellStyle);
Cell cell6 = workRow.createCell(5);
cell6.setCellValue(noneScoreList.get(i).getScores().size());
cell6.setCellStyle(cellStyle);
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment