parent
1045837bd7
commit
bb59628452
@ -0,0 +1,51 @@
|
|||||||
|
package org.dromara.oa.erp.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xins
|
||||||
|
* @description erp_rd_budget_travel_cost类型枚举
|
||||||
|
* @date 2025/12/11 13:58
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum TripTypeEnum {
|
||||||
|
/**
|
||||||
|
* 差旅费
|
||||||
|
*/
|
||||||
|
TRAVEL("1", "差旅费"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 交通费
|
||||||
|
*/
|
||||||
|
TRANSPORTATION("2", "交通费");
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编码
|
||||||
|
*/
|
||||||
|
private final String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 名称
|
||||||
|
*/
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
|
||||||
|
TripTypeEnum(String code, String name) {
|
||||||
|
this.code = code;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据流程编码获取配置
|
||||||
|
*/
|
||||||
|
public static TripTypeEnum getByCode(String code) {
|
||||||
|
for (TripTypeEnum config : values()) {
|
||||||
|
if (config.getCode().equals(code)) {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,309 @@
|
|||||||
|
package org.dromara.oa.excel;
|
||||||
|
import org.apache.poi.ss.usermodel.*;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFFont;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author xins
|
||||||
|
* @Date 2025/12/29 15:25
|
||||||
|
* @Description:Excel样式构建器
|
||||||
|
* * 简化样式创建和管理
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ExcelStyleBuilder {
|
||||||
|
|
||||||
|
private final Workbook workbook;
|
||||||
|
private final Map<String, CellStyle> styleCache = new HashMap<>();
|
||||||
|
|
||||||
|
// 常用字体名称
|
||||||
|
private static final String FONT_SONG = "宋体";
|
||||||
|
private static final String FONT_YA_HEI = "微软雅黑";
|
||||||
|
|
||||||
|
public ExcelStyleBuilder(Workbook workbook) {
|
||||||
|
this.workbook = workbook;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建基础样式构建器
|
||||||
|
*/
|
||||||
|
public StyleBuilder base() {
|
||||||
|
return new StyleBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取缓存的样式
|
||||||
|
*/
|
||||||
|
public CellStyle getStyle(String key) {
|
||||||
|
return styleCache.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取或创建样式
|
||||||
|
*/
|
||||||
|
public CellStyle getOrCreate(String key, Consumer<StyleBuilder> styleConfig) {
|
||||||
|
if (styleCache.containsKey(key)) {
|
||||||
|
return styleCache.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
StyleBuilder builder = new StyleBuilder();
|
||||||
|
styleConfig.accept(builder);
|
||||||
|
CellStyle style = builder.build();
|
||||||
|
styleCache.put(key, style);
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建字体
|
||||||
|
*/
|
||||||
|
public Font createFont(Consumer<Font> fontConfig) {
|
||||||
|
Font font = workbook.createFont();
|
||||||
|
fontConfig.accept(font);
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 样式构建器内部类
|
||||||
|
*/
|
||||||
|
public class StyleBuilder {
|
||||||
|
private CellStyle style;
|
||||||
|
private Font font;
|
||||||
|
|
||||||
|
public StyleBuilder() {
|
||||||
|
this.style = workbook.createCellStyle();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置字体
|
||||||
|
*/
|
||||||
|
public StyleBuilder font(String fontName, short fontSize, boolean bold) {
|
||||||
|
this.font = createFont(f -> {
|
||||||
|
f.setFontName(fontName);
|
||||||
|
f.setFontHeightInPoints(fontSize);
|
||||||
|
f.setBold(bold);
|
||||||
|
});
|
||||||
|
style.setFont(font);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置宋体字体
|
||||||
|
*/
|
||||||
|
public StyleBuilder song(short fontSize, boolean bold) {
|
||||||
|
return font(FONT_SONG, fontSize, bold);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置微软雅黑字体
|
||||||
|
*/
|
||||||
|
public StyleBuilder yaHei(short fontSize, boolean bold) {
|
||||||
|
return font(FONT_YA_HEI, fontSize, bold);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置颜色
|
||||||
|
*/
|
||||||
|
public StyleBuilder fontColor(IndexedColors color) {
|
||||||
|
if (font == null) {
|
||||||
|
yaHei((short) 10, false);
|
||||||
|
}
|
||||||
|
font.setColor(color.getIndex());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置背景色
|
||||||
|
*/
|
||||||
|
public StyleBuilder bgColor(IndexedColors color) {
|
||||||
|
style.setFillForegroundColor(color.getIndex());
|
||||||
|
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置对齐方式
|
||||||
|
*/
|
||||||
|
public StyleBuilder align(HorizontalAlignment horizontal, VerticalAlignment vertical) {
|
||||||
|
style.setAlignment(horizontal);
|
||||||
|
style.setVerticalAlignment(vertical);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置居中
|
||||||
|
*/
|
||||||
|
public StyleBuilder center() {
|
||||||
|
return align(HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置左对齐
|
||||||
|
*/
|
||||||
|
public StyleBuilder left() {
|
||||||
|
return align(HorizontalAlignment.LEFT, VerticalAlignment.CENTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置右对齐
|
||||||
|
*/
|
||||||
|
public StyleBuilder right() {
|
||||||
|
return align(HorizontalAlignment.RIGHT, VerticalAlignment.CENTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置边框
|
||||||
|
*/
|
||||||
|
public StyleBuilder border(BorderStyle borderStyle) {
|
||||||
|
style.setBorderTop(borderStyle);
|
||||||
|
style.setBorderBottom(borderStyle);
|
||||||
|
style.setBorderLeft(borderStyle);
|
||||||
|
style.setBorderRight(borderStyle);
|
||||||
|
|
||||||
|
short color = IndexedColors.BLACK.getIndex();
|
||||||
|
style.setTopBorderColor(color);
|
||||||
|
style.setBottomBorderColor(color);
|
||||||
|
style.setLeftBorderColor(color);
|
||||||
|
style.setRightBorderColor(color);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置自定义边框
|
||||||
|
*/
|
||||||
|
public StyleBuilder border(BorderStyle top, BorderStyle bottom,
|
||||||
|
BorderStyle left, BorderStyle right) {
|
||||||
|
style.setBorderTop(top);
|
||||||
|
style.setBorderBottom(bottom);
|
||||||
|
style.setBorderLeft(left);
|
||||||
|
style.setBorderRight(right);
|
||||||
|
|
||||||
|
short color = IndexedColors.BLACK.getIndex();
|
||||||
|
style.setTopBorderColor(color);
|
||||||
|
style.setBottomBorderColor(color);
|
||||||
|
style.setLeftBorderColor(color);
|
||||||
|
style.setRightBorderColor(color);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置底部边框
|
||||||
|
*/
|
||||||
|
public StyleBuilder bottomBorder(BorderStyle borderStyle) {
|
||||||
|
style.setBorderBottom(borderStyle);
|
||||||
|
style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置数据格式
|
||||||
|
*/
|
||||||
|
public StyleBuilder dataFormat(String format) {
|
||||||
|
DataFormat dataFormat = workbook.createDataFormat();
|
||||||
|
style.setDataFormat(dataFormat.getFormat(format));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置数字格式
|
||||||
|
*/
|
||||||
|
public StyleBuilder numberFormat() {
|
||||||
|
return dataFormat("0.00");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置百分比格式
|
||||||
|
*/
|
||||||
|
public StyleBuilder percentFormat() {
|
||||||
|
return dataFormat("0.00%");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置货币格式
|
||||||
|
*/
|
||||||
|
public StyleBuilder moneyFormat() {
|
||||||
|
return dataFormat("#,##0.00");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置自动换行
|
||||||
|
*/
|
||||||
|
public StyleBuilder wrapText(boolean wrap) {
|
||||||
|
style.setWrapText(wrap);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 克隆样式并自定义
|
||||||
|
*/
|
||||||
|
public StyleBuilder clone(CellStyle source, Consumer<StyleBuilder> customizer) {
|
||||||
|
this.style.cloneStyleFrom(source);
|
||||||
|
customizer.accept(this);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建样式
|
||||||
|
*/
|
||||||
|
public CellStyle build() {
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建并缓存
|
||||||
|
*/
|
||||||
|
public CellStyle buildAndCache(String key) {
|
||||||
|
CellStyle builtStyle = build();
|
||||||
|
styleCache.put(key, builtStyle);
|
||||||
|
return builtStyle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 常用样式键常量
|
||||||
|
*/
|
||||||
|
public static class Keys {
|
||||||
|
// 标题样式
|
||||||
|
public static final String TITLE = "title";
|
||||||
|
public static final String SUBTITLE = "subtitle";
|
||||||
|
|
||||||
|
// 表单样式
|
||||||
|
public static final String FORM_LEFT = "form_left";
|
||||||
|
public static final String FORM_RIGHT = "form_right";
|
||||||
|
public static final String FORM_FORMULA = "form_formula";
|
||||||
|
public static final String FORM_PERCENT = "form_percent";
|
||||||
|
|
||||||
|
// 表头样式
|
||||||
|
public static final String HEADER = "header";
|
||||||
|
public static final String MERGED_HEADER = "merged_header";
|
||||||
|
|
||||||
|
// 数据样式
|
||||||
|
public static final String DATA = "data";
|
||||||
|
public static final String DATA_LEFT = "data_left";
|
||||||
|
public static final String DATA_RIGHT = "data_right";
|
||||||
|
public static final String DATA_BOTTOM = "data_bottom";
|
||||||
|
public static final String DATA_CENTER = "data_center";
|
||||||
|
|
||||||
|
// 特殊格式
|
||||||
|
public static final String PERCENT = "percent";
|
||||||
|
public static final String FORMULA = "formula";
|
||||||
|
public static final String MONEY = "money";
|
||||||
|
public static final String FOOTER_FORMULA = "footer_formula";
|
||||||
|
|
||||||
|
// 备注样式
|
||||||
|
public static final String REMARK = "remark";
|
||||||
|
|
||||||
|
// 合并单元格样式
|
||||||
|
public static final String LEFT_MERGE = "left_merge";
|
||||||
|
|
||||||
|
// 研发预算相关
|
||||||
|
public static final String RD_COVER_TITLE = "rd_cover_title";
|
||||||
|
public static final String RD_COVER_SUBTITLE = "rd_cover_subtitle";
|
||||||
|
public static final String RD_HEADER = "rd_header";
|
||||||
|
public static final String RD_DATA = "rd_data";
|
||||||
|
public static final String RD_DATA_BOLD = "rd_data_bold";
|
||||||
|
public static final String RD_DATA_RED = "rd_data_red";
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,55 @@
|
|||||||
|
package org.dromara.oa.excel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author xins
|
||||||
|
* @Date 2025/12/30 17:21
|
||||||
|
* @Description: 研发预算汇总表枚举
|
||||||
|
*/
|
||||||
|
public enum RdBudgetItemEnums {
|
||||||
|
MATERIAL("材料费", "表2-材料费", "表2-材料费", "H"),
|
||||||
|
LABOR("人工费", "表3-人工费", "表3-人工费", "H"),
|
||||||
|
TRAVEL("差旅费", "表4-差旅费", "表4-差旅费", "M"),
|
||||||
|
TESTING("测试化验加工费", "表5-测试化验加工费","表5-测试化验加工费", "H"),
|
||||||
|
CONSULTATION("专家咨询费用", "表6-咨询费、设计费","专家费", "I"),
|
||||||
|
DESIGN("新产品设计费", "表6-咨询费、设计费", "新产品设计费", "H"),
|
||||||
|
OTHER("其他费用", "表7-其他费用", "表7-其他费用","D");
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
private final String sheetName;
|
||||||
|
private final String childSheetName;
|
||||||
|
private final String sheetPosition;
|
||||||
|
|
||||||
|
RdBudgetItemEnums(String name, String sheetName, String childSheetName, String sheetPosition) {
|
||||||
|
this.name = name;
|
||||||
|
this.sheetName = sheetName;
|
||||||
|
this.childSheetName = childSheetName;
|
||||||
|
this.sheetPosition = sheetPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取所有项目名称
|
||||||
|
public static String[] getAllItemNames() {
|
||||||
|
RdBudgetItemEnums[] items = values();
|
||||||
|
String[] names = new String[items.length];
|
||||||
|
for (int i = 0; i < items.length; i++) {
|
||||||
|
names[i] = items[i].getName();
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
|
// getter 方法
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSheetName() {
|
||||||
|
return sheetName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChildSheetName() {
|
||||||
|
return childSheetName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSheetPosition() {
|
||||||
|
return sheetPosition;
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue