1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- package com.persagy.dptool.dto;
- import com.persagy.dptool.CommonUtil;
- import com.persagy.dptool.dto.vender.*;
- import java.util.HashMap;
- import java.util.Map;
- public class VenderInfo {
- /** 项目id,包含Pj前缀 */
- public String projectId;
- /** 项目id,不含Pj前缀 */
- public String pjId;
- public VenderInfo(String projectId) {
- this.projectId = projectId;
- this.pjId = projectId.substring(2);
- }
- public static boolean init = false;
- public static Map<String, VenderDTO> venderMap = new HashMap<>();
- public static Map<String, BrandDTO> brandMap = new HashMap<>();
- public static Map<String, VenderContactDTO> venderContMap = new HashMap<>();
- public static Map<String, SpecificatDTO> specificMap = new HashMap<>();
- public boolean initData() {
- if(!init) {
- try {
- BrandRecords brandRecords = CommonUtil.jsonStrToObjByResourceJsonFile("/vender/brand.json", BrandRecords.class);
- for(BrandDTO obj : brandRecords.getRecords()) {
- brandMap.put(obj.getBrandId(), obj);
- }
- VenderRecords venderRecords = CommonUtil.jsonStrToObjByResourceJsonFile("/vender/venders.json", VenderRecords.class);
- for(VenderDTO obj : venderRecords.getRecords()) {
- venderMap.put(obj.getVenderId(), obj);
- }
- VenderContactRecords venderContactRecords = CommonUtil.jsonStrToObjByResourceJsonFile("/vender/vendercontactinfo.json", VenderContactRecords.class);
- for(VenderContactDTO obj : venderContactRecords.getRecords()) {
- venderContMap.put(obj.getVenderId(), obj);
- }
- SpecificatRecords specificatRecords = CommonUtil.jsonStrToObjByResourceJsonFile("/vender/specification.json", SpecificatRecords.class);
- for(SpecificatDTO obj : specificatRecords.getRecords()) {
- specificMap.put(obj.getSpecId(), obj);
- }
- System.out.println("厂商库配置初始化成功。venderSize=" + venderMap.size() + ", brandSize=" + brandMap.size()+ ", venderCont=" + venderContMap.size()+ ", specific=" + specificMap.size());
- init = true;
- }catch (Exception e) {
- System.out.println("厂商库配置初始化失败");
- e.printStackTrace();
- }
- }
- return init;
- }
- }
|