|
|
@ -3,16 +3,30 @@ package com.hnac.hzims.operational.access.service.impl; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.hnac.hzims.message.MessageConstants; |
|
|
|
import com.hnac.hzims.message.MessageConstants; |
|
|
|
import com.hnac.hzims.message.dto.BusinessMessageDTO; |
|
|
|
import com.hnac.hzims.message.dto.BusinessMessageDTO; |
|
|
|
import com.hnac.hzims.message.fegin.IMessageClient; |
|
|
|
import com.hnac.hzims.message.fegin.IMessageClient; |
|
|
|
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; |
|
|
|
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.access.constants.AccessConstants; |
|
|
|
import com.hnac.hzims.operational.access.dto.*; |
|
|
|
import com.hnac.hzims.operational.access.dto.*; |
|
|
|
import com.hnac.hzims.operational.access.entity.*; |
|
|
|
import com.hnac.hzims.operational.access.entity.*; |
|
|
|
import com.hnac.hzims.operational.access.service.*; |
|
|
|
import com.hnac.hzims.operational.access.service.*; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.access.vo.AccessExportVo; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.access.vo.AccessTaskExportVo; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.access.vo.OperAccessPlanVO; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.access.wrapper.OperAccessPlanWrapper; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.RandomUtils; |
|
|
|
import org.apache.commons.lang3.RandomUtils; |
|
|
|
|
|
|
|
import org.apache.poi.hssf.usermodel.*; |
|
|
|
|
|
|
|
import org.apache.poi.hssf.util.HSSFColor; |
|
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.BorderStyle; |
|
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.FillPatternType; |
|
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.HorizontalAlignment; |
|
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.VerticalAlignment; |
|
|
|
|
|
|
|
import org.apache.poi.ss.util.CellRangeAddress; |
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
@ -30,12 +44,21 @@ import org.springblade.system.user.feign.IUserClient; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import org.springframework.web.context.request.RequestContextHolder; |
|
|
|
|
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.ServletOutputStream; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.text.DecimalFormat; |
|
|
|
import java.text.DecimalFormat; |
|
|
|
import java.time.Duration; |
|
|
|
import java.time.Duration; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.*; |
|
|
|
import java.util.Arrays; |
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -48,6 +71,8 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ |
|
|
|
|
|
|
|
|
|
|
|
private final IOperAccessPlanService planService; |
|
|
|
private final IOperAccessPlanService planService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final IOperAccessTaskService taskService; |
|
|
|
|
|
|
|
|
|
|
|
private final IOperAccessMaterialService materialService; |
|
|
|
private final IOperAccessMaterialService materialService; |
|
|
|
|
|
|
|
|
|
|
|
private final IOperAccessContentService contentService; |
|
|
|
private final IOperAccessContentService contentService; |
|
|
@ -222,6 +247,7 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 开启检修任务 |
|
|
|
* 开启检修任务 |
|
|
|
* @param entity |
|
|
|
* @param entity |
|
|
@ -296,4 +322,259 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ |
|
|
|
message.setUserIds(userId); |
|
|
|
message.setUserIds(userId); |
|
|
|
messageClient.sendAppAndWsMsgByUsers(message); |
|
|
|
messageClient.sendAppAndWsMsgByUsers(message); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 检修计划分页查询 |
|
|
|
|
|
|
|
* @param page |
|
|
|
|
|
|
|
* @param param |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public IPage<OperAccessPlanVO> pages(IPage<OperAccessPlanEntity> page, OperAccessPlanListDTO param) { |
|
|
|
|
|
|
|
QueryWrapper<OperAccessPlanEntity> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
|
|
|
queryWrapper.lambda().orderByDesc(OperAccessPlanEntity::getCreateTime); |
|
|
|
|
|
|
|
if(ObjectUtil.isNotEmpty(param.getStartTime())){ |
|
|
|
|
|
|
|
queryWrapper.lambda().ge(OperAccessPlanEntity::getActStartTime,param.getStartTime()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(ObjectUtil.isNotEmpty(param.getEndTime())){ |
|
|
|
|
|
|
|
queryWrapper.lambda().le(OperAccessPlanEntity::getActStartTime,param.getEndTime()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(ObjectUtil.isNotEmpty(param.getName())){ |
|
|
|
|
|
|
|
queryWrapper.lambda().like(OperAccessPlanEntity::getName,param.getName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(ObjectUtil.isNotEmpty(param.getGradeCode())){ |
|
|
|
|
|
|
|
String[] gradeCodes = param.getGradeCode().split(","); |
|
|
|
|
|
|
|
queryWrapper.lambda().in(OperAccessPlanEntity::getGradeCode,Arrays.asList(gradeCodes)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(ObjectUtil.isNotEmpty(param.getProcessStep())){ |
|
|
|
|
|
|
|
if(AccessConstants.PROCESS_STEP_COMPLETE.equals(param.getProcessStep())){ |
|
|
|
|
|
|
|
queryWrapper.lambda().eq(OperAccessPlanEntity::getTaskName,"流程结束"); |
|
|
|
|
|
|
|
}else if(AccessConstants.PROCESS_STEP_INCOMPLETE.equals(param.getProcessStep())){ |
|
|
|
|
|
|
|
queryWrapper.lambda().ne(OperAccessPlanEntity::getTaskName,"流程结束"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
IPage pages = this.planService.page(page,queryWrapper); |
|
|
|
|
|
|
|
pages.setRecords(OperAccessPlanWrapper.build().listVO(pages.getRecords())); |
|
|
|
|
|
|
|
return pages; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 检修任务导出 |
|
|
|
|
|
|
|
* @param id |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void export(Long id) { |
|
|
|
|
|
|
|
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); |
|
|
|
|
|
|
|
HttpServletResponse response = servletRequestAttributes.getResponse(); |
|
|
|
|
|
|
|
// 查询检修计划内容
|
|
|
|
|
|
|
|
AccessExportVo access = this.accessExport(id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建Excel文件
|
|
|
|
|
|
|
|
HSSFWorkbook hssWB = new HSSFWorkbook(); |
|
|
|
|
|
|
|
// 添加sheet页
|
|
|
|
|
|
|
|
HSSFSheet sheet = hssWB.createSheet(access.getPlanName()); |
|
|
|
|
|
|
|
// 行高
|
|
|
|
|
|
|
|
sheet.setDefaultRowHeight((short) (20 * 25)); |
|
|
|
|
|
|
|
// 列宽
|
|
|
|
|
|
|
|
sheet.setDefaultColumnWidth(20); |
|
|
|
|
|
|
|
this.setFirstHeader(hssWB, sheet,access.getPlanName()); |
|
|
|
|
|
|
|
// 第二行/三行 表头格式设置
|
|
|
|
|
|
|
|
this.setWorkHeader(hssWB, sheet); |
|
|
|
|
|
|
|
if (!CollectionUtil.isEmpty(access.getTasks())) { |
|
|
|
|
|
|
|
// 数据填充
|
|
|
|
|
|
|
|
this.setWorkData(hssWB, sheet, access.getTasks()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 下载导出
|
|
|
|
|
|
|
|
String filename = access.getPlanName(); |
|
|
|
|
|
|
|
// 设置头信息
|
|
|
|
|
|
|
|
response.setCharacterEncoding("UTF-8"); |
|
|
|
|
|
|
|
response.setContentType("application/vnd.ms-excel"); |
|
|
|
|
|
|
|
ServletOutputStream outputStream; |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
//设置xlsx格式
|
|
|
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename + ".xls", "UTF-8")); |
|
|
|
|
|
|
|
//创建一个输出流
|
|
|
|
|
|
|
|
outputStream = response.getOutputStream(); |
|
|
|
|
|
|
|
//写入数据
|
|
|
|
|
|
|
|
hssWB.write(outputStream); |
|
|
|
|
|
|
|
// 关闭
|
|
|
|
|
|
|
|
outputStream.close(); |
|
|
|
|
|
|
|
hssWB.close(); |
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 查询检修任务导出数据 |
|
|
|
|
|
|
|
* @param id |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private AccessExportVo accessExport(Long id) { |
|
|
|
|
|
|
|
// 检修计划查询
|
|
|
|
|
|
|
|
OperAccessPlanEntity plan = this.planService.getById(id); |
|
|
|
|
|
|
|
AccessExportVo access = new AccessExportVo(); |
|
|
|
|
|
|
|
access.setPlanName(plan.getName()); |
|
|
|
|
|
|
|
access.setTasks(this.taskService.accessTasks(id)); |
|
|
|
|
|
|
|
return access; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 设置表头 |
|
|
|
|
|
|
|
* @param hssWB |
|
|
|
|
|
|
|
* @param sheet |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void setFirstHeader(HSSFWorkbook hssWB, HSSFSheet sheet,String planName) { |
|
|
|
|
|
|
|
// 第一行
|
|
|
|
|
|
|
|
HSSFRow fisrtRow = sheet.createRow(0); |
|
|
|
|
|
|
|
this.setTitileStyle(hssWB, fisrtRow, 7, true); |
|
|
|
|
|
|
|
// 第一个单元格
|
|
|
|
|
|
|
|
HSSFCell headCell = fisrtRow.getCell(0); |
|
|
|
|
|
|
|
headCell.setCellValue(planName); |
|
|
|
|
|
|
|
// 首行合并情况
|
|
|
|
|
|
|
|
CellRangeAddress region1 = new CellRangeAddress(0, 0, (short) 0, (short) 7); |
|
|
|
|
|
|
|
sheet.addMergedRegion(region1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 第一行条目名称设置 |
|
|
|
|
|
|
|
* @param hssWB |
|
|
|
|
|
|
|
* @param sheet |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void setWorkHeader(HSSFWorkbook hssWB, HSSFSheet sheet) { |
|
|
|
|
|
|
|
// 创建行
|
|
|
|
|
|
|
|
HSSFRow row_1 = sheet.createRow(1); |
|
|
|
|
|
|
|
this.setTitileStyle(hssWB, row_1, 7, true); |
|
|
|
|
|
|
|
// 第一行
|
|
|
|
|
|
|
|
HSSFCell header_row_1_cell_1 = row_1.getCell(0); |
|
|
|
|
|
|
|
header_row_1_cell_1.setCellValue("序号"); |
|
|
|
|
|
|
|
HSSFCell header_row_1_cell_2 = row_1.getCell(1); |
|
|
|
|
|
|
|
header_row_1_cell_2.setCellValue("设备名称"); |
|
|
|
|
|
|
|
HSSFCell header_row_1_cell_3 = row_1.getCell(2); |
|
|
|
|
|
|
|
header_row_1_cell_3.setCellValue("计划开始时间"); |
|
|
|
|
|
|
|
HSSFCell header_row_1_cell_4 = row_1.getCell(3); |
|
|
|
|
|
|
|
header_row_1_cell_4.setCellValue("计划结束时间"); |
|
|
|
|
|
|
|
HSSFCell header_row_1_cell_5 = row_1.getCell(4); |
|
|
|
|
|
|
|
header_row_1_cell_5.setCellValue("计划工时"); |
|
|
|
|
|
|
|
HSSFCell header_row_1_cell_6 = row_1.getCell(5); |
|
|
|
|
|
|
|
header_row_1_cell_6.setCellValue("检修项目"); |
|
|
|
|
|
|
|
HSSFCell header_row_1_cell_7 = row_1.getCell(6); |
|
|
|
|
|
|
|
header_row_1_cell_7.setCellValue("检修内容"); |
|
|
|
|
|
|
|
HSSFCell header_row_1_cell_8 = row_1.getCell(7); |
|
|
|
|
|
|
|
header_row_1_cell_8.setCellValue("检修负责人"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 内容填充 |
|
|
|
|
|
|
|
* @param hssWB |
|
|
|
|
|
|
|
* @param sheet |
|
|
|
|
|
|
|
* @param tasks |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void setWorkData(HSSFWorkbook hssWB, HSSFSheet sheet, List<AccessTaskExportVo> tasks) { |
|
|
|
|
|
|
|
int size = tasks.size(); |
|
|
|
|
|
|
|
int row = 2; |
|
|
|
|
|
|
|
for (int i = 0; i < size; i++) { |
|
|
|
|
|
|
|
AccessTaskExportVo task = tasks.get(i); |
|
|
|
|
|
|
|
List<OperAccessTaskDetailEntity> details = tasks.get(i).getDetails(); |
|
|
|
|
|
|
|
int detail_size = details.size(); |
|
|
|
|
|
|
|
for (int j = 0; j < detail_size ; j++){ |
|
|
|
|
|
|
|
HSSFRow detail_row = sheet.createRow(row + j); |
|
|
|
|
|
|
|
this.setTitileStyle(hssWB, detail_row, 7, false); |
|
|
|
|
|
|
|
if(j == 0){ |
|
|
|
|
|
|
|
// 序号
|
|
|
|
|
|
|
|
HSSFCell header_row_cell_0 = detail_row.getCell(0); |
|
|
|
|
|
|
|
header_row_cell_0.setCellValue(i + 1); |
|
|
|
|
|
|
|
// 设备名称
|
|
|
|
|
|
|
|
HSSFCell header_row_cell_1 = detail_row.getCell(1); |
|
|
|
|
|
|
|
header_row_cell_1.setCellValue(task.getEmName()); |
|
|
|
|
|
|
|
// 计划开始时间
|
|
|
|
|
|
|
|
HSSFCell header_row_cell_2 = detail_row.getCell(2); |
|
|
|
|
|
|
|
header_row_cell_2.setCellValue(DateUtil.format(task.getPlanStartTime(),DateUtil.PATTERN_DATETIME)); |
|
|
|
|
|
|
|
// 计划结束时间
|
|
|
|
|
|
|
|
HSSFCell header_row_cell_3 = detail_row.getCell(3); |
|
|
|
|
|
|
|
header_row_cell_3.setCellValue(DateUtil.format(task.getPlanEndTime(),DateUtil.PATTERN_DATETIME)); |
|
|
|
|
|
|
|
// 计划工时
|
|
|
|
|
|
|
|
HSSFCell header_row_cell_4 = detail_row.getCell(4); |
|
|
|
|
|
|
|
header_row_cell_4.setCellValue(task.getPlanHours()); |
|
|
|
|
|
|
|
// 检修负责人
|
|
|
|
|
|
|
|
HSSFCell header_row_cell_7 = detail_row.getCell(7); |
|
|
|
|
|
|
|
header_row_cell_7.setCellValue(task.getHeadName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 检修项目
|
|
|
|
|
|
|
|
HSSFCell header_row_cell_5 = detail_row.getCell(5); |
|
|
|
|
|
|
|
header_row_cell_5.setCellValue(details.get(j).getName()); |
|
|
|
|
|
|
|
// 检修内容
|
|
|
|
|
|
|
|
HSSFCell header_row_cell_6 = detail_row.getCell(6); |
|
|
|
|
|
|
|
header_row_cell_6.setCellValue(details.get(j).getContent()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
CellRangeAddress header_region_0 = new CellRangeAddress((short) row, (short) row + detail_size - 1, (short) 0, (short) 0); |
|
|
|
|
|
|
|
CellRangeAddress header_region_1 = new CellRangeAddress((short) row, (short) row + detail_size - 1, (short) 1, (short) 1); |
|
|
|
|
|
|
|
CellRangeAddress header_region_2 = new CellRangeAddress((short) row, (short) row + detail_size - 1, (short) 2, (short) 2); |
|
|
|
|
|
|
|
CellRangeAddress header_region_3 = new CellRangeAddress((short) row, (short) row + detail_size - 1, (short) 3, (short) 3); |
|
|
|
|
|
|
|
CellRangeAddress header_region_4 = new CellRangeAddress((short) row,(short) row + detail_size - 1, (short) 4, (short) 4); |
|
|
|
|
|
|
|
CellRangeAddress header_region_7 = new CellRangeAddress((short) row, (short) row + detail_size - 1, (short) 7, (short) 7); |
|
|
|
|
|
|
|
sheet.addMergedRegion(header_region_0); |
|
|
|
|
|
|
|
sheet.addMergedRegion(header_region_1); |
|
|
|
|
|
|
|
sheet.addMergedRegion(header_region_2); |
|
|
|
|
|
|
|
sheet.addMergedRegion(header_region_3); |
|
|
|
|
|
|
|
sheet.addMergedRegion(header_region_4); |
|
|
|
|
|
|
|
sheet.addMergedRegion(header_region_7); |
|
|
|
|
|
|
|
// 累计合并结束行号
|
|
|
|
|
|
|
|
row += detail_size; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 设置Titile单元格样式 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param hssWB |
|
|
|
|
|
|
|
* @param row |
|
|
|
|
|
|
|
* @param len |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void setTitileStyle(HSSFWorkbook hssWB, HSSFRow row, int len, boolean isHead) { |
|
|
|
|
|
|
|
HSSFCellStyle cellStyle = getHeadStyle(hssWB, isHead); |
|
|
|
|
|
|
|
for (int i = 0; i <= len; i++) { |
|
|
|
|
|
|
|
HSSFCell hssfcell = row.createCell(i); |
|
|
|
|
|
|
|
hssfcell.setCellStyle(cellStyle); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取表头样式 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param hssWB |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private HSSFCellStyle getHeadStyle(HSSFWorkbook hssWB, boolean isHead) { |
|
|
|
|
|
|
|
HSSFCellStyle headStyle = hssWB.createCellStyle(); |
|
|
|
|
|
|
|
//边框
|
|
|
|
|
|
|
|
headStyle.setBorderLeft(BorderStyle.THIN); |
|
|
|
|
|
|
|
headStyle.setBorderRight(BorderStyle.THIN); |
|
|
|
|
|
|
|
headStyle.setBorderTop(BorderStyle.THIN); |
|
|
|
|
|
|
|
headStyle.setBorderBottom(BorderStyle.THIN); |
|
|
|
|
|
|
|
//居中:
|
|
|
|
|
|
|
|
headStyle.setAlignment(HorizontalAlignment.CENTER); // 居中
|
|
|
|
|
|
|
|
headStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 垂直居中
|
|
|
|
|
|
|
|
//字体:
|
|
|
|
|
|
|
|
HSSFFont font = hssWB.createFont(); |
|
|
|
|
|
|
|
font.setFontName("黑体"); |
|
|
|
|
|
|
|
if (isHead) { |
|
|
|
|
|
|
|
//设置字体大小
|
|
|
|
|
|
|
|
font.setFontHeightInPoints((short) 12); |
|
|
|
|
|
|
|
//背景颜色
|
|
|
|
|
|
|
|
headStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); |
|
|
|
|
|
|
|
headStyle.setFillForegroundColor(HSSFColor.SKY_BLUE.index); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
//设置字体大小
|
|
|
|
|
|
|
|
font.setFontHeightInPoints((short) 8); |
|
|
|
|
|
|
|
//背景颜色
|
|
|
|
|
|
|
|
headStyle.setFillPattern(FillPatternType.NO_FILL); |
|
|
|
|
|
|
|
headStyle.setFillForegroundColor(HSSFColor.WHITE.index); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//字体格式
|
|
|
|
|
|
|
|
headStyle.setFont(font); |
|
|
|
|
|
|
|
return headStyle; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |