Browse Source

#两票统计

zhongwei
yang_shj 11 months ago
parent
commit
c3057ba1c3
  1. 8
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/CensController.java
  2. 4
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/CensService.java
  3. 55
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/CensServiceImpl.java

8
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/CensController.java

@ -36,8 +36,8 @@ public class CensController {
@GetMapping ("/censExport") @GetMapping ("/censExport")
@ApiOperation("两票统计导出") @ApiOperation("两票统计导出")
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 2)
public R censExport(HttpServletResponse response,CensParamVo param) { public void censExport(HttpServletResponse response,CensParamVo param) {
return censService.censExport(response,param); censService.censExport(response,param);
} }
@PostMapping("/censYear") @PostMapping("/censYear")
@ -50,7 +50,7 @@ public class CensController {
@GetMapping ("/censYearExport") @GetMapping ("/censYearExport")
@ApiOperation("两票年度统计导出") @ApiOperation("两票年度统计导出")
@ApiOperationSupport(order = 4) @ApiOperationSupport(order = 4)
public R censYearExport(HttpServletResponse response,CensYearParamVo param) { public void censYearExport(HttpServletResponse response,CensYearParamVo param) {
return censService.censYearExport(response,param); censService.censYearExport(response,param);
} }
} }

4
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/CensService.java

@ -18,7 +18,7 @@ public interface CensService {
List<CensYearVo> censYear(CensYearParamVo param); List<CensYearVo> censYear(CensYearParamVo param);
R censExport(HttpServletResponse response, CensParamVo param); void censExport(HttpServletResponse response, CensParamVo param);
R censYearExport(HttpServletResponse response, CensYearParamVo param); void censYearExport(HttpServletResponse response, CensYearParamVo param);
} }

55
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/CensServiceImpl.java

@ -222,7 +222,7 @@ public class CensServiceImpl implements CensService {
* @param param * @param param
*/ */
@Override @Override
public R censExport(HttpServletResponse response, CensParamVo param) { public void censExport(HttpServletResponse response, CensParamVo param) {
// 创建Excel文件 // 创建Excel文件
HSSFWorkbook hssWB = new HSSFWorkbook(); HSSFWorkbook hssWB = new HSSFWorkbook();
// 添加sheet页 // 添加sheet页
@ -259,7 +259,6 @@ public class CensServiceImpl implements CensService {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
return R.data("success");
} }
/** /**
@ -367,7 +366,6 @@ public class CensServiceImpl implements CensService {
headStyle.setFillForegroundColor(HSSFColor.HSSFColorPredefined.WHITE.getIndex()); headStyle.setFillForegroundColor(HSSFColor.HSSFColorPredefined.WHITE.getIndex());
} }
//字体格式 //字体格式
headStyle.setFont(font); headStyle.setFont(font);
return headStyle; return headStyle;
} }
@ -387,7 +385,7 @@ public class CensServiceImpl implements CensService {
CensVo cens = censs.get(i); CensVo cens = censs.get(i);
// 序号 // 序号
HSSFCell header_row_cell_0 = row.getCell(0); HSSFCell header_row_cell_0 = row.getCell(0);
header_row_cell_0.setCellValue(i); header_row_cell_0.setCellValue(i + 1);
// 单位 // 单位
HSSFCell header_row_cell_1 = row.getCell(1); HSSFCell header_row_cell_1 = row.getCell(1);
header_row_cell_1.setCellValue(cens.getDeptName()); header_row_cell_1.setCellValue(cens.getDeptName());
@ -409,14 +407,14 @@ public class CensServiceImpl implements CensService {
* @param param * @param param
*/ */
@Override @Override
public R censYearExport(HttpServletResponse response, CensYearParamVo param) { public void censYearExport(HttpServletResponse response, CensYearParamVo param) {
if(StringUtil.isEmpty(param.getYear())){ if(StringUtil.isEmpty(param.getYear())){
param.setYear(DateUtil.format(new Date(),"yyyy")); param.setYear(DateUtil.format(new Date(),"yyyy"));
} }
// 创建Excel文件 // 创建Excel文件
HSSFWorkbook hssWB = new HSSFWorkbook(); HSSFWorkbook hssWB = new HSSFWorkbook();
// 添加sheet页 // 添加sheet页
HSSFSheet sheet = hssWB.createSheet("两票" + param.getYear() + "年度统计报表"); HSSFSheet sheet = hssWB.createSheet(param.getYear() +"两票年度统计报表");
// 行高 // 行高
sheet.setDefaultRowHeight((short) (20 * 25)); sheet.setDefaultRowHeight((short) (20 * 25));
// 列宽 // 列宽
@ -431,7 +429,7 @@ public class CensServiceImpl implements CensService {
} }
// 下载导出 // 下载导出
String filename = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME) + "年度两票统计报表"; String filename = param.getYear() + "年度两票统计报表";
// 设置头信息 // 设置头信息
response.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8");
response.setContentType("application/vnd.ms-excel"); response.setContentType("application/vnd.ms-excel");
@ -449,7 +447,6 @@ public class CensServiceImpl implements CensService {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
return R.data("success");
} }
/** /**
@ -466,31 +463,31 @@ public class CensServiceImpl implements CensService {
header_row_1_cell_1.setCellValue("序号"); header_row_1_cell_1.setCellValue("序号");
HSSFCell header_row_1_cell_2 = row_1.getCell(1); HSSFCell header_row_1_cell_2 = row_1.getCell(1);
header_row_1_cell_2.setCellValue("单位"); header_row_1_cell_2.setCellValue("单位");
HSSFCell header_row_1_cell_3 = row_1.getCell(3); HSSFCell header_row_1_cell_3 = row_1.getCell(2);
header_row_1_cell_3.setCellValue("1月"); header_row_1_cell_3.setCellValue("1月");
HSSFCell header_row_1_cell_4 = row_1.getCell(5); HSSFCell header_row_1_cell_4 = row_1.getCell(4);
header_row_1_cell_4.setCellValue("2月"); header_row_1_cell_4.setCellValue("2月");
HSSFCell header_row_1_cell_5 = row_1.getCell(7); HSSFCell header_row_1_cell_5 = row_1.getCell(6);
header_row_1_cell_5.setCellValue("3月"); header_row_1_cell_5.setCellValue("3月");
HSSFCell header_row_1_cell_6 = row_1.getCell(9); HSSFCell header_row_1_cell_6 = row_1.getCell(8);
header_row_1_cell_6.setCellValue("4月"); header_row_1_cell_6.setCellValue("4月");
HSSFCell header_row_1_cell_7 = row_1.getCell(11); HSSFCell header_row_1_cell_7 = row_1.getCell(10);
header_row_1_cell_7.setCellValue("5月"); header_row_1_cell_7.setCellValue("5月");
HSSFCell header_row_1_cell_8 = row_1.getCell(13); HSSFCell header_row_1_cell_8 = row_1.getCell(12);
header_row_1_cell_8.setCellValue("6月"); header_row_1_cell_8.setCellValue("6月");
HSSFCell header_row_1_cell_9 = row_1.getCell(15); HSSFCell header_row_1_cell_9 = row_1.getCell(14);
header_row_1_cell_9.setCellValue("7月"); header_row_1_cell_9.setCellValue("7月");
HSSFCell header_row_1_cell_10 = row_1.getCell(17); HSSFCell header_row_1_cell_10 = row_1.getCell(16);
header_row_1_cell_10.setCellValue("8月"); header_row_1_cell_10.setCellValue("8月");
HSSFCell header_row_1_cell_11 = row_1.getCell(19); HSSFCell header_row_1_cell_11 = row_1.getCell(18);
header_row_1_cell_11.setCellValue("9月"); header_row_1_cell_11.setCellValue("9月");
HSSFCell header_row_1_cell_12 = row_1.getCell(21); HSSFCell header_row_1_cell_12 = row_1.getCell(20);
header_row_1_cell_12.setCellValue("10月"); header_row_1_cell_12.setCellValue("10月");
HSSFCell header_row_1_cell_13 = row_1.getCell(23); HSSFCell header_row_1_cell_13 = row_1.getCell(22);
header_row_1_cell_13.setCellValue("11月"); header_row_1_cell_13.setCellValue("11月");
HSSFCell header_row_1_cell_14 = row_1.getCell(25); HSSFCell header_row_1_cell_14 = row_1.getCell(24);
header_row_1_cell_14.setCellValue("12月"); header_row_1_cell_14.setCellValue("12月");
HSSFCell header_row_1_cell_15 = row_1.getCell(27); HSSFCell header_row_1_cell_15 = row_1.getCell(26);
header_row_1_cell_15.setCellValue("总计"); header_row_1_cell_15.setCellValue("总计");
// 第二行 // 第二行
@ -596,7 +593,7 @@ public class CensServiceImpl implements CensService {
CensYearVo censYear = censYears.get(i); CensYearVo censYear = censYears.get(i);
// 序号 // 序号
HSSFCell header_row_cell_0 = row.getCell(0); HSSFCell header_row_cell_0 = row.getCell(0);
header_row_cell_0.setCellValue(i); header_row_cell_0.setCellValue(i + 1);
// 单位 // 单位
HSSFCell header_row_cell_1 = row.getCell(1); HSSFCell header_row_cell_1 = row.getCell(1);
header_row_cell_1.setCellValue(censYear.getDeptName()); header_row_cell_1.setCellValue(censYear.getDeptName());
@ -604,15 +601,23 @@ public class CensServiceImpl implements CensService {
if(CollectionUtil.isEmpty(censs)){ if(CollectionUtil.isEmpty(censs)){
return; return;
} }
int workSum = 0,operateSum = 0;
for(int mon = 0; mon < 12; mon ++){ for(int mon = 0; mon < 12; mon ++){
CensVo cens = censs.get(mon); CensVo cens = censs.get(mon);
// 工作票数量 // 工作票数量
HSSFCell work_cell = row.getCell(3 + mon); HSSFCell work_cell = row.getCell(2 * (mon + 1));
work_cell.setCellValue(cens.getWorkCount()); work_cell.setCellValue(cens.getWorkCount());
workSum += cens.getWorkCount();
// 操作票数量 // 操作票数量
HSSFCell operate_cell = row.getCell(3 + mon + 1); HSSFCell operate_cell = row.getCell(2 * (mon + 1) + 1);
work_cell.setCellValue(cens.getOperateCount()); operate_cell.setCellValue(cens.getOperateCount());
operateSum += cens.getOperateCount();
} }
// 总计
HSSFCell work_sum_cell = row.getCell(26);
work_sum_cell.setCellValue(workSum);
HSSFCell operate_sum_cell = row.getCell(27);
operate_sum_cell.setCellValue(operateSum);
} }
} }

Loading…
Cancel
Save