animeic před 2 roky
rodič
revize
ca46d99f91

+ 3 - 4
boxcost/api/bill-purchase-excel.go

@@ -13,9 +13,10 @@ import (
 
 type PurchaseBillExcel struct {
 	Offset int
-	Row    int
 
-	Title string //标题
+	Row int
+
+	Title string
 
 	Excel *excelize.File
 
@@ -54,9 +55,7 @@ func (b *PurchaseBillExcel) drawTitle() error {
 }
 
 func (b *PurchaseBillExcel) drawSubTitles() error {
-
 	b.Row++
-
 	styleLeft, err := b.Excel.NewStyle(&excelize.Style{
 		Alignment: &excelize.Alignment{Horizontal: "left", Vertical: "center"},
 		Font:      &excelize.Font{Size: 11}})

+ 7 - 14
boxcost/api/plan.go

@@ -119,18 +119,15 @@ func DownLoadCompBills(c *gin.Context, apictx *ApiSession) (interface{}, error)
 	}
 
 	// 获取不同类型的单据id
-	// set := make(map[int]map[primitive.ObjectID]struct{})
 	billIds := make([]string, 0)
 	for _, stage := range curComp.Stages {
-		_billId := stage.BillId
-
-		billId, _ := primitive.ObjectIDFromHex(_billId)
+		billId, _ := primitive.ObjectIDFromHex(stage.BillId)
 		if !billId.IsZero() {
-			// set[stage.Type] = map[primitive.ObjectID]struct{}{billId: struct{}{}}
 			billIds = append(billIds, fmt.Sprintf("%d_%s", stage.BillType, stage.BillId))
-
 		}
 	}
+
+	// 去重单据号
 	typeBillIds := removeDuplicationSort(billIds)
 	if len(typeBillIds) < 1 {
 		return nil, errors.New("未找到单据信息")
@@ -146,7 +143,6 @@ func DownLoadCompBills(c *gin.Context, apictx *ApiSession) (interface{}, error)
 		tidArr := strings.Split(tId, "_")
 
 		var billExcel IExcel
-
 		// 采购
 		billId, _ := primitive.ObjectIDFromHex(tidArr[1])
 		if tidArr[0] == "1" {
@@ -163,7 +159,7 @@ func DownLoadCompBills(c *gin.Context, apictx *ApiSession) (interface{}, error)
 						repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
 							CollectName: repo.CollectionSignature,
 							Query:       repo.Map{"_id": bson.M{"$in": purchase.SignUsers}},
-							Sort:        bson.M{"sort": 1}, // 升序
+							Sort:        bson.M{"sort": 1},
 						}, &signs)
 						billExcel.SetSignatures(signs)
 					}
@@ -189,7 +185,7 @@ func DownLoadCompBills(c *gin.Context, apictx *ApiSession) (interface{}, error)
 						repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
 							CollectName: repo.CollectionSignature,
 							Query:       repo.Map{"_id": bson.M{"$in": produce.SignUsers}},
-							Sort:        bson.M{"sort": 1}, // 升序
+							Sort:        bson.M{"sort": 1},
 						}, &signs)
 						billExcel.SetSignatures(signs)
 					}
@@ -215,7 +211,7 @@ func DownLoadCompBills(c *gin.Context, apictx *ApiSession) (interface{}, error)
 						repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
 							CollectName: repo.CollectionSignature,
 							Query:       repo.Map{"_id": bson.M{"$in": product.SignUsers}},
-							Sort:        bson.M{"sort": 1}, // 升序
+							Sort:        bson.M{"sort": 1},
 						}, &signs)
 						billExcel.SetSignatures(signs)
 					}
@@ -228,10 +224,8 @@ func DownLoadCompBills(c *gin.Context, apictx *ApiSession) (interface{}, error)
 		if billExcel == nil {
 			continue
 		}
-		// download?id=63f70cbbf72d8f1253ccbb4d&compId=1676975264366
 		billExcel.SetRow(row)
 		billExcel.Draws()
-		fmt.Println(billExcel.GetRow())
 		row = billExcel.GetRow() + 5
 	}
 
@@ -257,7 +251,6 @@ func CreateProductPlan(c *gin.Context, apictx *ApiSession) (interface{}, error)
 		fmt.Println(err)
 		return nil, errors.New("参数错误!")
 	}
-	ctx := apictx.CreateRepoCtx()
 
 	if plan.Name == "" {
 		return nil, errors.New("生产计划名为空")
@@ -270,7 +263,7 @@ func CreateProductPlan(c *gin.Context, apictx *ApiSession) (interface{}, error)
 	plan.CreateTime = time.Now()
 	plan.UpdateTime = time.Now()
 
-	result, err := repo.RepoAddDoc(ctx, repo.CollectionProductPlan, &plan)
+	result, err := repo.RepoAddDoc(apictx.CreateRepoCtx(), repo.CollectionProductPlan, &plan)
 	return result, err
 }
 

+ 8 - 7
boxcost/api/print.go

@@ -1,8 +1,6 @@
 package api
 
 import (
-	"fmt"
-
 	"github.com/gin-gonic/gin"
 )
 
@@ -38,12 +36,15 @@ func Printr(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	// fmt.Println(startTime.Unix())
 	// fmt.Println(endTime.Unix())
 
+	// print
 	// return "success", nil
-	arr := []string{"a", "a", "a", "b", "a", "a", "a", "c", "c", "b"}
-	newArr := removeDuplicationSort(arr)
-	for k, v := range newArr {
-		fmt.Printf("k:%d,v:%s\n", k, v)
-	}
+
+	// 去重
+	// arr := []string{"a", "a", "a", "b", "a", "a", "a", "c", "c", "b"}
+	// newArr := removeDuplicationSort(arr)
+	// for k, v := range newArr {
+	// 	fmt.Printf("k:%d,v:%s\n", k, v)
+	// }
 	return nil, nil
 
 }

+ 3 - 3
boxcost/api/supplier.go

@@ -224,11 +224,11 @@ func GetPlanSuppliers(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	}
 
 	if query["productId"] != nil {
-		processId := query["processId"].(string)
-		if len(processId) < 1 {
+		productId := query["productId"].(string)
+		if len(productId) < 1 {
 			return nil, fmt.Errorf("productId(string)为空")
 		}
-		id, _ := primitive.ObjectIDFromHex(processId)
+		id, _ := primitive.ObjectIDFromHex(productId)
 		ok, list := repo.RepoSeachDocsMap(apictx.CreateRepoCtx(), &repo.DocsSearchOptions{
 			CollectName: repo.CollectionSupplierProductprice,
 			Query:       repo.Map{"productId": id},

+ 0 - 3
boxcost/api/utils.go

@@ -210,9 +210,7 @@ func getCompanyName(apictx *ApiSession) string {
 }
 
 const (
-	// 6 bits to represent a letter index
 	letterIdBits = 6
-	// All 1-bits as many as letterIdBits
 	letterIdMask = 1<<letterIdBits - 1
 	letterIdMax  = 63 / letterIdBits
 	letters      = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
@@ -222,7 +220,6 @@ var src = rand.NewSource(time.Now().UnixNano())
 
 func randName(n int) string {
 	b := make([]byte, n)
-	// A rand.Int63() generates 63 random bits, enough for letterIdMax letters!
 	for i, cache, remain := n-1, src.Int63(), letterIdMax; i >= 0; {
 		if remain == 0 {
 			cache, remain = src.Int63(), letterIdMax