animeic 2 éve
szülő
commit
9d245ed56e
3 módosított fájl, 65 hozzáadás és 62 törlés
  1. 2 2
      boxcost/api/bill-purchase-excel.go
  2. 62 60
      boxcost/api/supplier.go
  3. 1 0
      boxcost/boxcost.log

+ 2 - 2
boxcost/api/bill-purchase-excel.go

@@ -36,8 +36,8 @@ func (b *PurchaseBillExcel) drawTitle() error {
 	endCell := fmt.Sprintf("J%d", b.Row)
 	marginLeft := excelize.PageMarginLeft(0.2)
 	b.Excel.SetColWidth(b.SheetName, "A", "B", 14)
-	b.Excel.SetColWidth(b.SheetName, "C", "I", 10.5)
-	b.Excel.SetColWidth(b.SheetName, "J", "J", 14)
+	b.Excel.SetColWidth(b.SheetName, "C", "I", 9)
+	b.Excel.SetColWidth(b.SheetName, "J", "J", 24.5)
 	b.Excel.SetPageMargins(b.SheetName, marginLeft)
 	err := b.Excel.MergeCell(b.SheetName, startCell, endCell)
 	if err != nil {

+ 62 - 60
boxcost/api/supplier.go

@@ -11,6 +11,7 @@ import (
 	"github.com/gin-gonic/gin"
 	"go.mongodb.org/mongo-driver/bson"
 	"go.mongodb.org/mongo-driver/bson/primitive"
+	"go.mongodb.org/mongo-driver/mongo/options"
 )
 
 // 供应商管理
@@ -110,6 +111,7 @@ func GetSuppliers(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	return repo.RepoPageSearch(apictx.CreateRepoCtx(), option)
 }
 
+// !暂时弃用
 func GetPlanSuppliers(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	page, size, query := UtilQueryPageSize(c)
 
@@ -169,79 +171,79 @@ func GetPlanSuppliers(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	}
 
 	if query["craftId"] != nil {
-		// cratf := &model.Craft{}
+		cratf := &model.Craft{}
 
-		// ok, _ := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
-		// 	Query:       repo.Map{"_id": query["craftId"].(string)},
-		// 	CollectName: repo.CollectionCraft,
-		// }, cratf)
+		ok, _ := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
+			Query:       repo.Map{"_id": query["craftId"].(string)},
+			CollectName: repo.CollectionCraft,
+		}, cratf)
 
-		// if !ok {
-		// 	return nil, fmt.Errorf("没有对应的工艺信息")
-		// }
+		if !ok {
+			return nil, fmt.Errorf("没有对应的工艺信息")
+		}
 
-		// //查询工艺分类
-		// pipleLine := []bson.M{
-		// 	{
-		// 		"$lookup": bson.M{
-		// 			"from":         repo.CollectionCraft,
-		// 			"localField":   "productId",
-		// 			"foreignField": "_id",
-		// 			"as":           "craft_docs",
-		// 		},
-		// 	},
-		// 	{
-		// 		"$match": bson.M{
-		// 			"craft_docs.0.category": cratf.Category,
-		// 		},
-		// 	},
-		// 	{
-		// 		"$project": bson.M{
-		// 			"craft_docs": 0,
-		// 			"createTime": 0,
-		// 			"price":      0,
-		// 			"productId":  0,
-		// 			"updateTime": 0,
-		// 		},
-		// 	},
-		// }
-		// ctx := apictx.CreateRepoCtx()
+		//查询工艺分类
+		pipleLine := []bson.M{
+			{
+				"$lookup": bson.M{
+					"from":         repo.CollectionCraft,
+					"localField":   "productId",
+					"foreignField": "_id",
+					"as":           "craft_docs",
+				},
+			},
+			{
+				"$match": bson.M{
+					"craft_docs.0.category": cratf.Category,
+				},
+			},
+			{
+				"$project": bson.M{
+					"craft_docs": 0,
+					"createTime": 0,
+					"price":      0,
+					"productId":  0,
+					"updateTime": 0,
+				},
+			},
+		}
+		ctx := apictx.CreateRepoCtx()
 
-		// colls := ctx.Client.GetCollection(repo.CollectionSupplierCraftprice)
+		colls := ctx.Client.GetCollection(repo.CollectionSupplierCraftprice)
 
-		// findoptions := &options.AggregateOptions{}
+		findoptions := &options.AggregateOptions{}
 
-		// cur, err := colls.Aggregate(ctx.Ctx, pipleLine, findoptions)
-		// if err != nil {
-		// 	return nil, err
-		// }
+		cur, err := colls.Aggregate(ctx.Ctx, pipleLine, findoptions)
+		if err != nil {
+			return nil, err
+		}
 
-		// defer cur.Close(ctx.Ctx)
+		defer cur.Close(ctx.Ctx)
 
-		// err = cur.All(ctx.Ctx, &listOut)
+		err = cur.All(ctx.Ctx, &listOut)
 
-		// if err != nil {
-		// 	return nil, err
-		// }
-		// if len(listOut) < 1 {
-		// 	return emtyPage, nil
-		// }
-		// return listOut, nil
-		cratfId := query["cratfId"].(string)
-		if len(cratfId) < 1 {
-			return nil, fmt.Errorf("cratfId(string)为空")
+		if err != nil {
+			return nil, err
 		}
-		id, _ := primitive.ObjectIDFromHex(cratfId)
-		ok, list := repo.RepoSeachDocsMap(apictx.CreateRepoCtx(), &repo.DocsSearchOptions{
-			CollectName: repo.CollectionSupplierCraftprice,
-			Query:       repo.Map{"cratfId": id},
-			Project:     []string{"supplierId"},
-		})
-		if !ok {
+		if len(listOut) < 1 {
 			return emtyPage, nil
 		}
+		return listOut, nil
+		// cratfId := query["craftId"].(string)
+		// if len(cratfId) < 1 {
+		// 	return nil, fmt.Errorf("cratfId(string)为空")
+		// }
+		// id, _ := primitive.ObjectIDFromHex(cratfId)
+		// ok, list := repo.RepoSeachDocsMap(apictx.CreateRepoCtx(), &repo.DocsSearchOptions{
+		// 	CollectName: repo.CollectionSupplierCraftprice,
+		// 	Query:       repo.Map{"craftId": id},
+		// 	Project:     []string{"supplierId"},
+		// })
+		// if !ok {
+		// 	return emtyPage, nil
+		// }
 
-		listOut = list
+		// listOut = list
 	}
 
 	if query["productId"] != nil {

+ 1 - 0
boxcost/boxcost.log

@@ -224,3 +224,4 @@
 {"level":"error","timestamp":"2023-03-10 18:40:55","message":"[Post \"http://localhost:3001/convert/office\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)]","service_name":"boxcost"}
 {"level":"error","timestamp":"2023-03-10 18:40:55","message":"[Post \"http://localhost:3001/convert/office\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)]","service_name":"boxcost"}
 {"level":"error","timestamp":"2023-03-10 18:40:55","message":"[Post \"http://localhost:3001/convert/office\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)]","service_name":"boxcost"}
+{"level":"info","timestamp":"2023-03-24 17:08:54","message":"[<nil>]","service_name":"boxcost"}