VenderInfo.java 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package com.persagy.dptool.dto;
  2. import com.persagy.dptool.CommonUtil;
  3. import com.persagy.dptool.dto.vender.*;
  4. import java.util.HashMap;
  5. import java.util.Map;
  6. public class VenderInfo {
  7. /** 项目id,包含Pj前缀 */
  8. public String projectId;
  9. /** 项目id,不含Pj前缀 */
  10. public String pjId;
  11. public VenderInfo(String projectId) {
  12. this.projectId = projectId;
  13. this.pjId = projectId.substring(2);
  14. }
  15. public static boolean init = false;
  16. public static Map<String, VenderDTO> venderMap = new HashMap<>();
  17. public static Map<String, BrandDTO> brandMap = new HashMap<>();
  18. public static Map<String, VenderContactDTO> venderContMap = new HashMap<>();
  19. public static Map<String, SpecificatDTO> specificMap = new HashMap<>();
  20. public boolean initData() {
  21. if(!init) {
  22. try {
  23. BrandRecords brandRecords = CommonUtil.jsonStrToObjByResourceJsonFile("/vender/brand.json", BrandRecords.class);
  24. for(BrandDTO obj : brandRecords.getRecords()) {
  25. brandMap.put(obj.getBrandId(), obj);
  26. }
  27. VenderRecords venderRecords = CommonUtil.jsonStrToObjByResourceJsonFile("/vender/venders.json", VenderRecords.class);
  28. for(VenderDTO obj : venderRecords.getRecords()) {
  29. venderMap.put(obj.getVenderId(), obj);
  30. }
  31. VenderContactRecords venderContactRecords = CommonUtil.jsonStrToObjByResourceJsonFile("/vender/vendercontactinfo.json", VenderContactRecords.class);
  32. for(VenderContactDTO obj : venderContactRecords.getRecords()) {
  33. venderContMap.put(obj.getVenderId(), obj);
  34. }
  35. SpecificatRecords specificatRecords = CommonUtil.jsonStrToObjByResourceJsonFile("/vender/specification.json", SpecificatRecords.class);
  36. for(SpecificatDTO obj : specificatRecords.getRecords()) {
  37. specificMap.put(obj.getSpecId(), obj);
  38. }
  39. System.out.println("厂商库配置初始化成功。venderSize=" + venderMap.size() + ", brandSize=" + brandMap.size()+ ", venderCont=" + venderContMap.size()+ ", specific=" + specificMap.size());
  40. init = true;
  41. }catch (Exception e) {
  42. System.out.println("厂商库配置初始化失败");
  43. e.printStackTrace();
  44. }
  45. }
  46. return init;
  47. }
  48. }