|
@@ -1,6 +1,7 @@
|
|
package model
|
|
package model
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ "fmt"
|
|
"time"
|
|
"time"
|
|
|
|
|
|
pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
|
|
pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
|
|
@@ -62,7 +63,12 @@ func NewEventSaleCowList(pastureId int64, eventSale *EventSale, cowList []*Cow)
|
|
|
|
|
|
type EventSaleCowSlice []*EventSaleCow
|
|
type EventSaleCowSlice []*EventSaleCow
|
|
|
|
|
|
-func (e EventSaleCowSlice) ToPB(eventSaleMap map[int64]*EventSale, cowKindMap map[pasturePb.CowKind_Kind]string) []*pasturePb.AlreadySalesReport {
|
|
|
|
|
|
+func (e EventSaleCowSlice) ToPB(
|
|
|
|
+ eventSaleMap map[int64]*EventSale,
|
|
|
|
+ cowKindMap map[pasturePb.CowKind_Kind]string,
|
|
|
|
+ cowMap map[int64]*Cow,
|
|
|
|
+ sourceMap map[pasturePb.CowSource_Kind]string,
|
|
|
|
+) []*pasturePb.AlreadySalesReport {
|
|
res := make([]*pasturePb.AlreadySalesReport, 0)
|
|
res := make([]*pasturePb.AlreadySalesReport, 0)
|
|
for _, v := range e {
|
|
for _, v := range e {
|
|
cowKindName, saleAtFormat, dealerName := "", "", ""
|
|
cowKindName, saleAtFormat, dealerName := "", "", ""
|
|
@@ -79,6 +85,19 @@ func (e EventSaleCowSlice) ToPB(eventSaleMap map[int64]*EventSale, cowKindMap ma
|
|
dealerName = eventSale.DealerName
|
|
dealerName = eventSale.DealerName
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ feedCycle, cowSourceName := "", ""
|
|
|
|
+ if cowInfo, ok := cowMap[v.CowId]; ok {
|
|
|
|
+ admissionAtFormat := ""
|
|
|
|
+ if cowInfo.AdmissionAt > 0 {
|
|
|
|
+ feedCycle = time.Unix(cowInfo.AdmissionAt, 0).Local().Format(LayoutDate2)
|
|
|
|
+ }
|
|
|
|
+ feedCycle = fmt.Sprintf("%s-%s", admissionAtFormat, saleAtFormat)
|
|
|
|
+
|
|
|
|
+ if name, ok := sourceMap[cowInfo.SourceKind]; ok {
|
|
|
|
+ cowSourceName = name
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
res = append(res, &pasturePb.AlreadySalesReport{
|
|
res = append(res, &pasturePb.AlreadySalesReport{
|
|
CowId: int32(v.CowId),
|
|
CowId: int32(v.CowId),
|
|
EarNumber: v.EarNumber,
|
|
EarNumber: v.EarNumber,
|
|
@@ -91,7 +110,7 @@ func (e EventSaleCowSlice) ToPB(eventSaleMap map[int64]*EventSale, cowKindMap ma
|
|
SaleAvgWeight: saleAvgWeight,
|
|
SaleAvgWeight: saleAvgWeight,
|
|
SaleAllWeight: saleAllWeight,
|
|
SaleAllWeight: saleAllWeight,
|
|
AdmissionAge: v.AdmissionAge,
|
|
AdmissionAge: v.AdmissionAge,
|
|
- CowSourceName: "",
|
|
|
|
|
|
+ CowSourceName: cowSourceName,
|
|
EnterWeight: 0,
|
|
EnterWeight: 0,
|
|
EnterPrice: 0,
|
|
EnterPrice: 0,
|
|
GrowthWeight: 0,
|
|
GrowthWeight: 0,
|
|
@@ -101,6 +120,7 @@ func (e EventSaleCowSlice) ToPB(eventSaleMap map[int64]*EventSale, cowKindMap ma
|
|
OtherCost: 0,
|
|
OtherCost: 0,
|
|
DealerName: dealerName,
|
|
DealerName: dealerName,
|
|
ProfitAndLoss: 0,
|
|
ProfitAndLoss: 0,
|
|
|
|
+ FeedCycle: feedCycle,
|
|
})
|
|
})
|
|
}
|
|
}
|
|
return res
|
|
return res
|