partlaid.go 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. package model
  2. import (
  3. "time"
  4. "github.com/pkg/errors"
  5. "kpt.xdmy/pkg/util"
  6. )
  7. type BigPartLaid struct {
  8. // 入库单
  9. CreatDate time.Time `gorm:"column:creatDate"`
  10. EmpID int `gorm:"column:empId"`
  11. ID int `gorm:"column:id"`
  12. Issync int `gorm:"column:issync"`
  13. LaidCode string `gorm:"column:laidCode"`
  14. LaidType int `gorm:"column:laidType"`
  15. Msg string `gorm:"column:msg"`
  16. PastureID int `gorm:"column:pastureId"`
  17. PurchaseID string `gorm:"column:purchaseId"`
  18. StorageTime time.Time `gorm:"column:storageTime"`
  19. // add
  20. ProofCode string ` gorm:"column:proofCode"`
  21. ProofYear string ` gorm:"column:proofYear"`
  22. }
  23. type PartLaid struct {
  24. BigID int `gorm:"column:bigId"`
  25. BigBuyerId interface{} ` gorm:"column:bigBuyerId"`
  26. BrandID int `gorm:"column:brandId"`
  27. BuydetailID int `gorm:"column:buydetailId"`
  28. ContractID int `gorm:"column:contractId"`
  29. LocationID int `gorm:"column:locationId"`
  30. PartID int `gorm:"column:partId"`
  31. ProviderID int `gorm:"column:providerId"`
  32. PastureID int `gorm:"column:pastureId"`
  33. BuyAmount int `gorm:"column:buyAmount"`
  34. ID int `gorm:"column:id"`
  35. Note string `gorm:"column:note"`
  36. OrderNumber string `gorm:"column:orderNumber"`
  37. PartCode string `gorm:"column:partCode"`
  38. PartName string `gorm:"column:partName"`
  39. Price float32 `gorm:"column:price"`
  40. Purpose string `gorm:"column:purpose"`
  41. ReceivedAmount string `gorm:"column:receivedAmount"`
  42. Reportery string `gorm:"column:reportery"`
  43. Specification string `gorm:"column:specification"`
  44. StorageAmount float32 `gorm:"column:storageAmount"`
  45. StorageType int `gorm:"column:storageType"`
  46. SubscribePasture string `gorm:"column:subscribePasture"`
  47. SubscribeProvider string `gorm:"column:subscribeProvider"`
  48. SumPrice float32 `gorm:"column:sumPrice"`
  49. Unit string `gorm:"column:unit"`
  50. Dflag int `gorm:"column:dflag"`
  51. RowNumber int `gorm:"column:rowNumber"`
  52. IsZeroStock int `gorm:"column:isZeroStock"`
  53. }
  54. func (p *PartLaid) ToProofPart() (r *ProofPart, e error) {
  55. mb := &Brand{ID: p.BrandID}
  56. mp := &Provider{ID: p.ProviderID}
  57. mw := &Warehouse{ID: p.LocationID}
  58. e = First(mb)
  59. e = First(mp)
  60. e = First(mw)
  61. if e != nil {
  62. e = errors.Wrapf(e, " PartLaid ToProofPart()")
  63. return
  64. }
  65. r = &ProofPart{
  66. RowNumber: p.RowNumber,
  67. PartCode: p.PartCode,
  68. PartName: p.PartName,
  69. Specification: p.Specification,
  70. PartBrand: mb.BrandName,
  71. Supplier: mp.ProviderName,
  72. Warehouse: mw.WarehoseCode,
  73. ChangeCount: p.StorageAmount,
  74. UnitPrice: p.Price,
  75. TotalPrice: p.SumPrice,
  76. }
  77. return
  78. }
  79. func (p *BigPartLaid) NewProofPart() (mps []ProofPart, e error) {
  80. path := " BigPartLaid NewProof()"
  81. c := util.NewMap("bigid", p.ID)
  82. m := make([]PartLaid, 0)
  83. if e = Find(c, &m); e != nil {
  84. e = errors.Wrapf(e, path)
  85. return
  86. }
  87. mps = make([]ProofPart, 0)
  88. mp := new(ProofPart)
  89. for i, v := range m {
  90. if mp, e = v.ToProofPart(); e != nil {
  91. continue
  92. }
  93. mp.RowNumber = i
  94. mps = append(mps, *mp)
  95. }
  96. return
  97. }
  98. func (p *BigPartLaid) NewProof(pa *ProofReq) {
  99. pa.ChargeDate = p.CreatDate.Format("2006-01-02")
  100. pa.ProofCode = p.ProofCode
  101. pa.ProofYear = p.CreatDate.Format("2006")
  102. pa.OrderNumberId = p.ID
  103. }
  104. type PartLaidStr struct {
  105. BigID interface{} `gorm:"column:bigId"`
  106. BigBuyerId interface{} ` gorm:"column:bigBuyerId"`
  107. BrandID interface{} `gorm:"column:brandId"`
  108. BuydetailID interface{} `gorm:"column:buydetailId"`
  109. ContractID interface{} `gorm:"column:contractId"`
  110. LocationID interface{} `gorm:"column:locationId"`
  111. PartID interface{} `gorm:"column:partId"`
  112. ProviderID interface{} `gorm:"column:providerId"`
  113. PastureID interface{} `gorm:"column:pastureId"`
  114. BuyAmount interface{} `gorm:"column:buyAmount"`
  115. ID interface{} `gorm:"column:id"`
  116. Note interface{} `gorm:"column:note"`
  117. OrderNumber interface{} `gorm:"column:orderNumber"`
  118. PartCode interface{} `gorm:"column:partCode"`
  119. PartName interface{} `gorm:"column:partName"`
  120. Price interface{} `gorm:"column:price"`
  121. Purpose interface{} `gorm:"column:purpose"`
  122. ReceivedAmount interface{} `gorm:"column:receivedAmount"`
  123. Reportery interface{} `gorm:"column:reportery"`
  124. Specification interface{} `gorm:"column:specification"`
  125. StorageAmount interface{} `gorm:"column:storageAmount"`
  126. StorageType interface{} `gorm:"column:storageType"`
  127. SubscribePasture interface{} `gorm:"column:subscribePasture"`
  128. SubscribeProvider interface{} `gorm:"column:subscribeProvider"`
  129. SumPrice interface{} `gorm:"column:sumPrice"`
  130. Unit interface{} `gorm:"column:unit"`
  131. Dflag interface{} `gorm:"column:dflag"`
  132. RowNumber interface{} `gorm:"column:rowNumber"`
  133. IsZeroStock interface{} `gorm:"column:isZeroStock"`
  134. }