package com.changhong.epc.parsing.service.autosubmit.prop; import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.Map; import org.apache.commons.beanutils.PropertyUtils; import com.changhong.epc.parsing.service.autosubmit.info.Form; import com.changhong.epc.parsing.service.autosubmit.info.FormCpn; import com.changhong.epc.parsing.service.autosubmit.info.FormulaInfo.ResultInfo; import com.changhong.epc.parsing.service.autosubmit.tool.AviatorTool; /** * 公式结果处理类 * @author WangYX * */ public class ResultType { private static final Map MODE = new HashMap<>(); static{ // 公式fx MODE.put(1, (form, resultInfo, formCpn)->{ formCpn.put(resultInfo.getAttribute(), AviatorTool.execute(resultInfo.getCode(), form, Object.class)); }); // 控件下红字错误 MODE.put(2, (form, resultInfo, formCpn)->{ formCpn.put(CpnMsg.error, resultInfo.getMessage()); }); // 弹框消息 MODE.put(3, (form, resultInfo, formCpn)->{ formCpn.put(resultInfo.getMessageType(), resultInfo.getMessage()); }); } public static Model getModel(Integer type){ return MODE.get(type); } /** * 返回值模型 * @author WangYX * */ @FunctionalInterface public static interface Model{ default void executo(Form form, ResultInfo resultInfo) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException{ FormCpn formCpn = (FormCpn)PropertyUtils.getProperty(form, resultInfo.getEventField()); if(form.triggerEvent(formCpn)) executo(form, resultInfo, formCpn); else return; } void executo(Form form, ResultInfo resultInfo, FormCpn formCpn); } }