package com.changhong.epc.count.service.format; import com.changhong.epc.bean.count.format.CpnInfo; import com.changhong.epc.bean.count.format.CpnType; import com.changhong.epc.bean.count.format.FormInfo; import com.changhong.epc.bean.count.format.ItemInfo; import com.changhong.epc.constter.count.format.ConstFormat; import com.changhong.epc.constter.count.format.ConstFormatMsg; import com.iemsoft.framework.cloud.core.tools.ObjectUtil; import java.util.Collections; import java.util.List; /** * 格式表单信息 * @author WangYX * * @param */ public interface FormatFormInfo extends ConstFormat, ConstFormatMsg{ /** * 格式计算费用参数 * @param formInfo * @param flag */ I formatParam(FormInfo formInfo); /** * 格式计算后返回值 * @param formInfo * @param result * @param flag */ void formatResult(FormInfo formInfo, O result); /** * 是子表单 * @param cpnInfo * @return */ default boolean isSubForm(CpnInfo cpnInfo){ return cpnInfo == null ? false : cpnInfo.getType() == CpnType.subform; } /** * 不是子表单 * @param cpnInfo * @return */ default boolean isNotSubForm(CpnInfo cpnInfo){ return !isSubForm(cpnInfo); } /** * 是否是行程子表单 * @param cpnInfo * @return */ boolean isJourneySubForm(CpnInfo cpnInfo); /** * 获得行程数据信息 * @return */ default CpnInfo getJourneyInfo(FormInfo formInfo){ CpnInfo[] subForms = formInfo.getData().stream().filter(this::isJourneySubForm) .toArray(CpnInfo[]::new); if(ObjectUtil.empty(subForms)) return null; return subForms[0]; } }