package com.changhong.epc.parsing.service.transition.billInfo.util.impl; import com.changhong.epc.bean.count.MeInfo; 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.parsing.service.transition.billInfo.util.IGainValCodeTranche; import com.changhong.epc.rely.api.epc.system.ErrSystemApi; import com.iemsoft.framework.cloud.core.base.ResMsg; import com.iemsoft.framework.cloud.core.tools.JSONTool; import com.iemsoft.framework.cloud.core.tools.SpringUtil; import com.iemsoft.framework.cloud.ribbon.RestInterface; import org.apache.commons.lang3.StringUtils; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import java.util.Arrays; import java.util.HashMap; import java.util.Map; @Service("gainValCodeTranche") @Scope("prototype") public class GainValCodeTranche implements TenantUrlConst, SystemClients, IGainValCodeTranche { public Boolean flag; @Override public void initData(){ flag = false; } @Override public boolean isLoseMaster(){ return flag; } @SuppressWarnings("unchecked") public String getValCode(String fs,Map parm){ RestInterface restInterface = SpringUtil.getBean(SERVER_TENANT.getBeanName(), RestInterface.class); Object data = restInterface.post(fs, parm, ResMsg.class, EpcRestInterface.getEpcHeads()).getData(); if(data != null){ Map map = JSONTool.toObj(JSONTool.toJson(data),Map.class); return map.get("eleValue"); }else{ return null; } } @Override public String valToCode(String mdCode, String val, boolean ignore) { if(StringUtils.isBlank(mdCode)) return val; Map parme = new HashMap<>(); parme.put("defineCode", mdCode); parme.put("mvCode", val); String valCode = getValCode(TenantUrlConst.REST_TENANT_MASTERVALUE_GETCODE,parme); if(StringUtils.isBlank(valCode)){ if(ignore){ return "ignore"; } // 记录缺失的主数据 masterLostRecord(mdCode, val); return val; } return valCode; } /** * @auto 未完成 * 主数据缺失记录 */ public void masterLostRecord(String mdCode, String val){ flag = true; MeInfo meInfo = new MeInfo(); meInfo.setMeName("name"); meInfo.setMeValue(val); SpringUtil.getBean(ErrSystemApi.class).insertMasterErrMsg(mdCode, mdCode, Arrays.asList(meInfo)); } }