Browse Source

add supplier plan excel

animeic 2 years ago
parent
commit
722911e737
8 changed files with 1379 additions and 400 deletions
  1. 136 18
      boxcost/api/plan-cost-excel.go
  2. 14 4
      boxcost/api/plan.go
  3. 63 0
      boxcost/api/print_test.go
  4. 0 1
      boxcost/api/router.go
  5. 0 17
      boxcost/api/test_print.go
  6. 338 326
      boxcost/api/tmp.json
  7. 20 22
      boxcost/go.mod
  8. 808 12
      boxcost/go.sum

+ 136 - 18
boxcost/api/plan-cost-excel.go

@@ -1,10 +1,10 @@
 package api
 
 import (
-	"box-cost/db/model"
 	"fmt"
 
 	"github.com/xuri/excelize/v2"
+	"go.mongodb.org/mongo-driver/bson/primitive"
 )
 
 // 生产成本表
@@ -19,7 +19,8 @@ type PlanCostExcel struct {
 
 	AlignCenterStyle int
 
-	Content *model.ProductPlan
+	// Content *model.ProductPlan
+	Content *SupplierPlanCost
 }
 
 func (b *PlanCostExcel) drawTitle() error {
@@ -146,27 +147,140 @@ func (b *PlanCostExcel) drawTableTitle() error {
 	return nil
 }
 
-func (b *PlanCostExcel) drawTableContent() error {
+func (b *PlanCostExcel) drawSupplierContent() error {
+	supplierId, err := primitive.ObjectIDFromHex(b.Content.SupplierId)
+	if err != nil {
+		return err
+	}
 	row := b.Offset + 4
+	comps := b.Content.Pack.Components
+	var totalPlanPrice float32 = 0.00
+	if len(comps) > 0 {
+		for _, comp := range comps {
+			var totalOrderRealPrice float32 = 0.00
+			if len(comp.Mats) > 0 {
+				startRow := 0
+				for _, mat := range comp.Mats {
+					if mat.Supplier.SupplierInfo != nil {
+						if supplierId == mat.Supplier.SupplierInfo.Id {
+							// 材料
+							startRow = row
+							supplierName := mat.Supplier.SupplierInfo.Name
+							matHeigth := fmt.Sprintf("%d", mat.BatchSizeHeight)
+							b.FormatToEmpty(&matHeigth)
+							matWidth := fmt.Sprintf("%d", mat.BatchSizeWidth)
+							b.FormatToEmpty(&matWidth)
+							orderCount := fmt.Sprintf("%d", int(mat.Supplier.OrderCount))
+							b.FormatToEmpty(&orderCount)
+							orderPrice := fmt.Sprintf("%.2f", mat.Supplier.OrderPrice)
+							b.FormatToEmpty(&orderPrice)
+							totalOrderRealPrice += mat.Supplier.OrderRealPrice
+							orderRealPrice := fmt.Sprintf("%.2f", mat.Supplier.OrderRealPrice)
+
+							b.FormatToEmpty(&orderRealPrice)
+							b.drawRow(row, "", mat.MatInfo.Name, "", supplierName, mat.MatInfo.Norm, matHeigth, matWidth, mat.MatInfo.Unit, orderCount, orderPrice, orderRealPrice, "")
+							row++
+						}
+
+					}
+
+					if len(mat.Crafts) > 0 {
+						for _, craft := range mat.Crafts {
+							if craft.Supplier.SupplierInfo != nil {
+								// 工序
+								if supplierId == craft.Supplier.SupplierInfo.Id {
+									startRow = row
+									craftSupplierName := craft.Supplier.SupplierInfo.Name
+									carftOrderCount := fmt.Sprintf("%d", int(craft.Supplier.OrderCount))
+									b.FormatToEmpty(&carftOrderCount)
+									carftHeigth := fmt.Sprintf("%d", craft.BatchSizeHeight)
+									b.FormatToEmpty(&carftHeigth)
+									carftWidth := fmt.Sprintf("%d", craft.BatchSizeWidth)
+									b.FormatToEmpty(&carftWidth)
+									carftOrderPrice := fmt.Sprintf("%.2f", craft.Supplier.OrderPrice)
+									b.FormatToEmpty(&carftOrderPrice)
+									totalOrderRealPrice += craft.Supplier.OrderRealPrice
+									carftOrderRealPrice := fmt.Sprintf("%.2f", craft.Supplier.OrderRealPrice)
+									b.FormatToEmpty(&carftOrderRealPrice)
+									b.drawRow(row, "", "", craft.CraftInfo.Name, craftSupplierName, craft.CraftInfo.Norm, carftHeigth, carftWidth, craft.CraftInfo.Unit, carftOrderCount, carftOrderPrice, carftOrderRealPrice, "")
+									row++
+
+								}
+
+							}
+
+						}
+					}
+				}
+				if startRow != 0 {
+					endRow := row - 1
+					// 组件名字
+					startACell := fmt.Sprintf("%s%d", "A", startRow)
+					endACell := fmt.Sprintf("%s%d", "A", endRow)
+					b.Excel.MergeCell(b.SheetName, startACell, endACell)
+
+					err := b.Excel.SetCellStyle(b.SheetName, startACell, endACell, b.AlignCenterStyle)
+					if err != nil {
+						return err
+					}
+					b.Excel.SetCellValue(b.SheetName, startACell, comp.Name)
+					// 供应商组件汇总金额
+					startLCell := fmt.Sprintf("%s%d", "L", startRow)
+					endLCell := fmt.Sprintf("%s%d", "L", endRow)
+					b.Excel.MergeCell(b.SheetName, startLCell, endLCell)
+					err = b.Excel.SetCellStyle(b.SheetName, startLCell, endLCell, b.AlignCenterStyle)
+					if err != nil {
+						return err
+					}
+					compTotalPrice := fmt.Sprintf("%.2f", totalOrderRealPrice)
+					b.FormatToEmpty(&compTotalPrice)
+					b.Excel.SetCellValue(b.SheetName, startLCell, compTotalPrice)
+
+				}
 
-	var DrawRow = func(rowIndex int, values ...string) {
-		charas := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"}
-		for i, c := range charas {
-			v := ""
-			if i < len(values) {
-				v = values[i]
 			}
-			b.Excel.SetCellValue(b.SheetName, fmt.Sprintf("%s%d", c, rowIndex), v)
+			totalPlanPrice += totalOrderRealPrice
+		}
+		// 生产汇总金额
+		startACell := fmt.Sprintf("%s%d", "A", row)
+		endKCell := fmt.Sprintf("%s%d", "K", row)
+		endLCell := fmt.Sprintf("%s%d", "L", row)
+		b.Excel.MergeCell(b.SheetName, startACell, endKCell)
+		b.Excel.SetCellStyle(b.SheetName, startACell, endKCell, b.AlignCenterStyle)
+		b.Excel.SetCellValue(b.SheetName, startACell, "生产计划汇总金额")
 
-			val2Cel := fmt.Sprintf("%s%d", c, rowIndex)
-			b.Excel.SetCellStyle(b.SheetName, val2Cel, val2Cel, b.AlignCenterStyle)
+		b.Excel.SetCellStyle(b.SheetName, endLCell, endLCell, b.AlignCenterStyle)
+		planTotalPrice := fmt.Sprintf("%.2f", totalPlanPrice)
+		b.FormatToEmpty(&planTotalPrice)
+		b.Excel.SetCellValue(b.SheetName, endLCell, planTotalPrice)
 
-			b.Excel.SetRowHeight(b.SheetName, rowIndex, 21)
+	}
+
+	return nil
+}
+
+func (b *PlanCostExcel) drawRow(rowIndex int, values ...string) {
+	charas := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"}
+	for i, c := range charas {
+		v := ""
+		if i < len(values) {
+			v = values[i]
 		}
+		b.Excel.SetCellValue(b.SheetName, fmt.Sprintf("%s%d", c, rowIndex), v)
+
+		val2Cel := fmt.Sprintf("%s%d", c, rowIndex)
+		b.Excel.SetCellStyle(b.SheetName, val2Cel, val2Cel, b.AlignCenterStyle)
+
+		b.Excel.SetRowHeight(b.SheetName, rowIndex, 21)
 	}
+
+}
+
+func (b *PlanCostExcel) drawAllContent() error {
+	row := b.Offset + 4
+
 	comps := b.Content.Pack.Components
 	if len(comps) > 0 {
-		// row1 := row
 		for _, comp := range comps {
 			if len(comp.Mats) > 0 {
 				startRow := row
@@ -175,7 +289,6 @@ func (b *PlanCostExcel) drawTableContent() error {
 					supplierName := ""
 					if mat.Supplier.SupplierInfo != nil {
 						supplierName = mat.Supplier.SupplierInfo.Name
-
 					}
 					matHeigth := fmt.Sprintf("%d", mat.BatchSizeHeight)
 					b.FormatToEmpty(&matHeigth)
@@ -188,7 +301,7 @@ func (b *PlanCostExcel) drawTableContent() error {
 
 					orderRealPrice := fmt.Sprintf("%.2f", mat.Supplier.OrderRealPrice)
 					b.FormatToEmpty(&orderRealPrice)
-					DrawRow(row, "", mat.MatInfo.Name, "", supplierName, mat.MatInfo.Norm, matHeigth, matWidth, mat.MatInfo.Unit, orderCount, orderPrice, orderRealPrice, "")
+					b.drawRow(row, "", mat.MatInfo.Name, "", supplierName, mat.MatInfo.Norm, matHeigth, matWidth, mat.MatInfo.Unit, orderCount, orderPrice, orderRealPrice, "")
 
 					row++
 					if len(mat.Crafts) > 0 {
@@ -209,7 +322,7 @@ func (b *PlanCostExcel) drawTableContent() error {
 							b.FormatToEmpty(&carftOrderPrice)
 							carftOrderRealPrice := fmt.Sprintf("%.2f", craft.Supplier.OrderRealPrice)
 							b.FormatToEmpty(&carftOrderRealPrice)
-							DrawRow(row, "", "", craft.CraftInfo.Name, craftSupplierName, craft.CraftInfo.Norm, carftHeigth, carftWidth, craft.CraftInfo.Unit, carftOrderCount, carftOrderPrice, carftOrderRealPrice, "")
+							b.drawRow(row, "", "", craft.CraftInfo.Name, craftSupplierName, craft.CraftInfo.Norm, carftHeigth, carftWidth, craft.CraftInfo.Unit, carftOrderCount, carftOrderPrice, carftOrderRealPrice, "")
 							row++
 
 						}
@@ -260,7 +373,12 @@ func (b *PlanCostExcel) drawTableContent() error {
 func (b *PlanCostExcel) Draws() {
 	b.drawTitle()
 	b.drawTableTitle()
-	b.drawTableContent()
+	if b.Content.SupplierId != "" {
+		b.drawSupplierContent()
+	} else {
+		b.drawAllContent()
+	}
+
 }
 
 func NewPlanCostExcel(f *excelize.File) *PlanCostExcel {

+ 14 - 4
boxcost/api/plan.go

@@ -40,12 +40,20 @@ func ProductPlan(r *GinRouter) {
 
 }
 
+type SupplierPlanCost struct {
+	*model.ProductPlan
+	SupplierId string
+}
+
 func DownLoadPlanCost(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	_planId := c.Query("id")
+	supplierId := c.Query("supplierId")
 	planId, err := primitive.ObjectIDFromHex(_planId)
 	if err != nil {
 		return nil, errors.New("planId错误")
 	}
+	supplierPlanCost := &SupplierPlanCost{}
+
 	plan := model.ProductPlan{}
 	found, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
 		CollectName: repo.CollectionProductPlan,
@@ -54,19 +62,21 @@ func DownLoadPlanCost(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	if !found || err != nil {
 		return nil, errors.New("数据未找到")
 	}
+	supplierPlanCost.ProductPlan = &plan
+	supplierPlanCost.SupplierId = supplierId
 
 	f := excelize.NewFile()
 	index := f.NewSheet("Sheet1")
 	f.SetActiveSheet(index)
 	f.SetDefaultFont("宋体")
 	planCostExcel := NewPlanCostExcel(f)
-	planCostExcel.Content = &plan
 	planCostExcel.Title = fmt.Sprintf("生产成本表(%s)%d盒", plan.Name, plan.Total)
+	planCostExcel.Content = supplierPlanCost
 	planCostExcel.Draws()
 
-	// 另存为
-	// _ = os.MkdirAll("excel", os.ModePerm)
-	// filename1 := time.Now().Format("20060102150405") + ".xlsx"
+	// // 另存为
+	// // _ = os.MkdirAll("excel", os.ModePerm)
+	// // filename1 := time.Now().Format("20060102150405") + ".xlsx"
 	// filename1 := "生产成本表.xlsx"
 	// err = f.SaveAs(filename1)
 	// if err != nil {

+ 63 - 0
boxcost/api/print_test.go

@@ -0,0 +1,63 @@
+package api
+
+import (
+	"testing"
+)
+
+func TestFib(t *testing.T) {
+	var (
+		in       = 7
+		expected = 13
+	)
+	actual := Fib(in)
+	if actual != expected {
+		t.Errorf("-----")
+	}
+	t.Logf("%s", "sucess")
+}
+
+func Fib(n int) int {
+	if n < 2 {
+		return n
+	}
+	return Fib(n-1) + Fib(n-2)
+}
+
+// func BenchmarkHello(b *testing.B) {
+// 	for i := 0; 1 < b.N; i++ {
+// 		fmt.Sprintf("hello")
+// 	}
+// }
+
+// func BenchmarkFib10(b *testing.B) {
+
+//		for n := 0; n < b.N; n++ {
+//			Fib(10)
+//		}
+//	}
+func BenchmarkFib1(b *testing.B) {
+	benchmarkFib(1, b)
+}
+func BenchmarkFib2(b *testing.B) {
+	benchmarkFib(2, b)
+}
+func BenchmarkFib3(b *testing.B) {
+
+	benchmarkFib(3, b)
+}
+func BenchmarkFib10(b *testing.B) {
+	benchmarkFib(10, b)
+}
+func BenchmarkFib20(b *testing.B) {
+	benchmarkFib(20, b)
+}
+func BenchmarkFib40(b *testing.B) {
+	benchmarkFib(40, b)
+}
+
+func benchmarkFib(i int, b *testing.B) {
+	b.ReportAllocs()
+	for n := 0; n < b.N; n++ {
+		Fib(i)
+	}
+}

+ 0 - 1
boxcost/api/router.go

@@ -11,7 +11,6 @@ func RegRouters(svc *Service) {
 
 	boxcost := svc.NewGinRouter("/" + svc.Conf.Name)
 	boxcost.group.Use(Logger())
-	boxcost.GET("/printr", Printr)
 
 	//数据存储
 	boxcost.POST("/save/policy", ServiceObsUploadPolicy)

+ 0 - 17
boxcost/api/test_print.go

@@ -1,17 +0,0 @@
-package api
-
-import (
-	"time"
-
-	"github.com/gin-gonic/gin"
-)
-
-func Printr(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-
-	// id, _ := primitive.ObjectIDFromHex("638edc9ac3242a12b462efce")
-	// return searchBillTypeById(apictx, repo.CollectionBillProduce, id)
-	// return generateSerial(apictx, "纸张类")
-	now := time.Now()
-	return now.Local().Format("2006年01月02号 15:04:05"), nil
-
-}

+ 338 - 326
boxcost/api/tmp.json

@@ -1,335 +1,347 @@
 {
-  "errorNo": 200,
-  "result": {
-    "_id": "63904fb753445de55269103b",
-    "name": "测试",
-    "pack": {
-      "_id": "638f108e0027470dd3a42f64",
-      "name": "测试包装",
-      "thumbnail": "",
-      "compCounts": 1,
-      "designer": "1232",
-      "components": [
-        {
-          "id": "638f108e0027470dd3a42f60",
-          "name": "333",
-          "thumbnail": "",
-          "count": 1,
-          "uv": "",
-          "uvSize": "0",
-          "mats": [
-            {
-              "id": "1672128617843638eedb2f9039e0980fe5653",
-              "crafts": [
-                {
-                  "id": "16721286489396388430851ba5b3307f8ab600",
-                  "size": "0",
-                  "count": 1,
-                  "craftInfo": {
-                    "_id": "6388430851ba5b3307f8ab60",
-                    "name": "光膜",
-                    "unit": "平方米",
-                    "price": 0.4,
-                    "norm": "按文件要求",
-                    "remark": "",
-                    "createTime": "2022-12-01T06:00:40.068Z",
-                    "updateTime": "2022-12-01T06:00:40.068Z",
-                    "category": "覆膜"
-                  },
-                  "supplier": {
-                    "calc": null,
-                    "deliveryTime": "2022-12-27T08:11:03Z",
-                    "orderPrice": 0,
-                    "orderCount": 3000,
-                    "orderRealPrice": 0,
-                    "supplierInfo": null
-                  },
-                  "batchCount": 1,
-                  "batchSizeWidth": 0,
-                  "batchSizeHeight": 0,
-                  "billId": "",
-                  "remark": ""
-                }
-              ],
-              "matInfo": {
-                "_id": "638eedb2f9039e0980fe5653",
-                "name": "太阳白卡",
-                "category": "纸张类",
-                "price": 5400,
-                "unit": "吨",
-                "norm": "250g",
-                "height": 0,
-                "width": 0,
-                "remark": "",
-                "createTime": "2022-12-06T07:22:26.375Z",
-                "updateTime": "2022-12-06T07:24:48.591Z"
-              },
-              "supplier": {
-                "calc": null,
-                "deliveryTime": "2022-12-27T08:11:03Z",
-                "orderPrice": 0,
-                "orderCount": 3000,
-                "orderRealPrice": 0,
-                "supplierInfo": null
-              },
-              "batchCount": 1,
-              "batchSizeWidth": 0,
-              "batchSizeHeight": 0,
-              "billId": "",
-              "remark": ""
+  "_id": "63904fb753445de55269103b",
+  "name": "测试",
+  "pack": {
+    "_id": "638f108e0027470dd3a42f64",
+    "name": "测试包装",
+    "thumbnail": "",
+    "compCounts": 1,
+    "designer": "1232",
+    "components": [
+      {
+        "id": "638f108e0027470dd3a42f60",
+        "name": "333",
+        "thumbnail": "",
+        "count": 1,
+        "uv": "",
+        "uvSize": "0",
+        "mats": [
+          {
+            "id": "1672128617843638eedb2f9039e0980fe5653",
+            "crafts": [
+              {
+                "id": "16721286489396388430851ba5b3307f8ab600",
+                "size": "0",
+                "count": 1,
+                "craftInfo": {
+                  "_id": "6388430851ba5b3307f8ab60",
+                  "name": "光膜",
+                  "unit": "平方米",
+                  "price": 0.4,
+                  "norm": "按文件要求",
+                  "remark": "",
+                  "createTime": "2022-12-01T06:00:40.068Z",
+                  "updateTime": "2022-12-01T06:00:40.068Z",
+                  "category": "覆膜"
+                },
+                "supplier": {
+                  "calc": null,
+                  "deliveryTime": "2022-12-27T08:11:03Z",
+                  "orderPrice": 0,
+                  "orderCount": 3000,
+                  "orderRealPrice": 0,
+                  "supplierInfo": {
+                    "_id": "6388441551ba5b3307f8ab61",
+                    "name": "熊明军",
+                    "address": "金鸡路556",
+                    "phone": "13980871668",
+                    "category": "覆膜",
+                    "createTime": "2022-12-01T06:05:09.079Z",
+                    "updateTime": "2022-12-01T06:05:09.079Z"
+                  }
+                },
+                "batchCount": 1,
+                "batchSizeWidth": 0,
+                "batchSizeHeight": 0,
+                "billId": "63b3961900be5a99e8f7531b",
+                "remark": ""
+              }
+            ],
+            "matInfo": {
+              "_id": "638eedb2f9039e0980fe5653",
+              "name": "太阳白卡",
+              "category": "纸张类",
+              "price": 5400,
+              "unit": "吨",
+              "norm": "250g",
+              "height": 0,
+              "width": 0,
+              "remark": "",
+              "createTime": "2022-12-06T07:22:26.375Z",
+              "updateTime": "2022-12-06T07:24:48.591Z"
             },
-            {
-              "id": "1672128855538638eedb2f9039e0980fe5653",
-              "crafts": [
-                {
-                  "id": "167212855882663846db34d585ba68be6cba30",
-                  "size": "0",
-                  "count": 1,
-                  "craftInfo": {
-                    "_id": "63846db34d585ba68be6cba3",
-                    "name": "哑膜",
-                    "unit": "平方米",
-                    "price": 0.49,
-                    "norm": "按文件要求",
-                    "remark": "",
-                    "createTime": "2022-11-28T08:13:39.864Z",
-                    "updateTime": "2022-11-28T08:13:39.864Z",
-                    "category": "覆膜"
-                  },
-                  "supplier": {
-                    "calc": null,
-                    "deliveryTime": "2022-12-27T08:14:23Z",
-                    "orderPrice": 0,
-                    "orderCount": 3000,
-                    "orderRealPrice": 0,
-                    "supplierInfo": null
-                  },
-                  "batchCount": 1,
-                  "batchSizeWidth": 0,
-                  "batchSizeHeight": 0,
-                  "billId": "",
-                  "remark": ""
-                }
-              ],
-              "matInfo": {
-                "_id": "638eedb2f9039e0980fe5653",
-                "name": "太阳白卡",
+            "supplier": {
+              "calc": null,
+              "deliveryTime": "2022-12-30T08:11:03Z",
+              "orderPrice": 0,
+              "orderCount": 3000,
+              "orderRealPrice": 0,
+              "supplierInfo": {
+                "_id": "6384668e4d585ba68be6cb9f",
+                "name": "正大文博",
+                "address": "四川省成都市温江区分水村清波工业园A3号",
+                "phone": "13853360367",
                 "category": "纸张类",
-                "price": 5400,
-                "unit": "吨",
-                "norm": "250g",
-                "height": 0,
-                "width": 0,
-                "remark": "",
-                "createTime": "2022-12-06T07:22:26.375Z",
-                "updateTime": "2022-12-06T07:24:48.591Z"
-              },
-              "supplier": {
-                "calc": null,
-                "deliveryTime": "2022-12-27T08:14:23Z",
-                "orderPrice": 0,
-                "orderCount": 3000,
-                "orderRealPrice": 0,
-                "supplierInfo": null
-              },
-              "batchCount": 1,
-              "batchSizeWidth": 0,
-              "batchSizeHeight": 0,
-              "billId": "",
-              "remark": ""
+                "createTime": "2022-11-28T07:43:10.638Z",
+                "updateTime": "2022-12-06T07:19:45.089Z"
+              }
             },
-            {
-              "id": "167211384335463846f924d585ba68be6cba6",
-              "crafts": [
-                {
-                  "id": "1672113843354638471684d585ba68be6cbb00",
-                  "size": "0",
-                  "count": 1,
-                  "craftInfo": {
-                    "_id": "638471684d585ba68be6cbb0",
-                    "name": "打包",
-                    "unit": "张",
-                    "price": 0.01,
-                    "norm": "按文件要求",
-                    "remark": "",
-                    "createTime": "2022-11-28T08:29:28.343Z",
-                    "updateTime": "2022-11-28T08:29:28.343Z",
-                    "category": "打包"
-                  },
-                  "supplier": {
-                    "calc": null,
-                    "deliveryTime": "2022-12-27T04:04:10Z",
-                    "orderPrice": 0.01,
-                    "orderCount": 3000,
-                    "orderRealPrice": 30,
-                    "supplierInfo": null
-                  },
-                  "batchCount": 1,
-                  "batchSizeWidth": 0,
-                  "batchSizeHeight": 0,
-                  "billId": "",
-                  "remark": ""
-                }
-              ],
-              "matInfo": {
-                "_id": "63846f924d585ba68be6cba6",
-                "name": "E瓦",
-                "category": "瓦纸",
-                "price": 2,
-                "unit": "平方米",
-                "norm": "130+130",
-                "height": 0,
-                "width": 0,
-                "remark": "",
-                "createTime": "2022-11-28T08:21:38.722Z",
-                "updateTime": "2022-11-28T08:30:57.71Z"
-              },
-              "supplier": {
-                "calc": null,
-                "deliveryTime": "2022-12-27T04:04:10Z",
-                "orderPrice": 1.28,
-                "orderCount": 3000,
-                "orderRealPrice": 3840,
-                "supplierInfo": {
-                  "_id": "638844d151ba5b3307f8ab68",
-                  "name": "中印正隆",
-                  "address": "崇州2",
-                  "phone": "13699069388",
-                  "category": "打包",
-                  "createTime": "2022-12-01T06:08:17.095Z",
-                  "updateTime": "2022-12-01T06:08:17.095Z"
-                }
+            "batchCount": 1,
+            "batchSizeWidth": 0,
+            "batchSizeHeight": 0,
+            "billId": "63b3961000be5a99e8f7531a",
+            "remark": "3123144"
+          },
+          {
+            "id": "1672128855538638eedb2f9039e0980fe5653",
+            "crafts": [
+              {
+                "id": "167212855882663846db34d585ba68be6cba30",
+                "size": "0",
+                "count": 1,
+                "craftInfo": {
+                  "_id": "63846db34d585ba68be6cba3",
+                  "name": "哑膜",
+                  "unit": "平方米",
+                  "price": 0.49,
+                  "norm": "按文件要求",
+                  "remark": "",
+                  "createTime": "2022-11-28T08:13:39.864Z",
+                  "updateTime": "2022-11-28T08:13:39.864Z",
+                  "category": "覆膜"
+                },
+                "supplier": {
+                  "calc": null,
+                  "deliveryTime": "2022-12-27T08:14:23Z",
+                  "orderPrice": 0,
+                  "orderCount": 3000,
+                  "orderRealPrice": 0,
+                  "supplierInfo": null
+                },
+                "batchCount": 1,
+                "batchSizeWidth": 0,
+                "batchSizeHeight": 0,
+                "billId": "",
+                "remark": ""
+              }
+            ],
+            "matInfo": {
+              "_id": "638eedb2f9039e0980fe5653",
+              "name": "太阳白卡",
+              "category": "纸张类",
+              "price": 5400,
+              "unit": "吨",
+              "norm": "250g",
+              "height": 0,
+              "width": 0,
+              "remark": "",
+              "createTime": "2022-12-06T07:22:26.375Z",
+              "updateTime": "2022-12-06T07:24:48.591Z"
+            },
+            "supplier": {
+              "calc": null,
+              "deliveryTime": "2022-12-27T08:14:23Z",
+              "orderPrice": 0,
+              "orderCount": 3000,
+              "orderRealPrice": 0,
+              "supplierInfo": null
+            },
+            "batchCount": 1,
+            "batchSizeWidth": 0,
+            "batchSizeHeight": 0,
+            "billId": "",
+            "remark": ""
+          },
+          {
+            "id": "167211384335463846f924d585ba68be6cba6",
+            "crafts": [
+              {
+                "id": "1672113843354638471684d585ba68be6cbb00",
+                "size": "0",
+                "count": 1,
+                "craftInfo": {
+                  "_id": "638471684d585ba68be6cbb0",
+                  "name": "打包",
+                  "unit": "张",
+                  "price": 0.01,
+                  "norm": "按文件要求",
+                  "remark": "",
+                  "createTime": "2022-11-28T08:29:28.343Z",
+                  "updateTime": "2022-11-28T08:29:28.343Z",
+                  "category": "打包"
+                },
+                "supplier": {
+                  "calc": null,
+                  "deliveryTime": "2022-12-27T04:04:10Z",
+                  "orderPrice": 0.01,
+                  "orderCount": 3000,
+                  "orderRealPrice": 30,
+                  "supplierInfo": null
+                },
+                "batchCount": 1,
+                "batchSizeWidth": 0,
+                "batchSizeHeight": 0,
+                "billId": "",
+                "remark": ""
+              }
+            ],
+            "matInfo": {
+              "_id": "63846f924d585ba68be6cba6",
+              "name": "E瓦",
+              "category": "瓦纸",
+              "price": 2,
+              "unit": "平方米",
+              "norm": "130+130",
+              "height": 0,
+              "width": 0,
+              "remark": "",
+              "createTime": "2022-11-28T08:21:38.722Z",
+              "updateTime": "2022-11-28T08:30:57.71Z"
+            },
+            "supplier": {
+              "calc": null,
+              "deliveryTime": "2022-12-27T04:04:10Z",
+              "orderPrice": 1.28,
+              "orderCount": 3000,
+              "orderRealPrice": 3840,
+              "supplierInfo": {
+                "_id": "638844d151ba5b3307f8ab68",
+                "name": "中印正隆",
+                "address": "崇州2",
+                "phone": "13699069388",
+                "category": "打包",
+                "createTime": "2022-12-01T06:08:17.095Z",
+                "updateTime": "2022-12-01T06:08:17.095Z"
+              }
+            },
+            "batchCount": 1,
+            "batchSizeWidth": 800,
+            "batchSizeHeight": 800,
+            "billId": "63aa8f4d97479fa5562287cd",
+            "remark": ""
+          }
+        ],
+        "remark": "",
+        "totalPrice": 3870
+      },
+      {
+        "id": "1670397519144",
+        "name": "盒盖",
+        "thumbnail": "",
+        "count": 1,
+        "uv": "",
+        "uvSize": "200*300",
+        "mats": [
+          {
+            "id": "1670397527450638eedb2f9039e0980fe5653",
+            "crafts": [
+              {
+                "id": "1670397527450638471684d585ba68be6cbb00",
+                "size": "100*200",
+                "count": 1,
+                "craftInfo": {
+                  "_id": "638471684d585ba68be6cbb0",
+                  "name": "打包",
+                  "unit": "张",
+                  "price": 0.01,
+                  "norm": "按文件要求",
+                  "remark": "",
+                  "createTime": "2022-11-28T08:29:28.343Z",
+                  "updateTime": "2022-11-28T08:29:28.343Z",
+                  "category": "打包"
+                },
+                "supplier": {
+                  "calc": null,
+                  "deliveryTime": "2022-12-07T08:32:48Z",
+                  "orderPrice": 0.01,
+                  "orderCount": 3000,
+                  "orderRealPrice": 30,
+                  "supplierInfo": null
+                },
+                "batchCount": 1,
+                "batchSizeWidth": 100,
+                "batchSizeHeight": 200,
+                "billId": "",
+                "remark": ""
               },
-              "batchCount": 1,
-              "batchSizeWidth": 800,
-              "batchSizeHeight": 800,
-              "billId": "63aa8f4d97479fa5562287cd",
-              "remark": ""
-            }
-          ],
-          "remark": "",
-          "totalPrice": 3870
-        },
-        {
-          "id": "1670397519144",
-          "name": "盒盖",
-          "thumbnail": "",
-          "count": 1,
-          "uv": "",
-          "uvSize": "200*300",
-          "mats": [
-            {
-              "id": "1670397527450638eedb2f9039e0980fe5653",
-              "crafts": [
-                {
-                  "id": "1670397527450638471684d585ba68be6cbb00",
-                  "size": "100*200",
-                  "count": 1,
-                  "craftInfo": {
-                    "_id": "638471684d585ba68be6cbb0",
-                    "name": "打包",
-                    "unit": "张",
-                    "price": 0.01,
-                    "norm": "按文件要求",
-                    "remark": "",
-                    "createTime": "2022-11-28T08:29:28.343Z",
-                    "updateTime": "2022-11-28T08:29:28.343Z",
-                    "category": "打包"
-                  },
-                  "supplier": {
-                    "calc": null,
-                    "deliveryTime": "2022-12-07T08:32:48Z",
-                    "orderPrice": 0.01,
-                    "orderCount": 3000,
-                    "orderRealPrice": 30,
-                    "supplierInfo": null
-                  },
-                  "batchCount": 1,
-                  "batchSizeWidth": 100,
-                  "batchSizeHeight": 200,
-                  "billId": "",
-                  "remark": ""
+              {
+                "id": "1670397527450638470d24d585ba68be6cbaf1",
+                "size": "0",
+                "count": 1,
+                "craftInfo": {
+                  "_id": "638470d24d585ba68be6cbaf",
+                  "name": "粘盒",
+                  "unit": "张",
+                  "price": 0.08,
+                  "norm": "按文件要求",
+                  "remark": "",
+                  "createTime": "2022-11-28T08:26:58.869Z",
+                  "updateTime": "2022-11-28T08:27:24.914Z",
+                  "category": "粘盒"
                 },
-                {
-                  "id": "1670397527450638470d24d585ba68be6cbaf1",
-                  "size": "0",
-                  "count": 1,
-                  "craftInfo": {
-                    "_id": "638470d24d585ba68be6cbaf",
-                    "name": "粘盒",
-                    "unit": "张",
-                    "price": 0.08,
-                    "norm": "按文件要求",
-                    "remark": "",
-                    "createTime": "2022-11-28T08:26:58.869Z",
-                    "updateTime": "2022-11-28T08:27:24.914Z",
-                    "category": "粘盒"
-                  },
-                  "supplier": {
-                    "calc": null,
-                    "deliveryTime": "2022-12-07T08:32:48Z",
-                    "orderPrice": 0.08,
-                    "orderCount": 3000,
-                    "orderRealPrice": 240,
-                    "supplierInfo": null
-                  },
-                  "batchCount": 1,
-                  "batchSizeWidth": 0,
-                  "batchSizeHeight": 0,
-                  "billId": "",
-                  "remark": ""
-                }
-              ],
-              "matInfo": {
-                "_id": "638eedb2f9039e0980fe5653",
-                "name": "太阳白卡",
+                "supplier": {
+                  "calc": null,
+                  "deliveryTime": "2022-12-07T08:32:48Z",
+                  "orderPrice": 0.08,
+                  "orderCount": 3000,
+                  "orderRealPrice": 240,
+                  "supplierInfo": null
+                },
+                "batchCount": 1,
+                "batchSizeWidth": 0,
+                "batchSizeHeight": 0,
+                "billId": "",
+                "remark": ""
+              }
+            ],
+            "matInfo": {
+              "_id": "638eedb2f9039e0980fe5653",
+              "name": "太阳白卡",
+              "category": "纸张类",
+              "price": 5400,
+              "unit": "吨",
+              "norm": "250g",
+              "height": 0,
+              "width": 0,
+              "remark": "",
+              "createTime": "2022-12-06T07:22:26.375Z",
+              "updateTime": "2022-12-06T07:24:48.591Z"
+            },
+            "supplier": {
+              "calc": null,
+              "deliveryTime": "2022-12-07T08:32:48Z",
+              "orderPrice": 0.081,
+              "orderCount": 3000,
+              "orderRealPrice": 243,
+              "supplierInfo": {
+                "_id": "6384668e4d585ba68be6cb9f",
+                "name": "正大文博",
+                "address": "四川省成都市温江区分水村清波工业园A3号",
+                "phone": "13853360367",
                 "category": "纸张类",
-                "price": 5400,
-                "unit": "吨",
-                "norm": "250g",
-                "height": 0,
-                "width": 0,
-                "remark": "",
-                "createTime": "2022-12-06T07:22:26.375Z",
-                "updateTime": "2022-12-06T07:24:48.591Z"
-              },
-              "supplier": {
-                "calc": null,
-                "deliveryTime": "2022-12-07T08:32:48Z",
-                "orderPrice": 0.081,
-                "orderCount": 3000,
-                "orderRealPrice": 243,
-                "supplierInfo": {
-                  "_id": "6384668e4d585ba68be6cb9f",
-                  "name": "正大文博",
-                  "address": "四川省成都市温江区分水村清波工业园A3号",
-                  "phone": "13853360367",
-                  "category": "纸张类",
-                  "createTime": "2022-11-28T07:43:10.638Z",
-                  "updateTime": "2022-12-06T07:19:45.089Z"
-                }
-              },
-              "batchCount": 1,
-              "batchSizeWidth": 200,
-              "batchSizeHeight": 300,
-              "billId": "63915142af181d9ba5d87aaa",
-              "remark": ""
-            }
-          ],
-          "remark": "",
-          "totalPrice": 513
-        }
-      ],
-      "createTime": "2022-12-06T09:51:10.885Z",
-      "updateTime": "2022-12-27T08:14:19.213Z"
-    },
-    "thumbnail": "",
-    "createUser": "31231",
-    "total": 3000,
-    "status": "process",
-    "totalPrice": 4383,
-    "updateTime": "2022-12-27T08:14:26.563Z",
-    "createTime": "2022-12-07T08:32:55.92Z"
+                "createTime": "2022-11-28T07:43:10.638Z",
+                "updateTime": "2022-12-06T07:19:45.089Z"
+              }
+            },
+            "batchCount": 1,
+            "batchSizeWidth": 200,
+            "batchSizeHeight": 300,
+            "billId": "63915142af181d9ba5d87aaa",
+            "remark": ""
+          }
+        ],
+        "remark": "",
+        "totalPrice": 513
+      }
+    ],
+    "createTime": "2022-12-06T09:51:10.885Z",
+    "updateTime": "2022-12-27T08:14:19.213Z"
   },
-  "errorDesc": ""
+  "thumbnail": "",
+  "createUser": "31231",
+  "total": 3000,
+  "status": "process",
+  "totalPrice": 4383,
+  "updateTime": "2023-01-03T04:08:40.653Z",
+  "createTime": "2022-12-07T08:32:55.92Z"
 }

+ 20 - 22
boxcost/go.mod

@@ -12,32 +12,33 @@ require (
 	github.com/natefinch/lumberjack v2.0.0+incompatible
 	github.com/spf13/viper v1.9.0
 	github.com/xuri/excelize/v2 v2.6.1
-	go.mongodb.org/mongo-driver v1.9.1
+	go.mongodb.org/mongo-driver v1.11.1
 	go.uber.org/dig v1.12.0
 	go.uber.org/zap v1.17.0
 	infish.cn/comm v0.0.0
 )
 
 require (
-	github.com/cespare/xxhash/v2 v2.1.2 // indirect
+	github.com/cenkalti/backoff/v4 v4.2.0 // indirect
+	github.com/cespare/xxhash/v2 v2.2.0 // indirect
 	github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
 	github.com/fsnotify/fsnotify v1.5.1 // indirect
 	github.com/gin-contrib/sse v0.1.0 // indirect
 	github.com/go-playground/locales v0.13.0 // indirect
 	github.com/go-playground/universal-translator v0.17.0 // indirect
 	github.com/go-playground/validator/v10 v10.4.1 // indirect
-	github.com/go-stack/stack v1.8.0 // indirect
 	github.com/golang-jwt/jwt/v4 v4.1.0 // indirect
+	github.com/golang-migrate/migrate/v4 v4.15.2 // indirect
 	github.com/golang/protobuf v1.5.2 // indirect
-	github.com/golang/snappy v0.0.3 // indirect
-	github.com/google/go-cmp v0.5.7 // indirect
+	github.com/golang/snappy v0.0.4 // indirect
 	github.com/gorilla/context v1.1.1 // indirect
 	github.com/gorilla/securecookie v1.1.1 // indirect
 	github.com/gorilla/sessions v1.1.3 // indirect
+	github.com/hashicorp/errwrap v1.1.0 // indirect
+	github.com/hashicorp/go-multierror v1.1.1 // indirect
 	github.com/hashicorp/hcl v1.0.0 // indirect
 	github.com/json-iterator/go v1.1.12 // indirect
-	github.com/klauspost/compress v1.14.4 // indirect
-	github.com/kr/text v0.2.0 // indirect
+	github.com/klauspost/compress v1.15.13 // indirect
 	github.com/leodido/go-urn v1.2.0 // indirect
 	github.com/magiconair/properties v1.8.5 // indirect
 	github.com/mattn/go-isatty v0.0.12 // indirect
@@ -46,11 +47,11 @@ require (
 	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
 	github.com/modern-go/reflect2 v1.0.2 // indirect
 	github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
+	github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
 	github.com/nats-io/jwt/v2 v2.3.0 // indirect
-	github.com/nats-io/nats.go v1.13.1-0.20220308171302-2f2f6968e98d // indirect
+	github.com/nats-io/nats.go v1.22.1 // indirect
 	github.com/nats-io/nkeys v0.3.0 // indirect
 	github.com/nats-io/nuid v1.0.1 // indirect
-	github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
 	github.com/pelletier/go-toml v1.9.4 // indirect
 	github.com/pkg/errors v0.9.1 // indirect
 	github.com/richardlehane/mscfb v1.0.4 // indirect
@@ -62,23 +63,20 @@ require (
 	github.com/subosito/gotenv v1.2.0 // indirect
 	github.com/ugorji/go/codec v1.1.7 // indirect
 	github.com/xdg-go/pbkdf2 v1.0.0 // indirect
-	github.com/xdg-go/scram v1.0.2 // indirect
-	github.com/xdg-go/stringprep v1.0.2 // indirect
+	github.com/xdg-go/scram v1.1.2 // indirect
+	github.com/xdg-go/stringprep v1.0.4 // indirect
 	github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 // indirect
 	github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 // indirect
-	github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
-	go.uber.org/atomic v1.7.0 // indirect
+	github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
+	go.uber.org/atomic v1.10.0 // indirect
 	go.uber.org/multierr v1.6.0 // indirect
-	golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8 // indirect
-	golang.org/x/net v0.0.0-20220812174116-3211cb980234 // indirect
-	golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
-	golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 // indirect
-	golang.org/x/text v0.3.7 // indirect
-	golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 // indirect
-	google.golang.org/protobuf v1.28.0 // indirect
-	gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
+	golang.org/x/crypto v0.4.0 // indirect
+	golang.org/x/net v0.4.0 // indirect
+	golang.org/x/sync v0.1.0 // indirect
+	golang.org/x/sys v0.3.0 // indirect
+	golang.org/x/text v0.5.0 // indirect
+	google.golang.org/protobuf v1.28.1 // indirect
 	gopkg.in/ini.v1 v1.66.6 // indirect
-	gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
 	gopkg.in/yaml.v2 v2.4.0 // indirect
 )
 

File diff suppressed because it is too large
+ 808 - 12
boxcost/go.sum


Some files were not shown because too many files changed in this diff