kae_mihara e3f6fa236d
feat:improve product yarn ratio workflow (#5)
* feat: support product yarn batches

* feat: improve product yarn ratio workflow

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-07-05 08:06:28 +09:00

55 lines
1.4 KiB
Go

package logic
import (
"context"
"fmt"
"muyu-apiserver/pkg/tenantctx"
"muyu-apiserver/rpc/inventory/internal/svc"
"muyu-apiserver/rpc/inventory/pb"
"github.com/zeromicro/go-zero/core/logx"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
type ListPanViewLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewListPanViewLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListPanViewLogic {
return &ListPanViewLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *ListPanViewLogic) ListPanView(in *pb.ListPanViewReq) (*pb.ListPanViewResp, error) {
tenantId := tenantctx.ExtractTenantId(l.ctx)
list, total, err := l.svcCtx.PanModel.FindPanList(l.ctx, tenantId, in.Page, in.PageSize, in.ProductName, in.Position)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
pbList := make([]*pb.PanListItem, 0, len(list))
for _, item := range list {
pbList = append(pbList, &pb.PanListItem{
PanId: item.PanId,
ProductId: item.ProductId,
BatchId: item.BatchId,
BatchNo: item.BatchNo,
Name: item.Name,
Position: item.Position,
ProductName: item.ProductName,
Colors: item.Colors,
BoltCount: item.BoltCount,
TotalLengthM: fmt.Sprintf("%.2f", item.TotalLengthM),
})
}
return &pb.ListPanViewResp{Total: total, List: pbList}, nil
}