123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- package model
- import (
- "time"
- "github.com/pkg/errors"
- "kpt.xdmy/pkg/util"
- )
- type BigPartUse struct {
- ApplicatID int `gorm:"column:applicatId"`
- DepartmentID int `gorm:"column:departmentId"`
- EmpID int `gorm:"column:empId"`
- FClassID int `gorm:"column:fClassId"`
- ID int `gorm:"column:id"`
- MaintainID int `gorm:"column:maintainId"`
- PastureID int `gorm:"column:pastureId"`
- WorkflowID int `gorm:"column:workflowId"`
- PlanUpkeepID int `gorm:"column:planUpkeepId"`
- SClassID int `gorm:"column:sClassId"`
- ReceiveTime time.Time `gorm:"column:receiveTime"` //'领用时间'
- CreatDate time.Time `gorm:"column:creatDate"`
- FlowworkNote string `gorm:"column:flowworkNote"`
- ListType string `gorm:"column:listType"`
- OddCode string `gorm:"column:oddCode"`
- RefuseStatue int `gorm:"column:refuseStatue"`
- Msg string `gorm:"column:msg"`
- FlowCompeleted int `gorm:"column:flowCompeleted"`
- Issync int `gorm:"column:issync"`
- Note string `gorm:"column:note"`
- SumPrice string `gorm:"column:sumPrice"`
- UseType int `gorm:"column:useType"`
- UseForm string `gorm:"column:useForm"`
- UseStatus int `gorm:"column:useStatus"`
- ProofCode string `gorm:"column:proofCode"`
- }
- type PartUse struct {
- ID int `gorm:"column:id"`
- BigID int `gorm:"column:bigId"`
- BrandID int `gorm:"column:brandId"`
- ContractID int `gorm:"column:contractId"`
- LocationID int `gorm:"column:locationId"`
- MaintainID int `gorm:"column:maintainId"`
- PlanUpkeepID int `gorm:"column:planUpkeepId"`
- PartID int `gorm:"column:partId"`
- ProID int `gorm:"column:proId"`
- EqCode string `gorm:"column:eqCode"`
- EqID int `gorm:"column:eqId"`
- Cpm int `gorm:"column:CPM"`
- CheckoutNumber float32 `gorm:"column:checkoutNumber"` // 出库数量
- EqName string `gorm:"column:eqName"`
- IsRefuse int `gorm:"column:isRefuse"`
- Note string `gorm:"column:note"`
- PartCode string `gorm:"column:partCode"`
- PartName string `gorm:"column:partName"`
- Price float32 `gorm:"column:price"` // 单价
- ProName string `gorm:"column:proName"`
- QuitNumber string `gorm:"column:quitNumber"`
- RefuseNumber int `gorm:"column:refuseNumber"`
- RefuseStatue int `gorm:"column:refuseStatue"`
- Reportery string `gorm:"column:reportery"`
- Specification string `gorm:"column:specification"`
- SumPrice float32 `gorm:"column:sumPrice"` // 总价
- Unit string `gorm:"column:unit"`
- UseNumber string `gorm:"column:useNumber"`
- UseTypeV string `gorm:"column:useTypeV"`
- Dflag int `gorm:"column:dflag"`
- RowNumber int `gorm:"column:rowNumber"`
- }
- func (p *PartUse) ToProofPart() (r *ProofPart, e error) {
- mb := &Brand{ID: p.BrandID}
- mw := &Warehouse{ID: p.LocationID}
- e = First(mb)
- e = First(mw)
- if e != nil {
- e = errors.Wrapf(e, "model PartLaid ToProofPart()")
- return
- }
- r = &ProofPart{
- RowNumber: p.RowNumber,
- PartCode: p.PartCode,
- PartName: p.PartName,
- Specification: p.Specification,
- PartBrand: mb.BrandName,
- Supplier: p.ProName,
- Warehouse: mw.WarehoseCode,
- ChangeCount: p.CheckoutNumber,
- UnitPrice: p.Price,
- TotalPrice: p.SumPrice,
- }
- return
- }
- func (p *BigPartUse) NewProof(pa *ProofReq) {
- pa.ChargeDate = p.ReceiveTime.Format("2006-01-02")
- pa.ProofCode = p.UseForm
- pa.ProofYear = p.ReceiveTime.Format("2006")
- pa.OrderNumberId = p.ID
- }
- func (p *BigPartUse) NewProofPart() (mps []ProofPart, e error) {
- path := " BigPartUse NewProofPart()"
- c := util.NewMap("bigid", p.ID)
- m := make([]PartUse, 0)
- if e = Find(c, &m); e != nil {
- e = errors.Wrapf(e, path)
- return
- }
- mps = make([]ProofPart, 0)
- mp := new(ProofPart)
- for i, v := range m {
- mp, e = v.ToProofPart()
- mp.RowNumber = i
- mps = append(mps, *mp)
- }
- if e != e {
- e = errors.Wrapf(e, path)
- }
- return
- }
|