package net.cnki.editor.costcenter.pojo.enums;import lombok.Getter;import java.util.Arrays;/*** 費用枚舉接口*/
public interface CosttypeEnumInterface {/*** 費用類型和費用信息-> 費用性質, 支付人 , 收取人, 費用信息狀態*/@Getterenum CosttypePayerAndReceiveEnum implements CosttypeEnumInterface {//當前類 ; sql語句//1 審稿費;作者->編輯部 2 版面費;作者->編輯部 3 作者稿費;編輯部->作者 4 專家審稿費;編輯部->審稿專家 5 編輯稿費;編輯部->編輯REVIEWERS_FEE((short) 1, "審稿費", "作者", "編輯部", "待通知交費", "待作者交費", "待確認到款", "待開票完成", "己完成"),PAPER_FREE((short) 2, "版面費", "作者", "編輯部", "待通知交費", "待作者交費", "待確認到款", "待開票完成", "己完成"),AUTHOR_FREE((short) 3, "作者稿費", "編輯部", "作者", "待通知作者", "待作者確認信息", "信息已確認待支付", "作者稿費已支付", ""),EXPERT_FREE((short) 4, "專家審稿費", "編輯部", "審稿專家", "編輯部未登記", "編輯部已登記", "", "", ""),COPYREADER_FREE((short) 5, "編輯稿費", "編輯部", "編輯", "編輯部未登記", "編輯部已登記", "", "", ""),NULL(null, "", "", "", "", "", "", "", "");private final Short type;private final String name;//支付人private final String payerMan;//收取人private final String receiveMan;//費用信息狀態private final String status0;private final String status1;private final String status2;private final String status3;private final String status4;CosttypePayerAndReceiveEnum(Short type, String name, String payerMan, String receiveMan, String status0, String status1, String status2, String status3, String status4) {this.type = type;this.name = name;this.payerMan = payerMan;this.receiveMan = receiveMan;this.status0 = status0;this.status1 = status1;this.status2 = status2;this.status3 = status3;this.status4 = status4;}/*** 獲取 費用性質** @param type* @return*/public static CosttypePayerAndReceiveEnum getValue(short type) {CosttypePayerAndReceiveEnum costtypePayerAndReceiveEnum = Arrays.stream(CosttypePayerAndReceiveEnum.values()).filter(x -> x.getType() == type).findAny().orElse(CosttypePayerAndReceiveEnum.NULL);return costtypePayerAndReceiveEnum;}/*** 根據 費用性質 獲取 當前費用信息 的 信息狀態** @param typeCode 費用性質* @param statusCode 費用性質* @return*/public static String getStatusName(short typeCode, int statusCode) {CosttypePayerAndReceiveEnum costtypePayerAndReceiveEnum = Arrays.stream(CosttypePayerAndReceiveEnum.values()).filter(x -> x.getType() == typeCode).findAny().orElse(CosttypePayerAndReceiveEnum.NULL);switch (statusCode) {case 0:return costtypePayerAndReceiveEnum.getStatus0();case 1:return costtypePayerAndReceiveEnum.getStatus1();case 2:return costtypePayerAndReceiveEnum.getStatus2();case 3:return costtypePayerAndReceiveEnum.getStatus3();case 4:return costtypePayerAndReceiveEnum.getStatus4();default:return "";}}}/*** 結算方式: 結算方式 0 第三方轉賬 1 郵局匯款 2銀行匯款 3現金支付 4內部轉賬 5其他*/@Getterenum PayMethod implements CosttypeEnumInterface {METHOD("第三方轉賬", "郵局匯款", "銀行匯款", "現金支付", "內部轉賬", "其他");// 結算方式 0private final String payMethod0;// 結算方式 1private final String payMethod1;private final String payMethod2;private final String payMethod3;private final String payMethod4;private final String payMethod5;PayMethod(String payMethod0, String payMethod1, String payMethod2, String payMethod3, String payMethod4, String payMethod5) {this.payMethod0 = payMethod0;this.payMethod1 = payMethod1;this.payMethod2 = payMethod2;this.payMethod3 = payMethod3;this.payMethod4 = payMethod4;this.payMethod5 = payMethod5;}public static String getMethod(String payMethodCode) {switch (payMethodCode) {case "0":return PayMethod.METHOD.getPayMethod0();case "1":return PayMethod.METHOD.getPayMethod1();case "2":return PayMethod.METHOD.getPayMethod2();case "3":return PayMethod.METHOD.getPayMethod3();case "4":return PayMethod.METHOD.getPayMethod4();case "5":return PayMethod.METHOD.getPayMethod5();default:return "";}}}/*** 發票類型 0 普票 1 專票*/@Getterenum InvoiceType implements CosttypeEnumInterface {INVOICETYPE("普票", "專票");//分票類型0private final String invoiceType0;//分票類型1private final String invoiceType1;InvoiceType(String invoiceType0, String invoiceType1) {this.invoiceType0 = invoiceType0;this.invoiceType1 = invoiceType1;}public static String getInvoiceType(String invoiceTypeCode) {switch (invoiceTypeCode) {case "0":return InvoiceType.INVOICETYPE.getInvoiceType0();case "1":return InvoiceType.INVOICETYPE.getInvoiceType1();default:return "";}}}}
測試類
vo.setPayMethod(CosttypeEnumInterface.PayMethod.getMethod(StringUtils.defaultString(vo.getPayMethod())));vo.setInvoiceType(CosttypeEnumInterface.InvoiceType.getInvoiceType(StringUtils.defaultString(vo.getInvoiceType())));vo.setStatus(CosttypeEnumInterface.CosttypePayerAndReceiveEnum.getStatusName(Short.parseShort(vo.getCosttype()), Integer.parseInt(vo.getStatus())));