package com.ld.igds.n2; import com.ld.igds.data.VerbImg; import com.ld.igds.models.Depot; import lombok.Data; import org.apache.commons.lang3.StringUtils; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.PropertySource; import org.springframework.stereotype.Component; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @author: andy.jia * @description: 系统配置气调模块背景操作图 * @date:2019.05.02 **/ @Component @PropertySource("classpath:n2-conf.properties") @ConfigurationProperties(prefix = "n2") @Data public class ConfigN2Img { /** * 配置规则1:n2.mapImg.companyId_仓库编码/分库编码.a=default_3-box-00.png 表示获取默认default中国的图片 * 配置规则2:n2.mapImg.companyId_仓库编码/分库编码.a=3-box-00.png 表示获取自定义设计中的图片 */ private Map mapImg; /** * 根据仓库列表和所在分库编码获取当前仓库类的通风配置图片 * * @param depotList * @param deptId * @return */ public Map getN2Img(List depotList, String deptId) { Map result = new HashMap<>(); Map all = this.getMapImg(); if (null == depotList || null == all) return result; String companyId = depotList.get(0).getCompanyId(); VerbImg temp; for (Depot d : depotList) { //先从配置中获取 temp = all.get(companyId + "_" + d.getId()); //从分库配置中获取 if (null == temp) { temp = all.get(deptId); } if (null == temp || StringUtils.isEmpty(temp.getA())) continue; temp.setFile(companyId); if (temp.getA().indexOf("default_") >= 0) { result.put(d.getId(), new VerbImg(temp.getA().substring(8), temp.getB().substring(8), "default")); } else { result.put(d.getId(), temp); } } return result; } }