package com.ruoyi.cwgl.domain; import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.annotation.Excel; import com.baomidou.mybatisplus.annotation.TableField; import com.ruoyi.cwgl.enums.AccountingItemEnum; import java.util.Date; import java.util.ArrayList; import java.util.List; import lombok.Data; /** * 凭证科目设置对象 voucher_subject_setting * * @author ruoyi * @date 2026-01-19 */ @Data public class VoucherSubjectSetting{ /** 科目ID */ @TableField("id") private Integer id; /** 父科目ID */ @Excel(name = "父科目ID") @TableField("parent_id") private Integer parentId; /** 上级科目代码 */ @Excel(name = "上级科目代码") @TableField("parent_subject_code") private String parentSubjectCode; /** 上级科目名称 */ @Excel(name = "上级科目名称") @TableField("parent_subject_name") private String parentSubjectName; /** 祖级列表 */ @Excel(name = "祖级列表") @TableField("ancestors") private String ancestors; /** 账套 */ @Excel(name = "账套") @TableField("account_set") private String accountSet; /** 科目代码 */ @Excel(name = "科目代码") @TableField("subject_code") private String subjectCode; /** 科目名称 */ @Excel(name = "科目名称") @TableField("subject_name") private String subjectName; /** 科目类别 */ @Excel(name = "科目类别") @TableField("subject_type") private String subjectType; /** 启用(1启用 0停用) */ @Excel(name = "启用", readConverterExp = "1=启用,0=停用") @TableField("enabled") private String enabled; /** 余额方向(借/贷) */ @Excel(name = "余额方向", readConverterExp = "借=/贷") @TableField("balance_direction") private String balanceDirection; /** 核算项目(位运算值) */ @Excel(name = "核算项目") @TableField("accounting_items") private Integer accountingItems; /** 往来单位(0否 1是) */ @Excel(name = "往来单位", readConverterExp = "0=否,1=是") @TableField("contact_unit") private String contactUnit; /** 部门(0否 1是) */ @Excel(name = "部门", readConverterExp = "0=否,1=是") @TableField("department") private String department; /** 品名(0否 1是) */ @Excel(name = "品名", readConverterExp = "0=否,1=是") @TableField("product_name") private String productName; /** 数量金额核算(1是 0否) */ @Excel(name = "数量金额核算", readConverterExp = "1=是,0=否") @TableField("quantity_amount_accounting") private String quantityAmountAccounting; /** 现金科目(1是 0否) */ @Excel(name = "现金科目", readConverterExp = "1=是,0=否") @TableField("cash_subject") private String cashSubject; /** 银行科目(1是 0否) */ @Excel(name = "银行科目", readConverterExp = "1=是,0=否") @TableField("bank_subject") private String bankSubject; /** 现金流量科目(1是 0否) */ @Excel(name = "现金流量科目", readConverterExp = "1=是,0=否") @TableField("cash_flow_subject") private String cashFlowSubject; /** 费用名称 */ @Excel(name = "费用名称") @TableField("expense_name") private String expenseName; /** 助记码 */ @Excel(name = "助记码") @TableField("mnemonic_code") private String mnemonicCode; /** 外币核算(1是 0否) */ @Excel(name = "外币核算", readConverterExp = "1=是,0=否") @TableField("foreign_currency_accounting") private String foreignCurrencyAccounting; /** 计量单位 */ @Excel(name = "计量单位") @TableField("unit_of_measurement") private String unitOfMeasurement; /** 显示顺序 */ @Excel(name = "显示顺序") @TableField("order_num") private Integer orderNum; /** 状态(0正常 1停用) */ @Excel(name = "状态", readConverterExp = "0=正常,1=停用") @TableField("status") private String status; /** 删除标志(0代表存在 2代表删除) */ @TableField("del_flag") private String delFlag; /** 创建者 */ @TableField("create_by") private String createBy; /** 创建时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @TableField("create_time") private Date createTime; /** 更新者 */ @TableField("update_by") private String updateBy; /** 更新时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @TableField("update_time") private Date updateTime; /** 备注 */ @Excel(name = "备注") @TableField("remark") private String remark; /** 帐套类型(0珠海汇畅,1广珠物流) */ @Excel(name = "帐套类型", readConverterExp = "0=珠海汇畅,1广珠物流") @TableField("type") private String type; /** 核算项目描述(非数据库字段) */ @TableField(exist = false) private String accountingItemsDesc; /** 核算项目列表(非数据库字段) */ @TableField(exist = false) private List accountingItemList; /** 核算项目包含查询(非数据库字段) */ @TableField(exist = false) private Integer accountingItemsContains; /** 核算项目任意包含查询(非数据库字段) */ @TableField(exist = false) private Integer accountingItemsAny; /** * 获取核算项目的描述字符串 */ public String getAccountingItemsDesc() { if (accountingItems == null) { return ""; } return AccountingItemEnum.getDescriptions(accountingItems); } /** * 设置核算项目描述字符串 */ public void setAccountingItemsDesc(String accountingItemsDesc) { this.accountingItemsDesc = accountingItemsDesc; if (accountingItemsDesc != null && !accountingItemsDesc.trim().isEmpty()) { this.accountingItems = AccountingItemEnum.getValueByDescriptions(accountingItemsDesc); } } /** * 获取核算项目列表 */ public List getAccountingItemList() { if (accountingItems == null) { return new ArrayList<>(); } List list = new ArrayList<>(); for (AccountingItemEnum item : AccountingItemEnum.values()) { if (AccountingItemEnum.contains(accountingItems, item)) { list.add(item.getDescription()); } } return list; } /** * 设置核算项目列表 */ public void setAccountingItemList(List accountingItemList) { this.accountingItemList = accountingItemList; if (accountingItemList != null && !accountingItemList.isEmpty()) { int value = 0; for (String desc : accountingItemList) { for (AccountingItemEnum item : AccountingItemEnum.values()) { if (item.getDescription().equals(desc.trim())) { value = AccountingItemEnum.addItem(value, item); break; } } } this.accountingItems = value; } } /** * 检查是否包含某个核算项目 */ public boolean containsAccountingItem(AccountingItemEnum item) { if (accountingItems == null) { return false; } return AccountingItemEnum.contains(accountingItems, item); } /** * 添加核算项目 */ public void addAccountingItem(AccountingItemEnum item) { if (accountingItems == null) { accountingItems = 0; } accountingItems = AccountingItemEnum.addItem(accountingItems, item); } /** * 移除核算项目 */ public void removeAccountingItem(AccountingItemEnum item) { if (accountingItems != null) { accountingItems = AccountingItemEnum.removeItem(accountingItems, item); } } }