wang0018 5 years ago
parent
commit
8c2d2aed2f
  1. 2
      mt/src/main/java/com/ccsens/mt/api/ExcelController.java
  2. 116
      mt/src/main/java/com/ccsens/mt/service/ExcelService.java
  3. 2
      mt/src/main/java/com/ccsens/mt/service/IExcelService.java
  4. 4
      mt/src/main/resources/application.yml
  5. 3
      util/src/main/java/com/ccsens/util/PoiUtil.java

2
mt/src/main/java/com/ccsens/mt/api/ExcelController.java

@ -69,7 +69,7 @@ public class ExcelController {
@MustLogin @MustLogin
@ApiOperation(value = "XXX比赛报名汇总表(导出)", notes = "") @ApiOperation(value = "XXX比赛报名汇总表(导出)", notes = "")
@RequestMapping(value = "/competeAllCount", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RequestMapping(value = "/competeAllCount", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse competeAllCount(@ApiParam @Validated @RequestBody QueryDto<CompeteDto.CompeteTime> params) throws IOException { public JsonResponse competeAllCount(@ApiParam @Validated @RequestBody QueryDto<CompeteDto.CompeteTime> params) throws Exception {
log.info("XXX比赛报名汇总表:{}",params); log.info("XXX比赛报名汇总表:{}",params);
String path = excelService.competeAllCount(params.getParam()); String path = excelService.competeAllCount(params.getParam());
return JsonResponse.newInstance().ok(path); return JsonResponse.newInstance().ok(path);

116
mt/src/main/java/com/ccsens/mt/service/ExcelService.java

@ -590,7 +590,7 @@ public class ExcelService implements IExcelService {
} }
@Override @Override
public String competeAllCount(CompeteDto.CompeteTime params) throws IOException { public String competeAllCount(CompeteDto.CompeteTime params) throws Exception {
List<TableVo.CompeteAllCount1> competeAllCountList = competeAllCountList1(params.getCompeteTimeId()); List<TableVo.CompeteAllCount1> competeAllCountList = competeAllCountList1(params.getCompeteTimeId());
return getExcelFilePathForCompeteAllCount(competeAllCountList); return getExcelFilePathForCompeteAllCount(competeAllCountList);
} }
@ -721,7 +721,7 @@ public class ExcelService implements IExcelService {
} }
private String getExcelFilePathForCompeteAllCount(List<TableVo.CompeteAllCount1> arrayList) throws IOException { private String getExcelFilePathForCompeteAllCount(List<TableVo.CompeteAllCount1> arrayList) throws Exception {
//创建excle表格对象 //创建excle表格对象
List<List<PoiUtil.PoiUtilCell>> list = new ArrayList<>(); List<List<PoiUtil.PoiUtilCell>> list = new ArrayList<>();
//创建行对象 //创建行对象
@ -773,6 +773,118 @@ public class ExcelService implements IExcelService {
list.add(cells); list.add(cells);
i++; i++;
a++; a++;
if (competeAllCount.getProjectId()==2017){
cells = new ArrayList<>();
PoiUtil.PoiUtilCell poiUtilCel = new PoiUtil.PoiUtilCell();
poiUtilCel.setValue("--");
cells.add(poiUtilCel);
PoiUtil.PoiUtilCell poiUtilCel1 = new PoiUtil.PoiUtilCell();
poiUtilCel1.setValue("合计");
cells.add(poiUtilCel1);
for (int j = 3; j <19 ; j++) {
PoiUtil.PoiUtilCell poiUtilCel2 = new PoiUtil.PoiUtilCell();
if (j==3){
poiUtilCel2.setValue("");
poiUtilCel2.setFunction("sum(C2:C8)");
cells.add(poiUtilCel2);
}
if (j==4){
poiUtilCel2.setValue("");
poiUtilCel2.setFunction("sum(D2:D8)");
cells.add(poiUtilCel2);
}
if (j==5){
poiUtilCel2.setValue("");
poiUtilCel2.setFunction("sum(E2:E8)");
cells.add(poiUtilCel2);
}
if (j==6){
poiUtilCel2.setValue("");
poiUtilCel2.setFunction("sum(F2:F8)");
cells.add(poiUtilCel2);
} if (j==7){
poiUtilCel2.setValue("");
poiUtilCel2.setFunction("sum(G2:G8)");
cells.add(poiUtilCel2);
} if (j==8){
poiUtilCel2.setValue("");
poiUtilCel2.setFunction("sum(H2:H8)");
cells.add(poiUtilCel2);
} if (j==9){
poiUtilCel2.setValue("");
poiUtilCel2.setFunction("sum(I2:I8)");
cells.add(poiUtilCel2);
} if (j==10){
poiUtilCel2.setValue("");
poiUtilCel2.setFunction("sum(J2:J8)");
cells.add(poiUtilCel2);
} if (j==11){
poiUtilCel2.setValue("");
poiUtilCel2.setFunction("sum(K2:K8)");
cells.add(poiUtilCel2);
}
if (j==12){
poiUtilCel2.setValue("");
poiUtilCel2.setFunction("sum(L2:L8)");
cells.add(poiUtilCel2);
}
if (j==13){
poiUtilCel2.setValue("");
poiUtilCel2.setFunction("sum(M2:N8)");
cells.add(poiUtilCel2);
}
if (j==14){
poiUtilCel2.setValue("");
poiUtilCel2.setFunction("sum(N2:N8)");
cells.add(poiUtilCel2);
}
if (j==15){
poiUtilCel2.setValue("");
poiUtilCel2.setFunction("sum(O2:O8)");
cells.add(poiUtilCel2);
}
if (j==16){
poiUtilCel2.setValue("");
poiUtilCel2.setFunction("sum(P2:P8)");
cells.add(poiUtilCel2);
}
if (j==17){
poiUtilCel2.setValue("");
poiUtilCel2.setFunction("sum(Q2:Q8)");
cells.add(poiUtilCel2);
}
if (j==18){
poiUtilCel2.setValue("");
poiUtilCel2.setFunction("sum(R2:R8)");
cells.add(poiUtilCel2);
}
// String T1 = PoiUtil.toRadix(j);
// poiUtilCel2.setFunction("sum(c"+2+":c"+8+")");
}
list.add(cells);
}
if (competeAllCount.getProjectId()==2026){
cells = new ArrayList<>();
PoiUtil.PoiUtilCell poiUtilCel = new PoiUtil.PoiUtilCell();
poiUtilCel.setValue("--");
cells.add(poiUtilCel);
PoiUtil.PoiUtilCell poiUtilCel1 = new PoiUtil.PoiUtilCell();
poiUtilCel1.setValue("合计");
cells.add(poiUtilCel1);
PoiUtil.PoiUtilCell poiUtilCel2 = new PoiUtil.PoiUtilCell(3 + "", 15, 1, 300, 18);
poiUtilCel2.setValue("");
poiUtilCel2.setFunction("sum(C10:C18)");
cells.add(poiUtilCel2);
PoiUtil.PoiUtilCell poiUtilCel3 = new PoiUtil.PoiUtilCell();
poiUtilCel3.setValue("");
poiUtilCel3.setFunction("sum(R2:C19)");
cells.add(poiUtilCel3);
list.add(cells);
}
} }
//生成excel表格对象,并将数据放入 //生成excel表格对象,并将数据放入
Workbook wbs = PoiUtil.exportWB("比赛报名汇总表", list, workbook); Workbook wbs = PoiUtil.exportWB("比赛报名汇总表", list, workbook);

2
mt/src/main/java/com/ccsens/mt/service/IExcelService.java

@ -58,7 +58,7 @@ public interface IExcelService {
* @param params 大赛id * @param params 大赛id
* @return 返回失败的信息 * @return 返回失败的信息
*/ */
String competeAllCount(CompeteDto.CompeteTime params) throws IOException; String competeAllCount(CompeteDto.CompeteTime params) throws Exception;
String iCompetitionOrderService(QueryDto<CompeteDto.CompeteTime> params); String iCompetitionOrderService(QueryDto<CompeteDto.CompeteTime> params);

4
mt/src/main/resources/application.yml

@ -1,6 +1,6 @@
spring: spring:
profiles: profiles:
active: prod active: dev
include: common, util-prod include: common, util-dev

3
util/src/main/java/com/ccsens/util/PoiUtil.java

@ -597,6 +597,9 @@ public class PoiUtil {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
String s = toRadix(3);
System.out.println(s);
// File file = new File("F:\\wenjian\\3.xlsx"); // File file = new File("F:\\wenjian\\3.xlsx");
// file.createNewFile(); // file.createNewFile();

Loading…
Cancel
Save