SJA APS后端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
3.4 KiB

  1. package service
  2. import (
  3. "fmt"
  4. "leit.com/leit_seat_aps/db"
  5. "testing"
  6. )
  7. // 测试TOD引擎
  8. func TestLoadProjectDataService(t *testing.T) {
  9. var (
  10. tp TodProject
  11. bl_pt BL_Part
  12. bl_ptattr BL_PartAttribute
  13. bl_pf BL_PartFamily
  14. bl_pfattr BL_PartFamily_Atcod
  15. bl_sg BL_SupplyGroup
  16. bl_sgattr BL_SupplyGroup_Atcod
  17. bl_cm BL_Carmodel
  18. bl_cmattr BL_Carmodel_Atcod
  19. pf string
  20. bl_ptrule BL_PartAssignRule
  21. ptqtyasntab db.Me_partrule_qtyassign
  22. connstring string
  23. covtab db.Pln_custorder_ver
  24. covlst []db.Pln_custorder_ver
  25. err error
  26. )
  27. // 连接数据库
  28. connstring = fmt.Sprintf("server=%s;user id=%s;password=%s;database=%s;port=%d;encrypt=disable",
  29. `DESKTOP-S4G95G5\\MLINK`, "lapp", "123fis", "LAPP_JITS", 1433)
  30. if err = db.InitMssqlDb(connstring); err != nil {
  31. t.Errorf("Failed to connect db due to: %v", err)
  32. return
  33. }
  34. defer db.G_DbEngine.Close()
  35. tp = TodProject{}
  36. tp.Projectid = "G38"
  37. // 获取未解析的订单版本头
  38. covtab = db.Pln_custorder_ver{}
  39. if covlst, err = covtab.GetProjectUnparsed(tp.Projectid); err != nil {
  40. t.Errorf("Failed to load unparsed coh list due to %v", err)
  41. }
  42. for i, _ := range covlst {
  43. fmt.Println(covlst[i])
  44. }
  45. return
  46. // 测试获取项目的零件规则数据
  47. if err = tp.GetPartRuleList(); err != nil {
  48. t.Errorf("Failed to load partrule list due to %v", err)
  49. }
  50. for _, bl_ptrule = range tp.Partruledict {
  51. fmt.Println(bl_ptrule.Partid, bl_ptrule.Ruleid, bl_ptrule.Qty)
  52. for _, ptqtyasntab = range bl_ptrule.Assignnruledict {
  53. fmt.Println(" ==>", ptqtyasntab)
  54. }
  55. }
  56. fmt.Println("Total loaded:", len(tp.Partruledict), " Part rules!")
  57. return
  58. // 测试获取项目的车型数据
  59. if err = tp.GetCarModelList(); err != nil {
  60. t.Errorf("Failed to load carmodel list due to %v", err)
  61. }
  62. for _, bl_cm = range tp.Carmodeldict {
  63. fmt.Println(bl_cm.Carmodelid, bl_cm.Carmodeltab.Descr)
  64. for _, bl_cmattr = range bl_cm.Cm_attr_dict {
  65. fmt.Println(" ==>", bl_cmattr.Attrcode, bl_cmattr.Mandatory, bl_cmattr.Verifyrule)
  66. }
  67. for _, pf = range bl_cm.Cm_pf_dict {
  68. fmt.Println(" -->", pf)
  69. }
  70. }
  71. fmt.Println("Total loaded:", len(tp.Carmodeldict), " Carmodels!")
  72. // 测试获取项目的SG数据
  73. if err = tp.GetSupplyGroupList(); err != nil {
  74. t.Errorf("Failed to load supplygroup list due to %v", err)
  75. }
  76. for _, bl_sg = range tp.Supplygrpdict {
  77. fmt.Println(bl_sg.Supplygroupid, bl_sg.Supplygrouptab.Descr)
  78. for _, bl_sgattr = range bl_sg.Sg_attr_dict {
  79. fmt.Println(" ==>", bl_sgattr.Attrcode, bl_sgattr.Mandatory, bl_sgattr.Verifyrule)
  80. }
  81. }
  82. fmt.Println("Total loaded:", len(tp.Supplygrpdict), " Supplygroups!")
  83. // 测试获取项目的PF数据
  84. if err = tp.GetPartFamilyList(); err != nil {
  85. t.Errorf("Failed to load partfamily list due to %v", err)
  86. }
  87. for _, bl_pf = range tp.Partfamdict {
  88. fmt.Println(bl_pf.Partfamilyid)
  89. for _, bl_pfattr = range bl_pf.Pf_attr_dict {
  90. fmt.Println(" ==>", bl_pfattr.Attrcode, bl_pfattr.Mandatory, bl_pfattr.Verifyrule)
  91. }
  92. }
  93. fmt.Println("Total loaded:", len(tp.Partfamdict), " Partfamilys!")
  94. if err = tp.GetPartList(); err != nil {
  95. t.Errorf("Failed to load part list due to %v", err)
  96. }
  97. for _, bl_pt = range tp.Partdict {
  98. fmt.Println(bl_pt.Partid)
  99. for _, bl_ptattr = range bl_pt.AtcodDict {
  100. fmt.Println(" ==>", bl_ptattr.Attrcode, bl_ptattr.Attrvalue)
  101. }
  102. }
  103. fmt.Println("Total loaded:", len(tp.Partdict), " Parts!")
  104. }