苏州瑞玛APS项目web后台
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.

148 lines
5.8 KiB

3 years ago
3 years ago
  1. // Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
  2. package me
  3. import (
  4. "leit.com/LAPP_CHEERSSON_BACKEND/db"
  5. "leit.com/LAPP_CHEERSSON_BACKEND/grmi"
  6. "leit.com/LAPP_CHEERSSON_BACKEND/utils"
  7. "xorm.io/core"
  8. )
  9. /******************************************************************************
  10. *
  11. * @Struct Name : BomLst
  12. *-----------------------------------------------------------------------------
  13. *
  14. * @Description : BomLst的实体映射
  15. *
  16. * @Author : 代码生成器创建
  17. *
  18. * @Date : 2021-08-09 14:13:50
  19. *
  20. ******************************************************************************/
  21. type BomLst struct {
  22. PlantNr int `xorm:"pk int 'PlantNr'" json:"ME_BomLst-PlantNr"`
  23. BomId string `xorm:"pk nvarchar(20) 'BomId'" json:"ME_BomLst-BomId"`
  24. FmatNr string `xorm:"pk nvarchar(20) 'FmatNr'" json:"ME_BomLst-FmatNr"`
  25. CmatNr string `xorm:"pk nvarchar(20) 'CmatNr'" json:"ME_BomLst-CmatNr"`
  26. FmatName string `xorm:"nvarchar(40) 'FmatName' not null" json:"ME_BomLst-FmatName"`
  27. FmatSpec string `xorm:"nvarchar(40) 'FmatSpec' not null" json:"ME_BomLst-FmatSpec"`
  28. FmatQty float64 `xorm:"decimal 'FmatQty' not null" json:"ME_BomLst-FmatQty"`
  29. FmatUom string `xorm:"nvarchar(10) 'FmatUom' not null" json:"ME_BomLst-FmatUom"`
  30. CmatName string `xorm:"nvarchar(40) 'CmatName' not null" json:"ME_BomLst-CmatName"`
  31. CmatQty float64 `xorm:"decimal 'CmatQty' not null" json:"ME_BomLst-CmatQty"`
  32. CmatUom string `xorm:"nvarchar(10) 'CmatUom' not null" json:"ME_BomLst-CmatUom"`
  33. CmatType string `xorm:"nvarchar(20) 'CmatType' not null" json:"ME_BomLst-CmatType"`
  34. Position int `xorm:"int 'Position' not null" json:"ME_BomLst-Position"`
  35. LeadTime float64 `xorm:"decimal 'LeadTime' not null" json:"ME_BomLst-LeadTime"`
  36. TimeUom string `xorm:"nvarchar(10) 'TimeUom' not null" json:"ME_BomLst-TimeUom"`
  37. LossRate float64 `xorm:"decimal 'LossRate' not null" json:"ME_BomLst-LossRate"`
  38. BackFlushItem int `xorm:"smallint 'BackFlushItem' not null" json:"ME_BomLst-BackFlushItem"`
  39. CriticalItem int `xorm:"smallint 'CriticalItem' not null" json:"ME_BomLst-CriticalItem"`
  40. ValidFrom string `xorm:"nvarchar(14) 'ValidFrom'" json:"ME_BomLst-ValidFrom"`
  41. ValidTo string `xorm:"nvarchar(14) 'ValidTo'" json:"ME_BomLst-ValidTo"`
  42. BomlstCval1 string `xorm:"nvarchar(40) 'BomlstCval1' not null" json:"ME_BomLst-BomlstCval1"`
  43. BomlstCval2 string `xorm:"nvarchar(40) 'BomlstCval2' not null" json:"ME_BomLst-BomlstCval2"`
  44. BomlstIval1 int `xorm:"int 'BomlstIval1' not null" json:"ME_BomLst-BomlstIval1"`
  45. BomlstIval2 int `xorm:"int 'BomlstIval2' not null" json:"ME_BomLst-BomlstIval2"`
  46. LevelNr int `xorm:"int 'LevelNr'" json:"ME_BomLst-LevelNr"`
  47. LastModify grmi.DateTime `xorm:"datetime 'LastModify' not null updated" json:"ME_BomLst-LastModify"`
  48. LastUser string `xorm:"nvarchar(20) 'LastUser' not null" json:"ME_BomLst-LastUser"`
  49. CreateTime grmi.DateTime `xorm:"datetime 'CreateTime' not null created" json:"ME_BomLst-CreateTime"`
  50. ItemLi []BomLst `xorm:"-" json:"ME_BomLst-ItemLi"`
  51. }
  52. /******************************************************************************
  53. *
  54. * @Function Name : GetKey
  55. *-----------------------------------------------------------------------------
  56. *
  57. * @Description : 获取实体的主键
  58. *
  59. * @Return Value : 实体的主键
  60. *
  61. * @Author : 代码生成器创建
  62. *
  63. * @Date : 2021-08-09 14:13:50
  64. *
  65. ******************************************************************************/
  66. func (self *BomLst) GetKey() core.PK {
  67. return core.PK{self.PlantNr, self.BomId, self.FmatNr, self.CmatNr}
  68. }
  69. func (t *BomLst) TableName() string {
  70. return "ME_BomLst"
  71. }
  72. func (t *BomLst) GetPage() (Menus []BomLst, err error) {
  73. e := db.Eloquent.Master()
  74. table := e.Table(t.TableName()).Where("PlantNr = ?", t.PlantNr)
  75. if t.BomId != "" {
  76. table = table.And("BomId = ?", t.BomId)
  77. }
  78. if err = table.Asc("FmatNr").Find(&Menus); err != nil {
  79. return
  80. }
  81. return
  82. }
  83. //递归查询侧边栏
  84. func (t *BomLst) SetMenu(FmatNr string) (m []BomLst, err error) {
  85. menulist, err := t.GetPage()
  86. m = make([]BomLst, 0)
  87. for i := 0; i < len(menulist); i++ {
  88. //menulist[i].Clipped()
  89. if menulist[i].FmatNr != FmatNr {
  90. continue
  91. }
  92. menusInfo := DiguiMeBomlst(&menulist, menulist[i])
  93. m = append(m, menusInfo)
  94. }
  95. return
  96. }
  97. //递归查询
  98. func DiguiMeBomlst(me_bomlst *[]BomLst, me BomLst) BomLst {
  99. list := *me_bomlst
  100. min := make([]BomLst, 0)
  101. for j := 0; j < len(list); j++ {
  102. //list[j].Clipped()
  103. if me.CmatNr != list[j].FmatNr {
  104. continue
  105. }
  106. mi := BomLst{}
  107. mi.PlantNr = list[j].PlantNr
  108. mi.BomId = list[j].BomId
  109. mi.FmatNr = list[j].FmatNr
  110. mi.CmatNr = list[j].CmatNr
  111. mi.FmatName = list[j].FmatName
  112. mi.FmatSpec = list[j].FmatSpec
  113. mi.FmatQty = list[j].FmatQty
  114. mi.FmatUom = list[j].FmatUom
  115. mi.LevelNr = list[j].LevelNr
  116. mi.CmatName = list[j].CmatName
  117. mi.CmatQty = list[j].CmatQty
  118. mi.CmatUom = list[j].CmatUom
  119. mi.CmatType = list[j].CmatType
  120. mi.Position = list[j].Position
  121. mi.LeadTime = list[j].LeadTime
  122. mi.TimeUom = list[j].TimeUom
  123. mi.LossRate = list[j].LossRate
  124. mi.BackFlushItem = list[j].BackFlushItem
  125. mi.CriticalItem = list[j].CriticalItem
  126. mi.ValidFrom = list[j].ValidFrom
  127. mi.ValidTo = list[j].ValidTo
  128. mi.BomlstCval1 = list[j].BomlstCval1
  129. mi.BomlstCval2 = list[j].BomlstCval2
  130. mi.BomlstIval1 = list[j].BomlstIval1
  131. mi.BomlstIval2 = list[j].BomlstIval2
  132. mi.ItemLi = []BomLst{}
  133. ms := DiguiMeBomlst(me_bomlst, mi)
  134. utils.TrimStruct(&ms, ms)
  135. min = append(min, ms)
  136. }
  137. me.ItemLi = min
  138. return me
  139. }