package com.changhong.epc.rely.api.epc.tenant; import com.alibaba.fastjson.TypeReference; import com.changhong.epc.bean.tenant.master.AutoMasterVal; import com.changhong.epc.bean.tenant.master.MasterDefine; import com.changhong.epc.bean.tenant.master.MasterEleValue; import com.changhong.epc.bean.tenant.master.MasterValue; import com.changhong.epc.bean.tenant.master.extend.MasterDefinesExtend; import com.changhong.epc.constter.cache.master.MasterCache; import com.changhong.epc.constter.system.SystemClients; import com.changhong.epc.constter.system.run.EpcRestInterface; import com.changhong.epc.constter.tenant.TenantUrlConst; import com.changhong.epc.rely.api.epc.BaseApi; import com.iemsoft.framework.cloud.core.base.ResMsg; 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 org.springframework.stereotype.Service; import java.util.*; /** * 主数据查询api */ @Service public class MasterApi extends BaseApi implements SystemClients, MasterCache { /** * 根据值code获得主数据值 * @param mdCode * @param mvCode * @return */ public MasterValue getMasterVal(String mdCode, String mvCode){ MasterEleValue masterEleValue = new MasterEleValue(); masterEleValue.setDefineCode(mdCode); masterEleValue.setMvCode(mvCode); ResMsg resMsg = (ResMsg) SpringUtil.getBean(SERVER_TENANT.getBeanName(), RestInterface.class) .post(TenantUrlConst.REST_TENANT_MASTERVALUE_GETVAL , masterEleValue , new TypeReference>(){}.getType() , EpcRestInterface.getEpcHeads() ); assertSuccess(resMsg); return JSONTool.toObj(JSONTool.toJson(resMsg.getData()), MasterValue.class); } public Collection getMasterVal(Collection masterInfos){ if(ObjectUtil.empty(masterInfos)){ return Collections.EMPTY_LIST; } ResMsg> resMsg = (ResMsg>) SpringUtil.getBean(SERVER_TENANT.getBeanName(), RestInterface.class) .post(TenantUrlConst.REST_TENANT_MASTERELEMENT_SELECTCODES , masterInfos , new TypeReference>>(){}.getType() , EpcRestInterface.getEpcHeads() ); assertSuccess(resMsg); return JSONTool.toList(JSONTool.toJson(resMsg.getData()), MasterEleValue.class); } // @CacheSave(value = MASTER_DEF, company = false) public List getMasterDefs(){ ResMsg> resMsg = (ResMsg>) SpringUtil.getBean(SERVER_TENANT.getBeanName(), RestInterface.class) .post(TenantUrlConst.REST_TENANT_MASTERTYPE_SELECTELE , new MasterDefine() , new TypeReference>>(){}.getType() , EpcRestInterface.getEpcHeads() ); assertSuccess(resMsg); List data = JSONTool.toList(JSONTool.toJson(resMsg.getData()), MasterDefinesExtend.class); return data == null ? new ArrayList<>() : data; } /** * 根据纬度、条件返回主数据值 * @param autoMasterVal * @return */ public String getMasterVal(AutoMasterVal autoMasterVal){ ResMsg resMsg = (ResMsg) SpringUtil.getBean(SERVER_TENANT.getBeanName(), RestInterface.class) .post(TenantUrlConst.MASTER_TENANT_GETVAL , autoMasterVal , new TypeReference>(){}.getType() , EpcRestInterface.getEpcHeads() ); assertSuccess(resMsg); return resMsg.getData(); } }