Эх сурвалжийг харах

Merge branch 'master' of http://124.70.149.18:10880/waibao_2025/hangzhou_mat_manage

unknown 1 долоо хоног өмнө
parent
commit
30201caad9

+ 1 - 1
pack-sku3d/docker-compose.yaml

@@ -77,7 +77,7 @@ services:
 
   # website api服务
   sku3d-website:
-    image: crpi-tlcs37dul3eo9h1x.cn-hangzhou.personal.cr.aliyuncs.com/lymat/website:v1.1
+    image: registry.cn-chengdu.aliyuncs.com/infish/lymatweb:v1.1
     restart: always
     depends_on:
       - sku3d-bus

+ 55 - 8
sku3d/sku3d/api/a-service-img.go

@@ -28,10 +28,56 @@ func getSerialNum(img *model.MatImage, ctx *repo.RepoSession) (string, error) {
 	catId1 := ""
 	catId2 := ""
 	catId3 := ""
+	cat := &model.Category{
+		CreateTime: time.Now(),
+	}
+	find, err := repo.RepoSeachDoc(ctx, &repo.DocSearchOptions{CollectName: repo.CollectionCategory, Query: repo.Map{}, Project: []string{"name", "type", "children", "createTime"}}, cat)
+	if !find || err != nil {
+		fmt.Println("find category error", err)
+		return "", err
+	}
+	setMap := make(map[string]*model.Category, len(cat.Children)*20)
+	for _, s := range cat.Children {
+		for _, s1 := range s.Children {
+			setMap[s1.IdStr] = s1
+		}
+	}
+	setParentMap := make(map[string]*model.Category, len(cat.Children)*20)
+	for _, s := range cat.Children {
+		for _, s1 := range s.Children {
+			setParentMap[s1.IdStr] = s
+		}
+	}
+
+	for _, v := range img.Categories {
+		c, ok := setMap[v]
+		if !ok {
+			continue
+		}
+		p := setParentMap[v]
+
+		if p.Name == "商品分类" {
+			catId1 = c.CusNum
+			fmt.Println("p name", c.CusNum)
+			continue
+		}
+		if p.Name == "产品系列" {
+			catId2 = c.CusNum
+			continue
+		}
+		if p.Name == "产品用途" {
+			catId3 = c.CusNum
+		}
+	}
+
+	if len(catId1) < 1 || len(catId2) < 1 || len(catId3) < 1 {
+		fmt.Println("cat err", catId1, catId2, catId3)
+		return "", NewError("商品分类/产品系列/产品用途为空")
+	}
+
 	filter := bson.M{
-		"catId1": "",
-		"catId2": "",
-		"catId3": "",
+		"catId1": catId1,
+		"catId2": catId2,
 	}
 
 	update := bson.M{
@@ -39,8 +85,6 @@ func getSerialNum(img *model.MatImage, ctx *repo.RepoSession) (string, error) {
 		"$setOnInsert": bson.M{
 			"catId1": catId1,
 			"catId2": catId2,
-			"catId3": catId3,
-			"next":   1, // 初始值
 		},
 	}
 
@@ -50,11 +94,12 @@ func getSerialNum(img *model.MatImage, ctx *repo.RepoSession) (string, error) {
 
 	var result model.SerialNumer
 	col := ctx.Client.GetCollection(repo.CollectionSerialNos)
-	err := col.FindOneAndUpdate(ctx.Ctx, filter, update, opts).Decode(&result)
+	err = col.FindOneAndUpdate(ctx.Ctx, filter, update, opts).Decode(&result)
 	if err != nil {
+		fmt.Println("get SerialNumer error", err)
 		return "", fmt.Errorf("failed to get next serial number: %v", err)
 	}
-	return fmt.Sprintf("%s%s%d%s", "1", "2", result.Next, "3"), nil
+	return fmt.Sprintf("%s%s%03d%s", catId1, catId2, result.Next, catId3), nil
 }
 
 func UpdateImage(c *gin.Context, apictx *ApiSession) (interface{}, error) {
@@ -129,7 +174,7 @@ func SearchByFields(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 		Size:        size,
 		Query:       query,
 		// Project:     []string{"nameCn", "createTime", "thumbnail", "price", "from"},
-		// Sort: bson.M{"_id"},
+		Sort: bson.M{"createTime": -1},
 	}
 	return repo.RepoPageSearch(apictx.CreateRepoCtx(), pageOption)
 }
@@ -146,9 +191,11 @@ func createImg(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	data.UserId, _ = primitive.ObjectIDFromHex(apictx.User.ID)
 	serial, err := getSerialNum(data, apictx.CreateRepoCtx())
 	if err != nil {
+		fmt.Println(err)
 		return nil, NewError("编号生成失败")
 	}
 	data.CusNum = serial
+	fmt.Println("CusNum=>", serial)
 
 	idstr, err := repo.RepoAddDoc(apictx.CreateRepoCtx(), repo.CollectionMatImages, data)
 	if err != nil {

+ 1 - 1
sku3d/sku3d/app.yaml

@@ -3,7 +3,7 @@ port: 7902
 
 nats:
   # url: nats://124.71.139.24:14223
-  url: nats://47.96.90.34:14223
+  url: nats://comm-bus:4222
   maxReconnect: 1000
   reconnDelaySecond: 5
   renderStreamTopic: sku3drender-req-stream#sku3drender.request#sku3drender-queue

+ 2 - 2
sku3d/sku3d/build.sh

@@ -3,10 +3,10 @@
 # 编译应用
 echo "building..."
 
-go build -o sku3dweb-service
+GOOS=linux GOARCH=amd64 go build -o sku3dweb-service
 
 # 设置变量
-IMAGE_NAME="crpi-tlcs37dul3eo9h1x.cn-hangzhou.personal.cr.aliyuncs.com/lymat/website"
+IMAGE_NAME="registry.cn-chengdu.aliyuncs.com/infish/lymatweb"
 VERSION="v1.1"
 
 # 构建 Docker 镜像

+ 44 - 44
sku3d/sku3d/db/model/a-matimage.go

@@ -36,56 +36,56 @@ type SerialNumer struct {
 
 type MatImage struct {
 	Id           primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	UserId       primitive.ObjectID `bson:"userId,omitempty" json:"userId,omitempty"`   // 用户Id
-	Thumbnail    *OssType           `bson:"thumbnail,omitempty" json:"thumbnail"`       // 封面图
-	RawImage     *OssType           `bson:"rawImage,omitempty" json:"rawImage"`         // 原始大图
-	ProductImage *OssType           `bson:"productImage,omitempty" json:"productImage"` // 商品图片
-
+	UserId       primitive.ObjectID `bson:"userId,omitempty" json:"userId,omitempty"`         // 用户Id
+	Thumbnail    *OssType           `bson:"thumbnail,omitempty" json:"thumbnail"`             // 封面图
+	RawImage     *OssType           `bson:"rawImage,omitempty" json:"rawImage"`               // 原始大图
+	ProductImage *OssType           `bson:"productImage,omitempty" json:"productImage"`       // 商品图片
+	CreateTime   time.Time          `bson:"createTime,omitempty" json:"createTime,omitempty"` // 创建日期
 	// 商品信息
-	CusNum         string    `bson:"cusNum,omitempty" json:"cusNum"`                 // 公司商品编号(格式:分类编号+产品系列+3位流水号+产品用途)
-	From           string    `bson:"from,omitempty" json:"from"`                     // 来源(样品收集人)
-	TypeCategory   string    `bson:"typeCategory,omitempty" json:"typeCategory"`     // 种类分类
-	TaxNameCN      string    `bson:"taxNameCn,omitempty" json:"taxNameCn"`           // 报关商品中文名(必填)
-	CreateTime     time.Time `bson:"createTime,omitempty" json:"createTime"`         // 开发日期
-	Categories     []string  `bson:"categories,omitempty" json:"categories"`         // 商品分类(如:革PVC、布坯类等)
-	BaseCloth      string    `bson:"baseCloth,omitempty" json:"baseCloth"`           // 基布
-	SampleNumber   string    `bson:"sampleNumber,omitempty" json:"sampleNumber"`     // 样品编号
-	NameCN         string    `bson:"nameCn,omitempty" json:"nameCn"`                 // 商品中文名
-	ProductSeries  string    `bson:"productSeries,omitempty" json:"productSeries"`   // 产品系列
-	SurfaceProcess string    `bson:"surfaceProcess,omitempty" json:"surfaceProcess"` // 表面工艺
-	CatalogNumber  string    `bson:"catalogNumber,omitempty" json:"catalogNumber"`   // 留样册号
-	NameEN         string    `bson:"nameEn,omitempty" json:"nameEn"`                 // 商品英文名
-	ProductUsage   string    `bson:"productUsage,omitempty" json:"productUsage"`     // 产品用途
-	MnemonicSign   string    `bson:"mnemonicSign,omitempty" json:"mnemonicSign"`     // 报关助记符
-	UnitGroup      string    `bson:"unitGroup,omitempty" json:"unitGroup"`           // 计量单位组
-	OriginalNumber string    `bson:"originalNumber,omitempty" json:"originalNumber"` // 原命名编号
-	TaxGoodsNumber string    `bson:"taxGoodsNumber,omitempty" json:"taxGoodsNumber"` // 报关商品编号
+	CusNum         string    `bson:"cusNum,omitempty" json:"cusNum,omitempty"`                 // 公司商品编号(格式:分类编号+产品系列+3位流水号+产品用途)
+	From           string    `bson:"from,omitempty" json:"from,omitempty"`                     // 来源(样品收集人)
+	TypeCategory   string    `bson:"typeCategory,omitempty" json:"typeCategory,omitempty"`     // 种类分类
+	TaxNameCN      string    `bson:"taxNameCn,omitempty" json:"taxNameCn,omitempty"`           // 报关商品中文名(必填)
+	DevTime        time.Time `bson:"devTime,omitempty" json:"devTime,omitempty"`               // 开发日期
+	Categories     []string  `bson:"categories,omitempty" json:"categories,omitempty"`         // 商品分类(如:革PVC、布坯类等)
+	BaseCloth      string    `bson:"baseCloth,omitempty" json:"baseCloth,omitempty"`           // 基布
+	SampleNumber   string    `bson:"sampleNumber,omitempty" json:"sampleNumber,omitempty"`     // 样品编号
+	NameCN         string    `bson:"nameCn,omitempty" json:"nameCn,omitempty"`                 // 商品中文名
+	ProductSeries  string    `bson:"productSeries,omitempty" json:"productSeries,omitempty"`   // 产品系列
+	SurfaceProcess string    `bson:"surfaceProcess,omitempty" json:"surfaceProcess,omitempty"` // 表面工艺
+	CatalogNumber  string    `bson:"catalogNumber,omitempty" json:"catalogNumber,omitempty"`   // 留样册号
+	NameEN         string    `bson:"nameEn,omitempty" json:"nameEn,omitempty"`                 // 商品英文名
+	ProductUsage   string    `bson:"productUsage,omitempty" json:"productUsage,omitempty"`     // 产品用途
+	MnemonicSign   string    `bson:"mnemonicSign,omitempty" json:"mnemonicSign,omitempty"`     // 报关助记符
+	UnitGroup      string    `bson:"unitGroup,omitempty" json:"unitGroup,omitempty"`           // 计量单位组
+	OriginalNumber string    `bson:"originalNumber,omitempty" json:"originalNumber,omitempty"` // 原命名编号
+	TaxGoodsNumber string    `bson:"taxGoodsNumber,omitempty" json:"taxGoodsNumber,omitempty"` // 报关商品编号
 
 	// 商品厂家信息
-	SupplierID     string `bson:"supplierId,omitempty" json:"supplierId"`         // 供应商编号
-	MainSupplier   string `bson:"mainSupplier,omitempty" json:"mainSupplier"`     // 首选供应商
-	Price          int    `bson:"price,omitempty" json:"price"`                   // 价格(默认采购单价,单位:分)
-	MainUnit       string `bson:"mainUnit,omitempty" json:"mainUnit"`             // 主计量单位
-	OperationCycle string `bson:"operationCycle,omitempty" json:"operationCycle"` // 运营周期
+	SupplierID     string `bson:"supplierId,omitempty" json:"supplierId,omitempty"`         // 供应商编号
+	MainSupplier   string `bson:"mainSupplier,omitempty" json:"mainSupplier,omitempty"`     // 首选供应商
+	Price          int    `bson:"price,omitempty" json:"price,omitempty"`                   // 价格(默认采购单价,单位:分)
+	MainUnit       string `bson:"mainUnit,omitempty" json:"mainUnit,omitempty"`             // 主计量单位
+	OperationCycle string `bson:"operationCycle,omitempty" json:"operationCycle,omitempty"` // 运营周期
 
 	// 商品属性
-	ExportProperty     *bool `bson:"exportProperty,omitempty" json:"exportProperty"`         // 出口属性
-	DomesticProperty   *bool `bson:"domesticProperty,omitempty" json:"domesticProperty"`     // 内销属性
-	InpurchaseProperty *bool `bson:"inpurchaseProperty,omitempty" json:"inpurchaseProperty"` // 内购属性
-	OutsourcedProperty *bool `bson:"outsourcedProperty,omitempty" json:"outsourcedProperty"` // 委外属性
+	ExportProperty     *bool `bson:"exportProperty,omitempty" json:"exportProperty,omitempty"`         // 出口属性
+	DomesticProperty   *bool `bson:"domesticProperty,omitempty" json:"domesticProperty,omitempty"`     // 内销属性
+	InpurchaseProperty *bool `bson:"inpurchaseProperty,omitempty" json:"inpurchaseProperty,omitempty"` // 内购属性
+	OutsourcedProperty *bool `bson:"outsourcedProperty,omitempty" json:"outsourcedProperty,omitempty"` // 委外属性
 
 	// 体积重量
-	Thickness          int     `bson:"thickness,omitempty" json:"thickness"`                   // 厚度/高(单位:MM)
-	PackageGrossWeight float64 `bson:"packageGrossWeight,omitempty" json:"packageGrossWeight"` // 单位包材毛重(单位:KG)
-	PhyWidth           int     `bson:"phyWidth,omitempty" json:"phyWidth"`                     // 物理尺寸宽度(门幅/宽,单位:MM)
-	ProductVolume      float64 `bson:"productVolume,omitempty" json:"productVolume"`           // 商品单位体积
-	PhyHeight          int     `bson:"phyHeight,omitempty" json:"phyHeight"`                   // 物理尺寸高度(长度,单位:MM)
-	SurfaceWeight      float64 `bson:"surfaceWeight,omitempty" json:"surfaceWeight"`           // 面布克重
-	ProductWeight      float64 `bson:"productWeight,omitempty" json:"productWeight"`           // 产品克重(单位:KG)
-	BackingWeight      float64 `bson:"backingWeight,omitempty" json:"backingWeight"`           // 底布克重(单位:KG)
-	PackageVolume      float64 `bson:"packageVolume,omitempty" json:"packageVolume"`           // 单位包材体积(单位:CBM)
-	Remarks            string  `bson:"remarks,omitempty" json:"remarks"`                       // 备注
-	FitMarket          string  `bson:"fitMarket,omitempty" json:"fitMarket"`                   // 适合市场
+	Thickness          int     `bson:"thickness,omitempty" json:"thickness,omitempty"`                   // 厚度/高(单位:MM)
+	PackageGrossWeight float64 `bson:"packageGrossWeight,omitempty" json:"packageGrossWeight,omitempty"` // 单位包材毛重(单位:KG)
+	PhyWidth           int     `bson:"phyWidth,omitempty" json:"phyWidth,omitempty"`                     // 物理尺寸宽度(门幅/宽,单位:MM)
+	ProductVolume      float64 `bson:"productVolume,omitempty" json:"productVolume,omitempty"`           // 商品单位体积
+	PhyHeight          int     `bson:"phyHeight,omitempty" json:"phyHeight,omitempty"`                   // 物理尺寸高度(长度,单位:MM)
+	SurfaceWeight      float64 `bson:"surfaceWeight,omitempty" json:"surfaceWeight,omitempty"`           // 面布克重
+	ProductWeight      float64 `bson:"productWeight,omitempty" json:"productWeight,omitempty"`           // 产品克重(单位:KG)
+	BackingWeight      float64 `bson:"backingWeight,omitempty" json:"backingWeight,omitempty"`           // 底布克重(单位:KG)
+	PackageVolume      float64 `bson:"packageVolume,omitempty" json:"packageVolume,omitempty"`           // 单位包材体积(单位:CBM)
+	Remarks            string  `bson:"remarks,omitempty" json:"remarks,omitempty"`                       // 备注
+	FitMarket          string  `bson:"fitMarket,omitempty" json:"fitMarket,omitempty"`                   // 适合市场
 
-	UpdateTime time.Time `bson:"updateTime,omitempty" json:"updateTime"`
+	UpdateTime time.Time `bson:"updateTime,omitempty" json:"updateTime,omitempty"`
 }