|
|
@@ -7,9 +7,13 @@ import com.hotent.base.model.CommonResult;
|
|
|
import com.hotent.base.query.PageList;
|
|
|
import com.hotent.base.util.AuthenticationUtil;
|
|
|
import com.hotent.pricing.manager.FapReportScenicManager;
|
|
|
+import com.hotent.pricing.manager.FapScenicFinanceManager;
|
|
|
import com.hotent.pricing.model.entity.report.FapReportScenic;
|
|
|
+import com.hotent.pricing.model.entity.report.FapScenicFinance;
|
|
|
import com.hotent.pricing.util.ExcelUtil;
|
|
|
import com.hotent.pricing.util.OrgHierarchyUtil;
|
|
|
+import com.hotent.sys.persistence.manager.DataDictManager;
|
|
|
+import com.hotent.sys.persistence.model.DataDict;
|
|
|
import com.hotent.uc.manager.OrgManager;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
@@ -19,10 +23,17 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
import java.util.*;
|
|
|
|
|
|
+import org.apache.poi.ss.usermodel.*;
|
|
|
+import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFFont;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
+
|
|
|
/**
|
|
|
* 报表-景区基本信息主表 前端控制器
|
|
|
*
|
|
|
@@ -40,6 +51,12 @@ public class FapReportScenicController{
|
|
|
OrgManager orgService;
|
|
|
@Autowired
|
|
|
private OrgHierarchyUtil orgHierarchyUtil;
|
|
|
+ @Autowired
|
|
|
+ private FapScenicFinanceManager financeManager;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private DataDictManager dataDictManager;
|
|
|
+
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -103,7 +120,7 @@ public class FapReportScenicController{
|
|
|
new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<FapReportScenic>()
|
|
|
.eq(FapReportScenic::getRefId, record.getId())
|
|
|
.eq(FapReportScenic::getIsHistory, "1")
|
|
|
- .orderByDesc(FapReportScenic::getUpdateTime)
|
|
|
+ .orderByDesc(FapReportScenic::getCreateTime)
|
|
|
);
|
|
|
record.setHistoryList(historyList);
|
|
|
}
|
|
|
@@ -209,17 +226,6 @@ public class FapReportScenicController{
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
- /**
|
|
|
- * 批量删除
|
|
|
- */
|
|
|
- @DeleteMapping("/delete")
|
|
|
- @ApiOperation("根据ID集合批量删除")
|
|
|
- public CommonResult<Void> deleteBatch(@ApiParam(value = "ID集合", required = true) @RequestParam String... ids) {
|
|
|
- fapReportScenicManager.removeByIds(java.util.Arrays.asList(ids));
|
|
|
- return CommonResult.<Void>ok();
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 启用/停用景区
|
|
|
*/
|
|
|
@@ -240,163 +246,1435 @@ public class FapReportScenicController{
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 下载Excel模板(基于选中记录)
|
|
|
+ * 下载景区价格信息统计表模板(包含景区基本信息+收支情况+游客数据)
|
|
|
*/
|
|
|
@PostMapping("/template")
|
|
|
@ApiOperation("下载景区基本信息Excel模板")
|
|
|
public void downloadTemplate(@ApiParam(value = "选中的记录ID", required = true) @RequestBody FapReportScenic fapReportScenic,
|
|
|
- HttpServletResponse response) throws IOException {
|
|
|
- // 定义表头(只包含用户需要填写的价格字段)
|
|
|
- String[] headers = {
|
|
|
- "门票价格-淡季", "门票价格-旺季", "景交车", "观光车价格", "缆车价格", "索道价格", "电梯价格", "游船价格", "停车场", "其它"
|
|
|
- };
|
|
|
-
|
|
|
- // 定义字段名(只包含价格字段)
|
|
|
- String[] fieldNames = {
|
|
|
- "ticketLow", "ticketHigh", "price1", "price2", "price3", "price4", "price5", "price6", "price7", "price8"
|
|
|
- };
|
|
|
-
|
|
|
- // 验证选中记录是否存在
|
|
|
- if (fapReportScenic.getId()==null) {
|
|
|
- throw new IllegalArgumentException("请先选择要操作的记录");
|
|
|
- }
|
|
|
-
|
|
|
- FapReportScenic selectedRecord = fapReportScenicManager.getById(fapReportScenic.getId());
|
|
|
- if (selectedRecord == null) {
|
|
|
- throw new IllegalArgumentException("选中的记录不存在");
|
|
|
- }
|
|
|
-
|
|
|
- // 使用选中记录的数据作为模板(只包含价格字段)
|
|
|
- List<Map<String, Object>> sampleData = new ArrayList<>();
|
|
|
- Map<String, Object> data = new HashMap<>();
|
|
|
- data.put("ticketLow", selectedRecord.getTicketLow());
|
|
|
- data.put("ticketHigh", selectedRecord.getTicketHigh());
|
|
|
- data.put("price1", selectedRecord.getPrice1());
|
|
|
- data.put("price2", selectedRecord.getPrice2());
|
|
|
- data.put("price3", selectedRecord.getPrice3());
|
|
|
- data.put("price4", selectedRecord.getPrice4());
|
|
|
- data.put("price5", selectedRecord.getPrice5());
|
|
|
- data.put("price6", selectedRecord.getPrice6());
|
|
|
- data.put("price7", selectedRecord.getPrice7());
|
|
|
- data.put("price8", selectedRecord.getPrice8());
|
|
|
- sampleData.add(data);
|
|
|
-
|
|
|
- ExcelUtil.downloadTemplate(response, "景区基本信息", headers, fieldNames, sampleData);
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+
|
|
|
+ // 获取景区基本信息
|
|
|
+ FapReportScenic scenic = fapReportScenicManager.getById(fapReportScenic.getId());
|
|
|
+ if (scenic == null) {
|
|
|
+ throw new IllegalArgumentException("景区不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 创建工作簿
|
|
|
+ XSSFWorkbook workbook = new XSSFWorkbook();
|
|
|
+ XSSFSheet sheet = workbook.createSheet("景区价格信息统计表");
|
|
|
+
|
|
|
+ // 创建样式
|
|
|
+ CellStyle titleStyle = createTitleStyle(workbook);
|
|
|
+ CellStyle headerStyle = createHeaderStyle(workbook);
|
|
|
+ CellStyle dataStyle = createDataStyle(workbook);
|
|
|
+ CellStyle centerStyle = createCenterStyle(workbook);
|
|
|
+
|
|
|
+ int rowNum = 0;
|
|
|
+
|
|
|
+ // 第1行:标题
|
|
|
+ Row titleRow = sheet.createRow(rowNum++);
|
|
|
+ titleRow.setHeightInPoints(35); // 设置行高
|
|
|
+ Cell titleCell = titleRow.createCell(0);
|
|
|
+ String title = scenic.getScenicName() + "景区门票价格信息统计表";
|
|
|
+ titleCell.setCellValue(title);
|
|
|
+ titleCell.setCellStyle(titleStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, 0, 0, 0, 19);
|
|
|
+
|
|
|
+ // 第2行:单位和填表时间
|
|
|
+ Row unitRow = sheet.createRow(rowNum++);
|
|
|
+ unitRow.setHeightInPoints(25); // 设置行高
|
|
|
+
|
|
|
+ // 单位标签(第0-1列合并)
|
|
|
+ Cell unitLabelCell = unitRow.createCell(0);
|
|
|
+ unitLabelCell.setCellValue("单位:");
|
|
|
+ unitLabelCell.setCellStyle(headerStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 0, 1);
|
|
|
+
|
|
|
+ // 单位值(第2-11列合并,空白供用户填写)
|
|
|
+ Cell unitValueCell = unitRow.createCell(2);
|
|
|
+ unitValueCell.setCellValue("");
|
|
|
+ unitValueCell.setCellStyle(dataStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 2, 11);
|
|
|
+
|
|
|
+ // 填表时间标签(第12-13列合并)
|
|
|
+ Cell dateLabelCell = unitRow.createCell(12);
|
|
|
+ dateLabelCell.setCellValue("填表时间:");
|
|
|
+ dateLabelCell.setCellStyle(headerStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 12, 13);
|
|
|
+
|
|
|
+ // 填表时间值(第14-19列合并,空白供用户填写)
|
|
|
+ Cell dateValueCell = unitRow.createCell(14);
|
|
|
+ dateValueCell.setCellValue("");
|
|
|
+ dateValueCell.setCellStyle(dataStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 14, 19);
|
|
|
+
|
|
|
+ // 第3行:景区基本信息表头
|
|
|
+ Row basicInfoHeaderRow = sheet.createRow(rowNum++);
|
|
|
+ basicInfoHeaderRow.setHeightInPoints(30); // 设置行高
|
|
|
+
|
|
|
+ // 第0列:"基本情况"标签(稍后合并第3-7行)
|
|
|
+ Cell basicSituationLabel = basicInfoHeaderRow.createCell(0);
|
|
|
+ basicSituationLabel.setCellValue("基本情况");
|
|
|
+ basicSituationLabel.setCellStyle(headerStyle);
|
|
|
+
|
|
|
+ basicInfoHeaderRow.createCell(1).setCellValue("景区名称");
|
|
|
+ basicInfoHeaderRow.createCell(2).setCellValue("景区类型");
|
|
|
+ basicInfoHeaderRow.createCell(3).setCellValue("景区等级");
|
|
|
+ basicInfoHeaderRow.createCell(4).setCellValue("价格管理形式");
|
|
|
+ basicInfoHeaderRow.createCell(5).setCellValue("景区面积");
|
|
|
+ basicInfoHeaderRow.createCell(6).setCellValue("主管部门");
|
|
|
+ basicInfoHeaderRow.createCell(7).setCellValue("运营性质");
|
|
|
+ basicInfoHeaderRow.createCell(8).setCellValue("管理属性");
|
|
|
+
|
|
|
+ // 门票收支管理方式(第9-19列合并)
|
|
|
+ Cell revenueManageHeader = basicInfoHeaderRow.createCell(9);
|
|
|
+ revenueManageHeader.setCellValue("门票收支管理方式及财政资金关系");
|
|
|
+ revenueManageHeader.setCellStyle(headerStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 9, 19);
|
|
|
+
|
|
|
+ // 第4行:景区基本信息数据
|
|
|
+ Row basicInfoDataRow = sheet.createRow(rowNum++);
|
|
|
+ basicInfoDataRow.setHeightInPoints(25); // 设置行高
|
|
|
+
|
|
|
+ basicInfoDataRow.createCell(1).setCellValue(scenic.getScenicName() != null ? scenic.getScenicName() : "");
|
|
|
+ basicInfoDataRow.createCell(2).setCellValue(scenic.getScenicType() != null ? scenic.getScenicType() : "");
|
|
|
+ basicInfoDataRow.createCell(3).setCellValue(scenic.getScenicLevel() != null ? scenic.getScenicLevel() : "");
|
|
|
+ basicInfoDataRow.createCell(4).setCellValue(scenic.getPriceManageForm() != null ? scenic.getPriceManageForm() : "");
|
|
|
+ basicInfoDataRow.createCell(5).setCellValue((scenic.getScenicArea() != null ? scenic.getScenicArea() : "") +
|
|
|
+ (scenic.getAreaUnit() != null ? scenic.getAreaUnit() : ""));
|
|
|
+ basicInfoDataRow.createCell(6).setCellValue(scenic.getCompetentOrg() != null ? scenic.getCompetentOrg() : "");
|
|
|
+ // 运营性质
|
|
|
+ DataDict operationNatureDict = dataDictManager.getByDictKey("1965686172473999360", scenic.getOperationNature());
|
|
|
+ basicInfoDataRow.createCell(7).setCellValue(operationNatureDict.getName());
|
|
|
+ DataDict managementAttrDict = dataDictManager.getByDictKey("1965686172473999360", scenic.getManagementAttr());
|
|
|
+ basicInfoDataRow.createCell(8).setCellValue(managementAttrDict.getName());
|
|
|
+
|
|
|
+ // 门票收支管理方式(第9-19列合并)
|
|
|
+ Cell revenueManageData = basicInfoDataRow.createCell(9);
|
|
|
+ DataDict revenueManageDict = dataDictManager.getByDictKey("1965686172473999360", scenic.getRevenueManage());
|
|
|
+ revenueManageData.setCellValue(revenueManageDict.getName());
|
|
|
+ revenueManageData.setCellStyle(dataStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 9, 19);
|
|
|
+
|
|
|
+ // 设置前8列样式
|
|
|
+ for (int i = 1; i <= 8; i++) {
|
|
|
+ basicInfoDataRow.getCell(i).setCellStyle(dataStyle);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 第5行:门票价格第一行表头
|
|
|
+ Row priceHeaderRow1 = sheet.createRow(rowNum++);
|
|
|
+ priceHeaderRow1.setHeightInPoints(30); // 设置行高
|
|
|
+
|
|
|
+ // 调整前门票价格(合并第5行的1-3列)
|
|
|
+ Cell beforePriceHeader = priceHeaderRow1.createCell(1);
|
|
|
+ beforePriceHeader.setCellValue("调整前门票价格(元/人)");
|
|
|
+ beforePriceHeader.setCellStyle(headerStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 1, 3);
|
|
|
+
|
|
|
+ // 调整后门票价格(合并第5行的4-6列)
|
|
|
+ Cell afterPriceHeader = priceHeaderRow1.createCell(4);
|
|
|
+ afterPriceHeader.setCellValue("调整后门票价格(元/人)");
|
|
|
+ afterPriceHeader.setCellStyle(headerStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 4, 6);
|
|
|
+
|
|
|
+ // 调整幅度(合并第5行的7-8列)
|
|
|
+ Cell adjustHeader = priceHeaderRow1.createCell(7);
|
|
|
+ adjustHeader.setCellValue("调整幅度(元/人)");
|
|
|
+ adjustHeader.setCellStyle(headerStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 7, 8);
|
|
|
+
|
|
|
+ // 景区内交通运输服务价格(合并第5行的9-16列)
|
|
|
+ Cell transportHeader = priceHeaderRow1.createCell(9);
|
|
|
+ transportHeader.setCellValue("景区内交通运输服务价格(元/人)");
|
|
|
+ transportHeader.setCellStyle(headerStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 9, 16);
|
|
|
+
|
|
|
+ // 成本监审、成本调查、价格评估结果(合并第5行的17-18列)
|
|
|
+ Cell costAuditHeader5 = priceHeaderRow1.createCell(17);
|
|
|
+ costAuditHeader5.setCellValue("成本监审、成本调查、价格评估结果");
|
|
|
+ costAuditHeader5.setCellStyle(headerStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum, 17, 18);
|
|
|
+
|
|
|
+ // 定价文件(合并第5行的19列,跨2行)
|
|
|
+ Cell pricingDocHeader5 = priceHeaderRow1.createCell(19);
|
|
|
+ pricingDocHeader5.setCellValue("定价文件");
|
|
|
+ pricingDocHeader5.setCellStyle(headerStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum, 19, 19);
|
|
|
+
|
|
|
+ // 第6行:基本情况第二行表头
|
|
|
+ Row priceHeaderRow2 = sheet.createRow(rowNum++);
|
|
|
+ priceHeaderRow2.setHeightInPoints(25); // 设置行高
|
|
|
+
|
|
|
+ priceHeaderRow2.createCell(1).setCellValue("旺季");
|
|
|
+ priceHeaderRow2.createCell(2).setCellValue("淡季");
|
|
|
+ priceHeaderRow2.createCell(3).setCellValue("执行时间");
|
|
|
+ priceHeaderRow2.createCell(4).setCellValue("旺季");
|
|
|
+ priceHeaderRow2.createCell(5).setCellValue("淡季");
|
|
|
+ priceHeaderRow2.createCell(6).setCellValue("执行时间");
|
|
|
+ priceHeaderRow2.createCell(7).setCellValue("旺季");
|
|
|
+ priceHeaderRow2.createCell(8).setCellValue("淡季");
|
|
|
+
|
|
|
+ // 交通工具子表头
|
|
|
+ String[] transportHeaders = {"景交车", "观光车", "缆车", "索道", "电梯", "游船", "停车场", "其他"};
|
|
|
+ for (int i = 0; i < transportHeaders.length; i++) {
|
|
|
+ priceHeaderRow2.createCell(9 + i).setCellValue(transportHeaders[i]);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置第6行表头样式
|
|
|
+ for (int i = 1; i <= 16; i++) {
|
|
|
+ if (priceHeaderRow2.getCell(i) != null) {
|
|
|
+ priceHeaderRow2.getCell(i).setCellStyle(headerStyle);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 第7行:门票价格、交通价格、成本监审、定价文件
|
|
|
+ Row priceDataRow = sheet.createRow(rowNum++);
|
|
|
+ priceDataRow.setHeightInPoints(25); // 设置行高
|
|
|
+
|
|
|
+ // 合并"基本情况"标签(第0列,第3-7行,跨5行)
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 5, rowNum - 1, 0, 0);
|
|
|
+
|
|
|
+ // 调整前门票价格
|
|
|
+ priceDataRow.createCell(1).setCellValue(scenic.getTicketHigh() != null ? scenic.getTicketHigh() : "");
|
|
|
+ priceDataRow.createCell(2).setCellValue(scenic.getTicketLow() != null ? scenic.getTicketLow() : "");
|
|
|
+ priceDataRow.createCell(3).setCellValue(scenic.getExecuteTime() != null ? scenic.getExecuteTime().toString() : "");
|
|
|
+
|
|
|
+ // 调整后门票价格
|
|
|
+ priceDataRow.createCell(4).setCellValue(scenic.getTicketHighAdjust() != null ? scenic.getTicketHighAdjust() : "");
|
|
|
+ priceDataRow.createCell(5).setCellValue(scenic.getTicketLowAdjust() != null ? scenic.getTicketLowAdjust() : "");
|
|
|
+ priceDataRow.createCell(6).setCellValue(scenic.getExecuteTimeAdjust() != null ? scenic.getExecuteTimeAdjust().toString() : "");
|
|
|
+
|
|
|
+ // 调整幅度(计算百分比)
|
|
|
+ String highAdjust = "";
|
|
|
+ String lowAdjust = "";
|
|
|
+ try {
|
|
|
+ if (scenic.getTicketHigh() != null && scenic.getTicketHighAdjust() != null) {
|
|
|
+ double before = Double.parseDouble(scenic.getTicketHigh());
|
|
|
+ double after = Double.parseDouble(scenic.getTicketHighAdjust());
|
|
|
+ if (before != 0) {
|
|
|
+ double percentage = ((after - before) / before) * 100;
|
|
|
+ highAdjust = String.format("%.2f%%", percentage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (scenic.getTicketLow() != null && scenic.getTicketLowAdjust() != null) {
|
|
|
+ double before = Double.parseDouble(scenic.getTicketLow());
|
|
|
+ double after = Double.parseDouble(scenic.getTicketLowAdjust());
|
|
|
+ if (before != 0) {
|
|
|
+ double percentage = ((after - before) / before) * 100;
|
|
|
+ lowAdjust = String.format("%.2f%%", percentage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ // 忽略格式错误
|
|
|
+ }
|
|
|
+ priceDataRow.createCell(7).setCellValue(highAdjust);
|
|
|
+ priceDataRow.createCell(8).setCellValue(lowAdjust);
|
|
|
+
|
|
|
+ // 交通价格(第9-16列)
|
|
|
+ priceDataRow.createCell(9).setCellValue(scenic.getPrice1() != null ? scenic.getPrice1() : "");
|
|
|
+ priceDataRow.createCell(10).setCellValue(scenic.getPrice2() != null ? scenic.getPrice2() : "");
|
|
|
+ priceDataRow.createCell(11).setCellValue(scenic.getPrice3() != null ? scenic.getPrice3() : "");
|
|
|
+ priceDataRow.createCell(12).setCellValue(scenic.getPrice4() != null ? scenic.getPrice4() : "");
|
|
|
+ priceDataRow.createCell(13).setCellValue(scenic.getPrice5() != null ? scenic.getPrice5() : "");
|
|
|
+ priceDataRow.createCell(14).setCellValue(scenic.getPrice6() != null ? scenic.getPrice6() : "");
|
|
|
+ priceDataRow.createCell(15).setCellValue(scenic.getPrice7() != null ? scenic.getPrice7() : "");
|
|
|
+ priceDataRow.createCell(16).setCellValue(scenic.getPrice8() != null ? scenic.getPrice8() : "");
|
|
|
+
|
|
|
+ // 成本监审、成本调查、价格评估结果(第17-18列合并)
|
|
|
+ Cell costResultCell = priceDataRow.createCell(17);
|
|
|
+ costResultCell.setCellValue(scenic.getCostAuditResult() != null ? scenic.getCostAuditResult() : "");
|
|
|
+ costResultCell.setCellStyle(dataStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 17, 18);
|
|
|
+
|
|
|
+ // 定价文件(第19列)
|
|
|
+ Cell pricingDocCell = priceDataRow.createCell(19);
|
|
|
+ pricingDocCell.setCellValue(scenic.getPricingDocNo() != null ? scenic.getPricingDocNo() : "");
|
|
|
+ pricingDocCell.setCellStyle(dataStyle);
|
|
|
+
|
|
|
+ // 设置数据行样式
|
|
|
+ for (int i = 1; i <= 16; i++) {
|
|
|
+ if (priceDataRow.getCell(i) != null) {
|
|
|
+ priceDataRow.getCell(i).setCellStyle(dataStyle);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 第8-9行:收支情况表头
|
|
|
+ Row financeHeaderRow1 = sheet.createRow(rowNum++);
|
|
|
+ financeHeaderRow1.setHeightInPoints(30); // 设置行高
|
|
|
+ Row financeHeaderRow2 = sheet.createRow(rowNum++);
|
|
|
+ financeHeaderRow2.setHeightInPoints(25); // 设置行高
|
|
|
+
|
|
|
+ // 第一列:收支情况标签(跨3行)
|
|
|
+ Cell financeLabelCell = financeHeaderRow1.createCell(0);
|
|
|
+ financeLabelCell.setCellValue("收支情况");
|
|
|
+ financeLabelCell.setCellStyle(headerStyle);
|
|
|
+
|
|
|
+ Cell fh1 = financeHeaderRow1.createCell(1);
|
|
|
+ fh1.setCellValue("员工人数");
|
|
|
+ fh1.setCellStyle(headerStyle);
|
|
|
+
|
|
|
+ Cell fh2 = financeHeaderRow1.createCell(2);
|
|
|
+ fh2.setCellValue("总收入(万元)");
|
|
|
+ fh2.setCellStyle(headerStyle);
|
|
|
+
|
|
|
+ Cell fh3 = financeHeaderRow1.createCell(7);
|
|
|
+ fh3.setCellValue("总支出(万元)");
|
|
|
+ fh3.setCellStyle(headerStyle);
|
|
|
+
|
|
|
+ Cell fh4 = financeHeaderRow1.createCell(13);
|
|
|
+ fh4.setCellValue("利润(万元)");
|
|
|
+ fh4.setCellStyle(headerStyle);
|
|
|
+
|
|
|
+ Cell fh5 = financeHeaderRow1.createCell(14);
|
|
|
+ fh5.setCellValue("税金(万元)");
|
|
|
+ fh5.setCellStyle(headerStyle);
|
|
|
+
|
|
|
+ Cell fh6 = financeHeaderRow1.createCell(15);
|
|
|
+ fh6.setCellValue("税率(%)");
|
|
|
+ fh6.setCellStyle(headerStyle);
|
|
|
+
|
|
|
+ Cell fh7 = financeHeaderRow1.createCell(16);
|
|
|
+ fh7.setCellValue("备注");
|
|
|
+ fh7.setCellStyle(headerStyle);
|
|
|
+
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 2, rowNum - 1, 1, 1); // 员工人数
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 2, rowNum - 2, 2, 6); // 总收入
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 2, rowNum - 2, 7, 12); // 总支出
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 2, rowNum - 1, 13, 13); // 利润
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 2, rowNum - 1, 14, 14); // 税金
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 2, rowNum - 1, 15, 15); // 税率
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 2, rowNum - 1, 16, 19); // 备注(合并到第19列)
|
|
|
+
|
|
|
+ String[] revenueHeaders = {"合计", "门票", "经营服务", "财政拨款", "其他"};
|
|
|
+ for (int i = 0; i < revenueHeaders.length; i++) {
|
|
|
+ Cell rhCell = financeHeaderRow2.createCell(i + 2);
|
|
|
+ rhCell.setCellValue(revenueHeaders[i]);
|
|
|
+ rhCell.setCellStyle(headerStyle);
|
|
|
+ }
|
|
|
+
|
|
|
+ String[] expenseHeaders = {"合计", "上缴财政", "人员", "办公", "建设维护", "其他"};
|
|
|
+ for (int i = 0; i < expenseHeaders.length; i++) {
|
|
|
+ Cell ehCell = financeHeaderRow2.createCell(i + 7);
|
|
|
+ ehCell.setCellValue(expenseHeaders[i]);
|
|
|
+ ehCell.setCellStyle(headerStyle);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 第10行:收支情况数据
|
|
|
+ Row financeDataRow1 = sheet.createRow(rowNum++);
|
|
|
+ financeDataRow1.setHeightInPoints(25); // 设置行高
|
|
|
+
|
|
|
+ // 合并收支情况标签列(跨3行)- 第8-10行
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 3, rowNum - 1, 0, 0);
|
|
|
+
|
|
|
+ // 第10行收支数据:空白供用户填写
|
|
|
+ for (int i = 1; i <= 15; i++) {
|
|
|
+ Cell fdCell = financeDataRow1.createCell(i);
|
|
|
+ fdCell.setCellValue("");
|
|
|
+ fdCell.setCellStyle(dataStyle);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 备注(第16-19列合并)
|
|
|
+ Cell fd16 = financeDataRow1.createCell(16);
|
|
|
+ fd16.setCellValue("");
|
|
|
+ fd16.setCellStyle(dataStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 16, 19);
|
|
|
+
|
|
|
+ // ========== 第11-12行:年月度游客人数表格 ==========
|
|
|
+ Row monthlyVisitorHeaderRow = sheet.createRow(rowNum++);
|
|
|
+ monthlyVisitorHeaderRow.setHeightInPoints(25);
|
|
|
+ Row monthlyVisitorDataRow = sheet.createRow(rowNum++);
|
|
|
+ monthlyVisitorDataRow.setHeightInPoints(25);
|
|
|
+
|
|
|
+ // 第一列:标签(跨2行)
|
|
|
+ Cell monthlyLabel = monthlyVisitorHeaderRow.createCell(0);
|
|
|
+ monthlyLabel.setCellValue("年月度游客人数(人)");
|
|
|
+ monthlyLabel.setCellStyle(headerStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 2, rowNum - 1, 0, 0);
|
|
|
+
|
|
|
+ // 第13行:月度表头(1-12月)
|
|
|
+ String[] monthlyHeaders = {"1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"};
|
|
|
+ for (int i = 0; i < monthlyHeaders.length; i++) {
|
|
|
+ Cell mhCell = monthlyVisitorHeaderRow.createCell(i + 1);
|
|
|
+ mhCell.setCellValue(monthlyHeaders[i]);
|
|
|
+ mhCell.setCellStyle(headerStyle);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 本年度人数合计
|
|
|
+ Cell totalHeader = monthlyVisitorHeaderRow.createCell(13);
|
|
|
+ totalHeader.setCellValue("本年度人数合计");
|
|
|
+ totalHeader.setCellStyle(headerStyle);
|
|
|
+
|
|
|
+ // 优惠人数
|
|
|
+ Cell discountHeader = monthlyVisitorHeaderRow.createCell(14);
|
|
|
+ discountHeader.setCellValue("优惠人数");
|
|
|
+ discountHeader.setCellStyle(headerStyle);
|
|
|
+
|
|
|
+ // 其中免票人数
|
|
|
+ Cell freeHeader = monthlyVisitorHeaderRow.createCell(15);
|
|
|
+ freeHeader.setCellValue("其中免票人数");
|
|
|
+ freeHeader.setCellStyle(headerStyle);
|
|
|
+
|
|
|
+ // 免票人数占比(第16-19列合并)
|
|
|
+ Cell monthlyFreeRateHeader = monthlyVisitorHeaderRow.createCell(16);
|
|
|
+ monthlyFreeRateHeader.setCellValue("免票人数占比(%)");
|
|
|
+ monthlyFreeRateHeader.setCellStyle(headerStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 2, rowNum - 2, 16, 19);
|
|
|
+
|
|
|
+ // 第14行:月度游客数据(空白,用户填写)
|
|
|
+ for (int i = 1; i <= 19; i++) {
|
|
|
+ Cell mvdCell = monthlyVisitorDataRow.createCell(i);
|
|
|
+ mvdCell.setCellValue("");
|
|
|
+ mvdCell.setCellStyle(dataStyle);
|
|
|
+ }
|
|
|
+ // 合并免票占比列
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 16, 19);
|
|
|
+
|
|
|
+ // ========== 第13行:备注说明 ==========
|
|
|
+ Row remarkRow = sheet.createRow(rowNum++);
|
|
|
+ remarkRow.setHeightInPoints(60); // 增加行高以容纳三条备注
|
|
|
+
|
|
|
+ // 创建左对齐、自动换行样式
|
|
|
+ CellStyle remarkStyle = workbook.createCellStyle();
|
|
|
+ remarkStyle.setAlignment(HorizontalAlignment.LEFT);
|
|
|
+ remarkStyle.setVerticalAlignment(VerticalAlignment.TOP);
|
|
|
+ remarkStyle.setWrapText(true); // 启用自动换行
|
|
|
+ XSSFFont remarkFont = workbook.createFont();
|
|
|
+ remarkFont.setFontName("宋体");
|
|
|
+ remarkFont.setFontHeightInPoints((short) 10);
|
|
|
+ remarkStyle.setFont(remarkFont);
|
|
|
+
|
|
|
+ // 三条备注合并在一个单元格中
|
|
|
+ Cell remarkCell = remarkRow.createCell(0);
|
|
|
+ remarkCell.setCellValue("备注:1、表格中'现行门票价格'指定价文件中的价格开始执行时间,非临时优惠价格执行时间;\n" +
|
|
|
+ " 2、景区面积填写'平方公里'或'平方米'、'亩';\n" +
|
|
|
+ " 3、税率指企业所得税税率。");
|
|
|
+ remarkCell.setCellStyle(remarkStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 0, 19);
|
|
|
+
|
|
|
+ // ========== 第14行:填表信息 ==========
|
|
|
+ Row fillInfoRow = sheet.createRow(rowNum++);
|
|
|
+ fillInfoRow.setHeightInPoints(20);
|
|
|
+
|
|
|
+ // 创建填表信息样式
|
|
|
+ CellStyle fillInfoStyle = workbook.createCellStyle();
|
|
|
+ fillInfoStyle.setAlignment(HorizontalAlignment.LEFT);
|
|
|
+ fillInfoStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
+ XSSFFont fillInfoFont = workbook.createFont();
|
|
|
+ fillInfoFont.setFontName("宋体");
|
|
|
+ fillInfoFont.setFontHeightInPoints((short) 10);
|
|
|
+ fillInfoStyle.setFont(fillInfoFont);
|
|
|
+
|
|
|
+ // 景区门票价格工作负责人标签(第0列)
|
|
|
+ Cell responsiblePersonLabel = fillInfoRow.createCell(0);
|
|
|
+ responsiblePersonLabel.setCellValue("景区门票价格工作负责人:");
|
|
|
+ responsiblePersonLabel.setCellStyle(fillInfoStyle);
|
|
|
+
|
|
|
+ // 景区门票价格工作负责人值(第1-9列合并,空白供用户填写)
|
|
|
+ Cell responsiblePersonValue = fillInfoRow.createCell(1);
|
|
|
+ responsiblePersonValue.setCellValue("");
|
|
|
+ responsiblePersonValue.setCellStyle(dataStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 1, 9);
|
|
|
+
|
|
|
+ // 联系电话标签(第10列)
|
|
|
+ Cell contactPhoneLabel = fillInfoRow.createCell(10);
|
|
|
+ contactPhoneLabel.setCellValue("联系电话:");
|
|
|
+ contactPhoneLabel.setCellStyle(fillInfoStyle);
|
|
|
+
|
|
|
+ // 联系电话值(第11-19列合并,空白供用户填写)
|
|
|
+ Cell contactPhoneValue = fillInfoRow.createCell(11);
|
|
|
+ contactPhoneValue.setCellValue("");
|
|
|
+ contactPhoneValue.setCellStyle(dataStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 11, 19);
|
|
|
+
|
|
|
+ // 设置列宽
|
|
|
+ for (int i = 0; i < 20; i++) {
|
|
|
+ sheet.setColumnWidth(i, 4000);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置响应头
|
|
|
+ String fileName = scenic.getScenicName() + "_价格信息统计表.xlsx";
|
|
|
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
+ response.setHeader("Content-Disposition", "attachment; filename=" +
|
|
|
+ new String(fileName.getBytes("UTF-8"), "ISO-8859-1"));
|
|
|
+
|
|
|
+ // 输出到响应流
|
|
|
+ workbook.write(response.getOutputStream());
|
|
|
+ workbook.close();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 导入Excel数据(更新选中记录)
|
|
|
+ * 导入景区收支情况Excel(生成新的调整记录)
|
|
|
*/
|
|
|
@PostMapping("/import")
|
|
|
- @ApiOperation("导入景区基本信息Excel数据")
|
|
|
+ @ApiOperation("导入景区价格和收支情况Excel")
|
|
|
public CommonResult<String> importExcel(@ApiParam(value = "Excel文件", required = true) @RequestParam("file") MultipartFile file,
|
|
|
- @ApiParam(value = "选中的记录ID", required = true) @RequestParam("id") String selectedId) {
|
|
|
+ @ApiParam(value = "选中的记录ID", required = true) @RequestParam("id") String id) {
|
|
|
try {
|
|
|
- // 定义表头(只包含用户需要填写的价格字段)
|
|
|
- String[] headers = {
|
|
|
- "门票价格-淡季", "门票价格-旺季", "景交车", "观光车价格", "缆车价格", "索道价格", "电梯价格", "游船价格", "停车场", "其它"
|
|
|
- };
|
|
|
-
|
|
|
- // 定义字段名(只包含价格字段)
|
|
|
- String[] fieldNames = {
|
|
|
- "ticketLow", "ticketHigh", "price1", "price2", "price3", "price4", "price5", "price6", "price7", "price8"
|
|
|
- };
|
|
|
-
|
|
|
- // 验证选中记录是否存在
|
|
|
- if (selectedId == null || selectedId.trim().isEmpty()) {
|
|
|
- return CommonResult.<String>error().message("请先选择要更新的记录");
|
|
|
+ // 验证景区是否存在
|
|
|
+ FapReportScenic scenic = fapReportScenicManager.getById(id);
|
|
|
+ if (scenic == null) {
|
|
|
+ return CommonResult.<String>error().message("景区不存在");
|
|
|
}
|
|
|
|
|
|
- FapReportScenic selectedRecord = fapReportScenicManager.getById(selectedId);
|
|
|
- if (selectedRecord == null) {
|
|
|
- return CommonResult.<String>error().message("选中的记录不存在");
|
|
|
- }
|
|
|
+ // 使用POI解析Excel
|
|
|
+ // 模板结构(14行):
|
|
|
+ // 第1行: 标题
|
|
|
+ // 第2行: 单位和填表时间
|
|
|
+ // 第3-4行: 基本情况(不导入,保持原值)
|
|
|
+ // 第5-7行: 价格信息(不导入,保持原值)
|
|
|
+ // 第8-10行: 收支情况(第10行导入) ✅
|
|
|
+ // 第11-12行: 年月度游客人数(第12行导入) ✅
|
|
|
+ // 第13行: 备注说明
|
|
|
+ // 第14行: 填表信息
|
|
|
+ XSSFWorkbook workbook = new XSSFWorkbook(file.getInputStream());
|
|
|
+ XSSFSheet sheet = workbook.getSheetAt(0);
|
|
|
|
|
|
- // 解析Excel文件
|
|
|
- List<Map<String, Object>> dataList = ExcelUtil.parseExcel(file, headers, fieldNames);
|
|
|
+ // 第10行(索引9)是收支数据行
|
|
|
+ Row financeDataRow = sheet.getRow(9);
|
|
|
+ if (financeDataRow == null) {
|
|
|
+ return CommonResult.<String>error().message("Excel格式错误:找不到收支数据行(第10行)");
|
|
|
+ }
|
|
|
|
|
|
- if (dataList.isEmpty()) {
|
|
|
- return CommonResult.<String>error().message("Excel文件中没有有效数据");
|
|
|
+ // 第12行(索引11)是2024年月度游客数据行
|
|
|
+ Row monthlyVisitorDataRow = sheet.getRow(11);
|
|
|
+ if (monthlyVisitorDataRow == null) {
|
|
|
+ return CommonResult.<String>error().message("Excel格式错误:找不到2024年月度游客数据行(第12行)");
|
|
|
}
|
|
|
|
|
|
- Map<String, Object> data = dataList.get(0);
|
|
|
+ // ========== 1. 创建新的收支记录 ==========
|
|
|
+ FapScenicFinance finance = new FapScenicFinance();
|
|
|
+ finance.setScenicId(id);
|
|
|
+ finance.setYear(java.time.LocalDate.now().getYear());
|
|
|
|
|
|
- // 先保存历史记录
|
|
|
- if ("0".equals(selectedRecord.getIsHistory())) {
|
|
|
- FapReportScenic historyRecord = new FapReportScenic();
|
|
|
- BeanUtils.copyProperties(selectedRecord, historyRecord);
|
|
|
- historyRecord.setId(null);
|
|
|
- historyRecord.setIsHistory("1");
|
|
|
- historyRecord.setRefId(selectedRecord.getId());
|
|
|
- // 保存历史记录
|
|
|
- fapReportScenicManager.save(historyRecord);
|
|
|
+ // 解析填报信息
|
|
|
+ // 第2行(索引1)单位和填表时间
|
|
|
+ Row unitRow = sheet.getRow(1);
|
|
|
+ if (unitRow != null) {
|
|
|
+ // 单位名称(第2-11列合并,取第2列的值)
|
|
|
+ finance.setUnitName(getCellStringValue(unitRow.getCell(2)));
|
|
|
+ // 填表时间(第14-19列合并,取第14列的值)
|
|
|
+ finance.setFillDate(getCellLocalDateValue(unitRow.getCell(14)));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 第14行(索引13)是填表信息行
|
|
|
+ Row fillInfoRow = sheet.getRow(13);
|
|
|
+ if (fillInfoRow != null) {
|
|
|
+ // 景区门票价格工作负责人(第1-9列合并,取第1列的值)
|
|
|
+ finance.setResponsiblePerson(getCellStringValue(fillInfoRow.getCell(1)));
|
|
|
+ // 联系电话(第11-19列合并,取第11列的值)
|
|
|
+ finance.setContactPhone(getCellStringValue(fillInfoRow.getCell(11)));
|
|
|
}
|
|
|
|
|
|
- // 更新当前记录(只更新价格字段)
|
|
|
- updatePriceFieldsFromData(selectedRecord, data);
|
|
|
- fapReportScenicManager.updateById(selectedRecord);
|
|
|
+ // 解析收支数据(第10行)
|
|
|
+ finance.setEmployeeCount(getCellIntValue(financeDataRow.getCell(1)));
|
|
|
+ finance.setRevenueTotal(getCellBigDecimalValue(financeDataRow.getCell(2)));
|
|
|
+ finance.setRevenueTicket(getCellBigDecimalValue(financeDataRow.getCell(3)));
|
|
|
+ finance.setRevenueService(getCellBigDecimalValue(financeDataRow.getCell(4)));
|
|
|
+ finance.setRevenueFiscal(getCellBigDecimalValue(financeDataRow.getCell(5)));
|
|
|
+ finance.setRevenueOther(getCellBigDecimalValue(financeDataRow.getCell(6)));
|
|
|
+ finance.setExpenseTotal(getCellBigDecimalValue(financeDataRow.getCell(7)));
|
|
|
+ finance.setExpenseFiscalPayment(getCellBigDecimalValue(financeDataRow.getCell(8)));
|
|
|
+ finance.setExpensePersonnel(getCellBigDecimalValue(financeDataRow.getCell(9)));
|
|
|
+ finance.setExpenseOffice(getCellBigDecimalValue(financeDataRow.getCell(10)));
|
|
|
+ finance.setExpenseMaintenance(getCellBigDecimalValue(financeDataRow.getCell(11)));
|
|
|
+ finance.setExpenseOther(getCellBigDecimalValue(financeDataRow.getCell(12)));
|
|
|
+ finance.setProfit(getCellBigDecimalValue(financeDataRow.getCell(13)));
|
|
|
+ finance.setTax(getCellBigDecimalValue(financeDataRow.getCell(14)));
|
|
|
+ finance.setTaxRate(getCellBigDecimalValue(financeDataRow.getCell(15)));
|
|
|
+ finance.setRemark(getCellStringValue(financeDataRow.getCell(16)));
|
|
|
+
|
|
|
+ // 解析2024年月度游客数据(第12行,用户填写的新数据)
|
|
|
+ finance.setVisitorJan(getCellIntValue(monthlyVisitorDataRow.getCell(1)));
|
|
|
+ finance.setVisitorFeb(getCellIntValue(monthlyVisitorDataRow.getCell(2)));
|
|
|
+ finance.setVisitorMar(getCellIntValue(monthlyVisitorDataRow.getCell(3)));
|
|
|
+ finance.setVisitorApr(getCellIntValue(monthlyVisitorDataRow.getCell(4)));
|
|
|
+ finance.setVisitorMay(getCellIntValue(monthlyVisitorDataRow.getCell(5)));
|
|
|
+ finance.setVisitorJun(getCellIntValue(monthlyVisitorDataRow.getCell(6)));
|
|
|
+ finance.setVisitorJul(getCellIntValue(monthlyVisitorDataRow.getCell(7)));
|
|
|
+ finance.setVisitorAug(getCellIntValue(monthlyVisitorDataRow.getCell(8)));
|
|
|
+ finance.setVisitorSep(getCellIntValue(monthlyVisitorDataRow.getCell(9)));
|
|
|
+ finance.setVisitorOct(getCellIntValue(monthlyVisitorDataRow.getCell(10)));
|
|
|
+ finance.setVisitorNov(getCellIntValue(monthlyVisitorDataRow.getCell(11)));
|
|
|
+ finance.setVisitorDec(getCellIntValue(monthlyVisitorDataRow.getCell(12)));
|
|
|
+ finance.setVisitorTotal(getCellIntValue(monthlyVisitorDataRow.getCell(13)));
|
|
|
+ finance.setVisitorDiscount(getCellIntValue(monthlyVisitorDataRow.getCell(14)));
|
|
|
+ finance.setVisitorFree(getCellIntValue(monthlyVisitorDataRow.getCell(15)));
|
|
|
+ finance.setVisitorFreeRate(getCellBigDecimalValue(monthlyVisitorDataRow.getCell(16)));
|
|
|
+
|
|
|
+ workbook.close();
|
|
|
|
|
|
- return CommonResult.<String>ok().value("成功更新价格记录");
|
|
|
+ // 导入时直接保存,不创建历史记录
|
|
|
+ financeManager.save(finance);
|
|
|
+
|
|
|
+ return CommonResult.<String>ok().message("成功导入价格和收支记录");
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
return CommonResult.<String>error().message("导入失败: " + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取单元格整数值
|
|
|
+ */
|
|
|
+ private Integer getCellIntValue(Cell cell) {
|
|
|
+ if (cell == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ switch (cell.getCellType()) {
|
|
|
+ case NUMERIC:
|
|
|
+ return (int) cell.getNumericCellValue();
|
|
|
+ case STRING:
|
|
|
+ String str = cell.getStringCellValue().trim();
|
|
|
+ return str.isEmpty() ? null : Integer.parseInt(str);
|
|
|
+ default:
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
- * 只更新价格字段
|
|
|
+ * 获取单元格BigDecimal值
|
|
|
*/
|
|
|
- private void updatePriceFieldsFromData(FapReportScenic record, Map<String, Object> data) {
|
|
|
- Object ticketLow = data.get("ticketLow");
|
|
|
- if (ticketLow != null) {
|
|
|
- record.setTicketLow(ticketLow.toString());
|
|
|
+ private java.math.BigDecimal getCellBigDecimalValue(Cell cell) {
|
|
|
+ if (cell == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ switch (cell.getCellType()) {
|
|
|
+ case NUMERIC:
|
|
|
+ return new java.math.BigDecimal(cell.getNumericCellValue());
|
|
|
+ case STRING:
|
|
|
+ String str = cell.getStringCellValue().trim();
|
|
|
+ return str.isEmpty() ? null : new java.math.BigDecimal(str);
|
|
|
+ default:
|
|
|
+ return null;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- Object ticketHigh = data.get("ticketHigh");
|
|
|
- if (ticketHigh != null) {
|
|
|
- record.setTicketHigh(ticketHigh.toString());
|
|
|
+ /**
|
|
|
+ * 获取单元格字符串值
|
|
|
+ */
|
|
|
+ private String getCellStringValue(Cell cell) {
|
|
|
+ if (cell == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ switch (cell.getCellType()) {
|
|
|
+ case NUMERIC:
|
|
|
+ return String.valueOf(cell.getNumericCellValue());
|
|
|
+ case STRING:
|
|
|
+ return cell.getStringCellValue();
|
|
|
+ default:
|
|
|
+ return null;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- Object price1 = data.get("price1");
|
|
|
- if (price1 != null) {
|
|
|
- record.setPrice1(price1.toString());
|
|
|
+ /**
|
|
|
+ * 获取单元格LocalDate值
|
|
|
+ */
|
|
|
+ private java.time.LocalDate getCellLocalDateValue(Cell cell) {
|
|
|
+ if (cell == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ switch (cell.getCellType()) {
|
|
|
+ case NUMERIC:
|
|
|
+ // 如果是日期格式
|
|
|
+ if (org.apache.poi.ss.usermodel.DateUtil.isCellDateFormatted(cell)) {
|
|
|
+ return cell.getLocalDateTimeCellValue().toLocalDate();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ case STRING:
|
|
|
+ String str = cell.getStringCellValue().trim();
|
|
|
+ if (str.isEmpty()) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ // 尝试解析常见日期格式
|
|
|
+ return java.time.LocalDate.parse(str);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ return null;
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ // ==================== 景区收支情况相关接口 ====================
|
|
|
+
|
|
|
|
|
|
- Object price2 = data.get("price2");
|
|
|
- if (price2 != null) {
|
|
|
- record.setPrice2(price2.toString());
|
|
|
+ /**
|
|
|
+ * 获取景区收支调整记录列表(所有历史记录)
|
|
|
+ * 返回包含景区价格信息和收支情况的完整列表
|
|
|
+ */
|
|
|
+ @GetMapping("/finance/list")
|
|
|
+ @ApiOperation("获取景区收支调整记录列表")
|
|
|
+ public CommonResult<List<Map<String, Object>>> getFinanceList(
|
|
|
+ @ApiParam(value = "景区ID", required = true) @RequestParam String id) {
|
|
|
+
|
|
|
+ // 获取景区基本信息
|
|
|
+ FapReportScenic scenic = fapReportScenicManager.getById(id);
|
|
|
+ if (scenic == null) {
|
|
|
+ return CommonResult.<List<Map<String, Object>>>error().message("景区不存在");
|
|
|
}
|
|
|
|
|
|
- Object price3 = data.get("price3");
|
|
|
- if (price3 != null) {
|
|
|
- record.setPrice3(price3.toString());
|
|
|
+ // 获取收支调整记录列表
|
|
|
+ LambdaQueryWrapper<FapScenicFinance> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(FapScenicFinance::getScenicId, id);
|
|
|
+ wrapper.orderByDesc(FapScenicFinance::getCreateTime);
|
|
|
+ List<FapScenicFinance> financeList = financeManager.list(wrapper);
|
|
|
+
|
|
|
+ // 组合数据:景区价格信息 + 收支情况
|
|
|
+ List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
+ for (FapScenicFinance finance : financeList) {
|
|
|
+ Map<String, Object> item = new HashMap<>();
|
|
|
+
|
|
|
+ // 基本信息
|
|
|
+ item.put("id", finance.getId());
|
|
|
+ item.put("scenicId", finance.getScenicId());
|
|
|
+ item.put("scenicName", scenic.getScenicName());
|
|
|
+ item.put("year", finance.getYear());
|
|
|
+ item.put("createTime", finance.getCreateTime());
|
|
|
+
|
|
|
+ // 门票价格(来自景区表)
|
|
|
+ item.put("ticketLow", scenic.getTicketLow());
|
|
|
+ item.put("ticketHigh", scenic.getTicketHigh());
|
|
|
+ item.put("ticketLowAdjust", scenic.getTicketLowAdjust());
|
|
|
+ item.put("ticketHighAdjust", scenic.getTicketHighAdjust());
|
|
|
+
|
|
|
+ // 交通价格(来自景区表)
|
|
|
+ item.put("price1", scenic.getPrice1()); // 景交车
|
|
|
+ item.put("price2", scenic.getPrice2()); // 观光车
|
|
|
+ item.put("price3", scenic.getPrice3()); // 缆车
|
|
|
+ item.put("price4", scenic.getPrice4()); // 索道
|
|
|
+ item.put("price5", scenic.getPrice5()); // 电梯
|
|
|
+ item.put("price6", scenic.getPrice6()); // 游船
|
|
|
+ item.put("price7", scenic.getPrice7()); // 停车场
|
|
|
+ item.put("price8", scenic.getPrice8()); // 其他
|
|
|
+
|
|
|
+ // 收支情况(来自收支表)
|
|
|
+ item.put("employeeCount", finance.getEmployeeCount());
|
|
|
+ item.put("revenueTotal", finance.getRevenueTotal());
|
|
|
+ item.put("expenseTotal", finance.getExpenseTotal());
|
|
|
+ item.put("profit", finance.getProfit());
|
|
|
+ item.put("remark", finance.getRemark());
|
|
|
+
|
|
|
+ resultList.add(item);
|
|
|
}
|
|
|
|
|
|
- Object price4 = data.get("price4");
|
|
|
- if (price4 != null) {
|
|
|
- record.setPrice4(price4.toString());
|
|
|
+ return CommonResult.<List<Map<String, Object>>>ok().value(resultList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取收支调整记录详情(包含景区基础信息)
|
|
|
+ */
|
|
|
+ @GetMapping("/finance/detail")
|
|
|
+ @ApiOperation("获取收支调整记录详情")
|
|
|
+ public CommonResult<Map<String, Object>> getFinanceDetail(
|
|
|
+ @ApiParam(value = "调整记录ID", required = true) @RequestParam String id) {
|
|
|
+
|
|
|
+ FapScenicFinance finance = financeManager.getById(id);
|
|
|
+ if (finance == null) {
|
|
|
+ return CommonResult.<Map<String, Object>>error().message("调整记录不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取景区基础信息
|
|
|
+ FapReportScenic scenic = fapReportScenicManager.getById(finance.getScenicId());
|
|
|
+ if (scenic == null) {
|
|
|
+ return CommonResult.<Map<String, Object>>error().message("景区不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 组合数据
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+
|
|
|
+ // 基本信息
|
|
|
+ result.put("id", finance.getId());
|
|
|
+ result.put("scenicId", finance.getScenicId());
|
|
|
+ result.put("scenicName", scenic.getScenicName());
|
|
|
+ result.put("year", finance.getYear());
|
|
|
+ result.put("createTime", finance.getCreateTime());
|
|
|
+
|
|
|
+ // 填报信息
|
|
|
+ result.put("unitName", finance.getUnitName());
|
|
|
+ result.put("fillDate", finance.getFillDate());
|
|
|
+ result.put("responsiblePerson", finance.getResponsiblePerson());
|
|
|
+ result.put("contactPhone", finance.getContactPhone());
|
|
|
+
|
|
|
+ // 景区基础信息
|
|
|
+ result.put("scenicStatus", scenic.getScenicStatus());
|
|
|
+ result.put("scenicLevel", scenic.getScenicLevel());
|
|
|
+ result.put("resourceType", scenic.getResourceType());
|
|
|
+ result.put("scenicType", scenic.getScenicType());
|
|
|
+ result.put("scenicLocality", scenic.getScenicLocality());
|
|
|
+ result.put("competentOrg", scenic.getCompetentOrg());
|
|
|
+
|
|
|
+ // 字典值转换为中文
|
|
|
+ result.put("operationNature", scenic.getOperationNature());
|
|
|
+ DataDict operationNatureDict = dataDictManager.getByDictKey("1965686172473999360", scenic.getOperationNature());
|
|
|
+ result.put("operationNatureName", operationNatureDict != null ? operationNatureDict.getName() : "");
|
|
|
+
|
|
|
+ result.put("managementAttr", scenic.getManagementAttr());
|
|
|
+ DataDict managementAttrDict = dataDictManager.getByDictKey("1965686172473999360", scenic.getManagementAttr());
|
|
|
+ result.put("managementAttrName", managementAttrDict != null ? managementAttrDict.getName() : "");
|
|
|
+
|
|
|
+ result.put("scenicArea", scenic.getScenicArea());
|
|
|
+ result.put("areaUnit", scenic.getAreaUnit());
|
|
|
+ result.put("priceManageForm", scenic.getPriceManageForm());
|
|
|
+
|
|
|
+ result.put("revenueManage", scenic.getRevenueManage());
|
|
|
+ DataDict revenueManageDict = dataDictManager.getByDictKey("1965686172473999360", scenic.getRevenueManage());
|
|
|
+ result.put("revenueManageName", revenueManageDict != null ? revenueManageDict.getName() : "");
|
|
|
+
|
|
|
+ // 门票价格
|
|
|
+ result.put("ticketLow", scenic.getTicketLow());
|
|
|
+ result.put("ticketHigh", scenic.getTicketHigh());
|
|
|
+ result.put("executeTime", scenic.getExecuteTime());
|
|
|
+ result.put("ticketLowAdjust", scenic.getTicketLowAdjust());
|
|
|
+ result.put("ticketHighAdjust", scenic.getTicketHighAdjust());
|
|
|
+ result.put("executeTimeAdjust", scenic.getExecuteTimeAdjust());
|
|
|
+
|
|
|
+ // 交通价格
|
|
|
+ result.put("price1", scenic.getPrice1()); // 景交车
|
|
|
+ result.put("price2", scenic.getPrice2()); // 观光车
|
|
|
+ result.put("price3", scenic.getPrice3()); // 缆车
|
|
|
+ result.put("price4", scenic.getPrice4()); // 索道
|
|
|
+ result.put("price5", scenic.getPrice5()); // 电梯
|
|
|
+ result.put("price6", scenic.getPrice6()); // 游船
|
|
|
+ result.put("price7", scenic.getPrice7()); // 停车场
|
|
|
+ result.put("price8", scenic.getPrice8()); // 其他
|
|
|
+
|
|
|
+ // 成本监审和定价文件
|
|
|
+ result.put("costAuditResult", scenic.getCostAuditResult());
|
|
|
+ result.put("pricingDocNo", scenic.getPricingDocNo());
|
|
|
+
|
|
|
+ // 收支情况
|
|
|
+ result.put("employeeCount", finance.getEmployeeCount());
|
|
|
+ result.put("revenueTotal", finance.getRevenueTotal());
|
|
|
+ result.put("revenueTicket", finance.getRevenueTicket());
|
|
|
+ result.put("revenueService", finance.getRevenueService());
|
|
|
+ result.put("revenueFiscal", finance.getRevenueFiscal());
|
|
|
+ result.put("revenueOther", finance.getRevenueOther());
|
|
|
+ result.put("expenseTotal", finance.getExpenseTotal());
|
|
|
+ result.put("expenseFiscalPayment", finance.getExpenseFiscalPayment());
|
|
|
+ result.put("expensePersonnel", finance.getExpensePersonnel());
|
|
|
+ result.put("expenseOffice", finance.getExpenseOffice());
|
|
|
+ result.put("expenseMaintenance", finance.getExpenseMaintenance());
|
|
|
+ result.put("expenseOther", finance.getExpenseOther());
|
|
|
+ result.put("profit", finance.getProfit());
|
|
|
+ result.put("tax", finance.getTax());
|
|
|
+ result.put("taxRate", finance.getTaxRate());
|
|
|
+
|
|
|
+ // 游客数据
|
|
|
+ result.put("visitorJan", finance.getVisitorJan());
|
|
|
+ result.put("visitorFeb", finance.getVisitorFeb());
|
|
|
+ result.put("visitorMar", finance.getVisitorMar());
|
|
|
+ result.put("visitorApr", finance.getVisitorApr());
|
|
|
+ result.put("visitorMay", finance.getVisitorMay());
|
|
|
+ result.put("visitorJun", finance.getVisitorJun());
|
|
|
+ result.put("visitorJul", finance.getVisitorJul());
|
|
|
+ result.put("visitorAug", finance.getVisitorAug());
|
|
|
+ result.put("visitorSep", finance.getVisitorSep());
|
|
|
+ result.put("visitorOct", finance.getVisitorOct());
|
|
|
+ result.put("visitorNov", finance.getVisitorNov());
|
|
|
+ result.put("visitorDec", finance.getVisitorDec());
|
|
|
+ result.put("visitorTotal", finance.getVisitorTotal());
|
|
|
+ result.put("visitorDiscount", finance.getVisitorDiscount());
|
|
|
+ result.put("visitorFree", finance.getVisitorFree());
|
|
|
+ result.put("visitorFreeRate", finance.getVisitorFreeRate());
|
|
|
+
|
|
|
+ // 备注
|
|
|
+ result.put("remark", finance.getRemark());
|
|
|
+
|
|
|
+ return CommonResult.<Map<String, Object>>ok().value(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出收支调整记录详情(复杂表格格式)
|
|
|
+ */
|
|
|
+ @GetMapping("/finance/export")
|
|
|
+ @ApiOperation("导出收支调整记录详情")
|
|
|
+ public void exportFinanceDetail(
|
|
|
+ @ApiParam(value = "调整记录ID", required = true) @RequestParam String id,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+
|
|
|
+ FapScenicFinance finance = financeManager.getById(id);
|
|
|
+ if (finance == null) {
|
|
|
+ throw new IllegalArgumentException("调整记录不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取景区信息
|
|
|
+ FapReportScenic scenic = fapReportScenicManager.getById(finance.getScenicId());
|
|
|
+ if (scenic == null) {
|
|
|
+ throw new IllegalArgumentException("景区不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 创建工作簿
|
|
|
+ XSSFWorkbook workbook = new XSSFWorkbook();
|
|
|
+ XSSFSheet sheet = workbook.createSheet("景区价格信息统计表");
|
|
|
+
|
|
|
+ // 创建样式
|
|
|
+ CellStyle titleStyle = createTitleStyle(workbook);
|
|
|
+ CellStyle headerStyle = createHeaderStyle(workbook);
|
|
|
+ CellStyle dataStyle = createDataStyle(workbook);
|
|
|
+ CellStyle centerStyle = createCenterStyle(workbook);
|
|
|
+
|
|
|
+ int rowNum = 0;
|
|
|
+
|
|
|
+ // 第1行:标题
|
|
|
+ Row titleRow = sheet.createRow(rowNum++);
|
|
|
+ titleRow.setHeightInPoints(35);
|
|
|
+ Cell titleCell = titleRow.createCell(0);
|
|
|
+ String title = scenic.getScenicName() + "景区门票价格信息统计表";
|
|
|
+ titleCell.setCellValue(title);
|
|
|
+ titleCell.setCellStyle(titleStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, 0, 0, 0, 19);
|
|
|
+
|
|
|
+ // 第2行:单位和填表时间
|
|
|
+ Row unitRow = sheet.createRow(rowNum++);
|
|
|
+ unitRow.setHeightInPoints(25);
|
|
|
+
|
|
|
+ // 单位标签(第0-1列合并)
|
|
|
+ Cell unitLabelCell = unitRow.createCell(0);
|
|
|
+ unitLabelCell.setCellValue("单位:");
|
|
|
+ unitLabelCell.setCellStyle(headerStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 0, 1);
|
|
|
+
|
|
|
+ // 单位值(第2-11列合并,填充实际数据)
|
|
|
+ Cell unitValueCell = unitRow.createCell(2);
|
|
|
+ unitValueCell.setCellValue(finance.getUnitName() != null ? finance.getUnitName() : "");
|
|
|
+ unitValueCell.setCellStyle(dataStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 2, 11);
|
|
|
+
|
|
|
+ // 填表时间标签(第12-13列合并)
|
|
|
+ Cell dateLabelCell = unitRow.createCell(12);
|
|
|
+ dateLabelCell.setCellValue("填表时间:");
|
|
|
+ dateLabelCell.setCellStyle(headerStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 12, 13);
|
|
|
+
|
|
|
+ // 填表时间值(第14-19列合并,填充实际数据)
|
|
|
+ Cell dateValueCell = unitRow.createCell(14);
|
|
|
+ dateValueCell.setCellValue(finance.getFillDate() != null ? finance.getFillDate().toString() : "");
|
|
|
+ dateValueCell.setCellStyle(dataStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 14, 19);
|
|
|
+
|
|
|
+ // 第3行:景区基本信息表头
|
|
|
+ Row basicInfoHeaderRow = sheet.createRow(rowNum++);
|
|
|
+ basicInfoHeaderRow.setHeightInPoints(30);
|
|
|
+
|
|
|
+ // 第0列:"基本情况"标签(稍后合并第3-7行)
|
|
|
+ Cell basicSituationLabel = basicInfoHeaderRow.createCell(0);
|
|
|
+ basicSituationLabel.setCellValue("基本情况");
|
|
|
+ basicSituationLabel.setCellStyle(headerStyle);
|
|
|
+
|
|
|
+ basicInfoHeaderRow.createCell(1).setCellValue("景区名称");
|
|
|
+ basicInfoHeaderRow.createCell(2).setCellValue("景区类型");
|
|
|
+ basicInfoHeaderRow.createCell(3).setCellValue("景区等级");
|
|
|
+ basicInfoHeaderRow.createCell(4).setCellValue("价格管理形式");
|
|
|
+ basicInfoHeaderRow.createCell(5).setCellValue("景区面积");
|
|
|
+ basicInfoHeaderRow.createCell(6).setCellValue("主管部门");
|
|
|
+ basicInfoHeaderRow.createCell(7).setCellValue("运营性质");
|
|
|
+ basicInfoHeaderRow.createCell(8).setCellValue("管理属性");
|
|
|
+
|
|
|
+ // 门票收支管理方式(第9-19列合并)
|
|
|
+ Cell revenueManageHeader = basicInfoHeaderRow.createCell(9);
|
|
|
+ revenueManageHeader.setCellValue("门票收支管理方式及财政资金关系");
|
|
|
+ revenueManageHeader.setCellStyle(headerStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 9, 19);
|
|
|
+
|
|
|
+ // 设置表头样式
|
|
|
+ for (int i = 1; i <= 8; i++) {
|
|
|
+ basicInfoHeaderRow.getCell(i).setCellStyle(headerStyle);
|
|
|
}
|
|
|
|
|
|
- Object price5 = data.get("price5");
|
|
|
- if (price5 != null) {
|
|
|
- record.setPrice5(price5.toString());
|
|
|
+ // 第4行:景区基本信息数据
|
|
|
+ Row basicInfoDataRow = sheet.createRow(rowNum++);
|
|
|
+ basicInfoDataRow.setHeightInPoints(25);
|
|
|
+
|
|
|
+ basicInfoDataRow.createCell(1).setCellValue(scenic.getScenicName() != null ? scenic.getScenicName() : "");
|
|
|
+ basicInfoDataRow.createCell(2).setCellValue(scenic.getScenicType() != null ? scenic.getScenicType() : "");
|
|
|
+ basicInfoDataRow.createCell(3).setCellValue(scenic.getScenicLevel() != null ? scenic.getScenicLevel() : "");
|
|
|
+ basicInfoDataRow.createCell(4).setCellValue(scenic.getPriceManageForm() != null ? scenic.getPriceManageForm() : "");
|
|
|
+ basicInfoDataRow.createCell(5).setCellValue((scenic.getScenicArea() != null ? scenic.getScenicArea() : "") +
|
|
|
+ (scenic.getAreaUnit() != null ? scenic.getAreaUnit() : ""));
|
|
|
+ basicInfoDataRow.createCell(6).setCellValue(scenic.getCompetentOrg() != null ? scenic.getCompetentOrg() : "");
|
|
|
+ // 运营性质
|
|
|
+ DataDict operationNatureDict = dataDictManager.getByDictKey("1965686172473999360", scenic.getOperationNature());
|
|
|
+ basicInfoDataRow.createCell(7).setCellValue(operationNatureDict != null ? operationNatureDict.getName() : "");
|
|
|
+ DataDict managementAttrDict = dataDictManager.getByDictKey("1965686172473999360", scenic.getManagementAttr());
|
|
|
+ basicInfoDataRow.createCell(8).setCellValue(managementAttrDict != null ? managementAttrDict.getName() : "");
|
|
|
+
|
|
|
+ // 门票收支管理方式(第9-19列合并)
|
|
|
+ Cell revenueManageData = basicInfoDataRow.createCell(9);
|
|
|
+ DataDict revenueManageDict = dataDictManager.getByDictKey("1965686172473999360", scenic.getRevenueManage());
|
|
|
+ revenueManageData.setCellValue(revenueManageDict != null ? revenueManageDict.getName() : "");
|
|
|
+ revenueManageData.setCellStyle(dataStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 9, 19);
|
|
|
+
|
|
|
+ // 设置前8列样式
|
|
|
+ for (int i = 1; i <= 8; i++) {
|
|
|
+ basicInfoDataRow.getCell(i).setCellStyle(dataStyle);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 第5行:门票价格第一行表头
|
|
|
+ Row priceHeaderRow1 = sheet.createRow(rowNum++);
|
|
|
+ priceHeaderRow1.setHeightInPoints(30);
|
|
|
+
|
|
|
+ // 调整前门票价格(合并第5行的1-3列)
|
|
|
+ Cell beforePriceHeader = priceHeaderRow1.createCell(1);
|
|
|
+ beforePriceHeader.setCellValue("调整前门票价格(元/人)");
|
|
|
+ beforePriceHeader.setCellStyle(headerStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 1, 3);
|
|
|
+
|
|
|
+ // 调整后门票价格(合并第5行的4-6列)
|
|
|
+ Cell afterPriceHeader = priceHeaderRow1.createCell(4);
|
|
|
+ afterPriceHeader.setCellValue("调整后门票价格(元/人)");
|
|
|
+ afterPriceHeader.setCellStyle(headerStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 4, 6);
|
|
|
+
|
|
|
+ // 调整幅度(合并第5行的7-8列)
|
|
|
+ Cell adjustHeader = priceHeaderRow1.createCell(7);
|
|
|
+ adjustHeader.setCellValue("调整幅度(元/人)");
|
|
|
+ adjustHeader.setCellStyle(headerStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 7, 8);
|
|
|
+
|
|
|
+ // 景区内交通运输服务价格(合并第5行的9-16列)
|
|
|
+ Cell transportHeader = priceHeaderRow1.createCell(9);
|
|
|
+ transportHeader.setCellValue("景区内交通运输服务价格(元/人)");
|
|
|
+ transportHeader.setCellStyle(headerStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 9, 16);
|
|
|
+
|
|
|
+ // 成本监审、成本调查、价格评估结果(合并第5行的17-18列)
|
|
|
+ Cell costAuditHeader5 = priceHeaderRow1.createCell(17);
|
|
|
+ costAuditHeader5.setCellValue("成本监审、成本调查、价格评估结果");
|
|
|
+ costAuditHeader5.setCellStyle(headerStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum, 17, 18);
|
|
|
+
|
|
|
+ // 定价文件(合并第5行的19列,跨2行)
|
|
|
+ Cell pricingDocHeader5 = priceHeaderRow1.createCell(19);
|
|
|
+ pricingDocHeader5.setCellValue("定价文件");
|
|
|
+ pricingDocHeader5.setCellStyle(headerStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum, 19, 19);
|
|
|
+
|
|
|
+ // 第6行:基本情况第二行表头
|
|
|
+ Row priceHeaderRow2 = sheet.createRow(rowNum++);
|
|
|
+ priceHeaderRow2.setHeightInPoints(25);
|
|
|
+
|
|
|
+ priceHeaderRow2.createCell(1).setCellValue("旺季");
|
|
|
+ priceHeaderRow2.createCell(2).setCellValue("淡季");
|
|
|
+ priceHeaderRow2.createCell(3).setCellValue("执行时间");
|
|
|
+ priceHeaderRow2.createCell(4).setCellValue("旺季");
|
|
|
+ priceHeaderRow2.createCell(5).setCellValue("淡季");
|
|
|
+ priceHeaderRow2.createCell(6).setCellValue("执行时间");
|
|
|
+ priceHeaderRow2.createCell(7).setCellValue("旺季");
|
|
|
+ priceHeaderRow2.createCell(8).setCellValue("淡季");
|
|
|
+
|
|
|
+ // 交通工具子表头
|
|
|
+ String[] transportHeaders = {"景交车", "观光车", "缆车", "索道", "电梯", "游船", "停车场", "其他"};
|
|
|
+ for (int i = 0; i < transportHeaders.length; i++) {
|
|
|
+ priceHeaderRow2.createCell(9 + i).setCellValue(transportHeaders[i]);
|
|
|
}
|
|
|
|
|
|
- Object price6 = data.get("price6");
|
|
|
- if (price6 != null) {
|
|
|
- record.setPrice6(price6.toString());
|
|
|
+ // 设置第6行表头样式
|
|
|
+ for (int i = 1; i <= 16; i++) {
|
|
|
+ if (priceHeaderRow2.getCell(i) != null) {
|
|
|
+ priceHeaderRow2.getCell(i).setCellStyle(headerStyle);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- Object price7 = data.get("price7");
|
|
|
- if (price7 != null) {
|
|
|
- record.setPrice7(price7.toString());
|
|
|
+ // 第7行:门票价格、交通价格、成本监审、定价文件
|
|
|
+ Row priceDataRow = sheet.createRow(rowNum++);
|
|
|
+ priceDataRow.setHeightInPoints(25);
|
|
|
+
|
|
|
+ // 合并"基本情况"标签(第0列,第3-7行,跨5行)
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 5, rowNum - 1, 0, 0);
|
|
|
+
|
|
|
+ // 调整前门票价格
|
|
|
+ priceDataRow.createCell(1).setCellValue(scenic.getTicketHigh() != null ? scenic.getTicketHigh() : "");
|
|
|
+ priceDataRow.createCell(2).setCellValue(scenic.getTicketLow() != null ? scenic.getTicketLow() : "");
|
|
|
+ priceDataRow.createCell(3).setCellValue(scenic.getExecuteTime() != null ? scenic.getExecuteTime().toString() : "");
|
|
|
+
|
|
|
+ // 调整后门票价格
|
|
|
+ priceDataRow.createCell(4).setCellValue(scenic.getTicketHighAdjust() != null ? scenic.getTicketHighAdjust() : "");
|
|
|
+ priceDataRow.createCell(5).setCellValue(scenic.getTicketLowAdjust() != null ? scenic.getTicketLowAdjust() : "");
|
|
|
+ priceDataRow.createCell(6).setCellValue(scenic.getExecuteTimeAdjust() != null ? scenic.getExecuteTimeAdjust().toString() : "");
|
|
|
+
|
|
|
+ // 调整幅度(计算百分比)
|
|
|
+ String highAdjust = "";
|
|
|
+ String lowAdjust = "";
|
|
|
+ try {
|
|
|
+ if (scenic.getTicketHigh() != null && scenic.getTicketHighAdjust() != null) {
|
|
|
+ double before = Double.parseDouble(scenic.getTicketHigh());
|
|
|
+ double after = Double.parseDouble(scenic.getTicketHighAdjust());
|
|
|
+ if (before != 0) {
|
|
|
+ double percentage = ((after - before) / before) * 100;
|
|
|
+ highAdjust = String.format("%.2f%%", percentage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (scenic.getTicketLow() != null && scenic.getTicketLowAdjust() != null) {
|
|
|
+ double before = Double.parseDouble(scenic.getTicketLow());
|
|
|
+ double after = Double.parseDouble(scenic.getTicketLowAdjust());
|
|
|
+ if (before != 0) {
|
|
|
+ double percentage = ((after - before) / before) * 100;
|
|
|
+ lowAdjust = String.format("%.2f%%", percentage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ // 忽略格式错误
|
|
|
}
|
|
|
+ priceDataRow.createCell(7).setCellValue(highAdjust);
|
|
|
+ priceDataRow.createCell(8).setCellValue(lowAdjust);
|
|
|
+
|
|
|
+ // 交通价格(第9-16列)
|
|
|
+ priceDataRow.createCell(9).setCellValue(scenic.getPrice1() != null ? scenic.getPrice1() : "");
|
|
|
+ priceDataRow.createCell(10).setCellValue(scenic.getPrice2() != null ? scenic.getPrice2() : "");
|
|
|
+ priceDataRow.createCell(11).setCellValue(scenic.getPrice3() != null ? scenic.getPrice3() : "");
|
|
|
+ priceDataRow.createCell(12).setCellValue(scenic.getPrice4() != null ? scenic.getPrice4() : "");
|
|
|
+ priceDataRow.createCell(13).setCellValue(scenic.getPrice5() != null ? scenic.getPrice5() : "");
|
|
|
+ priceDataRow.createCell(14).setCellValue(scenic.getPrice6() != null ? scenic.getPrice6() : "");
|
|
|
+ priceDataRow.createCell(15).setCellValue(scenic.getPrice7() != null ? scenic.getPrice7() : "");
|
|
|
+ priceDataRow.createCell(16).setCellValue(scenic.getPrice8() != null ? scenic.getPrice8() : "");
|
|
|
|
|
|
- Object price8 = data.get("price8");
|
|
|
- if (price8 != null) {
|
|
|
- record.setPrice8(price8.toString());
|
|
|
+ // 成本监审、成本调查、价格评估结果(第17-18列合并)
|
|
|
+ Cell costResultCell = priceDataRow.createCell(17);
|
|
|
+ costResultCell.setCellValue(scenic.getCostAuditResult() != null ? scenic.getCostAuditResult() : "");
|
|
|
+ costResultCell.setCellStyle(dataStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 17, 18);
|
|
|
+
|
|
|
+ // 定价文件(第19列)
|
|
|
+ Cell pricingDocCell = priceDataRow.createCell(19);
|
|
|
+ pricingDocCell.setCellValue(scenic.getPricingDocNo() != null ? scenic.getPricingDocNo() : "");
|
|
|
+ pricingDocCell.setCellStyle(dataStyle);
|
|
|
+
|
|
|
+ // 设置数据行样式
|
|
|
+ for (int i = 1; i <= 16; i++) {
|
|
|
+ if (priceDataRow.getCell(i) != null) {
|
|
|
+ priceDataRow.getCell(i).setCellStyle(dataStyle);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ // 第8-9行:收支情况表头
|
|
|
+ Row financeHeaderRow1 = sheet.createRow(rowNum++);
|
|
|
+ financeHeaderRow1.setHeightInPoints(30);
|
|
|
+ Row financeHeaderRow2 = sheet.createRow(rowNum++);
|
|
|
+ financeHeaderRow2.setHeightInPoints(25);
|
|
|
+
|
|
|
+ // 第一列:收支情况标签(跨3行)
|
|
|
+ Cell financeLabelCell = financeHeaderRow1.createCell(0);
|
|
|
+ financeLabelCell.setCellValue("收支情况");
|
|
|
+ financeLabelCell.setCellStyle(headerStyle);
|
|
|
+
|
|
|
+ Cell fh1 = financeHeaderRow1.createCell(1);
|
|
|
+ fh1.setCellValue("员工人数");
|
|
|
+ fh1.setCellStyle(headerStyle);
|
|
|
+
|
|
|
+ Cell fh2 = financeHeaderRow1.createCell(2);
|
|
|
+ fh2.setCellValue("总收入(万元)");
|
|
|
+ fh2.setCellStyle(headerStyle);
|
|
|
+
|
|
|
+ Cell fh3 = financeHeaderRow1.createCell(7);
|
|
|
+ fh3.setCellValue("总支出(万元)");
|
|
|
+ fh3.setCellStyle(headerStyle);
|
|
|
+
|
|
|
+ Cell fh4 = financeHeaderRow1.createCell(13);
|
|
|
+ fh4.setCellValue("利润(万元)");
|
|
|
+ fh4.setCellStyle(headerStyle);
|
|
|
+
|
|
|
+ Cell fh5 = financeHeaderRow1.createCell(14);
|
|
|
+ fh5.setCellValue("税金(万元)");
|
|
|
+ fh5.setCellStyle(headerStyle);
|
|
|
+
|
|
|
+ Cell fh6 = financeHeaderRow1.createCell(15);
|
|
|
+ fh6.setCellValue("税率(%)");
|
|
|
+ fh6.setCellStyle(headerStyle);
|
|
|
+
|
|
|
+ Cell fh7 = financeHeaderRow1.createCell(16);
|
|
|
+ fh7.setCellValue("备注");
|
|
|
+ fh7.setCellStyle(headerStyle);
|
|
|
+
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 2, rowNum - 1, 1, 1); // 员工人数
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 2, rowNum - 2, 2, 6); // 总收入
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 2, rowNum - 2, 7, 12); // 总支出
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 2, rowNum - 1, 13, 13); // 利润
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 2, rowNum - 1, 14, 14); // 税金
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 2, rowNum - 1, 15, 15); // 税率
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 2, rowNum - 1, 16, 19); // 备注(合并到第19列)
|
|
|
+
|
|
|
+ String[] revenueHeaders = {"合计", "门票", "经营服务", "财政拨款", "其他"};
|
|
|
+ for (int i = 0; i < revenueHeaders.length; i++) {
|
|
|
+ Cell rhCell = financeHeaderRow2.createCell(i + 2);
|
|
|
+ rhCell.setCellValue(revenueHeaders[i]);
|
|
|
+ rhCell.setCellStyle(headerStyle);
|
|
|
+ }
|
|
|
+
|
|
|
+ String[] expenseHeaders = {"合计", "上缴财政", "人员", "办公", "建设维护", "其他"};
|
|
|
+ for (int i = 0; i < expenseHeaders.length; i++) {
|
|
|
+ Cell ehCell = financeHeaderRow2.createCell(i + 7);
|
|
|
+ ehCell.setCellValue(expenseHeaders[i]);
|
|
|
+ ehCell.setCellStyle(headerStyle);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 第10行:收支情况数据
|
|
|
+ Row financeDataRow1 = sheet.createRow(rowNum++);
|
|
|
+ financeDataRow1.setHeightInPoints(25);
|
|
|
+
|
|
|
+ // 合并收支情况标签列(跨3行)- 第8-10行
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 3, rowNum - 1, 0, 0);
|
|
|
+
|
|
|
+ financeDataRow1.createCell(1).setCellValue(finance.getEmployeeCount() != null ? finance.getEmployeeCount() : 0);
|
|
|
+ financeDataRow1.createCell(2).setCellValue(finance.getRevenueTotal() != null ? finance.getRevenueTotal().doubleValue() : 0);
|
|
|
+ financeDataRow1.createCell(3).setCellValue(finance.getRevenueTicket() != null ? finance.getRevenueTicket().doubleValue() : 0);
|
|
|
+ financeDataRow1.createCell(4).setCellValue(finance.getRevenueService() != null ? finance.getRevenueService().doubleValue() : 0);
|
|
|
+ financeDataRow1.createCell(5).setCellValue(finance.getRevenueFiscal() != null ? finance.getRevenueFiscal().doubleValue() : 0);
|
|
|
+ financeDataRow1.createCell(6).setCellValue(finance.getRevenueOther() != null ? finance.getRevenueOther().doubleValue() : 0);
|
|
|
+ financeDataRow1.createCell(7).setCellValue(finance.getExpenseTotal() != null ? finance.getExpenseTotal().doubleValue() : 0);
|
|
|
+ financeDataRow1.createCell(8).setCellValue(finance.getExpenseFiscalPayment() != null ? finance.getExpenseFiscalPayment().doubleValue() : 0);
|
|
|
+ financeDataRow1.createCell(9).setCellValue(finance.getExpensePersonnel() != null ? finance.getExpensePersonnel().doubleValue() : 0);
|
|
|
+ financeDataRow1.createCell(10).setCellValue(finance.getExpenseOffice() != null ? finance.getExpenseOffice().doubleValue() : 0);
|
|
|
+ financeDataRow1.createCell(11).setCellValue(finance.getExpenseMaintenance() != null ? finance.getExpenseMaintenance().doubleValue() : 0);
|
|
|
+ financeDataRow1.createCell(12).setCellValue(finance.getExpenseOther() != null ? finance.getExpenseOther().doubleValue() : 0);
|
|
|
+ financeDataRow1.createCell(13).setCellValue(finance.getProfit() != null ? finance.getProfit().doubleValue() : 0);
|
|
|
+ financeDataRow1.createCell(14).setCellValue(finance.getTax() != null ? finance.getTax().doubleValue() : 0);
|
|
|
+ financeDataRow1.createCell(15).setCellValue(finance.getTaxRate() != null ? finance.getTaxRate().doubleValue() : 0);
|
|
|
+
|
|
|
+ // 备注(第16-19列合并)
|
|
|
+ Cell fd16 = financeDataRow1.createCell(16);
|
|
|
+ fd16.setCellValue(finance.getRemark() != null ? finance.getRemark() : "");
|
|
|
+ fd16.setCellStyle(dataStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 16, 19);
|
|
|
+
|
|
|
+ // 设置数据行样式
|
|
|
+ for (int i = 1; i <= 15; i++) {
|
|
|
+ if (financeDataRow1.getCell(i) != null) {
|
|
|
+ financeDataRow1.getCell(i).setCellStyle(dataStyle);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // ========== 第11-12行:年月度游客人数表格 ==========
|
|
|
+ Row monthlyVisitorHeaderRow = sheet.createRow(rowNum++);
|
|
|
+ monthlyVisitorHeaderRow.setHeightInPoints(25);
|
|
|
+ Row monthlyVisitorDataRow = sheet.createRow(rowNum++);
|
|
|
+ monthlyVisitorDataRow.setHeightInPoints(25);
|
|
|
+
|
|
|
+ // 第一列:标签(跨2行)
|
|
|
+ Cell monthlyLabel = monthlyVisitorHeaderRow.createCell(0);
|
|
|
+ monthlyLabel.setCellValue("年月度游客人数(人)");
|
|
|
+ monthlyLabel.setCellStyle(headerStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 2, rowNum - 1, 0, 0);
|
|
|
+
|
|
|
+ // 第11行:月度表头(1-12月)
|
|
|
+ String[] monthlyHeaders = {"1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"};
|
|
|
+ for (int i = 0; i < monthlyHeaders.length; i++) {
|
|
|
+ Cell mhCell = monthlyVisitorHeaderRow.createCell(i + 1);
|
|
|
+ mhCell.setCellValue(monthlyHeaders[i]);
|
|
|
+ mhCell.setCellStyle(headerStyle);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 本年度人数合计
|
|
|
+ Cell totalHeader = monthlyVisitorHeaderRow.createCell(13);
|
|
|
+ totalHeader.setCellValue("本年度人数合计");
|
|
|
+ totalHeader.setCellStyle(headerStyle);
|
|
|
+
|
|
|
+ // 优惠人数
|
|
|
+ Cell discountHeader = monthlyVisitorHeaderRow.createCell(14);
|
|
|
+ discountHeader.setCellValue("优惠人数");
|
|
|
+ discountHeader.setCellStyle(headerStyle);
|
|
|
+
|
|
|
+ // 其中免票人数
|
|
|
+ Cell freeHeader = monthlyVisitorHeaderRow.createCell(15);
|
|
|
+ freeHeader.setCellValue("其中免票人数");
|
|
|
+ freeHeader.setCellStyle(headerStyle);
|
|
|
+
|
|
|
+ // 免票人数占比(第16-19列合并)
|
|
|
+ Cell monthlyFreeRateHeader = monthlyVisitorHeaderRow.createCell(16);
|
|
|
+ monthlyFreeRateHeader.setCellValue("免票人数占比(%)");
|
|
|
+ monthlyFreeRateHeader.setCellStyle(headerStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 2, rowNum - 2, 16, 19);
|
|
|
+
|
|
|
+ // 第12行:月度游客数据(填充实际数据)
|
|
|
+ monthlyVisitorDataRow.createCell(1).setCellValue(finance.getVisitorJan() != null ? finance.getVisitorJan() : 0);
|
|
|
+ monthlyVisitorDataRow.createCell(2).setCellValue(finance.getVisitorFeb() != null ? finance.getVisitorFeb() : 0);
|
|
|
+ monthlyVisitorDataRow.createCell(3).setCellValue(finance.getVisitorMar() != null ? finance.getVisitorMar() : 0);
|
|
|
+ monthlyVisitorDataRow.createCell(4).setCellValue(finance.getVisitorApr() != null ? finance.getVisitorApr() : 0);
|
|
|
+ monthlyVisitorDataRow.createCell(5).setCellValue(finance.getVisitorMay() != null ? finance.getVisitorMay() : 0);
|
|
|
+ monthlyVisitorDataRow.createCell(6).setCellValue(finance.getVisitorJun() != null ? finance.getVisitorJun() : 0);
|
|
|
+ monthlyVisitorDataRow.createCell(7).setCellValue(finance.getVisitorJul() != null ? finance.getVisitorJul() : 0);
|
|
|
+ monthlyVisitorDataRow.createCell(8).setCellValue(finance.getVisitorAug() != null ? finance.getVisitorAug() : 0);
|
|
|
+ monthlyVisitorDataRow.createCell(9).setCellValue(finance.getVisitorSep() != null ? finance.getVisitorSep() : 0);
|
|
|
+ monthlyVisitorDataRow.createCell(10).setCellValue(finance.getVisitorOct() != null ? finance.getVisitorOct() : 0);
|
|
|
+ monthlyVisitorDataRow.createCell(11).setCellValue(finance.getVisitorNov() != null ? finance.getVisitorNov() : 0);
|
|
|
+ monthlyVisitorDataRow.createCell(12).setCellValue(finance.getVisitorDec() != null ? finance.getVisitorDec() : 0);
|
|
|
+ monthlyVisitorDataRow.createCell(13).setCellValue(finance.getVisitorTotal() != null ? finance.getVisitorTotal() : 0);
|
|
|
+ monthlyVisitorDataRow.createCell(14).setCellValue(finance.getVisitorDiscount() != null ? finance.getVisitorDiscount() : 0);
|
|
|
+ monthlyVisitorDataRow.createCell(15).setCellValue(finance.getVisitorFree() != null ? finance.getVisitorFree() : 0);
|
|
|
+
|
|
|
+ // 免票占比(第16-19列合并)
|
|
|
+ Cell mvdFreeRate = monthlyVisitorDataRow.createCell(16);
|
|
|
+ mvdFreeRate.setCellValue(finance.getVisitorFreeRate() != null ? finance.getVisitorFreeRate().doubleValue() : 0);
|
|
|
+ mvdFreeRate.setCellStyle(dataStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 16, 19);
|
|
|
+
|
|
|
+ // 设置数据行样式
|
|
|
+ for (int i = 1; i <= 15; i++) {
|
|
|
+ if (monthlyVisitorDataRow.getCell(i) != null) {
|
|
|
+ monthlyVisitorDataRow.getCell(i).setCellStyle(dataStyle);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // ========== 第13行:备注说明 ==========
|
|
|
+ Row remarkRow = sheet.createRow(rowNum++);
|
|
|
+ remarkRow.setHeightInPoints(60);
|
|
|
+
|
|
|
+ // 创建左对齐、自动换行样式
|
|
|
+ CellStyle remarkStyle = workbook.createCellStyle();
|
|
|
+ remarkStyle.setAlignment(HorizontalAlignment.LEFT);
|
|
|
+ remarkStyle.setVerticalAlignment(VerticalAlignment.TOP);
|
|
|
+ remarkStyle.setWrapText(true);
|
|
|
+ remarkStyle.setBorderTop(BorderStyle.THIN);
|
|
|
+ remarkStyle.setBorderBottom(BorderStyle.THIN);
|
|
|
+ remarkStyle.setBorderLeft(BorderStyle.THIN);
|
|
|
+ remarkStyle.setBorderRight(BorderStyle.THIN);
|
|
|
+ XSSFFont remarkFont = workbook.createFont();
|
|
|
+ remarkFont.setFontName("宋体");
|
|
|
+ remarkFont.setFontHeightInPoints((short) 10);
|
|
|
+ remarkStyle.setFont(remarkFont);
|
|
|
+
|
|
|
+ // 三条备注合并在一个单元格中
|
|
|
+ Cell remarkCell = remarkRow.createCell(0);
|
|
|
+ remarkCell.setCellValue("备注:1、表格中'现行门票价格'指定价文件中的价格开始执行时间,非临时优惠价格执行时间;\n" +
|
|
|
+ " 2、景区面积填写'平方公里'或'平方米'、'亩';\n" +
|
|
|
+ " 3、税率指企业所得税税率。");
|
|
|
+ remarkCell.setCellStyle(remarkStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 0, 19);
|
|
|
+
|
|
|
+ // ========== 第14行:填表信息 ==========
|
|
|
+ Row fillInfoRow = sheet.createRow(rowNum++);
|
|
|
+ fillInfoRow.setHeightInPoints(20);
|
|
|
+
|
|
|
+ // 创建填表信息样式
|
|
|
+ CellStyle fillInfoStyle = workbook.createCellStyle();
|
|
|
+ fillInfoStyle.setAlignment(HorizontalAlignment.LEFT);
|
|
|
+ fillInfoStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
+ XSSFFont fillInfoFont = workbook.createFont();
|
|
|
+ fillInfoFont.setFontName("宋体");
|
|
|
+ fillInfoFont.setFontHeightInPoints((short) 10);
|
|
|
+ fillInfoStyle.setFont(fillInfoFont);
|
|
|
+
|
|
|
+ // 景区门票价格工作负责人标签(第0列)
|
|
|
+ Cell responsiblePersonLabel = fillInfoRow.createCell(0);
|
|
|
+ responsiblePersonLabel.setCellValue("景区门票价格工作负责人:");
|
|
|
+ responsiblePersonLabel.setCellStyle(fillInfoStyle);
|
|
|
+
|
|
|
+ // 景区门票价格工作负责人值(第1-9列合并,填充实际数据)
|
|
|
+ Cell responsiblePersonValue = fillInfoRow.createCell(1);
|
|
|
+ responsiblePersonValue.setCellValue(finance.getResponsiblePerson() != null ? finance.getResponsiblePerson() : "");
|
|
|
+ responsiblePersonValue.setCellStyle(dataStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 1, 9);
|
|
|
+
|
|
|
+ // 联系电话标签(第10列)
|
|
|
+ Cell contactPhoneLabel = fillInfoRow.createCell(10);
|
|
|
+ contactPhoneLabel.setCellValue("联系电话:");
|
|
|
+ contactPhoneLabel.setCellStyle(fillInfoStyle);
|
|
|
+
|
|
|
+ // 联系电话值(第11-19列合并,填充实际数据)
|
|
|
+ Cell contactPhoneValue = fillInfoRow.createCell(11);
|
|
|
+ contactPhoneValue.setCellValue(finance.getContactPhone() != null ? finance.getContactPhone() : "");
|
|
|
+ contactPhoneValue.setCellStyle(dataStyle);
|
|
|
+ addMergedRegionWithBorder(sheet, rowNum - 1, rowNum - 1, 11, 19);
|
|
|
+
|
|
|
+ // 设置列宽
|
|
|
+ for (int i = 0; i < 20; i++) {
|
|
|
+ sheet.setColumnWidth(i, 4000);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置响应头
|
|
|
+ String fileName = scenic.getScenicName() + "_" + finance.getYear() + "年价格信息统计表.xlsx";
|
|
|
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
+ response.setHeader("Content-Disposition", "attachment; filename=" +
|
|
|
+ new String(fileName.getBytes("UTF-8"), "ISO-8859-1"));
|
|
|
+
|
|
|
+ // 输出到响应流
|
|
|
+ workbook.write(response.getOutputStream());
|
|
|
+ workbook.close();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建标题样式
|
|
|
+ */
|
|
|
+ private CellStyle createTitleStyle(XSSFWorkbook workbook) {
|
|
|
+ CellStyle style = workbook.createCellStyle();
|
|
|
+ style.setAlignment(HorizontalAlignment.CENTER);
|
|
|
+ style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
+ // 添加边框
|
|
|
+ style.setBorderTop(BorderStyle.THIN);
|
|
|
+ style.setBorderBottom(BorderStyle.THIN);
|
|
|
+ style.setBorderLeft(BorderStyle.THIN);
|
|
|
+ style.setBorderRight(BorderStyle.THIN);
|
|
|
+ XSSFFont font = workbook.createFont();
|
|
|
+ font.setBold(true);
|
|
|
+ font.setFontHeightInPoints((short) 16);
|
|
|
+ style.setFont(font);
|
|
|
+ return style;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建表头样式
|
|
|
+ */
|
|
|
+ private CellStyle createHeaderStyle(XSSFWorkbook workbook) {
|
|
|
+ CellStyle style = workbook.createCellStyle();
|
|
|
+ style.setAlignment(HorizontalAlignment.CENTER);
|
|
|
+ style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
+ style.setBorderTop(BorderStyle.THIN);
|
|
|
+ style.setBorderBottom(BorderStyle.THIN);
|
|
|
+ style.setBorderLeft(BorderStyle.THIN);
|
|
|
+ style.setBorderRight(BorderStyle.THIN);
|
|
|
+ XSSFFont font = workbook.createFont();
|
|
|
+ font.setBold(true);
|
|
|
+ style.setFont(font);
|
|
|
+ return style;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 创建数据样式
|
|
|
+ */
|
|
|
+ private CellStyle createDataStyle(XSSFWorkbook workbook) {
|
|
|
+ CellStyle style = workbook.createCellStyle();
|
|
|
+ style.setAlignment(HorizontalAlignment.LEFT);
|
|
|
+ style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
+ style.setBorderTop(BorderStyle.THIN);
|
|
|
+ style.setBorderBottom(BorderStyle.THIN);
|
|
|
+ style.setBorderLeft(BorderStyle.THIN);
|
|
|
+ style.setBorderRight(BorderStyle.THIN);
|
|
|
+ return style;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建居中样式
|
|
|
+ */
|
|
|
+ private CellStyle createCenterStyle(XSSFWorkbook workbook) {
|
|
|
+ CellStyle style = workbook.createCellStyle();
|
|
|
+ style.setAlignment(HorizontalAlignment.CENTER);
|
|
|
+ style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
+ style.setBorderTop(BorderStyle.THIN);
|
|
|
+ style.setBorderBottom(BorderStyle.THIN);
|
|
|
+ style.setBorderLeft(BorderStyle.THIN);
|
|
|
+ style.setBorderRight(BorderStyle.THIN);
|
|
|
+ return style;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 为合并区域设置边框
|
|
|
+ */
|
|
|
+ private void setBorderForMergedRegion(CellRangeAddress region, XSSFSheet sheet) {
|
|
|
+ org.apache.poi.ss.util.RegionUtil.setBorderTop(BorderStyle.THIN, region, sheet);
|
|
|
+ org.apache.poi.ss.util.RegionUtil.setBorderBottom(BorderStyle.THIN, region, sheet);
|
|
|
+ org.apache.poi.ss.util.RegionUtil.setBorderLeft(BorderStyle.THIN, region, sheet);
|
|
|
+ org.apache.poi.ss.util.RegionUtil.setBorderRight(BorderStyle.THIN, region, sheet);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加合并区域并设置边框
|
|
|
+ */
|
|
|
+ private void addMergedRegionWithBorder(XSSFSheet sheet, int firstRow, int lastRow, int firstCol, int lastCol) {
|
|
|
+ CellRangeAddress region = new CellRangeAddress(firstRow, lastRow, firstCol, lastCol);
|
|
|
+ sheet.addMergedRegion(region);
|
|
|
+ setBorderForMergedRegion(region, sheet);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|