package com.changhong.epc.tenant.service.norm.impl.value; import com.changhong.epc.bean.tenant.master.MasterElement; import com.changhong.epc.bean.tenant.master.MasterValue; import com.changhong.epc.bean.tenant.master.extend.MasterDefinesExtend; import com.changhong.epc.constter.admin.AdminUrlConst; import com.changhong.epc.constter.base.BaseConst; import com.changhong.epc.constter.system.SystemClients; import com.changhong.epc.constter.system.run.EpcRestInterface; import com.changhong.epc.tenant.mapper.tenant.norm.MasterValueMapper; import com.changhong.epc.tenant.service.norm.impl.SimplAbstractMasterTools; import com.iemsoft.framework.cloud.core.base.ResMsg; import com.iemsoft.framework.cloud.core.tools.ObjectUtil; import com.iemsoft.framework.cloud.core.tools.SpringUtil; import com.iemsoft.framework.cloud.ribbon.RestInterface; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.map.HashedMap; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.*; /** * 主数据查询,用于补助标准 */ @Service @Slf4j public class ValueSeache extends SimplAbstractMasterTools implements SystemClients, BaseConst { @Resource private MasterValueMapper masterValueMapper; @Override protected Object adminOneDimensional(MasterDefinesExtend masterDefine, MasterValue masterValue) { RestInterface restInterface = SpringUtil.getBean(SERVER_ADMIN.getBeanName(), RestInterface.class); return restInterface.post(AdminUrlConst.VALUE_SELECTVALUESEACHE, masterValue, ResMsg.class, EpcRestInterface.getEpcHeads()).getData(); } /** * 通用二维 */ @Override protected Object adminTwoDimensional(MasterDefinesExtend masterDefine, MasterValue masterValue) { for(MasterElement m:masterDefine.getEleList()){ if(m.getAlias()!=null && !Objects.equals(m.getAlias(),"")){ if(Objects.equals("code",m.getAlias())){ masterValue.setEleCode(m.getDefMapTalbeField()); }else if(Objects.equals("value",m.getAlias())){ masterValue.setEleValue(m.getDefMapTalbeField()); } } } RestInterface restInterface = SpringUtil.getBean(SERVER_ADMIN.getBeanName(), RestInterface.class); Object data = restInterface.post(AdminUrlConst.VALUE_SEACHEVALUES, masterValue, ResMsg.class, EpcRestInterface.getEpcHeads()).getData(); return data; } @Override protected Object tenantOneDimensional(MasterDefinesExtend masterDefine, MasterValue masterValue) { Map map = new HashMap<>(); List list = masterValueMapper.selectValueSeache(masterValue.getDefineCode(),null,masterValue.getValue()); map.put("values", getMasterValue(list)); if(!ObjectUtil.empty(masterValue.getCodes()) && masterValue.getCodes().size()>0){ List list1 = masterValueMapper.selectValueSeache(masterValue.getDefineCode(),masterValue.getCodes(),null); map.put("selectSeache", getMasterValue(list1)); } return map; } /** * 租户二维 * @param masterDefine * @param masterValue * @return */ @Override protected Object tenantTwoDimensional(MasterDefinesExtend masterDefine, MasterValue masterValue) { Map map = new HashMap<>(); //取出code ,value String code = null; String value = null; for(MasterElement m:masterDefine.getEleList()){ if(m.getAlias()!=null && !Objects.equals(m.getAlias(),"")){ if(Objects.equals("code",m.getAlias())){ code = m.getDefMapTalbeField(); }else if(Objects.equals("value",m.getAlias())){ value = m.getDefMapTalbeField(); } } } map.put("values", masterValueMapper.seacherValues(code,value,masterDefine.getDefMapTableName(),null,masterValue.getValue())); map.put("selectSeache", masterValueMapper.seacherValues( code,value,masterDefine.getDefMapTableName(), masterValue.getCodes()!=null && masterValue.getCodes().size()>0?masterValue.getCodes():null,null)); return map; } public Object getMasterValue(List list) { Map> group = new HashedMap<>(); boolean flog = true; if (ObjectUtil.empty(list) || list.size() <= 0) { return new ArrayList(); } for (MasterValue mv : list) { Map temp; if (null == (temp = group.get(mv.getRowNo()))) { temp = new HashMap<>(); group.put(mv.getRowNo(), temp); } if (flog) { // System.out.println("code"); temp.put("code", mv.getEleValue()); } else { temp.put("value", mv.getEleValue()); // System.out.println("val"); } // System.out.println(flog); flog = !flog; } return group.values(); } }