partuse.go 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. package model
  2. import (
  3. "time"
  4. "github.com/pkg/errors"
  5. "kpt.xdmy/pkg/util"
  6. )
  7. type BigPartUse struct {
  8. ApplicatID int `gorm:"column:applicatId"`
  9. DepartmentID int `gorm:"column:departmentId"`
  10. EmpID int `gorm:"column:empId"`
  11. FClassID int `gorm:"column:fClassId"`
  12. ID int `gorm:"column:id"`
  13. MaintainID int `gorm:"column:maintainId"`
  14. PastureID int `gorm:"column:pastureId"`
  15. WorkflowID int `gorm:"column:workflowId"`
  16. PlanUpkeepID int `gorm:"column:planUpkeepId"`
  17. SClassID int `gorm:"column:sClassId"`
  18. ReceiveTime time.Time `gorm:"column:receiveTime"` //'领用时间'
  19. CreatDate time.Time `gorm:"column:creatDate"`
  20. FlowworkNote string `gorm:"column:flowworkNote"`
  21. ListType string `gorm:"column:listType"`
  22. OddCode string `gorm:"column:oddCode"`
  23. RefuseStatue int `gorm:"column:refuseStatue"`
  24. Msg string `gorm:"column:msg"`
  25. FlowCompeleted int `gorm:"column:flowCompeleted"`
  26. Issync int `gorm:"column:issync"`
  27. Note string `gorm:"column:note"`
  28. SumPrice string `gorm:"column:sumPrice"`
  29. UseType int `gorm:"column:useType"`
  30. UseForm string `gorm:"column:useForm"`
  31. UseStatus int `gorm:"column:useStatus"`
  32. ProofCode string `gorm:"column:proofCode"`
  33. }
  34. type PartUse struct {
  35. ID int `gorm:"column:id"`
  36. BigID int `gorm:"column:bigId"`
  37. BrandID int `gorm:"column:brandId"`
  38. ContractID int `gorm:"column:contractId"`
  39. LocationID int `gorm:"column:locationId"`
  40. MaintainID int `gorm:"column:maintainId"`
  41. PlanUpkeepID int `gorm:"column:planUpkeepId"`
  42. PartID int `gorm:"column:partId"`
  43. ProID int `gorm:"column:proId"`
  44. EqCode string `gorm:"column:eqCode"`
  45. EqID int `gorm:"column:eqId"`
  46. Cpm int `gorm:"column:CPM"`
  47. CheckoutNumber float32 `gorm:"column:checkoutNumber"` // 出库数量
  48. EqName string `gorm:"column:eqName"`
  49. IsRefuse int `gorm:"column:isRefuse"`
  50. Note string `gorm:"column:note"`
  51. PartCode string `gorm:"column:partCode"`
  52. PartName string `gorm:"column:partName"`
  53. Price float32 `gorm:"column:price"` // 单价
  54. ProName string `gorm:"column:proName"`
  55. QuitNumber string `gorm:"column:quitNumber"`
  56. RefuseNumber int `gorm:"column:refuseNumber"`
  57. RefuseStatue int `gorm:"column:refuseStatue"`
  58. Reportery string `gorm:"column:reportery"`
  59. Specification string `gorm:"column:specification"`
  60. SumPrice float32 `gorm:"column:sumPrice"` // 总价
  61. Unit string `gorm:"column:unit"`
  62. UseNumber string `gorm:"column:useNumber"`
  63. UseTypeV string `gorm:"column:useTypeV"`
  64. Dflag int `gorm:"column:dflag"`
  65. RowNumber int `gorm:"column:rowNumber"`
  66. }
  67. func (p *PartUse) ToProofPart() (r *ProofPart, e error) {
  68. mb := &Brand{ID: p.BrandID}
  69. mw := &Warehouse{ID: p.LocationID}
  70. e = First(mb)
  71. e = First(mw)
  72. if e != nil {
  73. e = errors.Wrapf(e, "model PartLaid ToProofPart()")
  74. return
  75. }
  76. r = &ProofPart{
  77. RowNumber: p.RowNumber,
  78. PartCode: p.PartCode,
  79. PartName: p.PartName,
  80. Specification: p.Specification,
  81. PartBrand: mb.BrandName,
  82. Supplier: p.ProName,
  83. Warehouse: mw.WarehoseCode,
  84. ChangeCount: p.CheckoutNumber,
  85. UnitPrice: p.Price,
  86. TotalPrice: p.SumPrice,
  87. }
  88. return
  89. }
  90. func (p *BigPartUse) NewProof(pa *ProofReq) {
  91. pa.ChargeDate = p.ReceiveTime.Format("2006-01-02")
  92. pa.ProofCode = p.UseForm
  93. pa.ProofYear = p.ReceiveTime.Format("2006")
  94. pa.OrderNumberId = p.ID
  95. }
  96. func (p *BigPartUse) NewProofPart() (mps []ProofPart, e error) {
  97. path := " BigPartUse NewProofPart()"
  98. c := util.NewMap("bigid", p.ID)
  99. m := make([]PartUse, 0)
  100. if e = Find(c, &m); e != nil {
  101. e = errors.Wrapf(e, path)
  102. return
  103. }
  104. mps = make([]ProofPart, 0)
  105. mp := new(ProofPart)
  106. for i, v := range m {
  107. mp, e = v.ToProofPart()
  108. mp.RowNumber = i
  109. mps = append(mps, *mp)
  110. }
  111. if e != e {
  112. e = errors.Wrapf(e, path)
  113. }
  114. return
  115. }
  116. type BigPartUseStr struct {
  117. ApplicatID interface{} `gorm:"column:applicatId"`
  118. DepartmentID interface{} `gorm:"column:departmentId"`
  119. EmpID interface{} `gorm:"column:empId"`
  120. FClassID interface{} `gorm:"column:fClassId"`
  121. ID interface{} `gorm:"column:id"`
  122. MaintainID interface{} `gorm:"column:maintainId"`
  123. PastureID interface{} `gorm:"column:pastureId"`
  124. WorkflowID interface{} `gorm:"column:workflowId"`
  125. PlanUpkeepID interface{} `gorm:"column:planUpkeepId"`
  126. SClassID interface{} `gorm:"column:sClassId"`
  127. ReceiveTime interface{} `gorm:"column:receiveTime"` //'领用时间'
  128. CreatDate interface{} `gorm:"column:creatDate"`
  129. FlowworkNote interface{} `gorm:"column:flowworkNote"`
  130. ListType interface{} `gorm:"column:listType"`
  131. OddCode interface{} `gorm:"column:oddCode"`
  132. RefuseStatue interface{} `gorm:"column:refuseStatue"`
  133. Msg interface{} `gorm:"column:msg"`
  134. FlowCompeleted interface{} `gorm:"column:flowCompeleted"`
  135. Issync interface{} `gorm:"column:issync"`
  136. Note interface{} `gorm:"column:note"`
  137. SumPrice interface{} `gorm:"column:sumPrice"`
  138. UseType interface{} `gorm:"column:useType"`
  139. UseForm interface{} `gorm:"column:useForm"`
  140. UseStatus interface{} `gorm:"column:useStatus"`
  141. ProofCode interface{} `gorm:"column:proofCode"`
  142. }
  143. type PartUseStr struct {
  144. ID interface{} `gorm:"column:id"`
  145. BigID interface{} `gorm:"column:bigId"`
  146. BrandID interface{} `gorm:"column:brandId"`
  147. ContractID interface{} `gorm:"column:contractId"`
  148. LocationID interface{} `gorm:"column:locationId"`
  149. MaintainID interface{} `gorm:"column:maintainId"`
  150. PlanUpkeepID interface{} `gorm:"column:planUpkeepId"`
  151. PartID interface{} `gorm:"column:partId"`
  152. ProID interface{} `gorm:"column:proId"`
  153. EqCode interface{} `gorm:"column:eqCode"`
  154. EqID interface{} `gorm:"column:eqId"`
  155. Cpm interface{} `gorm:"column:CPM"`
  156. CheckoutNumber interface{} `gorm:"column:checkoutNumber"` // 出库数量
  157. EqName interface{} `gorm:"column:eqName"`
  158. IsRefuse interface{} `gorm:"column:isRefuse"`
  159. Note interface{} `gorm:"column:note"`
  160. PartCode interface{} `gorm:"column:partCode"`
  161. PartName interface{} `gorm:"column:partName"`
  162. Price interface{} `gorm:"column:price"` // 单价
  163. ProName interface{} `gorm:"column:proName"`
  164. QuitNumber interface{} `gorm:"column:quitNumber"`
  165. RefuseNumber interface{} `gorm:"column:refuseNumber"`
  166. RefuseStatue interface{} `gorm:"column:refuseStatue"`
  167. Reportery interface{} `gorm:"column:reportery"`
  168. Specification interface{} `gorm:"column:specification"`
  169. SumPrice interface{} `gorm:"column:sumPrice"` // 总价
  170. Unit interface{} `gorm:"column:unit"`
  171. UseNumber interface{} `gorm:"column:useNumber"`
  172. UseTypeV interface{} `gorm:"column:useTypeV"`
  173. Dflag interface{} `gorm:"column:dflag"`
  174. RowNumber interface{} `gorm:"column:rowNumber"`
  175. }