package com.changhong.epc.parsing.service.util; import com.changhong.epc.bean.admin.CorresElField; import com.changhong.epc.bean.tenant.bill.OCRBillBodyEntity; import com.changhong.epc.bean.tenant.bill.OCRBillHeaderEntity; import com.changhong.epc.constter.parsing.subassembly.billinfo.TransverterConstKey; import com.changhong.epc.rely.api.epc.admin.CorresElFieldApi; import com.iemsoft.framework.cloud.core.tools.JSONTool; import com.iemsoft.framework.cloud.core.tools.ObjectUtil; import com.iemsoft.framework.cloud.core.tools.SpringUtil; import lombok.extern.slf4j.Slf4j; import java.util.*; /** * 票据解析工具类 */ @Slf4j public class BillTool implements TransverterConstKey { // public static final Set JOURNEY_BILL_MODEL_CODE = new HashSet<>(3); // // static { // JOURNEY_BILL_MODEL_CODE.add("B02500010000"); // 火车票 // JOURNEY_BILL_MODEL_CODE.add("B02500000000"); // 飞机票、联程机票 // JOURNEY_BILL_MODEL_CODE.add("B02500030000"); // 汽车票 // } /** * 是行程票据 * @param iocrBill * @return */ public static boolean isJourneyBill(OCRBillHeaderEntity iocrBill){ log.debug("票据code:{}", iocrBill.getBillModelCode()); CorresElField corresElField = SpringUtil.getBean(CorresElFieldApi.class).getCorresElField(BILL_CODES); if(ObjectUtil.empty(corresElField)){ return false; } return new HashSet(Arrays.asList(corresElField.getMdCode().split(","))).contains(iocrBill.getBillModelCode()); } /** * 拆封body * @param ocrBillHeaderEntity * @return */ public static List splitBody(OCRBillHeaderEntity ocrBillHeaderEntity){ if(ObjectUtil.empty(ocrBillHeaderEntity.getBillBodyEntityList())) return Arrays.asList(ocrBillHeaderEntity); List resultBodys = new ArrayList<>(ocrBillHeaderEntity.getBillBodyEntityList().size()); List bodys = ocrBillHeaderEntity.getBillBodyEntityList(); ocrBillHeaderEntity.setBillBodyEntityList(Collections.EMPTY_LIST); bodys.stream().forEach(body->{ OCRBillHeaderEntity ocrBillHeader = JSONTool.toObj(JSONTool.toJson(ocrBillHeaderEntity), OCRBillHeaderEntity.class); ocrBillHeader.getBillBodyEntityList().add(body); resultBodys.add(ocrBillHeader); }); return resultBodys; } }