package com.changhong.epc.form.service.budget.impl; import com.changhong.autoform.core.tool.MD5; import com.changhong.epc.bean.admin.CorresElField; import com.changhong.epc.bean.admin.extend.CorresElFieldExtendFind; import com.changhong.epc.bean.form.FormType; import com.changhong.epc.bean.tenant.system.SystemConfig; import com.changhong.epc.bean.tenant.system.SystemForm; import com.changhong.epc.constter.admin.AdminUrlConst; import com.changhong.epc.constter.system.SystemClients; import com.changhong.epc.constter.system.businesscode.BudgetBusinessMeaningCode; import com.changhong.epc.constter.system.run.EpcRestInterface; import com.changhong.epc.rely.api.epc.tenant.SystemConfigApi; import com.iemsoft.framework.cloud.core.base.ResMsg; import com.iemsoft.framework.cloud.core.exception.IEMRestException; 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 com.iemsoft.framework.cloud.ribbon.RestInterface; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; import static com.changhong.epc.constter.system.businesscode.BudgetBusinessMeaningCode.YS_FORMID; /** * 查询常亮表 * @author jksk * */ public class GetConstant implements SystemClients{ /** * 暂时缓存 */ static CorresElFieldExtendFind constEl = null; private static final HashMap GET_FORMTYPE = new HashMap<>(); static{ GET_FORMTYPE.put(BudgetBusinessMeaningCode.SQ_FORMID, FormType.SQ);//申请 GET_FORMTYPE.put(YS_FORMID, FormType.YS);//预算 GET_FORMTYPE.put(BudgetBusinessMeaningCode.BX_FORMID, FormType.BX);//报销 GET_FORMTYPE.put(BudgetBusinessMeaningCode.ZJ_YS_FORMID, FormType.ZJ_YS);//追加预算 GET_FORMTYPE.put(BudgetBusinessMeaningCode.TH_YS_FORMID, FormType.TH_YS);//退回预算 GET_FORMTYPE.put(BudgetBusinessMeaningCode.GDZC_FORMID, FormType.GDZC);//固定资产 GET_FORMTYPE.put(BudgetBusinessMeaningCode.HK_FORMID, FormType.HK);//还款 //GET_FORMTYPE.put(BudgetBusinessMeaningCode.EXPENDCONTRACT, FormType.HT);//合同报销单 } /** * 根据表单id 获得表单类型 申请 报销 预算 * @return */ public static FormType getFormType(String formId){ CorresElFieldExtendFind constEl = GetConstant.getConstEl(); CorresElField findCode = constEl.findVal(formId); if(findCode == null) return null; FormType formtype = GET_FORMTYPE.get(findCode.getBusinessMeaningCode()); if(formtype == null) throw new IEMRestException("位置FormId"); return formtype; } // private static Map cache = new HashMap<>(); public static Object getPostRest(String url,Map parm){ String key = MD5.toMD5(JSONTool.toJson(parm)+url); // if(cache.get(key) != null){ // return cache.get(key); // } RestInterface restInterface = SpringUtil.getBean(SERVER_ADMIN.getBeanName(), RestInterface.class); Object data = restInterface.post(url, parm, ResMsg.class, EpcRestInterface.getEpcHeads()).getData(); // cache.put(key, data); return data; } public static CorresElFieldExtendFind getConstEl(){ Object postRest = getPostRest(AdminUrlConst.REST_ADMIN_CORRESELFIELD_SELECT, new HashMap<>()); return JSONTool.toObj(JSONTool.toJson(postRest), CorresElFieldExtendFind.class); } /** * 获得 表单id * @param str * @return */ public static String getFormIdGetConstant(String str){ if(Objects.equals(str, YS_FORMID)){ str = SystemForm.BUDGET_FORM_ID.name(); } SystemConfig systemConfigs = SpringUtil.getBean(SystemConfigApi.class) .getSystemConfig(SystemConfig.ofKey("formInfo", str)); if(systemConfigs.getCvalue() == null) { return ""; } return systemConfigs.getCvalue(); } public static String getConstant(String key){ List corresElFields = getConstEl().getCorresElFieldList(); if(ObjectUtil.empty(corresElFields)){ return ""; } for(CorresElField corresElField : corresElFields){ if(Objects.equals(corresElField.getBusinessMeaningCode(), key)){ return corresElField.getMdCode(); } } return ""; } /** * 获得 表单id * @param str * @return * zz */ // public static String getFormIdGetConstantByMappingIden(String str,String mappingIden){ // // System.out.println("-------------------------------------------"); // // System.out.println(JSONTool.toJson(GetConstant.constEl)); // if(GetConstant.constEl==null){ // GetConstant.constEl = new GetConstant().getConstEl(); // } // List corrs = constEl.findMapper(mappingIden); // for(CorresElField corr : corrs){ // if(str.equals(corr.getBusinessMeaningCode())){ // return corr.getMdCode(); // } // } // return null; // } // /** *根据mdCode 获取business_meaning_code *zz */ public static String getMeaningByMdCode(String mdcode){ CorresElFieldExtendFind constEl = GetConstant.getConstEl(); CorresElField findCode = constEl.findVal(mdcode); return findCode.getBusinessMeaningCode(); } }