109 lines
3.1 KiB
Go
Raw Permalink Normal View History

package share
import (
"muyu-apiserver/gateway/internal/types"
"muyu-apiserver/rpc/production/productionservice"
)
func productionPlanInfoFromPB(p *productionservice.ProductionPlanInfo) *types.ProductionPlanInfo {
if p == nil {
return &types.ProductionPlanInfo{}
}
yarnRatios := make([]types.YarnRatioInfo, 0, len(p.YarnRatios))
for _, yr := range p.YarnRatios {
yarnRatios = append(yarnRatios, types.YarnRatioInfo{
RatioId: yr.RatioId,
PlanId: yr.PlanId,
YarnName: yr.YarnName,
Ratio: yr.Ratio,
AmountPerMeter: yr.AmountPerMeter,
TotalAmount: yr.TotalAmount,
CreatedAt: yr.CreatedAt,
})
}
processSteps := make([]types.ProcessStepInfo, 0, len(p.ProcessSteps))
for _, ps := range p.ProcessSteps {
processSteps = append(processSteps, types.ProcessStepInfo{
StepId: ps.StepId,
PlanId: ps.PlanId,
StepType: ps.StepType,
StepOrder: ps.StepOrder,
Status: ps.Status,
OperatorId: ps.OperatorId,
CompletedAt: ps.CompletedAt,
Remark: ps.Remark,
CreatedAt: ps.CreatedAt,
UpdatedAt: ps.UpdatedAt,
})
}
inboundRecords := make([]types.InboundRecordInfo, 0, len(p.InboundRecords))
for _, ir := range p.InboundRecords {
inboundRecords = append(inboundRecords, types.InboundRecordInfo{
RecordId: ir.RecordId,
TenantId: ir.TenantId,
PlanId: ir.PlanId,
ProductId: ir.ProductId,
BatchNo: ir.BatchNo,
Quantity: ir.Quantity,
Rolls: ir.Rolls,
PricePerMeter: ir.PricePerMeter,
OperatorId: ir.OperatorId,
Remark: ir.Remark,
CreatedAt: ir.CreatedAt,
})
}
return &types.ProductionPlanInfo{
PlanId: p.PlanId,
TenantId: p.TenantId,
PlanCode: p.PlanCode,
ProductId: p.ProductId,
ProductName: p.ProductName,
Color: p.Color,
FabricCode: p.FabricCode,
ColorCode: p.ColorCode,
TargetQuantity: p.TargetQuantity,
CompletedQuantity: p.CompletedQuantity,
YarnUsagePerMeter: p.YarnUsagePerMeter,
ProductionPrice: p.ProductionPrice,
SupplierId: p.SupplierId,
Status: p.Status,
Remark: p.Remark,
StartTime: p.StartTime,
Creator: p.Creator,
Operator: p.Operator,
CreatedAt: p.CreatedAt,
UpdatedAt: p.UpdatedAt,
YarnRatios: yarnRatios,
ProcessSteps: processSteps,
InboundRecords: inboundRecords,
}
}
func shareLinkInfoFromPB(s *productionservice.ShareLinkInfo) *types.ShareLinkInfoResp {
if s == nil {
return &types.ShareLinkInfoResp{}
}
return &types.ShareLinkInfoResp{
LinkId: s.LinkId,
TenantId: s.TenantId,
PlanId: s.PlanId,
ShortCode: s.ShortCode,
Token: s.Token,
FactoryType: s.FactoryType,
HideSensitive: s.HideSensitive,
Status: s.Status,
ClickCount: s.ClickCount,
ClickedAt: s.ClickedAt,
RespondedAt: s.RespondedAt,
RejectReason: s.RejectReason,
ExpiresAt: s.ExpiresAt,
CreatedBy: s.CreatedBy,
CreatedAt: s.CreatedAt,
UpdatedAt: s.UpdatedAt,
}
}