Partquit.go 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package model
  2. import (
  3. "time"
  4. "github.com/pkg/errors"
  5. "kpt.xdmy/pkg/util"
  6. )
  7. type BigPartquit struct {
  8. // 退库
  9. CreatDate string `gorm:"column:creatDate"`
  10. DeptID int `gorm:"column:deptId"`
  11. ID int `gorm:"column:id"`
  12. Issync int `gorm:"column:issync"`
  13. ListType int `gorm:"column:listType"`
  14. Msg string `gorm:"column:msg"`
  15. Note string `gorm:"column:note"`
  16. OddNumber string `gorm:"column:oddNumber"`
  17. PastureID int `gorm:"column:pastureId"`
  18. QuitDate time.Time `gorm:"column:quitDate"`
  19. QuitID int `gorm:"column:quitId"`
  20. SumPrice float32 `gorm:"column:sumPrice"`
  21. UseForm string `gorm:"column:useForm"` // 出库单号
  22. ProofCode string `gorm:"column:proofCode"`
  23. }
  24. type Partquit struct {
  25. // 退库详情
  26. ApplyNumber string `gorm:"column:applyNumber"`
  27. BigID int `gorm:"column:bigId"`
  28. Brand string `gorm:"column:brand"`
  29. ContractID int `gorm:"column:contractId"`
  30. ID int `gorm:"column:id"`
  31. Location string `gorm:"column:location"`
  32. Note string `gorm:"column:note"`
  33. PartCode string `gorm:"column:partCode"`
  34. PartID int `gorm:"column:partId"`
  35. PartName string `gorm:"column:partName"`
  36. PartUseID int `gorm:"column:partUseId"`
  37. Price float32 `gorm:"column:price"`
  38. ProviderID int `gorm:"column:providerId"`
  39. ProviderName string `gorm:"column:providerName"`
  40. QuitNumber float32 `gorm:"column:quitNumber"`
  41. Reportery string `gorm:"column:reportery"`
  42. Specification string `gorm:"column:specification"`
  43. SumPrice float32 `gorm:"column:sumPrice"`
  44. Unit string `gorm:"column:unit"`
  45. UseNumber string `gorm:"column:useNumber"`
  46. Dflag int `gorm:"column:dflag"`
  47. RowNumber int `gorm:"column:rowNumber"`
  48. }
  49. func (p *Partquit) ToProofPart() (r *ProofPart) {
  50. r = &ProofPart{
  51. RowNumber: p.RowNumber,
  52. PartCode: p.PartCode,
  53. PartName: p.PartName,
  54. Specification: p.Specification,
  55. PartBrand: p.Brand,
  56. Supplier: p.ProviderName,
  57. Warehouse: p.Location,
  58. ChangeCount: p.QuitNumber,
  59. UnitPrice: p.Price,
  60. TotalPrice: p.SumPrice,
  61. }
  62. return
  63. }
  64. func (p *BigPartquit) NewProof(pa *ProofReq) {
  65. pa.ChargeDate = p.QuitDate.Format("2006-01-02")
  66. pa.ProofCode = p.UseForm
  67. pa.ProofYear = p.QuitDate.Format("2006")
  68. pa.OrderNumberId = p.ID
  69. }
  70. func (p *BigPartquit) NewProofPart() (mps []ProofPart, e error) {
  71. path := " BigPartquit NewProofPart()"
  72. c := util.NewMap("bigid", p.ID)
  73. m := make([]Partquit, 0)
  74. if e = Find(c, &m); e != nil {
  75. e = errors.Wrapf(e, path)
  76. return
  77. }
  78. mps = make([]ProofPart, 0)
  79. mp := new(ProofPart)
  80. for i, v := range m {
  81. mp = v.ToProofPart()
  82. mp.RowNumber = i
  83. mps = append(mps, *mp)
  84. }
  85. return
  86. }